Author: myles Date: Wed Mar 24 23:02:53 2010 New Revision: 5286 URL: https://tracker.coreboot.org/trac/coreboot/changeset/5286
Log: Get rid of type-punned pointer errors.
Defining AmlCode differently in different source files is a bit ugly... Creating a void * to do the casting is not exactly beautiful either...
Signed-off-by: Myles Watson mylesgw@gmail.com Acked-by: Stefan Reinauer stepan@coresystems.de
Modified: trunk/src/mainboard/amd/dbm690t/acpi_tables.c trunk/src/mainboard/amd/mahogany/acpi_tables.c trunk/src/mainboard/amd/mahogany_fam10/acpi_tables.c trunk/src/mainboard/amd/pistachio/acpi_tables.c trunk/src/mainboard/amd/serengeti_cheetah/acpi_tables.c trunk/src/mainboard/amd/serengeti_cheetah_fam10/acpi_tables.c trunk/src/mainboard/asus/a8v-e_se/acpi_tables.c trunk/src/mainboard/asus/m2v-mx_se/acpi_tables.c trunk/src/mainboard/gigabyte/m57sli/acpi_tables.c trunk/src/mainboard/intel/d945gclf/acpi_tables.c trunk/src/mainboard/intel/eagleheights/acpi_tables.c trunk/src/mainboard/iwill/dk8_htx/acpi_tables.c trunk/src/mainboard/kontron/986lcd-m/acpi_tables.c trunk/src/mainboard/kontron/kt690/acpi_tables.c trunk/src/mainboard/msi/ms9652_fam10/acpi_tables.c trunk/src/mainboard/roda/rk886ex/acpi_tables.c trunk/src/mainboard/technexion/tim5690/acpi_tables.c trunk/src/mainboard/technexion/tim8690/acpi_tables.c trunk/src/mainboard/tyan/s2891/acpi_tables.c trunk/src/mainboard/tyan/s2892/acpi_tables.c trunk/src/mainboard/tyan/s2895/acpi_tables.c trunk/src/mainboard/via/epia-m/acpi_tables.c trunk/src/mainboard/via/epia-m700/acpi_tables.c trunk/src/mainboard/via/epia-n/acpi_tables.c trunk/src/mainboard/via/vt8454c/acpi_tables.c trunk/src/northbridge/amd/amdfam10/amdfam10_acpi.c
Modified: trunk/src/mainboard/amd/dbm690t/acpi_tables.c ============================================================================== --- trunk/src/mainboard/amd/dbm690t/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/amd/dbm690t/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -57,13 +57,13 @@ } #endif
-extern u8 AmlCode[]; +extern const acpi_header_t AmlCode;
#if CONFIG_ACPI_SSDTX_NUM >= 1 -extern u8 AmlCode_ssdt2[]; -extern u8 AmlCode_ssdt3[]; -extern u8 AmlCode_ssdt4[]; -extern u8 AmlCode_ssdt5[]; +extern const acpi_header_t AmlCode_ssdt2; +extern const acpi_header_t AmlCode_ssdt3; +extern const acpi_header_t AmlCode_ssdt4; +extern const acpi_header_t AmlCode_ssdt5; #endif
#define IO_APIC_ADDR 0xfec00000UL @@ -219,25 +219,24 @@ ssdtx = (acpi_header_t *) current; switch (sysconf.hcid[i]) { case 1: /* 8132 */ - p = AmlCode_ssdt2; + p = &AmlCode_ssdt2; break; case 2: /* 8151 */ - p = AmlCode_ssdt3; + p = &AmlCode_ssdt3; break; case 3: /* 8131 */ - p = AmlCode_ssdt4; + p = &AmlCode_ssdt4; break; default: /* HTX no io apic */ - p = AmlCode_ssdt5; + p = &AmlCode_ssdt5; break; } - current += ((acpi_header_t *) p)->length; - memcpy((void *)ssdtx, (void *)p, ((acpi_header_t *) p)->length); + current += p->length; + memcpy((void *)ssdtx, p, p->length); update_ssdtx((void *)ssdtx, i); ssdtx->checksum = 0; - ssdtx->checksum = - acpi_checksum((u8 *)ssdtx, ssdtx->length); + ssdtx->checksum = acpi_checksum((u8 *)ssdtx, ssdtx->length); acpi_add_table(rsdp, ssdtx); } #endif @@ -250,10 +249,9 @@
/* DSDT */ printk(BIOS_DEBUG, "ACPI: * DSDT\n"); - dsdt = (acpi_header_t *) current; - memcpy((void *)dsdt, (void *)AmlCode, - ((acpi_header_t *) AmlCode)->length); - current += dsdt->length; + dsdt = (acpi_header_t *)current; + current += AmlCode.length; + memcpy((void *)dsdt, &AmlCode, AmlCode.length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt, dsdt->length); /* FADT */ printk(BIOS_DEBUG, "ACPI: * FADT\n");
Modified: trunk/src/mainboard/amd/mahogany/acpi_tables.c ============================================================================== --- trunk/src/mainboard/amd/mahogany/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/amd/mahogany/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -57,13 +57,13 @@ } #endif
-extern u8 AmlCode[]; +extern const acpi_header_t AmlCode;
#if CONFIG_ACPI_SSDTX_NUM >= 1 -extern u8 AmlCode_ssdt2[]; -extern u8 AmlCode_ssdt3[]; -extern u8 AmlCode_ssdt4[]; -extern u8 AmlCode_ssdt5[]; +extern const acpi_header_t AmlCode_ssdt2; +extern const acpi_header_t AmlCode_ssdt3; +extern const acpi_header_t AmlCode_ssdt4; +extern const acpi_header_t AmlCode_ssdt5; #endif
#define IO_APIC_ADDR 0xfec00000UL @@ -219,25 +219,24 @@ ssdtx = (acpi_header_t *) current; switch (sysconf.hcid[i]) { case 1: /* 8132 */ - p = AmlCode_ssdt2; + p = &AmlCode_ssdt2; break; case 2: /* 8151 */ - p = AmlCode_ssdt3; + p = &AmlCode_ssdt3; break; case 3: /* 8131 */ - p = AmlCode_ssdt4; + p = &AmlCode_ssdt4; break; default: /* HTX no io apic */ - p = AmlCode_ssdt5; + p = &AmlCode_ssdt5; break; } - current += ((acpi_header_t *) p)->length; - memcpy((void *)ssdtx, (void *)p, ((acpi_header_t *) p)->length); + current += p->length; + memcpy((void *)ssdtx, p, p->length); update_ssdtx((void *)ssdtx, i); ssdtx->checksum = 0; - ssdtx->checksum = - acpi_checksum((u8 *)ssdtx, ssdtx->length); + ssdtx->checksum = acpi_checksum((u8 *)ssdtx, ssdtx->length); acpi_add_table(rsdp, ssdtx); } #endif @@ -251,8 +250,7 @@ /* DSDT */ printk(BIOS_DEBUG, "ACPI: * DSDT\n"); dsdt = (acpi_header_t *) current; - memcpy((void *)dsdt, (void *)AmlCode, - ((acpi_header_t *) AmlCode)->length); + memcpy((void *)dsdt, &AmlCode, AmlCode.length); current += dsdt->length; printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt, dsdt->length); /* FADT */
Modified: trunk/src/mainboard/amd/mahogany_fam10/acpi_tables.c ============================================================================== --- trunk/src/mainboard/amd/mahogany_fam10/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/amd/mahogany_fam10/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -46,14 +46,14 @@ } #endif
-extern u8 AmlCode[]; -extern u8 AmlCode_ssdt[]; +extern const acpi_header_t AmlCode; +extern const acpi_header_t AmlCode_ssdt;
#if CONFIG_ACPI_SSDTX_NUM >= 1 -extern u8 AmlCode_ssdt2[]; -extern u8 AmlCode_ssdt3[]; -extern u8 AmlCode_ssdt4[]; -extern u8 AmlCode_ssdt5[]; +extern const acpi_header_t AmlCode_ssdt2; +extern const acpi_header_t AmlCode_ssdt3; +extern const acpi_header_t AmlCode_ssdt4; +extern const acpi_header_t AmlCode_ssdt5; #endif
#define IO_APIC_ADDR 0xfec00000UL @@ -130,7 +130,7 @@ acpi_header_t *dsdt; acpi_header_t *ssdt; acpi_header_t *ssdtx; - u8 *p; + acpi_header_t const *p;
int i;
@@ -192,8 +192,8 @@ current = ( current + 0x0f) & -0x10; printk(BIOS_DEBUG, "ACPI: * SSDT at %lx\n", current); ssdt = (acpi_header_t *)current; - current += ((acpi_header_t *)AmlCode_ssdt)->length; - memcpy((void *)ssdt, (void *)AmlCode_ssdt, ((acpi_header_t *)AmlCode_ssdt)->length); + current += AmlCode_ssdt.length; + memcpy((void *)ssdt, &AmlCode_ssdt, AmlCode_ssdt.length); //Here you need to set value in pci1234, sblk and sbdn in get_bus_conf.c update_ssdt((void*)ssdt); /* recalculate checksum */ @@ -223,20 +223,20 @@ ssdtx = (acpi_header_t *)current; switch(sysconf.hcid[i]) { case 1: - p = AmlCode_ssdt2; + p = &AmlCode_ssdt2; break; case 2: - p = AmlCode_ssdt3; + p = &AmlCode_ssdt3; break; case 3: //8131 - p = AmlCode_ssdt4; + p = &AmlCode_ssdt4; break; default: //HTX no io apic - p = AmlCode_ssdt5; + p = &AmlCode_ssdt5; } current += ((acpi_header_t *)p)->length; - memcpy((void *)ssdtx, (void *)p, ((acpi_header_t *)p)->length); + memcpy((void *)ssdtx, p, p->length); update_ssdtx((void *)ssdtx, i); ssdtx->checksum = 0; ssdtx->checksum = acpi_checksum((unsigned char *)ssdtx,ssdtx->length); @@ -248,9 +248,8 @@ current = ( current + 0x07) & -0x08; printk(BIOS_DEBUG, "ACPI: * DSDT at %lx\n", current); dsdt = (acpi_header_t *)current; // it will used by fadt - current += ((acpi_header_t *)AmlCode)->length; - memcpy((void *)dsdt,(void *)AmlCode, \ - ((acpi_header_t *)AmlCode)->length); + current += AmlCode.length; + memcpy((void *)dsdt, &AmlCode, AmlCode.length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n",dsdt,dsdt->length);
/* FACS */ // it needs 64 bit alignment
Modified: trunk/src/mainboard/amd/pistachio/acpi_tables.c ============================================================================== --- trunk/src/mainboard/amd/pistachio/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/amd/pistachio/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -57,13 +57,13 @@ } #endif
-extern u8 AmlCode[]; +extern const acpi_header_t AmlCode;
#if CONFIG_ACPI_SSDTX_NUM >= 1 -extern u8 AmlCode_ssdt2[]; -extern u8 AmlCode_ssdt3[]; -extern u8 AmlCode_ssdt4[]; -extern u8 AmlCode_ssdt5[]; +extern const acpi_header_t AmlCode_ssdt2; +extern const acpi_header_t AmlCode_ssdt3; +extern const acpi_header_t AmlCode_ssdt4; +extern const acpi_header_t AmlCode_ssdt5; #endif
#define IO_APIC_ADDR 0xfec00000UL @@ -219,17 +219,17 @@ ssdtx = (acpi_header_t *) current; switch (sysconf.hcid[i]) { case 1: /* 8132 */ - p = AmlCode_ssdt2; + p = &AmlCode_ssdt2; break; case 2: /* 8151 */ - p = AmlCode_ssdt3; + p = &AmlCode_ssdt3; break; case 3: /* 8131 */ - p = AmlCode_ssdt4; + p = &AmlCode_ssdt4; break; default: /* HTX no io apic */ - p = AmlCode_ssdt5; + p = &AmlCode_ssdt5; break; } current += ((acpi_header_t *) p)->length; @@ -251,8 +251,7 @@ /* DSDT */ printk(BIOS_DEBUG, "ACPI: * DSDT\n"); dsdt = (acpi_header_t *) current; - memcpy((void *)dsdt, (void *)AmlCode, - ((acpi_header_t *) AmlCode)->length); + memcpy((void *)dsdt, &AmlCode, AmlCode.length);
current += dsdt->length; printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt, dsdt->length);
Modified: trunk/src/mainboard/amd/serengeti_cheetah/acpi_tables.c ============================================================================== --- trunk/src/mainboard/amd/serengeti_cheetah/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/amd/serengeti_cheetah/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -38,11 +38,11 @@ } #endif
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode; #if CONFIG_ACPI_SSDTX_NUM >= 1 -extern unsigned char AmlCode_ssdt2[]; -extern unsigned char AmlCode_ssdt3[]; -extern unsigned char AmlCode_ssdt4[]; +extern const acpi_header_t AmlCode_ssdt2; +extern const acpi_header_t AmlCode_ssdt3; +extern const acpi_header_t AmlCode_ssdt4; #endif
#define IO_APIC_ADDR 0xfec00000UL @@ -198,7 +198,7 @@ acpi_header_t *dsdt; acpi_header_t *ssdt; acpi_header_t *ssdtx; - unsigned char *p; + acpi_header_t const *p;
int i;
@@ -279,13 +279,13 @@ ssdtx = (acpi_header_t *)current; switch(sysconf.hcid[i]) { case 1: //8132 - p = AmlCode_ssdt2; + p = &AmlCode_ssdt2; break; case 2: //8151 - p = AmlCode_ssdt3; + p = &AmlCode_ssdt3; break; case 3: //8131 - p = AmlCode_ssdt4; + p = &AmlCode_ssdt4; break; default: continue; @@ -308,9 +308,8 @@ /* DSDT */ printk(BIOS_DEBUG, "ACPI: * DSDT\n"); dsdt = (acpi_header_t *)current; - current += ((acpi_header_t *)AmlCode)->length; - memcpy((void *)dsdt,(void *)AmlCode, \ - ((acpi_header_t *)AmlCode)->length); + current += AmlCode.length; + memcpy((void *)dsdt, &AmlCode, AmlCode.length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n",dsdt,dsdt->length);
/* FDAT */
Modified: trunk/src/mainboard/amd/serengeti_cheetah_fam10/acpi_tables.c ============================================================================== --- trunk/src/mainboard/amd/serengeti_cheetah_fam10/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/amd/serengeti_cheetah_fam10/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -46,14 +46,14 @@ } #endif
-extern u8 AmlCode[]; -extern u8 AmlCode_ssdt[]; +extern const acpi_header_t AmlCode; +extern const acpi_header_t AmlCode_ssdt;
#if CONFIG_ACPI_SSDTX_NUM >= 1 -extern u8 AmlCode_ssdt2[]; -extern u8 AmlCode_ssdt3[]; -extern u8 AmlCode_ssdt4[]; -extern u8 AmlCode_ssdt5[]; +extern const acpi_header_t AmlCode_ssdt2; +extern const acpi_header_t AmlCode_ssdt3; +extern const acpi_header_t AmlCode_ssdt4; +extern const acpi_header_t AmlCode_ssdt5; #endif
#define IO_APIC_ADDR 0xfec00000UL @@ -202,7 +202,7 @@ acpi_header_t *dsdt; acpi_header_t *ssdt; acpi_header_t *ssdtx; - u8 *p; + acpi_header_t const *p;
int i;
@@ -264,8 +264,8 @@ current = ( current + 0x0f) & -0x10; printk(BIOS_DEBUG, "ACPI: * SSDT at %lx\n", current); ssdt = (acpi_header_t *)current; - current += ((acpi_header_t *)AmlCode_ssdt)->length; - memcpy((void *)ssdt, (void *)AmlCode_ssdt, ((acpi_header_t *)AmlCode_ssdt)->length); + current += AmlCode_ssdt.length; + memcpy((void *)ssdt, &AmlCode_ssdt, AmlCode_ssdt.length); //Here you need to set value in pci1234, sblk and sbdn in get_bus_conf.c update_ssdt((void*)ssdt); /* recalculate checksum */ @@ -295,24 +295,24 @@ ssdtx = (acpi_header_t *)current; switch(sysconf.hcid[i]) { case 1: - p = AmlCode_ssdt2; + p = &AmlCode_ssdt2; break; case 2: - p = AmlCode_ssdt3; + p = &AmlCode_ssdt3; break; case 3: //8131 - p = AmlCode_ssdt4; - break; - default: + p = &AmlCode_ssdt4; + break; + default: //HTX no io apic - p = AmlCode_ssdt5; + p = &AmlCode_ssdt5; } - current += ((acpi_header_t *)p)->length; - memcpy((void *)ssdtx, (void *)p, ((acpi_header_t *)p)->length); + current += p->length; + memcpy((void *)ssdtx, p, p->length); update_ssdtx((void *)ssdtx, i); ssdtx->checksum = 0; - ssdtx->checksum = acpi_checksum((unsigned char *)ssdtx,ssdtx->length); - acpi_add_table(rsdp,ssdtx); + ssdtx->checksum = acpi_checksum((u8 *)ssdtx, ssdtx->length); + acpi_add_table(rsdp, ssdtx); } #endif
@@ -320,10 +320,9 @@ current = ( current + 0x07) & -0x08; printk(BIOS_DEBUG, "ACPI: * DSDT at %lx\n", current); dsdt = (acpi_header_t *)current; // it will used by fadt - current += ((acpi_header_t *)AmlCode)->length; - memcpy((void *)dsdt,(void *)AmlCode, \ - ((acpi_header_t *)AmlCode)->length); - printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n",dsdt,dsdt->length); + current += AmlCode.length; + memcpy((void *)dsdt, &AmlCode, AmlCode.length); + printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt, dsdt->length);
/* FACS */ // it needs 64 bit alignment current = ( current + 0x07) & -0x08;
Modified: trunk/src/mainboard/asus/a8v-e_se/acpi_tables.c ============================================================================== --- trunk/src/mainboard/asus/a8v-e_se/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/asus/a8v-e_se/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -31,7 +31,7 @@ #include <../../../southbridge/via/vt8237r/vt8237r.h> #include <../../../southbridge/via/k8t890/k8t890.h>
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
unsigned long acpi_fill_mcfg(unsigned long current) { @@ -118,9 +118,8 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *) current; - current += ((acpi_header_t *) AmlCode)->length; - memcpy((void *) dsdt, (void *) AmlCode, - ((acpi_header_t *) AmlCode)->length); + current += AmlCode.length; + memcpy((void *) dsdt, &AmlCode, AmlCode.length); dsdt->checksum = 0; /* Don't trust iasl to get this right. */ dsdt->checksum = acpi_checksum(dsdt, dsdt->length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt,
Modified: trunk/src/mainboard/asus/m2v-mx_se/acpi_tables.c ============================================================================== --- trunk/src/mainboard/asus/m2v-mx_se/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/asus/m2v-mx_se/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -33,7 +33,7 @@ #include <../../../northbridge/amd/amdk8/amdk8_acpi.h> #include <cpu/amd/model_fxx_powernow.h>
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
unsigned long acpi_fill_mcfg(unsigned long current) { @@ -133,9 +133,8 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *) current; - current += ((acpi_header_t *) AmlCode)->length; - memcpy((void *) dsdt, (void *) AmlCode, - ((acpi_header_t *) AmlCode)->length); + current += AmlCode.length; + memcpy((void *) dsdt, &AmlCode, AmlCode.length); dsdt->checksum = 0; /* Don't trust iasl to get this right. */ dsdt->checksum = acpi_checksum(dsdt, dsdt->length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt,
Modified: trunk/src/mainboard/gigabyte/m57sli/acpi_tables.c ============================================================================== --- trunk/src/mainboard/gigabyte/m57sli/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/gigabyte/m57sli/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -34,7 +34,7 @@ #include <device/pci.h> #include <cpu/amd/amdk8_sysconf.h>
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
unsigned long acpi_fill_mcfg(unsigned long current) { @@ -143,9 +143,8 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *) current; - current += ((acpi_header_t *) AmlCode)->length; - memcpy((void *) dsdt, (void *) AmlCode, - ((acpi_header_t *) AmlCode)->length); + current += AmlCode.length; + memcpy((void *) dsdt, &AmlCode, AmlCode.length); dsdt->checksum = 0; /* Don't trust iasl to get this right. */ dsdt->checksum = acpi_checksum(dsdt, dsdt->length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt,
Modified: trunk/src/mainboard/intel/d945gclf/acpi_tables.c ============================================================================== --- trunk/src/mainboard/intel/d945gclf/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/intel/d945gclf/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -31,8 +31,7 @@
#define OLD_ACPI 0
-extern unsigned char AmlCode[]; -void *amlcodeptr = &AmlCode; +extern const acpi_header_t AmlCode; #if CONFIG_HAVE_ACPI_SLIC unsigned long acpi_create_slic(unsigned long current); #endif @@ -273,10 +272,9 @@ ALIGN_CURRENT; acpi_create_facs(facs);
- int len = ((acpi_header_t *) amlcodeptr)->length; dsdt = (acpi_header_t *) current; - current += len; - memcpy((void *) dsdt, amlcodeptr, len); + current += AmlCode.length; + memcpy((void *) dsdt, &AmlCode, AmlCode.length);
#if OLD_ACPI for (i=0; i < dsdt->length; i++) {
Modified: trunk/src/mainboard/intel/eagleheights/acpi_tables.c ============================================================================== --- trunk/src/mainboard/intel/eagleheights/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/intel/eagleheights/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -28,7 +28,7 @@ #include <device/pci_ids.h> #include "ioapic.h"
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
unsigned long acpi_fill_mcfg(unsigned long current) { @@ -206,10 +206,9 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *) current; - current += ((acpi_header_t *) AmlCode)->length; + current += AmlCode.length; ALIGN_CURRENT; - memcpy((void *) dsdt, (void *) AmlCode, - ((acpi_header_t *) AmlCode)->length); + memcpy((void *) dsdt, &AmlCode, AmlCode.length);
printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt, dsdt->length);
Modified: trunk/src/mainboard/iwill/dk8_htx/acpi_tables.c ============================================================================== --- trunk/src/mainboard/iwill/dk8_htx/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/iwill/dk8_htx/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -38,13 +38,13 @@ } #endif
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
#if CONFIG_ACPI_SSDTX_NUM >= 1 -extern unsigned char AmlCode_ssdt2[]; -extern unsigned char AmlCode_ssdt3[]; -extern unsigned char AmlCode_ssdt4[]; -extern unsigned char AmlCode_ssdt5[]; +extern const acpi_header_t AmlCode_ssdt2; +extern const acpi_header_t AmlCode_ssdt3; +extern const acpi_header_t AmlCode_ssdt4; +extern const acpi_header_t AmlCode_ssdt5; #endif
#define IO_APIC_ADDR 0xfec00000UL @@ -201,7 +201,7 @@ acpi_header_t *dsdt; acpi_header_t *ssdt; acpi_header_t *ssdtx; - unsigned char *p; + acpi_header_t const *p;
int i;
@@ -282,17 +282,17 @@ ssdtx = (acpi_header_t *)current; switch(sysconf.hcid[i]) { case 1: //8132 - p = AmlCode_ssdt2; + p = &AmlCode_ssdt2; break; case 2: //8151 - p = AmlCode_ssdt3; + p = &AmlCode_ssdt3; break; case 3: //8131 - p = AmlCode_ssdt4; + p = &AmlCode_ssdt4; break; default: //HTX no io apic - p = AmlCode_ssdt5; + p = &AmlCode_ssdt5; break; } current += ((acpi_header_t *)p)->length; @@ -313,9 +313,8 @@ /* DSDT */ printk(BIOS_DEBUG, "ACPI: * DSDT\n"); dsdt = (acpi_header_t *)current; - current += ((acpi_header_t *)AmlCode)->length; - memcpy((void *)dsdt,(void *)AmlCode, \ - ((acpi_header_t *)AmlCode)->length); + current += AmlCode.length; + memcpy((void *)dsdt, &AmlCode, AmlCode.length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n",dsdt,dsdt->length);
/* FDAT */
Modified: trunk/src/mainboard/kontron/986lcd-m/acpi_tables.c ============================================================================== --- trunk/src/mainboard/kontron/986lcd-m/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/kontron/986lcd-m/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -29,8 +29,7 @@ #include <cpu/x86/msr.h> #include "dmi.h"
-extern unsigned char AmlCode[]; -void *amlcodeptr = &AmlCode; +extern const acpi_header_t AmlCode; #if CONFIG_HAVE_ACPI_SLIC unsigned long acpi_create_slic(unsigned long current); #endif @@ -204,10 +203,9 @@ ALIGN_CURRENT; acpi_create_facs(facs);
- int len = ((acpi_header_t *) amlcodeptr)->length; dsdt = (acpi_header_t *) current; - current += len; - memcpy((void *) dsdt, amlcodeptr, len); + current += AmlCode.length; + memcpy((void *) dsdt, &AmlCode, AmlCode.length);
ALIGN_CURRENT;
Modified: trunk/src/mainboard/kontron/kt690/acpi_tables.c ============================================================================== --- trunk/src/mainboard/kontron/kt690/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/kontron/kt690/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -57,13 +57,13 @@ } #endif
-extern u8 AmlCode[]; +extern const acpi_header_t AmlCode;
#if CONFIG_ACPI_SSDTX_NUM >= 1 -extern u8 AmlCode_ssdt2[]; -extern u8 AmlCode_ssdt3[]; -extern u8 AmlCode_ssdt4[]; -extern u8 AmlCode_ssdt5[]; +extern const acpi_header_t AmlCode_ssdt2; +extern const acpi_header_t AmlCode_ssdt3; +extern const acpi_header_t AmlCode_ssdt4; +extern const acpi_header_t AmlCode_ssdt5; #endif
#define IO_APIC_ADDR 0xfec00000UL @@ -219,17 +219,17 @@ ssdtx = (acpi_header_t *) current; switch (sysconf.hcid[i]) { case 1: /* 8132 */ - p = AmlCode_ssdt2; + p = &AmlCode_ssdt2; break; case 2: /* 8151 */ - p = AmlCode_ssdt3; + p = &AmlCode_ssdt3; break; case 3: /* 8131 */ - p = AmlCode_ssdt4; + p = &AmlCode_ssdt4; break; default: /* HTX no io apic */ - p = AmlCode_ssdt5; + p = &AmlCode_ssdt5; break; } current += ((acpi_header_t *) p)->length; @@ -251,8 +251,7 @@ /* DSDT */ printk(BIOS_DEBUG, "ACPI: * DSDT\n"); dsdt = (acpi_header_t *) current; - memcpy((void *)dsdt, (void *)AmlCode, - ((acpi_header_t *) AmlCode)->length); + memcpy((void *)dsdt, &AmlCode, AmlCode.length); current += dsdt->length; printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt, dsdt->length); /* FADT */
Modified: trunk/src/mainboard/msi/ms9652_fam10/acpi_tables.c ============================================================================== --- trunk/src/mainboard/msi/ms9652_fam10/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/msi/ms9652_fam10/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -35,7 +35,7 @@ #include <cpu/amd/amdfam10_sysconf.h> #include "mb_sysconf.h"
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
unsigned long acpi_fill_mcfg(unsigned long current) { @@ -147,9 +147,8 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *) current; - current += ((acpi_header_t *) AmlCode)->length; - memcpy((void *) dsdt, (void *) AmlCode, - ((acpi_header_t *) AmlCode)->length); + current += AmlCode.length; + memcpy((void *) dsdt, &AmlCode, AmlCode.length); dsdt->checksum = 0; /* Don't trust iasl to get this right. */ dsdt->checksum = acpi_checksum(dsdt, dsdt->length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt,
Modified: trunk/src/mainboard/roda/rk886ex/acpi_tables.c ============================================================================== --- trunk/src/mainboard/roda/rk886ex/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/roda/rk886ex/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -30,8 +30,7 @@ #include <device/pci_ids.h> #include "dmi.h"
-extern unsigned char AmlCode[]; -void *amlcodeptr = &AmlCode; +extern const acpi_header_t AmlCode; #if CONFIG_HAVE_ACPI_SLIC unsigned long acpi_create_slic(unsigned long current); #endif @@ -273,10 +272,9 @@ ALIGN_CURRENT; acpi_create_facs(facs);
- int len = ((acpi_header_t *)amlcodeptr)->length; dsdt = (acpi_header_t *) current; - current += len; - memcpy((void *) dsdt, amlcodeptr, len); + current += AmlCode.length; + memcpy((void *) dsdt, &AmlCode, AmlCode.length);
/* Fix up global NVS region for SMI handler. The GNVS region lives * in the (high) table area. The low memory map looks like this:
Modified: trunk/src/mainboard/technexion/tim5690/acpi_tables.c ============================================================================== --- trunk/src/mainboard/technexion/tim5690/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/technexion/tim5690/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -57,13 +57,13 @@ } #endif
-extern u8 AmlCode[]; +extern const acpi_header_t AmlCode;
#if CONFIG_ACPI_SSDTX_NUM >= 1 -extern u8 AmlCode_ssdt2[]; -extern u8 AmlCode_ssdt3[]; -extern u8 AmlCode_ssdt4[]; -extern u8 AmlCode_ssdt5[]; +extern const acpi_header_t AmlCode_ssdt2; +extern const acpi_header_t AmlCode_ssdt3; +extern const acpi_header_t AmlCode_ssdt4; +extern const acpi_header_t AmlCode_ssdt5; #endif
#define IO_APIC_ADDR 0xfec00000UL @@ -219,17 +219,17 @@ ssdtx = (acpi_header_t *) current; switch (sysconf.hcid[i]) { case 1: /* 8132 */ - p = AmlCode_ssdt2; + p = &AmlCode_ssdt2; break; case 2: /* 8151 */ - p = AmlCode_ssdt3; + p = &AmlCode_ssdt3; break; case 3: /* 8131 */ - p = AmlCode_ssdt4; + p = &AmlCode_ssdt4; break; default: /* HTX no io apic */ - p = AmlCode_ssdt5; + p = &AmlCode_ssdt5; break; } current += ((acpi_header_t *) p)->length; @@ -251,8 +251,7 @@ /* DSDT */ printk(BIOS_DEBUG, "ACPI: * DSDT\n"); dsdt = (acpi_header_t *) current; - memcpy((void *)dsdt, (void *)AmlCode, - ((acpi_header_t *) AmlCode)->length); + memcpy((void *)dsdt, &AmlCode, AmlCode.length); current += dsdt->length; printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt, dsdt->length); /* FADT */
Modified: trunk/src/mainboard/technexion/tim8690/acpi_tables.c ============================================================================== --- trunk/src/mainboard/technexion/tim8690/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/technexion/tim8690/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -57,13 +57,13 @@ } #endif
-extern u8 AmlCode[]; +extern const acpi_header_t AmlCode;
#if CONFIG_ACPI_SSDTX_NUM >= 1 -extern u8 AmlCode_ssdt2[]; -extern u8 AmlCode_ssdt3[]; -extern u8 AmlCode_ssdt4[]; -extern u8 AmlCode_ssdt5[]; +extern const acpi_header_t AmlCode_ssdt2; +extern const acpi_header_t AmlCode_ssdt3; +extern const acpi_header_t AmlCode_ssdt4; +extern const acpi_header_t AmlCode_ssdt5; #endif
#define IO_APIC_ADDR 0xfec00000UL @@ -219,17 +219,17 @@ ssdtx = (acpi_header_t *) current; switch (sysconf.hcid[i]) { case 1: /* 8132 */ - p = AmlCode_ssdt2; + p = &AmlCode_ssdt2; break; case 2: /* 8151 */ - p = AmlCode_ssdt3; + p = &AmlCode_ssdt3; break; case 3: /* 8131 */ - p = AmlCode_ssdt4; + p = &AmlCode_ssdt4; break; default: /* HTX no io apic */ - p = AmlCode_ssdt5; + p = &AmlCode_ssdt5; break; } current += ((acpi_header_t *) p)->length; @@ -251,8 +251,7 @@ /* DSDT */ printk(BIOS_DEBUG, "ACPI: * DSDT\n"); dsdt = (acpi_header_t *) current; - memcpy((void *)dsdt, (void *)AmlCode, - ((acpi_header_t *) AmlCode)->length); + memcpy((void *)dsdt, &AmlCode, AmlCode.length); current += dsdt->length; printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt, dsdt->length); /* FADT */
Modified: trunk/src/mainboard/tyan/s2891/acpi_tables.c ============================================================================== --- trunk/src/mainboard/tyan/s2891/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/tyan/s2891/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -20,7 +20,7 @@ #include <../../../northbridge/amd/amdk8/amdk8_acpi.h> #include <cpu/amd/model_fxx_powernow.h>
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
unsigned long acpi_fill_mcfg(unsigned long current) { @@ -139,8 +139,8 @@ current = ALIGN(current, 16); dsdt = (acpi_header_t *) current; printk(BIOS_DEBUG, "ACPI: * DSDT %p\n", dsdt); - current += ((acpi_header_t *) AmlCode)->length; - memcpy((void*) dsdt, (void*)AmlCode, ((acpi_header_t*)AmlCode)->length); + current += AmlCode.length; + memcpy((void*) dsdt, &AmlCode, AmlCode.length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n",dsdt,dsdt->length);
current = ALIGN(current, 16);
Modified: trunk/src/mainboard/tyan/s2892/acpi_tables.c ============================================================================== --- trunk/src/mainboard/tyan/s2892/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/tyan/s2892/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -20,7 +20,7 @@ #include <../../../northbridge/amd/amdk8/amdk8_acpi.h> #include <cpu/amd/model_fxx_powernow.h>
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
unsigned long acpi_fill_mcfg(unsigned long current) { @@ -139,8 +139,8 @@ current = ALIGN(current, 16); dsdt = (acpi_header_t *) current; printk(BIOS_DEBUG, "ACPI: * DSDT %p\n", dsdt); - current += ((acpi_header_t *) AmlCode)->length; - memcpy((void*) dsdt, (void*)AmlCode, ((acpi_header_t*)AmlCode)->length); + current += AmlCode.length; + memcpy((void*) dsdt, &AmlCode, AmlCode.length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n",dsdt,dsdt->length);
current = ALIGN(current, 16);
Modified: trunk/src/mainboard/tyan/s2895/acpi_tables.c ============================================================================== --- trunk/src/mainboard/tyan/s2895/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/tyan/s2895/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -20,7 +20,7 @@ #include <../../../northbridge/amd/amdk8/amdk8_acpi.h> #include <cpu/amd/model_fxx_powernow.h>
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
unsigned long acpi_fill_mcfg(unsigned long current) { @@ -164,8 +164,8 @@ current = ALIGN(current, 16); dsdt = (acpi_header_t *) current; printk(BIOS_DEBUG, "ACPI: * DSDT %p\n", dsdt); - current += ((acpi_header_t *) AmlCode)->length; - memcpy((void*) dsdt, (void*)AmlCode, ((acpi_header_t*)AmlCode)->length); + current += AmlCode.length; + memcpy((void*) dsdt, &AmlCode, AmlCode.length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n",dsdt,dsdt->length);
current = ALIGN(current, 16);
Modified: trunk/src/mainboard/via/epia-m/acpi_tables.c ============================================================================== --- trunk/src/mainboard/via/epia-m/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/via/epia-m/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -11,7 +11,7 @@ #include <string.h> #include <arch/acpi.h>
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
unsigned long acpi_fill_mcfg(unsigned long current) { @@ -75,8 +75,8 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *)current; - current += ((acpi_header_t *)AmlCode)->length; - memcpy((void *)dsdt,(void *)AmlCode, ((acpi_header_t *)AmlCode)->length); + current += AmlCode.length; + memcpy((void *)dsdt, &AmlCode, AmlCode.length); dsdt->checksum = 0; // don't trust intel iasl compiler to get this right dsdt->checksum = acpi_checksum(dsdt,dsdt->length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n",dsdt,dsdt->length);
Modified: trunk/src/mainboard/via/epia-m700/acpi_tables.c ============================================================================== --- trunk/src/mainboard/via/epia-m700/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/via/epia-m700/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -35,8 +35,8 @@ #include <device/pci_ids.h> #include <../../../northbridge/via/vx800/vx800.h>
-extern unsigned char AmlCode_dsdt[]; -extern unsigned char AmlCode_ssdt[]; +extern const acpi_header_t AmlCode_dsdt; +extern const acpi_header_t AmlCode_ssdt;
extern u32 wake_vec;
@@ -158,9 +158,8 @@
printk(BIOS_DEBUG, "ACPI: * DSDT\n"); dsdt = (acpi_header_t *) current; - current += ((acpi_header_t *) AmlCode_dsdt)->length; - memcpy((void *)dsdt, (void *)AmlCode_dsdt, - ((acpi_header_t *) AmlCode_dsdt)->length); + current += AmlCode_dsdt.length; + memcpy((void *)dsdt, &AmlCode_dsdt, AmlCode_dsdt.length); dsdt->checksum = 0; /* Don't trust iasl to get this right. */ dsdt->checksum = acpi_checksum(dsdt, dsdt->length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt, dsdt->length); @@ -190,8 +189,8 @@ #if 0 printk(BIOS_DEBUG, "ACPI: * SSDT\n"); ssdt = (acpi_header_t *) current; - current += ((acpi_header_t *)AmlCode_ssdt)->length; - memcpy((void *)ssdt,(void *)AmlCode_ssdt, ((acpi_header_t *)AmlCode_ssdt)->length); + current += AmlCode_ssdt.length; + memcpy((void *)ssdt, &AmlCode_ssdt, AmlCode_ssdt.length); ssdt->checksum = 0; /* Don't trust iasl to get this right. */ ssdt->checksum = acpi_checksum(ssdt, ssdt->length); acpi_add_table(rsdp, ssdt);
Modified: trunk/src/mainboard/via/epia-n/acpi_tables.c ============================================================================== --- trunk/src/mainboard/via/epia-n/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/via/epia-n/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -35,7 +35,7 @@ #include <device/pci_ids.h> #include "../../../southbridge/via/vt8237r/vt8237r.h"
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
/* * These four macros are copied from <arch/smp/mpspec.h>, I have to do this @@ -161,8 +161,8 @@
printk(BIOS_DEBUG, "ACPI: * DSDT\n"); dsdt = (acpi_header_t *)current; - current += ((acpi_header_t *)AmlCode)->length; - memcpy((void *)dsdt,(void *)AmlCode, ((acpi_header_t *)AmlCode)->length); + current += AmlCode.length; + memcpy((void *)dsdt, &AmlCode, AmlCode.length); dsdt->checksum = 0; // don't trust intel iasl compiler to get this right dsdt->checksum = acpi_checksum(dsdt,dsdt->length); printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n",dsdt,dsdt->length);
Modified: trunk/src/mainboard/via/vt8454c/acpi_tables.c ============================================================================== --- trunk/src/mainboard/via/vt8454c/acpi_tables.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/mainboard/via/vt8454c/acpi_tables.c Wed Mar 24 23:02:53 2010 (r5286) @@ -27,7 +27,7 @@ #include <device/pci_ids.h> #include "dmi.h"
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
unsigned long acpi_fill_mcfg(unsigned long current) { @@ -180,9 +180,8 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *) current; - current += ((acpi_header_t *) AmlCode)->length; - memcpy((void *) dsdt, (void *) AmlCode, - ((acpi_header_t *) AmlCode)->length); + current += AmlCode.length; + memcpy((void *) dsdt, &AmlCode,AmlCode.length); #if DONT_TRUST_IASL dsdt->checksum = 0; // don't trust intel iasl compiler to get this right dsdt->checksum = acpi_checksum(dsdt, dsdt->length);
Modified: trunk/src/northbridge/amd/amdfam10/amdfam10_acpi.c ============================================================================== --- trunk/src/northbridge/amd/amdfam10/amdfam10_acpi.c Wed Mar 24 22:24:17 2010 (r5285) +++ trunk/src/northbridge/amd/amdfam10/amdfam10_acpi.c Wed Mar 24 23:02:53 2010 (r5286) @@ -305,11 +305,11 @@ } }
-extern unsigned char AmlCode_sspr5[]; -extern unsigned char AmlCode_sspr4[]; -extern unsigned char AmlCode_sspr3[]; -extern unsigned char AmlCode_sspr2[]; -extern unsigned char AmlCode_sspr1[]; +extern const acpi_header_t AmlCode_sspr5; +extern const acpi_header_t AmlCode_sspr4; +extern const acpi_header_t AmlCode_sspr3; +extern const acpi_header_t AmlCode_sspr2; +extern const acpi_header_t AmlCode_sspr1;
/* fixme: find one good way for different p_state_num */ unsigned long acpi_add_ssdt_pstates(acpi_rsdp_t *rsdp, unsigned long current) @@ -321,13 +321,13 @@
if(!sysconf.p_state_num) return current;
- u8 *AmlCode_sspr; + acpi_header_t *AmlCode_sspr; switch(sysconf.p_state_num) { - case 1: AmlCode_sspr = AmlCode_sspr1; break; - case 2: AmlCode_sspr = AmlCode_sspr2; break; - case 3: AmlCode_sspr = AmlCode_sspr3; break; - case 4: AmlCode_sspr = AmlCode_sspr4; break; - default: AmlCode_sspr = AmlCode_sspr5; break; + case 1: AmlCode_sspr = &AmlCode_sspr1; break; + case 2: AmlCode_sspr = &AmlCode_sspr2; break; + case 3: AmlCode_sspr = &AmlCode_sspr3; break; + case 4: AmlCode_sspr = &AmlCode_sspr4; break; + default: AmlCode_sspr = &AmlCode_sspr5; break; }
for(cpu = all_devices; cpu; cpu = cpu->next) { @@ -342,8 +342,8 @@
current = ( current + 0x0f) & -0x10; ssdt = (acpi_header_t *)current; - current += ((acpi_header_t *)AmlCode_sspr)->length; - memcpy((void *)ssdt, (void *)AmlCode_sspr, ((acpi_header_t *)AmlCode_sspr)->length); + current += AmlCode_sspr->length; + memcpy((void *)ssdt, AmlCode_sspr, AmlCode_sspr->length); update_sspr((void*)ssdt,cpu->path.apic.node_id, cpu_index); /* recalculate checksum */ ssdt->checksum = 0;
On 3/24/10 11:02 PM, repository service wrote:
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
And we're positive, this always does the right thing with gcc?
Stefan
On 3/24/10 11:02 PM, repository service wrote:
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
And we're positive, this always does the right thing with gcc?
I am told that AmlCode is defined as array of (unsigned) char in some other file. Declaring it as some other type here is not valid C, and *will* break with GCC, with some options (-combine or LTO at least) -- it will not compile.
Segher
On 3/24/10 11:02 PM, repository service wrote:
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
And we're positive, this always does the right thing with gcc?
I am told that AmlCode is defined as array of (unsigned) char in some other file. Declaring it as some other type here is not valid C, and *will* break with GCC, with some options (-combine or LTO at least) -- it will not compile.
The biggest worry for me is incorrect execution. If it doesn't compile when it breaks, then that's a good thing.
Thanks, Myles
On 3/25/10 3:47 PM, Myles Watson wrote:
On 3/24/10 11:02 PM, repository service wrote:
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
And we're positive, this always does the right thing with gcc?
I am told that AmlCode is defined as array of (unsigned) char in some other file. Declaring it as some other type here is not valid C, and *will* break with GCC, with some options (-combine or LTO at least) -- it will not compile.
The biggest worry for me is incorrect execution. If it doesn't compile when it breaks, then that's a good thing.
Well, if it breaks with LTO, we should fix it right away... I'll try and prepare something.
On Thu, Mar 25, 2010 at 8:52 AM, Stefan Reinauer stepan@coresystems.dewrote:
On 3/25/10 3:47 PM, Myles Watson wrote:
On 3/24/10 11:02 PM, repository service wrote:
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
And we're positive, this always does the right thing with gcc?
I am told that AmlCode is defined as array of (unsigned) char in some other file. Declaring it as some other type here is not valid C, and *will* break with GCC, with some options (-combine or LTO at least) -- it will not compile.
The biggest worry for me is incorrect execution. If it doesn't compile
when
it breaks, then that's a good thing.
Well, if it breaks with LTO, we should fix it right away... I'll try and prepare something.
What do the IASL folks suggest? Do they have a way of doing this "correctly"?
It seems like others must have this problem of needing to force a binary blob into a struct.
Thanks, Myles
On Thu, Mar 25, 2010 at 7:56 AM, Myles Watson mylesgw@gmail.com wrote:
It seems like others must have this problem of needing to force a binary blob into a struct.
Hi, I've only been following this at a distance. I assume this all happens after memory is turned on. Why not just have a function to fill the struct given the binary blob? I'm starting to worry about all the tricks people want to play with gcc.
ron
On Thu, Mar 25, 2010 at 7:56 AM, Myles Watson mylesgw@gmail.com wrote:
It seems like others must have this problem of needing to force a binary blob into a struct.
Hi, I've only been following this at a distance. I assume this all happens after memory is turned on. Why not just have a function to fill the struct given the binary blob? I'm starting to worry about all the tricks people want to play with gcc.
Memory is on. The blob is in flash, and the first bit of the blob is the header with the length field.
We do a memcpy from flash to the struct, but first we have to cast it to a header so we can read out the length to copy. Gcc doesn't like the cast, so we just declare that we have the header stored in flash.
One way to solve it would be to copy the header first, then read the length and copy the rest...
It doesn't seem like there are any clean ways to do it. The way it's done now depends on the unsigned character array being 4-byte aligned.
Thanks, Myles
On 3/25/10 5:18 PM, Myles Watson wrote:
On Thu, Mar 25, 2010 at 7:56 AM, Myles Watson mylesgw@gmail.com wrote:
It seems like others must have this problem of needing to force a binary blob into a struct.
Hi, I've only been following this at a distance. I assume this all happens after memory is turned on. Why not just have a function to fill the struct given the binary blob? I'm starting to worry about all the tricks people want to play with gcc.
Memory is on. The blob is in flash, and the first bit of the blob is the header with the length field.
We do a memcpy from flash to the struct,
Actually this is a memcpy from memory to the cbmem area, but after it's copied it's not treated as a struct anymore.
but first we have to cast it to a header so we can read out the length to copy.
Which makes me think if there are not other ways to determine the size of an array. Maybe sizeof(AmlCode) ?
Gcc doesn't like the cast, so we just declare that we have the header stored in flash.
One way to solve it would be to copy the header first, then read the length and copy the rest...
That's more copying than my variant with the extra pointer. Since we copied (or uncompressed) the dsdt from flash to ram already before, and are going to make another copy, I suggest rather keeping an extra 4 bytes, than copying the complete header for no apparent reason...
Stefan
On Thu, Mar 25, 2010 at 10:39 AM, Stefan Reinauer stepan@coresystems.dewrote:
On 3/25/10 5:18 PM, Myles Watson wrote:
On Thu, Mar 25, 2010 at 7:56 AM, Myles Watson mylesgw@gmail.com
wrote:
It seems like others must have this problem of needing to force a
binary
blob into a struct.
Hi, I've only been following this at a distance. I assume this all happens after memory is turned on. Why not just have a function to fill the struct given the binary blob? I'm starting to worry about all the tricks people want to play with gcc.
Memory is on. The blob is in flash, and the first bit of the blob is the header with the length field.
We do a memcpy from flash to the struct,
Actually this is a memcpy from memory to the cbmem area,
You're right, since it gets copied to memory with the rest of coreboot_ram.
but after it's copied it's not treated as a struct anymore.
Except when you patch it?
but first we have to cast it to a header so we can read out the length to copy.
Which makes me think if there are not other ways to determine the size of an array. Maybe sizeof(AmlCode) ?
I tried that. It doesn't work because it's an incomplete type.
Gcc doesn't like the cast, so we just declare that we have the header stored in flash.
One way to solve it would be to copy the header first, then read the
length
and copy the rest...
That's more copying than my variant with the extra pointer. Since we copied (or uncompressed) the dsdt from flash to ram already before, and are going to make another copy, I suggest rather keeping an extra 4 bytes, than copying the complete header for no apparent reason...
The reason I object to the void* method was that it just masked the problem so that gcc couldn't spot it. Casting to void* and back to a struct seems equivalent to just having it declared two different ways.
Copying the header first works (boot tested), and if you want to save the redundant copy, we could start after the header for the second copy.
Index: svn/src/mainboard/amd/serengeti_cheetah_fam10/acpi_tables.c =================================================================== --- svn.orig/src/mainboard/amd/serengeti_cheetah_fam10/acpi_tables.c +++ svn/src/mainboard/amd/serengeti_cheetah_fam10/acpi_tables.c @@ -47,7 +47,7 @@ static void dump_mem(u32 start, u32 end) #endif
extern const acpi_header_t AmlCode; -extern const acpi_header_t AmlCode_ssdt; +extern const unsigned char AmlCode_ssdt[];
#if CONFIG_ACPI_SSDTX_NUM >= 1 extern const acpi_header_t AmlCode_ssdt2; @@ -264,8 +264,10 @@ unsigned long write_acpi_tables(unsigned current = ( current + 0x0f) & -0x10; printk(BIOS_DEBUG, "ACPI: * SSDT at %lx\n", current); ssdt = (acpi_header_t *)current; - current += AmlCode_ssdt.length; - memcpy((void *)ssdt, &AmlCode_ssdt, AmlCode_ssdt.length); + memcpy(ssdt, &AmlCode_ssdt[0], sizeof(acpi_header_t)); + current += ssdt->length; + printk(BIOS_DEBUG, "ssdt->length %x\n", ssdt->length); + memcpy(ssdt, &AmlCode_ssdt[0], ssdt->length); //Here you need to set value in pci1234, sblk and sbdn in get_bus_conf.c update_ssdt((void*)ssdt); /* recalculate checksum */
Thanks, Myles
On 3/25/10 5:45 PM, Myles Watson wrote:
The reason I object to the void* method was that it just masked the problem so that gcc couldn't spot it. Casting to void* and back to a struct seems equivalent to just having it declared two different ways.
I don't think it's masking the problem. It should be sufficient to let gcc know that it can't assume anything from the pointer since it comes from a void *. Also, it's not casting it back to a struct, because it never was a struct. So, while it might not be beautiful, I think it's at least not wrong.
Which makes me think if there are not other ways to determine the size of an array. Maybe sizeof(AmlCode) ?
I tried that. It doesn't work because it's an incomplete type.
It would not if we included the file
----- 8< ------ dsdt_wrapper.c -------- 8< ----------
#include "dsdt.c"
int AmlCodeSize = sizeof(AmlCode);
----- 8< ------ dsdt_wrapper.c -------- 8< ----------
and use that.
A (maybe too obvious) variant would be to create a binary dsdt instead of a C file and pack that into CBFS. It would reduce coreboot size and allow to copy/decompress it right to cbmem
Stefan
On Thu, Mar 25, 2010 at 11:53 AM, Stefan Reinauer stepan@coresystems.dewrote:
On 3/25/10 5:45 PM, Myles Watson wrote:
The reason I object to the void* method was that it just masked the problem so that gcc couldn't spot it. Casting to void* and back to a struct seems equivalent to just having it declared two different ways.
I don't think it's masking the problem. It should be sufficient to let gcc know that it can't assume anything from the pointer since it comes from a void *. Also, it's not casting it back to a struct, because it never was a struct. So, while it might not be beautiful, I think it's at least not wrong.
The interesting thing is that gcc won't allow the cast if you don't have a variable for it. That's why I thought it was masking the problem.
In other words, when I tried: ((acpi_header_t*)((void*)&AmlCode)) ->length
It still has the type-punned-pointer warning.
Which makes me think if there are not other ways to determine the size of an array. Maybe sizeof(AmlCode) ?
I tried that. It doesn't work because it's an incomplete type.
It would not if we included the file
----- 8< ------ dsdt_wrapper.c -------- 8< ----------
#include "dsdt.c"
int AmlCodeSize = sizeof(AmlCode);
The boards with multiple ssdts would have to be refactored.
A (maybe too obvious) variant would be to create a binary dsdt instead of a C file and pack that into CBFS. It would reduce coreboot size and allow to copy/decompress it right to cbmem
This would be fine with me. It's quite a bit more overhead than the double copy, though.
Thanks, Myles
On 3/25/10 7:54 PM, Myles Watson wrote:
A (maybe too obvious) variant would be to create a binary dsdt instead of a C file and pack that into CBFS. It would reduce coreboot size and allow to copy/decompress it right to cbmem
This would be fine with me. It's quite a bit more overhead than the double copy, though.
how so?
On Thu, Mar 25, 2010 at 1:00 PM, Stefan Reinauer stepan@coresystems.dewrote:
On 3/25/10 7:54 PM, Myles Watson wrote:
A (maybe too obvious) variant would be to create a binary dsdt instead of
a C file and pack that into CBFS. It would reduce coreboot size and allow to copy/decompress it right to cbmem
This would be fine with me. It's quite a bit more overhead than the double copy, though.
how so?
The overhead of more and longer searches through CBFS.
Thanks, Myles
It seems like others must have this problem of needing to force a binary blob into a struct.
Just memcpy() it from the blob to the struct. If I remember your code correctly, you copy it later anyway, so might as well do it in one step.
Segher
On 3/25/10 10:43 PM, Segher Boessenkool wrote:
It seems like others must have this problem of needing to force a binary blob into a struct.
Just memcpy() it from the blob to the struct. If I remember your code correctly, you copy it later anyway, so might as well do it in one step.
In two steps, because we need to copy the header first to find out how big the whole array is..
But that's a plan...
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
And we're positive, this always does the right thing with gcc?
I am told that AmlCode is defined as array of (unsigned) char in some other file. Declaring it as some other type here is not valid C, and *will* break with GCC, with some options (-combine or LTO at least) -- it will not compile.
The biggest worry for me is incorrect execution. If it doesn't compile when it breaks, then that's a good thing.
It will probably _work_ with current GCC and no whole-program stuff, but how do you *know* it does? Better to just fix it.
Segher
On 3/25/10 10:47 PM, Segher Boessenkool wrote:
-extern unsigned char AmlCode[]; +extern const acpi_header_t AmlCode;
And we're positive, this always does the right thing with gcc?
I am told that AmlCode is defined as array of (unsigned) char in some other file. Declaring it as some other type here is not valid C, and *will* break with GCC, with some options (-combine or LTO at least) -- it will not compile.
The biggest worry for me is incorrect execution. If it doesn't compile when it breaks, then that's a good thing.
It will probably _work_ with current GCC and no whole-program stuff, but how do you *know* it does? Better to just fix it.
I changed one as an example now... I guess we could optimize to not copy the header twice, but the header is really small, so i didn't care to make the code uglier.
Index: src/mainboard/intel/d945gclf/acpi_tables.c =================================================================== --- src/mainboard/intel/d945gclf/acpi_tables.c (revision 5297) +++ src/mainboard/intel/d945gclf/acpi_tables.c (working copy) @@ -31,7 +31,7 @@
#define OLD_ACPI 0
-extern const acpi_header_t AmlCode; +extern unsigned char AmlCode[]; #if CONFIG_HAVE_ACPI_SLIC unsigned long acpi_create_slic(unsigned long current); #endif @@ -273,8 +273,10 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *) current; - current += AmlCode.length; - memcpy((void *) dsdt, &AmlCode, AmlCode.length); + memcpy((void *) dsdt, AmlCode, sizeof(acpi_header_t)); + int len = dsdt->length; + current += len; + memcpy((void *) dsdt, AmlCode, len);
#if OLD_ACPI for (i=0; i < dsdt->length; i++) {
I changed one as an example now... I guess we could optimize to not copy the header twice, but the header is really small, so i didn't care to make the code uglier.
I agree.
@@ -273,8 +273,10 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *) current;
- current += AmlCode.length;
- memcpy((void *) dsdt, &AmlCode, AmlCode.length);
- memcpy((void *) dsdt, AmlCode, sizeof(acpi_header_t));
- int len = dsdt->length;
- current += len;
- memcpy((void *) dsdt, AmlCode, len);
Why not:
- current += dstd->length;
- memcpy((void *) dsdt, AmlCode, dsdt->length);
I don't think the extra variable adds anything.
I'll ack that.
Thanks, Myles
On 3/25/10 11:07 PM, Myles Watson wrote:
I changed one as an example now... I guess we could optimize to not copy the header twice, but the header is really small, so i didn't care to make the code uglier.
I agree.
@@ -273,8 +273,10 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *) current;
- current += AmlCode.length;
- memcpy((void *) dsdt, &AmlCode, AmlCode.length);
- memcpy((void *) dsdt, AmlCode, sizeof(acpi_header_t));
- int len = dsdt->length;
- current += len;
- memcpy((void *) dsdt, AmlCode, len);
Why not:
- current += dstd->length;
- memcpy((void *) dsdt, AmlCode, dsdt->length);
I don't think the extra variable adds anything.
Ah, I thought in terms of "it's overwriting memory while it's using it". Was I too careful? I think so.
On 3/25/10 11:07 PM, Myles Watson wrote:
@@ -273,8 +273,10 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *) current;
- current += AmlCode.length;
- memcpy((void *) dsdt, &AmlCode, AmlCode.length);
- memcpy((void *) dsdt, AmlCode, sizeof(acpi_header_t));
- int len = dsdt->length;
- current += len;
- memcpy((void *) dsdt, AmlCode, len);
Why not:
- current += dstd->length;
- memcpy((void *) dsdt, AmlCode, dsdt->length);
I don't think the extra variable adds anything.
I'll ack that.
This is not all boards yet, but I send them out so I can go to bed :-)
On 3/25/10 11:46 PM, Stefan Reinauer wrote:
On 3/25/10 11:07 PM, Myles Watson wrote:
@@ -273,8 +273,10 @@ acpi_create_facs(facs);
dsdt = (acpi_header_t *) current;
- current += AmlCode.length;
- memcpy((void *) dsdt, &AmlCode, AmlCode.length);
- memcpy((void *) dsdt, AmlCode, sizeof(acpi_header_t));
- int len = dsdt->length;
- current += len;
- memcpy((void *) dsdt, AmlCode, len);
Why not:
- current += dstd->length;
- memcpy((void *) dsdt, AmlCode, dsdt->length);
I don't think the extra variable adds anything.
I'll ack that.
This is not all boards yet, but I send them out so I can go to bed :-)
ping
I'll ack that.
This is not all boards yet, but I send them out so I can go to bed :-)
ping
I think I missed your patch. I sent one out for review, too.
Thanks, Myles
This is not all boards yet, but I send them out so I can go to bed :-)
Here's one for all boards.
Signed-off-by: Myles Watson mylesgw@gmail.com
Thanks, Myles
On 4/8/10 7:07 PM, Myles Watson wrote:
Here's one for all boards.
Signed-off-by: Myles Watson <mylesgw@gmail.com mailto:mylesgw@gmail.com>
Acked-by: Stefan Reinauer stepan@coresystems.de
Index: svn/src/mainboard/amd/dbm690t/acpi_tables.c
--- svn.orig/src/mainboard/amd/dbm690t/acpi_tables.c +++ svn/src/mainboard/amd/dbm690t/acpi_tables.c @@ -57,7 +57,7 @@ static void dump_mem(u32 start, u32 end) } #endif
-extern const acpi_header_t AmlCode; +extern const unsigned char AmlCode[];
I don't think defining them const here gains us much, as they're not defined const when they're created. Can we change that, maybe? Extra sed s/unsigned char AmlCode/const unsigned char AmlCode/g on the iasl output maybe?
Stefan
On Thu, Apr 8, 2010 at 5:03 PM, Stefan Reinauer stepan@coresystems.dewrote:
On 4/8/10 7:07 PM, Myles Watson wrote:
Here's one for all boards.
Signed-off-by: Myles Watson mylesgw@gmail.com
Acked-by: Stefan Reinauer stepan@coresystems.de stepan@coresystems.de
Rev. 5384
Index: svn/src/mainboard/amd/dbm690t/acpi_tables.c
--- svn.orig/src/mainboard/amd/dbm690t/acpi_tables.c +++ svn/src/mainboard/amd/dbm690t/acpi_tables.c @@ -57,7 +57,7 @@ static void dump_mem(u32 start, u32 end) } #endif
-extern const acpi_header_t AmlCode; +extern const unsigned char AmlCode[];
I don't think defining them const here gains us much, as they're not defined const when they're created.
I thought that making them const here would make it so that you couldn't do: AmlCode[23] = 'c';
without a warning.
Can we change that, maybe? Extra sed s/unsigned char AmlCode/const unsigned
char AmlCode/g on the iasl output maybe?
That would be fine with me. It might be more effort than it's worth. As long as we copy it before anything else, there shouldn't be any problems.
Thanks, Myles
I am told that AmlCode is defined as array of (unsigned) char in some other file. Declaring it as some other type here is not valid C, and *will* break with GCC, with some options (-combine or LTO at least) -- it will not compile.
The biggest worry for me is incorrect execution. If it doesn't compile when it breaks, then that's a good thing.
It will probably _work_ with current GCC and no whole-program stuff, but how do you *know* it does? Better to just fix it.
I misunderstood you. I thought you were saying that it wouldn't compile if you used those options, but that it would work otherwise.
Thanks, Myles
I am told that AmlCode is defined as array of (unsigned) char in some other file. Declaring it as some other type here is not valid C, and *will* break with GCC, with some options (-combine or LTO at least) -- it will not compile.
The biggest worry for me is incorrect execution. If it doesn't
compile
when it breaks, then that's a good thing.
It will probably _work_ with current GCC and no whole-program stuff, but how do you *know* it does? Better to just fix it.
I misunderstood you. I thought you were saying that it wouldn't compile if you used those options, but that it would work otherwise.
If you use whole-program optimisation, it will not even compile, indeed. If you do _not_ use whole-program optimisation, it will compile, and likely even work -- but no guarantees. The "workaround" correct code isn't very hard or expensive, best to use that.
It is a pity that GCC cannot detect all problems in your code, but that is equivalent to solving the halting problem (_and_ reading your mind ;-) ).
Segher