Change license from GPLv3 to LGPLv3.
[seabios.git] / src / output.c
index b09677e4b8a93e1a9db1364499ff5916fac458b1..63aec9d50fad25206dcbc522059d72f7f45974eb 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
 //
-// 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 <stdarg.h> // va_list
 
@@ -10,6 +10,7 @@
 #include "util.h" // printf
 #include "bregs.h" // struct bregs
 #include "config.h" // CONFIG_*
+#include "biosvar.h" // GET_GLOBAL
 
 #define DEBUG_PORT 0x03f8
 #define DEBUG_TIMEOUT 100000
@@ -96,7 +97,7 @@ static void
 puts_cs(u16 action, const char *s)
 {
     for (;; s++) {
-        char c = GET_VAR(CS, *(u8*)s);
+        char c = GET_GLOBAL(*(u8*)s);
         if (!c)
             break;
         putc(action, c);
@@ -156,7 +157,7 @@ bvprintf(u16 action, const char *fmt, va_list args)
 {
     const char *s = fmt;
     for (;; s++) {
-        char c = GET_VAR(CS, *(u8*)s);
+        char c = GET_GLOBAL(*(u8*)s);
         if (!c)
             break;
         if (c != '%') {
@@ -165,7 +166,7 @@ bvprintf(u16 action, const char *fmt, va_list args)
         }
         const char *n = s+1;
         for (;;) {
-            c = GET_VAR(CS, *(u8*)n);
+            c = GET_GLOBAL(*(u8*)n);
             if (!isdigit(c))
                 break;
             n++;
@@ -173,7 +174,7 @@ bvprintf(u16 action, const char *fmt, va_list args)
         if (c == 'l') {
             // Ignore long format indicator
             n++;
-            c = GET_VAR(CS, *(u8*)n);
+            c = GET_GLOBAL(*(u8*)n);
         }
         s32 val;
         const char *sarg;
@@ -204,7 +205,7 @@ bvprintf(u16 action, const char *fmt, va_list args)
             break;
         case '.':
             // Hack to support "%.s" - meaning string on stack.
-            if (GET_VAR(CS, *(u8*)(n+1)) != 's')
+            if (GET_GLOBAL(*(u8*)(n+1)) != 's')
                 break;
             n++;
             sarg = va_arg(args, const char *);
@@ -270,6 +271,7 @@ dump_regs(struct bregs *regs)
             , regs->ds, regs->es, regs->ip, regs->cs, regs->flags, regs);
 }
 
+// Report entry to an Interrupt Service Routine (ISR).
 void
 __debug_isr(const char *fname)
 {
@@ -279,30 +281,38 @@ __debug_isr(const char *fname)
 
 // Function called on handler startup.
 void
-__debug_enter(const char *fname, struct bregs *regs)
+__debug_enter(struct bregs *regs, const char *fname)
 {
     dprintf(1, "enter %s:\n", fname);
     dump_regs(regs);
 }
 
+// Send debugging output info.
 void
-__debug_stub(const char *fname, int lineno, struct bregs *regs)
+__debug_stub(struct bregs *regs, int lineno, const char *fname)
 {
     dprintf(1, "stub %s:%d:\n", fname, lineno);
     dump_regs(regs);
 }
 
+// Report on a handler returning a failure notification to the caller.
 void
-__set_fail(const char *fname, int lineno, struct bregs *regs)
+__set_fail(struct bregs *regs, int lineno, const char *fname)
 {
     dprintf(1, "fail %s:%d:\n", fname, lineno);
     dump_regs(regs);
     set_fail_silent(regs);
 }
 
+// Report on a handler returning a failure code to the caller.  Note,
+// the lineno and return code are encoded in the same parameter as gcc
+// does a better job of scheduling function calls when there are 3 or
+// less parameters.
 void
-__set_code_fail(const char *fname, int lineno, struct bregs *regs, u8 code)
+__set_code_fail(struct bregs *regs, u32 linecode, const char *fname)
 {
+    u8 code = linecode;
+    u32 lineno = linecode >> 8;
     dprintf(1, "fail %s:%d(%x):\n", fname, lineno, code);
     dump_regs(regs);
     set_code_fail_silent(regs, code);