OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [src/] [taskmp.c] - Blame information for rev 587

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.