source: rtems/cpukit/rtems/src/partmp.c @ e266d13

5
Last change on this file since e266d13 was 0a00b2b, checked in by Sebastian Huber <sebastian.huber@…>, on 05/20/16 at 11:24:11

rtems: Remove location from _Partition_Get()

Use _Objects_Get_local() for _Partition_Get() to get rid of the location
parameter. Move remote object handling to partition MPCI support.

  • Property mode set to 100644
File size: 7.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief Partition_MP_Send_process_packet
5 * @ingroup ClassicPartMP Partition MP Support
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/partimpl.h>
22#include <rtems/score/statesimpl.h>
23#include <rtems/score/threadimpl.h>
24#include <rtems/score/threadqimpl.h>
25
26RTEMS_STATIC_ASSERT(
27  sizeof(Partition_MP_Packet) <= MP_PACKET_MINIMUM_PACKET_SIZE,
28  Partition_MP_Packet
29);
30
31static Partition_MP_Packet *_Partition_MP_Get_packet( void )
32{
33  return (Partition_MP_Packet *) _MPCI_Get_packet();
34}
35
36static void _Partition_MP_Initialize_packet(
37  Partition_MP_Packet            *the_packet,
38  Objects_Id                      id,
39  Partition_MP_Remote_operations  operation
40)
41{
42  the_packet->Prefix.the_class  = MP_PACKET_PARTITION;
43  the_packet->Prefix.length     = sizeof( *the_packet );
44  the_packet->Prefix.to_convert = sizeof( *the_packet );
45  the_packet->Prefix.id         = id;
46  the_packet->operation         = operation;
47}
48
49/*
50 *  _Partition_MP_Send_process_packet
51 *
52 */
53
54void _Partition_MP_Send_process_packet (
55  Partition_MP_Remote_operations  operation,
56  Objects_Id                      partition_id,
57  rtems_name                      name,
58  Objects_Id                      proxy_id
59)
60{
61  Partition_MP_Packet *the_packet;
62  uint32_t             node;
63
64  switch ( operation ) {
65
66    case PARTITION_MP_ANNOUNCE_CREATE:
67    case PARTITION_MP_ANNOUNCE_DELETE:
68    case PARTITION_MP_EXTRACT_PROXY:
69
70      the_packet = _Partition_MP_Get_packet();
71      _Partition_MP_Initialize_packet( the_packet, partition_id, operation );
72      the_packet->name     = name;
73      the_packet->proxy_id = proxy_id;
74
75      if ( operation == PARTITION_MP_EXTRACT_PROXY )
76         node = _Objects_Get_node( partition_id );
77      else
78         node = MPCI_ALL_NODES;
79
80      _MPCI_Send_process_packet( node, &the_packet->Prefix );
81      break;
82
83    case PARTITION_MP_GET_BUFFER_REQUEST:
84    case PARTITION_MP_GET_BUFFER_RESPONSE:
85    case PARTITION_MP_RETURN_BUFFER_REQUEST:
86    case PARTITION_MP_RETURN_BUFFER_RESPONSE:
87      break;
88  }
89}
90
91/*
92 *  _Partition_MP_Send_request_packet
93 *
94 */
95
96static rtems_status_code _Partition_MP_Send_request_packet (
97  Objects_Id                      partition_id,
98  void                           *buffer,
99  Partition_MP_Remote_operations  operation
100)
101{
102  Partition_MP_Packet *the_packet;
103
104  if ( !_Partition_MP_Is_remote( partition_id ) ) {
105    return RTEMS_INVALID_ID;
106  }
107
108  switch ( operation ) {
109
110    case PARTITION_MP_GET_BUFFER_REQUEST:
111    case PARTITION_MP_RETURN_BUFFER_REQUEST:
112
113      the_packet = _Partition_MP_Get_packet();
114      _Partition_MP_Initialize_packet( the_packet, partition_id, operation );
115      the_packet->buffer = buffer;
116
117      return
118        _MPCI_Send_request_packet(
119          _Objects_Get_node( partition_id ),
120          &the_packet->Prefix,
121          STATES_READY,     /* Not used */
122          RTEMS_TIMEOUT
123        );
124
125      break;
126
127    case PARTITION_MP_ANNOUNCE_CREATE:
128    case PARTITION_MP_ANNOUNCE_DELETE:
129    case PARTITION_MP_EXTRACT_PROXY:
130    case PARTITION_MP_GET_BUFFER_RESPONSE:
131    case PARTITION_MP_RETURN_BUFFER_RESPONSE:
132      break;
133
134  }
135  /*
136   *  The following line is included to satisfy compilers which
137   *  produce warnings when a function does not end with a return.
138   */
139  return RTEMS_SUCCESSFUL;
140}
141
142rtems_status_code _Partition_MP_Get_buffer(
143  rtems_id   id,
144  void     **buffer
145)
146{
147  _Thread_Get_executing()->Wait.return_argument = buffer;
148  return _Partition_MP_Send_request_packet(
149    id,
150    buffer,
151    PARTITION_MP_GET_BUFFER_REQUEST
152  );
153}
154
155rtems_status_code _Partition_MP_Return_buffer(
156  rtems_id  id,
157  void     *buffer
158)
159{
160  return _Partition_MP_Send_request_packet(
161    id,
162    buffer,
163    PARTITION_MP_RETURN_BUFFER_REQUEST
164  );
165}
166
167/*
168 *  _Partition_MP_Send_response_packet
169 *
170 */
171
172static void _Partition_MP_Send_response_packet (
173  Partition_MP_Remote_operations  operation,
174  Objects_Id                      partition_id,
175  Thread_Control                 *the_thread
176)
177{
178  Partition_MP_Packet *the_packet;
179
180  switch ( operation ) {
181
182    case PARTITION_MP_GET_BUFFER_RESPONSE:
183    case PARTITION_MP_RETURN_BUFFER_RESPONSE:
184
185      the_packet = ( Partition_MP_Packet *) the_thread->receive_packet;
186
187/*
188 *  The packet being returned already contains the class, length, and
189 *  to_convert fields, therefore they are not set in this routine.
190 */
191      the_packet->operation = operation;
192      the_packet->Prefix.id = the_packet->Prefix.source_tid;
193
194      _MPCI_Send_response_packet(
195        _Objects_Get_node( the_packet->Prefix.source_tid ),
196        &the_packet->Prefix
197      );
198      break;
199
200    case PARTITION_MP_ANNOUNCE_CREATE:
201    case PARTITION_MP_ANNOUNCE_DELETE:
202    case PARTITION_MP_EXTRACT_PROXY:
203    case PARTITION_MP_GET_BUFFER_REQUEST:
204    case PARTITION_MP_RETURN_BUFFER_REQUEST:
205      break;
206
207  }
208}
209
210/*
211 *
212 *  _Partition_MP_Process_packet
213 *
214 */
215
216void _Partition_MP_Process_packet (
217  rtems_packet_prefix  *the_packet_prefix
218)
219{
220  Partition_MP_Packet *the_packet;
221  Thread_Control      *the_thread;
222
223  the_packet = (Partition_MP_Packet *) the_packet_prefix;
224
225  switch ( the_packet->operation ) {
226
227    case PARTITION_MP_ANNOUNCE_CREATE:
228
229      _Objects_MP_Allocate_and_open(
230        &_Partition_Information,
231        the_packet->name,
232        the_packet->Prefix.id,
233        true
234      );
235
236      _MPCI_Return_packet( the_packet_prefix );
237      break;
238
239    case PARTITION_MP_ANNOUNCE_DELETE:
240
241      _Objects_MP_Close( &_Partition_Information, the_packet->Prefix.id );
242
243      _MPCI_Return_packet( the_packet_prefix );
244      break;
245
246    case PARTITION_MP_EXTRACT_PROXY:
247
248      the_thread = _Thread_MP_Find_proxy( the_packet->proxy_id );
249
250      if ( ! _Thread_Is_null( the_thread ) )
251         _Thread_queue_Extract( the_thread );
252
253      _MPCI_Return_packet( the_packet_prefix );
254      break;
255
256    case PARTITION_MP_GET_BUFFER_REQUEST:
257
258      the_packet->Prefix.return_code = rtems_partition_get_buffer(
259        the_packet->Prefix.id,
260        &the_packet->buffer
261      );
262
263      _Partition_MP_Send_response_packet(
264        PARTITION_MP_GET_BUFFER_RESPONSE,
265        the_packet->Prefix.id,
266        _Thread_Executing
267      );
268      break;
269
270    case PARTITION_MP_GET_BUFFER_RESPONSE:
271
272      the_thread = _MPCI_Process_response( the_packet_prefix );
273
274      *(void **)the_thread->Wait.return_argument = the_packet->buffer;
275
276      _MPCI_Return_packet( the_packet_prefix );
277      break;
278
279    case PARTITION_MP_RETURN_BUFFER_REQUEST:
280
281      the_packet->Prefix.return_code = rtems_partition_return_buffer(
282        the_packet->Prefix.id,
283        the_packet->buffer
284      );
285
286      _Partition_MP_Send_response_packet(
287        PARTITION_MP_RETURN_BUFFER_RESPONSE,
288        the_packet->Prefix.id,
289        _Thread_Executing
290      );
291      break;
292
293    case PARTITION_MP_RETURN_BUFFER_RESPONSE:
294
295      the_thread = _MPCI_Process_response( the_packet_prefix );
296
297      _MPCI_Return_packet( the_packet_prefix );
298      break;
299
300  }
301}
302
303/*
304 *  _Partition_MP_Send_object_was_deleted
305 *
306 *  This routine is not needed by the Partition since a partition
307 *  cannot be deleted when buffers are in use.
308 *
309 */
310
311/*
312 *  _Partition_MP_Send_extract_proxy
313 *
314 */
315
316void _Partition_MP_Send_extract_proxy (
317  Thread_Control *the_thread,
318  Objects_Id      id
319)
320{
321  _Partition_MP_Send_process_packet(
322    PARTITION_MP_EXTRACT_PROXY,
323    id,
324    (rtems_name) 0,
325    the_thread->Object.id
326  );
327
328}
329
330/* end of file */
Note: See TracBrowser for help on using the repository browser.