source: rtems/cpukit/rtems/src/taskmp.c @ 484a769

4.104.114.9
Last change on this file since 484a769 was 484a769, checked in by Ralf Corsepius <ralf.corsepius@…>, on Sep 4, 2008 at 5:46:39 PM

Convert to "bool".

  • Property mode set to 100644
File size: 8.6 KB
Line 
1/*
2 *  Multiprocessing Support for the RTEMS Task Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-2008.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/rtems/status.h>
21#include <rtems/score/mpci.h>
22#include <rtems/score/mppkt.h>
23#include <rtems/score/object.h>
24#include <rtems/rtems/options.h>
25#include <rtems/rtems/tasks.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/watchdog.h>
28#include <rtems/rtems/support.h>
29
30/*PAGE
31 *
32 *  _RTEMS_tasks_MP_Send_process_packet
33 *
34 */
35
36void _RTEMS_tasks_MP_Send_process_packet (
37  RTEMS_tasks_MP_Remote_operations operation,
38  Objects_Id                       task_id,
39  rtems_name                       name
40)
41{
42  RTEMS_tasks_MP_Packet *the_packet;
43
44  switch ( operation ) {
45
46    case RTEMS_TASKS_MP_ANNOUNCE_CREATE:
47    case RTEMS_TASKS_MP_ANNOUNCE_DELETE:
48
49      the_packet                    = _RTEMS_tasks_MP_Get_packet();
50      the_packet->Prefix.the_class  = MP_PACKET_TASKS;
51      the_packet->Prefix.length     = sizeof ( RTEMS_tasks_MP_Packet );
52      the_packet->Prefix.to_convert = sizeof ( RTEMS_tasks_MP_Packet );
53      the_packet->operation         = operation;
54      the_packet->Prefix.id         = task_id;
55      the_packet->name              = name;
56
57      _MPCI_Send_process_packet( MPCI_ALL_NODES, &the_packet->Prefix );
58      break;
59
60    case RTEMS_TASKS_MP_SUSPEND_REQUEST:
61    case RTEMS_TASKS_MP_SUSPEND_RESPONSE:
62    case RTEMS_TASKS_MP_RESUME_REQUEST:
63    case RTEMS_TASKS_MP_RESUME_RESPONSE:
64    case RTEMS_TASKS_MP_SET_PRIORITY_REQUEST:
65    case RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE:
66    case RTEMS_TASKS_MP_GET_NOTE_REQUEST:
67    case RTEMS_TASKS_MP_GET_NOTE_RESPONSE:
68    case RTEMS_TASKS_MP_SET_NOTE_REQUEST:
69    case RTEMS_TASKS_MP_SET_NOTE_RESPONSE:
70      break;
71  }
72}
73
74/*PAGE
75 *
76 *  _RTEMS_tasks_MP_Send_request_packet
77 *
78 */
79
80rtems_status_code _RTEMS_tasks_MP_Send_request_packet (
81  RTEMS_tasks_MP_Remote_operations operation,
82  Objects_Id                       task_id,
83  rtems_task_priority                 new_priority,
84  uint32_t                         notepad,
85  uint32_t                         note
86)
87{
88  RTEMS_tasks_MP_Packet *the_packet;
89
90  switch ( operation ) {
91
92    case RTEMS_TASKS_MP_SUSPEND_REQUEST:
93    case RTEMS_TASKS_MP_RESUME_REQUEST:
94    case RTEMS_TASKS_MP_SET_PRIORITY_REQUEST:
95    case RTEMS_TASKS_MP_GET_NOTE_REQUEST:
96    case RTEMS_TASKS_MP_SET_NOTE_REQUEST:
97
98      the_packet                    = _RTEMS_tasks_MP_Get_packet();
99      the_packet->Prefix.the_class  = MP_PACKET_TASKS;
100      the_packet->Prefix.length     = sizeof ( RTEMS_tasks_MP_Packet );
101      the_packet->Prefix.to_convert = sizeof ( RTEMS_tasks_MP_Packet );
102      the_packet->operation         = operation;
103      the_packet->Prefix.id         = task_id;
104      the_packet->the_priority      = new_priority;
105      the_packet->notepad           = notepad;
106      the_packet->note              = note;
107
108      return _MPCI_Send_request_packet(
109        _Objects_Get_node( task_id ),
110        &the_packet->Prefix,
111        STATES_READY     /* Not used */
112      );
113      break;
114
115    case RTEMS_TASKS_MP_ANNOUNCE_CREATE:
116    case RTEMS_TASKS_MP_ANNOUNCE_DELETE:
117    case RTEMS_TASKS_MP_SUSPEND_RESPONSE:
118    case RTEMS_TASKS_MP_RESUME_RESPONSE:
119    case RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE:
120    case RTEMS_TASKS_MP_GET_NOTE_RESPONSE:
121    case RTEMS_TASKS_MP_SET_NOTE_RESPONSE:
122      break;
123
124  }
125  /*
126   *  The following line is included to satisfy compilers which
127   *  produce warnings when a function does not end with a return.
128   */
129  return RTEMS_SUCCESSFUL;
130}
131
132/*PAGE
133 *
134 *  _RTEMS_tasks_MP_Send_response_packet
135 *
136 */
137
138void _RTEMS_tasks_MP_Send_response_packet (
139  RTEMS_tasks_MP_Remote_operations  operation,
140  Thread_Control                   *the_thread
141)
142{
143  RTEMS_tasks_MP_Packet *the_packet;
144
145  switch ( operation ) {
146
147    case RTEMS_TASKS_MP_SUSPEND_RESPONSE:
148    case RTEMS_TASKS_MP_RESUME_RESPONSE:
149    case RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE:
150    case RTEMS_TASKS_MP_GET_NOTE_RESPONSE:
151    case RTEMS_TASKS_MP_SET_NOTE_RESPONSE:
152
153      the_packet = (RTEMS_tasks_MP_Packet *) the_thread->receive_packet;
154
155/*
156 *  The packet being returned already contains the class, length, and
157 *  to_convert fields, therefore they are not set in this routine.
158 */
159      the_packet->operation    = operation;
160      the_packet->Prefix.id    = the_packet->Prefix.source_tid;
161
162      _MPCI_Send_response_packet(
163        _Objects_Get_node( the_packet->Prefix.source_tid ),
164        &the_packet->Prefix
165      );
166      break;
167
168    case RTEMS_TASKS_MP_ANNOUNCE_CREATE:
169    case RTEMS_TASKS_MP_ANNOUNCE_DELETE:
170    case RTEMS_TASKS_MP_SUSPEND_REQUEST:
171    case RTEMS_TASKS_MP_RESUME_REQUEST:
172    case RTEMS_TASKS_MP_SET_PRIORITY_REQUEST:
173    case RTEMS_TASKS_MP_GET_NOTE_REQUEST:
174    case RTEMS_TASKS_MP_SET_NOTE_REQUEST:
175      break;
176
177  }
178}
179
180/*PAGE
181 *
182 *
183 *  _RTEMS_tasks_MP_Process_packet
184 *
185 */
186
187void _RTEMS_tasks_MP_Process_packet (
188  rtems_packet_prefix  *the_packet_prefix
189)
190{
191  RTEMS_tasks_MP_Packet *the_packet;
192  Thread_Control   *the_thread;
193  bool           ignored;
194
195  the_packet = (RTEMS_tasks_MP_Packet *) the_packet_prefix;
196
197  switch ( the_packet->operation ) {
198
199    case RTEMS_TASKS_MP_ANNOUNCE_CREATE:
200
201      ignored = _Objects_MP_Allocate_and_open(
202                  &_RTEMS_tasks_Information,
203                  the_packet->name,
204                  the_packet->Prefix.id,
205                  TRUE
206                );
207
208      _MPCI_Return_packet( the_packet_prefix );
209      break;
210
211    case RTEMS_TASKS_MP_ANNOUNCE_DELETE:
212
213      _Objects_MP_Close( &_RTEMS_tasks_Information, the_packet->Prefix.id );
214
215      _MPCI_Return_packet( the_packet_prefix );
216      break;
217
218    case RTEMS_TASKS_MP_SUSPEND_REQUEST:
219
220      the_packet->Prefix.return_code = rtems_task_suspend(
221        the_packet->Prefix.id
222      );
223
224      _RTEMS_tasks_MP_Send_response_packet(
225        RTEMS_TASKS_MP_SUSPEND_RESPONSE,
226        _Thread_Executing
227      );
228      break;
229
230    case RTEMS_TASKS_MP_SUSPEND_RESPONSE:
231    case RTEMS_TASKS_MP_RESUME_RESPONSE:
232    case RTEMS_TASKS_MP_SET_NOTE_RESPONSE:
233
234      the_thread = _MPCI_Process_response( the_packet_prefix );
235
236      _MPCI_Return_packet( the_packet_prefix );
237      break;
238
239    case RTEMS_TASKS_MP_RESUME_REQUEST:
240
241      the_packet->Prefix.return_code = rtems_task_resume(
242        the_packet->Prefix.id
243      );
244
245      _RTEMS_tasks_MP_Send_response_packet(
246        RTEMS_TASKS_MP_RESUME_RESPONSE,
247        _Thread_Executing
248      );
249      break;
250
251    case RTEMS_TASKS_MP_SET_PRIORITY_REQUEST:
252
253      the_packet->Prefix.return_code = rtems_task_set_priority(
254        the_packet->Prefix.id,
255        the_packet->the_priority,
256        &the_packet->the_priority
257      );
258
259      _RTEMS_tasks_MP_Send_response_packet(
260        RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE,
261        _Thread_Executing
262      );
263      break;
264
265    case RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE:
266
267      the_thread = _MPCI_Process_response( the_packet_prefix );
268
269      *(rtems_task_priority *)the_thread->Wait.return_argument =
270                                               the_packet->the_priority;
271
272      _MPCI_Return_packet( the_packet_prefix );
273      break;
274
275    case RTEMS_TASKS_MP_GET_NOTE_REQUEST:
276
277      the_packet->Prefix.return_code = rtems_task_get_note(
278        the_packet->Prefix.id,
279        the_packet->notepad,
280        &the_packet->note
281      );
282
283      _RTEMS_tasks_MP_Send_response_packet(
284        RTEMS_TASKS_MP_GET_NOTE_RESPONSE,
285        _Thread_Executing
286      );
287      break;
288
289    case RTEMS_TASKS_MP_GET_NOTE_RESPONSE:
290
291      the_thread = _MPCI_Process_response( the_packet_prefix );
292
293      *(uint32_t   *)the_thread->Wait.return_argument = the_packet->note;
294
295      _MPCI_Return_packet( the_packet_prefix );
296      break;
297
298    case RTEMS_TASKS_MP_SET_NOTE_REQUEST:
299
300      the_packet->Prefix.return_code = rtems_task_set_note(
301        the_packet->Prefix.id,
302        the_packet->notepad,
303        the_packet->note
304      );
305
306      _RTEMS_tasks_MP_Send_response_packet(
307        RTEMS_TASKS_MP_SET_NOTE_RESPONSE,
308        _Thread_Executing
309      );
310      break;
311  }
312}
313
314/*PAGE
315 *
316 *  _RTEMS_tasks_MP_Send_object_was_deleted
317 *
318 *  This routine is not neededby the Tasks since a task
319 *  cannot be globally deleted.
320 *
321 */
322
323/*PAGE
324 *
325 *  _RTEMS_tasks_MP_Send_extract_proxy
326 *
327 *  This routine is not neededby the Tasks since a task
328 *  cannot be globally deleted.
329 *
330 */
331
332/*PAGE
333 *
334 *  _RTEMS_tasks_MP_Get_packet
335 *
336 */
337
338RTEMS_tasks_MP_Packet *_RTEMS_tasks_MP_Get_packet ( void )
339{
340  return (RTEMS_tasks_MP_Packet *) _MPCI_Get_packet();
341}
342
343/* end of file */
Note: See TracBrowser for help on using the repository browser.