aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-03-11 20:38:33 -0400
committerKevin O'Connor <kevin@koconnor.net>2008-03-11 20:38:33 -0400
commit7a558e4417c74a0d7f2896178636b1d020d3fae9 (patch)
treeb725bb96feffa807da77e35b2b7d5169a85150ae
parent64c718d27a0b9e8570968eed749782b170e32645 (diff)
downloadseabios-7a558e4417c74a0d7f2896178636b1d020d3fae9.tar.gz
Don't save/restore flags and ebp on external calls - saves on stack space.
It isn't necessary to save ebp - just mark it as clobbered. The only important flag to save/restore is irqs - manually fixup all callers.
-rw-r--r--TODO3
-rw-r--r--src/boot.c4
-rw-r--r--src/clock.c1
-rw-r--r--src/mouse.c7
-rw-r--r--src/romlayout.S4
-rw-r--r--src/util.h9
6 files changed, 14 insertions, 14 deletions
diff --git a/TODO b/TODO
index 603d7638..e9c9d864 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,5 @@
-Audit all sti/cli calls.
+Audit all sti/cli calls. Audit all call16 calls to make sure flags is
+setup properly with respect to irqs.
Audit statements where a 32bit intermediary changes meaning of a 16bit
comparison.
diff --git a/src/boot.c b/src/boot.c
index b1fa050f..c75bc1b2 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -63,7 +63,10 @@ print_boot_failure(u16 type, u8 reason)
static void
try_boot(u16 seq_nr)
{
+ irq_enable();
+
SET_IPL(sequence, seq_nr);
+
u16 bootseg;
u8 bootdrv = 0;
u16 bootdev, bootip;
@@ -210,7 +213,6 @@ begin_boot()
{
if (CONFIG_ATA)
ata_detect();
- irq_enable();
struct bregs br;
memset(&br, 0, sizeof(br));
call16_int(0x19, &br);
diff --git a/src/clock.c b/src/clock.c
index c653c1f3..b9d75a3c 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -356,6 +356,7 @@ handle_70()
struct bregs br;
memset(&br, 0, sizeof(br));
call16_int(0x4a, &br);
+ irq_disable();
}
if (!(registerC & 0x40))
goto done;
diff --git a/src/mouse.c b/src/mouse.c
index 569488b7..6c214997 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -397,8 +397,6 @@ int74_function()
u32 func = GET_EBDA(far_call_pointer);
asm volatile(
- "pushl %%ebp\n"
- "pushfl\n"
"pushl %0\n"
"pushw %w1\n" // status
"pushw %w2\n" // X
@@ -406,11 +404,10 @@ int74_function()
"pushw $0\n" // Z
"lcallw *8(%%esp)\n"
"addl $12, %%esp\n"
- "popfl\n"
- "popl %%ebp\n"
+ "cld\n"
: "+a" (func), "+b" (status), "+c" (X), "+d" (Y)
:
- : "esi", "edi"
+ : "esi", "edi", "ebp", "cc"
);
}
diff --git a/src/romlayout.S b/src/romlayout.S
index 9f0541a7..d5253457 100644
--- a/src/romlayout.S
+++ b/src/romlayout.S
@@ -50,6 +50,8 @@ post16:
set_entry32:
pushl $0xf0000000
+ cld
+
// Fall through to transition32 function below
@@ -92,8 +94,6 @@ transition32:
movw %ax, %fs
movw %ax, %gs
- cld
-
retl
// Call a 16bit function from 32bit mode.
diff --git a/src/util.h b/src/util.h
index 7d5b7c8b..4df595a3 100644
--- a/src/util.h
+++ b/src/util.h
@@ -45,6 +45,7 @@ static inline void hlt(void)
// XXX - move this to a c file and use PANIC PORT.
#define BX_PANIC(fmt, args...) do { \
bprintf(0, fmt , ##args); \
+ irq_disable(); \
for (;;) \
hlt(); \
} while (0)
@@ -83,22 +84,20 @@ eoi_both_pics()
eoi_master_pic();
}
+// Call a function with a specified register state. Note that on
+// return, the interrupt enable/disable flag may be altered.
static inline
void call16(struct bregs *callregs)
{
asm volatile(
- "pushl %%ebp\n" // Save state
- "pushfl\n"
#ifdef MODE16
"calll __call16\n"
#else
"calll __call16_from32\n"
#endif
- "popfl\n" // Restore state
- "popl %%ebp\n"
: "+a" (callregs), "+m" (*callregs)
:
- : "ebx", "ecx", "edx", "esi", "edi");
+ : "ebx", "ecx", "edx", "esi", "edi", "ebp", "cc");
}
static inline