|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Implementation of DMC event handler. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #if _DEBUG |
|
22 #include <kern_priv.h> |
|
23 #endif // _DEBUG |
|
24 #include <pn_const.h> // PN_MODEM_MCE |
|
25 #include <phonetisi.h> // ISI_HEADER_*** |
|
26 |
|
27 // USE_MTC_SERVER is only for debugging purposes until brige hw is available |
|
28 #ifdef USE_MTC_SERVER |
|
29 #include <mtcisi.h> // MTC related definitions. Temporary for testing |
|
30 #else // USE_MTC_SERVER |
|
31 #include <mceisi.h> // MCE ISI stuff |
|
32 #endif // USE_MTC_SERVER |
|
33 |
|
34 #include <isikernel.h> // TIsiKernelSend |
|
35 #include "dmc_extension.h" // DDmcExtension |
|
36 #include "dmc_event_handler_ape_cent.h" |
|
37 #include "dmc_mce_isi.h" |
|
38 #include "dmc_trace.h" |
|
39 |
|
40 #include "osttracedefinitions.h" |
|
41 #ifdef OST_TRACE_COMPILER_IN_USE |
|
42 #include "dmc_event_handler_ape_centTraces.h" |
|
43 #endif |
|
44 |
|
45 // EXTERNAL DATA STRUCTURES |
|
46 // EXTERNAL FUNCTION PROTOTYPES |
|
47 // FORWARD DECLARATIONS |
|
48 // CONSTANTS |
|
49 |
|
50 // MACROS |
|
51 // TO-macro is used only for reading purposes |
|
52 #define TO(to) ((TUint8)to) |
|
53 |
|
54 #define SET_BIT(bit_map, bits) bit_map |= bits |
|
55 |
|
56 // LOCAL CONSTANTS AND MACROS |
|
57 _LIT(KDmcDrvName, "dmc"); |
|
58 |
|
59 #ifdef USE_MTC_SERVER |
|
60 |
|
61 #define MCE_STATE_INIT_VALUE 0xFF |
|
62 #define MCE_ACTION_INIT_VALUE 0xFF |
|
63 |
|
64 #else // USE_MTC_SERVER |
|
65 |
|
66 /** |
|
67 * Define MCE init state and action values because an ISI API does not provide them. |
|
68 */ |
|
69 #define MCE_STATE_INIT_VALUE static_cast<TUint8>(static_cast<TInt8>(~(MCE_NORMAL | MCE_LOCAL | MCE_SW_RESET | MCE_POWER_OFF))) |
|
70 #define MCE_ACTION_INIT_VALUE static_cast<TUint8>(static_cast<TInt8>(~(MCE_START | MCE_READY))) |
|
71 |
|
72 #endif // USE_MTC_SERVER |
|
73 |
|
74 /** |
|
75 * Modem actions: |
|
76 * Constants for iModemActionBitMap |
|
77 */ |
|
78 // Modem connection lost |
|
79 #define MODEM_CONNECTION_NOT_OK 0x01 |
|
80 // Modem state transition ready |
|
81 #define MODEM_READY 0x02 |
|
82 #define MODEM_NO_ACTIONS 0x00 |
|
83 |
|
84 |
|
85 |
|
86 /** |
|
87 * STATES of this event hander: |
|
88 * Constants for iCurrentstate |
|
89 */ |
|
90 #define IDLE 0x00 // All transactions begins in the IDLE-state. |
|
91 #define BUSY 0x01 // Used while checking an incoming transaction request. |
|
92 #define APE_PWR_OFF 0x02 // Handling APE orginated power off request. |
|
93 #define MODEM_PWR_OFF 0x03 // Handling Modem orginated power off request. |
|
94 #define APE_RESET 0x04 // Handling APE orginated reset. |
|
95 #define MODEM_CONTROLLED_RESET 0x05 // Handling Modem controlled reset. |
|
96 #define MODEM_UNCONTROLLED_RESET 0x06 // Handling Modem uncontrolled reset. |
|
97 /* LAST_STATE is the helper state used for detecting the value |
|
98 of the last state */ |
|
99 #define LAST_STATE (MODEM_UNCONTROLLED_RESET + 1) |
|
100 #define NO_STATES_DEFINED 0x00 |
|
101 |
|
102 // MODULE DATA STRUCTURES |
|
103 DDmcExtension* DmcEvHandApeCent::iDmcExtPtr(NULL); |
|
104 DMutex* DmcEvHandApeCent::iMutexPtr(NULL); |
|
105 TDfc* DmcEvHandApeCent::iUserEventDfcPtr(NULL); |
|
106 TBootReason::TStartupMode DmcEvHandApeCent::iTargetStartupMode(TBootReason::EStartupModeNone); |
|
107 TBool DmcEvHandApeCent::iHiddenStatus(EFalse); |
|
108 // Init with no valid state value |
|
109 TUint8 DmcEvHandApeCent::iModemCurrentState(MCE_STATE_INIT_VALUE); |
|
110 TUint8 DmcEvHandApeCent::iModemActionBitMap(MODEM_NO_ACTIONS); |
|
111 TUint8 DmcEvHandApeCent::iPowerDownCalled(FALSE); |
|
112 TUint8 DmcEvHandApeCent::iEventType(USER_CLIENT_NO_EVENT); |
|
113 TUint8 DmcEvHandApeCent::iCurrentState(IDLE); |
|
114 |
|
115 // This table defines allowed state transitions. |
|
116 const TUint8 DmcEvHandApeCent::iStateTransitionMap[LAST_STATE] = |
|
117 { |
|
118 // FROM IDLE -> |
|
119 TO((1 << BUSY | |
|
120 1 << APE_PWR_OFF | |
|
121 1 << MODEM_PWR_OFF | |
|
122 1 << APE_RESET | |
|
123 1 << MODEM_CONTROLLED_RESET | |
|
124 1 << MODEM_UNCONTROLLED_RESET)), |
|
125 // FROM BUSY -> |
|
126 TO((1 << IDLE | |
|
127 1 << APE_PWR_OFF | |
|
128 1 << MODEM_PWR_OFF | |
|
129 1 << APE_RESET | |
|
130 1 << MODEM_CONTROLLED_RESET | |
|
131 1 << MODEM_UNCONTROLLED_RESET)), |
|
132 // FROM APE_PWR_OFF -> |
|
133 TO((NO_STATES_DEFINED)), |
|
134 // FROM MODEM_PWR_OFF -> |
|
135 TO((NO_STATES_DEFINED)), |
|
136 // FROM APE_RESET -> |
|
137 TO((NO_STATES_DEFINED)), |
|
138 // FROM MODEM_CONTROLLED_RESET -> |
|
139 TO((NO_STATES_DEFINED)), |
|
140 // FROM MODEM_UNCONTROLLED_RESET -> |
|
141 TO((NO_STATES_DEFINED)), |
|
142 }; |
|
143 |
|
144 /* This bitmap defines user events that are handled in an any-state. Kernel event any |
|
145 state checking is based on the resource ID and message ID.*/ |
|
146 const TUint32 DmcEvHandApeCent::iAnyStateMap((1 << USER_GET_TARGET_STARTUP_MODE | |
|
147 1 << USER_GET_HIDDEN_RESET_STATUS | |
|
148 1 << USER_GET_EVENT_TYPE)); |
|
149 |
|
150 // LOCAL FUNCTION PROTOTYPES |
|
151 |
|
152 |
|
153 // ==================== LOCAL FUNCTIONS ==================== |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // DmcEvHandApeCent::Lock |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 inline void DmcEvHandApeCent::Lock() |
|
160 { |
|
161 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_LOCK, |
|
162 "DMC:EH_APE_CEN: Lock()"); |
|
163 DMC_TRACE(("DMC:EH_APE_CEN: Lock()")); |
|
164 |
|
165 NKern::ThreadEnterCS(); |
|
166 Kern::MutexWait(*iMutexPtr); |
|
167 } |
|
168 |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // DmcEvHandApeCent::Unlock |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 inline void DmcEvHandApeCent::Unlock() |
|
175 { |
|
176 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_UNLOCK, |
|
177 "DMC:EH_APE_CEN: Unlock()"); |
|
178 DMC_TRACE(("DMC:EH_APE_CEN: Unlock()")); |
|
179 |
|
180 Kern::MutexSignal(*iMutexPtr); |
|
181 NKern::ThreadLeaveCS(); |
|
182 } |
|
183 |
|
184 |
|
185 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
186 // ================= MEMBER FUNCTIONS ======================= |
|
187 |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // DDmcExtension::Init |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 void DmcEvHandApeCent::Init(DDmcExtension* const aDmcExtPtr) |
|
194 { |
|
195 OstTrace1(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_APE_CENT_INIT_ENTRY, |
|
196 "DMC:EH_APE_CEN: Init() # IN - aDmcExtPtr: 0x%x", aDmcExtPtr); |
|
197 DMC_TRACE((("DMC:EH_APE_CEN: Init() # IN - aDmcExtPtr: 0x%x "), aDmcExtPtr)); |
|
198 |
|
199 DMC_TRACE_ASSERT_RESET(aDmcExtPtr, "DMC:EH_APE_CEN: aDmcExtPtr, NULL pointer", |
|
200 KErrNoMemory); |
|
201 |
|
202 iDmcExtPtr = aDmcExtPtr; |
|
203 |
|
204 /* Add the extension pointer so that ISI-messages can be sent |
|
205 directly from the place where the message has been built. */ |
|
206 MceIsi::Init(aDmcExtPtr); |
|
207 |
|
208 DMC_TRACE((("DMC:EH_APE_CEN: Init() - Event Handler -> iCurrentState: 0x%02x "), |
|
209 iCurrentState)); |
|
210 |
|
211 // Create a mutex |
|
212 TInt err = Kern::MutexCreate(iMutexPtr, KDmcDrvName , KMutexOrdGeneral0); |
|
213 |
|
214 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_INIT_1, |
|
215 "DMC:EH_APE_CEN: Init() - MutexCreate, err: %d", err); |
|
216 |
|
217 DMC_TRACE((("DMC:EH_APE_CEN: Init() - MutexCreate, err: %d "), err)); |
|
218 DMC_TRACE_ASSERT_RESET(err == KErrNone , "Kern::MutexCreate failed", err); |
|
219 |
|
220 #if _DEBUG |
|
221 /* Print the bitmap(HW_CONF_RECORD) whom boot_reason_api uses in the target startup decision. |
|
222 Values of the HW_CONF_RECORD can be found in the "Loader Chipset API" specification. */ |
|
223 TUint32 startupReason = Kern::SuperPage().iHwStartupReason; |
|
224 |
|
225 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_INIT_2, |
|
226 "DMC:EH_APE_CEN: Init() - SuperPage().iHwStartupReason, startupReason: 0x%08x", |
|
227 startupReason); |
|
228 |
|
229 DMC_TRACE((("DMC:EH_APE_CEN: Init() - SuperPage().iHwStartupReason, startupReason: 0x%08x"), |
|
230 startupReason)); |
|
231 #endif // _DEBUG |
|
232 |
|
233 DmcEvHandApeCent::Lock(); |
|
234 /* Get and set the target startup mode in which a device is started. |
|
235 This is needed in case of device crash. */ |
|
236 TBootReason::GetStartupMode(iTargetStartupMode); |
|
237 TBootReason::SetTargetStartupMode(iTargetStartupMode); |
|
238 |
|
239 // Get a hidden reset status. |
|
240 iHiddenStatus = TBootReason::IsHiddenReset(); |
|
241 DmcEvHandApeCent::Unlock(); |
|
242 |
|
243 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_INIT_3, |
|
244 "DMC:EH_APE_CEN: Init() - iTargetStartupMode: 0x%02x", |
|
245 iTargetStartupMode); |
|
246 DMC_TRACE((("DMC:KERN_EXTEN: Init() - iTargetStartupMode: 0x%02x"), |
|
247 iTargetStartupMode)); |
|
248 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_INIT_4, |
|
249 "DMC:EH_APE_CEN: Init() - iHiddenStatus: %d", |
|
250 iHiddenStatus); |
|
251 DMC_TRACE((("DMC:KERN_EXTEN: Init() - iHiddenStatus: %d"), |
|
252 iHiddenStatus)); |
|
253 |
|
254 // Get Modem current state |
|
255 MceIsi::MceModemStateQueryReq(); |
|
256 |
|
257 OstTrace1(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_APE_CENT_INIT_RETURN, |
|
258 "DMC:EH_APE_CEN: Init() # OUT - iDmcExtPtr: 0x%x", iDmcExtPtr); |
|
259 DMC_TRACE((("DMC:EH_APE_CEN: Init() # OUT - iDmcExtPtr: 0x%x"), iDmcExtPtr)); |
|
260 } |
|
261 |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // DDmcExtension::SubscribeEvents |
|
265 // Set the user logical device dfc-queue available for modem events. |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 void DmcEvHandApeCent::SubscribeEvents(TDfc* const aUserEventDfcPtr) |
|
269 { |
|
270 OstTrace1(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_APE_SUBSCRIBE_EVENTS_ENTRY, |
|
271 "DMC:EH_APE_CEN: SubscribeEvents() # IN - aUserEventDfcPtr: 0x%x", |
|
272 aUserEventDfcPtr); |
|
273 DMC_TRACE((("DMC:EH_APE_CEN: SubscribeEvents() # IN - aUserEventDfcPtr: 0x%x "), |
|
274 aUserEventDfcPtr)); |
|
275 |
|
276 DMC_TRACE_ASSERT_RESET(aUserEventDfcPtr, "DMC:EH_APE_CEN: aUserEventDfcPtr, NULL pointer", |
|
277 KErrNoMemory); |
|
278 |
|
279 iUserEventDfcPtr = aUserEventDfcPtr; |
|
280 |
|
281 // Check if there are pending events. |
|
282 if (iEventType != USER_CLIENT_NO_EVENT) |
|
283 { |
|
284 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_APE_SUBSCRIBE_EVENTS_1, |
|
285 "DMC:EH_APE_CEN: SubscribeEvents() - Pending event, iEventType: %d", |
|
286 iEventType); |
|
287 |
|
288 if (NKern::CurrentContext() == NKern::EInterrupt) |
|
289 { |
|
290 iUserEventDfcPtr->Add(); |
|
291 } |
|
292 else |
|
293 { |
|
294 iUserEventDfcPtr->Enque(); |
|
295 } |
|
296 } |
|
297 |
|
298 OstTrace1(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_APE_SUBSCRIBE_EVENTS_RETURN, |
|
299 "DMC:EH_APE_CEN: SubscribeEvents() # OUT - iUserEventDfcPtr: 0x%x", |
|
300 iUserEventDfcPtr); |
|
301 DMC_TRACE((("DMC:EH_APE_CEN: SubscribeEvents() # OUT - iUserEventDfcPtr: 0x%x"), |
|
302 iUserEventDfcPtr)); |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // DDmcExtension::UnsubscribeEvents |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 void DmcEvHandApeCent::UnsubscribeEvents(TDfc* const aUserEventDfcPtr) |
|
310 { |
|
311 OstTrace1(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_APE_CENT_UNSUBSCRIBE_EVENTS_ENTRY, |
|
312 "DMC:EH_APE_CEN: UnsubscribeEvents() # IN - aUserEventDfcPtr: 0x%x", aUserEventDfcPtr); |
|
313 DMC_TRACE((("DMC:EH_APE_CEN: UnsubscribeEvents() # IN - aUserEventDfcPtr: 0x%x "), aUserEventDfcPtr)); |
|
314 |
|
315 /* Must be a NULL pointer since a client must have already delete the DFfc object before calling |
|
316 this function. */ |
|
317 DMC_TRACE_ASSERT_RESET(!aUserEventDfcPtr, "DMC:EH_APE_CEN: aUserEventDfcPtr, Not NULL pointer", |
|
318 KErrGeneral); |
|
319 |
|
320 iUserEventDfcPtr = aUserEventDfcPtr; |
|
321 |
|
322 OstTrace1(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_APE_UNSUBSCRIBE_EVENTS_RETURN, |
|
323 "DMC:EH_APE_CEN: UnsubscribeEvents() # OUT - iUserEventDfcPtr: 0x%x", |
|
324 iUserEventDfcPtr); |
|
325 DMC_TRACE((("DMC:EH_APE_CEN: UnsubscribeEvents() # OUT - iUserEventDfcPtr: 0x%x"), |
|
326 iUserEventDfcPtr)); |
|
327 } |
|
328 |
|
329 |
|
330 // ----------------------------------------------------------------------------- |
|
331 // DDmcExtension::HandleEvent |
|
332 // This function is the only entry point to access to the DMC Ape Centric |
|
333 // Event Handler. |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 TInt DmcEvHandApeCent::HandleEvent(const TUint8 aEventType, |
|
337 const TUint8* const aKernMsgPtr, |
|
338 TUint* const aUsrMsgPtr) |
|
339 { |
|
340 OstTraceExt3(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_HANDLE_EVENT_ENTRY, |
|
341 "DMC:EH_APE_CEN: HandleEvent() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x", |
|
342 aEventType, (TUint)aKernMsgPtr, (TUint)aUsrMsgPtr); |
|
343 DMC_TRACE((("DMC:EH_APE_CEN: HandleEvent() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x"), |
|
344 aEventType, aKernMsgPtr, aUsrMsgPtr)); |
|
345 |
|
346 TInt ret(KErrLocked); |
|
347 |
|
348 // First check if the event is part of the any state |
|
349 if (IsAnyStateEvent(aEventType, aKernMsgPtr)) |
|
350 { |
|
351 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_HANDLE_EVENT_1, |
|
352 "DMC:EH_APE_CEN: HandleEvent() - ANY, iCurrentState: 0x%02x", iCurrentState); |
|
353 DMC_TRACE((("DMC:EH_APE_CEN: HandleEvent() - ANY, iCurrentState: 0x%02x"), iCurrentState)); |
|
354 |
|
355 StateAny(aEventType, aKernMsgPtr, aUsrMsgPtr); |
|
356 |
|
357 ret = KErrNone; |
|
358 } |
|
359 else |
|
360 { |
|
361 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_HANDLE_EVENT_2, |
|
362 "DMC:EH_APE_CEN: HandleEvent() - iCurrentState: 0x%02x", iCurrentState); |
|
363 DMC_TRACE((("DMC:KERN_EXTEN: HandleEvent() - iCurrentState: 0x%02x"), iCurrentState)); |
|
364 |
|
365 // Check the state |
|
366 switch (iCurrentState) |
|
367 { |
|
368 case IDLE: |
|
369 { |
|
370 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_HANDLE_EVENT_IDLE_1, |
|
371 "DMC:EH_APE_CEN: HandleEvent() - IDLE"); |
|
372 DMC_TRACE(("DMC:EH_APE_CEN: HandleEvent() - IDLE")); |
|
373 |
|
374 StateIdle(aEventType, aKernMsgPtr, aUsrMsgPtr); |
|
375 |
|
376 ret = KErrNone; |
|
377 } |
|
378 break; |
|
379 |
|
380 case BUSY: |
|
381 { |
|
382 /* In busy state we do not handle anything, only one |
|
383 transaction is allowed at the time. */ |
|
384 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_HANDLE_EVENT_BUSY_1, |
|
385 "DMC:EH_APE_CEN: HandleEvent() - BUSY"); |
|
386 DMC_TRACE(("DMC:EH_APE_CEN: HandleEvent() - BUSY")); |
|
387 } |
|
388 break; |
|
389 |
|
390 case APE_PWR_OFF: |
|
391 { |
|
392 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_HANDLE_EVENT_APE_PWR_OFF_1, |
|
393 "DMC:EH_APE_CEN: HandleEvent() - APE_PWR_OFF"); |
|
394 DMC_TRACE(("DMC:EH_APE_CEN: HandleEvent() - APE_PWR_OFF")); |
|
395 |
|
396 StateApePwrOff(aEventType, aKernMsgPtr, aUsrMsgPtr); |
|
397 } |
|
398 break; |
|
399 |
|
400 case MODEM_PWR_OFF: |
|
401 { |
|
402 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_HANDLE_EVENT_MODEM_PWR_OFF_1, |
|
403 "DMC:EH_APE_CEN: HandleEvent() - MODEM_PWR_OFF"); |
|
404 DMC_TRACE(("DMC:EH_APE_CEN: HandleEvent() - MODEM_PWR_OFF")); |
|
405 |
|
406 StateModemPwrOff(aEventType, aKernMsgPtr, aUsrMsgPtr); |
|
407 } |
|
408 break; |
|
409 |
|
410 case APE_RESET: |
|
411 { |
|
412 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_HANDLE_EVENT_APE_RESET_1, |
|
413 "DMC:EH_APE_CEN: HandleEvent() - APE_RESET"); |
|
414 DMC_TRACE(("DMC:EH_APE_CEN: HandleEvent() - APE_RESET")); |
|
415 |
|
416 StateApeReset(aEventType, aKernMsgPtr, aUsrMsgPtr); |
|
417 } |
|
418 break; |
|
419 |
|
420 case MODEM_CONTROLLED_RESET: |
|
421 { |
|
422 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_HANDLE_EVENT_MODEM_CONTROLLED_RESET_1, |
|
423 "DMC:EH_APE_CEN: HandleEvent() - MODEM_CONTROLLED_RESET"); |
|
424 DMC_TRACE(("DMC:EH_APE_CEN: HandleEvent() - MODEM_CONTROLLED_RESET")); |
|
425 |
|
426 StateModemControlledReset(aEventType, aKernMsgPtr, aUsrMsgPtr); |
|
427 } |
|
428 break; |
|
429 |
|
430 case MODEM_UNCONTROLLED_RESET: |
|
431 { |
|
432 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_HANDLE_EVENT_MODEM_UNCONTROLLED_RESET_1, |
|
433 "DMC:EH_APE_CEN: HandleEvent() - MODEM_UNCONTROLLED_RESET"); |
|
434 DMC_TRACE(("DMC:EH_APE_CEN: HandleEvent() - MODEM_UNCONTROLLED_RESET")); |
|
435 |
|
436 StateModemUncontrolledReset(aEventType, aKernMsgPtr, aUsrMsgPtr); |
|
437 } |
|
438 break; |
|
439 |
|
440 default: |
|
441 { |
|
442 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_HANDLE_EVENT_STATE_DEFAULT, |
|
443 "DMC:EH_APE_CEN: HandleEvent() - iCurrentState"); |
|
444 DMC_TRACE_ASSERT_RESET_BRUTAL("DMC:EH_APE_CEN: HandleUserEvent() - Illegal state", |
|
445 KErrArgument); |
|
446 } |
|
447 break; |
|
448 } |
|
449 } |
|
450 |
|
451 OstTraceExt2(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_HANDLE_EVENT_RETURN, |
|
452 "DMC:EH_APE_CEN: HandleEvent() # OUT - iCurrentState: 0x%02x, ret: 0x%x", |
|
453 iCurrentState, (TUint)ret); |
|
454 DMC_TRACE((("DMC:EH_APE_CEN: HandleEvent() # OUT - iCurrentState: 0x%02x, ret: %d"), |
|
455 iCurrentState, ret)); |
|
456 |
|
457 return ret; |
|
458 } |
|
459 |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // DDmcExtension::StateAny |
|
463 // ----------------------------------------------------------------------------- |
|
464 // |
|
465 TInt DmcEvHandApeCent::StateAny(const TUint8 aEventType, |
|
466 const TUint8* const aKernMsgPtr, |
|
467 TUint* const aUsrMsgPtr) |
|
468 { |
|
469 OstTraceExt3(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_STATE_ANY_ENTRY, |
|
470 "DMC:EH_APE_CEN: StateAny() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x", |
|
471 aEventType, (TUint)aKernMsgPtr, (TUint)aUsrMsgPtr); |
|
472 DMC_TRACE((("DMC:EH_APE_CEN: StateAny() # IN - aType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x"), |
|
473 aEventType, aKernMsgPtr, aUsrMsgPtr)); |
|
474 |
|
475 TInt ret(KErrNone); |
|
476 |
|
477 // Supported events in the state ANY. No state transitions are executed from state ANY. |
|
478 switch (aEventType) |
|
479 { |
|
480 case KERNEL_EVENT_ISI: |
|
481 { |
|
482 TUint8 resourceId = aKernMsgPtr[ISI_HEADER_OFFSET_RESOURCEID]; |
|
483 |
|
484 DMC_TRACE((("DMC:EH_APE_CEN: StateAny() - resource ID: 0x%x: "), resourceId)); |
|
485 |
|
486 #ifdef USE_MTC_SERVER |
|
487 if (resourceId == PN_MTC) |
|
488 { |
|
489 DMC_TRACE(("DMC:EH_APE_CEN: StateAny() - PN_MTC")); |
|
490 |
|
491 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
492 |
|
493 switch (messageId) |
|
494 { |
|
495 case MTC_STATE_QUERY_RESP: |
|
496 { |
|
497 DMC_TRACE(("DMC:EH_APE_CEN: StateAny() - MTC_STATE_QUERY_RESP")); |
|
498 |
|
499 HandleMceModemStateQueryResp(aKernMsgPtr); |
|
500 } |
|
501 break; |
|
502 } |
|
503 } |
|
504 #else // USE_MTC_SERVER |
|
505 if (resourceId == PN_MODEM_MCE) |
|
506 { |
|
507 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_STATE_ANY_KERN_1, |
|
508 "DMC:EH_APE_CEN: StateAny() - PN_MODEM_MCE"); |
|
509 DMC_TRACE(("DMC:EH_APE_CEN: StateAny() - PN_MODEM_MCE")); |
|
510 |
|
511 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
512 |
|
513 switch (messageId) |
|
514 { |
|
515 case MCE_MODEM_STATE_QUERY_RESP: |
|
516 { |
|
517 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_STATE_ANY_KERN_2, |
|
518 "DMC:EH_APE_CEN: StateAny() - MCE_STATE_QUERY_RESP"); |
|
519 DMC_TRACE(("DMC:EH_APE_CEN: StateAny() - MCE_STATE_QUERY_RESP")); |
|
520 |
|
521 HandleMceModemStateQueryResp(aKernMsgPtr); |
|
522 } |
|
523 break; |
|
524 default: |
|
525 { |
|
526 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_STATE_ANY_KERN_3, |
|
527 "DMC:EH_APE_CEN: StateAny() - default, Unknown MCE MSG"); |
|
528 DMC_TRACE(("DMC:EH_APE_CEN: StateAny() - default, Unknown MCE MSG")); |
|
529 } |
|
530 break; |
|
531 } |
|
532 } |
|
533 #endif // USE_MTC_SERVER |
|
534 } |
|
535 break; |
|
536 |
|
537 case KERNEL_EVENT_PWR_HANDLER: |
|
538 { |
|
539 } |
|
540 break; |
|
541 |
|
542 case USER_GET_TARGET_STARTUP_MODE: |
|
543 { |
|
544 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_STATE_ANY_USER_1, |
|
545 "DMC:EH_APE_CEN: StateAny() - USER_GET_TARGET_STARTUP_MODE"); |
|
546 DMC_TRACE(("DMC:EH_APE_CEN: StateAny() - USER_GET_TARGET_STARTUP_MODE")); |
|
547 |
|
548 // Get the target startup mode if the mode has not been fetched yet |
|
549 DmcEvHandApeCent::Lock(); |
|
550 |
|
551 if (iTargetStartupMode == TBootReason::EStartupModeNone) |
|
552 { |
|
553 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_STATE_ANY_EVENT_2, |
|
554 "DMC:EH_APE_CEN: StateAny() - Get the target startup mode through Boot Reason API"); |
|
555 DMC_TRACE(("DMC:EH_APE_CEN: StateAny() - Get the target startup mode through Boot Reason API")); |
|
556 |
|
557 TBootReason::GetStartupMode(iTargetStartupMode); |
|
558 } |
|
559 |
|
560 *aUsrMsgPtr = static_cast<TUint>(iTargetStartupMode); |
|
561 DmcEvHandApeCent::Unlock(); |
|
562 |
|
563 OstTrace1(TRACE_FLOW, STATE_ANY_EVENT_3, |
|
564 "DMC:EH_APE_CEN: StateAny() - iTargetStartupMode: 0x%x", |
|
565 iTargetStartupMode); |
|
566 DMC_TRACE((("DMC:EH_APE_CEN: StateAny() - iTargetStartupMode: 0x%x"), |
|
567 iTargetStartupMode)); |
|
568 } |
|
569 break; |
|
570 |
|
571 case USER_GET_HIDDEN_RESET_STATUS: |
|
572 { |
|
573 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_STATE_ANY_EVENT_4, |
|
574 "DMC:EH_APE_CEN: StateAny() - USER_GET_HIDDEN_RESET_STATUS"); |
|
575 DMC_TRACE(("DMC:EH_APE_CEN: StateAny() - USER_GET_HIDDEN_RESET_STATUS")); |
|
576 |
|
577 // No need to lock because a status is updated once in the init phase. |
|
578 *aUsrMsgPtr = iHiddenStatus; |
|
579 |
|
580 OstTrace1(TRACE_FLOW, STATE_ANY_HIDDEN_EVENT_5, |
|
581 "DMC:EH_APE_CEN: StateAny() - IsHidden: %d", |
|
582 *aUsrMsgPtr); |
|
583 DMC_TRACE((("DMC:EH_APE_CEN: StateAny() - IsHidden: %d"), |
|
584 *aUsrMsgPtr)); |
|
585 } |
|
586 break; |
|
587 |
|
588 case USER_GET_EVENT_TYPE: |
|
589 { |
|
590 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_STATE_ANY_EVENT_5, |
|
591 "DMC:EH_APE_CEN: StateAny() - USER_GET_EVENT_TYPE"); |
|
592 DMC_TRACE(("DMC:EH_APE_CEN: StateAny() - USER_GET_EVENT_TYPE")); |
|
593 |
|
594 DmcEvHandApeCent::Lock(); |
|
595 |
|
596 *aUsrMsgPtr = iEventType; |
|
597 |
|
598 DmcEvHandApeCent::Unlock(); |
|
599 |
|
600 OstTrace1(TRACE_FLOW, STATE_ANY_EVENT_5, |
|
601 "DMC:EH_APE_CEN: StateAny() - User event type: 0x%x", |
|
602 *aUsrMsgPtr); |
|
603 DMC_TRACE((("DMC:EH_APE_CEN: StateAny() - User event type: 0x%x"), |
|
604 *aUsrMsgPtr)); |
|
605 } |
|
606 break; |
|
607 |
|
608 default: // aEventType |
|
609 { |
|
610 // Fatal error if the wrong event type. Make a reset and fix the problem. |
|
611 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_STATE_ANY_EVN_TYPE_DEFAULT, |
|
612 "DMC:EH_APE_CEN: StateAny() - Illegal Event Type"); |
|
613 DMC_TRACE_ASSERT_RESET_BRUTAL("DMC:EH_APE_CEN: StateAny() - Illegal Event Type", |
|
614 KErrArgument); |
|
615 } |
|
616 break; |
|
617 } |
|
618 |
|
619 OstTrace1(TRACE_ENTRY_EXIT, STATE_ANY_RETURN, |
|
620 "DMC:EH_APE_CEN: StateAny() # OUT - ret: %d", ret); |
|
621 DMC_TRACE((("DMC:EH_APE_CEN: StateAny() # OUT - ret: %d"), ret)); |
|
622 |
|
623 return ret; |
|
624 } |
|
625 |
|
626 |
|
627 // ----------------------------------------------------------------------------- |
|
628 // DDmcExtension::StateIdle |
|
629 // IDLE-state is the only state in which new transactions are started. |
|
630 // ----------------------------------------------------------------------------- |
|
631 // |
|
632 TInt DmcEvHandApeCent::StateIdle(const TUint8 aEventType, |
|
633 const TUint8* const aKernMsgPtr, |
|
634 TUint* const aUsrMsgPtr) |
|
635 { |
|
636 OstTraceExt3(TRACE_ENTRY_EXIT, STATE_IDLE_ENTRY, |
|
637 "DMC:EH_APE_CEN: StateIdle() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x", |
|
638 aEventType, (TUint)aKernMsgPtr, (TUint)aUsrMsgPtr); |
|
639 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x"), |
|
640 aEventType, aKernMsgPtr, aUsrMsgPtr)); |
|
641 |
|
642 TInt ret(KErrNone); |
|
643 |
|
644 /* |
|
645 * When checking whether a request is to be served in the IDLE-state, the |
|
646 * state is changed into BUSY to make sure that no new requqests are taken |
|
647 * into a process. |
|
648 * |
|
649 * If the request is not processed, the state will be changed back to |
|
650 * IDLE, otherwise to a state is changed according a request. |
|
651 */ |
|
652 DmcEvHandApeCent::SetNextState(BUSY); |
|
653 |
|
654 // Supported events in the IDLE-state |
|
655 switch (aEventType) |
|
656 { |
|
657 case KERNEL_EVENT_ISI: |
|
658 { |
|
659 OstTrace0(TRACE_FLOW, STATE_STATE_IDLE_EV_TYPE_ISI, |
|
660 "DMC:EH_APE_CEN: StateIdle() - KERNEL_EVENT_ISI"); |
|
661 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - KERNEL_EVENT_ISI")); |
|
662 |
|
663 // ISI msg pointer has been checked in the associated DfcQueue in the extension. |
|
664 TUint8 resourceId = aKernMsgPtr[ISI_HEADER_OFFSET_RESOURCEID]; |
|
665 |
|
666 OstTrace1(TRACE_FLOW, STATE_STATE_IDLE_KERN_EV_ISI_1, |
|
667 "DMC:EH_APE_CEN: StateIdle() - resourceId: 0x%x", (TUint)resourceId); |
|
668 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - resourceId: 0x%x:"), resourceId)); |
|
669 |
|
670 #ifdef USE_MTC_SERVER |
|
671 if (resourceId == PN_MTC) |
|
672 { |
|
673 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - PN_MTC")); |
|
674 |
|
675 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
676 |
|
677 switch (messageId) |
|
678 { |
|
679 case MTC_STATE_INFO_IND: |
|
680 { |
|
681 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - MTC_STATE_INFO_IND")); |
|
682 |
|
683 TUint8 modemState(MCE_STATE_INIT_VALUE); |
|
684 TUint8 modemAction(MCE_ACTION_INIT_VALUE); |
|
685 |
|
686 // Get the modem state and action information |
|
687 MceIsi::MceModemStateInd(aKernMsgPtr, modemState, modemAction); |
|
688 |
|
689 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - modemState: 0x%x, modemAction: 0x%x"), |
|
690 modemState, modemAction)); |
|
691 |
|
692 // In the IDLE-state we are only interested if Modem starts reset or power off. |
|
693 if (modemAction == MTC_START) |
|
694 { |
|
695 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - MTC_START")); |
|
696 |
|
697 if (modemState == MTC_POWER_OFF) |
|
698 { |
|
699 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - MTC_POWER_OFF")); |
|
700 |
|
701 // First set the target start-up mode to "none" meaning power off. |
|
702 DmcEvHandApeCent::Lock(); |
|
703 iTargetStartupMode = TBootReason::EStartupModeNone; |
|
704 TBootReason::SetTargetStartupMode(TBootReason::EStartupModeNone); |
|
705 |
|
706 /* Set the user client event type. The type of the event is read |
|
707 once the iUserEventDfcPtr dfc-queue gets execution time. */ |
|
708 iEventType = USER_CLIENT_POWER_OFF_EVENT; |
|
709 DmcEvHandApeCent::Unlock(); |
|
710 |
|
711 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - Boot API, iTargetStartupMode: 0x%x, User iEventType: 0x%x"), |
|
712 iTargetStartupMode, iEventType)); |
|
713 |
|
714 // Change the state to MODEM_PWR_OFF |
|
715 DmcEvHandApeCent::SetNextState(MODEM_PWR_OFF); |
|
716 } |
|
717 |
|
718 if (modemState == MTC_SW_RESET) |
|
719 { |
|
720 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - MTC_SW_RESET")); |
|
721 |
|
722 // Reset a device back to the same state as started. |
|
723 DmcEvHandApeCent::Lock(); |
|
724 TBootReason::SetTargetStartupMode(iTargetStartupMode); |
|
725 |
|
726 /* Set the user client event type. The type of the event is read |
|
727 once the iUserEventDfcPtr dfc-queue gets execution time. */ |
|
728 iEventType = USER_CLIENT_RESET_EVENT; |
|
729 DmcEvHandApeCent::Unlock(); |
|
730 |
|
731 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - Boot API, iTargetStartupMode: 0x%x, User iEventType: 0x%x"), |
|
732 iTargetStartupMode, iEventType)); |
|
733 |
|
734 // Change the state to MODEM_CONTROLLED_RESET |
|
735 DmcEvHandApeCent::SetNextState(MODEM_CONTROLLED_RESET); |
|
736 } |
|
737 |
|
738 // Now check if we have to generate a user event. |
|
739 if ((modemState == MTC_POWER_OFF) || (modemState == MTC_SW_RESET)) |
|
740 { |
|
741 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - Generate User event, iUserEventDfcPtr: 0x%x"), |
|
742 iUserEventDfcPtr)); |
|
743 /* Generate the user event. |
|
744 If no registered clients yet. Remain in the MODEM_CONTROLLED_RESET state |
|
745 and as soon as the first client subscribes events, the power |
|
746 off event is generated. */ |
|
747 if (iUserEventDfcPtr) |
|
748 { |
|
749 if (NKern::CurrentContext() == NKern::EInterrupt) |
|
750 { |
|
751 iUserEventDfcPtr->Add(); |
|
752 } |
|
753 else |
|
754 { |
|
755 iUserEventDfcPtr->Enque(); |
|
756 } |
|
757 } |
|
758 } |
|
759 } |
|
760 } |
|
761 break; |
|
762 |
|
763 default: |
|
764 { |
|
765 DMC_TRACE((("MCE_ISIMSG:DMC:EH_APE_CEN: StateIdle - \ |
|
766 MCE ISI message not supported in this state, messageId: 0x%x"), |
|
767 messageId)); |
|
768 } |
|
769 break; |
|
770 } |
|
771 } |
|
772 #else // USE_MTC_SERVER |
|
773 if (resourceId == PN_MODEM_MCE) |
|
774 { |
|
775 OstTrace0(TRACE_FLOW, STATE_STATE_IDLE_KERN_EV_ISI_2, |
|
776 "DMC:EH_APE_CEN: StateIdle() - PN_MODEM_MCE"); |
|
777 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - PN_MODEM_MCE")); |
|
778 |
|
779 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
780 |
|
781 switch (messageId) |
|
782 { |
|
783 case MCE_MODEM_STATE_IND: |
|
784 { |
|
785 OstTrace0(TRACE_FLOW, STATE_STATE_IDLE_KERN_EV_ISI_CASE_1, |
|
786 "DMC:EH_APE_CEN: StateIdle() - MCE_MODEM_STATE_IND"); |
|
787 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - MCE_MODEM_STATE_IND")); |
|
788 |
|
789 TUint8 modemState(MCE_STATE_INIT_VALUE); |
|
790 TUint8 modemAction(MCE_ACTION_INIT_VALUE); |
|
791 |
|
792 // Get the modem state and action information |
|
793 MceIsi::MceModemStateInd(aKernMsgPtr, modemState, modemAction); |
|
794 |
|
795 |
|
796 OstTraceExt2(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_STATE_IDLE_MCE_STATE_IND_1, |
|
797 "DMC:EH_APE_CEN: DMC:EH_APE_CEN: StateIdle() - modemState: 0x%x, modemAction: 0x%x", |
|
798 (TUint)modemState, (TUint)modemAction); |
|
799 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - modemState: 0x%x, modemAction: 0x%x"), |
|
800 modemState, modemAction)); |
|
801 |
|
802 if (modemAction == MCE_START) |
|
803 { |
|
804 OstTrace0(TRACE_FLOW, STATE_STATE_IDLE_KERN_EV_ISI_CASE_2, |
|
805 "DMC:EH_APE_CEN: StateIdle() - MCE_START"); |
|
806 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - MCE_START")); |
|
807 |
|
808 if (modemState == MCE_POWER_OFF) |
|
809 { |
|
810 OstTrace0(TRACE_FLOW, STATE_STATE_IDLE_KERN_EV_ISI_CASE_3, |
|
811 "DMC:EH_APE_CEN: StateIdle() - MCE_POWER_OFF"); |
|
812 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - MCE_POWER_OFF")); |
|
813 |
|
814 // First set the target start-up mode to "none" meaning power off. |
|
815 DmcEvHandApeCent::Lock(); |
|
816 iTargetStartupMode = TBootReason::EStartupModeNone; |
|
817 TBootReason::SetTargetStartupMode(TBootReason::EStartupModeNone); |
|
818 |
|
819 /* Set the user client event type. The type of the event is read |
|
820 once the iUserEventDfcPtr dfc-queue gets execution time. */ |
|
821 iEventType = USER_CLIENT_POWER_OFF_EVENT; |
|
822 DmcEvHandApeCent::Unlock(); |
|
823 |
|
824 OstTraceExt2(TRACE_FLOW, STATE_STATE_IDLE_KERN_EV_ISI_CASE_4, |
|
825 "DMC:EH_APE_CEN: StateIdle() - Boot API, iTargetStartupMode: 0x%x, User Event, iEventType: 0x%x", |
|
826 (TUint)iTargetStartupMode, (TUint)iEventType); |
|
827 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - Boot API, iTargetStartupMode: 0x%x, User Event, iEventType: 0x%x"), |
|
828 iTargetStartupMode, iEventType)); |
|
829 |
|
830 // Change the state to MODEM_PWR_OFF |
|
831 DmcEvHandApeCent::SetNextState(MODEM_PWR_OFF); |
|
832 } |
|
833 |
|
834 // Modes makes reset, MODEM_CONTROLLED_RESET. |
|
835 if (modemState == MCE_SW_RESET) |
|
836 { |
|
837 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - MCE_SW_RESET")); |
|
838 |
|
839 // Reset a device back to the same state as started. |
|
840 DmcEvHandApeCent::Lock(); |
|
841 TBootReason::SetTargetStartupMode(iTargetStartupMode); |
|
842 |
|
843 /* Set the user client event type. The type of the event is read |
|
844 once the iUserEventDfcPtr dfc-queue gets execution time. */ |
|
845 iEventType = USER_CLIENT_RESET_EVENT; |
|
846 DmcEvHandApeCent::Unlock(); |
|
847 |
|
848 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - Boot API, iTargetStartupMode: 0x%x, User Event, iEventType: 0x%x"), |
|
849 iTargetStartupMode, iEventType)); |
|
850 |
|
851 // Change the state to MODEM_CONTROLLED_RESET |
|
852 DmcEvHandApeCent::SetNextState(MODEM_CONTROLLED_RESET); |
|
853 } |
|
854 |
|
855 // Now check if we have to generate a user event. |
|
856 if ((modemState == MCE_POWER_OFF) || (modemState == MCE_START)) |
|
857 { |
|
858 OstTrace1(TRACE_FLOW, STATE_STATE_IDLE_KERN_EV_ISI_CASE_5, |
|
859 "DMC:EH_APE_CEN: StateIdle() - Generate User event, iUserEventDfcPtr: 0x%x", |
|
860 iUserEventDfcPtr); |
|
861 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - Generate User event, iUserEventDfcPtr: 0x%x"), |
|
862 iUserEventDfcPtr)); |
|
863 |
|
864 /* Generate the user event. |
|
865 If no registered clients yet. Remain in the MODEM_CONTROLLED_RESET state |
|
866 and as soon as the first client subscribes events, the power |
|
867 off event is generated. */ |
|
868 if (iUserEventDfcPtr) |
|
869 { |
|
870 if (NKern::CurrentContext() == NKern::EInterrupt) |
|
871 { |
|
872 iUserEventDfcPtr->Add(); |
|
873 } |
|
874 else |
|
875 { |
|
876 iUserEventDfcPtr->Enque(); |
|
877 } |
|
878 } |
|
879 } |
|
880 } |
|
881 } |
|
882 break; |
|
883 } |
|
884 } |
|
885 #endif // USE_MTC_SERVER |
|
886 } |
|
887 break; |
|
888 |
|
889 case KERNEL_EVENT_PWR_HANDLER: |
|
890 { |
|
891 // We should never come here. |
|
892 OstTrace0(TRACE_FLOW, STATE_STATE_IDLE_EV_TYPE_PWR_HANDLER, |
|
893 "DMC:EH_APE_CEN: StateIdle() - KERNEL_EVENT_PWR_HANDLER"); |
|
894 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - KERNEL_EVENT_PWR_HANDLER")); |
|
895 } |
|
896 break; |
|
897 |
|
898 /* Modem connection lost and no other transactions ongoing, |
|
899 thus handle as a modem uncontrolled reset. */ |
|
900 case KERNEL_EVENT_MODEM_CONNECTION_NOT_OK: |
|
901 { |
|
902 OstTrace0(TRACE_FLOW, STATE_STATE_IDLE_EV_TYPE_CONNECTION_NOK_1, |
|
903 "DMC:EH_APE_CEN: StateIdle() - KERNEL_EVENT_MODEM_CONNECTION_NOT_OK"); |
|
904 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - KERNEL_EVENT_MODEM_CONNECTION_NOT_OK")); |
|
905 |
|
906 // Reset a device back to the same state as started. |
|
907 DmcEvHandApeCent::Lock(); |
|
908 TBootReason::SetTargetStartupMode(iTargetStartupMode); |
|
909 |
|
910 /* Set the user client event type. The type of the event is read |
|
911 once the iUserEventDfcPtr dfc-queue gets execution time. */ |
|
912 iEventType = USER_CLIENT_RESET_EVENT; |
|
913 DmcEvHandApeCent::Unlock(); |
|
914 |
|
915 OstTraceExt2(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_STATE_IDLE_CONNECTION_NOK_2, |
|
916 "DMC:EH_APE_CEN: StateIdle() - Boot API, iTargetStartupMode: 0x%x, User Event, iEventType: 0x%x", |
|
917 (TUint)iTargetStartupMode, (TUint)iEventType); |
|
918 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - Boot API, iTargetStartupMode: 0x%x, User Event, iEventType: 0x%x"), |
|
919 iTargetStartupMode, iEventType)); |
|
920 |
|
921 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_STATE_IDLE_CONNECTION_NOK_3, |
|
922 "DMC:EH_APE_CEN: StateIdle() - Generate User event, iUserEventDfcPtr: 0x%x", |
|
923 iUserEventDfcPtr); |
|
924 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - Generate User event, iUserEventDfcPtr: 0x%x"), |
|
925 iUserEventDfcPtr)); |
|
926 /* Generate the user event. |
|
927 If no registered clients yet. Remain in the MODEM_UNCONTROLLED_RESET state |
|
928 and as soon as the first client subscribes events, the power |
|
929 off event is generated. */ |
|
930 if (iUserEventDfcPtr) |
|
931 { |
|
932 if (NKern::CurrentContext() == NKern::EInterrupt) |
|
933 { |
|
934 iUserEventDfcPtr->Add(); |
|
935 } |
|
936 else |
|
937 { |
|
938 iUserEventDfcPtr->Enque(); |
|
939 } |
|
940 } |
|
941 |
|
942 // Change the state to MODEM_UNCONTROLLED_RESET |
|
943 DmcEvHandApeCent::SetNextState(MODEM_UNCONTROLLED_RESET); |
|
944 } |
|
945 break; |
|
946 |
|
947 case USER_GENERATE_RESET: |
|
948 { |
|
949 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_STATE_IDLE_USER_EVENT_1, |
|
950 "DMC:EH_APE_CEN: StateIdle() - USER_GENERATE_RESET, targetStartUpMode: 0x%x", |
|
951 (TUint)*aUsrMsgPtr); |
|
952 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() - USER_GENERATE_RESET, targetStartUpMode: 0x%x"), |
|
953 *aUsrMsgPtr)); |
|
954 |
|
955 // First set the target start-up mode in which a device is booted after a reset |
|
956 DmcEvHandApeCent::Lock(); |
|
957 iTargetStartupMode = static_cast<TBootReason::TStartupMode>(*aUsrMsgPtr); |
|
958 TBootReason::SetTargetStartupMode(iTargetStartupMode); |
|
959 DmcEvHandApeCent::Unlock(); |
|
960 |
|
961 // Send indications that we are going to reset. |
|
962 // Send DMC_RESET_STARTED_IND |
|
963 |
|
964 /* Change the state to APE_RESET in which we wait a power down |
|
965 signal from Power Handler.*/ |
|
966 DmcEvHandApeCent::SetNextState(APE_RESET); |
|
967 } |
|
968 break; |
|
969 |
|
970 case USER_POWER_OFF: |
|
971 { |
|
972 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_STATE_IDLE_USER_EVENT_2, |
|
973 "DMC:EH_APE_CEN: StateIdle() - USER_POWER_OFF"); |
|
974 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - USER_POWER_OFF")); |
|
975 |
|
976 /* Set EStartupModeNone to power off the device. |
|
977 A device still might do the reset if e.g. a charger is connected, an alarm |
|
978 occurs or a power key is pressed. This detection is done by "Power Controller". */ |
|
979 DmcEvHandApeCent::Lock(); |
|
980 iTargetStartupMode = static_cast<TBootReason::TStartupMode>(*aUsrMsgPtr); |
|
981 TBootReason::SetTargetStartupMode(iTargetStartupMode); |
|
982 DmcEvHandApeCent::Unlock(); |
|
983 |
|
984 // Send indications that we are going to power off. |
|
985 // Send DMC_POWER_OFF_STARTED_IND |
|
986 |
|
987 /* Change the state to APE_PWR_OFF in which we wait a power down |
|
988 signal from Power Handler.*/ |
|
989 DmcEvHandApeCent::SetNextState(APE_PWR_OFF); |
|
990 } |
|
991 break; |
|
992 |
|
993 default: |
|
994 { |
|
995 /* Fatal error. */ |
|
996 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_STATE_IDLE_EV_TYPE_DEFAULT, |
|
997 "DMC:EH_APE_CEN: StateIdle() - Illegal event type, aUsrMsgPtr->EventId: %d", |
|
998 aEventType); |
|
999 DMC_TRACE_ASSERT_RESET_BRUTAL("DMC:EH_APE_CEN: StateIdle() - Illegal event type", |
|
1000 aEventType); |
|
1001 } |
|
1002 break; |
|
1003 } |
|
1004 |
|
1005 // Change a state back to IDLE if the event is not part of the IDLE-state. |
|
1006 if (iCurrentState == BUSY) |
|
1007 { |
|
1008 OstTrace0(TRACE_FLOW, STATE_IDLE_REMAIN_BUSY, |
|
1009 "DMC:EH_APE_CEN: StateIdle() - Remain in IDLE"); |
|
1010 DMC_TRACE(("DMC:EH_APE_CEN: StateIdle() - Remain in IDLE")); |
|
1011 DmcEvHandApeCent::SetNextState(IDLE); |
|
1012 } |
|
1013 |
|
1014 OstTrace1(TRACE_ENTRY_EXIT, STATE_IDLE_RETURN, |
|
1015 "DMC:EH_APE_CEN: StateIdle() # OUT - ret: %d", ret); |
|
1016 DMC_TRACE((("DMC:EH_APE_CEN: StateIdle() # OUT - ret: %d"), ret)); |
|
1017 |
|
1018 return ret; |
|
1019 } |
|
1020 |
|
1021 |
|
1022 // ----------------------------------------------------------------------------- |
|
1023 // DDmcExtension::StateApePwrOff |
|
1024 // State APE_PWR_OFF: Ape orginated power off request(PC or SSM Adaptation). |
|
1025 // ----------------------------------------------------------------------------- |
|
1026 // |
|
1027 TInt DmcEvHandApeCent::StateApePwrOff(const TUint8 aEventType, |
|
1028 const TUint8* const aKernMsgPtr, |
|
1029 TUint* const aUsrMsgPtr) |
|
1030 { |
|
1031 OstTraceExt3(TRACE_ENTRY_EXIT, STATE_PWR_OFF_ENTRY, |
|
1032 "DMC:EH_APE_CEN: StateApePwrOff() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x", |
|
1033 aEventType, (TUint)aKernMsgPtr, (TUint)aUsrMsgPtr); |
|
1034 DMC_TRACE((("DMC:EH_APE_CEN: StateApePwrOff() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x"), |
|
1035 aEventType, aKernMsgPtr, aUsrMsgPtr)); |
|
1036 |
|
1037 TInt ret(KErrNone); |
|
1038 |
|
1039 // Supported events in the APE_POWER_OFF-state |
|
1040 switch (aEventType) |
|
1041 { |
|
1042 case KERNEL_EVENT_ISI: |
|
1043 { |
|
1044 TUint8 resourceId = aKernMsgPtr[ISI_HEADER_OFFSET_RESOURCEID]; |
|
1045 |
|
1046 OstTrace1(TRACE_FLOW, STATE_APE_PWR_OFF_CASE_KRN_EV_1, |
|
1047 "DMC:EH_APE_CEN: StateApePwrOff() - resource ID: 0x%x", |
|
1048 (TUint)resourceId); |
|
1049 DMC_TRACE((("DMC:EH_APE_CEN: StateApePwrOff() - resource ID: 0x%x:"), resourceId)); |
|
1050 |
|
1051 #ifdef USE_MTC_SERVER |
|
1052 if (resourceId == PN_MTC) |
|
1053 { |
|
1054 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - PN_MTC")); |
|
1055 |
|
1056 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
1057 |
|
1058 switch (messageId) |
|
1059 { |
|
1060 case MTC_STATE_INFO_IND: |
|
1061 { |
|
1062 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - MTC_STATE_INFO_IND")); |
|
1063 |
|
1064 TUint8 modemState(MCE_STATE_INIT_VALUE); |
|
1065 TUint8 modemAction(MCE_ACTION_INIT_VALUE); |
|
1066 |
|
1067 // Get the modem state and action information |
|
1068 MceIsi::MceModemStateInd(aKernMsgPtr, modemState, modemAction); |
|
1069 |
|
1070 // Update the modem state variable if the modem has finished a state transition |
|
1071 if ((modemState == MTC_POWER_OFF) && (modemAction == MTC_READY)) |
|
1072 { |
|
1073 DmcEvHandApeCent::Lock(); |
|
1074 iModemCurrentState = modemState; |
|
1075 |
|
1076 SET_BIT(iModemActionBitMap, MODEM_READY); |
|
1077 |
|
1078 DmcEvHandApeCent::Unlock(); |
|
1079 |
|
1080 DMC_TRACE((("DMC:EH_APE_CEN: StateApePwrOff() - MTC_POWER_OFF, MCE_READY, iModemCurrentState: 0x%x"), |
|
1081 iModemCurrentState)); |
|
1082 |
|
1083 /* Modem has shut down properly and ready for power off. |
|
1084 Acknowledge Power Handler in case it has already called Power Down, |
|
1085 oherwise wait Power Down call. */ |
|
1086 if (iPowerDownCalled) |
|
1087 { |
|
1088 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - Complete Power Down" )); |
|
1089 |
|
1090 DmcEvHandApeCent::Lock(); |
|
1091 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1092 iPowerDownCalled = FALSE; |
|
1093 DmcEvHandApeCent::Unlock(); |
|
1094 |
|
1095 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1096 } |
|
1097 } |
|
1098 } |
|
1099 break; |
|
1100 |
|
1101 case MTC_POWER_OFF_RESP: // MCE_POWER_OFF_RESP |
|
1102 { |
|
1103 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - MTC_POWER_OFF_RESP")); |
|
1104 |
|
1105 MceIsi::McePowerOffResp(aKernMsgPtr); |
|
1106 } |
|
1107 break; |
|
1108 |
|
1109 default: |
|
1110 { |
|
1111 DMC_TRACE((("MCE_ISIMSG:DMC:EH_APE_CEN: StateApePwrOff - \ |
|
1112 MCE ISI message not supported in this state, messageId: 0x%x"), |
|
1113 messageId)); |
|
1114 } |
|
1115 break; |
|
1116 } |
|
1117 } |
|
1118 #else // USE_MTC_SERVER |
|
1119 if (resourceId == PN_MODEM_MCE) |
|
1120 { |
|
1121 OstTrace0(TRACE_FLOW, STATE_APE_PWR_OFF_2, |
|
1122 "DMC:EH_APE_CEN: StateApePwrOff() - PN_MODEM_MCE"); |
|
1123 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - PN_MODEM_MCE")); |
|
1124 |
|
1125 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
1126 |
|
1127 switch (messageId) |
|
1128 { |
|
1129 case MCE_MODEM_STATE_IND: |
|
1130 { |
|
1131 OstTrace0(TRACE_FLOW, STATE_APE_PWR_OFF_CASE_1, |
|
1132 "DMC:EH_APE_CEN: StateApePwrOff() - MCE_MODEM_STATE_IND"); |
|
1133 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - MCE_MODEM_STATE_IND")); |
|
1134 |
|
1135 TUint8 modemState(MCE_STATE_INIT_VALUE); |
|
1136 TUint8 modemAction(MCE_ACTION_INIT_VALUE); |
|
1137 |
|
1138 // Get the modem state and action information |
|
1139 MceIsi::MceModemStateInd(aKernMsgPtr, modemState, modemAction); |
|
1140 |
|
1141 // Update the modem state variable if the modem has finished a state transition |
|
1142 if ((modemState == MCE_POWER_OFF) && (modemAction == MCE_READY)) |
|
1143 { |
|
1144 DmcEvHandApeCent::Lock(); |
|
1145 iModemCurrentState = modemState; |
|
1146 |
|
1147 SET_BIT(iModemActionBitMap, MODEM_READY); |
|
1148 |
|
1149 DmcEvHandApeCent::Unlock(); |
|
1150 |
|
1151 OstTrace1(TRACE_FLOW, STATE_APE_PWR_OFF_CASE_2, |
|
1152 "DMC:EH_APE_CEN: StateApePwrOff() - MCE_POWER_OFF, MCE_READY, iModemCurrentState: 0x%x", |
|
1153 (TUint)iModemCurrentState); |
|
1154 DMC_TRACE((("DMC:EH_APE_CEN: StateApePwrOff() - MCE_POWER_OFF, MCE_READY, iModemCurrentState: 0x%x"), |
|
1155 iModemCurrentState)); |
|
1156 |
|
1157 /* Modem has shut down properly and ready for power off. |
|
1158 Acknowledge Power Handler in case it has already called Power Down, |
|
1159 oherwise wait Power Down call. */ |
|
1160 if (iPowerDownCalled) |
|
1161 { |
|
1162 OstTrace0(TRACE_FLOW, STATE_APE_PWR_OFF_CASE_3, "DMC:EH_APE_CEN: StateApePwrOff() - Complete Power Down"); |
|
1163 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - Complete Power Down" )); |
|
1164 |
|
1165 DmcEvHandApeCent::Lock(); |
|
1166 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1167 iPowerDownCalled = FALSE; |
|
1168 DmcEvHandApeCent::Unlock(); |
|
1169 |
|
1170 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1171 } |
|
1172 } |
|
1173 } |
|
1174 break; |
|
1175 |
|
1176 case MCE_POWER_OFF_RESP: |
|
1177 { |
|
1178 OstTrace0(TRACE_FLOW, STATE_APE_PWR_OFF_CASE_5, |
|
1179 "DMC:EH_APE_CEN: StateApePwrOff() - MCE_POWER_OFF_RESP"); |
|
1180 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - MCE_POWER_OFF_RESP")); |
|
1181 |
|
1182 MceIsi::McePowerOffResp(aKernMsgPtr); |
|
1183 } |
|
1184 break; |
|
1185 |
|
1186 default: |
|
1187 { |
|
1188 OstTrace1(TRACE_FLOW, STATE_APE_PWR_OFF_DEFAULT, |
|
1189 "DMC:EH_APE_CEN: StateApePwrOff() - MCE ISI message not supported in this state, messageId: 0x%x", |
|
1190 messageId); |
|
1191 DMC_TRACE((("MCE_ISIMSG:DMC:EH_APE_CEN: StateApePwrOff - \ |
|
1192 MCE ISI message not supported in this state, messageId: 0x%x"), |
|
1193 messageId)); |
|
1194 } |
|
1195 break; |
|
1196 } |
|
1197 } |
|
1198 #endif // USE_MTC_SERVER |
|
1199 } |
|
1200 break; |
|
1201 |
|
1202 case KERNEL_EVENT_MODEM_CONNECTION_NOT_OK: |
|
1203 { |
|
1204 OstTrace1(TRACE_FLOW, STATE_APE_PWR_OFF_CASE_MODEM_NOK_1, |
|
1205 "DMC:EH_APE_CEN: StateApePwrOff() - KERNEL_EVENT_MODEM_CONNECTION_NOT_OK, iPowerDownCalled: %d", |
|
1206 iPowerDownCalled); |
|
1207 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - KERNEL_EVENT_MODEM_CONNECTION_NOT_OK, iPowerDownCalled: %d", |
|
1208 iPowerDownCalled)); |
|
1209 |
|
1210 SET_BIT(iModemActionBitMap, MODEM_CONNECTION_NOT_OK); |
|
1211 |
|
1212 /* A modem connection lost and Power handler has started to |
|
1213 execute the power down, thus we can complete the power down. */ |
|
1214 if (iPowerDownCalled) |
|
1215 { |
|
1216 DmcEvHandApeCent::Lock(); |
|
1217 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1218 iPowerDownCalled = FALSE; |
|
1219 DmcEvHandApeCent::Unlock(); |
|
1220 |
|
1221 OstTrace0(TRACE_FLOW, STATE_APE_PWR_OFF_CASE_MODEM_NOK_2, |
|
1222 "DMC:EH_APE_CEN: StateApePwrOff() - Modem power off ready, complete power down"); |
|
1223 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - Modem power off ready, complete power down")); |
|
1224 |
|
1225 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1226 } |
|
1227 } |
|
1228 break; |
|
1229 |
|
1230 case KERNEL_EVENT_PWR_HANDLER: |
|
1231 { |
|
1232 OstTrace1(TRACE_FLOW, STATE_APE_PWR_KERNEL_EVENT_PWR_HANDLER_1, |
|
1233 "DMC:EH_APE_CEN: StateApePwrOff() - KERNEL_EVENT_PWR_HANDLER, iModemActionBitMap: 0x%x", |
|
1234 iModemActionBitMap); |
|
1235 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - KERNEL_EVENT_PWR_HANDLER, iModemActionBitMap: 0x%x", |
|
1236 iModemActionBitMap)); |
|
1237 |
|
1238 // Complete the power down if the modem power off is ready. |
|
1239 if (iModemActionBitMap & (MODEM_READY | MODEM_CONNECTION_NOT_OK)) |
|
1240 { |
|
1241 OstTrace0(TRACE_FLOW, STATE_APE_PWR___PWR_HANDLER_2, |
|
1242 "DMC:EH_APE_CEN: StateApePwrOff() - Modem power off ready, complete power down"); |
|
1243 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - Modem power off ready, complete power down")); |
|
1244 |
|
1245 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1246 } |
|
1247 else |
|
1248 { |
|
1249 OstTrace0(TRACE_FLOW, STATE_APE_PWR___PWR_HANDLER_3, |
|
1250 "DMC:EH_APE_CEN: StateApePwrOff() - Power off Modem"); |
|
1251 DMC_TRACE(("DMC:EH_APE_CEN: StateApePwrOff() - Power off Modem")); |
|
1252 |
|
1253 // Modem power off not ready yet, wait until it is. |
|
1254 DmcEvHandApeCent::Lock(); |
|
1255 /* Set TRUE to indicate that Power Handler started shutdown sequence. |
|
1256 DMC needs this information to acknowledge to PowerHandler |
|
1257 in case the modem connection is lost.*/ |
|
1258 iPowerDownCalled = TRUE; |
|
1259 DmcEvHandApeCent::Unlock(); |
|
1260 |
|
1261 // Power OFF Modem |
|
1262 MceIsi::McePowerOffReq(); |
|
1263 } |
|
1264 } |
|
1265 break; |
|
1266 |
|
1267 default: |
|
1268 { |
|
1269 /* Fatal error if the event type. */ |
|
1270 OstTrace1(TRACE_FLOW, STATE_APE_PWR_OFF_EVENT_TYPE_DEFAULT, |
|
1271 "DMC:EH_APE_CEN: StateApePwrOff() - Illegal event type, aEventType: %d", |
|
1272 aEventType); |
|
1273 DMC_TRACE_ASSERT_RESET_BRUTAL("DMC:EH_APE_CEN: StateApePwrOff() - Illegal event type", |
|
1274 aEventType); |
|
1275 } |
|
1276 break; |
|
1277 } |
|
1278 |
|
1279 OstTrace1(TRACE_ENTRY_EXIT, STATE_APE_PWR_OFF_RETURN, |
|
1280 "DMC:EH_APE_CEN: StateApePwrOff() # OUT - ret: %d", ret); |
|
1281 DMC_TRACE((("DMC:EH_APE_CEN: StateApePwrOff() # OUT - ret: %d"), ret)); |
|
1282 |
|
1283 return ret; |
|
1284 } |
|
1285 |
|
1286 |
|
1287 // ----------------------------------------------------------------------------- |
|
1288 // DDmcExtension::StateApeReset |
|
1289 // State APE_RESET: Ape orginated reset request(PC or SSM Adaptation). |
|
1290 // ----------------------------------------------------------------------------- |
|
1291 // |
|
1292 TInt DmcEvHandApeCent::StateApeReset(const TUint8 aEventType, |
|
1293 const TUint8* const aKernMsgPtr, |
|
1294 TUint* const aUsrMsgPtr) |
|
1295 { |
|
1296 OstTraceExt3(TRACE_ENTRY_EXIT, STATE_APE_RESET_ENTRY, |
|
1297 "DMC:EH_APE_CEN: StateApeReset() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x", |
|
1298 aEventType, (TUint)aKernMsgPtr, (TUint)aUsrMsgPtr); |
|
1299 DMC_TRACE((("DMC:EH_APE_CEN: StateApeReset() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x"), |
|
1300 aEventType, aKernMsgPtr, aUsrMsgPtr)); |
|
1301 |
|
1302 TInt ret(KErrNone); |
|
1303 |
|
1304 // Supported events in the APE_RESET-state |
|
1305 switch (aEventType) |
|
1306 { |
|
1307 case KERNEL_EVENT_ISI: |
|
1308 { |
|
1309 TUint8 resourceId = aKernMsgPtr[ISI_HEADER_OFFSET_RESOURCEID]; |
|
1310 |
|
1311 OstTrace1(TRACE_FLOW, STATE_APE_RESET_CASE_KRN_EV_1, |
|
1312 "DMC:EH_APE_CEN: StateApePwrOff() - resourceId: 0x%x", |
|
1313 (TUint)resourceId); |
|
1314 DMC_TRACE((("DMC:EH_APE_CEN: StateApeReset() - resource ID: 0x%x: "), resourceId)); |
|
1315 |
|
1316 #ifdef USE_MTC_SERVER |
|
1317 if (resourceId == PN_MTC) |
|
1318 { |
|
1319 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - PN_MTC")); |
|
1320 |
|
1321 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
1322 |
|
1323 switch (messageId) |
|
1324 { |
|
1325 case MTC_STATE_INFO_IND: |
|
1326 { |
|
1327 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - MTC_STATE_INFO_IND")); |
|
1328 |
|
1329 TUint8 modemState(MCE_STATE_INIT_VALUE); |
|
1330 TUint8 modemAction(MCE_ACTION_INIT_VALUE); |
|
1331 |
|
1332 // Get the modem state and action information |
|
1333 MceIsi::MceModemStateInd(aKernMsgPtr, modemState, modemAction); |
|
1334 |
|
1335 // Update the modem state variable if the modem has finished a state transition |
|
1336 if ((modemState == MTC_SW_RESET) && (modemAction == MTC_READY)) |
|
1337 { |
|
1338 DmcEvHandApeCent::Lock(); |
|
1339 iModemCurrentState = modemState; |
|
1340 |
|
1341 SET_BIT(iModemActionBitMap, MODEM_READY); |
|
1342 |
|
1343 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1344 iPowerDownCalled = FALSE; |
|
1345 DmcEvHandApeCent::Unlock(); |
|
1346 |
|
1347 DMC_TRACE((("DMC:EH_APE_CEN: StateApeReset() - MTC_READY, iModemCurrentState: 0x%x"), |
|
1348 iModemCurrentState)); |
|
1349 |
|
1350 /* Modem has shut down properly and ready for power off. |
|
1351 Acknowledge Power Handler in case it has already called Power Down, |
|
1352 oherwise wait Power Down call. */ |
|
1353 if (iPowerDownCalled) |
|
1354 { |
|
1355 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - Complete Power Down" )); |
|
1356 |
|
1357 DmcEvHandApeCent::Lock(); |
|
1358 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1359 iPowerDownCalled = FALSE; |
|
1360 DmcEvHandApeCent::Unlock(); |
|
1361 |
|
1362 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1363 } |
|
1364 } |
|
1365 } |
|
1366 break; |
|
1367 |
|
1368 case MTC_RESET_GENERATE_RESP: |
|
1369 { |
|
1370 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - MTC_RESET_GENERATE_RESP")); |
|
1371 |
|
1372 MceIsi::MceResetResp(aKernMsgPtr); |
|
1373 } |
|
1374 break; |
|
1375 |
|
1376 default: |
|
1377 { |
|
1378 DMC_TRACE((("MCE_ISIMSG:DMC:EH_APE_CEN: StateApeReset - MTC ISI message not supported in this state, messageId: 0x%x"), |
|
1379 messageId)); |
|
1380 } |
|
1381 break; |
|
1382 } |
|
1383 } |
|
1384 #else // USE_MTC_SERVER |
|
1385 if (resourceId == PN_MODEM_MCE) |
|
1386 { |
|
1387 OstTrace0(TRACE_FLOW, STATE_APE_RESET_2, |
|
1388 "DMC:EH_APE_CEN: StateApeReset() - PN_MODEM_MCE"); |
|
1389 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - PN_MODEM_MCE")); |
|
1390 |
|
1391 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
1392 |
|
1393 switch (messageId) |
|
1394 { |
|
1395 case MCE_MODEM_STATE_IND: |
|
1396 { |
|
1397 OstTrace0(TRACE_FLOW, STATE_APE_RESET_CASE_1, |
|
1398 "DMC:EH_APE_CEN: StateApeReset() - MCE_MODEM_STATE_IND"); |
|
1399 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - MCE_MODEM_STATE_IND")); |
|
1400 |
|
1401 TUint8 modemState(MCE_STATE_INIT_VALUE); |
|
1402 TUint8 modemAction(MCE_ACTION_INIT_VALUE); |
|
1403 |
|
1404 // Get the modem state and action information |
|
1405 MceIsi::MceModemStateInd(aKernMsgPtr, modemState, modemAction); |
|
1406 |
|
1407 // Update the modem state variable if the modem has finished a state transition |
|
1408 if ((modemState == MCE_SW_RESET) && (modemAction == MCE_READY)) |
|
1409 { |
|
1410 DmcEvHandApeCent::Lock(); |
|
1411 iModemCurrentState = modemState; |
|
1412 |
|
1413 SET_BIT(iModemActionBitMap, MODEM_READY); |
|
1414 |
|
1415 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1416 iPowerDownCalled = FALSE; |
|
1417 DmcEvHandApeCent::Unlock(); |
|
1418 |
|
1419 OstTrace1(TRACE_FLOW, STATE_APE_RESET_CASE_2, |
|
1420 "DMC:EH_APE_CEN: StateApeReset() - MCE_READY, iModemCurrentState: 0x%x", |
|
1421 (TUint)iModemCurrentState); |
|
1422 DMC_TRACE((("DMC:EH_APE_CEN: StateApeReset() - MCE_READY, iModemCurrentState: 0x%x"), |
|
1423 iModemCurrentState)); |
|
1424 |
|
1425 /* Modem has shut down properly and ready for power off. |
|
1426 Acknowledge Power Handler in case it has already called Power Down, |
|
1427 oherwise wait Power Down call. */ |
|
1428 if (iPowerDownCalled) |
|
1429 { |
|
1430 OstTrace0(TRACE_FLOW, STATE_APE_RESET_CASE_3, "DMC:EH_APE_CEN: StateApeReset() - Complete Power Down"); |
|
1431 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - Complete Power Down" )); |
|
1432 |
|
1433 DmcEvHandApeCent::Lock(); |
|
1434 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1435 iPowerDownCalled = FALSE; |
|
1436 DmcEvHandApeCent::Unlock(); |
|
1437 |
|
1438 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1439 } |
|
1440 } |
|
1441 } |
|
1442 break; |
|
1443 |
|
1444 case MCE_RESET_RESP: |
|
1445 { |
|
1446 OstTrace0(TRACE_FLOW, STATE_APE_RESET_CASE_5, |
|
1447 "DMC:EH_APE_CEN: StateApeReset() - MCE_RESET_RESP"); |
|
1448 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - MCE_RESET_RESP")); |
|
1449 |
|
1450 MceIsi::MceResetResp(aKernMsgPtr); |
|
1451 } |
|
1452 break; |
|
1453 |
|
1454 default: |
|
1455 { |
|
1456 OstTrace1(TRACE_FLOW, STATE_APE_RESET_DEFAULT, |
|
1457 "DMC:EH_APE_CEN: StateApeReset() - MCE ISI message not supported in this state, messageId: 0x%x", |
|
1458 messageId); |
|
1459 DMC_TRACE((("MCE_ISIMSG:DMC:EH_APE_CEN: StateApeReset - MCE ISI message not supported in this state, messageId: 0x%x"), |
|
1460 messageId)); |
|
1461 } |
|
1462 break; |
|
1463 } |
|
1464 } |
|
1465 #endif // USE_MTC_SERVER |
|
1466 } |
|
1467 break; |
|
1468 |
|
1469 case KERNEL_EVENT_MODEM_CONNECTION_NOT_OK: |
|
1470 { |
|
1471 OstTrace1(TRACE_FLOW, STATE_APE_RESET_CASE_MODEM_NOK_1, |
|
1472 "DMC:EH_APE_CEN: StateApeReset() - KERNEL_EVENT_MODEM_CONNECTION_NOT_OK, iPowerDownCalled: %d", |
|
1473 iPowerDownCalled); |
|
1474 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - KERNEL_EVENT_MODEM_CONNECTION_NOT_OK, iPowerDownCalled: %d", |
|
1475 iPowerDownCalled)); |
|
1476 |
|
1477 SET_BIT(iModemActionBitMap, MODEM_CONNECTION_NOT_OK); |
|
1478 |
|
1479 /* A modem connection lost and Power handler has started to |
|
1480 execute the power down, thus we can complete the power down. */ |
|
1481 |
|
1482 if (iPowerDownCalled) |
|
1483 { |
|
1484 DmcEvHandApeCent::Lock(); |
|
1485 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1486 iPowerDownCalled = FALSE; |
|
1487 DmcEvHandApeCent::Unlock(); |
|
1488 |
|
1489 OstTrace0(TRACE_FLOW, STATE_APE_RESET_CASE_MODEM_NOK_2, |
|
1490 "DMC:EH_APE_CEN: StateApeReset() - Modem power off ready, complete power down"); |
|
1491 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - Modem power off ready, complete power down")); |
|
1492 |
|
1493 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1494 } |
|
1495 } |
|
1496 break; |
|
1497 |
|
1498 case KERNEL_EVENT_PWR_HANDLER: |
|
1499 { |
|
1500 OstTrace1(TRACE_FLOW, STATE_APE_RESET_PWR_HANDLER_1, |
|
1501 "DMC:EH_APE_CEN: StateApeReset() - KERNEL_EVENT_PWR_HANDLER, iPowerDownCalled: %d", |
|
1502 iPowerDownCalled); |
|
1503 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - KERNEL_EVENT_PWR_HANDLER, iPowerDownCalled: %d", |
|
1504 iPowerDownCalled)); |
|
1505 |
|
1506 // Complete the power down if the modem power off is ready. |
|
1507 if (iModemActionBitMap & (MODEM_READY | MODEM_CONNECTION_NOT_OK)) |
|
1508 { |
|
1509 OstTrace0(TRACE_FLOW, STATE_APE_RESET__PWR_HANDLER_2, |
|
1510 "DMC:EH_APE_CEN: StateApeReset() - Modem power off ready, complete power down"); |
|
1511 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - Modem power off ready, complete power down")); |
|
1512 |
|
1513 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1514 } |
|
1515 else |
|
1516 { |
|
1517 OstTrace0(TRACE_FLOW, STATE_APE_RESET__PWR_HANDLER_3, |
|
1518 "DMC:EH_APE_CEN: StateApeReset() - Power off Modem"); |
|
1519 DMC_TRACE(("DMC:EH_APE_CEN: StateApeReset() - Power off Modem")); |
|
1520 |
|
1521 // Modem power off not ready yet, wait until it is. |
|
1522 DmcEvHandApeCent::Lock(); |
|
1523 /* Set TRUE to indicate that Power Handler started shutdown sequence. |
|
1524 DMC needs this information to acknowledge to PowerHandler |
|
1525 in case the modem connection is lost.*/ |
|
1526 iPowerDownCalled = TRUE; |
|
1527 DmcEvHandApeCent::Unlock(); |
|
1528 |
|
1529 // Reset Modem |
|
1530 MceIsi::MceResetReq(); |
|
1531 } |
|
1532 } |
|
1533 break; |
|
1534 |
|
1535 default: |
|
1536 { |
|
1537 /* Fatal error if the event type. */ |
|
1538 OstTrace1(TRACE_FLOW, STATE_RESET__EVENT_TYPE_CASE_DEFAULT, |
|
1539 "DMC:EH_APE_CEN: StateApeReset() - Illegal event type, aEventType: %d", |
|
1540 aEventType); |
|
1541 DMC_TRACE_ASSERT_RESET_BRUTAL("DMC:EH_APE_CEN: StateApeReset() - Illegal event type", |
|
1542 aEventType); |
|
1543 } |
|
1544 break; |
|
1545 } |
|
1546 |
|
1547 OstTrace1(TRACE_ENTRY_EXIT, STATE_RESET_RETURN, |
|
1548 "DMC:EH_APE_CEN: StateApeReset() # OUT - ret: %d", ret); |
|
1549 DMC_TRACE((("DMC:EH_APE_CEN: StateApeReset() # OUT - ret: %d"), ret)); |
|
1550 |
|
1551 return ret; |
|
1552 } |
|
1553 |
|
1554 |
|
1555 // ----------------------------------------------------------------------------- |
|
1556 // DDmcExtension::StateModemPwrOff |
|
1557 // State MODEM_PWR_OFF: Modem orginated power off. |
|
1558 // ----------------------------------------------------------------------------- |
|
1559 // |
|
1560 TInt DmcEvHandApeCent::StateModemPwrOff(const TUint8 aEventType, |
|
1561 const TUint8* const aKernMsgPtr, |
|
1562 TUint* const aUsrMsgPtr) |
|
1563 { |
|
1564 OstTraceExt3(TRACE_ENTRY_EXIT, STATE_MODEM_PWR_OFF_ENTRY, |
|
1565 "DMC:EH_APE_CEN: StateModemPwrOff() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x", |
|
1566 aEventType, (TUint)aKernMsgPtr, (TUint)aUsrMsgPtr); |
|
1567 DMC_TRACE((("DMC:EH_APE_CEN: StateModemPwrOff() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x"), |
|
1568 aEventType, aKernMsgPtr, aUsrMsgPtr)); |
|
1569 |
|
1570 TInt ret(KErrNone); |
|
1571 |
|
1572 // Supported events in the MODEM_PWR_OFF-state |
|
1573 switch (aEventType) |
|
1574 { |
|
1575 case KERNEL_EVENT_ISI: |
|
1576 { |
|
1577 TUint8 resourceId = aKernMsgPtr[ISI_HEADER_OFFSET_RESOURCEID]; |
|
1578 |
|
1579 OstTrace1(TRACE_FLOW, STATE_MODEM_PWR_OFF_CASE_KRN_EV_1, |
|
1580 "DMC:EH_APE_CEN: StateModemPwrOff() - MCE_POWER_OFF, MCE_READY, resourceId: 0x%x", |
|
1581 (TUint)resourceId); |
|
1582 DMC_TRACE((("DMC:EH_APE_CEN: StateModemPwrOff() - resource ID: 0x%x:"), resourceId)); |
|
1583 |
|
1584 #ifdef USE_MTC_SERVER |
|
1585 if (resourceId == PN_MTC) |
|
1586 { |
|
1587 DMC_TRACE(("DMC:EH_APE_CEN: StateModemPwrOff() - PN_MTC")); |
|
1588 |
|
1589 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
1590 |
|
1591 switch (messageId) |
|
1592 { |
|
1593 case MTC_STATE_INFO_IND: |
|
1594 { |
|
1595 DMC_TRACE(("DMC:EH_APE_CEN: StateModemPwrOff() - MTC_STATE_INFO_IND")); |
|
1596 |
|
1597 TUint8 modemState(MCE_STATE_INIT_VALUE); |
|
1598 TUint8 modemAction(MCE_ACTION_INIT_VALUE); |
|
1599 |
|
1600 // Get the modem state and action information |
|
1601 MceIsi::MceModemStateInd(aKernMsgPtr, modemState, modemAction); |
|
1602 |
|
1603 // Update the modem state variable if the modem has finished a state transition |
|
1604 if ((modemState == MTC_POWER_OFF) && (modemAction == MTC_READY)) |
|
1605 { |
|
1606 DmcEvHandApeCent::Lock(); |
|
1607 |
|
1608 iModemCurrentState = modemState; |
|
1609 SET_BIT(iModemActionBitMap, MODEM_READY); |
|
1610 |
|
1611 DmcEvHandApeCent::Unlock(); |
|
1612 |
|
1613 DMC_TRACE((("DMC:EH_APE_CEN: StateModemPwrOff() - MTC_READY, iModemCurrentState: 0x%x"), |
|
1614 iModemCurrentState)); |
|
1615 |
|
1616 /* Modem has shut down properly and ready for power off. |
|
1617 Acknowledge Power Handler in case it has already called Power Down, |
|
1618 oherwise wait Power Down call. */ |
|
1619 if (iPowerDownCalled) |
|
1620 { |
|
1621 DMC_TRACE(("DMC:EH_APE_CEN: StateModemPwrOff() - Complete Power Down" )); |
|
1622 |
|
1623 DmcEvHandApeCent::Lock(); |
|
1624 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1625 iPowerDownCalled = FALSE; |
|
1626 DmcEvHandApeCent::Unlock(); |
|
1627 |
|
1628 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1629 } |
|
1630 } |
|
1631 } |
|
1632 break; |
|
1633 |
|
1634 default: |
|
1635 { |
|
1636 DMC_TRACE((("MCE_ISIMSG:DMC:EH_APE_CEN: StateModemPwrOff - MTC ISI message not supported in this state, messageId: 0x%x"), |
|
1637 messageId)); |
|
1638 } |
|
1639 break; |
|
1640 } |
|
1641 } |
|
1642 #else // USE_MTC_SERVER |
|
1643 if (resourceId == PN_MODEM_MCE) |
|
1644 { |
|
1645 OstTrace0(TRACE_FLOW, STATE_MODEM_PWR_OFF_2, |
|
1646 "DMC:EH_APE_CEN: StateModemPwrOff() - PN_MODEM_MCE"); |
|
1647 DMC_TRACE(("DMC:EH_APE_CEN: StateModemPwrOff() - PN_MODEM_MCE")); |
|
1648 |
|
1649 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
1650 |
|
1651 switch (messageId) |
|
1652 { |
|
1653 case MCE_MODEM_STATE_IND: |
|
1654 { |
|
1655 OstTrace0(TRACE_FLOW, STATE_MODEM_PWR_OFF_STATE_CASE_1, |
|
1656 "DMC:EH_APE_CEN: StateModemPwrOff() - MCE_MODEM_STATE_IND"); |
|
1657 DMC_TRACE(("DMC:EH_APE_CEN: StateModemPwrOff() - MCE_MODEM_STATE_IND")); |
|
1658 |
|
1659 TUint8 modemState(MCE_STATE_INIT_VALUE); |
|
1660 TUint8 modemAction(MCE_ACTION_INIT_VALUE); |
|
1661 |
|
1662 // Get the modem state and action information |
|
1663 MceIsi::MceModemStateInd(aKernMsgPtr, modemState, modemAction); |
|
1664 |
|
1665 // Update the modem state variable if the modem has finished a state transition. |
|
1666 if ((modemState == MCE_POWER_OFF) && (modemAction == MCE_READY)) |
|
1667 { |
|
1668 DmcEvHandApeCent::Lock(); |
|
1669 |
|
1670 iModemCurrentState = modemState; |
|
1671 SET_BIT(iModemActionBitMap, MODEM_READY); |
|
1672 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1673 iPowerDownCalled = FALSE; |
|
1674 |
|
1675 DmcEvHandApeCent::Unlock(); |
|
1676 |
|
1677 OstTrace1(TRACE_FLOW, STATE_MODEM_PWR_OFF_CASE_CASE_2, |
|
1678 "DMC:EH_APE_CEN: StateModemPwrOff() - MCE_READY, iModemCurrentState: 0x%x", |
|
1679 (TUint)iModemCurrentState); |
|
1680 DMC_TRACE((("DMC:EH_APE_CEN: StateModemPwrOff() - MCE_READY, iModemCurrentState: 0x%x"), |
|
1681 iModemCurrentState)); |
|
1682 |
|
1683 /* Modem has shut down properly and ready for reset |
|
1684 so inform the power handler that we are ready. */ |
|
1685 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1686 } |
|
1687 } |
|
1688 break; |
|
1689 |
|
1690 default: |
|
1691 { |
|
1692 OstTrace1(TRACE_FLOW, STATE_MODEM_PWR_OFF_CASE_DEFAULT, |
|
1693 "DMC:EH_APE_CEN: StateModemPwrOff() - MCE ISI message not supported in this state, messageId: 0x%x", |
|
1694 messageId); |
|
1695 DMC_TRACE((("MCE_ISIMSG:DMC:EH_APE_CEN: StateModemPwrOff - MCE ISI message not supported in this state, messageId: 0x%x"), |
|
1696 messageId)); |
|
1697 } |
|
1698 break; |
|
1699 } |
|
1700 } |
|
1701 #endif // USE_MTC_SERVER |
|
1702 } |
|
1703 break; |
|
1704 |
|
1705 case KERNEL_EVENT_MODEM_CONNECTION_NOT_OK: |
|
1706 { |
|
1707 OstTrace1(TRACE_FLOW, STATE_MODEM_PWR_OFF_CASE_MODEM_NOK_1, |
|
1708 "DMC:EH_APE_CEN: StateModemPwrOff() - KERNEL_EVENT_MODEM_CONNECTION_NOT_OK, iPowerDownCalled: %d", |
|
1709 iPowerDownCalled); |
|
1710 DMC_TRACE(("DMC:EH_APE_CEN: StateModemPwrOff() - KERNEL_EVENT_MODEM_CONNECTION_NOT_OK, iPowerDownCalled: %d", |
|
1711 iPowerDownCalled)); |
|
1712 |
|
1713 SET_BIT(iModemActionBitMap, MODEM_CONNECTION_NOT_OK); |
|
1714 |
|
1715 /* A modem connection lost and Power handler has started to |
|
1716 execute the power down, thus we can complete the power down. */ |
|
1717 if (iPowerDownCalled) |
|
1718 { |
|
1719 OstTrace0(TRACE_FLOW, STATE_MODEM_PWR_OFF_CASE_MODEM_NOK_3, |
|
1720 "DMC:EH_APE_CEN: StateModemPwrOff() - Power off Modem"); |
|
1721 DMC_TRACE(("DMC:EH_APE_CEN: StateModemPwrOff() - Power off Modem")); |
|
1722 |
|
1723 DmcEvHandApeCent::Lock(); |
|
1724 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1725 iPowerDownCalled = FALSE; |
|
1726 DmcEvHandApeCent::Unlock(); |
|
1727 |
|
1728 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1729 } |
|
1730 } |
|
1731 break; |
|
1732 |
|
1733 case KERNEL_EVENT_PWR_HANDLER: |
|
1734 { |
|
1735 OstTrace1(TRACE_FLOW, STATE_MODEM_PWR_OFF__PWR_HANDLER_1, |
|
1736 "DMC:EH_APE_CEN: StateModemPwrOff() - KERNEL_EVENT_PWR_HANDLER, iModemActionBitMap: 0x%02x", |
|
1737 iModemActionBitMap); |
|
1738 DMC_TRACE(("DMC:EH_APE_CEN: StateModemPwrOff() - KERNEL_EVENT_PWR_HANDLER, iModemActionBitMap: 0x%02x", |
|
1739 iModemActionBitMap)); |
|
1740 |
|
1741 // Complete the power down if the modem power off is ready. |
|
1742 if (iModemActionBitMap & (MODEM_READY | MODEM_CONNECTION_NOT_OK)) |
|
1743 { |
|
1744 OstTrace0(TRACE_FLOW, STATE_MODEM_PWR_OFF__PWR_HANDLER_2, |
|
1745 "DMC:EH_APE_CEN: StateModemPwrOff() - Modem power off ready, complete power down"); |
|
1746 DMC_TRACE(("DMC:EH_APE_CEN: StateModemPwrOff() - Modem power off ready, complete power down")); |
|
1747 |
|
1748 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1749 } |
|
1750 else |
|
1751 { |
|
1752 OstTrace0(TRACE_FLOW, STATE_MODEM_PWR_OFF__PWR_HANDLER_3, |
|
1753 "DMC:EH_APE_CEN: StateModemPwrOff() - Wait modem ready or modem connection NOK"); |
|
1754 DMC_TRACE(("DMC:EH_APE_CEN: StateModemPwrOff() - Wait modem ready or modem connection NOK")); |
|
1755 |
|
1756 // Modem power off not ready yet, wait until it is. |
|
1757 DmcEvHandApeCent::Lock(); |
|
1758 /* Set TRUE to indicate that Power Handler started shutdown sequence. |
|
1759 DMC needs this information to acknowledge to PowerHandler |
|
1760 in case the modem connection is lost.*/ |
|
1761 iPowerDownCalled = TRUE; |
|
1762 DmcEvHandApeCent::Unlock(); |
|
1763 } |
|
1764 } |
|
1765 break; |
|
1766 |
|
1767 default: |
|
1768 { |
|
1769 /* Fatal error if the event type. */ |
|
1770 OstTrace1(TRACE_FLOW, STATE_MODEM_PWR_OFF__EVENT_TYPE_CASE_DEFAULT, |
|
1771 "DMC:EH_APE_CEN: StateModemPwrOff() - Illegal event type, aEventType: %d", |
|
1772 aEventType); |
|
1773 DMC_TRACE_ASSERT_RESET_BRUTAL("DMC:EH_APE_CEN: StateModemPwrOff() - Illegal event type", |
|
1774 aEventType); |
|
1775 } |
|
1776 break; |
|
1777 } |
|
1778 |
|
1779 OstTrace1(TRACE_ENTRY_EXIT, STATE_MODEM_PWR_OFF_RETURN, |
|
1780 "DMC:EH_APE_CEN: StateModemPwrOff() # OUT - ret: %d", ret); |
|
1781 DMC_TRACE((("DMC:EH_APE_CEN: StateModemPwrOff() # OUT - ret: %d"), ret)); |
|
1782 |
|
1783 return ret; |
|
1784 } |
|
1785 |
|
1786 |
|
1787 // ----------------------------------------------------------------------------- |
|
1788 // DDmcExtension::StateModemControlledReset |
|
1789 // State MODEM_CONTROLLED_RESET: Modem orginated reset. |
|
1790 // ----------------------------------------------------------------------------- |
|
1791 // |
|
1792 TInt DmcEvHandApeCent::StateModemControlledReset(const TUint8 aEventType, |
|
1793 const TUint8* const aKernMsgPtr, |
|
1794 TUint* const aUsrMsgPtr) |
|
1795 { |
|
1796 OstTraceExt3(TRACE_ENTRY_EXIT, STATE_MODEM_CONT_RESET_ENTRY, |
|
1797 "DMC:EH_APE_CEN: StateModemControlledReset() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x", |
|
1798 aEventType, (TUint)aKernMsgPtr, (TUint)aUsrMsgPtr); |
|
1799 DMC_TRACE((("DMC:EH_APE_CEN: StateModemControlledReset() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x"), |
|
1800 aEventType, aKernMsgPtr, aUsrMsgPtr)); |
|
1801 |
|
1802 TInt ret(KErrNone); |
|
1803 |
|
1804 // Supported events in the MODEM_CONTROLLED_RESET-state |
|
1805 switch (aEventType) |
|
1806 { |
|
1807 case KERNEL_EVENT_ISI: |
|
1808 { |
|
1809 TUint8 resourceId = aKernMsgPtr[ISI_HEADER_OFFSET_RESOURCEID]; |
|
1810 |
|
1811 OstTrace1(TRACE_FLOW, STATE_MODEM_CONT_RESET_CASE_KRN_EV_1, |
|
1812 "DMC:EH_APE_CEN: StateModemControlledReset() - MCE_POWER_OFF, MCE_READY, resourceId: 0x%x", |
|
1813 (TUint)resourceId); |
|
1814 DMC_TRACE((("DMC:EH_APE_CEN: StateModemControlledReset() - resource ID: 0x%x:"), resourceId)); |
|
1815 |
|
1816 #ifdef USE_MTC_SERVER |
|
1817 if (resourceId == PN_MTC) |
|
1818 { |
|
1819 DMC_TRACE(("DMC:EH_APE_CEN: StateModemControlledReset() - PN_MTC")); |
|
1820 |
|
1821 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
1822 |
|
1823 switch (messageId) |
|
1824 { |
|
1825 case MTC_STATE_INFO_IND: |
|
1826 { |
|
1827 DMC_TRACE(("DMC:EH_APE_CEN: StateModemControlledReset() - MTC_STATE_INFO_IND")); |
|
1828 |
|
1829 TUint8 modemState(MCE_STATE_INIT_VALUE); |
|
1830 TUint8 modemAction(MCE_ACTION_INIT_VALUE); |
|
1831 |
|
1832 // Get the modem state and action information |
|
1833 MceIsi::MceModemStateInd(aKernMsgPtr, modemState, modemAction); |
|
1834 |
|
1835 // Update the modem state variable if the modem has finished a state transition |
|
1836 if ((modemState == MTC_SW_RESET) && (modemAction == MTC_READY)) |
|
1837 { |
|
1838 DmcEvHandApeCent::Lock(); |
|
1839 iModemCurrentState = modemState; |
|
1840 |
|
1841 SET_BIT(iModemActionBitMap, MODEM_READY); |
|
1842 |
|
1843 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1844 iPowerDownCalled = FALSE; |
|
1845 DmcEvHandApeCent::Unlock(); |
|
1846 |
|
1847 DMC_TRACE((("DMC:EH_APE_CEN: StateModemControlledReset() - MTC_READY, iModemCurrentState: 0x%x"), |
|
1848 iModemCurrentState)); |
|
1849 |
|
1850 /* Modem has shut down properly and ready to power off, |
|
1851 so inform the power handler that we are ready. */ |
|
1852 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1853 } |
|
1854 } |
|
1855 break; |
|
1856 |
|
1857 default: |
|
1858 { |
|
1859 DMC_TRACE((("MCE_ISIMSG:DMC:EH_APE_CEN: StateModemControlledReset - MTC ISI message not supported in this state, messageId: 0x%x"), |
|
1860 messageId)); |
|
1861 } |
|
1862 break; |
|
1863 } |
|
1864 } |
|
1865 #else // USE_MTC_SERVER |
|
1866 if (resourceId == PN_MODEM_MCE) |
|
1867 { |
|
1868 OstTrace0(TRACE_FLOW, STATE_MODEM_CONT_RESET_2, |
|
1869 "DMC:EH_APE_CEN: StateModemControlledReset() - PN_MODEM_MCE"); |
|
1870 DMC_TRACE(("DMC:EH_APE_CEN: StateModemControlledReset() - PN_MODEM_MCE")); |
|
1871 |
|
1872 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
1873 |
|
1874 switch (messageId) |
|
1875 { |
|
1876 case MCE_MODEM_STATE_IND: |
|
1877 { |
|
1878 OstTrace0(TRACE_FLOW, STATE_MODEM_CONT_RESET_CASE_1, |
|
1879 "DMC:EH_APE_CEN: StateModemControlledReset() - MCE_MODEM_STATE_IND"); |
|
1880 DMC_TRACE(("DMC:EH_APE_CEN: StateModemControlledReset() - MCE_MODEM_STATE_IND")); |
|
1881 |
|
1882 TUint8 modemState(MCE_STATE_INIT_VALUE); |
|
1883 TUint8 modemAction(MCE_ACTION_INIT_VALUE); |
|
1884 |
|
1885 // Get the modem state and action information |
|
1886 MceIsi::MceModemStateInd(aKernMsgPtr, modemState, modemAction); |
|
1887 |
|
1888 // Update the modem state variable if the modem has finished a state transition. |
|
1889 if ((modemState == MCE_SW_RESET) && (modemAction == MCE_READY)) |
|
1890 { |
|
1891 DmcEvHandApeCent::Lock(); |
|
1892 iModemCurrentState = modemState; |
|
1893 |
|
1894 /* Set Modem ready so we can complete the power down immediately when Power Handler |
|
1895 makes the Power Down Call. */ |
|
1896 SET_BIT(iModemActionBitMap, MODEM_READY); |
|
1897 |
|
1898 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1899 iPowerDownCalled = FALSE; |
|
1900 DmcEvHandApeCent::Unlock(); |
|
1901 |
|
1902 OstTrace1(TRACE_FLOW, STATE_MODEM_CONT_RESET_CASE_CASE_2, |
|
1903 "DMC:EH_APE_CEN: StateModemControlledReset() - MCE_READY, iModemCurrentState: 0x%x", |
|
1904 (TUint)iModemCurrentState); |
|
1905 DMC_TRACE((("DMC:EH_APE_CEN: StateModemControlledReset() - MCE_READY, iModemCurrentState: 0x%x"), |
|
1906 iModemCurrentState)); |
|
1907 |
|
1908 /* Modem has shut down properly and ready for reset |
|
1909 so inform the power handler that we are ready. */ |
|
1910 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1911 } |
|
1912 } |
|
1913 break; |
|
1914 |
|
1915 default: |
|
1916 { |
|
1917 OstTrace1(TRACE_FLOW, STATE_MODEM_CONT_RESET_CASE_DEFAULT, |
|
1918 "DMC:EH_APE_CEN: StateModemControlledReset() - MCE ISI message not supported in this state, messageId: 0x%x", |
|
1919 messageId); |
|
1920 DMC_TRACE((("MCE_ISIMSG:DMC:EH_APE_CEN: StateModemControlledReset - MCE ISI message not supported in this state, messageId: 0x%x"), |
|
1921 messageId)); |
|
1922 } |
|
1923 break; |
|
1924 } |
|
1925 } |
|
1926 #endif // USE_MTC_SERVER |
|
1927 } |
|
1928 break; |
|
1929 |
|
1930 case KERNEL_EVENT_MODEM_CONNECTION_NOT_OK: |
|
1931 { |
|
1932 OstTrace1(TRACE_FLOW, STATE_MODEM_CONT_RESET_CASE_MODEM_NOK_1, |
|
1933 "DMC:EH_APE_CEN: StateModemControlledReset() - KERNEL_EVENT_MODEM_CONNECTION_NOT_OK, iPowerDownCalled: %d", |
|
1934 iPowerDownCalled); |
|
1935 DMC_TRACE(("DMC:EH_APE_CEN: StateModemControlledReset() - KERNEL_EVENT_MODEM_CONNECTION_NOT_OK, iPowerDownCalled: %d", |
|
1936 iPowerDownCalled)); |
|
1937 |
|
1938 SET_BIT(iModemActionBitMap, MODEM_CONNECTION_NOT_OK); |
|
1939 |
|
1940 /* A modem connection lost and Power handler has started to |
|
1941 execute the power down, thus we can complete the power down. */ |
|
1942 if (iPowerDownCalled) |
|
1943 { |
|
1944 DmcEvHandApeCent::Lock(); |
|
1945 /* Make sure that Power Handler is not acknowledged twice. */ |
|
1946 iPowerDownCalled = FALSE; |
|
1947 DmcEvHandApeCent::Unlock(); |
|
1948 |
|
1949 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1950 } |
|
1951 } |
|
1952 break; |
|
1953 |
|
1954 case KERNEL_EVENT_PWR_HANDLER: |
|
1955 { |
|
1956 OstTrace1(TRACE_FLOW, STATE_MODEM_CONT_RESET__PWR_HANDLER_1, |
|
1957 "DMC:EH_APE_CEN: StateModemControlledReset() - KERNEL_EVENT_PWR_HANDLER, iModemActionBitMap: 0x%02x", |
|
1958 iModemActionBitMap); |
|
1959 DMC_TRACE(("DMC:EH_APE_CEN: StateModemControlledReset() - KERNEL_EVENT_PWR_HANDLER, iModemActionBitMap: 0x%02x", |
|
1960 iModemActionBitMap)); |
|
1961 |
|
1962 // Complete the power down if the modem power off is ready or the communication is not possible. |
|
1963 if (iModemActionBitMap & (MODEM_READY | MODEM_CONNECTION_NOT_OK)) |
|
1964 { |
|
1965 OstTrace0(TRACE_FLOW, STATE_MODEM_CONT_RESET__PWR_HANDLER_2, |
|
1966 "DMC:EH_APE_CEN: StateModemControlledReset() - Modem power off ready, complete power down"); |
|
1967 DMC_TRACE(("DMC:EH_APE_CEN: StateModemControlledReset() - Modem power off ready, complete power down")); |
|
1968 |
|
1969 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
1970 } |
|
1971 else |
|
1972 { |
|
1973 // Modem power off not ready yet, wait until it is. |
|
1974 DmcEvHandApeCent::Lock(); |
|
1975 /* Set TRUE to indicate that Power Handler started shutdown sequence. |
|
1976 DMC needs this information to acknowledge to PowerHandler |
|
1977 in case the modem connection is lost.*/ |
|
1978 iPowerDownCalled = TRUE; |
|
1979 DmcEvHandApeCent::Unlock(); |
|
1980 } |
|
1981 } |
|
1982 break; |
|
1983 |
|
1984 default: |
|
1985 { |
|
1986 /* Fatal error. */ |
|
1987 OstTrace1(TRACE_FLOW, STATE_MODEM_CONT_RESET__EVENT_TYPE_CASE_DEFAULT, |
|
1988 "DMC:EH_APE_CEN: StateModemControlledReset() - Illegal event type, aEventType: %d", |
|
1989 aEventType); |
|
1990 DMC_TRACE_ASSERT_RESET_BRUTAL("DMC:EH_APE_CEN: StateModemControlledReset() - Illegal event type", |
|
1991 aEventType); |
|
1992 } |
|
1993 break; |
|
1994 } |
|
1995 |
|
1996 OstTrace1(TRACE_ENTRY_EXIT, STATE_MODEM_CONT_RESET_PWR_OFF_RETURN, |
|
1997 "DMC:EH_APE_CEN: StateModemControlledReset() # OUT - ret: %d", ret); |
|
1998 DMC_TRACE((("DMC:EH_APE_CEN: StateModemControlledReset() # OUT - ret: %d"), ret)); |
|
1999 |
|
2000 return ret; |
|
2001 } |
|
2002 |
|
2003 |
|
2004 // ----------------------------------------------------------------------------- |
|
2005 // DDmcExtension::StateModemUncontrolledReset |
|
2006 // State MODEM_UNCONTROLLED_RESET: Modem uncontrolled reset(channel lost) |
|
2007 // ----------------------------------------------------------------------------- |
|
2008 // |
|
2009 TInt DmcEvHandApeCent::StateModemUncontrolledReset(const TUint8 aEventType, |
|
2010 const TUint8* const aKernMsgPtr, |
|
2011 TUint* const aUsrMsgPtr) |
|
2012 { |
|
2013 OstTraceExt3(TRACE_ENTRY_EXIT, STATE_MODEM_UNCONT_RESET_ENTRY, |
|
2014 "DMC:EH_APE_CEN: StateModemUncontrolledReset() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x", |
|
2015 aEventType, (TUint)aKernMsgPtr, (TUint)aUsrMsgPtr); |
|
2016 DMC_TRACE((("DMC:EH_APE_CEN: StateModemUncontrolledReset() # IN - aEventType: 0x%x, aKernMsgPtr: 0x%x, aUsrMsgPtr: 0x%x"), |
|
2017 aEventType, aKernMsgPtr, aUsrMsgPtr)); |
|
2018 |
|
2019 TInt ret(KErrNone); |
|
2020 |
|
2021 // Supported events in the MODEM_CONTROLLED_RESET-state. |
|
2022 switch (aEventType) |
|
2023 { |
|
2024 case KERNEL_EVENT_PWR_HANDLER: |
|
2025 { |
|
2026 OstTrace0(TRACE_FLOW, STATE_MODEM_UNCONT_RESET__PWR_HANDLER_1, |
|
2027 "DMC:EH_APE_CEN: StateModemUncontrolledReset() - KERNEL_EVENT_PWR_HANDLER"); |
|
2028 DMC_TRACE(("DMC:EH_APE_CEN: StateModemUncontrolledReset() - KERNEL_EVENT_PWR_HANDLER")); |
|
2029 |
|
2030 // Modem power off not ready yet, wait until it is. |
|
2031 DmcEvHandApeCent::Lock(); |
|
2032 iPowerDownCalled = TRUE; |
|
2033 DmcEvHandApeCent::Unlock(); |
|
2034 |
|
2035 OstTrace0(TRACE_FLOW, STATE_MODEM_UNCONT_RESET__PWR_HANDLER_2, |
|
2036 "DMC:EH_APE_CEN: StateModemUncontrolledReset() - Complete power down"); |
|
2037 DMC_TRACE(("DMC:EH_APE_CEN: StateModemUncontrolledReset() - Complete power down")); |
|
2038 |
|
2039 DmcEvHandApeCent::iDmcExtPtr->CompletePowerDown(); |
|
2040 } |
|
2041 break; |
|
2042 |
|
2043 default: |
|
2044 { |
|
2045 /* Do not assert since there might buffered ISI-messages and can be received. |
|
2046 Just ignore and wait Power Handler Power Down call. */ |
|
2047 OstTrace1(TRACE_FLOW, STATE_MODEM_UNCONT_RESET__EVENT_TYPE_CASE_DEFAULT, |
|
2048 "DMC:EH_APE_CEN: StateModemUncontrolledReset() - Event type not handled in MODEM_CONTROLLED_RESET-state, aEventType: %d", |
|
2049 aEventType); |
|
2050 DMC_TRACE((("DMC:EH_APE_CEN: StateModemUncontrolledReset() - Event type not handled in MODEM_CONTROLLED_RESET-state, aEventType: %d"), |
|
2051 aEventType)); |
|
2052 } |
|
2053 break; |
|
2054 } |
|
2055 |
|
2056 OstTrace1(TRACE_ENTRY_EXIT, STATE_MODEM_UNCONT_RESET_PWR_OFF_RETURN, |
|
2057 "DMC:EH_APE_CEN: StateModemUncontrolledReset() # OUT - ret: %d", ret); |
|
2058 DMC_TRACE((("DMC:EH_APE_CEN: StateModemUncontrolledReset() # OUT - ret: %d"), ret)); |
|
2059 |
|
2060 |
|
2061 return ret; |
|
2062 } |
|
2063 |
|
2064 |
|
2065 // ----------------------------------------------------------------------------- |
|
2066 // DmcEvHandApeCent::HandleMceModemStateQueryResp |
|
2067 // This function decodes the MCE_MODEM_STATE_QUERY_RESP-message. |
|
2068 // ----------------------------------------------------------------------------- |
|
2069 // |
|
2070 void DmcEvHandApeCent::HandleMceModemStateQueryResp(const TUint8* const aMsgPtr) |
|
2071 { |
|
2072 OstTrace1(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_APE_CENT_HANDLE_MCE_STATE_QUERY_RESP_ENTRY, |
|
2073 "DMC:EH_APE_CEN: HandleMceModemStateQueryResp() # IN - aMsgPtr: 0x%x", |
|
2074 (TUint)aMsgPtr); |
|
2075 DMC_TRACE((("DMC:EH_APE_CEN: HandleMceModemStateQueryResp() # IN - aMsgPtr: 0x%x"), aMsgPtr)); |
|
2076 |
|
2077 TUint8 modemCurrentState; |
|
2078 |
|
2079 // Handle the response message |
|
2080 if (MceIsi::MceModemStateQueryResp(aMsgPtr, modemCurrentState) == KErrNone) |
|
2081 { |
|
2082 // Update the modem state |
|
2083 DmcEvHandApeCent::Lock(); |
|
2084 DmcEvHandApeCent::iModemCurrentState = modemCurrentState; |
|
2085 DmcEvHandApeCent::Unlock(); |
|
2086 |
|
2087 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_HANDLE_MCE_STATE_QUERY_RESP_1, |
|
2088 "DMC:EH_APE_CEN: HandleMceModemStateQueryResp() - iModemCurrentState: 0x%02x", |
|
2089 DmcEvHandApeCent::iModemCurrentState); |
|
2090 DMC_TRACE((("DMC:EH_APE_CEN: HandleMceModemStateQueryResp() - iModemCurrentState: 0x%02x"), |
|
2091 DmcEvHandApeCent::iModemCurrentState)); |
|
2092 } |
|
2093 else |
|
2094 { |
|
2095 // What to do now. Until better knowledge we just trace. |
|
2096 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_HANDLE_MCE_STATE_QUERY_RESP_2, |
|
2097 "DMC:EH_APE_CEN: HandleMceModemStateQueryResp() - modem MCE state transition not ready"); |
|
2098 DMC_TRACE(("DMC:EH_APE_CEN: HandleMceModemStateQueryResp() - modem MCE state transition not ready")); |
|
2099 } |
|
2100 |
|
2101 OstTrace0(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_APE_CENT_HANDLE_MCE_STATE_QUERY_RESP_RETURN, |
|
2102 "DMC:EH_APE_CEN: HandleMceModemStateInd() # OUT"); |
|
2103 DMC_TRACE(("DMC:EH_APE_CEN: HandleMceModemStateInd() # OUT")); |
|
2104 } |
|
2105 |
|
2106 |
|
2107 // ----------------------------------------------------------------------------- |
|
2108 // DmcEvHandApeCent::SetNextState |
|
2109 // Handles a state transition of the DMC Event Handler. |
|
2110 // ----------------------------------------------------------------------------- |
|
2111 // |
|
2112 void DmcEvHandApeCent::SetNextState(const TUint8 aNextState) |
|
2113 { |
|
2114 OstTraceExt2(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_APE_CENT_SET_NEXT_STATE_ENTRY, |
|
2115 "DMC:EH_APE_CEN: SetNextState() # IN - iCurrentState: 0x%02x, aNextState: 0x%02x ", |
|
2116 iCurrentState, (TUint)aNextState); |
|
2117 DMC_TRACE((("DMC:EH_APE_CEN: SetNextState() # IN - iCurrentState: 0x%02x, aNextState: 0x%02x"), |
|
2118 iCurrentState, aNextState)); |
|
2119 |
|
2120 if ((iStateTransitionMap[iCurrentState] >> aNextState) & 1) |
|
2121 { |
|
2122 DmcEvHandApeCent::Lock(); |
|
2123 iCurrentState = aNextState; |
|
2124 DmcEvHandApeCent::Unlock(); |
|
2125 |
|
2126 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_SET_NEXT_STATE_1, |
|
2127 "DMC:EH_APE_CEN: SetNextState()- State transition allowed"); |
|
2128 DMC_TRACE(("DMC:EH_APE_CEN: SetNextState() - State transition allowed")); |
|
2129 |
|
2130 } |
|
2131 else |
|
2132 { |
|
2133 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_HANDLE_EVENT_IDLE_2, |
|
2134 "DMC:EH_APE_CEN: HandleEvent() - Requested state transition not allowed"); |
|
2135 DMC_TRACE_ASSERT_RESET_BRUTAL("DMC:EH_APE_CEN: SetNextState() - Requested state transition not allowed", |
|
2136 KErrArgument); |
|
2137 } |
|
2138 |
|
2139 OstTrace1(TRACE_FLOW, DMC_EVENT_HAND_APE_CENT_SET_NEXT_STATE_RETURN, |
|
2140 "DMC:EH_APE_CEN: SetNextState() # OUT - new iCurrentState: 0x%x", |
|
2141 iCurrentState); |
|
2142 DMC_TRACE((("DMC:EH_APE_CEN: SetNextState() # OUT - new iCurrentState: 0x%02x"), |
|
2143 iCurrentState)); |
|
2144 } |
|
2145 |
|
2146 |
|
2147 // ----------------------------------------------------------------------------- |
|
2148 // DmcEvHandApeCent::IsAnyStateEvent |
|
2149 // Checks if the requested action is part of the any state. |
|
2150 // ----------------------------------------------------------------------------- |
|
2151 // |
|
2152 TUint8 DmcEvHandApeCent::IsAnyStateEvent(const TUint8 aEventType, const TUint8* const aKernMsgPtr) |
|
2153 { |
|
2154 OstTrace1(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_IS_ANY_STATE_ENTRY, |
|
2155 "DMC:EH_APE_CEN: IsAnyStateEvent() # IN - aEventType: 0x%x", |
|
2156 aEventType); |
|
2157 DMC_TRACE((("DMC:EH_APE_CEN: IsAnyStateEvent() # IN - aType: 0x%x"), aEventType)); |
|
2158 |
|
2159 TUint8 bit(0); |
|
2160 |
|
2161 if (aEventType > KERNEL_LAST_KERNEL_EVENT) |
|
2162 { |
|
2163 // User any state event checking |
|
2164 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_IS_ANY_STATE_1, |
|
2165 "DMC:EH_APE_CEN: HandleEvent() - User event"); |
|
2166 DMC_TRACE((("DMC:EH_APE_CEN: User event"))); |
|
2167 bit = ((iAnyStateMap >> aEventType) & 1); |
|
2168 } |
|
2169 // Only the listed ISI-messages are part of the any state. |
|
2170 else if (aEventType == KERNEL_EVENT_ISI) |
|
2171 { |
|
2172 // Kernel any state event checking |
|
2173 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_IS_ANY_STATE_2, |
|
2174 "DMC:EH_APE_CEN: HandleEvent() - Kernel event"); |
|
2175 DMC_TRACE((("DMC:EH_APE_CEN: Kernel event"))); |
|
2176 |
|
2177 /* Check msg ID, which are supported by any state. |
|
2178 A message pointer is already checked in the associated Dfc queue. */ |
|
2179 TUint8 resourceId = aKernMsgPtr[ISI_HEADER_OFFSET_RESOURCEID]; |
|
2180 |
|
2181 DMC_TRACE((("DMC:EH_APE_CEN: IsAnyStateEvent() - resource ID: 0x%x: "), resourceId)); |
|
2182 |
|
2183 #ifdef USE_MTC_SERVER |
|
2184 if (resourceId == PN_MTC) // PN_MTC |
|
2185 { |
|
2186 DMC_TRACE(("DMC:EH_APE_CEN: IsAnyStateEvent() - PN_MTC")); |
|
2187 |
|
2188 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
2189 |
|
2190 switch (messageId) |
|
2191 { |
|
2192 case MTC_STATE_QUERY_RESP: |
|
2193 { |
|
2194 DMC_TRACE(("DMC:EH_APE_CEN: IsAnyStateEvent() - MTC_STATE_QUERY_RESP")); |
|
2195 |
|
2196 bit = 1; |
|
2197 } |
|
2198 break; |
|
2199 |
|
2200 default: // nothing to do |
|
2201 break; |
|
2202 } |
|
2203 } |
|
2204 #else // USE_MTC_SERVER |
|
2205 if (resourceId == PN_MODEM_MCE) |
|
2206 { |
|
2207 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_IS_ANY_STATE_3, |
|
2208 "DMC:EH_APE_CEN: IsAnyStateEvent() - PN_MODEM_MCE"); |
|
2209 DMC_TRACE(("DMC:EH_APE_CEN: IsAnyStateEvent() - PN_MODEM_MCE")); |
|
2210 |
|
2211 TUint8 messageId = aKernMsgPtr[ISI_HEADER_OFFSET_MESSAGEID]; |
|
2212 |
|
2213 switch (messageId) |
|
2214 { |
|
2215 case MCE_MODEM_STATE_QUERY_RESP: |
|
2216 { |
|
2217 OstTrace0(TRACE_FLOW, DMC_EVENT_HAND_IS_ANY_STATE_4, |
|
2218 "DMC:EH_APE_CEN: IsAnyStateEvent() - MCE_STATE_QUERY_RESP"); |
|
2219 DMC_TRACE(("DMC:EH_APE_CEN: IsAnyStateEvent() - MCE_STATE_QUERY_RESP")); |
|
2220 |
|
2221 bit = 1; |
|
2222 } |
|
2223 break; |
|
2224 |
|
2225 default: // nothing to do |
|
2226 break; |
|
2227 } |
|
2228 } |
|
2229 #endif // USE_MTC_SERVER |
|
2230 } |
|
2231 |
|
2232 OstTrace1(TRACE_ENTRY_EXIT, DMC_EVENT_HAND_IS_ANY_STATE_RETURN, |
|
2233 "DMC:EH_APE_CEN: IsAnyStateEvent() # OUT - bit: 0x%02x", bit); |
|
2234 DMC_TRACE((("DMC:EH_APE_CEN: IsAnyStateEvent() # OUT - bit: 0x%02x"), bit)); |
|
2235 |
|
2236 return bit; |
|
2237 } |
|
2238 |
|
2239 // End of File |