default y
help
Support running hardware initialization in parallel.
- config THREAD_OPTIONROMS
- depends on THREADS && !CSM
- bool "Hardware init during option ROM execution"
- default n
- help
- Allow hardware init to run in parallel with optionrom execution.
-
- This can reduce boot time, but can cause some timing
- variations during option ROM code execution. It is not
- known if all option ROMs will behave properly with this
- option.
config RELOCATE_INIT
bool "Copy init code to high memory"
bda_init();
// Other interfaces
+ thread_init();
boot_init();
bios32_init();
pmm_init();
// Setup platform devices.
platform_hardware_setup();
- // Start hardware initialization (if optionrom threading)
- if (CONFIG_THREAD_OPTIONROMS)
+ // Start hardware initialization (if threads allowed during optionroms)
+ if (threads_during_optionroms())
device_hardware_setup();
// Run vga option rom
vgarom_setup();
// Do hardware initialization (if running synchronously)
- if (!CONFIG_THREAD_OPTIONROMS) {
+ if (!threads_during_optionroms()) {
device_hardware_setup();
wait_threads();
}
#include "list.h" // hlist_node
#include "malloc.h" // free
#include "output.h" // dprintf
+#include "romfile.h" // romfile_loadint
#include "stacks.h" // struct mutex_s
#include "util.h" // useRTC
return (void*)ALIGN_DOWN(esp, THREADSTACKSIZE);
}
+static int ThreadControl;
+
+// Initialize the support for internal threads.
+void
+thread_init(void)
+{
+ if (! CONFIG_THREADS)
+ return;
+ ThreadControl = romfile_loadint("etc/threads", 1);
+}
+
+// Should hardware initialization threads run during optionrom execution.
+int
+threads_during_optionroms(void)
+{
+ return CONFIG_THREADS && ThreadControl == 2;
+}
+
// Switch to next thread stack.
static void
switch_next(struct thread_info *cur)
run_thread(void (*func)(void*), void *data)
{
ASSERT32FLAT();
- if (! CONFIG_THREADS)
+ if (! CONFIG_THREADS || ! ThreadControl)
goto fail;
struct thread_info *thread;
thread = memalign_tmphigh(THREADSTACKSIZE, THREADSTACKSIZE);
void
start_preempt(void)
{
- if (! CONFIG_THREAD_OPTIONROMS)
+ if (! threads_during_optionroms())
return;
CanPreempt = 1;
PreemptCount = 0;
void
finish_preempt(void)
{
- if (! CONFIG_THREAD_OPTIONROMS) {
+ if (! threads_during_optionroms()) {
yield();
return;
}
int
wait_preempt(void)
{
- if (MODESEGMENT || !CONFIG_THREAD_OPTIONROMS || !CanPreempt
+ if (MODESEGMENT || !CONFIG_THREADS || !CanPreempt
|| getesp() < MAIN_STACK_MAX)
return 0;
while (CanPreempt)
check_preempt(void)
{
extern void _cfunc32flat_yield_preempt(void);
- if (CONFIG_THREAD_OPTIONROMS && GET_GLOBAL(CanPreempt) && have_threads())
+ if (CONFIG_THREADS && GET_GLOBAL(CanPreempt) && have_threads())
call32(_cfunc32flat_yield_preempt, 0, 0);
}