1 | /* |
---|
2 | * Thread Handler |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1998. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * Copyright assigned to U.S. Government, 1994. |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in found in the file LICENSE in this distribution or at |
---|
11 | * http://www.OARcorp.com/rtems/license.html. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #include <rtems/system.h> |
---|
17 | #include <rtems/score/apiext.h> |
---|
18 | #include <rtems/score/context.h> |
---|
19 | #include <rtems/score/interr.h> |
---|
20 | #include <rtems/score/isr.h> |
---|
21 | #include <rtems/score/object.h> |
---|
22 | #include <rtems/score/priority.h> |
---|
23 | #include <rtems/score/states.h> |
---|
24 | #include <rtems/score/sysstate.h> |
---|
25 | #include <rtems/score/thread.h> |
---|
26 | #include <rtems/score/threadq.h> |
---|
27 | #include <rtems/score/userext.h> |
---|
28 | #include <rtems/score/wkspace.h> |
---|
29 | |
---|
30 | /*PAGE |
---|
31 | * |
---|
32 | * _Thread_Create_idle |
---|
33 | */ |
---|
34 | |
---|
35 | char *_Thread_Idle_name = "IDLE"; |
---|
36 | |
---|
37 | void _Thread_Create_idle( void ) |
---|
38 | { |
---|
39 | void *idle; |
---|
40 | unsigned32 idle_task_stack_size; |
---|
41 | |
---|
42 | /* |
---|
43 | * The entire workspace is zeroed during its initialization. Thus, all |
---|
44 | * fields not explicitly assigned were explicitly zeroed by |
---|
45 | * _Workspace_Initialization. |
---|
46 | */ |
---|
47 | |
---|
48 | _Thread_Idle = _Thread_Internal_allocate(); |
---|
49 | |
---|
50 | /* |
---|
51 | * Initialize the IDLE task. |
---|
52 | */ |
---|
53 | |
---|
54 | #if (CPU_PROVIDES_IDLE_THREAD_BODY == TRUE) |
---|
55 | idle = (void *) _CPU_Thread_Idle_body; |
---|
56 | #else |
---|
57 | idle = (void *) _Thread_Idle_body; |
---|
58 | #endif |
---|
59 | |
---|
60 | if ( _CPU_Table.idle_task ) |
---|
61 | idle = _CPU_Table.idle_task; |
---|
62 | |
---|
63 | idle_task_stack_size = _CPU_Table.idle_task_stack_size; |
---|
64 | if ( idle_task_stack_size < STACK_MINIMUM_SIZE ) |
---|
65 | idle_task_stack_size = STACK_MINIMUM_SIZE; |
---|
66 | |
---|
67 | _Thread_Initialize( |
---|
68 | &_Thread_Internal_information, |
---|
69 | _Thread_Idle, |
---|
70 | NULL, /* allocate the stack */ |
---|
71 | idle_task_stack_size, |
---|
72 | CPU_IDLE_TASK_IS_FP, |
---|
73 | PRIORITY_MAXIMUM, |
---|
74 | TRUE, /* preemptable */ |
---|
75 | THREAD_CPU_BUDGET_ALGORITHM_NONE, |
---|
76 | NULL, /* no budget algorithm callout */ |
---|
77 | 0, /* all interrupts enabled */ |
---|
78 | _Thread_Idle_name |
---|
79 | ); |
---|
80 | |
---|
81 | /* |
---|
82 | * WARNING!!! This is necessary to "kick" start the system and |
---|
83 | * MUST be done before _Thread_Start is invoked. |
---|
84 | */ |
---|
85 | |
---|
86 | _Thread_Heir = |
---|
87 | _Thread_Executing = _Thread_Idle; |
---|
88 | |
---|
89 | _Thread_Start( |
---|
90 | _Thread_Idle, |
---|
91 | THREAD_START_NUMERIC, |
---|
92 | idle, |
---|
93 | NULL, |
---|
94 | 0 |
---|
95 | ); |
---|
96 | |
---|
97 | } |
---|