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

4.115
Last change on this file since d689de0 was d689de0, checked in by Sebastian Huber <sebastian.huber@…>, on 09/09/11 at 10:57:58

2011-09-09 Sebastian Huber <sebastian.huber@…>

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