source: rtems/cpukit/score/include/rtems/score/context.h @ 7e119990

4.115
Last change on this file since 7e119990 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 4.8 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#define CONTEXT_FP_SIZE CPU_CONTEXT_FP_SIZE
47
48/**
49 *  @brief Initialize context area.
50 *
51 *  This routine initializes @a _the_context such that the stack
52 *  pointer, interrupt level, and entry point are correct for the
53 *  thread's initial state.
54 *
55 *  @param[in] _the_context will be initialized
56 *  @param[in] _stack is the lowest physical address of the thread's
57 *         context
58 *  @param[in] _size is the size in octets of the thread's context
59 *  @param[in] _isr is the ISR enable level for this thread
60 *  @param[in] _entry is this thread's entry point
61 *  @param[in] _is_fp is set to true if this thread has floating point
62 *         enabled
63 *  @param[in] _tls_area The thread-local storage (TLS) area begin.
64 */
65#define _Context_Initialize( _the_context, _stack, _size, _isr, _entry, \
66  _is_fp, _tls_area ) \
67    _CPU_Context_Initialize( _the_context, _stack, _size, _isr, _entry, \
68      _is_fp, _tls_area )
69
70/**
71 *  This macro is invoked from _Thread_Handler to do whatever CPU
72 *  specific magic is required that must be done in the context of
73 *  the thread when it starts.
74 *
75 *  If the CPU architecture does not require any magic, then this
76 *  macro is empty.
77 */
78
79#if defined(_CPU_Context_Initialization_at_thread_begin)
80  #define _Context_Initialization_at_thread_begin() \
81     _CPU_Context_Initialization_at_thread_begin()
82#else
83  #define _Context_Initialization_at_thread_begin()
84#endif
85
86/**
87 *  @brief Perform context switch.
88 *
89 *  This routine saves the current context into the @a _executing
90 *  context record and restores the context specified by @a _heir.
91 *
92 *  @param[in] _executing is the currently executing thread's context
93 *  @param[in] _heir is the context of the thread to be switched to
94 */
95#define _Context_Switch( _executing, _heir ) \
96   _CPU_Context_switch( _executing, _heir )
97
98/**
99 *  @brief Restart currently executing thread.
100 *
101 *  This routine restarts the calling thread by restoring its initial
102 *  stack pointer and returning to the thread's entry point.
103 *
104 *  @param[in] _the_context is the context of the thread to restart
105 */
106#define _Context_Restart_self( _the_context ) \
107   _CPU_Context_Restart_self( _the_context )
108
109/**
110 *  @brief Return starting address of floating point context.
111 *
112 *  This function returns the starting address of the floating
113 *  point context save area.  It is assumed that the are reserved
114 *  for the floating point save area is large enough.
115 *
116 *  @param[in] _base is lowest physical address of the floating point
117 *         context save area.
118 *  @param[in] _offset is the offset into the floating point area
119 *
120 *  @retval the initial FP context pointer
121 */
122#define _Context_Fp_start( _base, _offset ) \
123   _CPU_Context_Fp_start( (_base), (_offset) )
124
125/**
126 *  @brief Initialize floating point context area.
127 *
128 *  This routine initializes the floating point context save
129 *  area to contain an initial known state.
130 *
131 *  @param[in] _fp_area is the base address of the floating point
132 *         context save area to initialize.
133 */
134#define _Context_Initialize_fp( _fp_area ) \
135   _CPU_Context_Initialize_fp( _fp_area )
136
137/**
138 *  @brief Restore floating point context area.
139 *
140 *  This routine restores the floating point context contained
141 *  in the @a _fp area.  It is assumed that the current
142 *  floating point context has been saved by a previous invocation
143 *  of @a _Context_Save_fp.
144 *
145 *  @param[in] _fp points to the floating point context area to restore.
146 */
147#define _Context_Restore_fp( _fp ) \
148   _CPU_Context_restore_fp( _fp )
149
150/**
151 *  @brief Save floating point context area.
152 *
153 *  This routine saves the current floating point context
154 *  in the @a _fp area.
155 *
156 *  @param[in] _fp points to the floating point context area to restore.
157 */
158#define _Context_Save_fp( _fp ) \
159   _CPU_Context_save_fp( _fp )
160
161#ifdef __cplusplus
162}
163#endif
164
165/**@}*/
166
167#endif
168/* end of include file */
Note: See TracBrowser for help on using the repository browser.