source: rtems/cpukit/sapi/include/rtems/extension.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: 10.4 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicUserExtensions
5 *
6 * @brief User Extensions 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_EXTENSION_H
21#define _RTEMS_EXTENSION_H
22
23#ifndef SAPI_EXT_EXTERN
24#define SAPI_EXT_EXTERN extern
25#endif
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#include <rtems/score/object.h>
32#include <rtems/score/userext.h>
33#include <rtems/rtems/status.h>
34#include <rtems/rtems/types.h>
35
36SAPI_EXT_EXTERN Objects_Information  _Extension_Information;
37
38typedef struct {
39  Objects_Control          Object;
40  User_extensions_Control  Extension;
41}   Extension_Control;
42
43void _Extension_Manager_initialization(void);
44
45typedef User_extensions_routine
46  rtems_extension RTEMS_COMPILER_DEPRECATED_ATTRIBUTE;
47
48/**
49 * @defgroup ClassicUserExtensions User Extensions
50 *
51 * @ingroup ClassicRTEMS
52 *
53 * @brief The User Extensions Manager allows the application developer to
54 * augment the executive by allowing them to supply extension routines which
55 * are invoked at critical system events.
56 *
57 * @section ClassicUserExtensionsSets Extension Sets
58 *
59 * An @ref User_extensions_Table "extension set" is defined as a set of
60 * routines which are invoked at each of the critical system events at which
61 * user extension routines are invoked.  Together a set of these routines
62 * typically perform a specific functionality such as performance monitoring or
63 * debugger support.
64 *
65 * RTEMS allows the user to have multiple extension sets active at the same
66 * time. First, a single static extension set may be defined as the
67 * application's User Extension Table which is included as part of the
68 * Configuration Table. This extension set is active for the entire life of the
69 * system and may not be deleted. This extension set is especially important
70 * because it is the only way the application can provided a fatal error
71 * extension which is invoked if RTEMS fails during the
72 * rtems_initialize_data_structures() directive. The static extension set is
73 * optional and may be configured as @c NULL if no static extension set is
74 * required.
75 *
76 * Second, the user can install dynamic extensions using the
77 * rtems_extension_create() directive. These extensions are RTEMS objects in
78 * that they have a name, an ID, and can be dynamically created and deleted. In
79 * contrast to the static extension set, these extensions can only be created
80 * and installed after the rtems_initialize_data_structures() directive
81 * successfully completes execution. Dynamic extensions are useful for
82 * encapsulating the functionality of an extension set. For example, the
83 * application could use extensions to manage a special coprocessor, do
84 * performance monitoring, and to do stack bounds checking. Each of these
85 * extension sets could be written and installed independently of the others.
86 *
87 * All user extensions are optional and RTEMS places no naming restrictions on
88 * the user. The user extension entry points are copied into an internal RTEMS
89 * structure. This means the user does not need to keep the table after
90 * creating it, and changing the handler entry points dynamically in a table
91 * once created has no effect. Creating a table local to a function can save
92 * space in space limited applications.
93 *
94 * Extension switches do not effect the context switch overhead if no switch
95 * handler is installed.
96 *
97 * @section ClassicUserExtensionsTCB Task Control Block Area
98 *
99 * RTEMS provides for a pointer to a user-defined data area for each extension
100 * set to be linked to each task's control block (TCB). This area is only
101 * available for the dynamic extensions. This set of pointers is an extension
102 * of the TCB and can be used to store additional data required by the user's
103 * extension functions. It is also possible for a user extension to utilize the
104 * notepad locations associated with each task although this may conflict with
105 * application usage of those particular notepads.
106 *
107 * The TCB extension is an array of pointers in the TCB. The index into the
108 * table can be obtained from the extension identifier returned when the
109 * extension is created:
110 *
111 * @code
112 * rtems_tcb *task = some_task;
113 * size_t index = rtems_object_id_get_index(extension_id);
114 * void *extension_data = task->extensions [index];
115 * @endcode
116 *
117 * The number of pointers in the area is the same as the number of user
118 * extension sets configured. This allows an application to augment the TCB
119 * with user-defined information. For example, an application could implement
120 * task profiling by storing timing statistics in the TCB's extended memory
121 * area. When a task context switch is being executed, the task switch
122 * extension could read a real-time clock to calculate how long the task being
123 * swapped out has run as well as timestamp the starting time for the task
124 * being swapped in.
125 *
126 * If used, the extended memory area for the TCB should be allocated and the
127 * TCB extension pointer should be set at the time the task is created or
128 * started by either the task create or task start extension. The application
129 * is responsible for managing this extended memory area for the TCBs. The
130 * memory may be reinitialized by the task restart extension and should be
131 * deallocated by the task delete extension when the task is deleted. Since the
132 * TCB extension buffers would most likely be of a fixed size, the RTEMS
133 * partition manager could be used to manage the application's extended memory
134 * area. The application could create a partition of fixed size TCB extension
135 * buffers and use the partition manager's allocation and deallocation
136 * directives to obtain and release the extension buffers.
137 *
138 * @section ClassicUserExtensionsOrder Order of Invokation
139 *
140 * When one of the critical system events occur, the user extensions are
141 * invoked in either @a forward or @a reverse order. Forward order indicates
142 * that the static extension set is invoked followed by the dynamic extension
143 * sets in the order in which they were created. Reverse order means that the
144 * dynamic extension sets are invoked in the opposite of the order in which
145 * they were created followed by the static extension set. By invoking the
146 * extension sets in this order, extensions can be built upon one another. At
147 * the following system events, the extensions are invoked in forward order:
148 *
149 * - Task creation
150 * - Task initiation
151 * - Task reinitiation
152 * - Task deletion
153 * - Task context switch
154 * - Post task context switch
155 * - Task begins to execute
156 *
157 * At the following system events, the extensions are invoked in reverse order:
158 *
159 * - Task deletion
160 * - Fatal error detection
161 *
162 * At these system events, the extensions are invoked in reverse order to
163 * insure that if an extension set is built upon another, the more complicated
164 * extension is invoked before the extension set it is built upon. For example,
165 * by invoking the static extension set last it is known that the "system"
166 * fatal error extension will be the last fatal error extension executed.
167 * Another example is use of the task delete extension by the Standard C
168 * Library. Extension sets which are installed after the Standard C Library
169 * will operate correctly even if they utilize the C Library because the C
170 * Library's task delete extension is invoked after that of the other
171 * extensions.
172 *
173 * @{
174 */
175
176typedef User_extensions_thread_create_extension   rtems_task_create_extension;
177typedef User_extensions_thread_delete_extension   rtems_task_delete_extension;
178typedef User_extensions_thread_start_extension    rtems_task_start_extension;
179typedef User_extensions_thread_restart_extension  rtems_task_restart_extension;
180typedef User_extensions_thread_switch_extension   rtems_task_switch_extension;
181typedef User_extensions_thread_begin_extension    rtems_task_begin_extension;
182typedef User_extensions_thread_exitted_extension  rtems_task_exitted_extension;
183typedef User_extensions_fatal_extension           rtems_fatal_extension;
184
185typedef User_extensions_Table                     rtems_extensions_table;
186
187/**
188 * @brief Creates an extension set object.
189 *
190 * This directive creates a extension set object from the extension table
191 * @a extension_table.  The assigned extension set identifier is returned in
192 * @a id.  The identifier is used to access this extension set in other
193 * extension set related directives.  The name @a name will be assigned to the
194 * extension set object.
195 *
196 * Newly created extension sets are immediately installed and are invoked upon
197 * the next system event supporting an extension.
198 *
199 * This directive will not cause the calling task to be preempted.
200 *
201 * @retval RTEMS_SUCCESSFUL Extension set created successfully.
202 * @retval RTEMS_INVALID_ADDRESS Identifier pointer is @c NULL.
203 * @retval RTEMS_INVALID_NAME Invalid extension set name.
204 * @retval RTEMS_TOO_MANY Too many extension sets created.
205 */
206rtems_status_code rtems_extension_create(
207  rtems_name              name,
208  rtems_extensions_table *extension_table,
209  rtems_id               *id
210);
211
212/**
213 * @brief Identifies an extension set object by a name.
214 *
215 * This directive obtains an extension set identifier in @a id associated with
216 * the extension set name @a name. If the extension set name is not unique,
217 * then the extension set identifier will match one of the extension sets with
218 * that name.  However, this extension set identifier is not guaranteed to
219 * correspond to the desired extension set. The extension set identifier is
220 * used to access this extension set in other extension set related directives.
221 *
222 * This directive will not cause the calling task to be preempted.
223 *
224 * @retval RTEMS_SUCCESSFUL Extension set identified successfully.
225 * @retval RTEMS_INVALID_ADDRESS Identifier pointer is @c NULL.
226 * @retval RTEMS_INVALID_NAME Extension set name not found or invalid name.
227 */
228rtems_status_code rtems_extension_ident(
229  rtems_name  name,
230  rtems_id   *id
231);
232
233/**
234 * @brief Deletes an extension set object specified by the identifier @a id.
235 *
236 * Any subsequent references to the extension's name and identifier are
237 * invalid.
238 *
239 * This directive will not cause the calling task to be preempted.
240 *
241 * @retval RTEMS_SUCCESSFUL Extension set deleted successfully.
242 * @retval RTEMS_INVALID_ID Invalid extension set identifier.
243 */
244rtems_status_code rtems_extension_delete(
245  rtems_id id
246);
247
248/** @} */
249
250#ifndef __RTEMS_APPLICATION__
251#include <rtems/extension.inl>
252#endif
253
254#ifdef __cplusplus
255}
256#endif
257
258#endif
259/* end of include file */
Note: See TracBrowser for help on using the repository browser.