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