1 | /* |
---|
2 | * User Extension Handler |
---|
3 | * |
---|
4 | * NOTE: XXX |
---|
5 | * |
---|
6 | * COPYRIGHT (c) 1989-1999. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in the file LICENSE in this distribution or at |
---|
11 | * http://www.rtems.com/license/LICENSE. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #if HAVE_CONFIG_H |
---|
17 | #include "config.h" |
---|
18 | #endif |
---|
19 | |
---|
20 | #include <rtems/system.h> |
---|
21 | #include <rtems/score/userext.h> |
---|
22 | |
---|
23 | /*PAGE |
---|
24 | * |
---|
25 | * _User_extensions_Thread_create |
---|
26 | */ |
---|
27 | |
---|
28 | boolean _User_extensions_Thread_create ( |
---|
29 | Thread_Control *the_thread |
---|
30 | ) |
---|
31 | { |
---|
32 | Chain_Node *the_node; |
---|
33 | User_extensions_Control *the_extension; |
---|
34 | boolean status; |
---|
35 | |
---|
36 | for ( the_node = _User_extensions_List.first ; |
---|
37 | !_Chain_Is_tail( &_User_extensions_List, the_node ) ; |
---|
38 | the_node = the_node->next ) { |
---|
39 | |
---|
40 | the_extension = (User_extensions_Control *) the_node; |
---|
41 | |
---|
42 | if ( the_extension->Callouts.thread_create != NULL ) { |
---|
43 | status = (*the_extension->Callouts.thread_create)( |
---|
44 | _Thread_Executing, |
---|
45 | the_thread |
---|
46 | ); |
---|
47 | if ( !status ) |
---|
48 | return FALSE; |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | return TRUE; |
---|
53 | } |
---|
54 | |
---|
55 | /*PAGE |
---|
56 | * |
---|
57 | * _User_extensions_Thread_delete |
---|
58 | */ |
---|
59 | |
---|
60 | void _User_extensions_Thread_delete ( |
---|
61 | Thread_Control *the_thread |
---|
62 | ) |
---|
63 | { |
---|
64 | Chain_Node *the_node; |
---|
65 | User_extensions_Control *the_extension; |
---|
66 | |
---|
67 | for ( the_node = _User_extensions_List.last ; |
---|
68 | !_Chain_Is_head( &_User_extensions_List, the_node ) ; |
---|
69 | the_node = the_node->previous ) { |
---|
70 | |
---|
71 | the_extension = (User_extensions_Control *) the_node; |
---|
72 | |
---|
73 | if ( the_extension->Callouts.thread_delete != NULL ) |
---|
74 | (*the_extension->Callouts.thread_delete)( |
---|
75 | _Thread_Executing, |
---|
76 | the_thread |
---|
77 | ); |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | /*PAGE |
---|
82 | * |
---|
83 | * _User_extensions_Thread_start |
---|
84 | * |
---|
85 | */ |
---|
86 | |
---|
87 | void _User_extensions_Thread_start ( |
---|
88 | Thread_Control *the_thread |
---|
89 | ) |
---|
90 | { |
---|
91 | Chain_Node *the_node; |
---|
92 | User_extensions_Control *the_extension; |
---|
93 | |
---|
94 | for ( the_node = _User_extensions_List.first ; |
---|
95 | !_Chain_Is_tail( &_User_extensions_List, the_node ) ; |
---|
96 | the_node = the_node->next ) { |
---|
97 | |
---|
98 | the_extension = (User_extensions_Control *) the_node; |
---|
99 | |
---|
100 | if ( the_extension->Callouts.thread_start != NULL ) |
---|
101 | (*the_extension->Callouts.thread_start)( |
---|
102 | _Thread_Executing, |
---|
103 | the_thread |
---|
104 | ); |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | /*PAGE |
---|
109 | * |
---|
110 | * _User_extensions_Thread_restart |
---|
111 | * |
---|
112 | */ |
---|
113 | |
---|
114 | void _User_extensions_Thread_restart ( |
---|
115 | Thread_Control *the_thread |
---|
116 | ) |
---|
117 | { |
---|
118 | Chain_Node *the_node; |
---|
119 | User_extensions_Control *the_extension; |
---|
120 | |
---|
121 | for ( the_node = _User_extensions_List.first ; |
---|
122 | !_Chain_Is_tail( &_User_extensions_List, the_node ) ; |
---|
123 | the_node = the_node->next ) { |
---|
124 | |
---|
125 | the_extension = (User_extensions_Control *) the_node; |
---|
126 | |
---|
127 | if ( the_extension->Callouts.thread_restart != NULL ) |
---|
128 | (*the_extension->Callouts.thread_restart)( |
---|
129 | _Thread_Executing, |
---|
130 | the_thread |
---|
131 | ); |
---|
132 | } |
---|
133 | } |
---|
134 | |
---|
135 | /*PAGE |
---|
136 | * |
---|
137 | * _User_extensions_Thread_begin |
---|
138 | * |
---|
139 | */ |
---|
140 | |
---|
141 | void _User_extensions_Thread_begin ( |
---|
142 | Thread_Control *executing |
---|
143 | ) |
---|
144 | { |
---|
145 | Chain_Node *the_node; |
---|
146 | User_extensions_Control *the_extension; |
---|
147 | |
---|
148 | for ( the_node = _User_extensions_List.first ; |
---|
149 | !_Chain_Is_tail( &_User_extensions_List, the_node ) ; |
---|
150 | the_node = the_node->next ) { |
---|
151 | |
---|
152 | the_extension = (User_extensions_Control *) the_node; |
---|
153 | |
---|
154 | if ( the_extension->Callouts.thread_begin != NULL ) |
---|
155 | (*the_extension->Callouts.thread_begin)( executing ); |
---|
156 | } |
---|
157 | } |
---|
158 | |
---|
159 | /*PAGE |
---|
160 | * |
---|
161 | * _User_extensions_Thread_exitted |
---|
162 | */ |
---|
163 | |
---|
164 | void _User_extensions_Thread_exitted ( |
---|
165 | Thread_Control *executing |
---|
166 | ) |
---|
167 | { |
---|
168 | Chain_Node *the_node; |
---|
169 | User_extensions_Control *the_extension; |
---|
170 | |
---|
171 | for ( the_node = _User_extensions_List.last ; |
---|
172 | !_Chain_Is_head( &_User_extensions_List, the_node ) ; |
---|
173 | the_node = the_node->previous ) { |
---|
174 | |
---|
175 | the_extension = (User_extensions_Control *) the_node; |
---|
176 | |
---|
177 | if ( the_extension->Callouts.thread_exitted != NULL ) |
---|
178 | (*the_extension->Callouts.thread_exitted)( executing ); |
---|
179 | } |
---|
180 | } |
---|
181 | |
---|
182 | /*PAGE |
---|
183 | * |
---|
184 | * _User_extensions_Fatal |
---|
185 | */ |
---|
186 | |
---|
187 | void _User_extensions_Fatal ( |
---|
188 | Internal_errors_Source the_source, |
---|
189 | boolean is_internal, |
---|
190 | uint32_t the_error |
---|
191 | ) |
---|
192 | { |
---|
193 | Chain_Node *the_node; |
---|
194 | User_extensions_Control *the_extension; |
---|
195 | |
---|
196 | for ( the_node = _User_extensions_List.last ; |
---|
197 | !_Chain_Is_head( &_User_extensions_List, the_node ) ; |
---|
198 | the_node = the_node->previous ) { |
---|
199 | |
---|
200 | the_extension = (User_extensions_Control *) the_node; |
---|
201 | |
---|
202 | if ( the_extension->Callouts.fatal != NULL ) |
---|
203 | (*the_extension->Callouts.fatal)( the_source, is_internal, the_error ); |
---|
204 | } |
---|
205 | } |
---|