source: rtems/cpukit/sapi/include/rtems/extension.h @ c52568d

5
Last change on this file since c52568d was c52568d, checked in by Sebastian Huber <sebastian.huber@…>, on 10/16/15 at 06:17:52

basdefs.h: Add and use RTEMS_DEPRECATED

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