]> xenbits.xensource.com Git - seabios.git/commitdiff
Don't enable interrupts prior to IVT and PIC setup
authorKevin O'Connor <kevin@koconnor.net>
Tue, 14 Jul 2015 19:44:26 +0000 (15:44 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Tue, 14 Jul 2015 19:47:39 +0000 (15:47 -0400)
The machine may crash if an interrupt occurs prior to the setup of the
interrupt vector table (IVT) and programmable interrupt controller
(PIC).  This patch makes sure that interrupts remain disabled until
these components are setup.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/fw/csm.c
src/post.c
src/stacks.c
src/stacks.h

index 7cdb398f20e3de4ecf59fee2c3e78c46a91f5dc7..aee2f90e15a1f2189c97d141d96c92fe98ea0fb1 100644 (file)
@@ -183,6 +183,7 @@ handle_csm_0002(struct bregs *regs)
     struct bios_data_area_s *bda = MAKE_FLATPTR(SEG_BDA, 0);
     bda->hdcount = 0;
 
+    thread_setup();
     mathcp_setup();
     timer_setup();
     clock_setup();
index 6157b5070528adf80b3a0021b372dae06c0089f1..8cb7b7cbbaea0a037f0f1021983c2cc3ea6aac2c 100644 (file)
@@ -124,7 +124,6 @@ interface_init(void)
     bda_init();
 
     // Other interfaces
-    thread_init();
     boot_init();
     bios32_init();
     pmm_init();
@@ -167,6 +166,7 @@ platform_hardware_setup(void)
 
     // Init base pc hardware.
     pic_setup();
+    thread_setup();
     mathcp_setup();
     timer_setup();
     clock_setup();
index 1dbdfe9bbc525942e84c9b3aa66d016c1ce0e6ee..1ad9ef093c1d5a46d3c14ceaffbef4005ba16c0f 100644 (file)
@@ -558,12 +558,13 @@ getCurThread(void)
     return (void*)ALIGN_DOWN(esp, THREADSTACKSIZE);
 }
 
-static int ThreadControl;
+static u8 CanInterrupt, ThreadControl;
 
 // Initialize the support for internal threads.
 void
-thread_init(void)
+thread_setup(void)
 {
+    CanInterrupt = 1;
     if (! CONFIG_THREADS)
         return;
     ThreadControl = romfile_loadint("etc/threads", 1);
@@ -673,11 +674,12 @@ void
 yield(void)
 {
     if (MODESEGMENT || !CONFIG_THREADS) {
-        check_irqs();
+        if (MODESEGMENT || CanInterrupt)
+            check_irqs();
         return;
     }
     struct thread_info *cur = getCurThread();
-    if (cur == &MainThread)
+    if (cur == &MainThread && CanInterrupt)
         // Permit irqs to fire
         check_irqs();
 
@@ -705,7 +707,8 @@ yield_toirq(void)
         yield();
         return;
     }
-    wait_irq();
+    if (MODESEGMENT || CanInterrupt)
+        wait_irq();
 }
 
 // Wait for all threads (other than the main thread) to complete.
index 82c4c3c85dbb43b4f2508cf992d2cf3dafd86151..a3b031ce8ed5993ed77d73b16e50e5abf142f37f 100644 (file)
@@ -28,7 +28,7 @@ extern struct thread_info MainThread;
 struct thread_info *getCurThread(void);
 void yield(void);
 void yield_toirq(void);
-void thread_init(void);
+void thread_setup(void);
 int threads_during_optionroms(void);
 void run_thread(void (*func)(void*), void *data);
 void wait_threads(void);