1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Event MP Support |
---|
5 | * @ingroup ClassicEventMP |
---|
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/eventimpl.h> |
---|
22 | #include <rtems/rtems/statusimpl.h> |
---|
23 | #include <rtems/score/threadimpl.h> |
---|
24 | #include <rtems/score/statesimpl.h> |
---|
25 | |
---|
26 | /** |
---|
27 | * The following enumerated type defines the list of |
---|
28 | * remote event operations. |
---|
29 | */ |
---|
30 | typedef enum { |
---|
31 | EVENT_MP_SEND_REQUEST = 0, |
---|
32 | EVENT_MP_SEND_RESPONSE = 1 |
---|
33 | } Event_MP_Remote_operations; |
---|
34 | |
---|
35 | /** |
---|
36 | * The following data structure defines the packet used to perform |
---|
37 | * remote event operations. |
---|
38 | */ |
---|
39 | typedef struct { |
---|
40 | rtems_packet_prefix Prefix; |
---|
41 | Event_MP_Remote_operations operation; |
---|
42 | rtems_event_set event_in; |
---|
43 | } Event_MP_Packet; |
---|
44 | |
---|
45 | RTEMS_STATIC_ASSERT( |
---|
46 | sizeof(Event_MP_Packet) <= MP_PACKET_MINIMUM_PACKET_SIZE, |
---|
47 | Event_MP_Packet |
---|
48 | ); |
---|
49 | |
---|
50 | static Event_MP_Packet *_Event_MP_Get_packet( Objects_Id id ) |
---|
51 | { |
---|
52 | if ( !_Thread_MP_Is_remote( id ) ) { |
---|
53 | return NULL; |
---|
54 | } |
---|
55 | |
---|
56 | return (Event_MP_Packet *) _MPCI_Get_packet(); |
---|
57 | } |
---|
58 | |
---|
59 | rtems_status_code _Event_MP_Send( |
---|
60 | rtems_id id, |
---|
61 | rtems_event_set event_in |
---|
62 | ) |
---|
63 | { |
---|
64 | Event_MP_Packet *the_packet; |
---|
65 | Status_Control status; |
---|
66 | |
---|
67 | the_packet = _Event_MP_Get_packet( id ); |
---|
68 | if ( the_packet == NULL ) { |
---|
69 | return RTEMS_INVALID_ID; |
---|
70 | } |
---|
71 | |
---|
72 | the_packet->Prefix.the_class = MP_PACKET_EVENT; |
---|
73 | the_packet->Prefix.length = sizeof ( *the_packet ); |
---|
74 | the_packet->Prefix.to_convert = sizeof ( *the_packet ); |
---|
75 | the_packet->operation = EVENT_MP_SEND_REQUEST; |
---|
76 | the_packet->Prefix.id = id; |
---|
77 | the_packet->event_in = event_in; |
---|
78 | |
---|
79 | status = _MPCI_Send_request_packet( |
---|
80 | _Objects_Get_node( id ), |
---|
81 | &the_packet->Prefix, |
---|
82 | STATES_READY |
---|
83 | ); |
---|
84 | return _Status_Get( status ); |
---|
85 | } |
---|
86 | |
---|
87 | static void _Event_MP_Send_response_packet ( |
---|
88 | Event_MP_Remote_operations operation, |
---|
89 | Thread_Control *the_thread |
---|
90 | ) |
---|
91 | { |
---|
92 | Event_MP_Packet *the_packet; |
---|
93 | |
---|
94 | switch ( operation ) { |
---|
95 | |
---|
96 | case EVENT_MP_SEND_RESPONSE: |
---|
97 | |
---|
98 | the_packet = ( Event_MP_Packet *) the_thread->receive_packet; |
---|
99 | |
---|
100 | /* |
---|
101 | * The packet being returned already contains the class, length, and |
---|
102 | * to_convert fields, therefore they are not set in this routine. |
---|
103 | */ |
---|
104 | the_packet->operation = operation; |
---|
105 | the_packet->Prefix.id = the_packet->Prefix.source_tid; |
---|
106 | |
---|
107 | _MPCI_Send_response_packet( |
---|
108 | _Objects_Get_node( the_packet->Prefix.source_tid ), |
---|
109 | &the_packet->Prefix |
---|
110 | ); |
---|
111 | break; |
---|
112 | |
---|
113 | case EVENT_MP_SEND_REQUEST: |
---|
114 | break; |
---|
115 | |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | void _Event_MP_Process_packet ( |
---|
120 | rtems_packet_prefix *the_packet_prefix |
---|
121 | ) |
---|
122 | { |
---|
123 | Event_MP_Packet *the_packet; |
---|
124 | |
---|
125 | the_packet = (Event_MP_Packet *) the_packet_prefix; |
---|
126 | |
---|
127 | switch ( the_packet->operation ) { |
---|
128 | |
---|
129 | case EVENT_MP_SEND_REQUEST: |
---|
130 | |
---|
131 | the_packet->Prefix.return_code = rtems_event_send( |
---|
132 | the_packet->Prefix.id, |
---|
133 | the_packet->event_in |
---|
134 | ); |
---|
135 | |
---|
136 | _Event_MP_Send_response_packet( |
---|
137 | EVENT_MP_SEND_RESPONSE, |
---|
138 | _Thread_Executing |
---|
139 | ); |
---|
140 | break; |
---|
141 | |
---|
142 | case EVENT_MP_SEND_RESPONSE: { |
---|
143 | _MPCI_Process_response( the_packet_prefix ); |
---|
144 | _MPCI_Return_packet( the_packet_prefix ); |
---|
145 | |
---|
146 | break; |
---|
147 | } |
---|
148 | |
---|
149 | } |
---|
150 | } |
---|
151 | |
---|
152 | /* |
---|
153 | * _Event_MP_Send_object_was_deleted |
---|
154 | * |
---|
155 | * This subprogram is not needed since there are no objects |
---|
156 | * deleted by this manager. |
---|
157 | * |
---|
158 | */ |
---|
159 | |
---|
160 | /* |
---|
161 | * _Event_MP_Send_extract_proxy |
---|
162 | * |
---|
163 | * This subprogram is not needed since there are no objects |
---|
164 | * deleted by this manager. |
---|
165 | * |
---|
166 | */ |
---|
167 | |
---|
168 | /* end of file */ |
---|