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

5
Last change on this file since ef6f8a83 was e38a92b, checked in by Sebastian Huber <sebastian.huber@…>, on 05/02/16 at 04:30:49

mpci: Make _*_MP_Get_packet() static

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