1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Initialize Thread Handler |
---|
5 | * @ingroup ScoreThread |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2011. |
---|
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/config.h> |
---|
23 | #include <rtems/score/apiext.h> |
---|
24 | #include <rtems/score/context.h> |
---|
25 | #include <rtems/score/interr.h> |
---|
26 | #include <rtems/score/isr.h> |
---|
27 | #include <rtems/score/object.h> |
---|
28 | #include <rtems/score/priority.h> |
---|
29 | #include <rtems/score/scheduler.h> |
---|
30 | #include <rtems/score/states.h> |
---|
31 | #include <rtems/score/sysstate.h> |
---|
32 | #include <rtems/score/thread.h> |
---|
33 | #include <rtems/score/threadq.h> |
---|
34 | #include <rtems/score/wkspace.h> |
---|
35 | #include <rtems/config.h> |
---|
36 | |
---|
37 | #if defined(RTEMS_SMP) |
---|
38 | #include <rtems/bspsmp.h> |
---|
39 | #endif |
---|
40 | |
---|
41 | void _Thread_Handler_initialization(void) |
---|
42 | { |
---|
43 | uint32_t ticks_per_timeslice = |
---|
44 | rtems_configuration_get_ticks_per_timeslice(); |
---|
45 | uint32_t maximum_extensions = |
---|
46 | rtems_configuration_get_maximum_extensions(); |
---|
47 | rtems_stack_allocate_init_hook stack_allocate_init_hook = |
---|
48 | rtems_configuration_get_stack_allocate_init_hook(); |
---|
49 | uint32_t maximum_internal_threads; |
---|
50 | #if defined(RTEMS_MULTIPROCESSING) |
---|
51 | uint32_t maximum_proxies = |
---|
52 | _Configuration_MP_table->maximum_proxies; |
---|
53 | #endif |
---|
54 | |
---|
55 | if ( rtems_configuration_get_stack_allocate_hook() == NULL || |
---|
56 | rtems_configuration_get_stack_free_hook() == NULL) |
---|
57 | _Internal_error_Occurred( |
---|
58 | INTERNAL_ERROR_CORE, |
---|
59 | true, |
---|
60 | INTERNAL_ERROR_BAD_STACK_HOOK |
---|
61 | ); |
---|
62 | |
---|
63 | if ( stack_allocate_init_hook != NULL ) |
---|
64 | (*stack_allocate_init_hook)( rtems_configuration_get_stack_space_size() ); |
---|
65 | |
---|
66 | _Thread_Dispatch_necessary = false; |
---|
67 | _Thread_Executing = NULL; |
---|
68 | _Thread_Heir = NULL; |
---|
69 | #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |
---|
70 | _Thread_Allocated_fp = NULL; |
---|
71 | #endif |
---|
72 | |
---|
73 | _Thread_Maximum_extensions = maximum_extensions; |
---|
74 | |
---|
75 | _Thread_Ticks_per_timeslice = ticks_per_timeslice; |
---|
76 | |
---|
77 | #if defined(RTEMS_MULTIPROCESSING) |
---|
78 | _Thread_MP_Handler_initialization( maximum_proxies ); |
---|
79 | #endif |
---|
80 | |
---|
81 | /* |
---|
82 | * Initialize the internal class of threads. We need an IDLE thread |
---|
83 | * per CPU in an SMP system. In addition, if this is a loosely |
---|
84 | * coupled multiprocessing system, account for the MPCI Server Thread. |
---|
85 | */ |
---|
86 | #if defined(RTEMS_SMP) |
---|
87 | maximum_internal_threads = rtems_configuration_get_maximum_processors(); |
---|
88 | #else |
---|
89 | maximum_internal_threads = 1; |
---|
90 | #endif |
---|
91 | |
---|
92 | #if defined(RTEMS_MULTIPROCESSING) |
---|
93 | if ( _System_state_Is_multiprocessing ) |
---|
94 | maximum_internal_threads += 1; |
---|
95 | #endif |
---|
96 | |
---|
97 | _Objects_Initialize_information( |
---|
98 | &_Thread_Internal_information, |
---|
99 | OBJECTS_INTERNAL_API, |
---|
100 | OBJECTS_INTERNAL_THREADS, |
---|
101 | maximum_internal_threads, |
---|
102 | sizeof( Thread_Control ), |
---|
103 | /* size of this object's control block */ |
---|
104 | false, /* true if names for this object are strings */ |
---|
105 | 8 /* maximum length of each object's name */ |
---|
106 | #if defined(RTEMS_MULTIPROCESSING) |
---|
107 | , |
---|
108 | false, /* true if this is a global object class */ |
---|
109 | NULL /* Proxy extraction support callout */ |
---|
110 | #endif |
---|
111 | ); |
---|
112 | |
---|
113 | } |
---|