]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/commitdiff
stacks: There is no need to disable NMI if it is already disabled
authorKevin O'Connor <kevin@koconnor.net>
Tue, 16 May 2017 15:59:10 +0000 (11:59 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 12 Jun 2017 18:59:38 +0000 (14:59 -0400)
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>
src/stacks.c

index f4d15ce991eee7a4339fd5d0b7c54c69a258c6a0..2fe1bfbd64fda39063923e234c0734b2db948751 100644 (file)
@@ -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;
 }