Support config driven debugging of each irq handler.
authorKevin O'Connor <kevin@koconnor.net>
Fri, 13 Jun 2008 02:59:43 +0000 (22:59 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Fri, 13 Jun 2008 02:59:43 +0000 (22:59 -0400)
This allows one to easily enable verbose output from handlers.

src/boot.c
src/clock.c
src/config.h
src/disk.c
src/floppy.c
src/kbd.c
src/mouse.c
src/serial.c
src/system.c
src/util.h

index 336d86986786a09c20e79ad7dd6170cb59b87f27..09d28e8a9ae43416be357ed65a1bd2e44bcbbc63 100644 (file)
@@ -200,7 +200,7 @@ do_boot(u16 seq_nr)
 void VISIBLE16
 handle_18()
 {
-    debug_enter(NULL);
+    debug_enter(NULL, DEBUG_HDL_18);
     u16 seq = GET_EBDA(ipl.sequence) + 1;
     do_boot(seq);
 }
@@ -209,6 +209,6 @@ handle_18()
 void VISIBLE16
 handle_19()
 {
-    debug_enter(NULL);
+    debug_enter(NULL, DEBUG_HDL_19);
     do_boot(0);
 }
index aef1be83755e8ed1162f46fb4fa4efd49fbba110..5bf4642b73b7e4fa80e88bbd8b14000da53b503b 100644 (file)
@@ -276,7 +276,7 @@ handle_1aXX(struct bregs *regs)
 void VISIBLE16
 handle_1a(struct bregs *regs)
 {
-    //debug_enter(regs);
+    debug_enter(regs, DEBUG_HDL_1a);
     switch (regs->ah) {
     case 0x00: handle_1a00(regs); break;
     case 0x01: handle_1a01(regs); break;
@@ -295,14 +295,14 @@ handle_1a(struct bregs *regs)
 void VISIBLE16
 handle_1c()
 {
-    //debug_enter(regs);
+    debug_isr(DEBUG_ISR_1c);
 }
 
 // INT 08h System Timer ISR Entry Point
 void VISIBLE16
 handle_08()
 {
-    //debug_isr();
+    debug_isr(DEBUG_ISR_08);
     irq_enable();
 
     floppy_tick();
@@ -448,7 +448,7 @@ handle_1583(struct bregs *regs)
 void VISIBLE16
 handle_70()
 {
-    //debug_isr();
+    debug_isr(DEBUG_ISR_70);
 
     // Check which modes are enabled and have occurred.
     u8 registerB = inb_cmos(CMOS_STATUS_B);
index 1f2a6b5f76c09c0e80da7f07f102ffa94a645506..3f5782f2b39894dd2640db5787b8962601547f2a 100644 (file)
 // Start of fixed addresses in 0xf0000 segment.
 #define BUILD_START_FIXED       0xe050
 
+// Debugging levels.  If non-zero and CONFIG_DEBUG_LEVEL is greater
+// than the specified value, then the corresponding irq handler will
+// report every enter event.
+#define DEBUG_HDL_05 1
+#define DEBUG_HDL_10 1
+#define DEBUG_HDL_11 1
+#define DEBUG_HDL_12 1
+#define DEBUG_HDL_15 9
+#define DEBUG_ISR_nmi 1
+#define DEBUG_ISR_75 1
+#define DEBUG_HDL_16 9
+#define DEBUG_ISR_09 9
+#define DEBUG_HDL_18 1
+#define DEBUG_HDL_19 1
+#define DEBUG_HDL_1a 9
+#define DEBUG_ISR_1c 9
+#define DEBUG_ISR_08 9
+#define DEBUG_ISR_70 9
+#define DEBUG_HDL_40 1
+#define DEBUG_HDL_13 9
+#define DEBUG_ISR_76 9
+#define DEBUG_HDL_14 1
+#define DEBUG_HDL_17 1
+#define DEBUG_ISR_74 9
+#define DEBUG_ISR_0e 9
+
 #endif // config.h
index f96342dfe7a7b765cd0dfd04dfe751fa24f983a3..c45d6adcab2ee244fc29b6adb984f2c2cc01cddf 100644 (file)
@@ -644,7 +644,7 @@ handle_legacy_disk(struct bregs *regs, u8 drive)
 void VISIBLE16
 handle_40(struct bregs *regs)
 {
-    debug_enter(regs);
+    debug_enter(regs, DEBUG_HDL_40);
     handle_legacy_disk(regs, regs->dl);
 }
 
@@ -652,7 +652,7 @@ handle_40(struct bregs *regs)
 void VISIBLE16
 handle_13(struct bregs *regs)
 {
-    //debug_enter(regs);
+    debug_enter(regs, DEBUG_HDL_13);
     u8 drive = regs->dl;
 
     if (CONFIG_CDROM_EMU) {
@@ -676,7 +676,7 @@ handle_13(struct bregs *regs)
 void VISIBLE16
 handle_76()
 {
-    //debug_isr();
+    debug_isr(DEBUG_ISR_76);
     SET_BDA(disk_interrupt_flag, 0xff);
     eoi_both_pics();
 }
index 1f1c2c5c68e342c6649780c03f47f22d4e3fc9d8..e0b46c2079fa78c08f409da5c17090a9b16311cd 100644 (file)
@@ -744,7 +744,7 @@ floppy_13(struct bregs *regs, u8 drive)
 void VISIBLE16
 handle_0e()
 {
-    //debug_isr();
+    debug_isr(DEBUG_ISR_0e);
     if ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0) {
         outb(0x08, PORT_FD_DATA); // sense interrupt status
         while ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0)
index fda58478c1c845869a6a7e79343143dd1aeb8ebf..fe2a77d489c4d9fa3f4e6ae26b8956425d5793ec 100644 (file)
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -390,7 +390,7 @@ set_leds()
 void VISIBLE16
 handle_16(struct bregs *regs)
 {
-    //debug_enter(regs);
+    debug_enter(regs, DEBUG_HDL_16);
 
     set_leds();
 
@@ -700,7 +700,7 @@ process_key(u8 scancode)
 void VISIBLE16
 handle_09()
 {
-    //debug_isr();
+    debug_isr(DEBUG_ISR_09);
 
     // disable keyboard
     outb(0xad, PORT_PS2_STATUS);
index 6c214997e67cfb744145446b5c1b9a2cfa63ba77..23e17dedf819c4e36170a7cdf726c6db12dbc2f2 100644 (file)
@@ -6,7 +6,7 @@
 // This file may be distributed under the terms of the GNU GPLv3 license.
 
 #include "biosvar.h" // struct bregs
-#include "util.h" // debug_enter
+#include "util.h" // debug_isr
 
 #define DEBUGF1(fmt, args...) bprintf(0, fmt , ##args)
 #define DEBUGF(fmt, args...)
@@ -415,7 +415,7 @@ int74_function()
 void VISIBLE16
 handle_74()
 {
-    //debug_isr();
+    debug_isr(DEBUG_ISR_74);
 
     irq_enable();
     int74_function();
index 5f5afce4654b7a131d2727f9070f9c22ff4363f6..6c38086e9a29e16a7bd2e7b48655f015b2b5d04e 100644 (file)
@@ -149,7 +149,7 @@ handle_14XX(struct bregs *regs)
 void VISIBLE16
 handle_14(struct bregs *regs)
 {
-    debug_enter(regs);
+    debug_enter(regs, DEBUG_HDL_14);
 
     irq_enable();
 
@@ -278,7 +278,7 @@ handle_17XX(struct bregs *regs)
 void VISIBLE16
 handle_17(struct bregs *regs)
 {
-    debug_enter(regs);
+    debug_enter(regs, DEBUG_HDL_17);
 
     irq_enable();
 
index f3909c166654f49bad9d6f45925815221335ef9f..0941565976ebe5dca485b3b2970b8c2263334a1c 100644 (file)
@@ -310,7 +310,7 @@ handle_15XX(struct bregs *regs)
 void VISIBLE16
 handle_15(struct bregs *regs)
 {
-    //debug_enter(regs);
+    debug_enter(regs, DEBUG_HDL_15);
     switch (regs->ah) {
     case 0x24: handle_1524(regs); break;
     case 0x4f: handle_154f(regs); break;
@@ -334,7 +334,7 @@ handle_15(struct bregs *regs)
 void VISIBLE16
 handle_12(struct bregs *regs)
 {
-    debug_enter(regs);
+    debug_enter(regs, DEBUG_HDL_12);
     regs->ax = GET_BDA(mem_size_kb);
 }
 
@@ -342,7 +342,7 @@ handle_12(struct bregs *regs)
 void VISIBLE16
 handle_11(struct bregs *regs)
 {
-    debug_enter(regs);
+    debug_enter(regs, DEBUG_HDL_11);
     regs->ax = GET_BDA(equipment_list_flags);
 }
 
@@ -350,21 +350,21 @@ handle_11(struct bregs *regs)
 void VISIBLE16
 handle_05(struct bregs *regs)
 {
-    debug_enter(regs);
+    debug_enter(regs, DEBUG_HDL_05);
 }
 
 // INT 10h Video Support Service Entry Point
 void VISIBLE16
 handle_10(struct bregs *regs)
 {
-    debug_enter(regs);
+    debug_enter(regs, DEBUG_HDL_10);
     // dont do anything, since the VGA BIOS handles int10h requests
 }
 
 void VISIBLE16
 handle_nmi()
 {
-    debug_isr();
+    debug_isr(DEBUG_ISR_nmi);
     BX_PANIC("NMI Handler called\n");
 }
 
@@ -372,7 +372,7 @@ handle_nmi()
 void VISIBLE16
 handle_75()
 {
-    debug_isr();
+    debug_isr(DEBUG_ISR_75);
 
     // clear irq13
     outb(0, PORT_MATH_CLEAR);
index fa30e08e58cb4f1c412f54e97106d8ca04a25ab3..8a715691fe7be409749322c38c0f5c2f63a8d99d 100644 (file)
@@ -120,12 +120,16 @@ void __debug_enter(const char *fname, struct bregs *regs);
 void __debug_fail(const char *fname, struct bregs *regs);
 void __debug_stub(const char *fname, struct bregs *regs);
 void __debug_isr(const char *fname);
-#define debug_enter(regs) \
-    __debug_enter(__func__, regs)
+#define debug_enter(regs, lvl) do {                     \
+        if ((lvl) && (lvl) <= CONFIG_DEBUG_LEVEL)       \
+            __debug_enter(__func__, regs);              \
+    } while (0)
+#define debug_isr(lvl) do {                             \
+        if ((lvl) && (lvl) <= CONFIG_DEBUG_LEVEL)       \
+            __debug_isr(__func__);                      \
+    } while (0)
 #define debug_stub(regs) \
     __debug_stub(__func__, regs)
-#define debug_isr(regs) \
-    __debug_isr(__func__)
 
 // Frequently used return codes
 #define RET_EUNSUPPORTED 0x86