Bug fixes; get mouse working.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 2 Mar 2008 18:58:23 +0000 (13:58 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 2 Mar 2008 18:58:23 +0000 (13:58 -0500)
Fix bug in post causing PIC2 to not be initialized properly.
Only run ata_detect if CONFIG_ATA enabled.
Improve debugging aids - introduce debug_isr(); move DEBUGF to each file.
Enable mouse by default.
Fix bug in floppy causing extra test of PORT_FD_STATUS on recalibrate.
Always disable/enable kbd in handle_09 event.

12 files changed:
src/ata.c
src/boot.c
src/clock.c
src/config.h
src/disk.c
src/floppy.c
src/kbd.c
src/mouse.c
src/output.c
src/post.c
src/system.c
src/util.h

index 47d893fabf50cf5f6d877f9e69b9d0fd9d1e2236..440feab6b8a7931afb39cb323f4e2a7d9bd42307 100644 (file)
--- a/src/ata.c
+++ b/src/ata.c
@@ -926,5 +926,4 @@ ata_detect()
     // FIXME : should use bios=cmos|auto|disable bits
     // FIXME : should know about translation bits
     // FIXME : move hard_drive_post here
-
 }
index 19a4929d8fd9722dc95ee6daa13ce5fe83a322f2..1ab9423bfa93c24b217562b56c400deaa653ff3d 100644 (file)
@@ -183,7 +183,8 @@ handle_19()
 void VISIBLE
 begin_boot()
 {
-    ata_detect();
+    if (CONFIG_ATA)
+        ata_detect();
     irq_enable();
     struct bregs br;
     memset(&br, 0, sizeof(br));
index 6895876b004e58104da2c4fa1fb0cd8a15959c67..a8c1d2ec1a3d08ba8b8c6ce19afcd5a7ee13ff7f 100644 (file)
@@ -10,6 +10,9 @@
 #include "disk.h" // floppy_tick
 #include "cmos.h" // inb_cmos
 
+#define DEBUGF1(fmt, args...) bprintf(0, fmt , ##args)
+#define DEBUGF(fmt, args...)
+
 static void
 init_rtc()
 {
@@ -257,7 +260,7 @@ handle_1c(struct bregs *regs)
 void VISIBLE
 handle_08(struct bregs *regs)
 {
-//    debug_enter(regs);
+//    debug_isr(regs);
 
     floppy_tick();
 
@@ -338,7 +341,7 @@ handle_1583(struct bregs *regs)
 void VISIBLE
 handle_70(struct bregs *regs)
 {
-    debug_enter(regs);
+    debug_isr(regs);
 
     // Check which modes are enabled and have occurred.
     u8 registerB = inb_cmos(CMOS_STATUS_B);
index a440201df4ab02e114ecedff67c71e76842b1c6d..a984e5cd4d6aa110dd2697314fcb329e451e2d0d 100644 (file)
@@ -3,10 +3,11 @@
 // Configuration definitions.
 
 #define CONFIG_FLOPPY_SUPPORT 1
-#define CONFIG_PS2_MOUSE 0
+#define CONFIG_PS2_MOUSE 1
 #define CONFIG_ATA 1
 #define CONFIG_KBD_CALL_INT15_4F 1
 #define CONFIG_ELTORITO_BOOT 0
+
 #define CONFIG_MAX_ATA_INTERFACES 4
 #define CONFIG_MAX_ATA_DEVICES  (CONFIG_MAX_ATA_INTERFACES*2)
 
index f7497c71d65b0a33439802bb530a9e548e720f92..8c845087c08b423b9a3ec2a4e498bf60cac74f81 100644 (file)
@@ -651,7 +651,7 @@ handle_13(struct bregs *regs)
 void VISIBLE
 handle_76(struct bregs *regs)
 {
-    debug_enter(regs);
+    debug_isr(regs);
     SET_BDA(floppy_harddisk_info, 0xff);
     eoi_both_pics();
 }
index 9131d98b8bfe7fe3a178183051377bce554ef88c..5a7513b237dcb300a45fc82aa1cc55efce67b367 100644 (file)
@@ -12,6 +12,9 @@
 #include "util.h" // irq_disable
 #include "cmos.h" // inb_cmos
 
+#define DEBUGF1(fmt, args...) bprintf(0, fmt , ##args)
+#define DEBUGF(fmt, args...)
+
 #define BX_FLOPPY_ON_CNT 37   /* 2 seconds */
 
 // New diskette parameter table adding 3 parameters from IBM
@@ -149,9 +152,6 @@ floppy_pio(u8 *cmd, u8 cmdlen)
     v &= ~FRS_TIMEOUT;
     SET_BDA(floppy_recalibration_status, v);
 
-    if ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0)
-        BX_PANIC("int13_diskette: ctrl not ready\n");
-
     return 0;
 }
 
@@ -201,6 +201,10 @@ floppy_cmd(struct bregs *regs, u16 count, u8 *cmd, u8 cmdlen)
     if (ret)
         return ret;
 
+    // check port 3f4 for accessibility to status bytes
+    if ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0)
+        BX_PANIC("int13_diskette: ctrl not ready\n");
+
     // read 7 return status bytes from controller
     u8 i;
     for (i=0; i<7; i++) {
@@ -347,6 +351,7 @@ check_drive(struct bregs *regs, u8 drive)
 {
     // see if drive exists
     if (drive > 1 || !get_drive_type(drive)) {
+        // XXX - return type doesn't match
         floppy_fail(regs, DISK_RET_ETIMEOUT);
         return 1;
     }
@@ -712,7 +717,7 @@ floppy_13(struct bregs *regs, u8 drive)
 void VISIBLE
 handle_0e(struct bregs *regs)
 {
-    //debug_enter(regs);
+    //debug_isr(regs);
     if ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0) {
         outb(0x08, PORT_FD_DATA); // sense interrupt status
         while ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0)
index 498f08cb403ab9411e32ff5676c9f38d7d5bcc98..e1f01a5b6d17d7f133762544c36830626d0b37ea 100644 (file)
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -544,15 +544,15 @@ process_key(u8 scancode)
 void VISIBLE
 handle_09(struct bregs *regs)
 {
-//    debug_enter(regs);
-
-    outb(0x0b, PORT_PIC1);
-    if ((inb(PORT_PIC1) & 0x02) == 0)
-        return;
+    //debug_isr(regs);
 
     // disable keyboard
     outb(0xad, PORT_PS2_STATUS);
 
+    outb(0x0b, PORT_PIC1);
+    if ((inb(PORT_PIC1) & 0x02) == 0)
+        goto done;
+
     // read key from keyboard controller
     u8 key = inb(PORT_PS2_DATA);
     irq_enable();
@@ -564,7 +564,7 @@ handle_09(struct bregs *regs)
         tr.ah = 0x4f;
         tr.flags = F_CF;
         call16_int(0x15, &tr);
-        if (!tr.flags & F_CF)
+        if (!(tr.flags & F_CF))
             goto done;
         key = tr.al;
     }
index e3c1789743a51cf545f1d03a9209acb76f052dcf..fd462193bac753e6d1fe1bf2c4cdf9d6f890a173 100644 (file)
@@ -191,7 +191,6 @@ mouse_15c203(struct bregs *regs)
     //      1 =  50 dpi, 2 counts per millimeter
     //      2 = 100 dpi, 4 counts per millimeter
     //      3 = 200 dpi, 8 counts per millimeter
-    bprintf(0, "ebda_seg=%x\n", GET_BDA(ebda_seg));
     u8 comm_byte = inhibit_mouse_int_and_events(); // disable IRQ12 and packets
     if (regs->bh >= 4) {
         handle_ret(regs, RET_EUNSUPPORTED);
@@ -235,7 +234,6 @@ mouse_15c205(struct bregs *regs)
         handle_ret(regs, RET_EINTERFACE);
         return;
     }
-    bprintf(0, "ebda_seg=%x\n", GET_BDA(ebda_seg));
     SET_EBDA(mouse_flag1, 0x00);
     SET_EBDA(mouse_flag2, regs->bh);
 
@@ -340,7 +338,7 @@ mouse_15c2XX(struct bregs *regs)
 void
 handle_15c2(struct bregs *regs)
 {
-    debug_stub(regs);
+    //debug_stub(regs);
 
     if (! CONFIG_PS2_MOUSE) {
         handle_ret(regs, RET_EUNSUPPORTED);
@@ -417,7 +415,7 @@ int74_function()
 void VISIBLE
 handle_74(struct bregs *regs)
 {
-    debug_enter(regs);
+    //debug_isr(regs);
 
     irq_enable();
     int74_function();
index 43eb12875837d977e2353f576b152366efae2044..0dcd20d7c80e1dfe4baead9f65401c48a5684892 100644 (file)
@@ -167,6 +167,13 @@ dump_regs(const char *fname, const char *type, struct bregs *regs)
             , regs->ip, regs->cs, regs->flags);
 }
 
+void
+__debug_isr(const char *fname, struct bregs *regs)
+{
+    puts_cs(0, fname);
+    putc(0, '\n');
+}
+
 // Function called on handler startup.
 void
 __debug_enter(const char *fname, struct bregs *regs)
index 0af8c0c47e490d34fe40d42718017f538d11cf19..4a87eca1f3e83126ff15e76ec687a7e74b7b01d6 100644 (file)
@@ -317,7 +317,7 @@ static void
 pic_setup()
 {
     outb(0x11, PORT_PIC1);
-    outb(0x11, PORT_PIC2_DATA);
+    outb(0x11, PORT_PIC2);
     outb(0x08, PORT_PIC1_DATA);
     outb(0x70, PORT_PIC2_DATA);
     outb(0x04, PORT_PIC1_DATA);
index 310a17e28e6bf991083c682ef8207505f072dbac..e09797b6d0d77b3f0d327413161f2567950bcabd 100644 (file)
@@ -471,7 +471,7 @@ handle_10(struct bregs *regs)
 void VISIBLE
 handle_nmi(struct bregs *regs)
 {
-    debug_enter(regs);
+    debug_isr(regs);
     // XXX
 }
 
@@ -479,7 +479,7 @@ handle_nmi(struct bregs *regs)
 void VISIBLE
 handle_75(struct bregs *regs)
 {
-    debug_enter(regs);
+    debug_isr(regs);
 
     // clear irq13
     outb(0, PORT_MATH_CLEAR);
index b858e8cb43fb07b2455c6a6186a88e4b9e54274f..29446b3038dd6dd9fa659194f718295597df3f98 100644 (file)
@@ -37,7 +37,6 @@ static inline void nop(void)
     asm volatile("nop");
 }
 
-#define DEBUGF(fmt, args...) bprintf(0, fmt , ##args)
 #define BX_PANIC(fmt, args...) bprintf(0, fmt , ##args)
 #define BX_INFO(fmt, args...) bprintf(0, fmt , ##args)
 
@@ -104,12 +103,15 @@ void bprintf(u16 action, const char *fmt, ...)
 void __debug_enter(const char *fname, struct bregs *regs);
 void __debug_exit(const char *fname, struct bregs *regs);
 void __debug_stub(const char *fname, struct bregs *regs);
+void __debug_isr(const char *fname, struct bregs *regs);
 #define debug_enter(regs) \
     __debug_enter(__func__, regs)
 #define debug_exit(regs) \
     __debug_exit(__func__, regs)
 #define debug_stub(regs) \
     __debug_stub(__func__, regs)
+#define debug_isr(regs) \
+    __debug_isr(__func__, regs)
 #define printf(fmt, args...)                     \
     bprintf(1, fmt , ##args )