0
|
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:
|
9
|
13 |
*
|
|
14 |
* Description:
|
0
|
15 |
* DMC APE centric event handler class declaration.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef DMC_EVENT_HANDLER_APE_CENT_H
|
|
21 |
#define DMC_EVENT_HANDLER_APE_CENT_H
|
|
22 |
|
|
23 |
#ifndef DMC_INTERNAL_INCLUDE
|
|
24 |
#error Illegal usage of dmc_event_handler_ape_cent.h, It is only for DMC internal use !
|
|
25 |
#endif // DMC_INTERNAL_INCLUDE
|
|
26 |
|
|
27 |
// INCLUDES
|
|
28 |
#include <e32def.h> // Data types, TUint8 etc.
|
|
29 |
#include <boot_reason_api/boot_reason_api.h> // TBootReason and TStartupMode handling
|
|
30 |
|
|
31 |
// CONSTANTS
|
|
32 |
|
|
33 |
/**
|
|
34 |
* INPUT EVENTS:
|
|
35 |
* This constanst defines event types / inputs to this event handler.
|
9
|
36 |
*
|
0
|
37 |
*
|
|
38 |
* Kernel events (KERNEL_*) can be one of the following:
|
|
39 |
* - ISI messages
|
|
40 |
* - Power Handler(Power Up / Power Down)
|
|
41 |
* - Isa Access Channel lost and open notification
|
|
42 |
*
|
|
43 |
* User events (USER_*) are:
|
|
44 |
* - Commands through DMC user interface.
|
|
45 |
*/
|
|
46 |
// An ISI-message. Can be a PN_MODEM_MCE or PN_DMC owned messages.
|
|
47 |
#define KERNEL_EVENT_ISI 0x00
|
|
48 |
// Power Handler Power Down
|
|
49 |
#define KERNEL_EVENT_PWR_HANDLER 0x01
|
|
50 |
// IAD Modem connection lost
|
|
51 |
#define KERNEL_EVENT_MODEM_CONNECTION_NOT_OK 0x02
|
9
|
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
|
0
|
62 |
// Used for detecting the event type
|
9
|
63 |
#define KERNEL_LAST_KERNEL_EVENT KERNEL_IF_POWER_OFF
|
0
|
64 |
// Get target startup mode
|
9
|
65 |
#define USER_GET_TARGET_STARTUP_MODE 0x08
|
|
66 |
// Generate reset requested from user side
|
|
67 |
#define USER_GENERATE_RESET 0x09
|
|
68 |
// Power off the device
|
|
69 |
#define USER_POWER_OFF 0x0A
|
|
70 |
// Get hidden reset status
|
|
71 |
#define USER_GET_HIDDEN_RESET_STATUS 0x0B
|
0
|
72 |
// Get the type of the event to be sent to user side client
|
9
|
73 |
#define USER_GET_EVENT_TYPE 0x0C
|
0
|
74 |
#define LAST_EVENT (USER_GET_EVENT_TYPE + 1)
|
|
75 |
#define NO_EVENTS_DEFINED 0x00
|
|
76 |
|
|
77 |
|
|
78 |
/**
|
|
79 |
* OUTPUT EVENTS:
|
|
80 |
* This constanst defines type of user side client events
|
|
81 |
* generated by this event handler.
|
|
82 |
*
|
|
83 |
* Event types are needed in case of Modem or PC SW
|
|
84 |
* orginated controlled or uncontrolled power off / reset.
|
|
85 |
*/
|
|
86 |
// Modem or PC SW orginated power off.
|
9
|
87 |
#define DMC_CLIENT_POWER_OFF_EVENT 0x01
|
0
|
88 |
// Modem or PC SW orginated resest.
|
9
|
89 |
#define DMC_CLIENT_RESET_EVENT 0x02
|
0
|
90 |
// No event requested
|
9
|
91 |
#define DMC_CLIENT_NO_EVENT 0x00
|
|
92 |
|
0
|
93 |
|
9
|
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
|
0
|
103 |
// EXTERNAL DATA STRUCTURES
|
9
|
104 |
// FUNCTION PROTOTYPES
|
0
|
105 |
// FORWARD DECLARATIONS
|
|
106 |
class DDmcExtension;
|
|
107 |
class DMutex;
|
9
|
108 |
class TDfc;
|
0
|
109 |
|
|
110 |
NONSHARABLE_CLASS(DmcEvHandApeCent)
|
|
111 |
{
|
|
112 |
public: // Event handler new public functions
|
9
|
113 |
|
0
|
114 |
/**
|
|
115 |
* Init the event handler
|
|
116 |
*
|
|
117 |
* @param *aDmcExt A pointer to the DMC kernel extension.
|
9
|
118 |
* @return None
|
0
|
119 |
*/
|
|
120 |
static void Init(DDmcExtension* const aDmcExt);
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Subscribe events.
|
|
124 |
*
|
9
|
125 |
* @param aTypeBitMask DMC_USER_BIT or/and DMC_KERNEL_BIT
|
|
126 |
* @param *aReceiveEventDfcPtr A pointer to TDfc queue.
|
0
|
127 |
* @return None
|
|
128 |
*/
|
9
|
129 |
static void SubscribeEvents(const TUint8 aTypeBitMask, TDfc* const aReceiveEventDfcPtr);
|
0
|
130 |
|
|
131 |
/**
|
|
132 |
* Unsubscribe events.
|
|
133 |
*
|
|
134 |
* @param *aUserEventDfcPtr A pointer to DMC logical device TDfc queue.
|
|
135 |
* @return None
|
|
136 |
*/
|
|
137 |
static void UnsubscribeEvents(TDfc* const aUserEventDfcPtr);
|
|
138 |
|
|
139 |
/**
|
|
140 |
* A function that handles all incoming events.
|
|
141 |
* This is the entry point for all events.
|
|
142 |
*
|
|
143 |
* @param aEventType Type of the message. A table "EVENTS" in the
|
|
144 |
* dmc_event_handler_ape_cent.cpp-file defines allowed values.
|
|
145 |
* @param *aKernMsgPtr A pointer to a incoming kernel message.
|
|
146 |
* @param *aUsrMsgPtr A pointer to a incoming user message.
|
9
|
147 |
* @return KErrNone or one of the system wide error
|
0
|
148 |
*/
|
|
149 |
static TInt HandleEvent(const TUint8 aType,
|
9
|
150 |
TUint8* const aKernMsgPtr,
|
0
|
151 |
TUint* const aUsrMsgPtr);
|
|
152 |
|
|
153 |
private: // Event handler new private functions
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Locks a section of code for an execution more
|
|
157 |
* than one thread concurrently.
|
|
158 |
*
|
|
159 |
* Use Unlock to free this lock.
|
|
160 |
*
|
|
161 |
* @param None
|
|
162 |
* @return None
|
|
163 |
*/
|
|
164 |
inline static void Lock();
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Frees the Lock.
|
|
168 |
*
|
|
169 |
* @param None
|
|
170 |
* @return None
|
|
171 |
*/
|
|
172 |
inline static void Unlock();
|
|
173 |
|
|
174 |
/**
|
9
|
175 |
* This function process an ANY-state.
|
0
|
176 |
* There are events, which always must be handled regardless of
|
|
177 |
* an ongoing transaction. These type of events are handled in the state ANY.
|
|
178 |
*
|
|
179 |
* @param aEventType Type of the message. A table "EVENTS" in the
|
|
180 |
* dmc_event_handler_ape_cent.cpp-file defines allowed values.
|
|
181 |
* @param *aKernMsgPtr A pointer to a incoming kernel message.
|
|
182 |
* @param *aUsrMsgPtr A pointer to a incoming user message.
|
9
|
183 |
* @return KErrNone or one of the system wide error
|
0
|
184 |
*/
|
|
185 |
static TInt StateAny(const TUint8 aEventType,
|
9
|
186 |
TUint8* const aKernMsgPtr,
|
0
|
187 |
TUint* const aUsrMsgPtr);
|
|
188 |
|
|
189 |
/**
|
|
190 |
* This function process an IDLE-state.
|
|
191 |
* IDLE-state is the only state in which a new transaction is started.
|
|
192 |
*
|
|
193 |
* @param aEventType Type of the message. A table "EVENTS" in the
|
|
194 |
* dmc_event_handler_ape_cent.cpp-file defines allowed values.
|
|
195 |
* @param *aKernMsgPtr A pointer to a incoming kernel message.
|
|
196 |
* @param *aUsrMsgPtr A pointer to a incoming user message.
|
9
|
197 |
* @return KErrNone or one of the system wide error
|
0
|
198 |
*/
|
|
199 |
static TInt StateIdle(const TUint8 aEventType,
|
|
200 |
const TUint8* const aKernMsgPtr,
|
|
201 |
TUint* const aUsrMsgPtr);
|
|
202 |
|
|
203 |
/**
|
|
204 |
* This function processes an APE_PWR_OFF-state (PC or SSM Adaptation).
|
|
205 |
*
|
|
206 |
* @param aEventType Type of the message. A table "EVENTS" in the
|
|
207 |
* dmc_event_handler_ape_cent.cpp-file defines allowed values.
|
|
208 |
* @param *aKernMsgPtr A pointer to a incoming kernel message.
|
|
209 |
* @param *aUsrMsgPtr A pointer to a incoming user message.
|
9
|
210 |
* @return KErrNone or one of the system wide error
|
0
|
211 |
*/
|
|
212 |
static TInt StateApePwrOff(const TUint8 aEventType,
|
|
213 |
const TUint8* const aKernMsgPtr,
|
|
214 |
TUint* const aUsrMsgPtr);
|
|
215 |
|
|
216 |
/**
|
|
217 |
* This function process an APE_RESET-state (APE orginated reset).
|
|
218 |
*
|
|
219 |
* @param aEventType Type of the message. A table "EVENTS" in the
|
|
220 |
* dmc_event_handler_ape_cent.cpp-file defines allowed values.
|
|
221 |
* @param *aKernMsgPtr A pointer to a incoming kernel message.
|
|
222 |
* @param *aUsrMsgPtr A pointer to a incoming user message.
|
9
|
223 |
* @return KErrNone or one of the system wide error
|
0
|
224 |
*/
|
|
225 |
static TInt StateApeReset(const TUint8 aEventType,
|
|
226 |
const TUint8* const aKernMsgPtr,
|
|
227 |
TUint* const aUsrMsgPtr);
|
|
228 |
|
|
229 |
/**
|
|
230 |
* This function process a MODEM_PWR_OFF-state.
|
|
231 |
*
|
|
232 |
* @param aEventType Type of the message. A table "EVENTS" in the
|
|
233 |
* dmc_event_handler_ape_cent.cpp-file defines allowed values.
|
|
234 |
* @param *aKernMsgPtr A pointer to a incoming kernel message.
|
|
235 |
* @param *aUsrMsgPtr A pointer to a incoming user message.
|
9
|
236 |
* @return KErrNone or one of the system wide error
|
0
|
237 |
*/
|
|
238 |
static TInt StateModemPwrOff(const TUint8 aEventType,
|
|
239 |
const TUint8* const aKernMsgPtr,
|
|
240 |
TUint* const aUsrMsgPtr);
|
|
241 |
|
|
242 |
/**
|
|
243 |
* This function process a MODEM_CONTROLLED_RESET-state.
|
|
244 |
*
|
|
245 |
* @param aEventType Type of the message. A table "EVENTS" in the
|
|
246 |
* dmc_event_handler_ape_cent.cpp-file defines allowed values.
|
|
247 |
* @param *aKernMsgPtr A pointer to a incoming kernel message.
|
|
248 |
* @param *aUsrMsgPtr A pointer to a incoming user message.
|
9
|
249 |
* @return KErrNone or one of the system wide error
|
0
|
250 |
*/
|
|
251 |
static TInt StateModemControlledReset(const TUint8 aEventType,
|
|
252 |
const TUint8* const aKernMsgPtr,
|
|
253 |
TUint* const aUsrMsgPtr);
|
|
254 |
|
|
255 |
/**
|
|
256 |
* This function process a MODEM_UNCONTROLLED_RESET-state.
|
|
257 |
*
|
|
258 |
* @param aEventType Type of the message. A table "EVENTS" in the
|
|
259 |
* dmc_event_handler_ape_cent.cpp-file defines allowed values.
|
|
260 |
* @param *aKernMsgPtr A pointer to a incoming kernel message.
|
|
261 |
* @param *aUsrMsgPtr A pointer to a incoming user message.
|
9
|
262 |
* @return KErrNone or one of the system wide error
|
0
|
263 |
*/
|
|
264 |
static TInt StateModemUncontrolledReset(const TUint8 aEventType,
|
|
265 |
const TUint8* const aKernMsgPtr,
|
|
266 |
TUint* const aUsrMsgPtr);
|
|
267 |
|
9
|
268 |
|
0
|
269 |
/**
|
|
270 |
* A function to handle a MCE_MODEM_STATE_QUERY_RESP
|
|
271 |
*
|
|
272 |
* @param *msgPtr A pointer to a response.
|
|
273 |
* @return None
|
|
274 |
*/
|
|
275 |
static void HandleMceModemStateQueryResp(const TUint8* const aMsgPtr);
|
|
276 |
|
9
|
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 |
|
|
288 |
|
0
|
289 |
/**
|
|
290 |
* Handles a state transition of the DMC Event Handler.
|
|
291 |
* This function also checks if the a required state transition is allowed.
|
|
292 |
*
|
|
293 |
* @param aNextState Next state to be transferred.
|
|
294 |
* A table "STATES" on top of this file defines
|
|
295 |
* allowed values.
|
|
296 |
* @return None
|
|
297 |
*/
|
|
298 |
static void SetNextState(const TUint8 aNextState);
|
|
299 |
|
|
300 |
/**
|
|
301 |
* This function checks if the incomming event is part of the any state.
|
|
302 |
* Requests that are part of the any state are processed regardless
|
|
303 |
* about the ongoing transaction. Requests are processed as long
|
|
304 |
* as possible.
|
|
305 |
*
|
|
306 |
* @param aEventType Type of the message. A table "EVENTS" in the
|
|
307 |
* dmc_event_handler_ape_cent.cpp-file.
|
|
308 |
* @param aKernMsgPtr Pointer to Kernel event
|
9
|
309 |
* @return 1: Bit set to indicate that a requested event is part of the any state.
|
0
|
310 |
* 0: Bit not set to indicate that a requested event is not part of the any state.
|
|
311 |
*/
|
|
312 |
static TUint8 IsAnyStateEvent(const TUint8 aEventType, const TUint8* const aKernMsgPtr);
|
|
313 |
|
|
314 |
private: // data types
|
|
315 |
|
|
316 |
/**
|
|
317 |
* A pointer to DMC extension.
|
|
318 |
* DMC extension owns this pointer.
|
9
|
319 |
*
|
0
|
320 |
*/
|
|
321 |
static DDmcExtension* iDmcExtPtr;
|
|
322 |
|
|
323 |
/**
|
|
324 |
* A pointer to mutex.
|
|
325 |
* This class owns this pointer.
|
9
|
326 |
*
|
0
|
327 |
*/
|
|
328 |
static DMutex* iMutexPtr;
|
|
329 |
|
|
330 |
/**
|
9
|
331 |
* A pointer to DMC user Dfc-queue.
|
0
|
332 |
* This class does not own this pointer.
|
9
|
333 |
*
|
0
|
334 |
*/
|
|
335 |
static TDfc* iUserEventDfcPtr;
|
|
336 |
|
|
337 |
/**
|
9
|
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.
|
0
|
359 |
* Values in the boot_reason_api.h-file.
|
|
360 |
*/
|
|
361 |
static TBootReason::TStartupMode iTargetStartupMode;
|
|
362 |
|
|
363 |
/**
|
9
|
364 |
* A hidden reset status.
|
0
|
365 |
* Values in the boot_reason_api.h-file.
|
|
366 |
*
|
|
367 |
* ETrue if the reset is hidden, otherwise EFalse.
|
|
368 |
*/
|
|
369 |
static TBool iHiddenStatus;
|
|
370 |
|
|
371 |
/**
|
|
372 |
* This bitmap a defines requests that are part
|
|
373 |
* of the any state.
|
|
374 |
*/
|
|
375 |
static const TUint32 iAnyStateMap;
|
|
376 |
|
|
377 |
/**
|
|
378 |
* This variable is needed to detect whether the Power Handler
|
|
379 |
* PowerDown() has been called.
|
|
380 |
*
|
9
|
381 |
* DMC needs this information to know if the Power Handler
|
0
|
382 |
* PowerDownDone must be called in case the modem connection
|
9
|
383 |
* is lost and there is an ongoing transaction.
|
0
|
384 |
*
|
|
385 |
* If there is no ongoing transaction, the modem connection
|
|
386 |
* lost is handled as a "MODEM_UNCONTROLLED_RESET".
|
9
|
387 |
*
|
0
|
388 |
* Only one transaction is allowed, thus if there is already
|
|
389 |
* ongoing transaction, the modem connection is handled as
|
|
390 |
* below.
|
|
391 |
*
|
|
392 |
* ModemConnection lost AND "transaction ongoing":
|
|
393 |
* IF "Power Handler PowerDown called"
|
|
394 |
* -> Acknowlege to Power Handler by
|
|
395 |
* PowerDownDone()
|
|
396 |
* ELSE
|
|
397 |
* -> Standby and wait until Power Handler
|
|
398 |
* PowerDown() is called and then
|
|
399 |
* acknowledge back immediately by
|
|
400 |
* calling PowerDownDone().
|
9
|
401 |
*
|
0
|
402 |
* Allowed values: TRUE / FALSE
|
|
403 |
*/
|
|
404 |
static TUint8 iPowerDownCalled;
|
|
405 |
|
|
406 |
/**
|
9
|
407 |
* Modem action bit map.
|
|
408 |
*
|
0
|
409 |
* This bit map defines actions that have
|
|
410 |
* been happend in the Modem state transition
|
|
411 |
* and a modem connection.
|
9
|
412 |
*
|
0
|
413 |
* Action information is needed to find a correct
|
|
414 |
* slot to acknowledge the Power Handler PowerDownDone.
|
|
415 |
*/
|
|
416 |
static TUint8 iModemActionBitMap;
|
|
417 |
|
|
418 |
/**
|
9
|
419 |
* A current modem state.
|
|
420 |
*
|
0
|
421 |
* Values from mceisi.h-file.
|
|
422 |
*/
|
|
423 |
static TUint8 iModemCurrentState;
|
|
424 |
|
|
425 |
/**
|
|
426 |
* Event type.
|
|
427 |
*
|
|
428 |
* Defines the type of the event to be sent
|
|
429 |
* user side client. The event type is used in case
|
|
430 |
* PC SW or Modem orginated power off or reset or
|
|
431 |
* in case of uncontrolled Modem reset..
|
9
|
432 |
*
|
0
|
433 |
* Values from OUTPUT EVENTS: defined beginning of this file.
|
|
434 |
*/
|
|
435 |
static TUint8 iEventType;
|
|
436 |
|
|
437 |
/**
|
|
438 |
* Current state
|
|
439 |
* Allowed values defined in dmc_event_handler_ape_cent.cpp-file.
|
|
440 |
*
|
|
441 |
*/
|
|
442 |
static TUint8 iCurrentState;
|
|
443 |
|
|
444 |
/**
|
|
445 |
* This table defines allowed state transitions.
|
|
446 |
*/
|
|
447 |
static const TUint8 iStateTransitionMap[];
|
9
|
448 |
|
0
|
449 |
};
|
|
450 |
|
|
451 |
#endif // DMC_EVENT_HANDLER_APE_CENT_H
|
|
452 |
|
|
453 |
// End of File
|