summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-10-19 11:51:45 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-10-19 11:51:45 +0000
commitd332601135f75dd4a06c1bc8347f0155dc2867f1 (patch)
tree9a6f609f57de1f0d7daac30b7ffea5fd05938cea
parent9ec00d7f25f2f6ec0fe43eae0b1749dafde0b32c (diff)
downloadrockbox-d332601135f75dd4a06c1bc8347f0155dc2867f1.tar.gz
rockbox-d332601135f75dd4a06c1bc8347f0155dc2867f1.zip
Save a little space and only initialize the minimum for initial threads at startup. The BSS sections should already be zereod and if they're mistakenly not, be sure to crash ASAP. ;)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15204 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/thread.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/firmware/thread.c b/firmware/thread.c
index 930e149302..db5d6c3d2c 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -2491,6 +2491,7 @@ unsigned int switch_core(unsigned int new_core)
2491void init_threads(void) 2491void init_threads(void)
2492{ 2492{
2493 const unsigned int core = CURRENT_CORE; 2493 const unsigned int core = CURRENT_CORE;
2494 struct thread_entry *thread;
2494 int slot; 2495 int slot;
2495 2496
2496 /* CPU will initialize first and then sleep */ 2497 /* CPU will initialize first and then sleep */
@@ -2503,42 +2504,38 @@ void init_threads(void)
2503 * or threads is in the wrong section. */ 2504 * or threads is in the wrong section. */
2504 THREAD_PANICF("init_threads->no slot", NULL); 2505 THREAD_PANICF("init_threads->no slot", NULL);
2505 } 2506 }
2506 2507
2507 cores[core].running = NULL; 2508 /* Initialize initially non-zero members of core */
2508 cores[core].timeout = NULL;
2509 thread_queue_init(&cores[core].waking); 2509 thread_queue_init(&cores[core].waking);
2510 cores[core].next_tmo_check = current_tick; /* Something not in the past */ 2510 cores[core].next_tmo_check = current_tick; /* Something not in the past */
2511#if NUM_CORES > 1 2511#if NUM_CORES == 1
2512 cores[core].blk_ops.flags = 0;
2513#else
2514 cores[core].irq_level = STAY_IRQ_LEVEL; 2512 cores[core].irq_level = STAY_IRQ_LEVEL;
2515#endif 2513#endif
2516 threads[slot].name = main_thread_name; 2514#ifdef HAVE_PRIORITY_SCHEDULING
2517 UNLOCK_THREAD_SET_STATE(&threads[slot], STATE_RUNNING); /* No sync worries yet */ 2515 cores[core].highest_priority = LOWEST_PRIORITY;
2518 threads[slot].context.start = NULL; /* core's main thread already running */
2519 threads[slot].tmo.prev = NULL;
2520 threads[slot].queue = NULL;
2521#ifdef HAVE_SCHEDULER_BOOSTCTRL
2522 threads[slot].boosted = 0;
2523#endif 2516#endif
2517
2518 /* Initialize initially non-zero members of slot */
2519 thread = &threads[slot];
2520 thread->name = main_thread_name;
2521 UNLOCK_THREAD_SET_STATE(thread, STATE_RUNNING); /* No sync worries yet */
2524#if NUM_CORES > 1 2522#if NUM_CORES > 1
2525 threads[slot].core = core; 2523 thread->core = core;
2526#endif 2524#endif
2527#ifdef HAVE_PRIORITY_SCHEDULING 2525#ifdef HAVE_PRIORITY_SCHEDULING
2528 threads[slot].priority = PRIORITY_USER_INTERFACE; 2526 thread->priority = PRIORITY_USER_INTERFACE;
2529 threads[slot].priority_x = LOWEST_PRIORITY; 2527 thread->priority_x = LOWEST_PRIORITY;
2530 cores[core].highest_priority = LOWEST_PRIORITY; 2528#endif
2529#if CONFIG_CORELOCK == SW_CORELOCK
2530 corelock_init(&thread->cl);
2531#endif 2531#endif
2532 2532
2533 add_to_list_l(&cores[core].running, &threads[slot]); 2533 add_to_list_l(&cores[core].running, thread);
2534 2534
2535 if (core == CPU) 2535 if (core == CPU)
2536 { 2536 {
2537#ifdef HAVE_SCHEDULER_BOOSTCTRL 2537 thread->stack = stackbegin;
2538 boosted_threads = 0; 2538 thread->stack_size = (int)stackend - (int)stackbegin;
2539#endif
2540 threads[slot].stack = stackbegin;
2541 threads[slot].stack_size = (int)stackend - (int)stackbegin;
2542#if NUM_CORES > 1 /* This code path will not be run on single core targets */ 2539#if NUM_CORES > 1 /* This code path will not be run on single core targets */
2543 /* TODO: HAL interface for this */ 2540 /* TODO: HAL interface for this */
2544 /* Wake up coprocessor and let it initialize kernel and threads */ 2541 /* Wake up coprocessor and let it initialize kernel and threads */
@@ -2550,10 +2547,8 @@ void init_threads(void)
2550 else 2547 else
2551 { 2548 {
2552 /* Initial stack is the COP idle stack */ 2549 /* Initial stack is the COP idle stack */
2553 threads[slot].stack = cop_idlestackbegin; 2550 thread->stack = cop_idlestackbegin;
2554 threads[slot].stack_size = IDLE_STACK_SIZE; 2551 thread->stack_size = IDLE_STACK_SIZE;
2555 /* Mark COP initialized */
2556 cores[COP].blk_ops.flags = 0;
2557 /* Get COP safely primed inside switch_thread where it will remain 2552 /* Get COP safely primed inside switch_thread where it will remain
2558 * until a thread actually exists on it */ 2553 * until a thread actually exists on it */
2559 CPU_CTL = PROC_WAKE; 2554 CPU_CTL = PROC_WAKE;