patch-2.4.21 linux-2.4.21/arch/ia64/sn/fakeprom/fw-emu.c

Next file: linux-2.4.21/arch/ia64/sn/fakeprom/klgraph_init.c
Previous file: linux-2.4.21/arch/ia64/sn/fakeprom/fpromasm.S
Back to the patch index
Back to the overall index

diff -urN linux-2.4.20/arch/ia64/sn/fakeprom/fw-emu.c linux-2.4.21/arch/ia64/sn/fakeprom/fw-emu.c
@@ -46,10 +46,26 @@
 #include <asm/sn/sn2/addrs.h>
 #include <asm/sn/sn2/shub_mmr.h>
 #endif
-#include <asm/acpi-ext.h>
+#include <linux/acpi.h>
 #include "fpmem.h"
 
-#define zzACPI_1_0	1		/* Include ACPI 1.0 tables */
+#define RSDP_NAME               "RSDP"
+#define RSDP_SIG                "RSD PTR "  /* RSDT Pointer signature */
+#define APIC_SIG                "APIC"      /* Multiple APIC Description Table */
+#define DSDT_SIG                "DSDT"      /* Differentiated System Description Table */
+#define FADT_SIG                "FACP"      /* Fixed ACPI Description Table */
+#define FACS_SIG                "FACS"      /* Firmware ACPI Control Structure */
+#define PSDT_SIG                "PSDT"      /* Persistent System Description Table */
+#define RSDT_SIG                "RSDT"      /* Root System Description Table */
+#define XSDT_SIG                "XSDT"      /* Extended  System Description Table */
+#define SSDT_SIG                "SSDT"      /* Secondary System Description Table */
+#define SBST_SIG                "SBST"      /* Smart Battery Specification Table */
+#define SPIC_SIG                "SPIC"      /* IOSAPIC table */
+#define SRAT_SIG                "SRAT"      /* SRAT table */
+#define SLIT_SIG                "SLIT"      /* SLIT table */
+#define BOOT_SIG                "BOOT"      /* Boot table */
+#define ACPI_SRAT_REVISION 1
+#define ACPI_SLIT_REVISION 1
 
 #define OEMID			"SGI"
 #ifdef CONFIG_IA64_SGI_SN1
@@ -77,11 +93,7 @@
 #define CPUS_PER_FSB		2
 #define CPUS_PER_FSB_MASK	(CPUS_PER_FSB-1)
 
-#ifdef ACPI_1_0
-#define NUM_EFI_DESCS		3
-#else
 #define NUM_EFI_DESCS		2
-#endif
 
 #define RSDP_CHECKSUM_LENGTH	20
 
@@ -139,22 +151,16 @@
 		    + sizeof(struct ia64_sal_systab)
 		    + sizeof(struct ia64_sal_desc_entry_point)
 		    + sizeof(struct ia64_sal_desc_ap_wakeup)
-#ifdef ACPI_1_0
-		    + sizeof(acpi_rsdp_t)
-		    + sizeof(acpi_rsdt_t)
-		    + sizeof(acpi_sapic_t)
-		    + MAX_LSAPICS*(sizeof(acpi_entry_lsapic_t))
-#endif
-		    + sizeof(acpi20_rsdp_t)
-		    + sizeof(acpi_xsdt_t)
-		    + sizeof(acpi_slit_t)
+		    + sizeof(struct acpi20_table_rsdp)
+		    + sizeof(struct acpi_table_xsdt)
+		    + sizeof(struct acpi_table_slit)
 		    +   MAX_SN_NODES*MAX_SN_NODES+8
-		    + sizeof(acpi_madt_t)
+		    + sizeof(struct acpi_table_madt)
 		    +   16*MAX_CPUS
 		    + (1+8*MAX_SN_NODES)*(sizeof(efi_memory_desc_t))
-		    + sizeof(acpi_srat_t)
-		    +   MAX_CPUS*sizeof(srat_cpu_affinity_t)
-		    +   MAX_SN_NODES*sizeof(srat_memory_affinity_t)
+		    + sizeof(struct acpi_table_srat)
+		    +   MAX_CPUS*sizeof(struct acpi_table_processor_affinity)
+		    +   MAX_SN_NODES*sizeof(struct acpi_table_memory_affinity)
 		    + sizeof(ia64_sal_desc_ptc_t) +
 		    + MAX_SN_NODES*sizeof(ia64_sal_ptc_domain_info_t) +
 		    + MAX_CPUS*sizeof(ia64_sal_ptc_domain_proc_entry_t) +
@@ -280,6 +286,7 @@
 	} else if (index == SAL_GET_STATE_INFO) {
 		;
 	} else if (index == SAL_GET_STATE_INFO_SIZE) {
+		r9 = 10000;
 		;
 	} else if (index == SAL_CLEAR_STATE_INFO) {
 		;
@@ -334,6 +341,8 @@
 		status = -1;
 	} else if (index == SN_SAL_CONSOLE_POLL) {
 		status = -1;
+	} else if (index == SN_SAL_SYSCTL_IOBRICK_MODULE_GET) {
+		status = -1;
 	} else {
 		status = -1;
 	}
@@ -402,7 +411,7 @@
 }
 
 void
-acpi_table_init(acpi_desc_table_hdr_t *p, char *sig, int siglen, int revision, int oem_revision)
+acpi_table_initx(struct acpi_table_header *p, char *sig, int siglen, int revision, int oem_revision)
 {
 	memcpy(p->signature, sig, siglen);
 	memcpy(p->oem_id, OEMID, 6);
@@ -410,12 +419,12 @@
 	memcpy(p->oem_table_id+4, PRODUCT, 4);
 	p->revision = revision;
 	p->oem_revision = (revision<<16) + oem_revision;
-	p->creator_id = 1;
-	p->creator_revision = 1;
+	memcpy(p->asl_compiler_id, "FPRM", 4);
+	p->asl_compiler_revision = 1;
 }
 
 void
-acpi_checksum(acpi_desc_table_hdr_t *p, int length)
+acpi_checksum(struct acpi_table_header *p, int length)
 {
 	u8	*cp, *cpe, checksum;
 
@@ -428,16 +437,22 @@
 }
 
 void
-acpi_checksum_rsdp20(acpi20_rsdp_t *p, int length)
+acpi_checksum_rsdp20(struct acpi20_table_rsdp *p, int length)
 {
 	u8	*cp, *cpe, checksum;
 
 	p->checksum = 0;
+	p->ext_checksum = 0;
 	p->length = length;
 	checksum = 0;
-	for (cp=(u8*)p, cpe=cp+RSDP_CHECKSUM_LENGTH; cp<cpe; cp++)
+	for (cp=(u8*)p, cpe=cp+20; cp<cpe; cp++)
 		checksum += *cp;
 	p->checksum = -checksum;
+
+	checksum = 0;
+	for (cp=(u8*)p, cpe=cp+length; cp<cpe; cp++)
+		checksum += *cp;
+	p->ext_checksum = -checksum;
 }
 
 int
@@ -462,21 +477,15 @@
 	static ia64_sal_desc_ptc_t *sal_ptc;
 	static ia64_sal_ptc_domain_info_t *sal_ptcdi;
 	static ia64_sal_ptc_domain_proc_entry_t *sal_ptclid;
-#ifdef ACPI_1_0
-	static acpi_rsdp_t *acpi_rsdp;
-	static acpi_rsdt_t *acpi_rsdt;
-	static acpi_sapic_t *acpi_sapic;
-	static acpi_entry_lsapic_t *acpi_lsapic;
-#endif
-	static acpi20_rsdp_t *acpi20_rsdp;
-	static acpi_xsdt_t *acpi_xsdt;
-	static acpi_slit_t *acpi_slit;
-	static acpi_madt_t *acpi_madt;
-	static acpi20_entry_lsapic_t *lsapic20;
+	static struct acpi20_table_rsdp *acpi20_rsdp;
+	static struct acpi_table_xsdt *acpi_xsdt;
+	static struct acpi_table_slit *acpi_slit;
+	static struct acpi_table_madt *acpi_madt;
+	static struct acpi_table_lsapic *lsapic20;
 	static struct ia64_sal_systab *sal_systab;
-	static acpi_srat_t *acpi_srat;
-	static srat_cpu_affinity_t *srat_cpu_affinity;
-	static srat_memory_affinity_t *srat_memory_affinity;
+	static struct acpi_table_srat *acpi_srat;
+	static struct acpi_table_processor_affinity *srat_cpu_affinity;
+	static struct acpi_table_memory_affinity *srat_memory_affinity;
 	static efi_memory_desc_t *efi_memmap, *md;
 	static unsigned long *pal_desc, *sal_desc;
 	static struct ia64_sal_desc_entry_point *sal_ed;
@@ -525,16 +534,10 @@
 	acpi_xsdt   = (void *) cp; cp += ALIGN8(sizeof(*acpi_xsdt) + 64); 
 			/* save space for more OS defined table pointers. */
 
-#ifdef ACPI_1_0
-	acpi_rsdp   = (void *) cp; cp += ALIGN8(sizeof(*acpi_rsdp));
-	acpi_rsdt   = (void *) cp; cp += ALIGN8(sizeof(*acpi_rsdt));
-	acpi_sapic  = (void *) cp; cp += sizeof(*acpi_sapic);
-	acpi_lsapic = (void *) cp; cp += num_cpus*sizeof(*acpi_lsapic);
-#endif
 	acpi_slit   = (void *) cp; cp += ALIGN8(sizeof(*acpi_slit) + 8 + (max_nasid+1)*(max_nasid+1));
-	acpi_madt   = (void *) cp; cp += ALIGN8(sizeof(*acpi_madt) + 8 * num_cpus+ 8);
-	acpi_srat   = (void *) cp; cp += ALIGN8(sizeof(acpi_srat_t));
-	cp         += sizeof(srat_cpu_affinity_t)*num_cpus + sizeof(srat_memory_affinity_t)*num_nodes;
+	acpi_madt   = (void *) cp; cp += ALIGN8(sizeof(*acpi_madt) + sizeof(struct acpi_table_lsapic) * (num_cpus+1));
+	acpi_srat   = (void *) cp; cp += ALIGN8(sizeof(struct acpi_table_srat));
+	cp         += sizeof(struct acpi_table_processor_affinity)*num_cpus + sizeof(struct acpi_table_memory_affinity)*num_nodes;
 	vendor 	    = (char *) cp; cp += ALIGN8(40);
 	efi_memmap  = (void *) cp; cp += ALIGN8(8*32*sizeof(*efi_memmap));
 	sal_ptcdi   = (void *) cp; cp += ALIGN8(CPUS_PER_FSB*(1+num_nodes)*sizeof(*sal_ptcdi));
@@ -585,11 +588,6 @@
 	efi_tables->guid = SAL_SYSTEM_TABLE_GUID;
 	efi_tables->table = __fwtab_pa(base_nasid, sal_systab);
 	efi_tables++;
-#ifdef ACPI_1_0
-	efi_tables->guid = ACPI_TABLE_GUID;
-	efi_tables->table = __fwtab_pa(base_nasid, acpi_rsdp);
-	efi_tables++;
-#endif
 	efi_tables->guid = ACPI_20_TABLE_GUID;
 	efi_tables->table = __fwtab_pa(base_nasid, acpi20_rsdp);
 	efi_tables++;
@@ -600,65 +598,32 @@
 	fix_function_pointer(&efi_reset_system);
 	fix_function_pointer(&efi_set_virtual_address_map);
 
-#ifdef ACPI_1_0
-	/* fill in the ACPI system table - has a pointer to the ACPI table header */
-	memcpy(acpi_rsdp->signature, "RSD PTR ", 8);
-	acpi_rsdp->rsdt = (struct acpi_rsdt*)__fwtab_pa(base_nasid, acpi_rsdt);
-
-	acpi_table_init(&acpi_rsdt->header, ACPI_RSDT_SIG, ACPI_RSDT_SIG_LEN, 1, 1);
-	acpi_rsdt->header.length = sizeof(acpi_rsdt_t);
-	acpi_rsdt->entry_ptrs[0] = __fwtab_pa(base_nasid, acpi_sapic);
-
-	memcpy(acpi_sapic->header.signature, "SPIC ", 4);
-	acpi_sapic->header.length = sizeof(acpi_sapic_t)+num_cpus*sizeof(acpi_entry_lsapic_t);
-
-	for (cnode=0; cnode<num_nodes; cnode++) {
-		nasid = GetNasid(cnode);
-		for(cpu=0; cpu<CPUS_PER_NODE; cpu++) {
-			if (!IsCpuPresent(cnode, cpu))
-				continue;
-			acpi_lsapic->type = ACPI_ENTRY_LOCAL_SAPIC;
-			acpi_lsapic->length = sizeof(acpi_entry_lsapic_t);
-			acpi_lsapic->acpi_processor_id = cnode*4+cpu;
-			acpi_lsapic->flags = LSAPIC_ENABLED|LSAPIC_PRESENT;
-#if defined(CONFIG_IA64_SGI_SN1)
-			acpi_lsapic->eid = cpu;
-			acpi_lsapic->id = nasid;
-#else
-			acpi_lsapic->eid = nasid&0xffff;
-			acpi_lsapic->id = (cpu<<4) | (nasid>>16);
-#endif
-			acpi_lsapic++;
-		}
-	}
-#endif
-
 
 	/* fill in the ACPI20 system table - has a pointer to the ACPI table header */
 	memcpy(acpi20_rsdp->signature, "RSD PTR ", 8);
-	acpi20_rsdp->xsdt = (struct acpi_xsdt*)__fwtab_pa(base_nasid, acpi_xsdt);
+	acpi20_rsdp->xsdt_address = (u64)__fwtab_pa(base_nasid, acpi_xsdt);
 	acpi20_rsdp->revision = 2;
-	acpi_checksum_rsdp20(acpi20_rsdp, sizeof(acpi20_rsdp_t));
+	acpi_checksum_rsdp20(acpi20_rsdp, sizeof(struct acpi20_table_rsdp));
 
 	/* Set up the XSDT table  - contains pointers to the other ACPI tables */
-	acpi_table_init(&acpi_xsdt->header, ACPI_XSDT_SIG, ACPI_XSDT_SIG_LEN, 1, 1);
-	acpi_xsdt->entry_ptrs[0] = __fwtab_pa(base_nasid, acpi_madt);
-	acpi_xsdt->entry_ptrs[1] = __fwtab_pa(base_nasid, acpi_slit);
-	acpi_xsdt->entry_ptrs[2] = __fwtab_pa(base_nasid, acpi_srat);
-	acpi_checksum(&acpi_xsdt->header, sizeof(acpi_xsdt_t) + 16);
-
-	/* Set up the MADT table */
-	acpi_table_init(&acpi_madt->header, ACPI_MADT_SIG, ACPI_MADT_SIG_LEN, 1, 1);
-	lsapic20 = (acpi20_entry_lsapic_t*) (acpi_madt + 1);
+	acpi_table_initx(&acpi_xsdt->header, XSDT_SIG, 4, 1, 1);
+	acpi_xsdt->entry[0] = __fwtab_pa(base_nasid, acpi_madt);
+	acpi_xsdt->entry[1] = __fwtab_pa(base_nasid, acpi_slit);
+	acpi_xsdt->entry[2] = __fwtab_pa(base_nasid, acpi_srat);
+	acpi_checksum(&acpi_xsdt->header, sizeof(struct acpi_table_xsdt) + 16);
+
+	/* Set up the APIC table */
+	acpi_table_initx(&acpi_madt->header, APIC_SIG, 4, 1, 1);
+	lsapic20 = (struct acpi_table_lsapic*) (acpi_madt + 1);
 	for (cnode=0; cnode<num_nodes; cnode++) {
 		nasid = GetNasid(cnode);
 		for(cpu=0; cpu<CPUS_PER_NODE; cpu++) {
 			if (!IsCpuPresent(cnode, cpu))
 				continue;
-			lsapic20->type = ACPI20_ENTRY_LOCAL_SAPIC;
-			lsapic20->length = sizeof(acpi_entry_lsapic_t);
-			lsapic20->acpi_processor_id = cnode*4+cpu;
-			lsapic20->flags = LSAPIC_ENABLED|LSAPIC_PRESENT;
+			lsapic20->header.type = ACPI_MADT_LSAPIC;
+			lsapic20->header.length = sizeof(struct acpi_table_lsapic);
+			lsapic20->acpi_id = cnode*4+cpu;
+			lsapic20->flags.enabled = 1;
 #if defined(CONFIG_IA64_SGI_SN1)
 			lsapic20->eid = cpu;
 			lsapic20->id = nasid;
@@ -666,20 +631,20 @@
 			lsapic20->eid = nasid&0xffff;
 			lsapic20->id = (cpu<<4) | (nasid>>16);
 #endif
-			lsapic20 = (acpi20_entry_lsapic_t*) ((long)lsapic20+sizeof(acpi_entry_lsapic_t));
+			lsapic20 = (struct acpi_table_lsapic*) ((long)lsapic20+sizeof(struct acpi_table_lsapic));
 		}
 	}
 	acpi_checksum(&acpi_madt->header, (char*)lsapic20 - (char*)acpi_madt);
 
 	/* Set up the SRAT table */
-	acpi_table_init(&acpi_srat->header, ACPI_SRAT_SIG, ACPI_SRAT_SIG_LEN, ACPI_SRAT_REVISION, 1);
+	acpi_table_initx(&acpi_srat->header, SRAT_SIG, 4, ACPI_SRAT_REVISION, 1);
 	ptr = acpi_srat+1;
 	for (cnode=0; cnode<num_nodes; cnode++) {
 		nasid = GetNasid(cnode);
 		srat_memory_affinity = ptr;
 		ptr = srat_memory_affinity+1;
-		srat_memory_affinity->type = SRAT_MEMORY_STRUCTURE;
-		srat_memory_affinity->length = sizeof(srat_memory_affinity_t);
+		srat_memory_affinity->header.type = ACPI_SRAT_MEMORY_AFFINITY;
+		srat_memory_affinity->header.length = sizeof(struct acpi_table_memory_affinity);
 		srat_memory_affinity->proximity_domain = PROXIMITY_DOMAIN(nasid);
 		srat_memory_affinity->base_addr_lo = 0;
 		srat_memory_affinity->length_lo = 0;
@@ -691,7 +656,7 @@
 		srat_memory_affinity->length_hi = SN2_NODE_SIZE>>32;
 #endif
 		srat_memory_affinity->memory_type = ACPI_ADDRESS_RANGE_MEMORY;
-		srat_memory_affinity->flags = SRAT_MEMORY_FLAGS_ENABLED;
+		srat_memory_affinity->flags.enabled = 1;
 	}
 
 	for (cnode=0; cnode<num_nodes; cnode++) {
@@ -701,15 +666,15 @@
 				continue;
 			srat_cpu_affinity = ptr;
 			ptr = srat_cpu_affinity + 1;
-			srat_cpu_affinity->type = SRAT_CPU_STRUCTURE;
-			srat_cpu_affinity->length = sizeof(srat_cpu_affinity_t);
+			srat_cpu_affinity->header.type = ACPI_SRAT_PROCESSOR_AFFINITY;
+			srat_cpu_affinity->header.length = sizeof(struct acpi_table_processor_affinity);
 			srat_cpu_affinity->proximity_domain = PROXIMITY_DOMAIN(nasid);
-			srat_cpu_affinity->flags = SRAT_CPU_FLAGS_ENABLED;
+			srat_cpu_affinity->flags.enabled = 1;
 #if defined(CONFIG_IA64_SGI_SN1)
 			srat_cpu_affinity->apic_id = nasid;
-			srat_cpu_affinity->local_sapic_eid = cpu;
+			srat_cpu_affinity->lsapic_eid = cpu;
 #else
-			srat_cpu_affinity->local_sapic_eid = nasid&0xffff;
+			srat_cpu_affinity->lsapic_eid = nasid&0xffff;
 			srat_cpu_affinity->apic_id = (cpu<<4) | (nasid>>16);
 #endif
 		}
@@ -718,9 +683,9 @@
 
 
 	/* Set up the SLIT table */
-	acpi_table_init(&acpi_slit->header, ACPI_SLIT_SIG, ACPI_SLIT_SIG_LEN, ACPI_SLIT_REVISION, 1);
+	acpi_table_initx(&acpi_slit->header, SLIT_SIG, 4, ACPI_SLIT_REVISION, 1);
 	acpi_slit->localities = PROXIMITY_DOMAIN(max_nasid)+1;
-	cp=acpi_slit->entries;
+	cp=acpi_slit->entry;
 	memset(cp, 255, acpi_slit->localities*acpi_slit->localities);
 
 	for (i=0; i<=max_nasid; i++)
@@ -728,7 +693,7 @@
 			if (nasid_present(i) && nasid_present(j))
 				*(cp+PROXIMITY_DOMAIN(i)*acpi_slit->localities+PROXIMITY_DOMAIN(j)) = 10 + MIN(254, 5*ABS(i-j));
 
-	cp = acpi_slit->entries + acpi_slit->localities*acpi_slit->localities;
+	cp = acpi_slit->entry + acpi_slit->localities*acpi_slit->localities;
 	acpi_checksum(&acpi_slit->header, cp - (char*)acpi_slit);
 
 
@@ -738,6 +703,8 @@
 	sal_systab->sal_rev_minor = 1;
 	sal_systab->sal_rev_major = 0;
 	sal_systab->entry_count = 3;
+	sal_systab->sal_b_rev_major = 0x1; /* set the SN SAL rev to */
+	sal_systab->sal_b_rev_minor = 0x0; /* 1.00 */
 
 	strcpy(sal_systab->oem_id, "SGI");
 	strcpy(sal_systab->product_id, "SN1");
@@ -792,11 +759,6 @@
 	 * table. We dont build enough table & the kernel aborts.
 	 * Note that the PROM hasd thhhe same problem!!
 	 */
-#ifdef DOESNT_WORK
-	for (checksum=0, cp=(char*)acpi_rsdp, cpe=cp+RSDP_CHECKSUM_LENGTH; cp<cpe; ++cp)
-		checksum += *cp;
-	acpi_rsdp->checksum = -checksum;
-#endif
 
 	md = &efi_memmap[0];
 	num_memmd = build_efi_memmap((void *)md, mdsize) ;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)