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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [src/] [partmp.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 Partition 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: partmp.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/part.h>
22
#include <rtems/score/thread.h>
23
#include <rtems/rtems/support.h>
24
 
25
/*PAGE
26
 *
27
 *  _Partition_MP_Send_process_packet
28
 *
29
 */
30
 
31
void _Partition_MP_Send_process_packet (
32
  Partition_MP_Remote_operations  operation,
33
  Objects_Id                      partition_id,
34
  rtems_name                      name,
35
  Objects_Id                      proxy_id
36
)
37
{
38
  Partition_MP_Packet *the_packet;
39
  unsigned32           node;
40
 
41
  switch ( operation ) {
42
 
43
    case PARTITION_MP_ANNOUNCE_CREATE:
44
    case PARTITION_MP_ANNOUNCE_DELETE:
45
    case PARTITION_MP_EXTRACT_PROXY:
46
 
47
      the_packet                    = _Partition_MP_Get_packet();
48
      the_packet->Prefix.the_class  = MP_PACKET_PARTITION;
49
      the_packet->Prefix.length     = sizeof ( Partition_MP_Packet );
50
      the_packet->Prefix.to_convert = sizeof ( Partition_MP_Packet );
51
      the_packet->operation         = operation;
52
      the_packet->Prefix.id         = partition_id;
53
      the_packet->name              = name;
54
      the_packet->proxy_id          = proxy_id;
55
 
56
      if ( operation == PARTITION_MP_EXTRACT_PROXY )
57
         node = rtems_get_node( partition_id );
58
      else
59
         node = MPCI_ALL_NODES;
60
 
61
      _MPCI_Send_process_packet( node, &the_packet->Prefix );
62
      break;
63
 
64
    case PARTITION_MP_GET_BUFFER_REQUEST:
65
    case PARTITION_MP_GET_BUFFER_RESPONSE:
66
    case PARTITION_MP_RETURN_BUFFER_REQUEST:
67
    case PARTITION_MP_RETURN_BUFFER_RESPONSE:
68
      break;
69
  }
70
}
71
 
72
/*PAGE
73
 *
74
 *  _Partition_MP_Send_request_packet
75
 *
76
 */
77
 
78
rtems_status_code _Partition_MP_Send_request_packet (
79
  Partition_MP_Remote_operations  operation,
80
  Objects_Id                      partition_id,
81
  void                           *buffer
82
)
83
{
84
  Partition_MP_Packet *the_packet;
85
 
86
  switch ( operation ) {
87
 
88
    case PARTITION_MP_GET_BUFFER_REQUEST:
89
    case PARTITION_MP_RETURN_BUFFER_REQUEST:
90
 
91
      the_packet                    = _Partition_MP_Get_packet();
92
      the_packet->Prefix.the_class  = MP_PACKET_PARTITION;
93
      the_packet->Prefix.length     = sizeof ( Partition_MP_Packet );
94
      the_packet->Prefix.to_convert = sizeof ( Partition_MP_Packet );
95
      the_packet->operation         = operation;
96
      the_packet->Prefix.id         = partition_id;
97
      the_packet->buffer            = buffer;
98
 
99
      return
100
        _MPCI_Send_request_packet(
101
          rtems_get_node( partition_id ),
102
          &the_packet->Prefix,
103
          STATES_READY      /* Not used */
104
        );
105
 
106
      break;
107
 
108
    case PARTITION_MP_ANNOUNCE_CREATE:
109
    case PARTITION_MP_ANNOUNCE_DELETE:
110
    case PARTITION_MP_EXTRACT_PROXY:
111
    case PARTITION_MP_GET_BUFFER_RESPONSE:
112
    case PARTITION_MP_RETURN_BUFFER_RESPONSE:
113
      break;
114
 
115
  }
116
  /*
117
   *  The following line is included to satisfy compilers which
118
   *  produce warnings when a function does not end with a return.
119
   */
120
  return RTEMS_SUCCESSFUL;
121
}
122
 
123
/*PAGE
124
 *
125
 *  _Partition_MP_Send_response_packet
126
 *
127
 */
128
 
129
void _Partition_MP_Send_response_packet (
130
  Partition_MP_Remote_operations  operation,
131
  Objects_Id                      partition_id,
132
  Thread_Control                 *the_thread
133
)
134
{
135
  Partition_MP_Packet *the_packet;
136
 
137
  switch ( operation ) {
138
 
139
    case PARTITION_MP_GET_BUFFER_RESPONSE:
140
    case PARTITION_MP_RETURN_BUFFER_RESPONSE:
141
 
142
      the_packet = ( Partition_MP_Packet *) the_thread->receive_packet;
143
 
144
/*
145
 *  The packet being returned already contains the class, length, and
146
 *  to_convert fields, therefore they are not set in this routine.
147
 */
148
      the_packet->operation = operation;
149
      the_packet->Prefix.id = the_packet->Prefix.source_tid;
150
 
151
      _MPCI_Send_response_packet(
152
        rtems_get_node( the_packet->Prefix.source_tid ),
153
        &the_packet->Prefix
154
      );
155
      break;
156
 
157
    case PARTITION_MP_ANNOUNCE_CREATE:
158
    case PARTITION_MP_ANNOUNCE_DELETE:
159
    case PARTITION_MP_EXTRACT_PROXY:
160
    case PARTITION_MP_GET_BUFFER_REQUEST:
161
    case PARTITION_MP_RETURN_BUFFER_REQUEST:
162
      break;
163
 
164
  }
165
}
166
 
167
/*PAGE
168
 *
169
 *
170
 *  _Partition_MP_Process_packet
171
 *
172
 */
173
 
174
void _Partition_MP_Process_packet (
175
  rtems_packet_prefix  *the_packet_prefix
176
)
177
{
178
  Partition_MP_Packet *the_packet;
179
  Thread_Control      *the_thread;
180
  boolean              ignored;
181
 
182
  the_packet = (Partition_MP_Packet *) the_packet_prefix;
183
 
184
  switch ( the_packet->operation ) {
185
 
186
    case PARTITION_MP_ANNOUNCE_CREATE:
187
 
188
      ignored = _Objects_MP_Allocate_and_open(
189
                  &_Partition_Information,
190
                  the_packet->name,
191
                  the_packet->Prefix.id,
192
                  TRUE
193
                );
194
 
195
      _MPCI_Return_packet( the_packet_prefix );
196
      break;
197
 
198
    case PARTITION_MP_ANNOUNCE_DELETE:
199
 
200
      _Objects_MP_Close( &_Partition_Information, the_packet->Prefix.id );
201
 
202
      _MPCI_Return_packet( the_packet_prefix );
203
      break;
204
 
205
    case PARTITION_MP_EXTRACT_PROXY:
206
 
207
      the_thread = _Thread_MP_Find_proxy( the_packet->proxy_id );
208
 
209
      if ( ! _Thread_Is_null( the_thread ) )
210
         _Thread_queue_Extract( the_thread->Wait.queue, the_thread );
211
 
212
      _MPCI_Return_packet( the_packet_prefix );
213
      break;
214
 
215
    case PARTITION_MP_GET_BUFFER_REQUEST:
216
 
217
      the_packet->Prefix.return_code = rtems_partition_get_buffer(
218
        the_packet->Prefix.id,
219
        &the_packet->buffer
220
      );
221
 
222
      _Partition_MP_Send_response_packet(
223
        PARTITION_MP_GET_BUFFER_RESPONSE,
224
        the_packet->Prefix.id,
225
        _Thread_Executing
226
      );
227
      break;
228
 
229
    case PARTITION_MP_GET_BUFFER_RESPONSE:
230
 
231
      the_thread = _MPCI_Process_response( the_packet_prefix );
232
 
233
      *(void **)the_thread->Wait.return_argument = the_packet->buffer;
234
 
235
      _MPCI_Return_packet( the_packet_prefix );
236
      break;
237
 
238
    case PARTITION_MP_RETURN_BUFFER_REQUEST:
239
 
240
      the_packet->Prefix.return_code = rtems_partition_return_buffer(
241
        the_packet->Prefix.id,
242
        the_packet->buffer
243
      );
244
 
245
      _Partition_MP_Send_response_packet(
246
        PARTITION_MP_RETURN_BUFFER_RESPONSE,
247
        the_packet->Prefix.id,
248
        _Thread_Executing
249
      );
250
      break;
251
 
252
    case PARTITION_MP_RETURN_BUFFER_RESPONSE:
253
 
254
      the_thread = _MPCI_Process_response( the_packet_prefix );
255
 
256
      _MPCI_Return_packet( the_packet_prefix );
257
      break;
258
 
259
  }
260
}
261
 
262
/*PAGE
263
 *
264
 *  _Partition_MP_Send_object_was_deleted
265
 *
266
 *  This routine is not needed by the Partition since a partition
267
 *  cannot be deleted when buffers are in use.
268
 *
269
 */
270
 
271
/*PAGE
272
 *
273
 *  _Partition_MP_Send_extract_proxy
274
 *
275
 */
276
 
277
void _Partition_MP_Send_extract_proxy (
278
  Thread_Control *the_thread
279
)
280
{
281
  _Partition_MP_Send_process_packet(
282
    PARTITION_MP_EXTRACT_PROXY,
283
    the_thread->Wait.id,
284
    (rtems_name) 0,
285
    the_thread->Object.id
286
  );
287
 
288
}
289
 
290
/*PAGE
291
 *
292
 *  _Partition_MP_Get_packet
293
 *
294
 */
295
 
296
Partition_MP_Packet *_Partition_MP_Get_packet ( void )
297
{
298
  return ( (Partition_MP_Packet *) _MPCI_Get_packet() );
299
}
300
 
301
/* end of file */

powered by: WebSVN 2.1.0

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