source: rtems/cpukit/score/include/rtems/score/userext.h @ c42d1a4

4.104.115
Last change on this file since c42d1a4 was c42d1a4, checked in by Joel Sherrill <joel.sherrill@…>, on 09/25/09 at 17:51:46

2009-09-25 Sebastian Huber <Sebastian.Huber@…>

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