[SeaBIOS] [PATCH] Cleanup - it's no longer necessary to manually reset global variables.

Kevin O'Connor kevin at koconnor.net
Sat Sep 25 19:54:04 CEST 2010


Now that a soft-reboot forces a hard-reboot, it is no longer necessary
to manually reset global variables.
---
 src/block.c      |   11 -----------
 src/cdrom.c      |    2 --
 src/clock.c      |    1 -
 src/coreboot.c   |    6 ------
 src/disk.h       |    1 -
 src/memmap.c     |    7 -------
 src/memmap.h     |    1 -
 src/optionroms.c |    5 +----
 src/pmm.c        |    6 ------
 src/post.c       |    3 ---
 src/smp.c        |    8 --------
 src/stacks.c     |    2 --
 src/usb-hid.c    |    9 ---------
 src/usb-hid.h    |    1 -
 src/usb.c        |    2 --
 src/util.h       |    1 -
 src/vgahooks.c   |    5 ++---
 17 files changed, 3 insertions(+), 68 deletions(-)

diff --git a/src/block.c b/src/block.c
index b6b1902..3f4b13f 100644
--- a/src/block.c
+++ b/src/block.c
@@ -329,14 +329,3 @@ send_disk_op(struct disk_op_s *op)
 
     return stack_hop((u32)op, GET_SEG(SS), __send_disk_op);
 }
-
-
-/****************************************************************
- * Setup
- ****************************************************************/
-
-void
-drive_setup(void)
-{
-    memset(&Drives, 0, sizeof(Drives));
-}
diff --git a/src/cdrom.c b/src/cdrom.c
index 655ee00..349e401 100644
--- a/src/cdrom.c
+++ b/src/cdrom.c
@@ -109,8 +109,6 @@ cdemu_setup(void)
 {
     if (!CONFIG_CDROM_EMU)
         return;
-    cdemu_drive_gf = NULL;
-    cdemu_buf_fl = NULL;
     if (!Drives.cdcount)
         return;
 
diff --git a/src/clock.c b/src/clock.c
index f6a43e9..fcdc698 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -211,7 +211,6 @@ timer_setup(void)
     u32 ticks = (hours * 60 + minutes) * 60 + seconds;
     ticks = ((u64)ticks * PIT_TICK_RATE) / PIT_TICK_INTERVAL;
     SET_BDA(timer_counter, ticks);
-    SET_BDA(timer_rollover, 0);
 
     enable_hwirq(0, FUNC16(entry_08));
     enable_hwirq(8, FUNC16(entry_70));
diff --git a/src/coreboot.c b/src/coreboot.c
index db0063b..50d300c 100644
--- a/src/coreboot.c
+++ b/src/coreboot.c
@@ -126,8 +126,6 @@ coreboot_fill_map(void)
 {
     dprintf(3, "Attempting to find coreboot table\n");
 
-    CBMemTable = NULL;
-
     // Find coreboot table.
     struct cb_header *cbh = find_cb_header(0, 0x1000);
     if (!cbh)
@@ -290,10 +288,6 @@ coreboot_copy_biostable(void)
 
     dprintf(3, "Relocating coreboot bios tables\n");
 
-    // Init variables set in coreboot table memory scan.
-    PirOffset = 0;
-    RsdpAddr = 0;
-
     // Scan CB_MEM_TABLE areas for bios tables.
     int i, count = MEM_RANGE_COUNT(cbm);
     for (i=0; i<count; i++) {
diff --git a/src/disk.h b/src/disk.h
index 9e5b083..55a5da3 100644
--- a/src/disk.h
+++ b/src/disk.h
@@ -234,7 +234,6 @@ void map_hd_drive(struct drive_s *drive_g);
 void map_cd_drive(struct drive_s *drive_g);
 int process_op(struct disk_op_s *op);
 int send_disk_op(struct disk_op_s *op);
-void drive_setup(void);
 
 // floppy.c
 extern struct floppy_ext_dbt_s diskette_param_table2;
diff --git a/src/memmap.c b/src/memmap.c
index 84bc4fa..ea05953 100644
--- a/src/memmap.c
+++ b/src/memmap.c
@@ -119,13 +119,6 @@ add_e820(u64 start, u64 size, u32 type)
     //dump_map();
 }
 
-// Prep for memmap stuff - init bios table locations.
-void
-memmap_setup(void)
-{
-    e820_count = 0;
-}
-
 // Report on final memory locations.
 void
 memmap_finalize(void)
diff --git a/src/memmap.h b/src/memmap.h
index d4154c1..01c7ddb 100644
--- a/src/memmap.h
+++ b/src/memmap.h
@@ -17,7 +17,6 @@ struct e820entry {
 };
 
 void add_e820(u64 start, u64 size, u32 type);
-void memmap_setup(void);
 void memmap_finalize(void);
 
 // A typical OS page size
diff --git a/src/optionroms.c b/src/optionroms.c
index ceb4060..854c33f 100644
--- a/src/optionroms.c
+++ b/src/optionroms.c
@@ -72,7 +72,7 @@ struct pnp_data {
 #define PCIROM_CODETYPE_X86 0
 
 // The end of the last deployed rom.
-u32 RomEnd;
+u32 RomEnd = BUILD_ROM_START;
 
 
 /****************************************************************
@@ -423,9 +423,6 @@ optionrom_setup(void)
 void
 vga_setup(void)
 {
-    VGAbdf = -1;
-    RomEnd = BUILD_ROM_START;
-
     if (! CONFIG_OPTIONROMS)
         return;
 
diff --git a/src/pmm.c b/src/pmm.c
index bb90ff0..e0770ac 100644
--- a/src/pmm.c
+++ b/src/pmm.c
@@ -193,12 +193,6 @@ malloc_setup(void)
     ASSERT32FLAT();
     dprintf(3, "malloc setup\n");
 
-    ZoneLow.info = ZoneHigh.info = ZoneFSeg.info = NULL;
-    ZoneTmpLow.info = ZoneTmpHigh.info = NULL;
-
-    // Clear memory in 0xf0000 area.
-    memset(BiosTableSpace, 0, CONFIG_MAX_BIOSTABLE);
-
     // Populate temp high ram
     u32 highram = 0;
     int i;
diff --git a/src/post.c b/src/post.c
index a72b8cd..4e42731 100644
--- a/src/post.c
+++ b/src/post.c
@@ -211,7 +211,6 @@ maininit(void)
     mathcp_setup();
 
     // Initialize mtrr
-    smp_probe_setup();
     mtrr_setup();
 
     // Initialize pci
@@ -220,7 +219,6 @@ maininit(void)
 
     // Initialize internal tables
     boot_setup();
-    drive_setup();
 
     // Start hardware initialization (if optionrom threading)
     if (CONFIG_THREADS && CONFIG_THREAD_OPTIONROMS)
@@ -327,7 +325,6 @@ void VISIBLE32INIT
 post(void)
 {
     // Detect ram and setup internal malloc.
-    memmap_setup();
     qemu_cfg_port_probe();
     ram_probe();
     malloc_setup();
diff --git a/src/smp.c b/src/smp.c
index 38e117e..40f5451 100644
--- a/src/smp.c
+++ b/src/smp.c
@@ -127,11 +127,3 @@ smp_probe(void)
     dprintf(1, "Found %d cpu(s) max supported %d cpu(s)\n", readl(&CountCPUs),
         MaxCountCPUs);
 }
-
-// Reset variables to zero
-void
-smp_probe_setup(void)
-{
-    CountCPUs = 0;
-    smp_mtrr_count = 0;
-}
diff --git a/src/stacks.c b/src/stacks.c
index dade3af..d541a4f 100644
--- a/src/stacks.c
+++ b/src/stacks.c
@@ -195,8 +195,6 @@ thread_setup(void)
 {
     MainThread.next = &MainThread;
     MainThread.pprev = &MainThread.next;
-    MainThread.stackpos = NULL;
-    CanPreempt = 0;
 }
 
 // Return the 'struct thread_info' for the currently running thread.
diff --git a/src/usb-hid.c b/src/usb-hid.c
index b88d684..168b7fa 100644
--- a/src/usb-hid.c
+++ b/src/usb-hid.c
@@ -130,15 +130,6 @@ usb_hid_init(struct usb_pipe *pipe
     return -1;
 }
 
-void
-usb_hid_setup(void)
-{
-    if (CONFIG_USB_KEYBOARD)
-        keyboard_pipe = NULL;
-    if (CONFIG_USB_MOUSE)
-        mouse_pipe = NULL;
-}
-
 
 /****************************************************************
  * Keyboard events
diff --git a/src/usb-hid.h b/src/usb-hid.h
index d8199b9..7fbcf4b 100644
--- a/src/usb-hid.h
+++ b/src/usb-hid.h
@@ -6,7 +6,6 @@ struct usb_interface_descriptor;
 struct usb_pipe;
 int usb_hid_init(struct usb_pipe *pipe
                  , struct usb_interface_descriptor *iface, int imax);
-void usb_hid_setup(void);
 inline int usb_kbd_active(void);
 inline int usb_kbd_command(int command, u8 *param);
 inline int usb_mouse_active(void);
diff --git a/src/usb.c b/src/usb.c
index cefc5f3..aa8d72c 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -423,8 +423,6 @@ usb_setup(void)
 
     dprintf(3, "init usb\n");
 
-    usb_hid_setup();
-
     // Look for USB controllers
     int ehcibdf = -1;
     int count = 0;
diff --git a/src/util.h b/src/util.h
index c27037a..1823fd4 100644
--- a/src/util.h
+++ b/src/util.h
@@ -358,7 +358,6 @@ extern u32 CountCPUs;
 extern u32 MaxCountCPUs;
 void wrmsr_smp(u32 index, u64 val);
 void smp_probe(void);
-void smp_probe_setup(void);
 
 // coreboot.c
 struct cbfs_file;
diff --git a/src/vgahooks.c b/src/vgahooks.c
index 14678be..eb4dfa8 100644
--- a/src/vgahooks.c
+++ b/src/vgahooks.c
@@ -13,7 +13,7 @@
 #include "config.h" // CONFIG_*
 
 // The Bus/Dev/Fn of the primary VGA device.
-int VGAbdf VAR16VISIBLE;
+int VGAbdf VAR16VISIBLE = -1;
 // Coreboot board detected.
 int CBmainboard VAR16VISIBLE;
 
@@ -305,11 +305,10 @@ vgahook_setup(const char *vendor, const char *part)
     if (! CONFIG_VGAHOOKS)
         return;
 
-    CBmainboard = 0;
     for (i=0; i<(sizeof(mainboard_list) / sizeof(mainboard_list[0])); i++) {
         if (!strcmp(vendor, mainboard_list[i].vendor) &&
             !strcmp(part, mainboard_list[i].device)) {
-            printf("Found mainboard %s %s\n", vendor, part); 
+            printf("Found mainboard %s %s\n", vendor, part);
             CBmainboard = mainboard_list[i].type;
             break;
         }
-- 
1.7.2.3




More information about the SeaBIOS mailing list