reformating, we are going to use it for
authorLi-Ta Lo <ollie@lanl.gov>
Fri, 17 Mar 2006 19:52:52 +0000 (19:52 +0000)
committerLi-Ta Lo <ollie@lanl.gov>
Fri, 17 Mar 2006 19:52:52 +0000 (19:52 +0000)
vsa on geode GX.

There was some bug in setting up stack, what was that?

git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2208 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

src/mainboard/via/epia-m/vgabios.c

index 67620eaa2e8980a89302c1706ec859b6f43841c7..8565ba2236108d4d491504835477a43dca95690c 100644 (file)
    Core part of the bios no longer sets up any 16 bit segments */
 __asm__ (
        /* pointer to original gdt */
-       "gdtarg:                        \n\t"
-       ".word  gdt_limit       \n\t"
-       ".long  gdt                     \n\t"           
+       "gdtarg:                        \n"
+       "       .word   gdt_limit       \n"
+       "       .long   gdt             \n"             
 
        /* compute the table limit */
-       "__mygdt_limit = __mygdt_end - __mygdt - 1      \n\t"
+       "__mygdt_limit = __mygdt_end - __mygdt - 1      \n"
 
-       "__mygdtaddr:                   \n\t"
-       ".word  __mygdt_limit   \n\t"
-       ".long  __mygdt                 \n\t"           
+       "__mygdtaddr:                   \n"
+       "       .word   __mygdt_limit   \n"
+       "       .long   __mygdt         \n"
 
-
-       "__mygdt:                               \n\t"
+       "__mygdt:                       \n"
        /* selgdt 0, unused */
-       ".word  0x0000, 0x0000  \n\t"
-       ".byte  0x00, 0x00, 0x00, 0x00  \n\t"
+       "       .word   0x0000, 0x0000  \n"
+       "       .byte   0x00, 0x00, 0x00, 0x00  \n"
 
        /* selgdt 8, unused */
-       ".word  0x0000, 0x0000                  \n\t"
-       ".byte  0x00, 0x00, 0x00, 0x00  \n\t"
+       "       .word   0x0000, 0x0000          \n"
+       "       .byte   0x00, 0x00, 0x00, 0x00  \n"
 
        /* selgdt 0x10, flat code segment */
-       ".word  0xffff, 0x0000                  \n\t"           
-       ".byte  0x00, 0x9b, 0xcf, 0x00  \n\t"   
+       "       .word   0xffff, 0x0000          \n"
+       "       .byte   0x00, 0x9b, 0xcf, 0x00  \n"     
 
        /* selgdt 0x18, flat data segment */
-       ".word  0xffff, 0x0000                  \n\t"           
-       ".byte  0x00, 0x93, 0xcf, 0x00  \n\t"
+       "       .word   0xffff, 0x0000          \n"
+       "       .byte   0x00, 0x93, 0xcf, 0x00  \n"
 
        /* selgdt 0x20, unused */
-       ".word  0x0000, 0x0000                  \n\t"
-       ".byte  0x00, 0x00, 0x00, 0x00  \n\t"
+       "       .word   0x0000, 0x0000          \n"
+       "       .byte   0x00, 0x00, 0x00, 0x00  \n"
 
-        /*selgdt 0x28 16-bit 64k code at 0x00000000 */
-       ".word 0xffff, 0x0000                   \n\t"
-       ".byte 0, 0x9a, 0, 0                    \n\t"
+        /* selgdt 0x28 16-bit 64k code at 0x00000000 */
+       "       .word   0xffff, 0x0000          \n"
+       "       .byte   0, 0x9a, 0, 0           \n"
 
        /* selgdt 0x30 16-bit 64k data at 0x00000000 */
-       ".word 0xffff, 0x0000                   \n\t"
-       ".byte 0, 0x92, 0, 0                    \n\t"
+       "       .word   0xffff, 0x0000          \n"
+       "       .byte   0, 0x92, 0, 0           \n"
 
-       "__mygdt_end:                                   \n\t"
+       "__mygdt_end:                           \n"
 );
 
 /* Declare a pointer to where our idt is going to be i.e. at mem zero */
-__asm__ (
-       "__myidt:       \n"
-       "    .word 1023 \n"
-       "    .long 0 \n"
-       "    .word 0 \n"
+__asm__ ("__myidt:             \n"
+        /* 16-bit limit */
+        "      .word 1023      \n"
+        /* 24-bit base */
+        "      .long 0         \n"
+        "      .word 0         \n"
 );
 
 /* The address arguments to this function are PHYSICAL ADDRESSES */ 
@@ -135,92 +135,93 @@ static void real_mode_switch_call_vga(unsigned long devfn)
        __asm__ __volatile__ (
                // paranoia -- does ecx get saved? not sure. This is 
                // the easiest safe thing to do.
-               "       pushal\n"
+               "       pushal                  \n"
                /* save the stack */
-               "       mov %esp, __stack\n"
-               "       jmp 1f\n"
-               "__stack: .long 0\n"
+               "       mov     %esp, __stack   \n"
+               "       jmp     1f              \n"
+               "__stack: .long 0               \n"
                "1:\n"
                /* get devfn into %ecx */
-               "       movl    %esp, %ebp\n"
-               "       movl    8(%ebp), %ecx\n"
+               "       movl    %esp, %ebp      \n"
+               "       movl    8(%ebp), %ecx   \n"
                /* load 'our' gdt */
-               "   lgdt %cs:__mygdtaddr                \n\t"
+               "       lgdt    %cs:__mygdtaddr \n"
 
                /*  This configures CS properly for real mode. */
-               "       ljmp $0x28, $__rms_16bit\n"
-               "__rms_16bit:                 \n"
-               ".code16                      \n"
+               "       ljmp    $0x28, $__rms_16bit\n"
+               "__rms_16bit:                   \n"
+               "       .code16                 \n"
                /* 16 bit code from here on... */
 
                /* Load the segment registers w/ properly configured segment
                 * descriptors.  They will retain these configurations (limits,
                 * writability, etc.) once protected mode is turned off. */
-               "       mov  $0x30, %ax         \n"
-               "       mov  %ax, %ds          \n"
-               "       mov  %ax, %es          \n"
-               "       mov  %ax, %fs          \n"
-               "       mov  %ax, %gs          \n"
-               "       mov  %ax, %ss          \n"
+               "       mov     $0x30, %ax      \n"
+               "       mov     %ax, %ds        \n"
+               "       mov     %ax, %es        \n"
+               "       mov     %ax, %fs        \n"
+               "       mov     %ax, %gs        \n"
+               "       mov     %ax, %ss        \n"
 
                /* Turn off protection (bit 0 in CR0) */
-               "       movl %cr0, %eax        \n"
-               "       andl $0xFFFFFFFE, %eax  \n"
-               "       movl %eax, %cr0        \n"
+               "       movl    %cr0, %eax      \n"
+               "       andl    $0xFFFFFFFE, %eax \n"
+               "       movl    %eax, %cr0      \n"
 
                /* Now really going into real mode */
-               "       ljmp $0,  $__rms_real \n"
-               "__rms_real:                  \n"
+               "       ljmp    $0,  $__rms_real\n"
+               "__rms_real:                    \n"
 
-               // put the stack at the end of page zero. 
-               // that way we can easily share it between real and protected, 
-               // since the 16-bit ESP at segment 0 will work for any case. 
+               /* put the stack at the end of page zero. 
+                * that way we can easily share it between real and protected, 
+                * since the 16-bit ESP at segment 0 will work for any case. 
                /* Setup a stack */
-               "    mov  $0x0, %ax       \n"
-               "    mov  %ax, %ss          \n"
-               "    movl  $0x1000, %eax       \n"
-               "    movl  %eax, %esp          \n"
+               "       mov     $0x0, %ax       \n"
+               "       mov     %ax, %ss        \n"
+               "       movl    $0x1000, %eax   \n"
+               "       movl    %eax, %esp      \n"
 
                /* Load our 16 it idt */
-               "    xor  %ax, %ax          \n"
-               "    mov  %ax, %ds          \n"
-               "    lidt __myidt            \n"
-
+               "       xor     %ax, %ax        \n"
+               "       mov     %ax, %ds        \n"
+               "       lidt    __myidt         \n"
 
                /* Dump zeros in the other segregs */
-               "    mov  %ax, %es          \n"
-               "    mov  %ax, %fs          \n"
-               "    mov  %ax, %gs          \n"
-               "    mov  $0x40, %ax          \n"
-               "    mov  %ax, %ds          \n"
-               "    mov %cx, %ax       \n"
-               /* go run the code */
-               " .byte 0x9a, 0x03, 0, 0, 0xc0  \n"
+               "       mov     %ax, %es        \n"
+               "       mov     %ax, %fs        \n"
+               "       mov     %ax, %gs        \n"
+               "       mov     $0x40, %ax      \n"
+               "       mov     %ax, %ds        \n"
+               "       mov     %cx, %ax        \n"
+
+               /* run VGA BIOS at 0xc000:0003 */
+               "       lcall   $0xc000, $0x0003\n"
 
                /* if we got here, just about done. 
                 * Need to get back to protected mode */
-               "movl   %cr0, %eax\n"
-               "orl    $0x0000001, %eax\n" /* PE = 1 */
-               "movl   %eax, %cr0\n"
+               "       movl    %cr0, %eax      \n"
+               "       orl     $0x0000001, %eax\n" /* PE = 1 */
+               "       movl    %eax, %cr0      \n"
 
                /* Now that we are in protected mode jump to a 32 bit code segment. */
-               "data32 ljmp    $0x10, $vgarestart\n"
+               "       data32  ljmp    $0x10, $vgarestart\n"
                "vgarestart:\n"
-               ".code32\n"
-               "    movw $0x18, %ax          \n"
-               "    mov  %ax, %ds          \n"
-               "    mov  %ax, %es          \n"
-               "    mov  %ax, %fs          \n"
-               "    mov  %ax, %gs          \n"
-               "    mov  %ax, %ss          \n"
+               "       .code32\n"
+               "       movw    $0x18, %ax      \n"
+               "       mov     %ax, %ds        \n"
+               "       mov     %ax, %es        \n"
+               "       mov     %ax, %fs        \n"
+               "       mov     %ax, %gs        \n"
+               "       mov     %ax, %ss        \n"
 
                /* restore proper gdt and idt */
-               "        lgdt %cs:gdtarg                        \n"
-               "    lidt idtarg            \n"
-               ".globl vga_exit\n"
-               "vga_exit:\n"
-               "    mov  __stack, %esp\n"
-               "    popal\n"
+               "       lgdt    %cs:gdtarg      \n"
+               "       lidt    idtarg          \n"
+
+               ".globl vga_exit                \n"
+               "vga_exit:                      \n"
+               "       mov     __stack, %esp   \n"
+               "       popal                   \n"
                );
 }
 
@@ -228,109 +229,109 @@ __asm__ (".text\n""real_mode_switch_end:\n");
 extern char real_mode_switch_end[];
 
 /* call vga bios int 10 function 0x4f14 to enable main console 
-   epia-m does not always autosence the main console so forcing it on is good !! */
+   epia-m does not always autosence the main console so forcing it on is good !! */ 
 void vga_enable_console()
 {
        __asm__ __volatile__ (
-               // paranoia -- does ecx get saved? not sure. This is 
-               // the easiest safe thing to do.
-               "       pushal\n"
+               /* paranoia -- does ecx get saved? not sure. This is 
+                * the easiest safe thing to do. */
+               "       pushal                  \n"
                /* save the stack */
-               "       mov %esp, __stack\n"
+               "       mov     %esp, __stack   \n"
 
                /* load 'our' gdt */
-               "   lgdt %cs:__mygdtaddr                \n\t"
+               "       lgdt    %cs:__mygdtaddr \n"
 
                /*  This configures CS properly for real mode. */
-               "       ljmp $0x28, $__vga_ec_16bit\n"
-               "__vga_ec_16bit:                 \n"
-               ".code16                      \n"
+               "       ljmp    $0x28, $__vga_ec_16bit\n"
+               "__vga_ec_16bit:                \n"
+               "       .code16                 \n"
                /* 16 bit code from here on... */
 
                /* Load the segment registers w/ properly configured segment
                 * descriptors.  They will retain these configurations (limits,
                 * writability, etc.) once protected mode is turned off. */
-               "       mov  $0x30, %ax         \n"
-               "       mov  %ax, %ds          \n"
-               "       mov  %ax, %es          \n"
-               "       mov  %ax, %fs          \n"
-               "       mov  %ax, %gs          \n"
-               "       mov  %ax, %ss          \n"
+               "       mov     $0x30, %ax      \n"
+               "       mov     %ax, %ds        \n"
+               "       mov     %ax, %es        \n"
+               "       mov     %ax, %fs        \n"
+               "       mov     %ax, %gs        \n"
+               "       mov     %ax, %ss        \n"
 
                /* Turn off protection (bit 0 in CR0) */
-               "       movl %cr0, %eax        \n"
-               "       andl $0xFFFFFFFE, %eax  \n"
-               "       movl %eax, %cr0        \n"
+               "       movl    %cr0, %eax      \n"
+               "       andl    $0xFFFFFFFE, %eax\n"
+               "       movl    %eax, %cr0      \n"
 
                /* Now really going into real mode */
-               "       ljmp $0,  $__vga_ec_real \n"
+               "       ljmp    $0, $__vga_ec_real \n"
                "__vga_ec_real:                  \n"
 
-               // put the stack at the end of page zero. 
-               // that way we can easily share it between real and protected, 
-               // since the 16-bit ESP at segment 0 will work for any case. 
+               /* put the stack at the end of page zero. 
+                * that way we can easily share it between real and protected, 
+                * since the 16-bit ESP at segment 0 will work for any case. 
                /* Setup a stack */
-               "    mov  $0x0, %ax       \n"
-               "    mov  %ax, %ss          \n"
-               "    movl  $0x1000, %eax       \n"
-               "    movl  %eax, %esp          \n"
+               "       mov     $0x0, %ax       \n"
+               "       mov     %ax, %ss        \n"
+               "       movl    $0x1000, %eax   \n"
+               "       movl    %eax, %esp      \n"
+
                /* debugging for RGM */
-               "    mov $0x11, %al     \n"
-               " outb  %al, $0x80\n"
+               "       mov     $0x11, %al      \n"
+               "       outb    %al, $0x80      \n"
 
                /* Load our 16 it idt */
-               "    xor  %ax, %ax          \n"
-               "    mov  %ax, %ds          \n"
-               "    lidt __myidt            \n"
+               "       xor     %ax, %ax        \n"
+               "       mov     %ax, %ds        \n"
+               "       lidt    __myidt         \n"
 
                /* Dump zeros in the other segregs */
-               "    mov  %ax, %ds          \n"
-               "    mov  %ax, %es          \n"
-               "    mov  %ax, %fs          \n"
-               "    mov  %ax, %gs          \n"
+               "       mov     %ax, %ds        \n"
+               "       mov     %ax, %es        \n"
+               "       mov     %ax, %fs        \n"
+               "       mov     %ax, %gs        \n"
 
                /* ask bios to enable main console */
-               /* set up for int 10 call - values found from X server bios call routines */
-               "    movw $0x4f14,%ax    \n"
-               "    movw $0x8003,%bx     \n"
-               "    movw $1, %cx          \n"
-               "    movw $0, %dx          \n"
-               "    movw $0, %di          \n"
-               "  .byte 0xcd, 0x10             \n"
-               " movb $0x55, %al\noutb %al, $0x80\n"
+               /* set up for int 10 call - values found from X server
+                * bios call routines */
+               "       movw    $0x4f14,%ax     \n"
+               "       movw    $0x8003,%bx     \n"
+               "       movw    $1, %cx         \n"
+               "       movw    $0, %dx         \n"
+               "       movw    $0, %di         \n"
+               "       int     $0x10           \n"
+
+               "       movb    $0x55, %al      \n"
+               "       outb    %al, $0x80      \n"
 
                /* if we got here, just about done. 
                 * Need to get back to protected mode */
-               "movl   %cr0, %eax\n"
-               "orl    $0x0000001, %eax\n" /* PE = 1 */
-               "movl   %eax, %cr0\n"
+               "       movl    %cr0, %eax      \n"
+               "       orl     $0x0000001, %eax\n" /* PE = 1 */
+               "       movl    %eax, %cr0      \n"
 
                /* Now that we are in protected mode jump to a 32 bit code segment. */
-               "data32 ljmp    $0x10, $vga_ec_restart\n"
+               "       data32  ljmp    $0x10, $vga_ec_restart\n"
                "vga_ec_restart:\n"
-               ".code32\n"
-               "    movw $0x18, %ax          \n"
-               "    mov  %ax, %ds          \n"
-               "    mov  %ax, %es          \n"
-               "    mov  %ax, %fs          \n"
-               "    mov  %ax, %gs          \n"
-               "    mov  %ax, %ss          \n"
-
+               "       .code32\n"
+               "       movw    $0x18, %ax      \n"
+               "       mov     %ax, %ds        \n"
+               "       mov     %ax, %es        \n"
+               "       mov     %ax, %fs        \n"
+               "       mov     %ax, %gs        \n"
+               "       mov     %ax, %ss        \n"
 
                /* restore proper gdt and idt */
-               "        lgdt %cs:gdtarg                        \n"
-               "    lidt idtarg            \n"
-               ".globl vga__ec_exit\n"
+               "       lgdt    %cs:gdtarg      \n"
+               "       lidt    idtarg          \n"
+               "       .globl  vga__ec_exit    \n"
                "vga_ec_exit:\n"
-               "    mov  __stack, %esp\n"
-               "    popal\n"
+               "       mov     __stack, %esp   \n"
+               "       popal\n"
                );
 }
 
-
-void
-do_vgabios(void)
+void do_vgabios(void)
 {
        device_t dev;
        unsigned long busdevfn;
@@ -340,19 +341,20 @@ do_vgabios(void)
        int i;
        
        /* clear vga bios data area */
-       for (i=0x400; i<0x500; i++) {
+       for (i = 0x400; i < 0x500; i++) {
                *(unsigned char *) i = 0;
        }
 
        dev = dev_find_class(PCI_CLASS_DISPLAY_VGA<<8 , 0);
 
-       if (! dev) {
+       if (!dev) {
                printk_debug("NO VGA FOUND\n");
                return;
        }
        printk_debug("found VGA: vid=%x, did=%x\n", dev->vendor, dev->device);
-       
-       /* declare rom address here - keep any config data out of the way of core LXB stuff */
+
+       /* declare rom address here - keep any config data out of the way
+        * of core LXB stuff */
 
        rom = 0xfffc0000;
        pci_write_config32(dev, PCI_ROM_ADDRESS, rom|1);
@@ -373,12 +375,10 @@ do_vgabios(void)
                        real_mode_switch_call_vga(busdevfn);
                } else
                        printk_debug("Failed to copy VGA BIOS to 0xc0000\n");
-               
        } else 
                printk_debug("BAD SIGNATURE 0x%x 0x%x\n", buf[0], buf[1]);
-       
-       pci_write_config32(dev, PCI_ROM_ADDRESS, 0);
 
+       pci_write_config32(dev, PCI_ROM_ADDRESS, 0);
 }
 
 
@@ -405,33 +405,33 @@ struct realidt {
 // more complex code in linuxbios 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) {
+void handler(void)
+{
        __asm__ __volatile__ ( 
-               ".code16\n"
-               "idthandle:\n"
-               "       pushal\n"
-               "       movb $0, %al\n"
-               "       ljmp $0, $callbiosint16\n"
-               "end_idthandle:\n"
-               ".code32\n"
+               "       .code16         \n"
+               "idthandle:             \n"
+               "       pushal          \n"
+               "       movb    $0, %al \n"
+               "       ljmp    $0, $callbiosint16\n"
+               "end_idthandle:         \n"
+               "       .code32         \n"
                );
-
 }
 
-void debughandler(void) {
+void debughandler(void)
+{
        __asm__ __volatile__ ( 
-               ".code16\n"
-               "debughandle:\n"
-               "   pushw %cx  \n"
-               "   movw  $250, %cx \n"
-               "dbh1:         \n"
-               "       loop dbh1  \n"
-               "   popw %cx   \n"
-               "       iret \n"
-               "end_debughandle:\n"
-               ".code32\n"
+               "       .code16         \n"
+               "debughandle:           \n"
+               "       pushw   %cx     \n"
+               "       movw    $250, %cx \n"
+               "dbh1:                  \n"
+               "       loop    dbh1    \n"
+               "       popw    %cx     \n"
+               "       iret            \n"
+               "end_debughandle:       \n"
+               ".code32                \n"
                );
-
 }
 
 // Calling conventions. The first C function is called with this stuff
@@ -440,136 +440,118 @@ void debughandler(void) {
 // the C function will call the biosint function with these as
 // REFERENCE parameters. In this way, we can easily get 
 // returns back to the INTx caller (i.e. vgabios)
-void callbiosint(void) {
+void callbiosint(void)
+{
        __asm__ __volatile__ (
-               ".code16\n"
-               "callbiosint16:\n"
-               " push %ds \n"
-               " push %es \n"
-               " push %fs \n"
-               " push %gs \n"
+               "       .code16         \n"
+               "callbiosint16:         \n"
+               "       push    %ds     \n"
+               "       push    %es     \n"
+               "       push    %fs     \n"
+               "       push    %gs     \n"
                // clean up the int #. To save space we put it in the lower
                // byte. But the top 24 bits are junk. 
-               "andl $0xff, %eax\n"
+               "       andl    $0xff, %eax\n"
                // this push does two things:
                // - put the INT # on the stack as a parameter
                // - provides us with a temp for the %cr0 mods.
-               "pushl  %eax\n"
-               "movl    %cr0, %eax\n"
-               //"andl    $0x7FFAFFD1, %eax\n" /* PG,AM,WP,NE,TS,EM,MP = 0 */
-               //"orl    $0x60000001, %eax\n" /* CD, NW, PE = 1 */
-               "orl    $0x00000001, %eax\n" /* PE = 1 */
-               "movl    %eax, %cr0\n"
+               "       pushl   %eax    \n"
+               "       movl    %cr0, %eax\n"
+               "       orl     $0x00000001, %eax\n" /* PE = 1 */
+               "       movl    %eax, %cr0\n"
                /* Now that we are in protected mode jump to a 32 bit code segment. */
-               "data32  ljmp    $0x10, $biosprotect\n"
-               "biosprotect:\n"
-               ".code32\n"
-               "    movw $0x18, %ax          \n"
-               "    mov  %ax, %ds          \n"
-               "    mov  %ax, %es          \n"
-               "    mov  %ax, %fs          \n"
-               "    mov  %ax, %gs          \n"
-               "    mov  %ax, %ss          \n"
-               "   lidt idtarg         \n"
+               "       data32  ljmp    $0x10, $biosprotect\n"
+               "biosprotect:           \n"
+               "       .code32         \n"
+               "       movw    $0x18, %ax          \n"
+               "       mov     %ax, %ds          \n"
+               "       mov     %ax, %es          \n"
+               "       mov     %ax, %fs          \n"
+               "       mov     %ax, %gs          \n"
+               "       mov     %ax, %ss          \n"
+               "       lidt    idtarg         \n"
                "       call    biosint \n"
                // back to real mode ...
-               "    ljmp $0x28, $__rms_16bit2\n"
-               "__rms_16bit2:                 \n"
-               ".code16                      \n" /* 16 bit code from here on... */
-               
+               "       ljmp    $0x28, $__rms_16bit2\n"
+               "__rms_16bit2:                  \n"
+               "       .code16                 \n"
+               /* 16 bit code from here on... */
                /* Load the segment registers w/ properly configured segment
                 * descriptors.  They will retain these configurations (limits,
                 * writability, etc.) once protected mode is turned off. */
-               "    mov  $0x30, %ax         \n"
-               "    mov  %ax, %ds          \n"
-               "    mov  %ax, %es          \n"
-               "    mov  %ax, %fs          \n"
-               "    mov  %ax, %gs          \n"
-               "    mov  %ax, %ss          \n"
+               "       mov     $0x30, %ax      \n"
+               "       mov     %ax, %ds        \n"
+               "       mov     %ax, %es        \n"
+               "       mov     %ax, %fs        \n"
+               "       mov     %ax, %gs        \n"
+               "       mov     %ax, %ss        \n"
                
                /* Turn off protection (bit 0 in CR0) */
-               "    movl %cr0, %eax        \n"
-               "    andl $0xFFFFFFFE, %eax  \n"
-               "    movl %eax, %cr0        \n"
-               
+               "       movl    %cr0, %eax              \n"
+               "       andl    $0xFFFFFFFE, %eax       \n"
+               "       movl    %eax, %cr0              \n"
+
                /* Now really going into real mode */
-               "    ljmp $0,  $__rms_real2 \n"
-               "__rms_real2:                  \n"
-               
-               /* Setup a stack */
-               "    mov  $0x0, %ax       \n"
-               "    mov  %ax, %ss          \n"
+               "       ljmp $0,  $__rms_real2  \n"
+               "__rms_real2:                   \n"
+
+               /* Setup a stack
+                * FixME: where is esp? */
+               "       mov     $0x0, %ax       \n"
+               "       mov     %ax, %ss        \n"
+
                /* ebugging for RGM */
-               "    mov $0x11, %al      \n"
-               " outb  %al, $0x80\n"
-               "    xor  %ax, %ax          \n"
-               "    mov  %ax, %ds          \n"
-               "    lidt __myidt           \n"
-               "    mov  %ax, %es          \n"
-               "    mov  %ax, %fs          \n"
-               "    mov  %ax, %gs          \n"
-               "    mov  $0x40, %ax        \n"
-               "    mov  %ax, %ds          \n"
-               // pop the INT # that you pushed earlier
-               "   popl        %eax\n"
-               "   pop %gs \n"
-               "   pop %fs \n"
-               "   pop %es \n"
-               "   pop %ds \n"
-               "   popal\n"
-               "   iret\n"
-               ".code32\n"
+               "       mov     $0x11, %al      \n"
+               "       outb    %al, $0x80      \n"
+
+               /* Load our 16 it idt */
+               "       xor     %ax, %ax        \n"
+               "       mov     %ax, %ds        \n"
+               "       lidt    __myidt         \n"
+
+               /* Dump zeros in the other segregs */
+               "       mov     %ax, %es        \n"
+               "       mov     %ax, %fs        \n"
+               "       mov     %ax, %gs        \n"
+               "       mov     $0x40, %ax      \n"
+               "       mov     %ax, %ds        \n"
+
+               /* pop the INT # that you pushed earlier */
+               "       popl    %eax            \n"
+               "       pop     %gs             \n"
+               "       pop     %fs             \n"
+               "       pop     %es             \n"
+               "       pop     %ds             \n"
+               "       popal                   \n"
+               "       iret                    \n"
+               "       .code32                 \n"
                );
 }
 
-
 enum {
        PCIBIOS = 0x1a, 
        MEMSIZE = 0x12
 };
-int
-pcibios(
-        unsigned long *pedi,
-        unsigned long *pesi,
-        unsigned long *pebp,
-        unsigned long *pesp,
-        unsigned long *pebx,
-        unsigned long *pedx,
-        unsigned long *pecx,
-        unsigned long *peax,
-        unsigned long *pflags
-        );
-int
-handleint21(
-        unsigned long *pedi,
-        unsigned long *pesi,
-        unsigned long *pebp,
-        unsigned long *pesp,
-        unsigned long *pebx,
-        unsigned long *pedx,
-        unsigned long *pecx,
-        unsigned long *peax,
-        unsigned long *pflags
+
+int pcibios(unsigned long *pedi, unsigned long *pesi, unsigned long *pebp,
+           unsigned long *pesp, unsigned long *pebx, unsigned long *pedx,
+           unsigned long *pecx, unsigned long *peax, unsigned long *pflags);
+
+int handleint21(unsigned long *pedi, unsigned long *pesi, unsigned long *pebp,
+               unsigned long *pesp, unsigned long *pebx, unsigned long *pedx,
+               unsigned long *pecx, unsigned long *peax, unsigned long *pflags
         );
 
 extern void vga_exit(void);
 
-int
-biosint(
-       unsigned long intnumber,
-       unsigned long gsfs,
-       unsigned long dses,
-       unsigned long edi, 
-       unsigned long esi,
-       unsigned long ebp, 
-       unsigned long esp, 
-       unsigned long ebx, 
-       unsigned long edx, 
-       unsigned long ecx, 
-       unsigned long eax, 
-       unsigned long cs_ip,
-       unsigned short stackflags
-       ) {
+int biosint(unsigned long intnumber,
+           unsigned long gsfs, unsigned long dses,
+           unsigned long edi, unsigned long esi,
+           unsigned long ebp, unsigned long esp, 
+           unsigned long ebx, unsigned long edx, 
+           unsigned long ecx, unsigned long eax, 
+           unsigned long cs_ip, unsigned short stackflags)
+{
        unsigned long ip; 
        unsigned long cs; 
        unsigned long flags;
@@ -579,10 +561,14 @@ biosint(
        cs = cs_ip >> 16;
        flags = stackflags;
        
-       printk_debug("biosint: # 0x%lx, eax 0x%lx ebx 0x%lx ecx 0x%lx edx 0x%lx\n", 
-                    intnumber, eax, ebx, ecx, edx);
-       printk_debug("biosint: ebp 0x%lx esp 0x%lx edi 0x%lx esi 0x%lx\n", ebp, esp, edi, esi);
-       printk_debug("biosint: ip 0x%x cs 0x%x flags 0x%x\n", ip, cs, flags);
+       printk_debug("biosint: INT# 0x%lx\n", intnumber);
+       printk_debug("biosint: eax 0x%lx ebx 0x%lx ecx 0x%lx edx 0x%lx\n", 
+                     eax, ebx, ecx, edx);
+       printk_debug("biosint: ebp 0x%lx esp 0x%lx edi 0x%lx esi 0x%lx\n",
+                    ebp, esp, edi, esi);
+       printk_debug("biosint:  ip 0x%x   cs 0x%x  flags 0x%x\n",
+                    ip, cs, flags);
+
        // cases in a good compiler are just as good as your own tables. 
        switch (intnumber) {
        case 0 ... 15:
@@ -667,8 +653,8 @@ void setup_realmode_idt(void)
        intbyte = codeptr + 3;
        *intbyte = 0x42; /* int42 is the relocated int10 */
 
-       /* debug handler - useful to set a programmable delay between instructions if the TF bit is set upon
-           call to real mode */
+       /* debug handler - useful to set a programmable delay between instructions if the
+          TF bit is set upon call to real mode */
        idts[1].cs = 0;
        idts[1].offset = 16384;
        memcpy(16384, &debughandle, &end_debughandle - &debughandle);
@@ -697,17 +683,10 @@ enum {
 };
 
 int
-pcibios(
-       unsigned long *pedi, 
-       unsigned long *pesi,
-       unsigned long *pebp, 
-       unsigned long *pesp, 
-       unsigned long *pebx, 
-       unsigned long *pedx, 
-       unsigned long *pecx, 
-       unsigned long *peax, 
-       unsigned long *pflags
-       ) {
+pcibios(unsigned long *pedi, unsigned long *pesi, unsigned long *pebp, 
+       unsigned long *pesp, unsigned long *pebx, unsigned long *pedx, 
+       unsigned long *pecx, unsigned long *peax, unsigned long *pflags)
+{
        unsigned long edi = *pedi;
        unsigned long esi = *pesi;
        unsigned long ebp = *pebp;
@@ -808,7 +787,8 @@ pcibios(
                
                if (retval) 
                        retval = PCIBIOS_BADREG;
-               printk_debug("0x%x: bus %d devfn 0x%x reg 0x%x val 0x%lx\n", func, bus, devfn, reg, *pecx);
+               printk_debug("0x%x: bus %d devfn 0x%x reg 0x%x val 0x%lx\n",
+                            func, bus, devfn, reg, *pecx);
                *peax = 0;
                retval = 0;
        }
@@ -821,13 +801,11 @@ pcibios(
        return retval;
 } 
 
-
-
-int handleint21( unsigned long *edi, unsigned long *esi, unsigned long *ebp,
-                         unsigned long *esp, unsigned long *ebx, unsigned long *edx,
-                         unsigned long *ecx, unsigned long *eax, unsigned long *flags)
+int handleint21(unsigned long *edi, unsigned long *esi, unsigned long *ebp,
+               unsigned long *esp, unsigned long *ebx, unsigned long *edx,
+               unsigned long *ecx, unsigned long *eax, unsigned long *flags)
 {
-int res=-1;
+       int res=-1;
        switch(*eax&0xffff)
        {
        case 0x5f19: