1 | /** |
---|
2 | * @file rtems/score/context.h |
---|
3 | * |
---|
4 | * @brief Information About Each Thread's Context |
---|
5 | * |
---|
6 | * This include file contains all information about each thread's context. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2011. |
---|
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 | #ifndef _RTEMS_SCORE_CONTEXT_H |
---|
19 | #define _RTEMS_SCORE_CONTEXT_H |
---|
20 | |
---|
21 | /** |
---|
22 | * @defgroup ScoreContext Context Handler |
---|
23 | * |
---|
24 | * @ingroup Score |
---|
25 | * |
---|
26 | * This handler encapsulates functionality which abstracts thread context |
---|
27 | * management in a portable manner. |
---|
28 | * |
---|
29 | * The context switch needed variable is contained in the per cpu |
---|
30 | * data structure. |
---|
31 | */ |
---|
32 | /**@{*/ |
---|
33 | |
---|
34 | #ifdef __cplusplus |
---|
35 | extern "C" { |
---|
36 | #endif |
---|
37 | |
---|
38 | #include <rtems/score/cpu.h> |
---|
39 | |
---|
40 | /** |
---|
41 | * @brief Size of floating point context area. |
---|
42 | * |
---|
43 | * This constant defines the number of bytes required |
---|
44 | * to store a full floating point context. |
---|
45 | */ |
---|
46 | #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) |
---|
47 | #define CONTEXT_FP_SIZE CPU_CONTEXT_FP_SIZE |
---|
48 | #else |
---|
49 | #define CONTEXT_FP_SIZE 0 |
---|
50 | #endif |
---|
51 | |
---|
52 | /** |
---|
53 | * @brief Initialize context area. |
---|
54 | * |
---|
55 | * This routine initializes @a _the_context such that the stack |
---|
56 | * pointer, interrupt level, and entry point are correct for the |
---|
57 | * thread's initial state. |
---|
58 | * |
---|
59 | * @param[in] _the_context will be initialized |
---|
60 | * @param[in] _stack is the lowest physical address of the thread's |
---|
61 | * context |
---|
62 | * @param[in] _size is the size in octets of the thread's context |
---|
63 | * @param[in] _isr is the ISR enable level for this thread |
---|
64 | * @param[in] _entry is this thread's entry point |
---|
65 | * @param[in] _is_fp is set to true if this thread has floating point |
---|
66 | * enabled |
---|
67 | * @param[in] _tls_area The thread-local storage (TLS) area begin. |
---|
68 | */ |
---|
69 | #define _Context_Initialize( _the_context, _stack, _size, _isr, _entry, \ |
---|
70 | _is_fp, _tls_area ) \ |
---|
71 | _CPU_Context_Initialize( _the_context, _stack, _size, _isr, _entry, \ |
---|
72 | _is_fp, _tls_area ) |
---|
73 | |
---|
74 | /** |
---|
75 | * This macro is invoked from _Thread_Handler to do whatever CPU |
---|
76 | * specific magic is required that must be done in the context of |
---|
77 | * the thread when it starts. |
---|
78 | * |
---|
79 | * If the CPU architecture does not require any magic, then this |
---|
80 | * macro is empty. |
---|
81 | */ |
---|
82 | |
---|
83 | #if defined(_CPU_Context_Initialization_at_thread_begin) |
---|
84 | #define _Context_Initialization_at_thread_begin() \ |
---|
85 | _CPU_Context_Initialization_at_thread_begin() |
---|
86 | #else |
---|
87 | #define _Context_Initialization_at_thread_begin() |
---|
88 | #endif |
---|
89 | |
---|
90 | /** |
---|
91 | * @brief Perform context switch. |
---|
92 | * |
---|
93 | * This routine saves the current context into the @a _executing |
---|
94 | * context record and restores the context specified by @a _heir. |
---|
95 | * |
---|
96 | * @param[in] _executing is the currently executing thread's context |
---|
97 | * @param[in] _heir is the context of the thread to be switched to |
---|
98 | */ |
---|
99 | #define _Context_Switch( _executing, _heir ) \ |
---|
100 | _CPU_Context_switch( _executing, _heir ) |
---|
101 | |
---|
102 | /** |
---|
103 | * @brief Restart currently executing thread. |
---|
104 | * |
---|
105 | * This routine restarts the calling thread by restoring its initial |
---|
106 | * stack pointer and returning to the thread's entry point. |
---|
107 | * |
---|
108 | * @param[in] _the_context is the context of the thread to restart |
---|
109 | */ |
---|
110 | #define _Context_Restart_self( _the_context ) \ |
---|
111 | _CPU_Context_Restart_self( _the_context ) |
---|
112 | |
---|
113 | /** |
---|
114 | * @brief Initialize floating point context area. |
---|
115 | * |
---|
116 | * This routine initializes the floating point context save |
---|
117 | * area to contain an initial known state. |
---|
118 | * |
---|
119 | * @param[in] _fp_area is the base address of the floating point |
---|
120 | * context save area to initialize. |
---|
121 | */ |
---|
122 | #define _Context_Initialize_fp( _fp_area ) \ |
---|
123 | _CPU_Context_Initialize_fp( _fp_area ) |
---|
124 | |
---|
125 | /** |
---|
126 | * @brief Restore floating point context area. |
---|
127 | * |
---|
128 | * This routine restores the floating point context contained |
---|
129 | * in the @a _fp area. It is assumed that the current |
---|
130 | * floating point context has been saved by a previous invocation |
---|
131 | * of @a _Context_Save_fp. |
---|
132 | * |
---|
133 | * @param[in] _fp points to the floating point context area to restore. |
---|
134 | */ |
---|
135 | #define _Context_Restore_fp( _fp ) \ |
---|
136 | _CPU_Context_restore_fp( _fp ) |
---|
137 | |
---|
138 | /** |
---|
139 | * @brief Save floating point context area. |
---|
140 | * |
---|
141 | * This routine saves the current floating point context |
---|
142 | * in the @a _fp area. |
---|
143 | * |
---|
144 | * @param[in] _fp points to the floating point context area to restore. |
---|
145 | */ |
---|
146 | #define _Context_Save_fp( _fp ) \ |
---|
147 | _CPU_Context_save_fp( _fp ) |
---|
148 | |
---|
149 | #if defined(_CPU_Context_Destroy) |
---|
150 | #define _Context_Destroy( _the_thread, _the_context ) \ |
---|
151 | _CPU_Context_Destroy( _the_thread, _the_context ) |
---|
152 | #else |
---|
153 | #define _Context_Destroy( _the_thread, _the_context ) |
---|
154 | #endif |
---|
155 | |
---|
156 | #ifdef __cplusplus |
---|
157 | } |
---|
158 | #endif |
---|
159 | |
---|
160 | /**@}*/ |
---|
161 | |
---|
162 | #endif |
---|
163 | /* end of include file */ |
---|