[c42d1a4] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @ingroup ScoreUserExt |
---|
| 5 | * |
---|
| 6 | * @brief User Extension Handler implementation. |
---|
| 7 | */ |
---|
| 8 | |
---|
[5072b07] | 9 | /* |
---|
[790b50b] | 10 | * COPYRIGHT (c) 1989-2008. |
---|
[5072b07] | 11 | * On-Line Applications Research Corporation (OAR). |
---|
| 12 | * |
---|
[98e4ebf5] | 13 | * The license and distribution terms for this file may be |
---|
| 14 | * found in the file LICENSE in this distribution or at |
---|
[dd687d97] | 15 | * http://www.rtems.com/license/LICENSE. |
---|
[5072b07] | 16 | */ |
---|
| 17 | |
---|
[a8eed23] | 18 | #if HAVE_CONFIG_H |
---|
[466cf31d] | 19 | #include "config.h" |
---|
[a8eed23] | 20 | #endif |
---|
| 21 | |
---|
[790b50b] | 22 | #include <rtems/config.h> |
---|
[5e9b32b] | 23 | #include <rtems/score/userext.h> |
---|
[c3db01d0] | 24 | #include <rtems/score/wkspace.h> |
---|
[5072b07] | 25 | |
---|
[466cf31d] | 26 | CHAIN_DEFINE_EMPTY( _User_extensions_Switches_list ); |
---|
| 27 | |
---|
| 28 | typedef struct { |
---|
| 29 | User_extensions_Switch_control *switch_control; |
---|
| 30 | } User_extensions_Switch_context; |
---|
| 31 | |
---|
| 32 | static void _User_extensions_Switch_visitor( |
---|
| 33 | Thread_Control *executing, |
---|
| 34 | void *arg, |
---|
| 35 | const User_extensions_Table *callouts |
---|
| 36 | ) |
---|
[5072b07] | 37 | { |
---|
[466cf31d] | 38 | User_extensions_thread_switch_extension callout = callouts->thread_switch; |
---|
[790b50b] | 39 | |
---|
[466cf31d] | 40 | if ( callout != NULL ) { |
---|
| 41 | User_extensions_Switch_context *ctx = arg; |
---|
| 42 | User_extensions_Switch_control *ctrl = ctx->switch_control; |
---|
[05279b84] | 43 | |
---|
[466cf31d] | 44 | _Chain_Append_unprotected( &_User_extensions_Switches_list, &ctrl->Node ); |
---|
| 45 | ctrl->thread_switch = callout; |
---|
| 46 | |
---|
| 47 | ctx->switch_control = ctrl + 1; |
---|
| 48 | } |
---|
| 49 | } |
---|
[05279b84] | 50 | |
---|
[466cf31d] | 51 | void _User_extensions_Handler_initialization(void) |
---|
| 52 | { |
---|
| 53 | uint32_t number_of_initial_extensions = |
---|
| 54 | rtems_configuration_get_number_of_initial_extensions(); |
---|
| 55 | |
---|
| 56 | if ( number_of_initial_extensions > 0 ) { |
---|
| 57 | User_extensions_Switch_control *initial_extension_switch_controls = |
---|
[c3db01d0] | 58 | _Workspace_Allocate_or_fatal_error( |
---|
[466cf31d] | 59 | number_of_initial_extensions |
---|
| 60 | * sizeof( *initial_extension_switch_controls ) |
---|
[5072b07] | 61 | ); |
---|
[466cf31d] | 62 | User_extensions_Switch_context ctx = { initial_extension_switch_controls }; |
---|
[28352fae] | 63 | |
---|
[466cf31d] | 64 | _User_extensions_Iterate( &ctx, _User_extensions_Switch_visitor ); |
---|
[5072b07] | 65 | } |
---|
| 66 | } |
---|