]> git.sur5r.net Git - u-boot/blobdiff - arch/x86/lib/realmode.c
x86: Put global data on the stack
[u-boot] / arch / x86 / lib / realmode.c
index 5be827c66b124d1d0520a747599a9b19b89d32c9..75511b2bdf9893f29483d6d3b70d8817f43c3f47 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * (C) Copyright 2002
- * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
+ * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
 #include <asm/ptrace.h>
 #include <asm/realmode.h>
 
-#define REALMODE_MAILBOX ((char*)0xe00)
-
-extern ulong __realmode_start;
-extern ulong __realmode_size;
-extern char realmode_enter;
+#define REALMODE_MAILBOX ((char *)0xe00)
 
 int realmode_setup(void)
 {
-       ulong realmode_start = (ulong)&__realmode_start + gd->reloc_off;
+       /* The realmode section is not relocated and still in the ROM. */
+       ulong realmode_start = (ulong)&__realmode_start;
        ulong realmode_size = (ulong)&__realmode_size;
 
        /* copy the realmode switch code */
        if (realmode_size > (REALMODE_MAILBOX - (char *)REALMODE_BASE)) {
                printf("realmode switch too large (%ld bytes, max is %d)\n",
                       realmode_size,
-                      (REALMODE_MAILBOX - (char *)REALMODE_BASE));
+                      (int)(REALMODE_MAILBOX - (char *)REALMODE_BASE));
                return -1;
        }
 
@@ -63,15 +60,14 @@ int enter_realmode(u16 seg, u16 off, struct pt_regs *in, struct pt_regs *out)
 
        in->eip = off;
        in->xcs = seg;
-       if (3>(in->esp & 0xffff)) {
+       if ((in->esp & 0xffff) < 4)
                printf("Warning: entering realmode with sp < 4 will fail\n");
-       }
 
        memcpy(REALMODE_MAILBOX, in, sizeof(struct pt_regs));
        asm("wbinvd\n");
 
        __asm__ volatile (
-                "lcall $0x20,%0\n"  : :  "i" (&realmode_enter) );
+                "lcall $0x20,%0\n" : : "i" (&realmode_enter));
 
        asm("wbinvd\n");
        memcpy(out, REALMODE_MAILBOX, sizeof(struct pt_regs));
@@ -79,9 +75,10 @@ int enter_realmode(u16 seg, u16 off, struct pt_regs *in, struct pt_regs *out)
        return out->eax;
 }
 
-
-/* This code is supposed to access a realmode interrupt
- * it does currently not work for me */
+/*
+ * This code is supposed to access a realmode interrupt
+ * it does currently not work for me
+ */
 int enter_realmode_int(u8 lvl, struct pt_regs *in, struct pt_regs *out)
 {
        /* place two instructions at 0x700 */
@@ -92,5 +89,5 @@ int enter_realmode_int(u8 lvl, struct pt_regs *in, struct pt_regs *out)
 
        enter_realmode(0x00, 0x700, in, out);
 
-       return out->eflags&1;
+       return out->eflags & 0x00000001;
 }