source: rtems/cpukit/score/include/rtems/score/context.h @ b5f1b24

5
Last change on this file since b5f1b24 was f455cdea, checked in by Sebastian Huber <sebastian.huber@…>, on 06/02/15 at 22:20:54

rtems: Change CONTEXT_FP_SIZE define

Define CONTEXT_FP_SIZE to zero in case hardware and software floating
point support is disabled. The problem is that empty structures have a
different size in C and C++. In C++ they have a non-zero size leading
to an overestimate of the workspace size.

  • Property mode set to 100644
File size: 4.9 KB
Line 
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
35extern "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 Return starting address of floating point context.
115 *
116 *  This function returns the starting address of the floating
117 *  point context save area.  It is assumed that the are reserved
118 *  for the floating point save area is large enough.
119 *
120 *  @param[in] _base is lowest physical address of the floating point
121 *         context save area.
122 *  @param[in] _offset is the offset into the floating point area
123 *
124 *  @retval the initial FP context pointer
125 */
126#define _Context_Fp_start( _base, _offset ) \
127   _CPU_Context_Fp_start( (_base), (_offset) )
128
129/**
130 *  @brief Initialize floating point context area.
131 *
132 *  This routine initializes the floating point context save
133 *  area to contain an initial known state.
134 *
135 *  @param[in] _fp_area is the base address of the floating point
136 *         context save area to initialize.
137 */
138#define _Context_Initialize_fp( _fp_area ) \
139   _CPU_Context_Initialize_fp( _fp_area )
140
141/**
142 *  @brief Restore floating point context area.
143 *
144 *  This routine restores the floating point context contained
145 *  in the @a _fp area.  It is assumed that the current
146 *  floating point context has been saved by a previous invocation
147 *  of @a _Context_Save_fp.
148 *
149 *  @param[in] _fp points to the floating point context area to restore.
150 */
151#define _Context_Restore_fp( _fp ) \
152   _CPU_Context_restore_fp( _fp )
153
154/**
155 *  @brief Save floating point context area.
156 *
157 *  This routine saves the current floating point context
158 *  in the @a _fp area.
159 *
160 *  @param[in] _fp points to the floating point context area to restore.
161 */
162#define _Context_Save_fp( _fp ) \
163   _CPU_Context_save_fp( _fp )
164
165#ifdef __cplusplus
166}
167#endif
168
169/**@}*/
170
171#endif
172/* end of include file */
Note: See TracBrowser for help on using the repository browser.