From 8db0cfefd16c9aa6dbc0ffdfd9d2ba81a1561650 Mon Sep 17 00:00:00 2001 From: Rudolf Marek Date: Tue, 3 Feb 2009 22:37:22 +0000 Subject: [PATCH] Following patch converts the run-time SSDT patching via update_ssdt funtion to new AML code generator. Compile-tested on all changed targets. I think it should work because it works for Asus M2V-MX SE. Signed-off-by: Rudolf Marek Acked-by: Carl-Daniel Hailfinger git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3929 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- src/mainboard/agami/aruma/acpi_tables.c | 90 ++----------------- src/mainboard/amd/dbm690t/acpi_tables.c | 22 +++-- src/mainboard/amd/pistachio/acpi_tables.c | 23 +++-- .../amd/serengeti_cheetah/acpi_tables.c | 22 +++-- src/mainboard/iwill/dk8_htx/acpi_tables.c | 21 +++-- src/northbridge/amd/amdk8/Config.lb | 7 -- src/northbridge/amd/amdk8/amdk8_acpi.c | 83 ----------------- src/northbridge/amd/amdk8/ssdt.dsl | 78 ---------------- 8 files changed, 48 insertions(+), 298 deletions(-) delete mode 100644 src/northbridge/amd/amdk8/ssdt.dsl diff --git a/src/mainboard/agami/aruma/acpi_tables.c b/src/mainboard/agami/aruma/acpi_tables.c index b10b73b3b6..da1bf56d7c 100644 --- a/src/mainboard/agami/aruma/acpi_tables.c +++ b/src/mainboard/agami/aruma/acpi_tables.c @@ -15,6 +15,7 @@ #include #include #include +#include <../../../northbridge/amd/amdk8/amdk8_acpi.h> #define DUMP_ACPI_TABLES 0 @@ -37,8 +38,6 @@ static void dump_mem(unsigned start, unsigned end) #define HC_POSSIBLE_NUM 8 extern unsigned char AmlCode[]; -extern unsigned char AmlCode_ssdt[]; - #if ACPI_SSDTX_NUM >= 1 extern unsigned char AmlCode_ssdt2[]; extern unsigned char AmlCode_ssdt3[]; @@ -187,78 +186,11 @@ unsigned long acpi_fill_madt(unsigned long current) return current; } -//FIXME: next could be moved to northbridge/amd/amdk8/amdk8_acpi.c or cpu/amd/k8/k8_acpi.c begin -static void int_to_stream(uint32_t val, uint8_t * dest) -{ - int i; - for (i = 0; i < 4; i++) { - *(dest + i) = (val >> (8 * i)) & 0xff; - } +unsigned long acpi_fill_ssdt_generator(unsigned long current, char *oem_table_id) { + k8acpi_write_vars(); + return (unsigned long) (acpigen_get_current()); } -extern void get_bus_conf(void); - -static void update_ssdt(void *ssdt) -{ - uint8_t *BUSN; - uint8_t *MMIO; - uint8_t *PCIO; - uint8_t *SBLK; - uint8_t *TOM1; - uint8_t *HCLK; - uint8_t *SBDN; - uint8_t *HCDN; - int i; - device_t dev; - uint32_t dword; - msr_t msr; - - BUSN = ssdt + 0x3a; //+5 will be next BUSN - MMIO = ssdt + 0x57; //+5 will be next MMIO - PCIO = ssdt + 0xaf; //+5 will be next PCIO - SBLK = ssdt + 0xdc; // one byte - TOM1 = ssdt + 0xe3; // - HCLK = ssdt + 0xfa; //+5 will be next HCLK - SBDN = ssdt + 0xed; // - HCDN = ssdt + 0x12a; //+5 will be next HCDN - - dev = dev_find_slot(0, PCI_DEVFN(0x18, 1)); - - for (i = 0; i < 4; i++) { - dword = pci_read_config32(dev, 0xe0 + i * 4); - int_to_stream(dword, BUSN + i * 5); - } - - for (i = 0; i < 0x10; i++) { - dword = pci_read_config32(dev, 0x80 + i * 4); - int_to_stream(dword, MMIO + i * 5); - } - - for (i = 0; i < 0x08; i++) { - dword = pci_read_config32(dev, 0xc0 + i * 4); - int_to_stream(dword, PCIO + i * 5); - } - - *SBLK = (uint8_t) (sblk); - - msr = rdmsr(TOP_MEM); - int_to_stream(msr.lo, TOM1); - - for (i = 0; i < hc_possible_num; i++) { - int_to_stream(pci1234[i], HCLK + i * 5); - int_to_stream(hcdn[i], HCDN + i * 5); - } - for (i = hc_possible_num; i < HC_POSSIBLE_NUM; i++) { // in case we set array size to other than 8 - int_to_stream(0x00000000, HCLK + i * 5); - int_to_stream(hcdn[i], HCDN + i * 5); - } - - int_to_stream(sbdn, SBDN); - -} - -//end - unsigned long write_acpi_tables(unsigned long start) { unsigned long current; @@ -322,16 +254,10 @@ unsigned long write_acpi_tables(unsigned long start) /* SSDT */ printk_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); - //Here you need to set value in pci1234, sblk and sbdn in get_bus_conf.c - update_ssdt((void *) ssdt); - /* recalculate checksum */ - ssdt->checksum = 0; - ssdt->checksum = - acpi_checksum((unsigned char *) ssdt, ssdt->length); + ssdt = (acpi_header_t *)current; + + acpi_create_ssdt_generator(ssdt, "DYNADATA"); + current += ssdt->length; acpi_add_table(rsdt, ssdt); #if ACPI_SSDTX_NUM >= 1 diff --git a/src/mainboard/amd/dbm690t/acpi_tables.c b/src/mainboard/amd/dbm690t/acpi_tables.c index 893ac158fd..0d890b5c60 100644 --- a/src/mainboard/amd/dbm690t/acpi_tables.c +++ b/src/mainboard/amd/dbm690t/acpi_tables.c @@ -25,7 +25,7 @@ #include #include #include - +#include <../../../northbridge/amd/amdk8/amdk8_acpi.h> #include #define DUMP_ACPI_TABLES 0 @@ -99,8 +99,6 @@ unsigned long acpi_fill_madt(unsigned long current) extern void get_bus_conf(void); -extern void update_ssdt(void *ssdt); - void update_ssdtx(void *ssdtx, int i) { uint8_t *PCI; @@ -591,6 +589,11 @@ u32 pstates_algorithm(acpi_header_t * dsdt) } +unsigned long acpi_fill_ssdt_generator(unsigned long current, char *oem_table_id) { + k8acpi_write_vars(); + return (unsigned long) (acpigen_get_current()); +} + unsigned long write_acpi_tables(unsigned long start) { unsigned long current; @@ -657,15 +660,10 @@ unsigned long write_acpi_tables(unsigned long start) /* SSDT */ printk_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); - /* Here you need to set value in pci1234, sblk and sbdn in get_bus_conf.c */ - update_ssdt((void *)ssdt); - /* recalculate checksum */ - ssdt->checksum = 0; - ssdt->checksum = acpi_checksum((u8 *)ssdt, ssdt->length); + ssdt = (acpi_header_t *)current; + + acpi_create_ssdt_generator(ssdt, "DYNADATA"); + current += ssdt->length; acpi_add_table(rsdt, ssdt); #if ACPI_SSDTX_NUM >= 1 diff --git a/src/mainboard/amd/pistachio/acpi_tables.c b/src/mainboard/amd/pistachio/acpi_tables.c index 893ac158fd..57d8214e66 100644 --- a/src/mainboard/amd/pistachio/acpi_tables.c +++ b/src/mainboard/amd/pistachio/acpi_tables.c @@ -25,7 +25,7 @@ #include #include #include - +#include <../../../northbridge/amd/amdk8/amdk8_acpi.h> #include #define DUMP_ACPI_TABLES 0 @@ -55,7 +55,6 @@ static void dump_mem(u32 start, u32 end) #endif extern u8 AmlCode[]; -extern u8 AmlCode_ssdt[]; #if ACPI_SSDTX_NUM >= 1 extern u8 AmlCode_ssdt2[]; @@ -99,8 +98,6 @@ unsigned long acpi_fill_madt(unsigned long current) extern void get_bus_conf(void); -extern void update_ssdt(void *ssdt); - void update_ssdtx(void *ssdtx, int i) { uint8_t *PCI; @@ -591,6 +588,11 @@ u32 pstates_algorithm(acpi_header_t * dsdt) } +unsigned long acpi_fill_ssdt_generator(unsigned long current, char *oem_table_id) { + k8acpi_write_vars(); + return (unsigned long) (acpigen_get_current()); +} + unsigned long write_acpi_tables(unsigned long start) { unsigned long current; @@ -657,15 +659,10 @@ unsigned long write_acpi_tables(unsigned long start) /* SSDT */ printk_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); - /* Here you need to set value in pci1234, sblk and sbdn in get_bus_conf.c */ - update_ssdt((void *)ssdt); - /* recalculate checksum */ - ssdt->checksum = 0; - ssdt->checksum = acpi_checksum((u8 *)ssdt, ssdt->length); + ssdt = (acpi_header_t *)current; + + acpi_create_ssdt_generator(ssdt, "DYNADATA"); + current += ssdt->length; acpi_add_table(rsdt, ssdt); #if ACPI_SSDTX_NUM >= 1 diff --git a/src/mainboard/amd/serengeti_cheetah/acpi_tables.c b/src/mainboard/amd/serengeti_cheetah/acpi_tables.c index ddc8c1826f..d671907687 100644 --- a/src/mainboard/amd/serengeti_cheetah/acpi_tables.c +++ b/src/mainboard/amd/serengeti_cheetah/acpi_tables.c @@ -16,6 +16,7 @@ #include #include #include +#include <../../../northbridge/amd/amdk8/amdk8_acpi.h> #include "mb_sysconf.h" @@ -38,8 +39,6 @@ static void dump_mem(unsigned start, unsigned end) #endif extern unsigned char AmlCode[]; -extern unsigned char AmlCode_ssdt[]; - #if ACPI_SSDTX_NUM >= 1 extern unsigned char AmlCode_ssdt2[]; extern unsigned char AmlCode_ssdt3[]; @@ -157,8 +156,6 @@ unsigned long acpi_fill_madt(unsigned long current) extern void get_bus_conf(void); -extern void update_ssdt(void *ssdt); - void update_ssdtx(void *ssdtx, int i) { uint8_t *PCI; @@ -182,6 +179,11 @@ void update_ssdtx(void *ssdtx, int i) } +unsigned long acpi_fill_ssdt_generator(unsigned long current, char *oem_table_id) { + k8acpi_write_vars(); + return (unsigned long) (acpigen_get_current()); +} + unsigned long write_acpi_tables(unsigned long start) { unsigned long current; @@ -256,14 +258,10 @@ unsigned long write_acpi_tables(unsigned long start) /* SSDT */ printk_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); - //Here you need to set value in pci1234, sblk and sbdn in get_bus_conf.c - update_ssdt((void*)ssdt); - /* recalculate checksum */ - ssdt->checksum = 0; - ssdt->checksum = acpi_checksum((unsigned char *)ssdt,ssdt->length); - acpi_add_table(rsdt,ssdt); + + acpi_create_ssdt_generator(ssdt, "DYNADATA"); + current += ssdt->length; + acpi_add_table(rsdt, ssdt); #if ACPI_SSDTX_NUM >= 1 diff --git a/src/mainboard/iwill/dk8_htx/acpi_tables.c b/src/mainboard/iwill/dk8_htx/acpi_tables.c index 1f891dae08..c382e3e298 100644 --- a/src/mainboard/iwill/dk8_htx/acpi_tables.c +++ b/src/mainboard/iwill/dk8_htx/acpi_tables.c @@ -16,6 +16,7 @@ #include #include #include +#include <../../../northbridge/amd/amdk8/amdk8_acpi.h> #include "mb_sysconf.h" @@ -38,7 +39,6 @@ static void dump_mem(unsigned start, unsigned end) #endif extern unsigned char AmlCode[]; -extern unsigned char AmlCode_ssdt[]; #if ACPI_SSDTX_NUM >= 1 extern unsigned char AmlCode_ssdt2[]; @@ -159,8 +159,6 @@ unsigned long acpi_fill_madt(unsigned long current) extern void get_bus_conf(void); -extern void update_ssdt(void *ssdt); - void update_ssdtx(void *ssdtx, int i) { uint8_t *PCI; @@ -184,6 +182,11 @@ void update_ssdtx(void *ssdtx, int i) } +unsigned long acpi_fill_ssdt_generator(unsigned long current, char *oem_table_id) { + k8acpi_write_vars(); + return (unsigned long) (acpigen_get_current()); +} + unsigned long write_acpi_tables(unsigned long start) { unsigned long current; @@ -258,14 +261,10 @@ unsigned long write_acpi_tables(unsigned long start) /* SSDT */ printk_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); - //Here you need to set value in pci1234, sblk and sbdn in get_bus_conf.c - update_ssdt((void*)ssdt); - /* recalculate checksum */ - ssdt->checksum = 0; - ssdt->checksum = acpi_checksum((unsigned char *)ssdt,ssdt->length); - acpi_add_table(rsdt,ssdt); + + acpi_create_ssdt_generator(ssdt, "DYNADATA"); + current += ssdt->length; + acpi_add_table(rsdt, ssdt); #if ACPI_SSDTX_NUM >= 1 diff --git a/src/northbridge/amd/amdk8/Config.lb b/src/northbridge/amd/amdk8/Config.lb index 1849d70a60..d0de06740e 100644 --- a/src/northbridge/amd/amdk8/Config.lb +++ b/src/northbridge/amd/amdk8/Config.lb @@ -19,13 +19,6 @@ end if HAVE_ACPI_TABLES object amdk8_acpi.o - makerule ssdt.c - depends "$(TOP)/src/northbridge/amd/amdk8/ssdt.dsl" - action "iasl -p $(PWD)/ssdt -tc $(TOP)/src/northbridge/amd/amdk8/ssdt.dsl" - action "perl -pi -e 's/AmlCode/AmlCode_ssdt/g' ssdt.hex" - action "mv ssdt.hex ssdt.c" - end - object ./ssdt.o end diff --git a/src/northbridge/amd/amdk8/amdk8_acpi.c b/src/northbridge/amd/amdk8/amdk8_acpi.c index 16739c4751..2d56a4f605 100644 --- a/src/northbridge/amd/amdk8/amdk8_acpi.c +++ b/src/northbridge/amd/amdk8/amdk8_acpi.c @@ -308,86 +308,3 @@ int k8acpi_write_vars(void) acpigen_patch_len(lens - 1); return lens; } - -// moved from mb acpi_tables.c -static void intx_to_stream(u32 val, u32 len, u8 *dest) -{ - int i; - for(i=0;i> (8*i)) & 0xff; - } -} - -static void int_to_stream(u32 val, u8 *dest) -{ - return intx_to_stream(val, 4, dest); -} - -// used by acpi_tables.h -void update_ssdt(void *ssdt) -{ - u8 *BUSN; - u8 *MMIO; - u8 *PCIO; - u8 *SBLK; - u8 *TOM1; - u8 *SBDN; - u8 *HCLK; - u8 *HCDN; - u8 *CBST; - - int i; - device_t dev; - u32 dword; - msr_t msr; - - BUSN = ssdt+0x3a; //+5 will be next BUSN - MMIO = ssdt+0x57; //+5 will be next MMIO - PCIO = ssdt+0xaf; //+5 will be next PCIO - SBLK = ssdt+0xdc; // one byte - TOM1 = ssdt+0xe3; // - SBDN = ssdt+0xed; // - HCLK = ssdt+0xfa; //+5 will be next HCLK - HCDN = ssdt+0x12a; //+5 will be next HCDN - CBST = ssdt+0x157; // - - dev = dev_find_slot(0, PCI_DEVFN(0x18, 1)); - for(i=0;i<4;i++) { - dword = pci_read_config32(dev, 0xe0+i*4); - int_to_stream(dword, BUSN+i*5); - } - for(i=0;i<0x10;i++) { - dword = pci_read_config32(dev, 0x80+i*4); - int_to_stream(dword, MMIO+i*5); - } - for(i=0;i<0x08;i++) { - dword = pci_read_config32(dev, 0xc0+i*4); - int_to_stream(dword, PCIO+i*5); - } - - *SBLK = (u8)(sysconf.sblk); - - msr = rdmsr(TOP_MEM); - int_to_stream(msr.lo, TOM1); - - for(i=0;i> 12) & 0xff) { //sb chain on other than bus 0 - *CBST = (u8) (0x0f); - } - else { - *CBST = (u8) (0x00); - } - -} - -//end diff --git a/src/northbridge/amd/amdk8/ssdt.dsl b/src/northbridge/amd/amdk8/ssdt.dsl deleted file mode 100644 index 681fac2ba0..0000000000 --- a/src/northbridge/amd/amdk8/ssdt.dsl +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2005 AMD - */ -DefinitionBlock ("SSDT.aml", "SSDT", 1, "AMD-K8", "AMD-ACPI", 100925440) -{ - /* - * These objects were referenced but not defined in this table - */ - External (\_SB_.PCI0, DeviceObj) - - Scope (\_SB.PCI0) - { - Name (BUSN, Package (0x04) - { - 0x11111111, - 0x22222222, - 0x33333333, - 0x44444444 - }) - Name (MMIO, Package (0x10) - { - 0x11111111, - 0x22222222, - 0x33333333, - 0x44444444, - 0x55555555, - 0x66666666, - 0x77777777, - 0x88888888, - 0x99999999, - 0xaaaaaaaa, - 0xbbbbbbbb, - 0xcccccccc, - 0xdddddddd, - 0xeeeeeeee, - 0x11111111, - 0x22222222 - }) - Name (PCIO, Package (0x08) - { - 0x77777777, - 0x88888888, - 0x99999999, - 0xaaaaaaaa, - 0xbbbbbbbb, - 0xcccccccc, - 0xdddddddd, - 0xeeeeeeee - }) - Name (SBLK, 0x11) - Name (TOM1, 0xaaaaaaaa) - Name (SBDN, 0xbbbbbbbb) - Name (HCLK, Package (0x08) - { - 0x11111111, - 0x22222222, - 0x33333333, - 0x44444444, - 0x55555555, - 0x66666666, - 0x77777777, - 0x88888888 - }) - Name (HCDN, Package (0x08) - { - 0x11111111, - 0x22222222, - 0x33333333, - 0x44444444, - 0x55555555, - 0x66666666, - 0x77777777, - 0x88888888 - }) - Name (CBST, 0x88) - } -} -