This patch unifies the use of config options in v2 to all start with CONFIG_
[coreboot.git] / src / cpu / amd / model_gx2 / vsmsetup.c
index b462fcd8fdcb84a4d46d13d79da91f5d7a1f8ddf..3c71cdb4083b57fc586c8fe549d8f64f2da54a63 100644 (file)
@@ -5,6 +5,14 @@
 #undef __KERNEL__
 #include <arch/io.h>
 #include <string.h>
+#include <cpu/amd/gx2def.h>
+
+/* what a mess this uncompress thing is. I am not at all happy about how this 
+ * was done, but can't fix it yet. RGM
+ */
+#warning "Fix the uncompress once coreboot knows how to do it"
+#include "../lib/nrv2b.c"
+
 /* vsmsetup.c derived from vgabios.c. Derived from: */
 
 /*------------------------------------------------------------ -*- C -*-
@@ -63,7 +71,7 @@
  *--------------------------------------------------------------------*/
 
 /* Modified to be a self sufficient plug in so that it can be used 
-   without reliance on other parts of core Linuxbios 
+   without reliance on other parts of core coreboot 
    (C) 2005 Nick.Barker9@btinternet.com
 
   Used initially for epia-m where there are problems getting the bios
@@ -244,8 +252,9 @@ void do_vsmbios(void)
        unsigned long busdevfn;
        unsigned int rom = 0;
        unsigned char *buf;
-       unsigned int size = 256*1024;
+       unsigned int size = SMM_SIZE*1024;
        int i;
+       unsigned long ilen, olen;
        
        printk_err("do_vsmbios\n");
        /* clear vsm bios data area */
@@ -260,11 +269,15 @@ void do_vsmbios(void)
          * much better parameterized 
          */
        //rom = 0xfff80000;
-       rom = 0xfffc0000;
+       //rom = 0xfffc0000;
+       /* the VSA starts at the base of rom - 64 */
+       rom = ((unsigned long) 0) - (CONFIG_ROM_SIZE  + 64*1024);
 
-       buf = (unsigned char *) rom;
+       buf = (unsigned char *) 0x60000;
+       olen = unrv2b((uint8_t *)rom, buf, &ilen);
+       printk_debug("buf ilen %d olen%d\n", ilen, olen);
        printk_debug("buf %p *buf %d buf[256k] %d\n",
-                    buf, buf[0], buf[256*1024]);
+                    buf, buf[0], buf[SMM_SIZE*1024]);
        printk_debug("buf[0x20] signature is %x:%x:%x:%x\n",
                     buf[0x20] ,buf[0x21] ,buf[0x22],buf[0x23]);
        /* check for post code at start of vsainit.bin. If you don't see it,
@@ -275,7 +288,7 @@ void do_vsmbios(void)
                return;
        }
 
-       memcpy((void *) 0x60000, buf, size);
+       //memcpy((void *) 0x60000, buf, size);
 
        //for (i = 0; i < 0x800000; i++)
        //      outb(0xaa, 0x80);
@@ -283,6 +296,10 @@ void do_vsmbios(void)
        /* ecx gets smm, edx gets sysm */
        printk_err("Call real_mode_switch_call_vsm\n");
        real_mode_switch_call_vsm(0x10000026, 0x10000028);
+
+       /* restart timer 1 */
+       outb(0x56, 0x43);
+       outb(0x12, 0x41);
 }
 
 
@@ -303,10 +320,10 @@ struct realidt {
 // that simplifies a lot of things ...
 // we'll just push all the registers on the stack as longwords, 
 // and pop to protected mode. 
-// second, since this only ever runs as part of linuxbios
+// second, since this only ever runs as part of coreboot
 // we know all the segment register values -- so we don't save any.
 // keep the handler that calls things small. It can do a call to 
-// more complex code in linuxbios itself. This helps a lot as we don't
+// more complex code in coreboot itself. This helps a lot as we don't
 // have to do address fixup in this little stub, and calls are absolute
 // so the handler is relocatable.
 void handler(void)
@@ -634,7 +651,7 @@ pcibios(unsigned long *pedi, unsigned long *pesi, unsigned long *pebp,
                        // busnum is an unsigned char;
                        // devfn is an int, so we mask it off. 
                        busdevfn = (dev->bus->secondary << 8)
-                               | (dev->path.u.pci.devfn & 0xff);
+                               | (dev->path.pci.devfn & 0xff);
                        printk_debug("0x%x: return 0x%x\n", func, busdevfn);
                        *pebx = busdevfn;
                        retval = 0;