47 #define KERNEL_EVENT_ISI 0x00 |
47 #define KERNEL_EVENT_ISI 0x00 |
48 // Power Handler Power Down |
48 // Power Handler Power Down |
49 #define KERNEL_EVENT_PWR_HANDLER 0x01 |
49 #define KERNEL_EVENT_PWR_HANDLER 0x01 |
50 // IAD Modem connection lost |
50 // IAD Modem connection lost |
51 #define KERNEL_EVENT_MODEM_CONNECTION_NOT_OK 0x02 |
51 #define KERNEL_EVENT_MODEM_CONNECTION_NOT_OK 0x02 |
|
52 // Get the type of the event to be sent to kernel side client |
|
53 #define KERNEL_GET_EVENT_TYPE 0x03 |
|
54 // Used through DMC kernel IF |
|
55 #define KERNEL_IF_GET_STARTUP_MODE 0x04 |
|
56 // Get hidden reset status, used through DMC kernel IF |
|
57 #define KERNEL_IF_GET_HIDDEN_RESET_STATUS 0x05 |
|
58 // Generate reset requested from kernel side |
|
59 #define KERNEL_IF_GENERATE_RESET 0x06 |
|
60 // Power off the device |
|
61 #define KERNEL_IF_POWER_OFF 0x07 |
52 // Used for detecting the event type |
62 // Used for detecting the event type |
53 #define KERNEL_LAST_KERNEL_EVENT KERNEL_EVENT_MODEM_CONNECTION_NOT_OK |
63 #define KERNEL_LAST_KERNEL_EVENT KERNEL_IF_POWER_OFF |
54 // Get target startup mode |
64 // Get target startup mode |
55 #define USER_GET_TARGET_STARTUP_MODE 0x03 |
65 #define USER_GET_TARGET_STARTUP_MODE 0x08 |
56 // Get target startup mode |
66 // Generate reset requested from user side |
57 #define USER_GENERATE_RESET 0x04 |
67 #define USER_GENERATE_RESET 0x09 |
58 // Get target startup mode |
68 // Power off the device |
59 #define USER_POWER_OFF 0x05 |
69 #define USER_POWER_OFF 0x0A |
60 // Get target startup mode |
70 // Get hidden reset status |
61 #define USER_GET_HIDDEN_RESET_STATUS 0x07 |
71 #define USER_GET_HIDDEN_RESET_STATUS 0x0B |
62 // Get the type of the event to be sent to user side client |
72 // Get the type of the event to be sent to user side client |
63 #define USER_GET_EVENT_TYPE 0x08 |
73 #define USER_GET_EVENT_TYPE 0x0C |
64 #define LAST_EVENT (USER_GET_EVENT_TYPE + 1) |
74 #define LAST_EVENT (USER_GET_EVENT_TYPE + 1) |
65 #define NO_EVENTS_DEFINED 0x00 |
75 #define NO_EVENTS_DEFINED 0x00 |
66 |
76 |
67 |
77 |
68 /** |
78 /** |
72 * |
82 * |
73 * Event types are needed in case of Modem or PC SW |
83 * Event types are needed in case of Modem or PC SW |
74 * orginated controlled or uncontrolled power off / reset. |
84 * orginated controlled or uncontrolled power off / reset. |
75 */ |
85 */ |
76 // Modem or PC SW orginated power off. |
86 // Modem or PC SW orginated power off. |
77 #define USER_CLIENT_POWER_OFF_EVENT 0x01 |
87 #define DMC_CLIENT_POWER_OFF_EVENT 0x01 |
78 // Modem or PC SW orginated resest. |
88 // Modem or PC SW orginated resest. |
79 #define USER_CLIENT_RESET_EVENT 0x02 |
89 #define DMC_CLIENT_RESET_EVENT 0x02 |
80 // No event requested |
90 // No event requested |
81 #define USER_CLIENT_NO_EVENT 0x00 |
91 #define DMC_CLIENT_NO_EVENT 0x00 |
82 |
92 |
83 // MACROS |
93 |
84 // DATA TYPES |
94 /** |
|
95 * CLIENT TYPE: |
|
96 * A type of the client that request services. |
|
97 */ |
|
98 #define DMC_USER_BIT 0x01 |
|
99 #define DMC_KERNEL_BIT 0x02 |
|
100 |
|
101 // MACROS |
|
102 // DATA TYPES |
85 // EXTERNAL DATA STRUCTURES |
103 // EXTERNAL DATA STRUCTURES |
86 // FUNCTION PROTOTYPES |
104 // FUNCTION PROTOTYPES |
87 // FORWARD DECLARATIONS |
105 // FORWARD DECLARATIONS |
88 class DDmcExtension; |
106 class DDmcExtension; |
89 class DMutex; |
107 class DMutex; |
|
108 class TDfc; |
90 |
109 |
91 NONSHARABLE_CLASS(DmcEvHandApeCent) |
110 NONSHARABLE_CLASS(DmcEvHandApeCent) |
92 { |
111 { |
93 public: // Event handler new public functions |
112 public: // Event handler new public functions |
94 |
113 |
95 /** |
114 /** |
96 * Init the event handler |
115 * Init the event handler |
97 * |
116 * |
98 * @param *aDmcExt A pointer to the DMC kernel extension. |
117 * @param *aDmcExt A pointer to the DMC kernel extension. |
99 * @return None |
118 * @return None |
100 */ |
119 */ |
101 static void Init(DDmcExtension* const aDmcExt); |
120 static void Init(DDmcExtension* const aDmcExt); |
102 |
121 |
103 /** |
122 /** |
104 * Subscribe events. |
123 * Subscribe events. |
105 * |
124 * |
106 * @param *aUserEventDfcPtr A pointer to DMC logical device TDfc queue. |
125 * @param aTypeBitMask DMC_USER_BIT or/and DMC_KERNEL_BIT |
107 * @return None |
126 * @param *aReceiveEventDfcPtr A pointer to TDfc queue. |
108 */ |
127 * @return None |
109 static void SubscribeEvents(TDfc* const aUserEventDfcPtr); |
128 */ |
|
129 static void SubscribeEvents(const TUint8 aTypeBitMask, TDfc* const aReceiveEventDfcPtr); |
110 |
130 |
111 /** |
131 /** |
112 * Unsubscribe events. |
132 * Unsubscribe events. |
113 * |
133 * |
114 * @param *aUserEventDfcPtr A pointer to DMC logical device TDfc queue. |
134 * @param *aUserEventDfcPtr A pointer to DMC logical device TDfc queue. |
122 * |
142 * |
123 * @param aEventType Type of the message. A table "EVENTS" in the |
143 * @param aEventType Type of the message. A table "EVENTS" in the |
124 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
144 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
125 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
145 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
126 * @param *aUsrMsgPtr A pointer to a incoming user message. |
146 * @param *aUsrMsgPtr A pointer to a incoming user message. |
127 * @return KErrNone or one of the system wide error |
147 * @return KErrNone or one of the system wide error |
128 */ |
148 */ |
129 static TInt HandleEvent(const TUint8 aType, |
149 static TInt HandleEvent(const TUint8 aType, |
130 const TUint8* const aKernMsgPtr, |
150 TUint8* const aKernMsgPtr, |
131 TUint* const aUsrMsgPtr); |
151 TUint* const aUsrMsgPtr); |
132 |
152 |
133 private: // Event handler new private functions |
153 private: // Event handler new private functions |
134 |
154 |
135 /** |
155 /** |
150 * @return None |
170 * @return None |
151 */ |
171 */ |
152 inline static void Unlock(); |
172 inline static void Unlock(); |
153 |
173 |
154 /** |
174 /** |
155 * This function process an ANY-state. |
175 * This function process an ANY-state. |
156 * There are events, which always must be handled regardless of |
176 * There are events, which always must be handled regardless of |
157 * an ongoing transaction. These type of events are handled in the state ANY. |
177 * an ongoing transaction. These type of events are handled in the state ANY. |
158 * |
178 * |
159 * @param aEventType Type of the message. A table "EVENTS" in the |
179 * @param aEventType Type of the message. A table "EVENTS" in the |
160 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
180 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
161 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
181 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
162 * @param *aUsrMsgPtr A pointer to a incoming user message. |
182 * @param *aUsrMsgPtr A pointer to a incoming user message. |
163 * @return KErrNone or one of the system wide error |
183 * @return KErrNone or one of the system wide error |
164 */ |
184 */ |
165 static TInt StateAny(const TUint8 aEventType, |
185 static TInt StateAny(const TUint8 aEventType, |
166 const TUint8* const aKernMsgPtr, |
186 TUint8* const aKernMsgPtr, |
167 TUint* const aUsrMsgPtr); |
187 TUint* const aUsrMsgPtr); |
168 |
188 |
169 /** |
189 /** |
170 * This function process an IDLE-state. |
190 * This function process an IDLE-state. |
171 * IDLE-state is the only state in which a new transaction is started. |
191 * IDLE-state is the only state in which a new transaction is started. |
172 * |
192 * |
173 * @param aEventType Type of the message. A table "EVENTS" in the |
193 * @param aEventType Type of the message. A table "EVENTS" in the |
174 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
194 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
175 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
195 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
176 * @param *aUsrMsgPtr A pointer to a incoming user message. |
196 * @param *aUsrMsgPtr A pointer to a incoming user message. |
177 * @return KErrNone or one of the system wide error |
197 * @return KErrNone or one of the system wide error |
178 */ |
198 */ |
179 static TInt StateIdle(const TUint8 aEventType, |
199 static TInt StateIdle(const TUint8 aEventType, |
180 const TUint8* const aKernMsgPtr, |
200 const TUint8* const aKernMsgPtr, |
181 TUint* const aUsrMsgPtr); |
201 TUint* const aUsrMsgPtr); |
182 |
202 |
185 * |
205 * |
186 * @param aEventType Type of the message. A table "EVENTS" in the |
206 * @param aEventType Type of the message. A table "EVENTS" in the |
187 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
207 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
188 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
208 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
189 * @param *aUsrMsgPtr A pointer to a incoming user message. |
209 * @param *aUsrMsgPtr A pointer to a incoming user message. |
190 * @return KErrNone or one of the system wide error |
210 * @return KErrNone or one of the system wide error |
191 */ |
211 */ |
192 static TInt StateApePwrOff(const TUint8 aEventType, |
212 static TInt StateApePwrOff(const TUint8 aEventType, |
193 const TUint8* const aKernMsgPtr, |
213 const TUint8* const aKernMsgPtr, |
194 TUint* const aUsrMsgPtr); |
214 TUint* const aUsrMsgPtr); |
195 |
215 |
198 * |
218 * |
199 * @param aEventType Type of the message. A table "EVENTS" in the |
219 * @param aEventType Type of the message. A table "EVENTS" in the |
200 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
220 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
201 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
221 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
202 * @param *aUsrMsgPtr A pointer to a incoming user message. |
222 * @param *aUsrMsgPtr A pointer to a incoming user message. |
203 * @return KErrNone or one of the system wide error |
223 * @return KErrNone or one of the system wide error |
204 */ |
224 */ |
205 static TInt StateApeReset(const TUint8 aEventType, |
225 static TInt StateApeReset(const TUint8 aEventType, |
206 const TUint8* const aKernMsgPtr, |
226 const TUint8* const aKernMsgPtr, |
207 TUint* const aUsrMsgPtr); |
227 TUint* const aUsrMsgPtr); |
208 |
228 |
211 * |
231 * |
212 * @param aEventType Type of the message. A table "EVENTS" in the |
232 * @param aEventType Type of the message. A table "EVENTS" in the |
213 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
233 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
214 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
234 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
215 * @param *aUsrMsgPtr A pointer to a incoming user message. |
235 * @param *aUsrMsgPtr A pointer to a incoming user message. |
216 * @return KErrNone or one of the system wide error |
236 * @return KErrNone or one of the system wide error |
217 */ |
237 */ |
218 static TInt StateModemPwrOff(const TUint8 aEventType, |
238 static TInt StateModemPwrOff(const TUint8 aEventType, |
219 const TUint8* const aKernMsgPtr, |
239 const TUint8* const aKernMsgPtr, |
220 TUint* const aUsrMsgPtr); |
240 TUint* const aUsrMsgPtr); |
221 |
241 |
224 * |
244 * |
225 * @param aEventType Type of the message. A table "EVENTS" in the |
245 * @param aEventType Type of the message. A table "EVENTS" in the |
226 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
246 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
227 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
247 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
228 * @param *aUsrMsgPtr A pointer to a incoming user message. |
248 * @param *aUsrMsgPtr A pointer to a incoming user message. |
229 * @return KErrNone or one of the system wide error |
249 * @return KErrNone or one of the system wide error |
230 */ |
250 */ |
231 static TInt StateModemControlledReset(const TUint8 aEventType, |
251 static TInt StateModemControlledReset(const TUint8 aEventType, |
232 const TUint8* const aKernMsgPtr, |
252 const TUint8* const aKernMsgPtr, |
233 TUint* const aUsrMsgPtr); |
253 TUint* const aUsrMsgPtr); |
234 |
254 |
237 * |
257 * |
238 * @param aEventType Type of the message. A table "EVENTS" in the |
258 * @param aEventType Type of the message. A table "EVENTS" in the |
239 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
259 * dmc_event_handler_ape_cent.cpp-file defines allowed values. |
240 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
260 * @param *aKernMsgPtr A pointer to a incoming kernel message. |
241 * @param *aUsrMsgPtr A pointer to a incoming user message. |
261 * @param *aUsrMsgPtr A pointer to a incoming user message. |
242 * @return KErrNone or one of the system wide error |
262 * @return KErrNone or one of the system wide error |
243 */ |
263 */ |
244 static TInt StateModemUncontrolledReset(const TUint8 aEventType, |
264 static TInt StateModemUncontrolledReset(const TUint8 aEventType, |
245 const TUint8* const aKernMsgPtr, |
265 const TUint8* const aKernMsgPtr, |
246 TUint* const aUsrMsgPtr); |
266 TUint* const aUsrMsgPtr); |
247 |
267 |
|
268 |
248 /** |
269 /** |
249 * A function to handle a MCE_MODEM_STATE_QUERY_RESP |
270 * A function to handle a MCE_MODEM_STATE_QUERY_RESP |
250 * |
271 * |
251 * @param *msgPtr A pointer to a response. |
272 * @param *msgPtr A pointer to a response. |
252 * @return None |
273 * @return None |
253 */ |
274 */ |
254 static void HandleMceModemStateQueryResp(const TUint8* const aMsgPtr); |
275 static void HandleMceModemStateQueryResp(const TUint8* const aMsgPtr); |
|
276 |
|
277 |
|
278 /** |
|
279 * This function Generates an event for user and kernel side clients. |
|
280 * The event is generated only if events are subscribed. |
|
281 * |
|
282 * @param aToWhomBitMask Defines whom to generate an event. |
|
283 * DMC_USER_BIT or/and DMC_KERNEL_BIT |
|
284 * @return None |
|
285 */ |
|
286 static void GenerateEvent(const TUint8 aToWhomBitMask); |
|
287 |
255 |
288 |
256 /** |
289 /** |
257 * Handles a state transition of the DMC Event Handler. |
290 * Handles a state transition of the DMC Event Handler. |
258 * This function also checks if the a required state transition is allowed. |
291 * This function also checks if the a required state transition is allowed. |
259 * |
292 * |
271 * as possible. |
304 * as possible. |
272 * |
305 * |
273 * @param aEventType Type of the message. A table "EVENTS" in the |
306 * @param aEventType Type of the message. A table "EVENTS" in the |
274 * dmc_event_handler_ape_cent.cpp-file. |
307 * dmc_event_handler_ape_cent.cpp-file. |
275 * @param aKernMsgPtr Pointer to Kernel event |
308 * @param aKernMsgPtr Pointer to Kernel event |
276 * @return 1: Bit set to indicate that a requested event is part of the any state. |
309 * @return 1: Bit set to indicate that a requested event is part of the any state. |
277 * 0: Bit not set to indicate that a requested event is not part of the any state. |
310 * 0: Bit not set to indicate that a requested event is not part of the any state. |
278 */ |
311 */ |
279 static TUint8 IsAnyStateEvent(const TUint8 aEventType, const TUint8* const aKernMsgPtr); |
312 static TUint8 IsAnyStateEvent(const TUint8 aEventType, const TUint8* const aKernMsgPtr); |
280 |
313 |
281 private: // data types |
314 private: // data types |
282 |
315 |
283 /** |
316 /** |
284 * A pointer to DMC extension. |
317 * A pointer to DMC extension. |
285 * DMC extension owns this pointer. |
318 * DMC extension owns this pointer. |
286 * |
319 * |
287 */ |
320 */ |
288 static DDmcExtension* iDmcExtPtr; |
321 static DDmcExtension* iDmcExtPtr; |
289 |
322 |
290 /** |
323 /** |
291 * A pointer to mutex. |
324 * A pointer to mutex. |
292 * This class owns this pointer. |
325 * This class owns this pointer. |
293 * |
326 * |
294 */ |
327 */ |
295 static DMutex* iMutexPtr; |
328 static DMutex* iMutexPtr; |
296 |
329 |
297 /** |
330 /** |
298 * A pointer to DMC user / kernel Dfc-queue. |
331 * A pointer to DMC user Dfc-queue. |
299 * This class does not own this pointer. |
332 * This class does not own this pointer. |
300 * |
333 * |
301 */ |
334 */ |
302 static TDfc* iUserEventDfcPtr; |
335 static TDfc* iUserEventDfcPtr; |
303 |
336 |
304 /** |
337 /** |
305 * A target start-up mode. |
338 * A pointer to DMC kernel Dfc-queue. |
|
339 * This class does not own this pointer. |
|
340 * |
|
341 */ |
|
342 static TDfc* iKernelEventDfcPtr; |
|
343 |
|
344 /** |
|
345 * Event for signaling upstairs to start power off |
|
346 * |
|
347 */ |
|
348 static TRawEvent iSwitchOffEvent; |
|
349 |
|
350 /** |
|
351 * Event for signaling upstairs to start reset |
|
352 * |
|
353 */ |
|
354 static TRawEvent iResetEvent; |
|
355 |
|
356 |
|
357 /** |
|
358 * A target start-up mode. |
306 * Values in the boot_reason_api.h-file. |
359 * Values in the boot_reason_api.h-file. |
307 */ |
360 */ |
308 static TBootReason::TStartupMode iTargetStartupMode; |
361 static TBootReason::TStartupMode iTargetStartupMode; |
309 |
362 |
310 /** |
363 /** |
311 * A hidden reset status. |
364 * A hidden reset status. |
312 * Values in the boot_reason_api.h-file. |
365 * Values in the boot_reason_api.h-file. |
313 * |
366 * |
314 * ETrue if the reset is hidden, otherwise EFalse. |
367 * ETrue if the reset is hidden, otherwise EFalse. |
315 */ |
368 */ |
316 static TBool iHiddenStatus; |
369 static TBool iHiddenStatus; |
323 |
376 |
324 /** |
377 /** |
325 * This variable is needed to detect whether the Power Handler |
378 * This variable is needed to detect whether the Power Handler |
326 * PowerDown() has been called. |
379 * PowerDown() has been called. |
327 * |
380 * |
328 * DMC needs this information to know if the Power Handler |
381 * DMC needs this information to know if the Power Handler |
329 * PowerDownDone must be called in case the modem connection |
382 * PowerDownDone must be called in case the modem connection |
330 * is lost and there is an ongoing transaction. |
383 * is lost and there is an ongoing transaction. |
331 * |
384 * |
332 * If there is no ongoing transaction, the modem connection |
385 * If there is no ongoing transaction, the modem connection |
333 * lost is handled as a "MODEM_UNCONTROLLED_RESET". |
386 * lost is handled as a "MODEM_UNCONTROLLED_RESET". |
334 * |
387 * |
335 * Only one transaction is allowed, thus if there is already |
388 * Only one transaction is allowed, thus if there is already |
336 * ongoing transaction, the modem connection is handled as |
389 * ongoing transaction, the modem connection is handled as |
337 * below. |
390 * below. |
338 * |
391 * |
339 * ModemConnection lost AND "transaction ongoing": |
392 * ModemConnection lost AND "transaction ongoing": |
343 * ELSE |
396 * ELSE |
344 * -> Standby and wait until Power Handler |
397 * -> Standby and wait until Power Handler |
345 * PowerDown() is called and then |
398 * PowerDown() is called and then |
346 * acknowledge back immediately by |
399 * acknowledge back immediately by |
347 * calling PowerDownDone(). |
400 * calling PowerDownDone(). |
348 * |
401 * |
349 * Allowed values: TRUE / FALSE |
402 * Allowed values: TRUE / FALSE |
350 */ |
403 */ |
351 static TUint8 iPowerDownCalled; |
404 static TUint8 iPowerDownCalled; |
352 |
405 |
353 /** |
406 /** |
354 * Modem action bit map. |
407 * Modem action bit map. |
355 * |
408 * |
356 * This bit map defines actions that have |
409 * This bit map defines actions that have |
357 * been happend in the Modem state transition |
410 * been happend in the Modem state transition |
358 * and a modem connection. |
411 * and a modem connection. |
359 * |
412 * |
360 * Action information is needed to find a correct |
413 * Action information is needed to find a correct |
361 * slot to acknowledge the Power Handler PowerDownDone. |
414 * slot to acknowledge the Power Handler PowerDownDone. |
362 */ |
415 */ |
363 static TUint8 iModemActionBitMap; |
416 static TUint8 iModemActionBitMap; |
364 |
417 |
365 /** |
418 /** |
366 * A current modem state. |
419 * A current modem state. |
367 * |
420 * |
368 * Values from mceisi.h-file. |
421 * Values from mceisi.h-file. |
369 */ |
422 */ |
370 static TUint8 iModemCurrentState; |
423 static TUint8 iModemCurrentState; |
371 |
424 |
372 /** |
425 /** |
374 * |
427 * |
375 * Defines the type of the event to be sent |
428 * Defines the type of the event to be sent |
376 * user side client. The event type is used in case |
429 * user side client. The event type is used in case |
377 * PC SW or Modem orginated power off or reset or |
430 * PC SW or Modem orginated power off or reset or |
378 * in case of uncontrolled Modem reset.. |
431 * in case of uncontrolled Modem reset.. |
379 * |
432 * |
380 * Values from OUTPUT EVENTS: defined beginning of this file. |
433 * Values from OUTPUT EVENTS: defined beginning of this file. |
381 */ |
434 */ |
382 static TUint8 iEventType; |
435 static TUint8 iEventType; |
383 |
436 |
384 /** |
437 /** |