source: rtems/cpukit/include/rtems/extension.h @ 5fc855d

5
Last change on this file since 5fc855d was 5fc855d, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 8, 2018 at 12:17:37 PM

rtems: Move internal structures to extensiondata.h

Update #3598.

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