source: rtems/cpukit/score/include/rtems/score/userext.h @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 8.8 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreUserExt
5 *
6 * @brief User Extension Handler API.
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2009.
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.com/license/LICENSE.
16 */
17
18#ifndef _RTEMS_SCORE_USEREXT_H
19#define _RTEMS_SCORE_USEREXT_H
20
21#include <rtems/score/interr.h>
22#include <rtems/score/chain.h>
23#include <rtems/score/thread.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29typedef void User_extensions_routine RTEMS_COMPILER_DEPRECATED_ATTRIBUTE;
30
31/**
32 * @defgroup ScoreUserExt User Extension Handler
33 *
34 * @ingroup Score
35 *
36 * @brief The User Extension Handler provides invocation of application
37 * dependent routines at critical points in the life of each thread and the
38 * system as a whole.
39 *
40 * @{
41 */
42
43/**
44 * @brief Task create extension.
45 *
46 * It corresponds to _Thread_Initialize() (used by the rtems_task_create()
47 * directive).  The first parameter points to the currently executing thread
48 * which created the new thread.  The second parameter points to the created
49 * thread.
50 *
51 * It is invoked after the new thread has been completely initialized, but
52 * before it is placed on a ready chain.
53 *
54 * Thread dispatching may be disabled.  This depends on the context of the
55 * _Thread_Initialize() call.  Thread dispatch is disabled during the creation
56 * of the idle thread and the initialization threads.  It can be considered as
57 * an invalid API usage, if the application calls _Thread_Initialize() with
58 * disabled thread dispatching.  Disabled thread dispatching is different from
59 * disabled preemption.
60 *
61 * It can be assumed that the executing thread locked the allocator mutex.
62 * The only exception is the creation of the idle thread.  In this case the
63 * allocator mutex is not locked.  Since the allocator mutex is non-recursive,
64 * it is prohibited to call the normal memory allocation routines.  It is
65 * possible to use internal rountines like _Workspace_Allocate() or
66 * _Heap_Allocate() for heaps which are protected by the allocator mutex.
67 *
68 * @retval true The thread create extension was successful.
69 * @retval false A thread create user extension will frequently attempt to
70 * allocate resources.  If this allocation fails, then the extension should
71 * return @a false and the entire thread create operation will fail.
72 */
73typedef bool ( *User_extensions_thread_create_extension )(
74  Thread_Control *,
75  Thread_Control *
76);
77
78/**
79 * @brief Task delete extension.
80 *
81 * It corresponds to _Thread_Close() (used by the rtems_task_delete()
82 * directive).  The first parameter points to the currently executing thread
83 * which deleted the thread.  The second parameter points to the deleted
84 * thread.
85 *
86 * It is invoked before all resources of the thread are deleted.
87 *
88 * Thread dispatching is enabled.  The executing thread locked the allocator
89 * mutex.
90 */
91typedef void( *User_extensions_thread_delete_extension )(
92  Thread_Control *,
93  Thread_Control *
94);
95
96/**
97 * @brief Task start extension.
98 *
99 * It corresponds to _Thread_Start() (used by the rtems_task_start()
100 * directive).  The first parameter points to the currently executing thread
101 * which started the thread.  The second parameter points to the started
102 * thread.
103 *
104 * It is invoked after the environment of the thread has been loaded and the
105 * thread has been made ready.
106 *
107 * Thread dispatching is disabled.  The executing thread is not the holder of
108 * the allocator mutex.
109 */
110typedef void( *User_extensions_thread_start_extension )(
111  Thread_Control *,
112  Thread_Control *
113);
114
115/**
116 * @brief Task restart extension.
117 *
118 * It corresponds to _Thread_Restart() (used by the rtems_task_restart()
119 * directive).  The first parameter points to the currently executing thread
120 * which restarted the thread.  The second parameter points to the restarted
121 * thread.
122 *
123 * It is invoked after the environment of the thread has been loaded and the
124 * thread has been made ready.
125 *
126 * Thread dispatching is disabled.  The executing thread is not the holder of
127 * the allocator mutex.
128 */
129typedef void( *User_extensions_thread_restart_extension )(
130  Thread_Control *,
131  Thread_Control *
132);
133
134/**
135 * @brief Task switch extension.
136 *
137 * It corresponds to _Thread_Dispatch().  The first parameter points to the
138 * currently executing thread.  The second parameter points to the heir thread.
139 *
140 * It is invoked before the context switch from the executing to the heir
141 * thread.
142 *
143 * Thread dispatching is disabled.  The state of the allocator mutex is
144 * arbitrary.
145 *
146 * The context switches initiated through _Thread_Start_multitasking() and
147 * _Thread_Stop_multitasking() are not covered by this extension.  The
148 * executing thread may run with a minimal setup, for example with a freed task
149 * stack.
150 */
151typedef void( *User_extensions_thread_switch_extension )(
152  Thread_Control *,
153  Thread_Control *
154);
155
156/**
157 * @brief Task begin extension.
158 *
159 * It corresponds to _Thread_Handler().  The first parameter points to the
160 * currently executing thread which begins now execution.
161 *
162 * Thread dispatching is disabled.  The executing thread is not the holder of
163 * the allocator mutex.
164 */
165typedef void( *User_extensions_thread_begin_extension )(
166  Thread_Control *
167);
168
169/**
170 * @brief Task exitted extension.
171 *
172 * It corresponds to _Thread_Handler().  The first parameter points to the
173 * currently executing thread which exitted before.
174 *
175 * Thread dispatching is disabled.  The state of the allocator mutex is
176 * arbitrary.
177 */
178typedef void( *User_extensions_thread_exitted_extension )(
179  Thread_Control *
180);
181
182/**
183 * @brief Fatal error extension.
184 *
185 * It corresponds to _Internal_error_Occurred() (used by the
186 * rtems_fatal_error_occurred() directive).  The first parameter contains the
187 * error source.  The second parameter indicates if it was an internal error.
188 * The third parameter contains the error code.
189 *
190 * This extension should not call any RTEMS directives.
191 */
192typedef void( *User_extensions_fatal_extension )(
193  Internal_errors_Source,
194  bool,
195  Internal_errors_t
196);
197
198/**
199 * @brief User extension table.
200 */
201typedef struct {
202  User_extensions_thread_create_extension  thread_create;
203  User_extensions_thread_start_extension   thread_start;
204  User_extensions_thread_restart_extension thread_restart;
205  User_extensions_thread_delete_extension  thread_delete;
206  User_extensions_thread_switch_extension  thread_switch;
207  User_extensions_thread_begin_extension   thread_begin;
208  User_extensions_thread_exitted_extension thread_exitted;
209  User_extensions_fatal_extension          fatal;
210}   User_extensions_Table;
211
212/**
213 * @brief Manages the switch callouts.
214 *
215 * They are managed separately from other extensions for performance reasons.
216 */
217typedef struct {
218  Chain_Node                              Node;
219  User_extensions_thread_switch_extension thread_switch;
220}   User_extensions_Switch_control;
221
222/**
223 * @brief Manages each user extension set.
224 *
225 * The switch control is part of the extensions control even if not used due to
226 * the extension not having a switch handler.
227 */
228typedef struct {
229  Chain_Node                     Node;
230  User_extensions_Switch_control Switch;
231  User_extensions_Table          Callouts;
232}   User_extensions_Control;
233
234/**
235 * @brief List of active extensions.
236 */
237SCORE_EXTERN Chain_Control _User_extensions_List;
238
239/**
240 * @brief List of active task switch extensions.
241 */
242SCORE_EXTERN Chain_Control _User_extensions_Switches_list;
243
244/**
245 * @name Extension Maintainance
246 *
247 * @{
248 */
249
250void _User_extensions_Handler_initialization( void );
251
252void _User_extensions_Add_set(
253  User_extensions_Control *extension
254);
255
256RTEMS_INLINE_ROUTINE void _User_extensions_Add_API_set(
257  User_extensions_Control *extension
258)
259{
260  _User_extensions_Add_set( extension );
261}
262
263RTEMS_INLINE_ROUTINE void _User_extensions_Add_set_with_table(
264  User_extensions_Control     *extension,
265  const User_extensions_Table *extension_table
266)
267{
268  extension->Callouts = *extension_table;
269
270  _User_extensions_Add_set( extension );
271}
272
273void _User_extensions_Remove_set(
274  User_extensions_Control *extension
275);
276
277/** @} */
278
279/**
280 * @name Extension Callout Dispatcher
281 *
282 * @{
283 */
284
285bool _User_extensions_Thread_create(
286  Thread_Control *created
287);
288
289void _User_extensions_Thread_delete(
290  Thread_Control *deleted
291);
292
293void _User_extensions_Thread_start(
294  Thread_Control *started
295);
296
297void _User_extensions_Thread_restart(
298  Thread_Control *restarted
299);
300
301void _User_extensions_Thread_begin(
302  Thread_Control *executing
303);
304
305void _User_extensions_Thread_switch(
306  Thread_Control *executing,
307  Thread_Control *heir
308);
309
310void _User_extensions_Thread_exitted(
311  Thread_Control *executing
312);
313
314void _User_extensions_Fatal(
315  Internal_errors_Source source,
316  bool                   is_internal,
317  Internal_errors_t      error
318);
319
320/** @} */
321
322/** @} */
323
324#ifdef __cplusplus
325}
326#endif
327
328#endif
329/* end of include file */
Note: See TracBrowser for help on using the repository browser.