1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Start Thread Multitasking |
---|
5 | * @ingroup ScoreThread |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2006. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/score/apiext.h> |
---|
23 | #include <rtems/score/context.h> |
---|
24 | #include <rtems/score/interr.h> |
---|
25 | #include <rtems/score/isr.h> |
---|
26 | #include <rtems/score/object.h> |
---|
27 | #include <rtems/score/priority.h> |
---|
28 | #include <rtems/score/states.h> |
---|
29 | #include <rtems/score/sysstate.h> |
---|
30 | #include <rtems/score/thread.h> |
---|
31 | #include <rtems/score/threadq.h> |
---|
32 | #include <rtems/score/wkspace.h> |
---|
33 | |
---|
34 | void _Thread_Start_multitasking( void ) |
---|
35 | { |
---|
36 | /* |
---|
37 | * The system is now multitasking and completely initialized. |
---|
38 | * This system thread now "hides" in a single processor until |
---|
39 | * the system is shut down. |
---|
40 | */ |
---|
41 | |
---|
42 | _System_state_Set( SYSTEM_STATE_UP ); |
---|
43 | |
---|
44 | _Thread_Dispatch_necessary = false; |
---|
45 | |
---|
46 | _Thread_Executing = _Thread_Heir; |
---|
47 | |
---|
48 | /* |
---|
49 | * Get the init task(s) running. |
---|
50 | * |
---|
51 | * Note: Thread_Dispatch() is normally used to dispatch threads. As |
---|
52 | * part of its work, Thread_Dispatch() restores floating point |
---|
53 | * state for the heir task. |
---|
54 | * |
---|
55 | * This code avoids Thread_Dispatch(), and so we have to restore |
---|
56 | * (actually initialize) the floating point state "by hand". |
---|
57 | * |
---|
58 | * Ignore the CPU_USE_DEFERRED_FP_SWITCH because we must always |
---|
59 | * switch in the first thread if it is FP. |
---|
60 | */ |
---|
61 | #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |
---|
62 | /* |
---|
63 | * don't need to worry about saving BSP's floating point state |
---|
64 | */ |
---|
65 | |
---|
66 | if ( _Thread_Heir->fp_context != NULL ) |
---|
67 | _Context_Restore_fp( &_Thread_Heir->fp_context ); |
---|
68 | #endif |
---|
69 | |
---|
70 | #if defined(_CPU_Start_multitasking) |
---|
71 | _CPU_Start_multitasking( &_Thread_BSP_context, &_Thread_Heir->Registers ); |
---|
72 | #else |
---|
73 | _Context_Switch( &_Thread_BSP_context, &_Thread_Heir->Registers ); |
---|
74 | #endif |
---|
75 | } |
---|