diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-05-16 11:47:27 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-05-16 12:13:32 -0400 |
commit | 8ebb33b1588d6be4241a70e7daabdab4eb076cd8 (patch) | |
tree | c33661243dc30366b5fe3360a0ae513637834cb6 /src/x86.h | |
parent | 5869a6b58745e3e83f4b9257cf6f64216d5e61dc (diff) | |
download | seabios-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.h | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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 |