source: rtems/cpukit/score/src/mpci.c @ ac7d5ef0

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on May 11, 1995 at 5:39:37 PM

Initial revision

  • Property mode set to 100644
File size: 5.3 KB
Line 
1/*
2 *  Multiprocessing Communications Interface (MPCI) Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
6 *  On-Line Applications Research Corporation (OAR).
7 *  All rights assigned to U.S. Government, 1994.
8 *
9 *  This material may be reproduced by or for the U.S. Government pursuant
10 *  to the copyright license under the clause at DFARS 252.227-7013.  This
11 *  notice must appear in all copies of this file and its derivatives.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/config.h>
18#include <rtems/cpu.h>
19#include <rtems/fatal.h>
20#include <rtems/mpci.h>
21#include <rtems/mppkt.h>
22#include <rtems/states.h>
23#include <rtems/thread.h>
24#include <rtems/threadq.h>
25#include <rtems/tqdata.h>
26#include <rtems/watchdog.h>
27
28/*PAGE
29 *
30 *  _MPCI_Handler_initialization
31 *
32 *  This subprogram performs the initialization necessary for this handler.
33 */
34
35void _MPCI_Handler_initialization ( void )
36{
37  _Thread_queue_Initialize(
38    &_MPCI_Remote_blocked_threads,
39    RTEMS_FIFO,
40    STATES_WAITING_FOR_RPC_REPLY
41  );
42}
43
44/*PAGE
45 *
46 *  _MPCI_Initialization
47 *
48 *  This subprogram initializes the MPCI driver by
49 *  invoking the user provided MPCI initialization callout.
50 */
51
52void _MPCI_Initialization ( void )
53{
54  (*_Configuration_MPCI_table->initialization)(
55    _Configuration_Table,
56    &_CPU_Table,
57    _Configuration_MP_table
58  );
59}
60
61/*PAGE
62 *
63 *  _MPCI_Get_packet
64 *
65 *  This subprogram obtains a packet by invoking the user provided
66 *  MPCI get packet callout.
67 */
68
69rtems_packet_prefix *_MPCI_Get_packet ( void )
70{
71  rtems_packet_prefix  *the_packet;
72
73  (*_Configuration_MPCI_table->get_packet)( &the_packet );
74
75  if ( the_packet == NULL )
76    rtems_fatal_error_occurred( RTEMS_UNSATISFIED );
77
78  /*
79   *  Put in a default timeout that will be used for
80   *  all packets that do not otherwise have a timeout.
81   */
82
83  the_packet->timeout = MPCI_DEFAULT_TIMEOUT;
84
85  return the_packet;
86}
87
88/*PAGE
89 *
90 *  _MPCI_Return_packet
91 *
92 *  This subprogram returns a packet by invoking the user provided
93 *  MPCI return packet callout.
94 */
95
96void _MPCI_Return_packet (
97  rtems_packet_prefix   *the_packet
98)
99{
100  (*_Configuration_MPCI_table->return_packet)( the_packet );
101}
102
103/*PAGE
104 *
105 *  _MPCI_Send_process_packet
106 *
107 *  This subprogram sends a process packet by invoking the user provided
108 *  MPCI send callout.
109 */
110
111void _MPCI_Send_process_packet (
112  unsigned32          destination,
113  rtems_packet_prefix   *the_packet
114)
115{
116  the_packet->source_tid = _Thread_Executing->Object.id;
117  the_packet->to_convert =
118     ( the_packet->to_convert - sizeof(rtems_packet_prefix) ) /
119       sizeof(unsigned32);
120
121  (*_Configuration_MPCI_table->send_packet)( destination, the_packet );
122}
123
124/*PAGE
125 *
126 *  _MPCI_Send_request_packet
127 *
128 *  This subprogram sends a request packet by invoking the user provided
129 *  MPCI send callout.
130 */
131
132rtems_status_code _MPCI_Send_request_packet (
133  unsigned32          destination,
134  rtems_packet_prefix   *the_packet,
135  States_Control      extra_state
136)
137{
138  the_packet->source_tid      = _Thread_Executing->Object.id;
139  the_packet->source_priority = _Thread_Executing->current_priority;
140  the_packet->to_convert =
141     ( the_packet->to_convert - sizeof(rtems_packet_prefix) ) /
142       sizeof(unsigned32);
143
144  _Thread_Executing->Wait.id = the_packet->id;
145
146  _Thread_Executing->Wait.queue = &_MPCI_Remote_blocked_threads;
147
148  _Thread_Disable_dispatch();
149
150    (*_Configuration_MPCI_table->send_packet)( destination, the_packet );
151
152    _MPCI_Remote_blocked_threads.sync = TRUE;
153
154    /*
155     *  See if we need a default timeout
156     */
157
158    if (the_packet->timeout == MPCI_DEFAULT_TIMEOUT)
159        the_packet->timeout = _Configuration_MPCI_table->default_timeout;
160
161    _Thread_queue_Enqueue( &_MPCI_Remote_blocked_threads, the_packet->timeout );
162
163    _Thread_Executing->current_state =
164      _States_Set( extra_state, _Thread_Executing->current_state );
165
166  _Thread_Enable_dispatch();
167
168  return _Thread_Executing->Wait.return_code;
169}
170
171/*PAGE
172 *
173 *  _MPCI_Send_response_packet
174 *
175 *  This subprogram sends a response packet by invoking the user provided
176 *  MPCI send callout.
177 */
178
179void _MPCI_Send_response_packet (
180  unsigned32          destination,
181  rtems_packet_prefix   *the_packet
182)
183{
184  the_packet->source_tid = _Thread_Executing->Object.id;
185
186  (*_Configuration_MPCI_table->send_packet)( destination, the_packet );
187}
188
189/*PAGE
190 *
191 *  _MPCI_Receive_packet
192 *
193 *  This subprogram receives a packet by invoking the user provided
194 *  MPCI receive callout.
195 */
196
197rtems_packet_prefix  *_MPCI_Receive_packet ( void )
198{
199  rtems_packet_prefix  *the_packet;
200
201  (*_Configuration_MPCI_table->receive_packet)( &the_packet );
202
203  return the_packet;
204}
205
206/*PAGE
207 *
208 *  _MPCI_Process_response
209 *
210 *  This subprogram obtains a packet by invoking the user provided
211 *  MPCI get packet callout.
212 */
213
214Thread_Control *_MPCI_Process_response (
215  rtems_packet_prefix  *the_packet
216)
217{
218  Thread_Control    *the_thread;
219  Objects_Locations  location;
220
221  the_thread = _Thread_Get( the_packet->id, &location );
222  switch ( location ) {
223    case OBJECTS_ERROR:
224    case OBJECTS_REMOTE:
225      the_thread = NULL;          /* IMPOSSIBLE */
226      break;
227    case OBJECTS_LOCAL:
228      _Thread_queue_Extract( &_MPCI_Remote_blocked_threads, the_thread );
229      the_thread->Wait.return_code = the_packet->return_code;
230      _Thread_Unnest_dispatch();
231    break;
232  }
233
234  return the_thread;
235}
236
237/* end of file */
Note: See TracBrowser for help on using the repository browser.