source: rtems/cpukit/sapi/include/rtems/extension.h @ 599d71f

5
Last change on this file since 599d71f was d5154d0f, checked in by Aun-Ali Zaidi <admin@…>, on 12/23/15 at 20:44:02

api: Remove deprecated Notepads

Notepads where a feature of RTEMS' tasks that simply functioned in
the same way as POSIX keys or threaded local storage (TLS). They were
introduced well before per task variables, which are also deprecated,
and were barely used in favor of their POSIX alternatives.

In addition to their scarce usage, Notepads took up unnecessary memory.
For each task:

  • 16 32-bit integers were allocated.
  • A total of 64 bytes per task per thread.

This is especially critical in low memory and safety-critical applications.

They are also defined as uint32_t, and therefore are not guaranteed to
hold a pointer.

Lastly, they are not portable solutions for SMP and uniprocessor systems,
like POSIX keys and TLS.

updates #2493.

  • Property mode set to 100644
File size: 10.1 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.
92 *
93 * The TCB extension is an array of pointers in the TCB. The index into the
94 * table can be obtained from the extension identifier returned when the
95 * extension is created:
96 *
97 * @code
98 * rtems_tcb *task = some_task;
99 * size_t index = rtems_object_id_get_index(extension_id);
100 * void *extension_data = task->extensions [index];
101 * @endcode
102 *
103 * The number of pointers in the area is the same as the number of user
104 * extension sets configured. This allows an application to augment the TCB
105 * with user-defined information. For example, an application could implement
106 * task profiling by storing timing statistics in the TCB's extended memory
107 * area. When a task context switch is being executed, the task switch
108 * extension could read a real-time clock to calculate how long the task being
109 * swapped out has run as well as timestamp the starting time for the task
110 * being swapped in.
111 *
112 * If used, the extended memory area for the TCB should be allocated and the
113 * TCB extension pointer should be set at the time the task is created or
114 * started by either the task create or task start extension. The application
115 * is responsible for managing this extended memory area for the TCBs. The
116 * memory may be reinitialized by the task restart extension and should be
117 * deallocated by the task delete extension when the task is deleted. Since the
118 * TCB extension buffers would most likely be of a fixed size, the RTEMS
119 * partition manager could be used to manage the application's extended memory
120 * area. The application could create a partition of fixed size TCB extension
121 * buffers and use the partition manager's allocation and deallocation
122 * directives to obtain and release the extension buffers.
123 *
124 * @section ClassicUserExtensionsOrder Order of Invokation
125 *
126 * When one of the critical system events occur, the user extensions are
127 * invoked in either @a forward or @a reverse order. Forward order indicates
128 * that the static extension set is invoked followed by the dynamic extension
129 * sets in the order in which they were created. Reverse order means that the
130 * dynamic extension sets are invoked in the opposite of the order in which
131 * they were created followed by the static extension set. By invoking the
132 * extension sets in this order, extensions can be built upon one another. At
133 * the following system events, the extensions are invoked in forward order:
134 *
135 * - Task creation
136 * - Task start
137 * - Task restart
138 * - Task context switch
139 * - Post task context switch
140 * - Task begins to execute
141 *
142 * At the following system events, the extensions are invoked in reverse order:
143 *
144 * - Task exit
145 * - Task deletion
146 * - Fatal error detection
147 *
148 * At these system events, the extensions are invoked in reverse order to
149 * insure that if an extension set is built upon another, the more complicated
150 * extension is invoked before the extension set it is built upon. For example,
151 * by invoking the static extension set last it is known that the "system"
152 * fatal error extension will be the last fatal error extension executed.
153 * Another example is use of the task delete extension by the Standard C
154 * Library. Extension sets which are installed after the Standard C Library
155 * will operate correctly even if they utilize the C Library because the C
156 * Library's task delete extension is invoked after that of the other
157 * extensions.
158 */
159/**@{**/
160
161typedef User_extensions_thread_create_extension   rtems_task_create_extension;
162typedef User_extensions_thread_delete_extension   rtems_task_delete_extension;
163typedef User_extensions_thread_start_extension    rtems_task_start_extension;
164typedef User_extensions_thread_restart_extension  rtems_task_restart_extension;
165typedef User_extensions_thread_switch_extension   rtems_task_switch_extension;
166typedef User_extensions_thread_begin_extension    rtems_task_begin_extension;
167typedef User_extensions_thread_exitted_extension  rtems_task_exitted_extension;
168typedef User_extensions_fatal_extension           rtems_fatal_extension;
169
170typedef User_extensions_Table                     rtems_extensions_table;
171
172typedef Internal_errors_Source rtems_fatal_source;
173
174typedef Internal_errors_t rtems_fatal_code;
175
176/**
177 * @brief Creates an extension set object.
178 *
179 * This directive creates a extension set object from the extension table
180 * @a extension_table.  The assigned extension set identifier is returned in
181 * @a id.  The identifier is used to access this extension set in other
182 * extension set related directives.  The name @a name will be assigned to the
183 * extension set object.
184 *
185 * Newly created extension sets are immediately installed and are invoked upon
186 * the next system event supporting an extension.
187 *
188 * This directive will not cause the calling task to be preempted.
189 *
190 * @retval RTEMS_SUCCESSFUL Extension set created successfully.
191 * @retval RTEMS_INVALID_ADDRESS Identifier pointer is @c NULL.
192 * @retval RTEMS_INVALID_NAME Invalid extension set name.
193 * @retval RTEMS_TOO_MANY Too many extension sets created.
194 */
195rtems_status_code rtems_extension_create(
196  rtems_name                    name,
197  const rtems_extensions_table *extension_table,
198  rtems_id                     *id
199);
200
201/**
202 * @brief Identifies an extension set object by a name.
203 *
204 * This directive obtains an extension set identifier in @a id associated with
205 * the extension set name @a name. If the extension set name is not unique,
206 * then the extension set identifier will match one of the extension sets with
207 * that name.  However, this extension set identifier is not guaranteed to
208 * correspond to the desired extension set. The extension set identifier is
209 * used to access this extension set in other extension set related directives.
210 *
211 * This directive will not cause the calling task to be preempted.
212 *
213 * @retval RTEMS_SUCCESSFUL Extension set identified successfully.
214 * @retval RTEMS_INVALID_ADDRESS Identifier pointer is @c NULL.
215 * @retval RTEMS_INVALID_NAME Extension set name not found or invalid name.
216 */
217rtems_status_code rtems_extension_ident(
218  rtems_name  name,
219  rtems_id   *id
220);
221
222/**
223 * @brief Deletes an extension set object specified by the identifier @a id.
224 *
225 * Any subsequent references to the extension's name and identifier are
226 * invalid.
227 *
228 * This directive will not cause the calling task to be preempted.
229 *
230 * @retval RTEMS_SUCCESSFUL Extension set deleted successfully.
231 * @retval RTEMS_INVALID_ID Invalid extension set identifier.
232 */
233rtems_status_code rtems_extension_delete(
234  rtems_id id
235);
236
237/** @} */
238
239#ifdef __cplusplus
240}
241#endif
242
243#endif
244/* end of include file */
Note: See TracBrowser for help on using the repository browser.