Misc fixes and updates.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 19 Jul 2008 18:12:32 +0000 (14:12 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 19 Jul 2008 18:12:32 +0000 (14:12 -0400)
Minor code cleanups.
Fix parenthesis imbalance in keyboard led test.
The printf() call is only used in 32bit mode - make this explicit to
    the compiler - it improves the code generation.
Clear the screen after initializing the vga option rom.

TODO
src/bregs.h
src/cdrom.c
src/kbd.c
src/mouse.c
src/output.c
src/pcibios.c
src/pic.c
src/post.c

diff --git a/TODO b/TODO
index d7acfe54489205d9b1fbbbd478156053d78f1510..5ad04282c5e389ac4d1ce2ccade76f841df5899b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,3 +1,5 @@
+Clean up timer code.  Don't use PORT_DIAG as delay mechanism.
+
 Disable a20 on jump to 16bit mode.
 
 Do a pci scan for ide controllers - don't just assume ISA ports are
@@ -34,13 +36,24 @@ Code assumes ebda segment is static - it doesn't read 0x40e.
 The __call16 code does a long jump to the interrupt trampolines - this
 is unnecessary.
 
-Fix makefiles so that they rebuild the required files automatically.
-
 Cleanup setting of ES on GET/SET_BDA
 
+Audit code for 16bit protected mode accesses.
+
+Support 1ab1 from 16bit protected mode.
+
+Verify option roms wont stomp on seabios stack and bss.
+
 Possibly implement 32bit pcibios support.
 
 Allow one to select adding 32 bit code to 0xf000 or in a separate
 location.
 
+See if it is possible to handle interrupts while in 32bit mode.
+
 Look at integrating the lgpl vgabios into tree.
+
+Look at usb booting specs.  Look at possibly supporting usb
+keyboard/mice.
+
+Add a graphical boot splash screen?
index f7060e8a08a0d6536b91053f576e927def31df83..2c36239aa3a836885a39248db083ebbe50ae4109 100644 (file)
@@ -7,6 +7,8 @@
 #ifndef __BREGS_H
 #define __BREGS_H
 
+#include "types.h" // u16
+
 
 /****************************************************************
  * Registers saved/restored in romlayout.S
index 57c2ce48dc277420eaad3c69bbd8a5cb493f6d25..0ccc2c43ffae063256b05d1e52a30f01cc55537f 100644 (file)
@@ -435,11 +435,7 @@ cdrom_boot()
 
     int ret = atapi_is_ready(device);
     if (ret)
-        dprintf(1, "ata_is_ready returned %d\n", ret);
-
-    // if not found
-    if (device >= CONFIG_MAX_ATA_DEVICES)
-        return 2;
+        dprintf(1, "atapi_is_ready returned %d\n", ret);
 
     // Read the Boot Record Volume Descriptor
     u8 buffer[2048];
index 5dbb2570df786686d322d23589006a8bb8208f11..d63c8c37f38a454a50d7fd4fde0a1c8ba07e7658 100644 (file)
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -374,7 +374,7 @@ set_leds()
 {
     u8 shift_flags = GET_BDA(kbd_flag0);
     u8 led_flags = GET_BDA(kbd_led);
-    if (((shift_flags >> 4) & 0x07) ^ ((led_flags & 0x07) == 0))
+    if ((((shift_flags >> 4) & 0x07) ^ (led_flags & 0x07)) == 0)
         return;
 
     outb(0xed, PORT_PS2_DATA);
index 08beafe6ae34b1598b6dc6b633981a56400decaa..cb471db57c6aff46ebbd6c4881909990db1ba9ba 100644 (file)
@@ -384,7 +384,8 @@ int74_function()
     u8 mouse_flags_1 = GET_EBDA(mouse_flag1);
     u8 mouse_flags_2 = GET_EBDA(mouse_flag2);
 
-    if ((mouse_flags_2 & 0x80) != 0x80)
+    if (! (mouse_flags_2 & 0x80))
+        // far call handler not installed
         return;
 
     u8 package_count = mouse_flags_2 & 0x07;
@@ -402,9 +403,6 @@ int74_function()
     u16 X      = GET_EBDA(mouse_data[1]);
     u16 Y      = GET_EBDA(mouse_data[2]);
     SET_EBDA(mouse_flag1, 0);
-    // check if far call handler installed
-    if (! (mouse_flags_2 & 0x80))
-        return;
 
     u32 func = GET_EBDA(far_call_pointer);
     asm volatile(
index 8b584859ddd5caa148e81065e42b3b8ac72b35e5..d9671ac692602c0621c8b2c8a1b597e048ecb12d 100644 (file)
@@ -1,4 +1,4 @@
-// Raw screen writing code.
+// Raw screen writing and debug output code.
 //
 // Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
 //
@@ -33,6 +33,7 @@ debug_serial_setup()
                 , oldparam, oldier, newparam, newier);
 }
 
+// Write a character to the serial port.
 static void
 debug_serial(char c)
 {
@@ -44,9 +45,13 @@ debug_serial(char c)
     outb(c, DEBUG_PORT);
 }
 
+// Show a character on the screen.
 static void
 screenc(u8 c)
 {
+    if (MODE16)
+        // printf is only used in 32bit code.
+        return;
     struct bregs br;
     memset(&br, 0, sizeof(br));
     br.ah = 0x0e;
@@ -54,7 +59,7 @@ screenc(u8 c)
     call16_int(0x10, &br);
 }
 
-// Write a charcter to the framebuffer.
+// Output a character.
 static void
 putc(u16 action, char c)
 {
@@ -78,7 +83,7 @@ putc(u16 action, char c)
     }
 }
 
-// Write a string to the framebuffer.
+// Ouptut a string.
 static void
 puts(u16 action, const char *s)
 {
@@ -86,7 +91,7 @@ puts(u16 action, const char *s)
         putc(action, *s);
 }
 
-// Write a string to the framebuffer.
+// Output a string that is in the CS segment.
 static void
 puts_cs(u16 action, const char *s)
 {
@@ -98,7 +103,7 @@ puts_cs(u16 action, const char *s)
     }
 }
 
-// Write an unsigned integer to the screen.
+// Output an unsigned integer.
 static void
 putuint(u16 action, u32 val)
 {
@@ -115,7 +120,7 @@ putuint(u16 action, u32 val)
     puts(action, d);
 }
 
-// Write a single digit hex character to the screen.
+// Output a single digit hex character.
 static inline void
 putsinglehex(u16 action, u32 val)
 {
@@ -126,7 +131,7 @@ putsinglehex(u16 action, u32 val)
     putc(action, val);
 }
 
-// Write an integer in hexadecimal to the screen.
+// Output an integer in hexadecimal.
 static void
 puthex(u16 action, u32 val)
 {
index 05d78565998b0c068567bd383def171e3bed6037..545ad8dd59817743131028fbdf6a4e39d4ee753c 100644 (file)
@@ -23,6 +23,7 @@ handle_1ab101(struct bregs *regs)
     regs->ax = 0x0001;
     regs->bx = 0x0210;
     regs->cx = 0;
+    // XXX - regs->cl should equal max bus number.
     regs->edx = 0x20494350; // "PCI "
     // XXX - bochs bios code sets edi to point to 32bit code - but no
     // reference to this in spec.
index 129fc349adeefade915e7315f4916aa1a63d88bf..f895798a827dfc46c275752ddbe04160a9de6889 100644 (file)
--- a/src/pic.c
+++ b/src/pic.c
@@ -16,7 +16,7 @@ pic_setup()
     // Send ICW1 (select OCW1 + will send ICW4)
     outb(0x11, PORT_PIC1_CMD);
     outb(0x11, PORT_PIC2_CMD);
-    // Send ICW2 (base irqs: 0x08-0x0f for irq0-7, 0x70-0x78 for irq8-15)
+    // Send ICW2 (base irqs: 0x08-0x0f for irq0-7, 0x70-0x77 for irq8-15)
     outb(0x08, PORT_PIC1_DATA);
     outb(0x70, PORT_PIC2_DATA);
     // Send ICW3 (cascaded pic ids)
index 0a64f179320f8e2fb91f7aad19a1d105aa8e2cab..9e0d5fffc0e4e36195b792cee422767bb1ec387a 100644 (file)
@@ -273,6 +273,20 @@ rom_scan(u32 start, u32 end)
     }
 }
 
+// Call into vga code to turn on console.
+static void
+vga_setup()
+{
+    dprintf(1, "Scan for VGA option rom\n");
+    rom_scan(0xc0000, 0xc7800);
+
+    dprintf(1, "Turning on vga console\n");
+    struct bregs br;
+    memset(&br, 0, sizeof(br));
+    br.ax = 0x0003;
+    call16_int(0x10, &br);
+}
+
 // Main setup code.
 static void
 post()
@@ -292,8 +306,7 @@ post()
 
     ram_probe();
 
-    dprintf(1, "Scan for VGA option rom\n");
-    rom_scan(0xc0000, 0xc7800);
+    vga_setup();
 
     printf("BIOS - begin\n\n");