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