summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-11-28 10:45:38 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-12-05 18:07:04 +0100
commit04b5d174a4def46c0f667207119f2f5b83e247b4 (patch)
tree2c622c7c19c4b242c077a7c8a2e5f7242b77199c /cpukit/score/include
parentscore: Add _Chain_Append_if_is_off_chain_*() (diff)
downloadrtems-04b5d174a4def46c0f667207119f2f5b83e247b4.tar.bz2
score: Add API extensions post switch list
Move post switch hook from API_extensions_Control to new API_extensions_Post_switch_control. Rename _API_extensions_Run_postswitch() in _API_extensions_Run_post_switch(). Add _API_extensions_Post_switch_list and _API_extensions_Add_post_switch().
Diffstat (limited to 'cpukit/score/include')
-rw-r--r--cpukit/score/include/rtems/score/apiext.h59
1 files changed, 44 insertions, 15 deletions
diff --git a/cpukit/score/include/rtems/score/apiext.h b/cpukit/score/include/rtems/score/apiext.h
index 82910bfc0d..db77a8b9c8 100644
--- a/cpukit/score/include/rtems/score/apiext.h
+++ b/cpukit/score/include/rtems/score/apiext.h
@@ -46,9 +46,9 @@
typedef void (*API_extensions_Postdriver_hook)(void);
/**
- * This type defines the prototype of the Postswitch Hook.
+ * This type defines the prototype of the Post Switch Hook.
*/
-typedef void (*API_extensions_Postswitch_hook)(
+typedef void (*API_extensions_Post_switch_hook)(
Thread_Control *
);
@@ -77,20 +77,34 @@ typedef struct {
* @note If this field is NULL, no extension is invoked.
*/
API_extensions_Postdriver_hook postdriver_hook;
+} API_extensions_Control;
+
+/**
+ * @brief Control structure for post switch hooks.
+ */
+typedef struct {
+ Chain_Node Node;
+
/**
- * This field is the callout invoked during each context switch
- * in the context of the heir thread.
+ * @brief The hook invoked during each context switch in the context of the
+ * heir thread.
*
- * @note If this field is NULL, no extension is invoked.
+ * This hook must not be NULL.
*/
- API_extensions_Postswitch_hook postswitch_hook;
-} API_extensions_Control;
+ API_extensions_Post_switch_hook hook;
+} API_extensions_Post_switch_control;
/**
* This is the list of API extensions to the system initialization.
*/
SCORE_EXTERN Chain_Control _API_extensions_List;
+
+/**
+ * @brief The API extensions post switch list.
+ */
+SCORE_EXTERN Chain_Control _API_extensions_Post_switch_list;
+
/**
* @brief Initialize the API Extensions Handler
*
@@ -109,6 +123,23 @@ void _API_extensions_Add(
API_extensions_Control *the_extension
);
+/**
+ * @brief Adds the API extension post switch control to the post switch list.
+ *
+ * The post switch control is only added to the list if it is in the off chain
+ * state. Thus this function can be called multiple times with the same
+ * post switch control and only the first invocation will actually add it to the
+ * list.
+ *
+ * There is no protection against concurrent access. This function must be
+ * called within a _Thread_Disable_dispatch() critical section.
+ *
+ * @param [in, out] post_switch The post switch control.
+ */
+void _API_extensions_Add_post_switch(
+ API_extensions_Post_switch_control *post_switch
+);
+
#if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API)
/**
* @brief Execute all Pre-Driver Extensions
@@ -126,21 +157,19 @@ void _API_extensions_Add(
void _API_extensions_Run_postdriver( void );
/**
- * @brief Execute all Post Context Switch Extensions
- *
- * This routine executes all of the post context switch callouts.
+ * @brief Runs all API extension post switch hooks.
*/
-static inline void _API_extensions_Run_postswitch( Thread_Control *executing )
+static inline void _API_extensions_Run_post_switch( Thread_Control *executing )
{
- const Chain_Control *chain = &_API_extensions_List;
+ const Chain_Control *chain = &_API_extensions_Post_switch_list;
const Chain_Node *tail = _Chain_Immutable_tail( chain );
const Chain_Node *node = _Chain_Immutable_first( chain );
while ( node != tail ) {
- const API_extensions_Control *extension =
- (const API_extensions_Control *) node;
+ const API_extensions_Post_switch_control *post_switch =
+ (const API_extensions_Post_switch_control *) node;
- (*extension->postswitch_hook)( executing );
+ (*post_switch->hook)( executing );
node = _Chain_Immutable_next( node );
}