RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
userextimpl.h
Go to the documentation of this file.
1
9/*
10 * COPYRIGHT (c) 1989-2009.
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_SCORE_USEREXTIMPL_H
19#define _RTEMS_SCORE_USEREXTIMPL_H
20
23#include <rtems/score/isrlock.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/percpu.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
47 Chain_Iterator Iterator;
48 struct User_extensions_Iterator *previous;
50
51typedef struct {
56
61
66 ISR_LOCK_MEMBER( Lock )
68
73
78
89
97);
98
105 User_extensions_Control *extension
106)
107{
108 _User_extensions_Add_set( extension );
109}
110
118 User_extensions_Control *extension,
119 const User_extensions_Table *extension_table
120)
121{
122 extension->Callouts = *extension_table;
123
124 _User_extensions_Add_set( extension );
125}
126
133 User_extensions_Control *extension
134);
135
144 Thread_Control *executing,
145 void *arg,
146 const User_extensions_Table *callouts
147);
148
149typedef struct {
150 Thread_Control *created;
151 bool ok;
153
162 Thread_Control *executing,
163 void *arg,
164 const User_extensions_Table *callouts
165);
166
175 Thread_Control *executing,
176 void *arg,
177 const User_extensions_Table *callouts
178);
179
188 Thread_Control *executing,
189 void *arg,
190 const User_extensions_Table *callouts
191);
192
201 Thread_Control *executing,
202 void *arg,
203 const User_extensions_Table *callouts
204);
205
214 Thread_Control *executing,
215 void *arg,
216 const User_extensions_Table *callouts
217);
218
227 Thread_Control *executing,
228 void *arg,
229 const User_extensions_Table *callouts
230);
231
232typedef struct {
234 Internal_errors_t error;
236
245 Thread_Control *executing,
246 void *arg,
247 const User_extensions_Table *callouts
248);
249
258 Thread_Control *executing,
259 void *arg,
260 const User_extensions_Table *callouts
261);
262
271 void *arg,
274);
275
291static inline bool _User_extensions_Thread_create( Thread_Control *created )
292{
293 User_extensions_Thread_create_context ctx = { created, true };
294
296 &ctx,
299 );
300
301 return ctx.ok;
302}
303
309static inline void _User_extensions_Thread_delete( Thread_Control *deleted )
310{
312 deleted,
315 );
316}
317
323static inline void _User_extensions_Thread_start( Thread_Control *started )
324{
326 started,
329 );
330}
331
337static inline void _User_extensions_Thread_restart( Thread_Control *restarted )
338{
340 restarted,
343 );
344}
345
351static inline void _User_extensions_Thread_begin( Thread_Control *executing )
352{
354 executing,
357 );
358}
359
366static inline void _User_extensions_Thread_switch(
367 Thread_Control *executing,
368 Thread_Control *heir
369)
370{
371 const Chain_Control *chain;
372 const Chain_Node *tail;
373 const Chain_Node *node;
374
376 tail = _Chain_Immutable_tail( chain );
377 node = _Chain_Immutable_first( chain );
378
379 if ( node != tail ) {
380#if defined(RTEMS_SMP)
381 ISR_lock_Context lock_context;
382 Per_CPU_Control *cpu_self;
383
384 cpu_self = _Per_CPU_Get();
385
386 _ISR_lock_ISR_disable( &lock_context );
387 _Per_CPU_Acquire( cpu_self, &lock_context );
388
389 executing = cpu_self->ancestor;
390 cpu_self->ancestor = heir;
391 node = _Chain_Immutable_first( chain );
392
393 /*
394 * An executing thread equal to the heir thread may happen in two
395 * situations. Firstly, in case context switch extensions are created after
396 * system initialization. Secondly, during a thread self restart.
397 */
398 if ( executing != heir ) {
399#endif
400
401 while ( node != tail ) {
402 const User_extensions_Switch_control *extension;
403
404 extension = (const User_extensions_Switch_control *) node;
405 node = _Chain_Immutable_next( node );
406 (*extension->thread_switch)( executing, heir );
407 }
408
409#if defined(RTEMS_SMP)
410 }
411
412 _Per_CPU_Release( cpu_self, &lock_context );
413 _ISR_lock_ISR_enable( &lock_context );
414#endif
415 }
416}
417
423static inline void _User_extensions_Thread_exitted( Thread_Control *executing )
424{
426 executing,
429 );
430}
431
438static inline void _User_extensions_Fatal(
440 Internal_errors_t error
441)
442{
443 User_extensions_Fatal_context ctx = { source, error };
444
446 &ctx,
449 );
450}
451
457static inline void _User_extensions_Thread_terminate(
458 Thread_Control *executing
459)
460{
462 executing,
465 );
466}
467
473static inline void _User_extensions_Acquire( ISR_lock_Context *lock_context )
474{
477 lock_context
478 );
479}
480
486static inline void _User_extensions_Release( ISR_lock_Context *lock_context )
487{
490 lock_context
491 );
492}
493
500static inline void _User_extensions_Destroy_iterators(
501 Thread_Control *the_thread
502)
503{
504 ISR_lock_Context lock_context;
506
507 _User_extensions_Acquire( &lock_context );
508
509 iter = the_thread->last_user_extensions_iterator;
510
511 while ( iter != NULL ) {
512 _Chain_Iterator_destroy( &iter->Iterator );
513 iter = iter->previous;
514 }
515
516 _User_extensions_Release( &lock_context );
517}
518
523#ifdef __cplusplus
524}
525#endif
526
527#endif
528/* end of include file */
#define NULL
Requests a GPIO pin group configuration.
Definition: bestcomm_api.h:77
Chain Handler API.
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_first(const Chain_Control *the_chain)
Returns pointer to immutable chain's first node.
Definition: chainimpl.h:277
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_tail(const Chain_Control *the_chain)
Returns pointer to immutable chain tail.
Definition: chainimpl.h:243
RTEMS_INLINE_ROUTINE const Chain_Node * _Chain_Immutable_next(const Chain_Node *the_node)
Returns pointer to the immutable next node from this node.
Definition: chainimpl.h:343
Chain_Iterator_direction
The chain iterator direction.
Definition: chainimpl.h:884
RTEMS_INLINE_ROUTINE void _Chain_Iterator_destroy(Chain_Iterator *the_iterator)
Destroys the iterator.
Definition: chainimpl.h:1121
@ CHAIN_ITERATOR_BACKWARD
Iteration from tail to head.
Definition: chainimpl.h:893
@ CHAIN_ITERATOR_FORWARD
Iteration from head to tail.
Definition: chainimpl.h:888
#define ISR_LOCK_MEMBER(_designator)
Defines an ISR lock member.
Definition: isrlock.h:89
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:419
#define _ISR_lock_ISR_disable(_context)
Disables interrupts and saves the previous interrupt state in the ISR lock context.
Definition: isrlock.h:398
#define _ISR_lock_Release_and_ISR_enable(_lock, _context)
Releases an ISR lock.
Definition: isrlock.h:263
#define _ISR_lock_ISR_disable_and_acquire(_lock, _context)
Acquires an ISR lock.
Definition: isrlock.h:238
Internal_errors_Source
This type lists the possible sources from which an error can be reported.
Definition: interr.h:47
void _User_extensions_Thread_create_visitor(Thread_Control *executing, void *arg, const User_extensions_Table *callouts)
Creates a visitor.
Definition: userextiterate.c:40
void _User_extensions_Thread_delete_visitor(Thread_Control *executing, void *arg, const User_extensions_Table *callouts)
Deletes a visitor.
Definition: userextiterate.c:55
void _User_extensions_Thread_start_visitor(Thread_Control *executing, void *arg, const User_extensions_Table *callouts)
Starts a visitor.
Definition: userextiterate.c:68
void _User_extensions_Iterate(void *arg, User_extensions_Visitor visitor, Chain_Iterator_direction direction)
Iterates through all user extensions and calls the visitor for each.
Definition: userextiterate.c:149
void _User_extensions_Remove_set(User_extensions_Control *extension)
Removes a user extension.
Definition: userextremoveset.c:25
void _User_extensions_Thread_restart_visitor(Thread_Control *executing, void *arg, const User_extensions_Table *callouts)
Restarts a visitor.
Definition: userextiterate.c:81
struct User_extensions_Iterator User_extensions_Iterator
Chain iterator for dynamic user extensions.
void(* User_extensions_Visitor)(Thread_Control *executing, void *arg, const User_extensions_Table *callouts)
User extension visitor.
Definition: userextimpl.h:143
void _User_extensions_Thread_terminate_visitor(Thread_Control *executing, void *arg, const User_extensions_Table *callouts)
Terminates a visitor.
Definition: userextiterate.c:135
void _User_extensions_Fatal_visitor(Thread_Control *executing, void *arg, const User_extensions_Table *callouts)
Calls the fatal function of the thread callout for the visitor.
Definition: userextiterate.c:120
void _User_extensions_Thread_begin_visitor(Thread_Control *executing, void *arg, const User_extensions_Table *callouts)
Calls the begin function of the thread callout for the visitor.
Definition: userextiterate.c:94
void _User_extensions_Thread_exitted_visitor(Thread_Control *executing, void *arg, const User_extensions_Table *callouts)
Calls the exitted function of the thread callout for the visitor.
Definition: userextiterate.c:107
User_extensions_List _User_extensions_List
List of active extensions.
Definition: userextiterate.c:31
Chain_Control _User_extensions_Switches_list
List of active task switch extensions.
RTEMS_INLINE_ROUTINE void _User_extensions_Add_set_with_table(User_extensions_Control *extension, const User_extensions_Table *extension_table)
Adds a user extension with the given extension table as callouts.
Definition: userextimpl.h:117
void _User_extensions_Handler_initialization(void)
Initializes the user extensions handler.
Definition: userext.c:24
RTEMS_INLINE_ROUTINE void _User_extensions_Add_API_set(User_extensions_Control *extension)
Adds a user extension.
Definition: userextimpl.h:104
void _User_extensions_Add_set(User_extensions_Control *extension)
Adds a user extension.
Definition: userextaddset.c:45
ISR Locks.
Constants and Structures Related with the Thread Control Block.
A registry for chain iterators.
Definition: chainimpl.h:934
A chain iterator which is updated during node extraction if it is properly registered.
Definition: chainimpl.h:902
Definition: chain.h:68
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Per CPU Core Structure.
Definition: percpu.h:347
Manages each user extension set.
Definition: userextdata.h:50
Definition: userextimpl.h:232
Chain iterator for dynamic user extensions.
Definition: userextimpl.h:46
Definition: userextimpl.h:51
Chain_Iterator_registry Iterators
Chain iterator registration.
Definition: userextimpl.h:60
Chain_Control Active
Active dynamically added user extensions.
Definition: userextimpl.h:55
Manages the switch callouts.
Definition: userextdata.h:39
User extension table.
Definition: userext.h:232
Definition: userextimpl.h:149
Definition: thread.h:732
struct User_extensions_Iterator * last_user_extensions_iterator
LIFO list of user extensions iterators.
Definition: thread.h:876
Definition: chain.h:86
User Extension Handler Data Structures.