[20f02c6] | 1 | /** |
---|
[11874561] | 2 | * @file rtems/score/context.h |
---|
[ac7d5ef0] | 3 | * |
---|
[1dbbc0c] | 4 | * @brief Information About Each Thread's Context |
---|
| 5 | * |
---|
[baff4da] | 6 | * This include file contains all information about each thread's context. |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | /* |
---|
[7a5a885e] | 10 | * COPYRIGHT (c) 1989-2011. |
---|
[ac7d5ef0] | 11 | * On-Line Applications Research Corporation (OAR). |
---|
| 12 | * |
---|
[98e4ebf5] | 13 | * The license and distribution terms for this file may be |
---|
| 14 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 15 | * http://www.rtems.org/license/LICENSE. |
---|
[ac7d5ef0] | 16 | */ |
---|
| 17 | |
---|
[092f142a] | 18 | #ifndef _RTEMS_SCORE_CONTEXT_H |
---|
| 19 | #define _RTEMS_SCORE_CONTEXT_H |
---|
[ac7d5ef0] | 20 | |
---|
[baff4da] | 21 | /** |
---|
| 22 | * @defgroup ScoreContext Context Handler |
---|
| 23 | * |
---|
[d8cd045c] | 24 | * @ingroup Score |
---|
| 25 | * |
---|
[6a07436] | 26 | * This handler encapsulates functionality which abstracts thread context |
---|
[baff4da] | 27 | * management in a portable manner. |
---|
[11e8bc5] | 28 | * |
---|
| 29 | * The context switch needed variable is contained in the per cpu |
---|
| 30 | * data structure. |
---|
[baff4da] | 31 | */ |
---|
| 32 | /**@{*/ |
---|
| 33 | |
---|
[ac7d5ef0] | 34 | #ifdef __cplusplus |
---|
| 35 | extern "C" { |
---|
| 36 | #endif |
---|
| 37 | |
---|
[5e9b32b] | 38 | #include <rtems/score/cpu.h> |
---|
[ac7d5ef0] | 39 | |
---|
[baff4da] | 40 | /** |
---|
[1dbbc0c] | 41 | * @brief Size of floating point context area. |
---|
[6a07436] | 42 | * |
---|
[baff4da] | 43 | * This constant defines the number of bytes required |
---|
[ac7d5ef0] | 44 | * to store a full floating point context. |
---|
| 45 | */ |
---|
[f455cdea] | 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 |
---|
[ac7d5ef0] | 51 | |
---|
[baff4da] | 52 | /** |
---|
[1dbbc0c] | 53 | * @brief Initialize context area. |
---|
[7a5a885e] | 54 | * |
---|
[baff4da] | 55 | * This routine initializes @a _the_context such that the stack |
---|
[ac7d5ef0] | 56 | * pointer, interrupt level, and entry point are correct for the |
---|
| 57 | * thread's initial state. |
---|
[baff4da] | 58 | * |
---|
[6a07436] | 59 | * @param[in] _the_context will be initialized |
---|
[20f02c6] | 60 | * @param[in] _stack is the lowest physical address of the thread's |
---|
[baff4da] | 61 | * context |
---|
[6a07436] | 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 |
---|
[c6b3719] | 65 | * @param[in] _is_fp is set to true if this thread has floating point |
---|
[baff4da] | 66 | * enabled |
---|
[022851a] | 67 | * @param[in] _tls_area The thread-local storage (TLS) area begin. |
---|
[ac7d5ef0] | 68 | */ |
---|
[022851a] | 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 ) |
---|
[ac7d5ef0] | 73 | |
---|
[48816d7] | 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 | |
---|
[baff4da] | 90 | /** |
---|
[1dbbc0c] | 91 | * @brief Perform context switch. |
---|
[6a07436] | 92 | * |
---|
[baff4da] | 93 | * This routine saves the current context into the @a _executing |
---|
| 94 | * context record and restores the context specified by @a _heir. |
---|
[ac7d5ef0] | 95 | * |
---|
[6a07436] | 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 |
---|
[ac7d5ef0] | 98 | */ |
---|
| 99 | #define _Context_Switch( _executing, _heir ) \ |
---|
| 100 | _CPU_Context_switch( _executing, _heir ) |
---|
| 101 | |
---|
[baff4da] | 102 | /** |
---|
[1dbbc0c] | 103 | * @brief Restart currently executing thread. |
---|
[6a07436] | 104 | * |
---|
[ac7d5ef0] | 105 | * This routine restarts the calling thread by restoring its initial |
---|
| 106 | * stack pointer and returning to the thread's entry point. |
---|
[baff4da] | 107 | * |
---|
[6a07436] | 108 | * @param[in] _the_context is the context of the thread to restart |
---|
[ac7d5ef0] | 109 | */ |
---|
| 110 | #define _Context_Restart_self( _the_context ) \ |
---|
| 111 | _CPU_Context_Restart_self( _the_context ) |
---|
| 112 | |
---|
[baff4da] | 113 | /** |
---|
[1dbbc0c] | 114 | * @brief Initialize floating point context area. |
---|
[6a07436] | 115 | * |
---|
[ac7d5ef0] | 116 | * This routine initializes the floating point context save |
---|
| 117 | * area to contain an initial known state. |
---|
[baff4da] | 118 | * |
---|
[6a07436] | 119 | * @param[in] _fp_area is the base address of the floating point |
---|
[baff4da] | 120 | * context save area to initialize. |
---|
[ac7d5ef0] | 121 | */ |
---|
| 122 | #define _Context_Initialize_fp( _fp_area ) \ |
---|
| 123 | _CPU_Context_Initialize_fp( _fp_area ) |
---|
| 124 | |
---|
[baff4da] | 125 | /** |
---|
[1dbbc0c] | 126 | * @brief Restore floating point context area. |
---|
[6a07436] | 127 | * |
---|
[ac7d5ef0] | 128 | * This routine restores the floating point context contained |
---|
[baff4da] | 129 | * in the @a _fp area. It is assumed that the current |
---|
[ac7d5ef0] | 130 | * floating point context has been saved by a previous invocation |
---|
[baff4da] | 131 | * of @a _Context_Save_fp. |
---|
| 132 | * |
---|
[6a07436] | 133 | * @param[in] _fp points to the floating point context area to restore. |
---|
[ac7d5ef0] | 134 | */ |
---|
| 135 | #define _Context_Restore_fp( _fp ) \ |
---|
| 136 | _CPU_Context_restore_fp( _fp ) |
---|
| 137 | |
---|
[baff4da] | 138 | /** |
---|
[1dbbc0c] | 139 | * @brief Save floating point context area. |
---|
[6a07436] | 140 | * |
---|
[ac7d5ef0] | 141 | * This routine saves the current floating point context |
---|
[baff4da] | 142 | * in the @a _fp area. |
---|
| 143 | * |
---|
[6a07436] | 144 | * @param[in] _fp points to the floating point context area to restore. |
---|
[ac7d5ef0] | 145 | */ |
---|
| 146 | #define _Context_Save_fp( _fp ) \ |
---|
| 147 | _CPU_Context_save_fp( _fp ) |
---|
| 148 | |
---|
[b2e1bded] | 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 | |
---|
[ac7d5ef0] | 156 | #ifdef __cplusplus |
---|
| 157 | } |
---|
| 158 | #endif |
---|
| 159 | |
---|
[baff4da] | 160 | /**@}*/ |
---|
| 161 | |
---|
[ac7d5ef0] | 162 | #endif |
---|
[b10825c] | 163 | /* end of include file */ |
---|