Cleanup - it's no longer necessary to manually reset global variables.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 25 Sep 2010 18:53:15 +0000 (14:53 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 25 Sep 2010 18:53:15 +0000 (14:53 -0400)
Now that a soft-reboot forces a hard-reboot, it is no longer necessary
to manually reset global variables.

17 files changed:
src/block.c
src/cdrom.c
src/clock.c
src/coreboot.c
src/disk.h
src/memmap.c
src/memmap.h
src/optionroms.c
src/pmm.c
src/post.c
src/smp.c
src/stacks.c
src/usb-hid.c
src/usb-hid.h
src/usb.c
src/util.h
src/vgahooks.c

index b6b1902679bc6248781d7c8cef240340db0f5c96..3f4b13faaad9d314da0f0d7caa59dba31fbf7c15 100644 (file)
@@ -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));
-}
index 655ee00ad09ffebc8f045f225c01b9182570b78c..349e401bbd65346bcc3a3291906df47477f7fcdb 100644 (file)
@@ -109,8 +109,6 @@ cdemu_setup(void)
 {
     if (!CONFIG_CDROM_EMU)
         return;
-    cdemu_drive_gf = NULL;
-    cdemu_buf_fl = NULL;
     if (!Drives.cdcount)
         return;
 
index f6a43e9eebda9908a556a1fef793d174b8cc6454..fcdc698bb15b8c9a0cad8a950312fa1b3b35e965 100644 (file)
@@ -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));
index db0063beecaa51fce8a1fcfbc0c0e7eb367f17ed..50d300c8dabd2251c4784bcfcc6f67c6d004a973 100644 (file)
@@ -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++) {
index 9e5b08357d2e2497f40030d5bf3ed91260ac3cc2..55a5da3ba7031afe61bc8f55583143bc2ab0f563 100644 (file)
@@ -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;
index 84bc4faa94650db92a1d03fc964d38e0dd6424f1..ea05953def3568e48f84d107bba63a444dd6139b 100644 (file)
@@ -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)
index d4154c1a7d15e9f66c321c679693148767469e5f..01c7ddb1f63e609e2b091260a45e94a765d93bc2 100644 (file)
@@ -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
index ceb4060391ed9f0e0c930eba0fd9866f38e67ac7..854c33fd1d44e2a2648a809bb6c570c43f2a1b31 100644 (file)
@@ -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;
 
index bb90ff068bc27723c85829e0896e8b27ef703d98..e0770ac55f73e516bc0ff3113b779b978538d2cb 100644 (file)
--- 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;
index a72b8cdcba122030afe7478afba1f806d1994085..1e351421034abf05b2ff233195dec40cbc022811 100644 (file)
@@ -205,13 +205,11 @@ maininit(void)
     init_bda();
 
     // Init base pc hardware.
-    thread_setup();
     pic_setup();
     timer_setup();
     mathcp_setup();
 
     // Initialize mtrr
-    smp_probe_setup();
     mtrr_setup();
 
     // Initialize pci
@@ -220,7 +218,6 @@ maininit(void)
 
     // Initialize internal tables
     boot_setup();
-    drive_setup();
 
     // Start hardware initialization (if optionrom threading)
     if (CONFIG_THREADS && CONFIG_THREAD_OPTIONROMS)
@@ -327,7 +324,6 @@ void VISIBLE32INIT
 post(void)
 {
     // Detect ram and setup internal malloc.
-    memmap_setup();
     qemu_cfg_port_probe();
     ram_probe();
     malloc_setup();
index 38e117ebb74b389e61b8c42377a0c67d8f4e5bce..40f5451e5fee4ec0276de4a8c5203467892120ae 100644 (file)
--- 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;
-}
index dade3af76e9a0c71667965438e80336e81459866..14f6f8ad4160052aa3f6be60ac4c037ad83098e5 100644 (file)
@@ -15,7 +15,9 @@ struct thread_info {
     void *stackpos;
     struct thread_info **pprev;
 };
-struct thread_info VAR16VISIBLE MainThread;
+struct thread_info VAR32FLATVISIBLE MainThread = {
+    &MainThread, NULL, &MainThread.next
+};
 
 
 /****************************************************************
@@ -190,15 +192,6 @@ stack_hop(u32 eax, u32 edx, void *func)
 #define THREADSTACKSIZE 4096
 int VAR16VISIBLE CanPreempt;
 
-void
-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.
 struct thread_info *
 getCurThread(void)
@@ -397,7 +390,7 @@ check_preempt(void)
 {
     if (! CONFIG_THREADS || ! CONFIG_THREAD_OPTIONROMS
         || !GET_GLOBAL(CanPreempt)
-        || GET_GLOBAL(MainThread.next) == &MainThread)
+        || GET_FLATPTR(MainThread.next) == &MainThread)
         return;
 
     call32(yield_preempt);
index b88d684f483b6c9518b06a870c01dc106d0cb56e..168b7fabb209588fffe89bdfd79fdfc8c3f98233 100644 (file)
@@ -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
index d8199b9bfe1e3cb6979d548676525b3a9e6ee9b7..7fbcf4b0a56289645168ac8cb009fff43291802a 100644 (file)
@@ -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);
index cefc5f3f6837c749ac9f1278730db1cb966f3995..aa8d72cc1f7ec273e07faa1d463d24e8fba169b0 100644 (file)
--- 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;
index c27037a61ff3d457b8ec3fa20f94b8dc1a25b381..5cc9f17de6d29b13d8127f6e1023f488fdfd6904 100644 (file)
@@ -213,7 +213,6 @@ int get_keystroke(int msec);
 // stacks.c
 inline u32 stack_hop(u32 eax, u32 edx, void *func);
 extern struct thread_info MainThread;
-void thread_setup(void);
 struct thread_info *getCurThread(void);
 void yield(void);
 void wait_irq(void);
@@ -358,7 +357,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;
index 14678be76c645d95d1d0e3964997c0e2dd8cc68b..eb4dfa890ab52c8a49601c592b633ba95b724164 100644 (file)
@@ -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;
         }