Change license from GPLv3 to LGPLv3.
[seabios.git] / src / apm.c
index 1d8ceef0c99017179cd1b1cc7ff6e50b2583756a..6efead02f683e8b97bf80636d1efc886549dcbb5 100644 (file)
--- a/src/apm.c
+++ b/src/apm.c
@@ -4,19 +4,26 @@
 // Copyright (C) 2005 Struan Bartlett
 // Copyright (C) 2004 Fabrice Bellard
 //
-// This file may be distributed under the terms of the GNU GPLv3 license.
+// This file may be distributed under the terms of the GNU LGPLv3 license.
 
 #include "farptr.h" // GET_VAR
-#include "biosvar.h" // struct bregs
+#include "bregs.h" // struct bregs
 #include "ioport.h" // outb
 #include "util.h" // irq_enable
+#include "config.h" // CONFIG_*
+#include "biosvar.h" // GET_GLOBAL
 
 static void
 out_str(const char *str_cs)
 {
+    if (CONFIG_COREBOOT) {
+        dprintf(1, "APM request '%s'\n", str_cs);
+        return;
+    }
+
     u8 *s = (u8*)str_cs;
     for (;;) {
-        u8 c = GET_VAR(CS, *s);
+        u8 c = GET_GLOBAL(*s);
         if (!c)
             break;
         outb(c, PORT_BIOS_APM);
@@ -92,6 +99,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)
@@ -136,12 +150,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
@@ -178,6 +193,11 @@ handle_1553XX(struct bregs *regs)
 void VISIBLE16
 handle_1553(struct bregs *regs)
 {
+    if (! CONFIG_APMBIOS) {
+        set_code_fail(regs, RET_EUNSUPPORTED);
+        return;
+    }
+
     //debug_stub(regs);
     switch (regs->al) {
     case 0x00: handle_155300(regs); break;
@@ -186,6 +206,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;