Cleanup implementation of call16().
authorKevin O'Connor <kevin@koconnor.net>
Sat, 1 Mar 2008 19:46:37 +0000 (14:46 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 1 Mar 2008 19:46:37 +0000 (14:46 -0500)
TODO
src/rombios32.lds.S
src/util.h

diff --git a/TODO b/TODO
index d8d0128..08aaf91 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
 Find out why ubuntu compiles are failing.  Find work around.
 
-Fixup __call16 usage from util.h / rombios32.lds.S
-
 See if it is better to tell gcc that call16 clobbers all registers
 instead of having the code call pushal/popal.
 
index 5d7e772..78546cf 100644 (file)
@@ -23,7 +23,7 @@ SECTIONS
         __bss_start = . ;
         .bss      : { *(.bss) *(COMMON) }
         _end = . ;
-        __call16 = (0xf0000 | OFFSET___call16_from32) ;
+        __call16_from32 = (0xf0000 | OFFSET___call16_from32) ;
         /DISCARD/ : { *(.stab)
                      *(.stabstr)
                      *(.comment)
index cdb8b1b..7de577b 100644 (file)
@@ -67,29 +67,33 @@ void call16(struct bregs *callregs)
     asm volatile(
         "pushfl\n"   // Save flags
         "pushal\n"   // Save registers
+#ifdef MODE16
         "calll __call16\n"
+#else
+        "calll __call16_from32\n"
+#endif
         "popal\n"
         "popfl\n"
         : : "a" (callregs), "m" (*callregs));
 }
 
-// XXX - this is ugly.
+static inline
+void __call16_int(struct bregs *callregs, u16 offset)
+{
+    callregs->cs = 0xf000;
+    callregs->ip = offset;
+    call16(callregs);
+}
+
 #ifdef MODE16
-#define call16_int(nr, callregs) do {           \
-        struct bregs *__br = (callregs);        \
-        extern void irq_trampoline_ ##nr ();    \
-        __br->cs = 0xf000;                      \
-        __br->ip = (u16)&irq_trampoline_ ##nr;  \
-        call16(__br);                           \
+#define call16_int(nr, callregs) do {                           \
+        extern void irq_trampoline_ ##nr ();                    \
+        __call16_int((callregs), (u16)&irq_trampoline_ ##nr );  \
     } while (0)
 #else
 #include "../out/rom16.offset.auto.h"
-#define call16_int(nr, callregs) do {           \
-        struct bregs *__br = (callregs);        \
-        __br->cs = 0xf000;                      \
-        __br->ip = OFFSET_irq_trampoline_ ##nr; \
-        call16(__br);                           \
-    } while (0)
+#define call16_int(nr, callregs)                                \
+    __call16_int((callregs), OFFSET_irq_trampoline_ ##nr )
 #endif
 
 // output.c