source: rtems/cpukit/rtems/src/signalmp.c

Last change on this file was b3b6d21e, checked in by Joel Sherrill <joel@…>, on 02/16/22 at 22:28:59

cpukit/rtems/src/[s-z]*.c: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSImplClassicSignalMP
7 *
8 * @brief This source file contains the implementation to support the Signal
9 *   Manager in multiprocessing (MP) configurations.
10 */
11
12/*
13 *  COPYRIGHT (c) 1989-2008.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 *    notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 *    notice, this list of conditions and the following disclaimer in the
23 *    documentation and/or other materials provided with the distribution.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifdef HAVE_CONFIG_H
39#include "config.h"
40#endif
41
42#include <rtems/rtems/signalimpl.h>
43#include <rtems/rtems/optionsimpl.h>
44#include <rtems/rtems/statusimpl.h>
45#include <rtems/score/statesimpl.h>
46#include <rtems/score/threadimpl.h>
47#include <rtems/score/threadqimpl.h>
48
49/**
50 *  The following enumerated type defines the list of
51 *  remote signal operations.
52 */
53typedef enum {
54  SIGNAL_MP_SEND_REQUEST  = 0,
55  SIGNAL_MP_SEND_RESPONSE = 1
56}   Signal_MP_Remote_operations;
57
58/**
59 *  The following data structure defines the packet used to perform
60 *  remote signal operations.
61 */
62typedef struct {
63  rtems_packet_prefix          Prefix;
64  Signal_MP_Remote_operations  operation;
65  rtems_signal_set             signal_set;
66}   Signal_MP_Packet;
67
68RTEMS_STATIC_ASSERT(
69  sizeof(Signal_MP_Packet) <= MP_PACKET_MINIMUM_PACKET_SIZE,
70  Signal_MP_Packet
71);
72
73static Signal_MP_Packet *_Signal_MP_Get_packet( Objects_Id id )
74{
75  if ( !_Thread_MP_Is_remote( id ) ) {
76    return NULL;
77  }
78
79  return (Signal_MP_Packet *) _MPCI_Get_packet();
80}
81
82/*
83 *  _Signal_MP_Send_process_packet
84 *
85 *  This subprogram is not needed since there are no process
86 *  packets to be sent by this manager.
87 *
88 */
89
90rtems_status_code _Signal_MP_Send(
91  rtems_id         id,
92  rtems_signal_set signal_set
93)
94{
95  Signal_MP_Packet *the_packet;
96  Status_Control    status;
97
98  the_packet = _Signal_MP_Get_packet( id );
99  if ( the_packet == NULL ) {
100    return RTEMS_INVALID_ID;
101  }
102
103  the_packet->Prefix.the_class  = MP_PACKET_SIGNAL;
104  the_packet->Prefix.length     = sizeof( *the_packet );
105  the_packet->Prefix.to_convert = sizeof( *the_packet );
106  the_packet->operation         = SIGNAL_MP_SEND_REQUEST;
107  the_packet->Prefix.id         = id;
108  the_packet->signal_set        = signal_set;
109
110  status = _MPCI_Send_request_packet(
111    _Objects_Get_node( id ),
112    &the_packet->Prefix,
113    STATES_READY
114  );
115  return _Status_Get( status );
116}
117
118static void _Signal_MP_Send_response_packet (
119  Signal_MP_Remote_operations  operation,
120  Thread_Control              *the_thread
121)
122{
123  Signal_MP_Packet *the_packet;
124
125  switch ( operation ) {
126
127    case SIGNAL_MP_SEND_RESPONSE:
128
129      the_packet = ( Signal_MP_Packet *) the_thread->receive_packet;
130
131/*
132 *  The packet being returned already contains the class, length, and
133 *  to_convert fields, therefore they are not set in this routine.
134 */
135      the_packet->operation = operation;
136      the_packet->Prefix.id = the_packet->Prefix.source_tid;
137
138      _MPCI_Send_response_packet(
139        _Objects_Get_node( the_packet->Prefix.source_tid ),
140        &the_packet->Prefix
141      );
142      break;
143
144    case SIGNAL_MP_SEND_REQUEST:
145      break;
146
147  }
148}
149
150void _Signal_MP_Process_packet (
151  rtems_packet_prefix  *the_packet_prefix
152)
153{
154  Signal_MP_Packet *the_packet;
155
156  the_packet = (Signal_MP_Packet *) the_packet_prefix;
157
158  switch ( the_packet->operation ) {
159
160    case SIGNAL_MP_SEND_REQUEST:
161
162      the_packet->Prefix.return_code = rtems_signal_send(
163        the_packet->Prefix.id,
164        the_packet->signal_set
165      );
166
167      _Signal_MP_Send_response_packet(
168        SIGNAL_MP_SEND_RESPONSE,
169        _Thread_Executing
170      );
171      break;
172
173    case SIGNAL_MP_SEND_RESPONSE:
174
175      _MPCI_Process_response( the_packet_prefix );
176      _MPCI_Return_packet( the_packet_prefix );
177      break;
178
179  }
180}
181
182/*
183 *  _Signal_MP_Send_object_was_deleted
184 *
185 *  This subprogram is not needed since there are no objects
186 *  deleted by this manager.
187 *
188 */
189
190/*
191 *  _Signal_MP_Send_extract_proxy
192 *
193 *  This subprogram is not needed since there are no objects
194 *  deleted by this manager.
195 *
196 */
197
198/* end of file */
Note: See TracBrowser for help on using the repository browser.