aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-05-16 11:59:10 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-06-12 14:59:38 -0400
commitdee3c1535d5550fab914cd181cbb02741d749e2a (patch)
treed81323795bbb88b25c5e92c26cb31241e66ab9f8
parent8ebb33b1588d6be4241a70e7daabdab4eb076cd8 (diff)
downloadseabios-dee3c1535d5550fab914cd181cbb02741d749e2a.zip
seabios-dee3c1535d5550fab914cd181cbb02741d749e2a.tar.gz
seabios-dee3c1535d5550fab914cd181cbb02741d749e2a.tar.bz2
stacks: There is no need to disable NMI if it is already disabled
Don't write to the cmos index port on a mode switch if NMI is already disabled. This reduces the number of outb() calls. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/stacks.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/stacks.c b/src/stacks.c
index f4d15ce..2fe1bfb 100644
--- a/src/stacks.c
+++ b/src/stacks.c
@@ -66,8 +66,10 @@ call32_prep(u8 method)
// Backup cmos index register and disable nmi
u8 cmosindex = inb(PORT_CMOS_INDEX);
- outb(cmosindex | NMI_DISABLE_BIT, PORT_CMOS_INDEX);
- inb(PORT_CMOS_DATA);
+ if (!(cmosindex & NMI_DISABLE_BIT)) {
+ outb(cmosindex | NMI_DISABLE_BIT, PORT_CMOS_INDEX);
+ inb(PORT_CMOS_DATA);
+ }
SET_LOW(Call16Data.cmosindex, cmosindex);
SET_LOW(Call16Data.method, method);
@@ -103,8 +105,11 @@ call32_post(void)
}
// Restore cmos index register
- outb(GET_LOW(Call16Data.cmosindex), PORT_CMOS_INDEX);
- inb(PORT_CMOS_DATA);
+ u8 cmosindex = GET_LOW(Call16Data.cmosindex);
+ if (!(cmosindex & NMI_DISABLE_BIT)) {
+ outb(cmosindex, PORT_CMOS_INDEX);
+ inb(PORT_CMOS_DATA);
+ }
return method;
}