aboutsummaryrefslogtreecommitdiffstats
path: root/src/stacks.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2015-07-14 15:44:26 -0400
committerKevin O'Connor <kevin@koconnor.net>2015-07-14 15:47:39 -0400
commit8b9942fa3368139b089dc3fea0549cc3282b5c12 (patch)
tree39d57e05e25a6529aa5f06b955d43e6459ff2aa0 /src/stacks.c
parent6a668b35e1691de8ebccf9c8b627c58f333cea7a (diff)
downloadseabios-8b9942fa3368139b089dc3fea0549cc3282b5c12.tar.gz
Don't enable interrupts prior to IVT and PIC setup
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>
Diffstat (limited to 'src/stacks.c')
-rw-r--r--src/stacks.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/stacks.c b/src/stacks.c
index 1dbdfe9b..1ad9ef09 100644
--- a/src/stacks.c
+++ b/src/stacks.c
@@ -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.