Add additional config options to remove parts of code.
authorKevin O'Connor <kevin@koconnor.net>
Tue, 22 Jul 2008 02:23:05 +0000 (22:23 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 22 Jul 2008 02:23:05 +0000 (22:23 -0400)
Added options CONFIG_BOOT, CONFIG_SERIAL, CONFIG_LPT, CONFIG_KEYBOARD,
    CONFIG_BOOTMENU.
Also extended coverage of existing options to ensure full code got
    removed.

src/boot.c
src/config.h
src/floppy.c
src/kbd.c
src/mouse.c
src/post.c
src/post_menu.c
src/serial.c
src/smm.c

index b090058fab64e41e3381c11d20407e1624d0c93d..3efa9b6e5a347d6a7f109bba4caab5ebee5e865b 100644 (file)
@@ -77,6 +77,9 @@ print_boot_failure(u16 type, u8 reason)
 static void
 try_boot(u16 seq_nr)
 {
+    if (! CONFIG_BOOT)
+        BX_PANIC("Boot support not compiled in.\n");
+
     SET_EBDA(ipl.sequence, seq_nr);
 
     u32 bootdev = GET_EBDA(ipl.bootorder);
index 596df24e28b776fd09fada25a6ac1ffed958a6c3..745a99605835e7f74e51834f30bd293c0150e925 100644 (file)
 // Send debugging information to serial port
 #define CONFIG_DEBUG_SERIAL 0
 
+// Support for int13 floppy drive access
 #define CONFIG_FLOPPY_SUPPORT 1
+// Support for int15c2 mouse calls
 #define CONFIG_PS2_MOUSE 1
+// Support for IDE disk code
 #define CONFIG_ATA 1
+// Support calling int155f on each keyboard press
 #define CONFIG_KBD_CALL_INT15_4F 1
 // Support for booting from a CD
 #define CONFIG_CDROM_BOOT 1
 #define CONFIG_PCIBIOS 1
 // Support int 15/53 APM BIOS calls
 #define CONFIG_APMBIOS 1
+// Support int 19/18 system bootup support
+#define CONFIG_BOOT 1
+// Support int 14 parallel port calls
+#define CONFIG_SERIAL 1
+// Support int 17 parallel port calls
+#define CONFIG_LPT 1
+// Support int 16 keyboard calls
+#define CONFIG_KEYBOARD 1
+// Support an interactive boot menu at end of post.
+#define CONFIG_BOOTMENU 1
 
 // Support generation of a PIR table in 0xf000 segment (for emulators)
 #define CONFIG_PIRTABLE 1
@@ -41,6 +55,8 @@
 #define CONFIG_MPTABLE 1
 // Support generation of ACPI tables (for emulators)
 #define CONFIG_ACPI 1
+// Support bios callbacks specific to via vgabios.
+#define CONFIG_VGAHOOKS 1
 
 /* define it if the (emulated) hardware supports SMM mode */
 #define CONFIG_USE_SMM 1
index 6e903adbd8b5c0cd3e4ccd5bde09b9643becdb42..a42f53f3ee38479733f79576e1976c9a8cce72dd 100644 (file)
@@ -20,6 +20,7 @@
 // Since no provisions are made for multiple drive types, most
 // values in this table are ignored.  I set parameters for 1.44M
 // floppy here
+#if MODE16 == 1
 struct floppy_ext_dbt_s diskette_param_table2 VISIBLE16 = {
     .dbt = {
         .specify1       = 0xAF,
@@ -38,6 +39,7 @@ struct floppy_ext_dbt_s diskette_param_table2 VISIBLE16 = {
     .data_rate      = 0,    // data transfer rate
     .drive_type     = 4,    // drive type in cmos
 };
+#endif
 
 void
 floppy_drive_setup()
@@ -739,6 +741,9 @@ void VISIBLE16
 handle_0e()
 {
     debug_isr(DEBUG_ISR_0e);
+    if (! CONFIG_FLOPPY_SUPPORT)
+        goto done;
+
     if ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0) {
         outb(0x08, PORT_FD_DATA); // sense interrupt status
         while ((inb(PORT_FD_STATUS) & 0xc0) != 0xc0)
@@ -747,15 +752,20 @@ handle_0e()
             inb(PORT_FD_DATA);
         } while ((inb(PORT_FD_STATUS) & 0xc0) == 0xc0);
     }
-    eoi_pic1();
     // diskette interrupt has occurred
     SETBITS_BDA(floppy_recalibration_status, FRS_TIMEOUT);
+
+done:
+    eoi_pic1();
 }
 
 // Called from int08 handler.
 void
 floppy_tick()
 {
+    if (! CONFIG_FLOPPY_SUPPORT)
+        return;
+
     // time to turn off drive(s)?
     u8 fcount = GET_BDA(floppy_motor_counter);
     if (fcount) {
index b47b3ca56767336b1a28e6be4e95ac2308d03ff5..f4a1c95f757fad1437eb7b6bcb9284d84e69d645 100644 (file)
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -92,6 +92,9 @@ kbd_setup()
     SET_BDA(kbd_buf_end_offset
             , x + FIELD_SIZEOF(struct bios_data_area_s, kbd_buf));
 
+    if (! CONFIG_KEYBOARD)
+        return;
+
     keyboard_init();
 
     // Enable IRQ1 (handle_09)
@@ -306,6 +309,8 @@ void VISIBLE16
 handle_16(struct bregs *regs)
 {
     debug_enter(regs, DEBUG_HDL_16);
+    if (! CONFIG_KEYBOARD)
+        return;
 
     irq_enable();
 
@@ -616,6 +621,8 @@ void VISIBLE16
 handle_09()
 {
     debug_isr(DEBUG_ISR_09);
+    if (! CONFIG_KEYBOARD)
+        goto done;
 
     // read key from keyboard controller
     u8 v = inb(PORT_PS2_STATUS);
index 22d0148fdae5b92706d777d2ca32df35f04e76af..0f0a75f31471866203afc4e657d20a450956624b 100644 (file)
@@ -335,10 +335,13 @@ void VISIBLE16
 handle_74()
 {
     debug_isr(DEBUG_ISR_74);
+    if (! CONFIG_PS2_MOUSE)
+        goto done;
 
     irq_enable();
     int74_function();
     irq_disable();
 
+done:
     eoi_pic2();
 }
index 9e0d5fffc0e4e36195b792cee422767bb1ec387a..93d8210b643bff76cced6d77b148e8ed99867b9b 100644 (file)
@@ -170,6 +170,8 @@ init_bios_tables(void)
 static void
 init_boot_vectors()
 {
+    if (! CONFIG_BOOT)
+        return;
     dprintf(3, "init boot device ordering\n");
 
     // Floppy drive
@@ -258,6 +260,9 @@ rom_scan(u32 start, u32 end)
         // Found a device that thinks it can boot the system.  Record
         // its BEV and product name string.
 
+        if (! CONFIG_BOOT)
+            continue;
+
         if (ebda->ipl.count >= ARRAY_SIZE(ebda->ipl.table))
             continue;
 
index 5115321ea6c8bb4264a9350bf1dbce7e2d50b01d..caba7da134ac5aa12dc9ec11f602626165779375 100644 (file)
@@ -42,6 +42,9 @@ udelay_and_check_for_keystroke(u32 usec, int count)
 void
 interactive_bootmenu()
 {
+    if (! CONFIG_BOOTMENU)
+        return;
+
     while (check_for_keystroke())
         get_keystroke();
 
index 46a9558b363cc7e98fde276dc285a87d4d505c05..6d1f92844b3e4fa663f31837d2384eb98e1a1d0d 100644 (file)
@@ -31,7 +31,10 @@ detect_serial(u16 port, u8 timeout, u8 count)
 void
 serial_setup()
 {
+    if (! CONFIG_SERIAL)
+        return;
     dprintf(3, "init serial\n");
+
     u16 count = 0;
     count += detect_serial(0x3f8, 0x0a, count);
     count += detect_serial(0x2f8, 0x0a, count);
@@ -151,6 +154,10 @@ void VISIBLE16
 handle_14(struct bregs *regs)
 {
     debug_enter(regs, DEBUG_HDL_14);
+    if (! CONFIG_SERIAL) {
+        handle_14XX(regs);
+        return;
+    }
 
     irq_enable();
 
@@ -186,7 +193,10 @@ detect_parport(u16 port, u8 timeout, u8 count)
 void
 lpt_setup()
 {
+    if (! CONFIG_LPT)
+        return;
     dprintf(3, "init lpt\n");
+
     u16 count = 0;
     count += detect_parport(0x378, 0x14, count);
     count += detect_parport(0x278, 0x14, count);
@@ -280,6 +290,10 @@ void VISIBLE16
 handle_17(struct bregs *regs)
 {
     debug_enter(regs, DEBUG_HDL_17);
+    if (! CONFIG_LPT) {
+        handle_17XX(regs);
+        return;
+    }
 
     irq_enable();
 
index 9500e923bf38e81b779f62d1cca66ee0f7ee8172..6f5fbb151d54fbf5214071910e8edfd24ff7b9f0 100644 (file)
--- a/src/smm.c
+++ b/src/smm.c
@@ -10,6 +10,7 @@
 #include "config.h" // CONFIG_*
 #include "ioport.h" // outb
 
+#if CONFIG_USE_SMM
 asm(
     ".global smm_relocation_start\n"
     ".global smm_relocation_end\n"
@@ -67,6 +68,7 @@ asm(
     "smm_code_end:\n"
     "  .code32\n"
     );
+#endif
 
 extern u8 smm_relocation_start, smm_relocation_end;
 extern u8 smm_code_start, smm_code_end;