source: rtems/cpukit/score/src/mpci.c @ 5072b07

4.104.114.84.95
Last change on this file since 5072b07 was 7f6a24ab, checked in by Joel Sherrill <joel.sherrill@…>, on 08/28/95 at 15:30:29

Added unused priority ceiling parameter to rtems_semaphore_create.

Rearranged code to created thread handler routines to initialize,
start, restart, and "close/delete" a thread.

Made internal threads their own object class. This now uses the
thread support routines for starting and initializing a thread.

Insured deleted tasks are freed to the Inactive pool associated with the
correct Information block.

Added an RTEMS API specific data area to the thread control block.

Beginnings of removing the word "rtems" from the core.

  • 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    OBJECTS_NO_CLASS,
40    THREAD_QUEUE_DISCIPLINE_FIFO,
41    STATES_WAITING_FOR_RPC_REPLY,
42    NULL
43  );
44}
45
46/*PAGE
47 *
48 *  _MPCI_Initialization
49 *
50 *  This subprogram initializes the MPCI driver by
51 *  invoking the user provided MPCI initialization callout.
52 */
53
54void _MPCI_Initialization ( void )
55{
56  (*_Configuration_MPCI_table->initialization)(
57    _Configuration_Table,
58    &_CPU_Table,
59    _Configuration_MP_table
60  );
61}
62
63/*PAGE
64 *
65 *  _MPCI_Get_packet
66 *
67 *  This subprogram obtains a packet by invoking the user provided
68 *  MPCI get packet callout.
69 */
70
71rtems_packet_prefix *_MPCI_Get_packet ( void )
72{
73  rtems_packet_prefix  *the_packet;
74
75  (*_Configuration_MPCI_table->get_packet)( &the_packet );
76
77  if ( the_packet == NULL )
78    rtems_fatal_error_occurred( RTEMS_UNSATISFIED );
79
80  /*
81   *  Put in a default timeout that will be used for
82   *  all packets that do not otherwise have a timeout.
83   */
84
85  the_packet->timeout = MPCI_DEFAULT_TIMEOUT;
86
87  return the_packet;
88}
89
90/*PAGE
91 *
92 *  _MPCI_Return_packet
93 *
94 *  This subprogram returns a packet by invoking the user provided
95 *  MPCI return packet callout.
96 */
97
98void _MPCI_Return_packet (
99  rtems_packet_prefix   *the_packet
100)
101{
102  (*_Configuration_MPCI_table->return_packet)( the_packet );
103}
104
105/*PAGE
106 *
107 *  _MPCI_Send_process_packet
108 *
109 *  This subprogram sends a process packet by invoking the user provided
110 *  MPCI send callout.
111 */
112
113void _MPCI_Send_process_packet (
114  unsigned32          destination,
115  rtems_packet_prefix   *the_packet
116)
117{
118  the_packet->source_tid = _Thread_Executing->Object.id;
119  the_packet->to_convert =
120     ( the_packet->to_convert - sizeof(rtems_packet_prefix) ) /
121       sizeof(unsigned32);
122
123  (*_Configuration_MPCI_table->send_packet)( destination, the_packet );
124}
125
126/*PAGE
127 *
128 *  _MPCI_Send_request_packet
129 *
130 *  This subprogram sends a request packet by invoking the user provided
131 *  MPCI send callout.
132 */
133
134rtems_status_code _MPCI_Send_request_packet (
135  unsigned32          destination,
136  rtems_packet_prefix   *the_packet,
137  States_Control      extra_state
138)
139{
140  the_packet->source_tid      = _Thread_Executing->Object.id;
141  the_packet->source_priority = _Thread_Executing->current_priority;
142  the_packet->to_convert =
143     ( the_packet->to_convert - sizeof(rtems_packet_prefix) ) /
144       sizeof(unsigned32);
145
146  _Thread_Executing->Wait.id = the_packet->id;
147
148  _Thread_Executing->Wait.queue = &_MPCI_Remote_blocked_threads;
149
150  _Thread_Disable_dispatch();
151
152    (*_Configuration_MPCI_table->send_packet)( destination, the_packet );
153
154    _MPCI_Remote_blocked_threads.sync = TRUE;
155
156    /*
157     *  See if we need a default timeout
158     */
159
160    if (the_packet->timeout == MPCI_DEFAULT_TIMEOUT)
161        the_packet->timeout = _Configuration_MPCI_table->default_timeout;
162
163    _Thread_queue_Enqueue( &_MPCI_Remote_blocked_threads, the_packet->timeout );
164
165    _Thread_Executing->current_state =
166      _States_Set( extra_state, _Thread_Executing->current_state );
167
168  _Thread_Enable_dispatch();
169
170  return _Thread_Executing->Wait.return_code;
171}
172
173/*PAGE
174 *
175 *  _MPCI_Send_response_packet
176 *
177 *  This subprogram sends a response packet by invoking the user provided
178 *  MPCI send callout.
179 */
180
181void _MPCI_Send_response_packet (
182  unsigned32          destination,
183  rtems_packet_prefix   *the_packet
184)
185{
186  the_packet->source_tid = _Thread_Executing->Object.id;
187
188  (*_Configuration_MPCI_table->send_packet)( destination, the_packet );
189}
190
191/*PAGE
192 *
193 *  _MPCI_Receive_packet
194 *
195 *  This subprogram receives a packet by invoking the user provided
196 *  MPCI receive callout.
197 */
198
199rtems_packet_prefix  *_MPCI_Receive_packet ( void )
200{
201  rtems_packet_prefix  *the_packet;
202
203  (*_Configuration_MPCI_table->receive_packet)( &the_packet );
204
205  return the_packet;
206}
207
208/*PAGE
209 *
210 *  _MPCI_Process_response
211 *
212 *  This subprogram obtains a packet by invoking the user provided
213 *  MPCI get packet callout.
214 */
215
216Thread_Control *_MPCI_Process_response (
217  rtems_packet_prefix  *the_packet
218)
219{
220  Thread_Control    *the_thread;
221  Objects_Locations  location;
222
223  the_thread = _Thread_Get( the_packet->id, &location );
224  switch ( location ) {
225    case OBJECTS_ERROR:
226    case OBJECTS_REMOTE:
227      the_thread = NULL;          /* IMPOSSIBLE */
228      break;
229    case OBJECTS_LOCAL:
230      _Thread_queue_Extract( &_MPCI_Remote_blocked_threads, the_thread );
231      the_thread->Wait.return_code = the_packet->return_code;
232      _Thread_Unnest_dispatch();
233    break;
234  }
235
236  return the_thread;
237}
238
239/* end of file */
Note: See TracBrowser for help on using the repository browser.