1 | /** |
---|
2 | * @file rtems/score/context.h |
---|
3 | * |
---|
4 | * This include file contains all information about each thread's context. |
---|
5 | */ |
---|
6 | |
---|
7 | /* |
---|
8 | * COPYRIGHT (c) 1989-2006. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.rtems.com/license/LICENSE. |
---|
14 | * |
---|
15 | * $Id$ |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef _RTEMS_SCORE_CONTEXT_H |
---|
19 | #define _RTEMS_SCORE_CONTEXT_H |
---|
20 | |
---|
21 | /** |
---|
22 | * @defgroup ScoreContext Context Handler |
---|
23 | * |
---|
24 | * This handler encapsulates functionality which abstracts thread context |
---|
25 | * management in a portable manner. |
---|
26 | */ |
---|
27 | /**@{*/ |
---|
28 | |
---|
29 | #ifdef __cplusplus |
---|
30 | extern "C" { |
---|
31 | #endif |
---|
32 | |
---|
33 | #include <rtems/score/cpu.h> |
---|
34 | |
---|
35 | /** |
---|
36 | * @brief Size of Floating Point Context Area |
---|
37 | * |
---|
38 | * This constant defines the number of bytes required |
---|
39 | * to store a full floating point context. |
---|
40 | */ |
---|
41 | #define CONTEXT_FP_SIZE CPU_CONTEXT_FP_SIZE |
---|
42 | |
---|
43 | /** |
---|
44 | * @brief Is Context Switch Needed? |
---|
45 | * |
---|
46 | * This variable is set to TRUE when a reschedule operation |
---|
47 | * has determined that the processor should be taken away from the |
---|
48 | * currently executing thread and given to the heir thread. |
---|
49 | */ |
---|
50 | |
---|
51 | SCORE_EXTERN volatile boolean _Context_Switch_necessary; |
---|
52 | |
---|
53 | /** |
---|
54 | * @brief Initialize Context Area |
---|
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 | */ |
---|
68 | #define _Context_Initialize(_the_context, _stack, _size, _isr, _entry, _is_fp) \ |
---|
69 | _CPU_Context_Initialize( _the_context, _stack, _size, _isr, _entry, _is_fp ) |
---|
70 | |
---|
71 | /** |
---|
72 | * This macro is invoked from _Thread_Handler to do whatever CPU |
---|
73 | * specific magic is required that must be done in the context of |
---|
74 | * the thread when it starts. |
---|
75 | * |
---|
76 | * If the CPU architecture does not require any magic, then this |
---|
77 | * macro is empty. |
---|
78 | */ |
---|
79 | |
---|
80 | #if defined(_CPU_Context_Initialization_at_thread_begin) |
---|
81 | #define _Context_Initialization_at_thread_begin() \ |
---|
82 | _CPU_Context_Initialization_at_thread_begin() |
---|
83 | #else |
---|
84 | #define _Context_Initialization_at_thread_begin() |
---|
85 | #endif |
---|
86 | |
---|
87 | /** |
---|
88 | * @brief Perform Context Switch |
---|
89 | * |
---|
90 | * This routine saves the current context into the @a _executing |
---|
91 | * context record and restores the context specified by @a _heir. |
---|
92 | * |
---|
93 | * @param[in] _executing is the currently executing thread's context |
---|
94 | * @param[in] _heir is the context of the thread to be switched to |
---|
95 | */ |
---|
96 | #define _Context_Switch( _executing, _heir ) \ |
---|
97 | _CPU_Context_switch( _executing, _heir ) |
---|
98 | |
---|
99 | /** |
---|
100 | * @brief Restart Currently Executing Thread |
---|
101 | * |
---|
102 | * This routine restarts the calling thread by restoring its initial |
---|
103 | * stack pointer and returning to the thread's entry point. |
---|
104 | * |
---|
105 | * @param[in] _the_context is the context of the thread to restart |
---|
106 | */ |
---|
107 | #define _Context_Restart_self( _the_context ) \ |
---|
108 | _CPU_Context_Restart_self( _the_context ) |
---|
109 | |
---|
110 | /** |
---|
111 | * @brief Return Starting Address of Floating Point Context |
---|
112 | * |
---|
113 | * This function returns the starting address of the floating |
---|
114 | * point context save area. It is assumed that the are reserved |
---|
115 | * for the floating point save area is large enough. |
---|
116 | * |
---|
117 | * @param[in] _base is lowest physical address of the floating point |
---|
118 | * context save area. |
---|
119 | * @param[in] _offset is the offset into the floating point area |
---|
120 | * |
---|
121 | * @return the initial FP context pointer |
---|
122 | */ |
---|
123 | #define _Context_Fp_start( _base, _offset ) \ |
---|
124 | _CPU_Context_Fp_start( (_base), (_offset) ) |
---|
125 | |
---|
126 | /** |
---|
127 | * @brief Initialize Floating Point Context Area |
---|
128 | * |
---|
129 | * This routine initializes the floating point context save |
---|
130 | * area to contain an initial known state. |
---|
131 | * |
---|
132 | * @param[in] _fp_area is the base address of the floating point |
---|
133 | * context save area to initialize. |
---|
134 | */ |
---|
135 | #define _Context_Initialize_fp( _fp_area ) \ |
---|
136 | _CPU_Context_Initialize_fp( _fp_area ) |
---|
137 | |
---|
138 | /** |
---|
139 | * @brief Restore Floating Point Context Area |
---|
140 | * |
---|
141 | * This routine restores the floating point context contained |
---|
142 | * in the @a _fp area. It is assumed that the current |
---|
143 | * floating point context has been saved by a previous invocation |
---|
144 | * of @a _Context_Save_fp. |
---|
145 | * |
---|
146 | * @param[in] _fp points to the floating point context area to restore. |
---|
147 | */ |
---|
148 | #define _Context_Restore_fp( _fp ) \ |
---|
149 | _CPU_Context_restore_fp( _fp ) |
---|
150 | |
---|
151 | /** |
---|
152 | * @brief Save Floating Point Context Area |
---|
153 | * |
---|
154 | * This routine saves the current floating point context |
---|
155 | * in the @a _fp area. |
---|
156 | * |
---|
157 | * @param[in] _fp points to the floating point context area to restore. |
---|
158 | */ |
---|
159 | #define _Context_Save_fp( _fp ) \ |
---|
160 | _CPU_Context_save_fp( _fp ) |
---|
161 | |
---|
162 | #ifdef __cplusplus |
---|
163 | } |
---|
164 | #endif |
---|
165 | |
---|
166 | /**@}*/ |
---|
167 | |
---|
168 | #endif |
---|
169 | /* end of include file */ |
---|