adaptationlayer/devicemodecontroller/dmc_ext/inc/dmc_event_handler_ape_cent.h
changeset 0 63b37f68c1ce
child 9 8486d82aef45
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     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 *     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.
       
    36 *   
       
    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
       
    52 // Used for detecting the event type
       
    53 #define KERNEL_LAST_KERNEL_EVENT              KERNEL_EVENT_MODEM_CONNECTION_NOT_OK
       
    54 // Get target startup mode
       
    55 #define USER_GET_TARGET_STARTUP_MODE          0x03
       
    56 // Get target startup mode
       
    57 #define USER_GENERATE_RESET                   0x04
       
    58 // Get target startup mode
       
    59 #define USER_POWER_OFF                        0x05
       
    60 // Get target startup mode
       
    61 #define USER_GET_HIDDEN_RESET_STATUS          0x07
       
    62 // Get the type of the event to be sent to user side client
       
    63 #define USER_GET_EVENT_TYPE                   0x08
       
    64 #define LAST_EVENT                            (USER_GET_EVENT_TYPE + 1)
       
    65 #define NO_EVENTS_DEFINED                     0x00
       
    66 
       
    67 
       
    68 /**
       
    69 * OUTPUT EVENTS:
       
    70 *   This constanst defines type of user side client events
       
    71 *   generated by this event handler.
       
    72 *
       
    73 *   Event types are needed in case of Modem or PC SW
       
    74 *   orginated controlled or uncontrolled power off / reset.
       
    75 */
       
    76 // Modem or PC SW orginated power off.
       
    77 #define USER_CLIENT_POWER_OFF_EVENT           0x01
       
    78 // Modem or PC SW orginated resest.
       
    79 #define USER_CLIENT_RESET_EVENT               0x02
       
    80 // No event requested
       
    81 #define USER_CLIENT_NO_EVENT                  0x00
       
    82 
       
    83 //  MACROS  
       
    84 //  DATA TYPES 
       
    85 //  EXTERNAL DATA STRUCTURES
       
    86 //  FUNCTION PROTOTYPES  
       
    87 //  FORWARD DECLARATIONS
       
    88 class DDmcExtension;
       
    89 class DMutex;
       
    90 
       
    91 NONSHARABLE_CLASS(DmcEvHandApeCent)
       
    92     {
       
    93     public: // Event handler new public functions
       
    94     
       
    95         /**
       
    96         * Init the event handler
       
    97         *
       
    98         * @param   *aDmcExt     A pointer to the DMC kernel extension.
       
    99         * @return  None 
       
   100         */
       
   101         static void Init(DDmcExtension* const aDmcExt);
       
   102 
       
   103         /**
       
   104         * Subscribe events.
       
   105         *
       
   106         * @param   *aUserEventDfcPtr     A pointer to DMC logical device TDfc queue.
       
   107         * @return  None
       
   108         */
       
   109         static void SubscribeEvents(TDfc* const aUserEventDfcPtr);
       
   110 
       
   111         /**
       
   112         * Unsubscribe events.
       
   113         *
       
   114         * @param   *aUserEventDfcPtr     A pointer to DMC logical device TDfc queue.
       
   115         * @return  None
       
   116         */
       
   117         static void UnsubscribeEvents(TDfc* const aUserEventDfcPtr);
       
   118 
       
   119         /**
       
   120         * A function that handles all incoming events.
       
   121         * This is the entry point for all events.
       
   122         *
       
   123         * @param   aEventType       Type of the message. A table "EVENTS" in the
       
   124         *                           dmc_event_handler_ape_cent.cpp-file defines allowed values.
       
   125         * @param   *aKernMsgPtr     A pointer to a incoming kernel message.
       
   126         * @param   *aUsrMsgPtr      A pointer to a incoming user message.
       
   127         * @return  KErrNone or one of the system wide error 
       
   128         */
       
   129         static TInt HandleEvent(const TUint8  aType,
       
   130                                 const TUint8* const aKernMsgPtr,
       
   131                                 TUint* const  aUsrMsgPtr);
       
   132 
       
   133     private:  // Event handler new private functions
       
   134 
       
   135         /**
       
   136         * Locks a section of code for an execution more
       
   137         * than one thread concurrently.
       
   138         *
       
   139         * Use Unlock to free this lock.
       
   140         *
       
   141         * @param   None
       
   142         * @return  None
       
   143         */
       
   144         inline static void Lock();
       
   145 
       
   146         /**
       
   147         * Frees the Lock.
       
   148         *
       
   149         * @param   None
       
   150         * @return  None
       
   151         */
       
   152         inline static void Unlock();
       
   153 
       
   154         /**
       
   155         * This function process an ANY-state. 
       
   156         * There are events, which always must be handled regardless of
       
   157         * an ongoing transaction. These type of events are handled in the state ANY.
       
   158         *
       
   159         * @param   aEventType       Type of the message. A table "EVENTS" in the
       
   160         *                           dmc_event_handler_ape_cent.cpp-file defines allowed values.
       
   161         * @param   *aKernMsgPtr     A pointer to a incoming kernel message.
       
   162         * @param   *aUsrMsgPtr      A pointer to a incoming user message.
       
   163         * @return  KErrNone or one of the system wide error 
       
   164         */
       
   165         static TInt StateAny(const TUint8  aEventType,
       
   166                              const TUint8* const aKernMsgPtr,
       
   167                              TUint* const  aUsrMsgPtr);
       
   168 
       
   169         /**
       
   170         * This function process an IDLE-state.
       
   171         * IDLE-state is the only state in which a new transaction is started.
       
   172         *
       
   173         * @param   aEventType       Type of the message. A table "EVENTS" in the
       
   174         *                           dmc_event_handler_ape_cent.cpp-file defines allowed values.
       
   175         * @param   *aKernMsgPtr     A pointer to a incoming kernel message.
       
   176         * @param   *aUsrMsgPtr      A pointer to a incoming user message.
       
   177         * @return  KErrNone or one of the system wide error 
       
   178         */
       
   179         static TInt StateIdle(const TUint8  aEventType,
       
   180                               const TUint8* const aKernMsgPtr,
       
   181                               TUint* const  aUsrMsgPtr);
       
   182 
       
   183         /**
       
   184         * This function processes an APE_PWR_OFF-state (PC or SSM Adaptation).
       
   185         *
       
   186         * @param   aEventType       Type of the message. A table "EVENTS" in the
       
   187         *                           dmc_event_handler_ape_cent.cpp-file defines allowed values.
       
   188         * @param   *aKernMsgPtr     A pointer to a incoming kernel message.
       
   189         * @param   *aUsrMsgPtr      A pointer to a incoming user message.
       
   190         * @return  KErrNone or one of the system wide error 
       
   191         */
       
   192         static TInt StateApePwrOff(const TUint8  aEventType,
       
   193                                    const TUint8* const aKernMsgPtr,
       
   194                                    TUint* const  aUsrMsgPtr);
       
   195 
       
   196         /**
       
   197         * This function process an APE_RESET-state (APE orginated reset).
       
   198         *
       
   199         * @param   aEventType       Type of the message. A table "EVENTS" in the
       
   200         *                           dmc_event_handler_ape_cent.cpp-file defines allowed values.
       
   201         * @param   *aKernMsgPtr     A pointer to a incoming kernel message.
       
   202         * @param   *aUsrMsgPtr      A pointer to a incoming user message.
       
   203         * @return  KErrNone or one of the system wide error 
       
   204         */
       
   205         static TInt StateApeReset(const TUint8  aEventType,
       
   206                                   const TUint8* const aKernMsgPtr,
       
   207                                   TUint* const  aUsrMsgPtr);
       
   208 
       
   209         /**
       
   210         * This function process a MODEM_PWR_OFF-state.
       
   211         *
       
   212         * @param   aEventType       Type of the message. A table "EVENTS" in the
       
   213         *                           dmc_event_handler_ape_cent.cpp-file defines allowed values.
       
   214         * @param   *aKernMsgPtr     A pointer to a incoming kernel message.
       
   215         * @param   *aUsrMsgPtr      A pointer to a incoming user message.
       
   216         * @return  KErrNone or one of the system wide error 
       
   217         */
       
   218         static TInt StateModemPwrOff(const TUint8  aEventType,
       
   219                                      const TUint8* const aKernMsgPtr,
       
   220                                      TUint* const  aUsrMsgPtr);
       
   221 
       
   222         /**
       
   223         * This function process a MODEM_CONTROLLED_RESET-state.
       
   224         *
       
   225         * @param   aEventType       Type of the message. A table "EVENTS" in the
       
   226         *                           dmc_event_handler_ape_cent.cpp-file defines allowed values.
       
   227         * @param   *aKernMsgPtr     A pointer to a incoming kernel message.
       
   228         * @param   *aUsrMsgPtr      A pointer to a incoming user message.
       
   229         * @return  KErrNone or one of the system wide error 
       
   230         */
       
   231         static TInt StateModemControlledReset(const TUint8  aEventType,
       
   232                                               const TUint8* const aKernMsgPtr,
       
   233                                               TUint* const  aUsrMsgPtr);
       
   234 
       
   235         /**
       
   236         * This function process a MODEM_UNCONTROLLED_RESET-state.
       
   237         *
       
   238         * @param   aEventType       Type of the message. A table "EVENTS" in the
       
   239         *                           dmc_event_handler_ape_cent.cpp-file defines allowed values.
       
   240         * @param   *aKernMsgPtr     A pointer to a incoming kernel message.
       
   241         * @param   *aUsrMsgPtr      A pointer to a incoming user message.
       
   242         * @return  KErrNone or one of the system wide error 
       
   243         */
       
   244         static TInt StateModemUncontrolledReset(const TUint8  aEventType,
       
   245                                                 const TUint8* const aKernMsgPtr,
       
   246                                                 TUint* const  aUsrMsgPtr);
       
   247 
       
   248         /**
       
   249         * A function to handle a MCE_MODEM_STATE_QUERY_RESP
       
   250         *
       
   251         * @param   *msgPtr     A pointer to a response.
       
   252         * @return  None
       
   253         */
       
   254         static void HandleMceModemStateQueryResp(const TUint8* const aMsgPtr);
       
   255 
       
   256         /**
       
   257         * Handles a state transition of the DMC Event Handler.
       
   258         * This function also checks if the a required state transition is allowed.
       
   259         *
       
   260         * @param   aNextState    Next state to be transferred.
       
   261         *                        A table "STATES" on top of this file defines
       
   262         *                        allowed values.
       
   263         * @return  None
       
   264         */
       
   265         static void SetNextState(const TUint8 aNextState);
       
   266 
       
   267         /**
       
   268         * This function checks if the incomming event is part of the any state.
       
   269         * Requests that are part of the any state are processed regardless
       
   270         * about the ongoing transaction. Requests are processed as long
       
   271         * as possible.
       
   272         *
       
   273         * @param   aEventType       Type of the message. A table "EVENTS" in the
       
   274         *                           dmc_event_handler_ape_cent.cpp-file.
       
   275         * @param   aKernMsgPtr      Pointer to Kernel event
       
   276         * @return  1: Bit set to indicate that a requested event is part of the any state. 
       
   277         *          0: Bit not set to indicate that a requested event is not part of the any state.
       
   278         */
       
   279         static TUint8 IsAnyStateEvent(const TUint8 aEventType, const TUint8* const aKernMsgPtr);
       
   280 
       
   281     private: // data types
       
   282 
       
   283         /**
       
   284         * A pointer to DMC extension.
       
   285         * DMC extension owns this pointer.
       
   286         * 
       
   287         */
       
   288         static DDmcExtension* iDmcExtPtr;
       
   289 
       
   290         /**
       
   291         * A pointer to mutex.
       
   292         * This class owns this pointer.
       
   293         * 
       
   294         */
       
   295         static DMutex* iMutexPtr;
       
   296 
       
   297         /**
       
   298         * A pointer to DMC user / kernel Dfc-queue.
       
   299         * This class does not own this pointer.
       
   300         * 
       
   301         */
       
   302         static TDfc* iUserEventDfcPtr;
       
   303 
       
   304         /**
       
   305         * A target start-up mode. 
       
   306         * Values in the boot_reason_api.h-file.
       
   307         */
       
   308         static TBootReason::TStartupMode iTargetStartupMode;
       
   309 
       
   310         /**
       
   311         * A  hidden reset status. 
       
   312         * Values in the boot_reason_api.h-file.
       
   313         *
       
   314         * ETrue if the reset is hidden, otherwise EFalse.
       
   315         */
       
   316         static TBool iHiddenStatus;
       
   317 
       
   318         /**
       
   319         * This bitmap a defines requests that are part
       
   320         * of the any state.
       
   321         */
       
   322         static const TUint32 iAnyStateMap;
       
   323 
       
   324         /**
       
   325         * This variable is needed to detect whether the Power Handler
       
   326         * PowerDown() has been called.
       
   327         *
       
   328         * DMC needs this information to know if the Power Handler 
       
   329         * PowerDownDone must be called in case the modem connection
       
   330         * is lost and there is an ongoing transaction. 
       
   331         *
       
   332         * If there is no ongoing transaction, the modem connection
       
   333         * lost is handled as a "MODEM_UNCONTROLLED_RESET".
       
   334         * 
       
   335         * Only one transaction is allowed, thus if there is already
       
   336         * ongoing transaction, the modem connection is handled as
       
   337         * below.
       
   338         *
       
   339         * ModemConnection lost AND "transaction ongoing":
       
   340         *     IF "Power Handler PowerDown called"
       
   341         *         -> Acknowlege to Power Handler by
       
   342         *            PowerDownDone()
       
   343         *     ELSE
       
   344         *        -> Standby and wait until Power Handler
       
   345         *           PowerDown() is called and then
       
   346         *           acknowledge back immediately by
       
   347         *           calling PowerDownDone().
       
   348         * 
       
   349         * Allowed values: TRUE / FALSE
       
   350         */
       
   351         static TUint8 iPowerDownCalled;
       
   352 
       
   353         /**
       
   354         * Modem action bit map. 
       
   355         * 
       
   356         * This bit map defines actions that have
       
   357         * been happend in the Modem state transition
       
   358         * and a modem connection.
       
   359         * 
       
   360         * Action information is needed to find a correct
       
   361         * slot to acknowledge the Power Handler PowerDownDone.
       
   362         */
       
   363         static TUint8 iModemActionBitMap;
       
   364 
       
   365         /**
       
   366         * A current modem state. 
       
   367         * 
       
   368         * Values from mceisi.h-file.
       
   369         */
       
   370         static TUint8 iModemCurrentState;
       
   371 
       
   372         /**
       
   373         * Event type.
       
   374         *
       
   375         * Defines the type of the event to be sent
       
   376         * user side client. The event type is used in case
       
   377         * PC SW or Modem orginated power off or reset or
       
   378         * in case of uncontrolled Modem reset..
       
   379         * 
       
   380         * Values from OUTPUT EVENTS: defined beginning of this file.
       
   381         */
       
   382         static TUint8 iEventType;
       
   383 
       
   384         /**
       
   385         * Current state
       
   386         * Allowed values defined in dmc_event_handler_ape_cent.cpp-file.
       
   387         *
       
   388         */
       
   389         static TUint8 iCurrentState;
       
   390 
       
   391         /**
       
   392         * This table defines allowed state transitions.
       
   393         */
       
   394         static const TUint8 iStateTransitionMap[];
       
   395     };
       
   396 
       
   397 #endif // DMC_EVENT_HANDLER_APE_CENT_H
       
   398 
       
   399 // End of File