Hello,

Following patch is doing same what was the revF patch. The SSDT table is populated through the generator and not with the help of binary patching.

The code is UNTESTED, just compiles. Please review/test carefully.

I also have in plan to deal with the Powernow stuff, which can be also converted. I will do that first for revF cpu.

Signed-off-by: Rudolf Marek <[email protected]>

Rudolf
Index: mainboard/amd/serengeti_cheetah_fam10/acpi_tables.c
===================================================================
--- mainboard/amd/serengeti_cheetah_fam10/acpi_tables.c	(revision 3945)
+++ mainboard/amd/serengeti_cheetah_fam10/acpi_tables.c	(working copy)
@@ -47,7 +47,6 @@
 #endif
 
 extern u8 AmlCode[];
-extern u8 AmlCode_ssdt[];
 
 #if ACPI_SSDTX_NUM >= 1
 extern u8 AmlCode_ssdt2[];
@@ -162,9 +161,7 @@
 }
 
 extern void get_bus_conf(void);
-extern void update_ssdt(void *ssdt);
 
-
 void update_ssdtx(void *ssdtx, int i)
 {
 	u8 *PCI;
@@ -188,6 +185,11 @@
 
 }
 
+unsigned long acpi_fill_ssdt_generator(unsigned long current, char *oem_table_id) {
+	amdfam10_acpi_write_vars();
+	return (unsigned long) (acpigen_get_current());
+}
+
 unsigned long write_acpi_tables(unsigned long start)
 {
 	unsigned long current;
@@ -261,18 +263,13 @@
 	acpi_add_table(rsdt,slit);
 
 	/* SSDT */
-	current	  = ( current + 0x0f) & -0x10;
-	printk_debug("ACPI:    * SSDT at %lx\n", current);
+	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);
+
 	printk_debug("ACPI:    * SSDT for PState at %lx\n", current);
 	current = acpi_add_ssdt_pstates(rsdt, current);
 
Index: northbridge/amd/amdfam10/ssdt.dsl
===================================================================
--- northbridge/amd/amdfam10/ssdt.dsl	(revision 3945)
+++ northbridge/amd/amdfam10/ssdt.dsl	(working copy)
@@ -1,346 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2007 Advanced Micro Devices, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-/*
- * Make sure HC_NUMS and HC_POSSIBLE_NUM setting is consistent to this file
- */
-
-DefinitionBlock ("SSDT.aml", "SSDT", 1, "AMD-FAM10", "AMD-ACPI", 100925440)
-{
-	/*
-	 * These objects were referenced but not defined in this table
-	 */
-	External (\_SB_.PCI0, DeviceObj)
-
-	Scope (\_SB.PCI0)
-	{
-		Name (BUSN, Package (0x20) /* HC_NUMS */
-		{
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc,
-			0xdddddddd,
-			0xeeeeeeee,
-			0x10101010,
-			0x11111111,
-			0x12121212,
-			0x13131313,
-			0x14141414,
-			0x15151515,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc
-		})
-		Name (MMIO, Package (0x80) /* HC_NUMS * 4 */
-		{
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc,
-			0xdddddddd,
-			0xeeeeeeee,
-			0x11111111,
-			0x22222222,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc,
-			0xdddddddd,
-			0xeeeeeeee,
-			0x11111111,
-			0x22222222,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc,
-			0xdddddddd,
-			0xeeeeeeee,
-			0x11111111,
-			0x22222222,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc,
-			0xdddddddd,
-			0xeeeeeeee,
-			0x11111111,
-			0x22222222,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc,
-			0xdddddddd,
-			0xeeeeeeee,
-			0x11111111,
-			0x22222222,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888
-		})
-		Name (PCIO, Package (0x40) /* HC_NUMS * 2 */
-		{
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc,
-			0xdddddddd,
-			0xeeeeeeee,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc,
-			0xdddddddd,
-			0xeeeeeeee,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc,
-			0xdddddddd,
-			0xeeeeeeee,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc,
-			0xdddddddd,
-			0xeeeeeeee,
-			0xaaaaaaaa,
-			0xbbbbbbbb,
-			0xcccccccc,
-			0xdddddddd,
-			0xeeeeeeee,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x99999999,
-			0xaaaaaaaa,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444
-		})
-		Name (SBLK, 0x11)
-		Name (TOM1, 0xaaaaaaaa)
-		Name (SBDN, 0xbbbbbbbb)
-		Name (HCLK, Package (0x20) /* HC_POSSIBLE_NUM */
-		{
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888
-		})
-		Name (HCDN, Package (0x20) /* HC_POSSIBLE_NUM */
-		{
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888,
-			0x11111111,
-			0x22222222,
-			0x33333333,
-			0x44444444,
-			0x55555555,
-			0x66666666,
-			0x77777777,
-			0x88888888
-		})
-		Name (CBB, 0x99)
-		Name (CBST, 0x88)
-		Name (CBB2, 0x77)
-		Name (CBS2, 0x66)
-
-	}
-}
-
Index: northbridge/amd/amdfam10/Config.lb
===================================================================
--- northbridge/amd/amdfam10/Config.lb	(revision 3945)
+++ northbridge/amd/amdfam10/Config.lb	(working copy)
@@ -32,13 +32,6 @@
 
 if HAVE_ACPI_TABLES
 	object amdfam10_acpi.o
-	makerule ssdt.c
-		depends "$(TOP)/src/northbridge/amd/amdfam10/ssdt.dsl"
-		action	 "iasl -p $(PWD)/ssdt -tc $(TOP)/src/northbridge/amd/amdfam10/ssdt.dsl"
-		action	 "perl -pi -e 's/AmlCode/AmlCode_ssdt/g' ssdt.hex"
-		action	 "mv ssdt.hex ssdt.c"
-	end
-	object ./ssdt.o
 	makerule sspr1.c
 		depends "$(TOP)/src/northbridge/amd/amdfam10/sspr1.dsl"
 		action	 "iasl -p $(PWD)/sspr1 -tc $(TOP)/src/northbridge/amd/amdfam10/sspr1.dsl"
Index: northbridge/amd/amdfam10/amdfam10_acpi.c
===================================================================
--- northbridge/amd/amdfam10/amdfam10_acpi.c	(revision 3945)
+++ northbridge/amd/amdfam10/amdfam10_acpi.c	(working copy)
@@ -20,6 +20,7 @@
 #include <console/console.h>
 #include <string.h>
 #include <arch/acpi.h>
+#include <arch/acpigen.h>
 #include <device/pci.h>
 #include <cpu/x86/msr.h>
 #include <cpu/amd/mtrr.h>
@@ -190,105 +191,12 @@
 	}
 }
 
-static void int_to_stream(u32 val, u8 *dest)
+void update_sspr(void *sspr, u32 nodeid, u32 cpuindex)
 {
-	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;
-	u8 *CBBX;
-	u8 *CBS2;
-	u8 *CBB2;
 
 
-	int i;
-	u32 dword;
-	msr_t msr;
 
-	// the offset could be different if have different HC_NUMS, and HC_POSSIBLE_NUM and ssdt.asl
-	BUSN = ssdt+0x3b; //+5 will be next BUSN
-	MMIO = ssdt+0xe4; //+5 will be next MMIO
-	PCIO = ssdt+0x36d; //+5 will be next PCIO
-	SBLK = ssdt+0x4b2; // one byte
-	TOM1 = ssdt+0x4b9; //
-	SBDN = ssdt+0x4c3;//
-	HCLK = ssdt+0x4d1; //+5 will be next HCLK
-	HCDN = ssdt+0x57a; //+5 will be next HCDN
-	CBBX = ssdt+0x61f; //
-	CBST = ssdt+0x626;
-	CBB2 = ssdt+0x62d; //
-	CBS2 = ssdt+0x634;
-
-	for(i=0;i<HC_NUMS;i++) {
-		dword = sysconf.ht_c_conf_bus[i];
-		int_to_stream(dword, BUSN+i*5);
-	}
-
-	for(i=0;i<(HC_NUMS*2);i++) { // FIXME: change to more chain
-		dword = sysconf.conf_mmio_addrx[i]; //base
-		int_to_stream(dword, MMIO+(i*2)*5);
-		dword = sysconf.conf_mmio_addr[i]; //mask
-		int_to_stream(dword, MMIO+(i*2+1)*5);
-	}
-	for(i=0;i<HC_NUMS;i++) { // FIXME: change to more chain
-		dword = sysconf.conf_io_addrx[i];
-		int_to_stream(dword, PCIO+(i*2)*5);
-		dword = sysconf.conf_io_addr[i];
-		int_to_stream(dword, PCIO+(i*2+1)*5);
-	}
-
-	*SBLK = (u8)(sysconf.sblk);
-
-	msr = rdmsr(TOP_MEM);
-	int_to_stream(msr.lo, TOM1);
-
-	int_to_stream(sysconf.sbdn, SBDN);
-
-	for(i=0;i<sysconf.hc_possible_num;i++) {
-		int_to_stream(sysconf.pci1234[i], HCLK + i*5);
-		int_to_stream(sysconf.hcdn[i],	   HCDN + i*5);
-	}
-	for(i=sysconf.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(0x20202020, HCDN + i*5);
-	}
-
-	*CBBX = (u8)(CBB);
-
-	if(CBB == 0xff) {
-		*CBST = (u8) (0x0f);
-	} else {
-		if((sysconf.pci1234[0] >> 12) & 0xff) { //sb chain on  other than bus 0
-			*CBST = (u8) (0x0f);
-		}
-		else {
-			*CBST = (u8) (0x00);
-		}
-	}
-
-	if((CBB == 0xff) && (sysconf.nodes>32)) {
-		 *CBS2 = 0x0f;
-		 *CBB2 = (u8)(CBB-1);
-	} else {
-		*CBS2 = 0x00;
-		*CBB2 = 0x00;
-	}
-
-}
-
-void update_sspr(void *sspr, u32 nodeid, u32 cpuindex)
-{
 	u8 *CPU;
 	u8 *CPUIN;
 	u8 *COREFREQ;
@@ -373,3 +281,97 @@
 	}
 	return current;
 }
+
+/* this is same as k8acpi_write_HT(void) */
+static int amdfam10_acpi_write_HT(void) {
+	int len, lenp, i;
+
+	len = acpigen_write_name("HCLK");
+	lenp = acpigen_write_package(HC_POSSIBLE_NUM);
+
+	for(i=0;i<sysconf.hc_possible_num;i++) {
+		lenp += acpigen_write_dword(sysconf.pci1234[i]);
+	}
+	for(i=sysconf.hc_possible_num; i<HC_POSSIBLE_NUM; i++) { // in case we set array size to other than 8
+		lenp += acpigen_write_dword(0x0);
+	}
+
+	acpigen_patch_len(lenp - 1);
+	len += lenp;
+
+	len += acpigen_write_name("HCDN");
+	lenp = acpigen_write_package(HC_POSSIBLE_NUM);
+
+	for(i=0;i<sysconf.hc_possible_num;i++) {
+		lenp += acpigen_write_dword(sysconf.hcdn[i]);
+	}
+	for(i=sysconf.hc_possible_num; i<HC_POSSIBLE_NUM; i++) { // in case we set array size to other than 8
+		lenp += acpigen_write_dword(0x20202020);
+	}
+	acpigen_patch_len(lenp - 1);
+	len += lenp;
+
+	return len;
+}
+
+static int amdfam10_acpi_write_sysconf_dwords(char *name, int dlen, unsigned int p[],
+					    unsigned int p2[]) {
+	int len, lenp, i;
+
+	len = acpigen_write_name(name);
+	lenp = acpigen_write_package(dlen);
+	for(i=0; i<dlen; i++) {
+		lenp += acpigen_write_dword(p[i]);
+		if (p2) {
+			lenp += acpigen_write_dword(p2[i]);
+		}
+	}
+	// minus the opcode
+	acpigen_patch_len(lenp - 1);
+	return len + lenp;
+}
+
+int amdfam10_acpi_write_vars(void)
+{
+	int lens;
+	msr_t msr;
+	char pscope[] = "\\._SB_PCI0";
+
+	lens = acpigen_write_scope(pscope);
+	
+	lens += amdfam10_acpi_write_sysconf_dwords("BUSN", HC_NUMS, &sysconf.ht_c_conf_bus[0],
+						NULL);
+	/* FIXME: change to more chain */
+	lens += amdfam10_acpi_write_sysconf_dwords("MMIO", HC_NUMS * 2, &sysconf.conf_mmio_addrx[0],
+						&sysconf.conf_mmio_addr[0]);
+	/* FIXME: change to more chain */
+	lens += amdfam10_acpi_write_sysconf_dwords("PCIO", HC_NUMS * 2, &sysconf.conf_io_addrx[0],
+						&sysconf.conf_io_addr[0]);
+	lens += acpigen_write_name_byte("SBLK", sysconf.sblk);
+	lens += acpigen_write_name_dword("SBDN", sysconf.sbdn);
+	msr = rdmsr(TOP_MEM);
+	lens += acpigen_write_name_dword("TOM1", msr.lo);
+	msr = rdmsr(TOP_MEM2);
+	lens += acpigen_write_name_dword("TOM2", msr.lo);
+	lens += amdfam10_acpi_write_HT();
+	lens += acpigen_write_name_byte("CBB", (u8)(CBB));
+
+	if(CBB == 0xff) {
+		lens += acpigen_write_name_byte("CBST", 0x0);
+	} else {
+		/* SB chain on other bus then 0 */
+		lens += acpigen_write_name_byte("CBST",
+	    ((sysconf.pci1234[0] >> 12) & 0xff) ? 0xf : 0x0);
+	}
+
+	if((CBB == 0xff) && (sysconf.nodes>32)) {
+		lens += acpigen_write_name_byte("CBS2", 0xf);
+		lens += acpigen_write_name_byte("CBB2", (u8)(CBB - 1));
+	} else {
+		lens += acpigen_write_name_byte("CBS2", 0x0);
+		lens += acpigen_write_name_byte("CBB2", 0x0);
+	}
+	/* patch package len minus opcode size */
+	acpigen_patch_len(lens - 1);
+	return lens;
+}
--
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to