]> xenbits.xensource.com Git - seabios.git/commitdiff
Replace CONFIG_THREAD_OPTIONROMS with a runtime config setting.
authorKevin O'Connor <kevin@koconnor.net>
Mon, 7 Apr 2014 16:15:34 +0000 (12:15 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 7 Apr 2014 16:15:34 +0000 (12:15 -0400)
Replace the CONFIG_THREAD_OPTIONROMS option with the CBFS (or fw_cfg)
file "etc/threads".  This allows for the "threads during optionrom"
capability to be enabled/disabled without requiring SeaBIOS to be
recompiled.  A value of "2" in this file will enable threads to run
during option rom execution.

This change also allows for all threads to be disabled via the same
runtime config file.  Setting the file to a value of "0" will cause
SeaBIOS to perform all hardware initialization serially.

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

index cce3ad877cdaf9eb5e6c8b298c112b53d3c365cd..a8638662b95e0b647763ccef67cd942aff08c9fe 100644 (file)
@@ -46,17 +46,6 @@ endchoice
         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"
index b5cbdb82155c77be87ffc2829aca99ab87e2df7f..5fc196806bbe5167b18af50506d1d42c2320dea8 100644 (file)
@@ -122,6 +122,7 @@ interface_init(void)
     bda_init();
 
     // Other interfaces
+    thread_init();
     boot_init();
     bios32_init();
     pmm_init();
@@ -212,15 +213,15 @@ maininit(void)
     // 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();
     }
index de71c1dd178fecaac1f72e28d6bda95e32ad36fc..6bcb3194072f9bb7f147f460851a99d78be16c50 100644 (file)
@@ -10,6 +10,7 @@
 #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
 
@@ -271,6 +272,24 @@ getCurThread(void)
     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)
@@ -309,7 +328,7 @@ void
 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);
@@ -452,7 +471,7 @@ static u32 PreemptCount;
 void
 start_preempt(void)
 {
-    if (! CONFIG_THREAD_OPTIONROMS)
+    if (! threads_during_optionroms())
         return;
     CanPreempt = 1;
     PreemptCount = 0;
@@ -463,7 +482,7 @@ start_preempt(void)
 void
 finish_preempt(void)
 {
-    if (! CONFIG_THREAD_OPTIONROMS) {
+    if (! threads_during_optionroms()) {
         yield();
         return;
     }
@@ -477,7 +496,7 @@ finish_preempt(void)
 int
 wait_preempt(void)
 {
-    if (MODESEGMENT || !CONFIG_THREAD_OPTIONROMS || !CanPreempt
+    if (MODESEGMENT || !CONFIG_THREADS || !CanPreempt
         || getesp() < MAIN_STACK_MAX)
         return 0;
     while (CanPreempt)
@@ -498,7 +517,7 @@ void
 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);
 }
 
index 9fe876127e18ed5f42a5b8903ee4e675ffd0b369..d8584f22fa1fb3610f37903d4b0b6ff549bfd78d 100644 (file)
@@ -21,6 +21,8 @@ extern struct thread_info MainThread;
 struct thread_info *getCurThread(void);
 void yield(void);
 void yield_toirq(void);
+void thread_init(void);
+int threads_during_optionroms(void);
 void run_thread(void (*func)(void*), void *data);
 void wait_threads(void);
 struct mutex_s { u32 isLocked; };