1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Initializes Enviroment for A Thread |
---|
5 | * |
---|
6 | * @ingroup ScoreThread |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-1999. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #if HAVE_CONFIG_H |
---|
19 | #include "config.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | #include <rtems/score/threadimpl.h> |
---|
23 | |
---|
24 | void _Thread_Load_environment( |
---|
25 | Thread_Control *the_thread |
---|
26 | ) |
---|
27 | { |
---|
28 | bool is_fp; |
---|
29 | uint32_t isr_level; |
---|
30 | |
---|
31 | #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |
---|
32 | if ( the_thread->Start.fp_context ) { |
---|
33 | the_thread->fp_context = the_thread->Start.fp_context; |
---|
34 | _Context_Initialize_fp( &the_thread->fp_context ); |
---|
35 | is_fp = true; |
---|
36 | } else |
---|
37 | #endif |
---|
38 | is_fp = false; |
---|
39 | |
---|
40 | the_thread->is_preemptible = the_thread->Start.is_preemptible; |
---|
41 | the_thread->budget_algorithm = the_thread->Start.budget_algorithm; |
---|
42 | the_thread->budget_callout = the_thread->Start.budget_callout; |
---|
43 | |
---|
44 | #if defined( RTEMS_SMP ) |
---|
45 | /* |
---|
46 | * On SMP we have to start the threads with interrupts disabled, see also |
---|
47 | * _Thread_Handler() and _Thread_Dispatch(). In _Thread_Handler() the |
---|
48 | * _ISR_Set_level() is used to set the desired interrupt state of the thread. |
---|
49 | */ |
---|
50 | isr_level = CPU_MODES_INTERRUPT_MASK; |
---|
51 | #else |
---|
52 | isr_level = the_thread->Start.isr_level; |
---|
53 | #endif |
---|
54 | |
---|
55 | _Context_Initialize( |
---|
56 | &the_thread->Registers, |
---|
57 | the_thread->Start.Initial_stack.area, |
---|
58 | the_thread->Start.Initial_stack.size, |
---|
59 | isr_level, |
---|
60 | _Thread_Handler, |
---|
61 | is_fp, |
---|
62 | the_thread->Start.tls_area |
---|
63 | ); |
---|
64 | |
---|
65 | } |
---|