[52adc808] | 1 | /** |
---|
| 2 | * @file |
---|
[ac7d5ef0] | 3 | * |
---|
[52adc808] | 4 | * @brief RTEMS Task API Extensions |
---|
| 5 | * @ingroup ClassicTasks |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | /* |
---|
[e6c87f7] | 9 | * COPYRIGHT (c) 1989-2014. |
---|
[ac7d5ef0] | 10 | * On-Line Applications Research Corporation (OAR). |
---|
| 11 | * |
---|
[98e4ebf5] | 12 | * The license and distribution terms for this file may be |
---|
| 13 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 14 | * http://www.rtems.org/license/LICENSE. |
---|
[ac7d5ef0] | 15 | */ |
---|
| 16 | |
---|
[1095ec1] | 17 | #if HAVE_CONFIG_H |
---|
| 18 | #include "config.h" |
---|
| 19 | #endif |
---|
| 20 | |
---|
[4cb19041] | 21 | #include <rtems/config.h> |
---|
[565672a] | 22 | #include <rtems/sysinit.h> |
---|
[f4d9ab3e] | 23 | #include <rtems/rtems/asrimpl.h> |
---|
[e151eb1] | 24 | #include <rtems/rtems/eventimpl.h> |
---|
[c404828] | 25 | #include <rtems/rtems/tasksimpl.h> |
---|
[6fd1bdb7] | 26 | #include <rtems/score/threadimpl.h> |
---|
[3be0c9a] | 27 | #include <rtems/score/userextimpl.h> |
---|
[3a4ae6c] | 28 | |
---|
[565672a] | 29 | Thread_Information _RTEMS_tasks_Information; |
---|
| 30 | |
---|
[64adc13] | 31 | /* |
---|
[3a4ae6c] | 32 | * _RTEMS_tasks_Create_extension |
---|
| 33 | * |
---|
[3ba754e1] | 34 | * This routine is an extension routine that is invoked as part |
---|
| 35 | * of creating any type of task or thread in the system. If the |
---|
| 36 | * task is created via another API, then this routine is invoked |
---|
| 37 | * and this API given the opportunity to initialize its extension |
---|
| 38 | * area. |
---|
[3a4ae6c] | 39 | */ |
---|
| 40 | |
---|
[32a19d6] | 41 | static bool _RTEMS_tasks_Create_extension( |
---|
[50f32b11] | 42 | Thread_Control *executing, |
---|
[3a4ae6c] | 43 | Thread_Control *created |
---|
| 44 | ) |
---|
| 45 | { |
---|
| 46 | RTEMS_API_Control *api; |
---|
| 47 | |
---|
[69aa3349] | 48 | api = created->API_Extensions[ THREAD_API_RTEMS ]; |
---|
[50f32b11] | 49 | |
---|
[0960fee] | 50 | _ASR_Create( &api->Signal ); |
---|
[f4631c47] | 51 | |
---|
[484a769] | 52 | return true; |
---|
[3a4ae6c] | 53 | } |
---|
| 54 | |
---|
[64adc13] | 55 | /* |
---|
[3a4ae6c] | 56 | * _RTEMS_tasks_Start_extension |
---|
| 57 | * |
---|
[3ba754e1] | 58 | * This extension routine is invoked when a task is started for the |
---|
| 59 | * first time. |
---|
[3a4ae6c] | 60 | */ |
---|
[50f32b11] | 61 | |
---|
[32a19d6] | 62 | static void _RTEMS_tasks_Start_extension( |
---|
[3a4ae6c] | 63 | Thread_Control *executing, |
---|
| 64 | Thread_Control *started |
---|
| 65 | ) |
---|
| 66 | { |
---|
| 67 | RTEMS_API_Control *api; |
---|
| 68 | |
---|
| 69 | api = started->API_Extensions[ THREAD_API_RTEMS ]; |
---|
[50f32b11] | 70 | |
---|
[990575c] | 71 | _Event_Initialize( &api->Event ); |
---|
[0edf263] | 72 | _Event_Initialize( &api->System_event ); |
---|
[3a4ae6c] | 73 | } |
---|
| 74 | |
---|
[0960fee] | 75 | static void _RTEMS_tasks_Delete_extension( |
---|
| 76 | Thread_Control *executing, |
---|
| 77 | Thread_Control *deleted |
---|
| 78 | ) |
---|
| 79 | { |
---|
| 80 | RTEMS_API_Control *api; |
---|
| 81 | |
---|
| 82 | api = deleted->API_Extensions[ THREAD_API_RTEMS ]; |
---|
| 83 | |
---|
| 84 | _ASR_Destroy( &api->Signal ); |
---|
| 85 | } |
---|
| 86 | |
---|
[7af35da5] | 87 | User_extensions_Control _RTEMS_tasks_User_extensions = { |
---|
[1d40d81b] | 88 | .Callouts = { |
---|
| 89 | .thread_create = _RTEMS_tasks_Create_extension, |
---|
| 90 | .thread_start = _RTEMS_tasks_Start_extension, |
---|
| 91 | .thread_restart = _RTEMS_tasks_Start_extension, |
---|
| 92 | .thread_delete = _RTEMS_tasks_Delete_extension |
---|
[3a4ae6c] | 93 | } |
---|
| 94 | }; |
---|
[ac7d5ef0] | 95 | |
---|
[565672a] | 96 | static void _RTEMS_tasks_Manager_initialization(void) |
---|
[5250ff39] | 97 | { |
---|
[d7665823] | 98 | _Thread_Initialize_information( |
---|
[90015e7f] | 99 | &_RTEMS_tasks_Information, /* object information table */ |
---|
| 100 | OBJECTS_CLASSIC_API, /* object API */ |
---|
| 101 | OBJECTS_RTEMS_TASKS, /* object class */ |
---|
[db80f11] | 102 | Configuration_RTEMS_API.maximum_tasks, |
---|
| 103 | /* maximum objects of this class */ |
---|
[eaef4657] | 104 | false, /* true if the name is a string */ |
---|
[90015e7f] | 105 | RTEMS_MAXIMUM_NAME_LENGTH /* maximum length of an object name */ |
---|
[5250ff39] | 106 | ); |
---|
[3a4ae6c] | 107 | |
---|
| 108 | /* |
---|
| 109 | * Add all the extensions for this API |
---|
| 110 | */ |
---|
| 111 | |
---|
[7af35da5] | 112 | _User_extensions_Add_API_set( &_RTEMS_tasks_User_extensions ); |
---|
[3a4ae6c] | 113 | |
---|
| 114 | /* |
---|
| 115 | * Register the MP Process Packet routine. |
---|
| 116 | */ |
---|
| 117 | |
---|
[97e2729d] | 118 | #if defined(RTEMS_MULTIPROCESSING) |
---|
[3a4ae6c] | 119 | _MPCI_Register_packet_processor( |
---|
| 120 | MP_PACKET_TASKS, |
---|
| 121 | _RTEMS_tasks_MP_Process_packet |
---|
| 122 | ); |
---|
[97e2729d] | 123 | #endif |
---|
[3a4ae6c] | 124 | |
---|
[5250ff39] | 125 | } |
---|
[0ab34c90] | 126 | |
---|
[565672a] | 127 | RTEMS_SYSINIT_ITEM( |
---|
| 128 | _RTEMS_tasks_Manager_initialization, |
---|
| 129 | RTEMS_SYSINIT_CLASSIC_TASKS, |
---|
| 130 | RTEMS_SYSINIT_ORDER_MIDDLE |
---|
| 131 | ); |
---|