aboutsummaryrefslogtreecommitdiff
path: root/src/cpu/k8/cpufixup.c
diff options
context:
space:
mode:
authorEric Biederman <ebiederm@xmission.com>2003-04-22 19:02:15 +0000
committerEric Biederman <ebiederm@xmission.com>2003-04-22 19:02:15 +0000
commit8ca8d7665d671e10d72b8fcb4d69121d75f7906e (patch)
treedaad2699b4e6b6014bce5a76e82dd9c974801777 /src/cpu/k8/cpufixup.c
parentb138ac83b53da9abf3dc9a87a1cd4b3d3a8150bd (diff)
- Initial checkin of the freebios2 tree
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@784 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/cpu/k8/cpufixup.c')
-rw-r--r--src/cpu/k8/cpufixup.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/cpu/k8/cpufixup.c b/src/cpu/k8/cpufixup.c
new file mode 100644
index 0000000000..9f306d1156
--- /dev/null
+++ b/src/cpu/k8/cpufixup.c
@@ -0,0 +1,59 @@
+/* Needed so the AMD K8 runs correctly. */
+#include <console/console.h>
+#include <mem.h>
+#include <cpu/p6/msr.h>
+
+#define TOP_MEM 0xc001001A
+#define TOP_MEM2 0xc001001D
+#define IORR_FIRST 0xC0010016
+#define IORR_LAST 0xC0010019
+#define SYSCFG 0xC0010010
+
+#define MTRRVARDRAMEN (1 << 20)
+
+void k8_cpufixup(struct mem_range *mem)
+{
+ unsigned long lo = 0, hi = 0, i;
+ unsigned long ram_megabytes;
+
+ /* For now no Athlon board has significant holes in it's
+ * address space so just find the last memory region
+ * and compute the end of memory from that.
+ */
+ for(i = 0; mem[i].sizek; i++)
+ ;
+ if (i == 0)
+ return;
+ ram_megabytes = (mem[i-1].basek + mem[i-1].sizek) *1024;
+
+
+ // 8 MB alignment please
+ ram_megabytes += 0x7fffff;
+ ram_megabytes &= (~0x7fffff);
+
+ // set top_mem registers to ram size
+ printk_spew("Setting top_mem to 0x%x\n", ram_megabytes);
+ rdmsr(TOP_MEM, lo, hi);
+ printk_spew("TOPMEM was 0x%02x:0x%02x\n", hi, lo);
+ hi = 0;
+ lo = ram_megabytes;
+ wrmsr(TOP_MEM, lo, hi);
+
+ // I am setting this even though I won't enable it
+ wrmsr(TOP_MEM2, lo, hi);
+
+ /* zero the IORR's before we enable to prevent
+ * undefined side effects
+ */
+ lo = hi = 0;
+ for (i = IORR_FIRST; i <= IORR_LAST; i++)
+ wrmsr(i, lo, hi);
+
+ rdmsr(SYSCFG, lo, hi);
+ printk_spew("SYSCFG was 0x%x:0x%x\n", hi, lo);
+ lo |= MTRRVARDRAMEN;
+ wrmsr(SYSCFG, lo, hi);
+ rdmsr(SYSCFG, lo, hi);
+ printk_spew("SYSCFG IS NOW 0x%x:0x%x\n", hi, lo);
+}
+