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

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

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

Updates #3053.

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSImplClassicEventMP
7 *
8 * @brief This source file contains the implementation to support the Event
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/eventimpl.h>
43#include <rtems/rtems/statusimpl.h>
44#include <rtems/score/threadimpl.h>
45#include <rtems/score/statesimpl.h>
46
47/**
48 *  The following enumerated type defines the list of
49 *  remote event operations.
50 */
51typedef enum {
52  EVENT_MP_SEND_REQUEST  =  0,
53  EVENT_MP_SEND_RESPONSE =  1
54}   Event_MP_Remote_operations;
55
56/**
57 *  The following data structure defines the packet used to perform
58 *  remote event operations.
59 */
60typedef struct {
61  rtems_packet_prefix         Prefix;
62  Event_MP_Remote_operations  operation;
63  rtems_event_set             event_in;
64}   Event_MP_Packet;
65
66RTEMS_STATIC_ASSERT(
67  sizeof(Event_MP_Packet) <= MP_PACKET_MINIMUM_PACKET_SIZE,
68  Event_MP_Packet
69);
70
71static Event_MP_Packet *_Event_MP_Get_packet( Objects_Id id )
72{
73  if ( !_Thread_MP_Is_remote( id ) ) {
74    return NULL;
75  }
76
77  return (Event_MP_Packet *) _MPCI_Get_packet();
78}
79
80rtems_status_code _Event_MP_Send(
81  rtems_id        id,
82  rtems_event_set event_in
83)
84{
85  Event_MP_Packet *the_packet;
86  Status_Control   status;
87
88  the_packet = _Event_MP_Get_packet( id );
89  if ( the_packet == NULL ) {
90    return RTEMS_INVALID_ID;
91  }
92
93  the_packet->Prefix.the_class  = MP_PACKET_EVENT;
94  the_packet->Prefix.length     = sizeof ( *the_packet );
95  the_packet->Prefix.to_convert = sizeof ( *the_packet );
96  the_packet->operation         = EVENT_MP_SEND_REQUEST;
97  the_packet->Prefix.id         = id;
98  the_packet->event_in          = event_in;
99
100  status = _MPCI_Send_request_packet(
101    _Objects_Get_node( id ),
102    &the_packet->Prefix,
103    STATES_READY
104  );
105  return _Status_Get( status );
106}
107
108static void _Event_MP_Send_response_packet (
109  Event_MP_Remote_operations  operation,
110  Thread_Control             *the_thread
111)
112{
113  Event_MP_Packet *the_packet;
114
115  switch ( operation ) {
116
117    case EVENT_MP_SEND_RESPONSE:
118
119      the_packet = ( Event_MP_Packet *) the_thread->receive_packet;
120
121/*
122 *  The packet being returned already contains the class, length, and
123 *  to_convert fields, therefore they are not set in this routine.
124 */
125      the_packet->operation = operation;
126      the_packet->Prefix.id = the_packet->Prefix.source_tid;
127
128      _MPCI_Send_response_packet(
129        _Objects_Get_node( the_packet->Prefix.source_tid ),
130        &the_packet->Prefix
131      );
132      break;
133
134    case EVENT_MP_SEND_REQUEST:
135      break;
136
137  }
138}
139
140void _Event_MP_Process_packet (
141  rtems_packet_prefix  *the_packet_prefix
142)
143{
144  Event_MP_Packet *the_packet;
145
146  the_packet = (Event_MP_Packet *) the_packet_prefix;
147
148  switch ( the_packet->operation ) {
149
150    case EVENT_MP_SEND_REQUEST:
151
152      the_packet->Prefix.return_code = rtems_event_send(
153        the_packet->Prefix.id,
154        the_packet->event_in
155      );
156
157      _Event_MP_Send_response_packet(
158        EVENT_MP_SEND_RESPONSE,
159        _Thread_Executing
160      );
161      break;
162
163    case EVENT_MP_SEND_RESPONSE: {
164      _MPCI_Process_response( the_packet_prefix );
165      _MPCI_Return_packet( the_packet_prefix );
166
167      break;
168    }
169
170  }
171}
172
173/*
174 *  _Event_MP_Send_object_was_deleted
175 *
176 *  This subprogram is not needed since there are no objects
177 *  deleted by this manager.
178 *
179 */
180
181/*
182 *  _Event_MP_Send_extract_proxy
183 *
184 *  This subprogram is not needed since there are no objects
185 *  deleted by this manager.
186 *
187 */
188
189/* end of file */
Note: See TracBrowser for help on using the repository browser.