[SeaBIOS] [PATCH 06/12] Simplify farcall16 code

Kevin O'Connor kevin at koconnor.net
Tue Sep 30 20:38:40 CEST 2014


With this change, farcall16() is only used for external API calls and
is only invoked from a 32bit mode entered directly via transition32.
farcall16big() is also only used for external API calls and is only
invoked from a 32bit mode entered directly via transition32.

call16_int() now calls _farcall16() directly, and it will use normal
16bit mode or big real mode as required.

Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 src/stacks.c | 26 ++++++++++++--------------
 src/stacks.h |  6 +++---
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/stacks.c b/src/stacks.c
index 5674d0a..a36f643 100644
--- a/src/stacks.c
+++ b/src/stacks.c
@@ -236,34 +236,32 @@ _farcall16(struct bregs *callregs, u16 callregseg)
         : "ebx", "ecx", "esi", "edi", "cc", "memory");
 }
 
-inline void
+void
 farcall16(struct bregs *callregs)
 {
-    if (MODE16) {
-        _farcall16(callregs, GET_SEG(SS));
-        return;
-    }
     extern void _cfunc16__farcall16(void);
-    call16((u32)callregs - StackSeg * 16, StackSeg, _cfunc16__farcall16);
+    call16((u32)callregs, 0, _cfunc16__farcall16);
 }
 
-inline void
+void
 farcall16big(struct bregs *callregs)
 {
     extern void _cfunc16__farcall16(void);
-    call16big((u32)callregs - StackSeg * 16, StackSeg, _cfunc16__farcall16);
+    call16big((u32)callregs, 0, _cfunc16__farcall16);
 }
 
 // Invoke a 16bit software interrupt.
-inline void
+void
 __call16_int(struct bregs *callregs, u16 offset)
 {
-    if (MODESEGMENT)
-        callregs->code.seg = GET_SEG(CS);
-    else
-        callregs->code.seg = SEG_BIOS;
     callregs->code.offset = offset;
-    farcall16(callregs);
+    if (!MODESEGMENT) {
+        callregs->code.seg = SEG_BIOS;
+        _farcall16((void*)callregs - StackSeg * 16, StackSeg);
+        return;
+    }
+    callregs->code.seg = GET_SEG(CS);
+    _farcall16(callregs, GET_SEG(SS));
 }
 
 // Reset the machine
diff --git a/src/stacks.h b/src/stacks.h
index cbc5f4f..c3ddc17 100644
--- a/src/stacks.h
+++ b/src/stacks.h
@@ -11,9 +11,9 @@ u32 stack_hop(u32 eax, u32 edx, void *func);
 u32 stack_hop_back(u32 eax, u32 edx, void *func);
 int on_extra_stack(void);
 struct bregs;
-inline void farcall16(struct bregs *callregs);
-inline void farcall16big(struct bregs *callregs);
-inline void __call16_int(struct bregs *callregs, u16 offset);
+void farcall16(struct bregs *callregs);
+void farcall16big(struct bregs *callregs);
+void __call16_int(struct bregs *callregs, u16 offset);
 #define call16_int(nr, callregs) do {                           \
         extern void irq_trampoline_ ##nr ();                    \
         __call16_int((callregs), (u32)&irq_trampoline_ ##nr );  \
-- 
1.9.3




More information about the SeaBIOS mailing list