aboutsummaryrefslogtreecommitdiff
path: root/src/northbridge/amd
diff options
context:
space:
mode:
authorRudolf Marek <r.marek@assembler.cz>2009-02-01 18:35:15 +0000
committerRudolf Marek <r.marek@assembler.cz>2009-02-01 18:35:15 +0000
commit293b5f52253ec0e5edb38e9f7113afc7e8f8ba6e (patch)
treed0ab38cd89f3ceace9ee3de1cddd6bb5d9acea1a /src/northbridge/amd
parent1c49bc9744c2e9044ddd1c8d20a1728f57eda85c (diff)
Following patch adds dynamic ACPI AML code generator which can be used to
generate run-time ACPI ASL code. Moreover it demonstrates its use on Asus M2V-MX SE where the SSDT table is generated by new function k8acpi_write_vars (technically similar to update_ssdt). But lot of nicer. x Signed-off-by: Rudolf Marek <r.marek@assembler.cz> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3925 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/northbridge/amd')
-rw-r--r--src/northbridge/amd/amdk8/amdk8_acpi.c75
-rw-r--r--src/northbridge/amd/amdk8/amdk8_acpi.h25
2 files changed, 99 insertions, 1 deletions
diff --git a/src/northbridge/amd/amdk8/amdk8_acpi.c b/src/northbridge/amd/amdk8/amdk8_acpi.c
index e3709c4753..16739c4751 100644
--- a/src/northbridge/amd/amdk8/amdk8_acpi.c
+++ b/src/northbridge/amd/amdk8/amdk8_acpi.c
@@ -226,7 +226,6 @@ unsigned long acpi_fill_slit(unsigned long current)
p[i*nodes+j] = hops_8[i*nodes+j] * 2 + 10;
#endif
-
}
}
}
@@ -236,6 +235,80 @@ unsigned long acpi_fill_slit(unsigned long current)
return current;
}
+static int k8acpi_write_HT(void) {
+ device_t dev;
+ uint32_t dword;
+ 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 k8acpi_write_pci_data(int dlen, char *name, int offset) {
+ device_t dev;
+ uint32_t dword;
+ int len, lenp, i;
+
+ dev = dev_find_slot(0, PCI_DEVFN(0x18, 1));
+
+ len = acpigen_write_name(name);
+ lenp = acpigen_write_package(dlen);
+ for(i=0; i<dlen; i++) {
+ dword = pci_read_config32(dev, offset+i*4);
+ lenp += acpigen_write_dword(dword);
+ }
+ // minus the opcode
+ acpigen_patch_len(lenp - 1);
+ return len + lenp;
+}
+
+int k8acpi_write_vars(void)
+{
+ int lens;
+ msr_t msr;
+ char pscope[] = "\\._SB_PCI0";
+
+ lens = acpigen_write_scope(pscope);
+ lens += k8acpi_write_pci_data(4, "BUSN", 0xe0);
+ lens += k8acpi_write_pci_data(8, "PCIO", 0xc0);
+ lens += k8acpi_write_pci_data(16, "MMIO", 0x80);
+ lens += acpigen_write_name_byte("SBLK", sysconf.sblk);
+ lens += acpigen_write_name_byte("CBST",
+ ((sysconf.pci1234[0] >> 12) & 0xff) ? 0xf : 0x0);
+ lens += acpigen_write_name_dword("SBDN", sysconf.sbdn);
+ msr = rdmsr(TOP_MEM);
+ lens += acpigen_write_name_dword("TOM1", msr.lo);
+
+ lens += k8acpi_write_HT();
+ //minus opcode
+ acpigen_patch_len(lens - 1);
+ return lens;
+}
+
// moved from mb acpi_tables.c
static void intx_to_stream(u32 val, u32 len, u8 *dest)
{
diff --git a/src/northbridge/amd/amdk8/amdk8_acpi.h b/src/northbridge/amd/amdk8/amdk8_acpi.h
new file mode 100644
index 0000000000..faf0474e65
--- /dev/null
+++ b/src/northbridge/amd/amdk8/amdk8_acpi.h
@@ -0,0 +1,25 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2009 Rudolf Marek <r.marek@assembler.cz>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License v2 as published by
+ * the Free Software Foundation.
+ *
+ * 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
+ */
+#ifndef AMDK8_ACPI_H
+#define AMDK8_ACPI_H
+#include <arch/acpigen.h>
+
+int k8acpi_write_vars(void);
+
+#endif