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

4.115
Last change on this file since e6b31b27 was f5d6c8b, checked in by Sebastian Huber <sebastian.huber@…>, on 04/27/15 at 14:25:52

score: Delete Thread_queue_Control::timeout_status

Use a parameter for _Thread_queue_Enqueue() instead to reduce memory
usage.

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