![]() |
|
|||
File indexing completed on 2025-05-11 08:24:12
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSScoreContext 0007 * 0008 * @brief This header file provides the interfaces of the 0009 * @ref RTEMSScoreContext. 0010 */ 0011 0012 /* 0013 * COPYRIGHT (c) 1989-2011. 0014 * On-Line Applications Research Corporation (OAR). 0015 * 0016 * Redistribution and use in source and binary forms, with or without 0017 * modification, are permitted provided that the following conditions 0018 * are met: 0019 * 1. Redistributions of source code must retain the above copyright 0020 * notice, this list of conditions and the following disclaimer. 0021 * 2. Redistributions in binary form must reproduce the above copyright 0022 * notice, this list of conditions and the following disclaimer in the 0023 * documentation and/or other materials provided with the distribution. 0024 * 0025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0028 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0029 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0030 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0031 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0032 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0033 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0034 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0035 * POSSIBILITY OF SUCH DAMAGE. 0036 */ 0037 0038 #ifndef _RTEMS_SCORE_CONTEXT_H 0039 #define _RTEMS_SCORE_CONTEXT_H 0040 0041 /** 0042 * @defgroup RTEMSScoreContext Context Handler 0043 * 0044 * @ingroup RTEMSScore 0045 * 0046 * @brief This group contains the Context Handler implementation. 0047 * 0048 * This handler encapsulates functionality which abstracts thread context 0049 * management in a portable manner. 0050 * 0051 * The context switch needed variable is contained in the per cpu 0052 * data structure. 0053 * 0054 * @{ 0055 */ 0056 0057 #ifdef __cplusplus 0058 extern "C" { 0059 #endif 0060 0061 #include <rtems/score/cpu.h> 0062 0063 /** 0064 * @brief Size of floating point context area. 0065 * 0066 * This constant defines the number of bytes required 0067 * to store a full floating point context. 0068 */ 0069 #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) 0070 #define CONTEXT_FP_SIZE \ 0071 RTEMS_ALIGN_UP( CPU_CONTEXT_FP_SIZE, CPU_STACK_ALIGNMENT ) 0072 #else 0073 #define CONTEXT_FP_SIZE 0 0074 #endif 0075 0076 /** 0077 * @brief Initialize context area. 0078 * 0079 * This routine initializes @a _the_context such that the stack 0080 * pointer, interrupt level, and entry point are correct for the 0081 * thread's initial state. 0082 * 0083 * @param[in] _the_context will be initialized 0084 * @param[in] _stack is the lowest physical address of the thread's 0085 * context 0086 * @param[in] _size is the size in octets of the thread's context 0087 * @param[in] _isr is the ISR enable level for this thread 0088 * @param[in] _entry is this thread's entry point 0089 * @param[in] _is_fp is set to true if this thread has floating point 0090 * enabled 0091 * @param[in] _tls_area The thread-local storage (TLS) area begin. 0092 */ 0093 #define _Context_Initialize( _the_context, _stack, _size, _isr, _entry, \ 0094 _is_fp, _tls_area ) \ 0095 _CPU_Context_Initialize( _the_context, _stack, _size, _isr, _entry, \ 0096 _is_fp, _tls_area ) 0097 0098 /** 0099 * This macro is invoked from _Thread_Handler to do whatever CPU 0100 * specific magic is required that must be done in the context of 0101 * the thread when it starts. 0102 * 0103 * If the CPU architecture does not require any magic, then this 0104 * macro is empty. 0105 */ 0106 0107 #if defined(_CPU_Context_Initialization_at_thread_begin) 0108 #define _Context_Initialization_at_thread_begin() \ 0109 _CPU_Context_Initialization_at_thread_begin() 0110 #else 0111 #define _Context_Initialization_at_thread_begin() 0112 #endif 0113 0114 /** 0115 * @brief Perform context switch. 0116 * 0117 * This routine saves the current context into the @a _executing 0118 * context record and restores the context specified by @a _heir. 0119 * 0120 * @param[in] _executing is the currently executing thread's context 0121 * @param[in] _heir is the context of the thread to be switched to 0122 */ 0123 #define _Context_Switch( _executing, _heir ) \ 0124 _CPU_Context_switch( _executing, _heir ) 0125 0126 /** 0127 * @brief Restart currently executing thread. 0128 * 0129 * This routine restarts the calling thread by restoring its initial 0130 * stack pointer and returning to the thread's entry point. 0131 * 0132 * @param[in] _the_context is the context of the thread to restart 0133 */ 0134 #define _Context_Restart_self( _the_context ) \ 0135 _CPU_Context_Restart_self( _the_context ) 0136 0137 /** 0138 * @brief Initialize floating point context area. 0139 * 0140 * This routine initializes the floating point context save 0141 * area to contain an initial known state. 0142 * 0143 * @param[in] _fp_area is the base address of the floating point 0144 * context save area to initialize. 0145 */ 0146 #define _Context_Initialize_fp( _fp_area ) \ 0147 _CPU_Context_Initialize_fp( _fp_area ) 0148 0149 /** 0150 * @brief Restore floating point context area. 0151 * 0152 * This routine restores the floating point context contained 0153 * in the @a _fp area. It is assumed that the current 0154 * floating point context has been saved by a previous invocation 0155 * of @a _Context_Save_fp. 0156 * 0157 * @param[in] _fp points to the floating point context area to restore. 0158 */ 0159 #define _Context_Restore_fp( _fp ) \ 0160 _CPU_Context_restore_fp( _fp ) 0161 0162 /** 0163 * @brief Save floating point context area. 0164 * 0165 * This routine saves the current floating point context 0166 * in the @a _fp area. 0167 * 0168 * @param[in] _fp points to the floating point context area to restore. 0169 */ 0170 #define _Context_Save_fp( _fp ) \ 0171 _CPU_Context_save_fp( _fp ) 0172 0173 #if defined(_CPU_Context_Destroy) 0174 #define _Context_Destroy( _the_thread, _the_context ) \ 0175 _CPU_Context_Destroy( _the_thread, _the_context ) 0176 #else 0177 #define _Context_Destroy( _the_thread, _the_context ) 0178 #endif 0179 0180 #ifdef __cplusplus 0181 } 0182 #endif 0183 0184 /** @} */ 0185 0186 #endif 0187 /* end of include file */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |