APM fixes; don't save/clear/restore %esp high bits.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 7 Jun 2008 18:51:14 +0000 (14:51 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 7 Jun 2008 18:51:14 +0000 (14:51 -0400)
Don't worry about %esp high bits - 16bit protected mode may require
    the bits to be set.  It would be very odd to call into the bios
    with junk in %esp high bits.
Fix 32bit apm entry point.
Don't log apm calls 155306/15530b.

src/apm.c
src/romlayout.S

index 2abf504a83ea7d2499b91f106c74fb278d2398cf..19885aa524d4ec4e03305a4aef0b3903e339aea6 100644 (file)
--- a/src/apm.c
+++ b/src/apm.c
@@ -97,6 +97,13 @@ handle_155305(struct bregs *regs)
     set_success(regs);
 }
 
+// APM cpu busy
+static void
+handle_155306(struct bregs *regs)
+{
+    set_success(regs);
+}
+
 // APM Set Power State
 static void
 handle_155307(struct bregs *regs)
@@ -141,12 +148,13 @@ handle_15530a(struct bregs *regs)
     set_success(regs);
 }
 
+#define RET_ENOEVENT 0x80
+
 // Get PM Event
 static void
 handle_15530b(struct bregs *regs)
 {
-    set_fail(regs);
-    regs->ah = 0x80; // no event pending
+    set_code_fail_silent(regs, RET_ENOEVENT);
 }
 
 // APM Driver Version
@@ -196,6 +204,7 @@ handle_1553(struct bregs *regs)
     case 0x03: handle_155303(regs); break;
     case 0x04: handle_155304(regs); break;
     case 0x05: handle_155305(regs); break;
+    case 0x06: handle_155306(regs); break;
     case 0x07: handle_155307(regs); break;
     case 0x08: handle_155308(regs); break;
     case 0x0a: handle_15530a(regs); break;
index f843d86f540ca4df7365fe649838f9a133c245f2..5f7afc7862e5f4c47cfe311531a75c4bf10cac77 100644 (file)
         pushw %ds
         movw %ss, %ax           // Move %ss to %ds
         movw %ax, %ds
-        pushl %esp              // Backup %esp, then clear high bits
-        movzwl %sp, %esp
         calll \cfunc
-        popl %esp               // Restore %esp (including high bits)
         popw %ds                // Restore registers saved above
         popw %es
         popl %edx
         pushw %ds
         movw %ss, %ax           // Move %ss to %ds
         movw %ax, %ds
-        movl %esp, %ebx         // Backup %esp, then zero high bits
-        movzwl %sp, %esp
         movl %esp, %eax         // First arg is pointer to struct bregs
         calll \cfunc
-        movl %ebx, %esp         // Restore %esp (including high bits)
         popw %ds                // Restore registers (from struct bregs)
         popw %es
         popl %edi
@@ -263,7 +257,7 @@ apm16protected_entry:
         pushfw          // save flags
         pushl %eax      // dummy
         ENTRY_ARG handle_1553
-        addw $4, %sp    // pop dummy
+        addl $4, %esp   // pop dummy
         popfw           // restore flags
         lretw
 
@@ -273,14 +267,14 @@ apm32protected_entry:
         pushfw
         pushw %cs       // Setup for long jump to 16bit mode
         pushw $1f
-        incw 2(%esp)
+        addw $8, 2(%esp)
         ljmpw *(%esp)
         .code16gcc
 1:
         ENTRY_ARG handle_1553
 
         movw $2f,(%esp) // Setup for long jump back to 32bit mode
-        decw 2(%esp)
+        subw $8, 2(%esp)
         ljmpw *(%esp)
         .code32
 2: