aboutsummaryrefslogtreecommitdiffstats
path: root/src/x86.h
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-05-16 11:47:27 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-05-16 12:13:32 -0400
commit8ebb33b1588d6be4241a70e7daabdab4eb076cd8 (patch)
treec33661243dc30366b5fe3360a0ae513637834cb6 /src/x86.h
parent5869a6b58745e3e83f4b9257cf6f64216d5e61dc (diff)
downloadseabios-8ebb33b1588d6be4241a70e7daabdab4eb076cd8.tar.gz
stacks: Don't update the A20 settings if they haven't changed
The A20 setting is almost always enabled - only issue an outb() if the A20 is actually changing. This reduces the number of outb() calls. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/x86.h')
-rw-r--r--src/x86.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/x86.h b/src/x86.h
index a770e6f6..4aea65cd 100644
--- a/src/x86.h
+++ b/src/x86.h
@@ -258,9 +258,10 @@ static inline u8 get_a20(void) {
}
static inline u8 set_a20(u8 cond) {
- u8 val = inb(PORT_A20);
- outb((val & ~A20_ENABLE_BIT) | (cond ? A20_ENABLE_BIT : 0), PORT_A20);
- return (val & A20_ENABLE_BIT) != 0;
+ u8 val = inb(PORT_A20), a20_enabled = (val & A20_ENABLE_BIT) != 0;
+ if (a20_enabled != !!cond)
+ outb(val ^ A20_ENABLE_BIT, PORT_A20);
+ return a20_enabled;
}
// x86.c