OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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

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

powered by: WebSVN 2.1.0

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