aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2015-09-11 16:15:23 -0400
committerKevin O'Connor <kevin@koconnor.net>2015-09-14 10:12:34 -0400
commit63766c43f1242b48fcacf616280777fd0388a168 (patch)
tree051bfd40ba696f40bacaef24ab84f4eaaf6df8c0
parent46a346e7dbf41ab6b7813d7356840d5bd434d99f (diff)
downloadseabios-63766c43f1242b48fcacf616280777fd0388a168.zip
seabios-63766c43f1242b48fcacf616280777fd0388a168.tar.gz
seabios-63766c43f1242b48fcacf616280777fd0388a168.tar.bz2
Unify call32_sloppy() and call32()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/stacks.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/stacks.c b/src/stacks.c
index f92a484..a1b8677 100644
--- a/src/stacks.c
+++ b/src/stacks.c
@@ -197,12 +197,20 @@ call16_smm(u32 eax, u32 edx, void *func)
return eax;
}
-// Call a C function in 32bit mode. This clobbers the 16bit segment
-// selector registers.
-static u32
-call32_sloppy(void *func, u32 eax)
+// Call a 32bit SeaBIOS function from a 16bit SeaBIOS function.
+u32 VISIBLE16
+call32(void *func, u32 eax, u32 errret)
{
ASSERT16();
+ if (CONFIG_CALL32_SMM && GET_GLOBAL(HaveSmmCall32))
+ return call32_smm(func, eax);
+ u32 cr0 = getcr0();
+ if (cr0 & CR0_PE)
+ // Called in 16bit protected mode?!
+ return errret;
+
+ // Jump direclty to 32bit mode - this clobbers the 16bit segment
+ // selector registers.
call32_prep(C16_BIG);
u32 bkup_ss, bkup_esp;
asm volatile(
@@ -275,20 +283,6 @@ call16_back(u32 eax, u32 edx, void *func)
return eax;
}
-// Call a 32bit SeaBIOS function from a 16bit SeaBIOS function.
-u32 VISIBLE16
-call32(void *func, u32 eax, u32 errret)
-{
- ASSERT16();
- if (CONFIG_CALL32_SMM && GET_GLOBAL(HaveSmmCall32))
- return call32_smm(func, eax);
- u32 cr0 = getcr0();
- if (cr0 & CR0_PE)
- // Called in 16bit protected mode?!
- return errret;
- return call32_sloppy(func, eax);
-}
-
// Call a 16bit SeaBIOS function in regular ("non-big") mode.
static u32
call16(u32 eax, u32 edx, void *func)