1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Task API Extensions |
---|
5 | * @ingroup ClassicTasks |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2014. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/config.h> |
---|
22 | #include <rtems/sysinit.h> |
---|
23 | #include <rtems/rtems/eventimpl.h> |
---|
24 | #include <rtems/rtems/tasksimpl.h> |
---|
25 | #include <rtems/score/threadimpl.h> |
---|
26 | #include <rtems/score/userextimpl.h> |
---|
27 | |
---|
28 | Thread_Information _RTEMS_tasks_Information; |
---|
29 | |
---|
30 | static void _RTEMS_tasks_Start_extension( |
---|
31 | Thread_Control *executing, |
---|
32 | Thread_Control *started |
---|
33 | ) |
---|
34 | { |
---|
35 | RTEMS_API_Control *api; |
---|
36 | |
---|
37 | api = started->API_Extensions[ THREAD_API_RTEMS ]; |
---|
38 | |
---|
39 | _Event_Initialize( &api->Event ); |
---|
40 | _Event_Initialize( &api->System_event ); |
---|
41 | } |
---|
42 | |
---|
43 | #if defined(RTEMS_MULTIPROCESSING) |
---|
44 | static void _RTEMS_tasks_Terminate_extension( Thread_Control *executing ) |
---|
45 | { |
---|
46 | if ( executing->is_global ) { |
---|
47 | _Objects_MP_Close( |
---|
48 | &_RTEMS_tasks_Information.Objects, |
---|
49 | executing->Object.id |
---|
50 | ); |
---|
51 | _RTEMS_tasks_MP_Send_process_packet( |
---|
52 | RTEMS_TASKS_MP_ANNOUNCE_DELETE, |
---|
53 | executing->Object.id, |
---|
54 | 0 /* Not used */ |
---|
55 | ); |
---|
56 | } |
---|
57 | } |
---|
58 | #endif |
---|
59 | |
---|
60 | User_extensions_Control _RTEMS_tasks_User_extensions = { |
---|
61 | .Callouts = { |
---|
62 | #if defined(RTEMS_MULTIPROCESSING) |
---|
63 | .thread_terminate = _RTEMS_tasks_Terminate_extension, |
---|
64 | #endif |
---|
65 | .thread_start = _RTEMS_tasks_Start_extension, |
---|
66 | .thread_restart = _RTEMS_tasks_Start_extension |
---|
67 | } |
---|
68 | }; |
---|
69 | |
---|
70 | static void _RTEMS_tasks_Manager_initialization(void) |
---|
71 | { |
---|
72 | _Thread_Initialize_information( |
---|
73 | &_RTEMS_tasks_Information, /* object information table */ |
---|
74 | OBJECTS_CLASSIC_API, /* object API */ |
---|
75 | OBJECTS_RTEMS_TASKS, /* object class */ |
---|
76 | Configuration_RTEMS_API.maximum_tasks |
---|
77 | /* maximum objects of this class */ |
---|
78 | ); |
---|
79 | |
---|
80 | /* |
---|
81 | * Add all the extensions for this API |
---|
82 | */ |
---|
83 | |
---|
84 | _User_extensions_Add_API_set( &_RTEMS_tasks_User_extensions ); |
---|
85 | |
---|
86 | /* |
---|
87 | * Register the MP Process Packet routine. |
---|
88 | */ |
---|
89 | |
---|
90 | #if defined(RTEMS_MULTIPROCESSING) |
---|
91 | _MPCI_Register_packet_processor( |
---|
92 | MP_PACKET_TASKS, |
---|
93 | _RTEMS_tasks_MP_Process_packet |
---|
94 | ); |
---|
95 | #endif |
---|
96 | |
---|
97 | } |
---|
98 | |
---|
99 | RTEMS_SYSINIT_ITEM( |
---|
100 | _RTEMS_tasks_Manager_initialization, |
---|
101 | RTEMS_SYSINIT_CLASSIC_TASKS, |
---|
102 | RTEMS_SYSINIT_ORDER_MIDDLE |
---|
103 | ); |
---|