DrvMain.c revision b1c7adde70f3a7dd380758004b9d274dc9abe9ea
1981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
2981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * DrvMain.c
3981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
4981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * All rights reserved.
6981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
7981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Redistribution and use in source and binary forms, with or without
8981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * modification, are permitted provided that the following conditions
9981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * are met:
10981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
11981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Redistributions of source code must retain the above copyright
12981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    notice, this list of conditions and the following disclaimer.
13981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Redistributions in binary form must reproduce the above copyright
14981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    notice, this list of conditions and the following disclaimer in
15981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    the documentation and/or other materials provided with the
16981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    distribution.
17981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  * Neither the name Texas Instruments nor the names of its
18981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    contributors may be used to endorse or promote products derived
19981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *    from this software without specific prior written permission.
20981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
21981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
33981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
34981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
35981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** \file   DrvMain.c
36981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \brief  The DrvMain module. Handles driver init, stop and recovery processes.
37981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
38981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *  \see    DrvMain.h
39981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
40981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
41981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define __FILE_ID__  FILE_ID_49
42981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "tidef.h"
43981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "osApi.h"
44981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "report.h"
45981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "context.h"
46981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "timer.h"
47981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "CmdHndlr.h"
48981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "DrvMain.h"
49981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "scrApi.h"
50981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "EvHandler.h"
51981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "connApi.h"
52981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "siteMgrApi.h"
53981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "sme.h"
54981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "SoftGeminiApi.h"
55981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "roamingMngrApi.h"
56981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "qosMngr_API.h"
57981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "TrafficMonitor.h"
58981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "PowerMgr_API.h"
59981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "EvHandler.h"
60981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "apConn.h"
61981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "currBss.h"
62981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "SwitchChannelApi.h"
63981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "ScanCncn.h"
64981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "healthMonitor.h"
65981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "scanMngrApi.h"
66981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "regulatoryDomainApi.h"
67981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "measurementMgrApi.h"
68981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
69981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "XCCMngr.h"
70981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
71981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "TxnQueue.h"
72981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "TWDriver.h"
73981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "debug.h"
74981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "host_platform.h"
75981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "StaCap.h"
76981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "WlanDrvCommon.h"
77981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "DrvMainModules.h"
78981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#include "CmdDispatcher.h"
79981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
80981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
81981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define SM_WATCHDOG_TIME_MS     20000  /* SM processes timeout is 20 sec. */
82981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
83653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt#define SDIO_CONNECT_THRESHOLD  8
84653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
85981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
86981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* Handle failure status from the SM callbacks by triggering the SM with FAILURE event */
87981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#define HANDLE_CALLBACKS_FAILURE_STATUS(hDrvMain, eStatus)      \
88981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (eStatus != TI_OK) { drvMain_SmEvent (hDrvMain, SM_EVENT_FAILURE);  return; }
89981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
90981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* The DrvMain SM states */
91981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef enum
92981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
93981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  0 */ SM_STATE_IDLE,
94981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  1 */ SM_STATE_WAIT_INI_FILE,
95981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  2 */ SM_STATE_WAIT_NVS_FILE,
96981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  3 */ SM_STATE_HW_INIT,
97653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    /*  4 */ SM_STATE_DOWNLOAD_FW_FILE,
98981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  5 */ SM_STATE_WAIT_FW_FILE,
99981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  6 */ SM_STATE_FW_INIT,
100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  7 */ SM_STATE_FW_CONFIG,
101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  8 */ SM_STATE_OPERATIONAL,
102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  9 */ SM_STATE_DISCONNECTING,
103981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 10 */ SM_STATE_STOPPING,
104981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 11 */ SM_STATE_STOPPED,
105981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 12 */ SM_STATE_STOPPING_ON_FAIL,
106981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 13 */ SM_STATE_FAILED
107981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
108981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} ESmState;
109981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
110981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* The DrvMain SM events */
111981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef enum
112981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
113981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  0 */ SM_EVENT_START,
114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  1 */ SM_EVENT_INI_FILE_READY,
115981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  2 */ SM_EVENT_NVS_FILE_READY,
116981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  3 */ SM_EVENT_HW_INIT_COMPLETE,
117981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  4 */ SM_EVENT_FW_FILE_READY,
118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  5 */ SM_EVENT_FW_INIT_COMPLETE,
119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  6 */ SM_EVENT_FW_CONFIG_COMPLETE,
120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  7 */ SM_EVENT_STOP,
121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  8 */ SM_EVENT_RECOVERY,
122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*  9 */ SM_EVENT_DISCONNECTED,
123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 10 */ SM_EVENT_STOP_COMPLETE,
124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* 11 */ SM_EVENT_FAILURE
125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
126981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} ESmEvent;
127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* The module's object */
129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidttypedef struct
130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TStadHandlesList  tStadHandles; /* All STAD modules handles (distributed in driver init process) */
132981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_BOOL           bRecovery;    /* Indicates if we are during recovery process */
133981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    ESmState          eSmState;     /* The DrvMain SM state. */
134981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    ESmEvent          ePendingEvent;/* A pending event issued when the SM is busy */
135981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32         uPendingEventsCount; /* Counts the number of events pending for SM execution */
136981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TFileInfo         tFileInfo;    /* Information of last file retrieved by os_GetFile() */
137981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT32         uContextId;   /* ID allocated to this module on registration to context module */
138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    EActionType       eAction;      /* The last action (start/stop) inserted to the driver */
139981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    void             *hSignalObj;   /* The signal object used for waiting for action completion */
140981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE         hWatchdogTimer;/* SM Watchdog timer - expires upon deadlock in Start/Stop/Recovery processes. */
141981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TBusDrvCfg        tBusDrvCfg;   /* A union (struc per each supported bus type) for the bus driver configuration */
142981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt} TDrvMain;
144981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
145981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_Init (TI_HANDLE hDrvMain);
147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_InitHwCb (TI_HANDLE hDrvMain, TI_STATUS eStatus);
148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_InitFwCb (TI_HANDLE hDrvMain, TI_STATUS eStatus);
149981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_ConfigFwCb (TI_HANDLE hDrvMain, TI_STATUS eStatus);
150981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_TwdStopCb (TI_HANDLE hDrvMain, TI_STATUS eStatus);
151981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_InitFailCb (TI_HANDLE hDrvMain, TI_STATUS eStatus);
152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_InitLocals (TDrvMain *pDrvMain);
153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* static void drvMain_SmWatchdogTimeout (TI_HANDLE hDrvMain); */
154981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_SmEvent (TI_HANDLE hDrvMain, ESmEvent eEvent);
155981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_Sm (TI_HANDLE hDrvMain, ESmEvent eEvent);
156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
157981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/* External functions prototypes */
158981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
159981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** \brief WLAN Driver I/F Get file
160981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
161981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hOs         - OS module object handle
162981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pFileInfo   - Pointer to output file information
163981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return TI_OK on success or TI_NOK on failure
164981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
165981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \par Description
166981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * This function provides access to a requested init file:
167981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * It provides the requested file information and call the requester callback.
168981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Note that in Linux the files were previously loaded to driver memory by the loader
169981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
170981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
171981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
172981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtextern int  wlanDrvIf_GetFile (TI_HANDLE hOs, TFileInfo *pFileInfo);
173981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** \brief WLAN Driver I/F Update Driver State
174981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
175653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt * \param  hOs          - OS module object handle
176653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt * \param  eDriverState - New Driver State
177981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
178981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
179981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \par Description
180981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * This function Update the driver state (Idle | Running | Stopped |Failed):
181981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
182981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
183981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
184981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtextern void wlanDrvIf_UpdateDriverState (TI_HANDLE hOs, EDriverSteadyState eDriverState);
185981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** \brief WLAN Driver I/F Set MAC Address
186981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
187653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt * \param  hOs          - OS module object handle
188653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt * \param  pMacAddr     - Pointer to MAC address to set
189981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
190981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
191981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \par Description
192981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * This function Update the driver MAC address by copy it to the network interface structure
193981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
194981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
195981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
196981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtextern void wlanDrvIf_SetMacAddress (TI_HANDLE hOs, TI_UINT8 *pMacAddr);
197981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/** \brief OS Init Table INI File
198981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
199653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt * \param  hOs              - OS module object handle
200653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt * \param  InitTable        - Pointer to initialization table
201653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt * \param  file_buf         - Pointer to Input buffer from INI file
202653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt * \param  file_length      - Length of input buffer from INI file
203981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
204981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
205981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \par Description
206981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * This function perform Initializing of init table accrding to data from INI file and driver defaults
207981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
208981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
209981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
210981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtextern int  osInitTable_IniFile (TI_HANDLE hOs, TInitTable *InitTable, char *file_buf, int file_length);
211981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
212981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
213981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
214981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
215981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_Create
216981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Create the driver modules
217981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
218981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Create all STAD and TWD modules.
219981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Then call all modules init functions which initializes their handles and variables.
220981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
221981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
222981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hOs          - Handle to the Os Abstraction Layer
223981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pDrvMainHndl - Pointer for returning the DrvMain handle.
224981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pCmdHndlr    - Pointer for returning the CmdHndlr handle.
225981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pContext     - Pointer for returning the Context handle.
226981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pTxDataQ     - Pointer for returning the TxDataQ handle.
227981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pTxMgmtQ     - Pointer for returning the TxMgmtQ handle.
228981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pTxCtrl      - Pointer for returning the TxCtrl handle.
229981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pTwd         - Pointer for returning the TWD handle.
230981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pEvHandler   - Pointer for returning the EvHndler handle.
231981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return Handle to the DrvMain module (NULL if failed)
232981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
233981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
234981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS drvMain_Create (TI_HANDLE  hOs,
235981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE *pDrvMainHndl,
236981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE *pCmdHndlr,
237981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE *pContext,
238981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE *pTxDataQ,
239981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE *pTxMgmtQ,
240981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE *pTxCtrl,
241981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE *pTwd,
242981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                          TI_HANDLE *pEvHandler)
243981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
244981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Create the DrvMain module object. */
245981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain *pDrvMain = (TDrvMain *) os_memoryAlloc (hOs, sizeof(TDrvMain));
246981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
247981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain == NULL)
248981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
249981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
250981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
251981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
252981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_memoryZero (hOs, (void *)pDrvMain, sizeof(TDrvMain));
253981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
254981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hDrvMain = (TI_HANDLE)pDrvMain;
255981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hOs = hOs;
256981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
257981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Create watchdog timer to detect deadlocks in the DrvMain SM processes. */
258981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* return thr timer later on */
259981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*pDrvMain->hWatchdogTimer = os_timerCreate (hOs, drvMain_SmWatchdogTimeout, (TI_HANDLE)pDrvMain);
260981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->hWatchdogTimer == NULL)
261981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
262981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
263981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
264981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }*/
265981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
266981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
267981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   Create all driver modules
268981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *   =========================
269981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
270981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
271981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hContext = context_Create (hOs);
272981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hContext == NULL)
273981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
274981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
275981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
276981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
277981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
278981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hTimer = tmr_Create (hOs);
279981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTimer == NULL)
280981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
281981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
282981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
283981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
284981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
285981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hSCR = scr_create (hOs);
286981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hSCR == NULL)
287981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
288981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
289981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
290981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
291981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
292981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hTxnQ = txnQ_Create (hOs);
293981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTxnQ == NULL)
294981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
295981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
296981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
297981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
298981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
299981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hEvHandler = EvHandler_Create (hOs);
300981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hEvHandler == NULL)
301653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    {
302653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        drvMain_Destroy (pDrvMain);
303653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        return TI_NOK;
304653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    }
305981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
306653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pDrvMain->tStadHandles.hReport = report_Create (hOs);
307653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    if (pDrvMain->tStadHandles.hReport == NULL)
308981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
309981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
310981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
311981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
312981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
313981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hConn = conn_create (hOs);
314981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hConn == NULL)
315981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
316981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
317981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
318981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
319981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
320981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hScanCncn = scanCncn_Create (hOs);
321981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hScanCncn == NULL)
322981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
323981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
324981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
325981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
326981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
327981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hSme = sme_Create (hOs);
328981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hSme == NULL)
329981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
330981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
331981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
332981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
333981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
334981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hSiteMgr = siteMgr_create (hOs);
335981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hSiteMgr == NULL)
336981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
337981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
338981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
339981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
340981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
341981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hMlmeSm = mlme_create (hOs);
342981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hMlmeSm == NULL)
343981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
344981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
345981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
346981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
347981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
348981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hAuth = auth_create (hOs);
349981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hAuth == NULL)
350981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
351981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
352981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
353981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
354981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
355981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hAssoc = assoc_create (hOs);
356981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hAssoc == NULL)
357981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
358981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
359981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
360981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
361981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
362981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hRxData = rxData_create (hOs);
363981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hRxData == NULL)
364981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
365981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
366981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
367981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
368981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
369981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hTxCtrl = txCtrl_Create (hOs);
370981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTxCtrl == NULL)
371981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
372981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
373981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
374981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
375981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
376981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hTxDataQ = txDataQ_Create(hOs);
377981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTxDataQ == NULL)
378981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
379981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
380981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
381981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
382981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
383981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hTxMgmtQ = txMgmtQ_Create(hOs);
384981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTxMgmtQ == NULL)
385981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
386981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
387981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
388981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
389981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
390981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hTxPort = txPort_create (hOs);
391981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTxPort == NULL)
392981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
393981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
394981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
395981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
396981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
397981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hCtrlData = ctrlData_create (hOs);
398981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hCtrlData == NULL)
399981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
400981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
401981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
402981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
403981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
404981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hTrafficMon = TrafficMonitor_create (hOs);
405981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTrafficMon == NULL)
406981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
407981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
408981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
409981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
410981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
411981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hRsn = rsn_create (hOs);
412981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hRsn == NULL)
413981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
414981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
415981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
416981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
417981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
418981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hRegulatoryDomain = regulatoryDomain_create (hOs);
419981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hRegulatoryDomain == NULL)
420981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
421981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
422981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
423981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
424981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
425981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hMeasurementMgr = measurementMgr_create (hOs);
426981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hMeasurementMgr == NULL)
427981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
428981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
429981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
430981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
431981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
432981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hSoftGemini = SoftGemini_create (hOs);
433981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hSoftGemini == NULL)
434981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
435981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
436981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
437981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
438981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
439981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
440981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hXCCMngr = XCCMngr_create (hOs);
441981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hXCCMngr == NULL)
442981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
443981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
444981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
445981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
446981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#else
447981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hXCCMngr = NULL;
448981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
449981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
450981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hRoamingMngr = roamingMngr_create (hOs);
451981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hRoamingMngr == NULL)
452981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
453981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
454981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
455981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
456981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
457981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hAPConnection = apConn_create (hOs);
458981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hAPConnection == NULL)
459981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
460981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
461981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
462981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
463981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
464981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hCurrBss = currBSS_create (hOs);
465981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hCurrBss == NULL)
466981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
467981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
468981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
469981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
470981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
471981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hQosMngr = qosMngr_create (hOs);
472981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hQosMngr == NULL)
473981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
474981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
475981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
476981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
477981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
478981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hPowerMgr = PowerMgr_create (hOs);
479981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hPowerMgr == NULL)
480981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
481981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
482981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
483981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
484981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
485981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hSwitchChannel = switchChannel_create (hOs);
486981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hSwitchChannel == NULL)
487981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
488981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
489981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
490981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
491981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
492981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hScanMngr = scanMngr_create (hOs);
493981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (NULL == pDrvMain->tStadHandles.hScanMngr)
494981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
495981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
496981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
497981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
498981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
499981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hHealthMonitor = healthMonitor_create (hOs);
500981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (NULL == pDrvMain->tStadHandles.hHealthMonitor)
501981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
502981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
503981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
504981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
505981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
506981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hTWD = TWD_Create (hOs);
507981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTWD == NULL)
508981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
509981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
510981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
511981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
512981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
513653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pDrvMain->tStadHandles.hCmdHndlr = cmdHndlr_Create (hOs, pDrvMain->tStadHandles.hEvHandler);
514981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hCmdHndlr == NULL)
515981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
516981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
517981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
518981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
519981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
520981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hCmdDispatch = cmdDispatch_Create (hOs);
521981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hCmdDispatch == NULL)
522981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
523981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
524981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
525981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
526981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
527981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tStadHandles.hStaCap = StaCap_Create (hOs);
528981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hStaCap == NULL)
529981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
530981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Destroy (pDrvMain);
531981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
532981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
533981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
534981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Bind all modules handles */
535981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    drvMain_Init ((TI_HANDLE)pDrvMain);
536981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
537981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
538981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Provide required handles to the OAL */
539981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    *pDrvMainHndl = (TI_HANDLE)pDrvMain;
540981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    *pCmdHndlr    = pDrvMain->tStadHandles.hCmdHndlr;
541981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    *pContext     = pDrvMain->tStadHandles.hContext;
542981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    *pTxDataQ     = pDrvMain->tStadHandles.hTxDataQ;
543981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    *pTxMgmtQ     = pDrvMain->tStadHandles.hTxMgmtQ;
544981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    *pTxCtrl      = pDrvMain->tStadHandles.hTxCtrl;
545981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    *pTwd         = pDrvMain->tStadHandles.hTWD;
546981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    *pEvHandler   = pDrvMain->tStadHandles.hEvHandler;
547981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
548981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_INIT_REPORT (("drvMain_Create: success\n"));
549981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
550981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
551981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
552981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
553981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
554981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
555981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_Destroy
556981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Destroy driver
557981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
558981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Destroy all STAD and TWD modules and resources.
559981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
560981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
561981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hDrvMain - The DrvMain object
562981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return TI_OK if succeeded, TI_NOK if failed.
563981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     drvMain_Create
564981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
565981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS drvMain_Destroy (TI_HANDLE  hDrvMain)
566981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
567981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain *pDrvMain = (TDrvMain *)hDrvMain;
568981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
569981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    hPlatform_Wlan_Hardware_DeInit ();
570981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
571981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain == NULL)
572981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
573981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
574981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
575981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
576981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hScanMngr != NULL)
577981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
578981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        scanMngr_unload (pDrvMain->tStadHandles.hScanMngr);
579981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
580981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
581981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hSiteMgr != NULL)
582981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
583981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        siteMgr_unLoad (pDrvMain->tStadHandles.hSiteMgr);
584981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
585981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
586981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hSme != NULL)
587981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
588981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        sme_Destroy (pDrvMain->tStadHandles.hSme);
589981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
590981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
591981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hConn != NULL)
592981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
593981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        conn_unLoad (pDrvMain->tStadHandles.hConn);
594981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
595981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
596981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTWD != NULL)
597981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
598981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TWD_Destroy (pDrvMain->tStadHandles.hTWD);
599981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
600981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
601981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hScanCncn != NULL)
602981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
603981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        scanCncn_Destroy (pDrvMain->tStadHandles.hScanCncn);
604981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
605981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
606981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTrafficMon != NULL)
607981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
608981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TrafficMonitor_Destroy (pDrvMain->tStadHandles.hTrafficMon);
609981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
610981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
611981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hCtrlData != NULL)
612981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
613981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        ctrlData_unLoad (pDrvMain->tStadHandles.hCtrlData);
614981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
615981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
616981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTxCtrl != NULL)
617981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
618981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        txCtrl_Unload (pDrvMain->tStadHandles.hTxCtrl);
619981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
620981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
621981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTxDataQ != NULL)
622981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
623981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        txDataQ_Destroy (pDrvMain->tStadHandles.hTxDataQ);
624981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
625981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
626981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTxMgmtQ != NULL)
627981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
628981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        txMgmtQ_Destroy (pDrvMain->tStadHandles.hTxMgmtQ);
629981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
630981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
631981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTxPort != NULL)
632981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
633981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        txPort_unLoad (pDrvMain->tStadHandles.hTxPort);
634981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
635981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
636981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hRxData != NULL)
637981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
638981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        rxData_unLoad (pDrvMain->tStadHandles.hRxData);
639981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
640981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
641981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hAssoc != NULL)
642981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
643981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        assoc_unload (pDrvMain->tStadHandles.hAssoc);
644981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
645981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
646981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hAuth != NULL)
647981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
648981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        auth_unload (pDrvMain->tStadHandles.hAuth);
649981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
650981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
651981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hMlmeSm != NULL)
652981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
653981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        mlme_unload (pDrvMain->tStadHandles.hMlmeSm);
654981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
655981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
656981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hSCR != NULL)
657981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
658981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        scr_release (pDrvMain->tStadHandles.hSCR);
659981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
660981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
661981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hEvHandler != NULL)
662981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
663981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         EvHandlerUnload (pDrvMain->tStadHandles.hEvHandler);
664981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
665981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
666981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hRsn != NULL)
667981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
668981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        rsn_unload (pDrvMain->tStadHandles.hRsn);
669981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
670981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
671981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hRegulatoryDomain != NULL)
672981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
673981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        regulatoryDomain_destroy (pDrvMain->tStadHandles.hRegulatoryDomain);
674981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
675981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
676981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hMeasurementMgr != NULL)
677981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
678981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        measurementMgr_destroy (pDrvMain->tStadHandles.hMeasurementMgr);
679981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
680981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
681981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hSoftGemini != NULL)
682981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
683981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        SoftGemini_destroy (pDrvMain->tStadHandles.hSoftGemini);
684981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
685981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
686981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
687981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hXCCMngr != NULL)
688981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
689981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        XCCMngr_unload (pDrvMain->tStadHandles.hXCCMngr);
690981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
691981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
692981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
693981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hRoamingMngr != NULL)
694981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
695981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        roamingMngr_unload (pDrvMain->tStadHandles.hRoamingMngr);
696981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
697981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
698981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hQosMngr != NULL)
699981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
700981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        qosMngr_destroy (pDrvMain->tStadHandles.hQosMngr);
701981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
702981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
703981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hPowerMgr != NULL)
704981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
705981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        PowerMgr_destroy (pDrvMain->tStadHandles.hPowerMgr);
706981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
707981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
708981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hAPConnection != NULL)
709981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
710981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        apConn_unload (pDrvMain->tStadHandles.hAPConnection);
711981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
712981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
713981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hCurrBss != NULL)
714981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
715981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        currBSS_unload (pDrvMain->tStadHandles.hCurrBss);
716981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
717981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
718981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hSwitchChannel != NULL)
719981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
720981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        switchChannel_unload (pDrvMain->tStadHandles.hSwitchChannel);
721981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
722981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
723981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hHealthMonitor != NULL)
724981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
725981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        healthMonitor_unload (pDrvMain->tStadHandles.hHealthMonitor);
726981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
727981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
728653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    if (pDrvMain->tStadHandles.hCmdHndlr && pDrvMain->tStadHandles.hEvHandler)
729653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    {
730653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        cmdHndlr_Destroy (pDrvMain->tStadHandles.hCmdHndlr, pDrvMain->tStadHandles.hEvHandler);
731653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    }
732981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
733981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hCmdDispatch)
734981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
735981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        cmdDispatch_Destroy (pDrvMain->tStadHandles.hCmdDispatch);
736981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
737981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
738981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hContext != NULL)
739981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
740981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        context_Destroy (pDrvMain->tStadHandles.hContext);
741981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
742981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
743981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Note: The Timer module must be destroyed last, so all created timers are already destroyed!! */
744981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->tStadHandles.hTimer != NULL)
745981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
746981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        tmr_Destroy (pDrvMain->tStadHandles.hTimer);
747981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
748981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
749981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Destroy the SM watchdog timer */
750981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->hWatchdogTimer != NULL)
751981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
752981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        os_timerDestroy (pDrvMain->tStadHandles.hOs, pDrvMain->hWatchdogTimer);
753981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
754981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
755981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     if (pDrvMain->tStadHandles.hStaCap != NULL)
756981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
757981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        StaCap_Destroy (pDrvMain->tStadHandles.hStaCap);
758981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
759981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
760653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    if (pDrvMain->tStadHandles.hReport != NULL)
761981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
762981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        report_Unload (pDrvMain->tStadHandles.hReport);
763981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
764981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
765981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Destroy the DrvMain object */
766981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_memoryFree (pDrvMain->tStadHandles.hOs, hDrvMain, sizeof(TDrvMain));
767981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
768981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
769981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
770981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
771981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtvoid drvMain_SmeStop (TI_HANDLE hDrvMain)
772981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
773981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    drvMain_SmEvent (hDrvMain, SM_EVENT_DISCONNECTED);
774981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
775981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
776981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
777981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
778981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_Init
779981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Init driver modules
780981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
781981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Called from OS context following the driver creation.
782981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Calls all STAD and TWD modules Init functions, which are saving other modules handles,
783981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *     registering to other modules and initializing their variables.
784981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
785981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
786981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hDrvMain - The DrvMain object
787981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
788981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     drvMain_Create
789981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
790981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_Init (TI_HANDLE hDrvMain)
791981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
792981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain    *pDrvMain = (TDrvMain *) hDrvMain;
793981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TStadHandlesList *pModules = &pDrvMain->tStadHandles; /* The STAD modules handles list */
794981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
795981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*
796981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *  Init all modules handles, variables and registries
797981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     */
798981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    context_Init (pModules->hContext, pModules->hOs, pModules->hReport);
799981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    tmr_Init (pModules->hTimer, pModules->hOs, pModules->hReport, pModules->hContext);
800981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txnQ_Init (pModules->hTxnQ, pModules->hOs, pModules->hReport, pModules->hContext);
801981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    scr_init (pModules);
802981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    conn_init (pModules);
803981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    ctrlData_init (pModules,
804981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                 #ifdef XCC_MODULE_INCLUDED
805981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                   XCCMngr_LinkTestRetriesUpdate, pModules->hXCCMngr);
806981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                 #else
807981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                   NULL, NULL);
808981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                 #endif
809981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    siteMgr_init (pModules);
810981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    regulatoryDomain_init (pModules);
811981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    scanCncn_Init (pModules);
812981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    auth_init (pModules);
813981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    mlme_init (pModules);
814981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    assoc_init (pModules);
815981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rxData_init (pModules);
816981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txCtrl_Init (pModules);
817981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txDataQ_Init (pModules);
818981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txMgmtQ_Init (pModules);
819981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txPort_init (pModules);
820981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TrafficMonitor_Init (pModules, 1000 /* pInitTable->trafficMonitorMinIntervalPercentage */);
821981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    sme_Init (pModules);
822981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rsn_init (pModules);
823981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    measurementMgr_init (pModules);
824981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
825981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    XCCMngr_init (pModules);
826981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
827981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    scanMngr_init (pModules);
828981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    currBSS_init (pModules);
829981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_init (pModules);
830981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    roamingMngr_init (pModules);
831981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    qosMngr_init (pModules);
832981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switchChannel_init (pModules);
833981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    healthMonitor_init (pModules);
834981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    PowerMgr_init (pModules);
835981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    SoftGemini_init (pModules);
836981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdDispatch_Init (pModules);
837981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    StaCap_Init (pModules);
838981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdHndlr_Init (pModules);
839981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
840981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Init TWD component (handles, variables and registries) and provide callbacks for next steps */
841981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TWD_Init (pModules->hTWD,
842981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt              pModules->hReport,
843981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt              pModules->hDrvMain,
844981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt              pModules->hTimer,
845981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt              pModules->hContext,
846981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt              pModules->hTxnQ,
847981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt              (TTwdCallback)drvMain_InitHwCb,
848981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt              (TTwdCallback)drvMain_InitFwCb,
849981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt              (TTwdCallback)drvMain_ConfigFwCb,
850981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt              (TTwdCallback)drvMain_TwdStopCb,
851981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt              (TTwdCallback)drvMain_InitFailCb);
852981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
853981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Init DrvMain module local variables */
854981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    drvMain_InitLocals (pDrvMain);
855981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
856981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
857981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
858981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
859981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_SetDefaults
860981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Set driver default configuration
861981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
862981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Configure all STAD and TWD modules with their default settings from the ini-file.
863981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Timers creation is also done at this stage.
864981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
865981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
866981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hDrvMain - The DrvMain object
867981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pBuf     - The ini-file data.
868981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  uLength  - The ini-file length.
869981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return TI_OK if succeeded, TI_NOK if failed.
870981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     drvMain_Init
871981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
872981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS drvMain_SetDefaults (TI_HANDLE hDrvMain, TI_UINT8 *pBuf, TI_UINT32 uLength)
873981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
874981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain   *pDrvMain = (TDrvMain *) hDrvMain;
875981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TInitTable *pInitTable;
876981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_STATUS   eStatus;
877981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
878981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pInitTable = os_memoryAlloc (pDrvMain->tStadHandles.hOs, sizeof(TInitTable));
879981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
880981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Parse defaults */
881981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    eStatus = osInitTable_IniFile (pDrvMain->tStadHandles.hOs, pInitTable, (char*)pBuf, (int)uLength);
882981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
883981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*
884981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *  Configure modules with their default settings
885981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     */
886981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    report_SetDefaults (pDrvMain->tStadHandles.hReport, &pInitTable->tReport);
887981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    context_SetDefaults (pDrvMain->tStadHandles.hContext, &pInitTable->tContextInitParams);
888981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TWD_SetDefaults (pDrvMain->tStadHandles.hTWD, &pInitTable->twdInitParams);
889981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    conn_SetDefaults (pDrvMain->tStadHandles.hConn, &pInitTable->connInitParams);
890981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    ctrlData_SetDefaults (pDrvMain->tStadHandles.hCtrlData, &pInitTable->ctrlDataInitParams);
891981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    siteMgr_SetDefaults (pDrvMain->tStadHandles.hSiteMgr, &pInitTable->siteMgrInitParams);
892981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    regulatoryDomain_SetDefaults (pDrvMain->tStadHandles.hRegulatoryDomain, &pInitTable->regulatoryDomainInitParams);
893981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    scanCncn_SetDefaults (pDrvMain->tStadHandles.hScanCncn, &pInitTable->tScanCncnInitParams);
894981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    auth_SetDefaults (pDrvMain->tStadHandles.hAuth, &pInitTable->authInitParams);
895981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    assoc_SetDefaults (pDrvMain->tStadHandles.hAssoc, &pInitTable->assocInitParams);
896981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rxData_SetDefaults (pDrvMain->tStadHandles.hRxData, &pInitTable->rxDataInitParams);
897981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    sme_SetDefaults (pDrvMain->tStadHandles.hSme, &pInitTable->tSmeModifiedInitParams, &pInitTable->tSmeInitParams);
898981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    rsn_SetDefaults (pDrvMain->tStadHandles.hRsn, &pInitTable->rsnInitParams);
899981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    measurementMgr_SetDefaults (pDrvMain->tStadHandles.hMeasurementMgr, &pInitTable->measurementInitParams);
900981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#ifdef XCC_MODULE_INCLUDED
901981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    XCCMngr_SetDefaults (pDrvMain->tStadHandles.hXCCMngr, &pInitTable->XCCMngrParams);
902981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif /*XCC_MODULE_INCLUDED*/
903981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    apConn_SetDefaults (pDrvMain->tStadHandles.hAPConnection, &pInitTable->apConnParams);
904981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    qosMngr_SetDefaults (pDrvMain->tStadHandles.hQosMngr, &pInitTable->qosMngrInitParams);
905981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switchChannel_SetDefaults (pDrvMain->tStadHandles.hSwitchChannel, &pInitTable->SwitchChannelInitParams);
906981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    healthMonitor_SetDefaults (pDrvMain->tStadHandles.hHealthMonitor, &pInitTable->healthMonitorInitParams);
907981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    PowerMgr_SetDefaults (pDrvMain->tStadHandles.hPowerMgr, &pInitTable->PowerMgrInitParams);
908981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    SoftGemini_SetDefaults (pDrvMain->tStadHandles.hSoftGemini, &pInitTable->SoftGeminiInitParams);
909981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txDataQ_SetDefaults (pDrvMain->tStadHandles.hTxDataQ, &pInitTable->txDataInitParams);
910981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txCtrl_SetDefaults (pDrvMain->tStadHandles.hTxCtrl, &pInitTable->txDataInitParams);
911981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    currBSS_SetDefaults (pDrvMain->tStadHandles.hCurrBss, &pInitTable->tCurrBssInitParams);
912981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    mlme_SetDefaults (pDrvMain->tStadHandles.hMlmeSm, &pInitTable->tMlmeInitParams);
913981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
914653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    scanMngr_SetDefaults(pDrvMain->tStadHandles.hScanMngr, &pInitTable->tRoamScanMngrInitParams);
915653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    roamingMngr_setDefaults(pDrvMain->tStadHandles.hRoamingMngr, &pInitTable->tRoamScanMngrInitParams);
916653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
917981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Set DrvMain local defaults */
918981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tBusDrvCfg.tSdioCfg.uBlkSizeShift         = pInitTable->tDrvMainParams.uSdioBlkSizeShift;
919981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->tBusDrvCfg.tSdioCfg.uBusDrvThreadPriority = pInitTable->tDrvMainParams.uBusDrvThreadPriority;
920981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_SetDrvThreadPriority (pDrvMain->tStadHandles.hOs, pInitTable->tDrvMainParams.uWlanDrvThreadPriority);
921981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
922981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Release the init table memory */
923981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    os_memoryFree (pDrvMain->tStadHandles.hOs, pInitTable, sizeof(TInitTable));
924981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
925981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return eStatus;
926981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
927981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
928981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
929981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
930981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_xxx...Cb
931981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Callback functions for the init/stop stages completion
932981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
933981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * The following callback functions are called from other modules (most from TWD)
934981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *     when the current init/stop step is completed.
935981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Note that the callbacks are called anyway, either in the original context (if completed), or
936981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *     in another context if pending.
937981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * The first case (same context) may lead to a recursion of the SM, so a special handling is added
938981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *     to the SM to prevent recursion (see drvMain_Sm).
939981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
940981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * drvMain_InitHwCb   - HW init completion callback
941981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * drvMain_InitFwCb   - FW init (mainly download) completion callback
942981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * drvMain_ConfigFwCb - FW configuration completion callback
943981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * drvMain_TwdStopCb  - TWD stopping completion callback
944981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * drvMain_InitFailCb - FW init faulty completion callback
945981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * drvMain_SmeStopCb  - SME stopping completion callback
946981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * drvMain_GetFileCb  - Getting-file completion callback
947981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
948981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
949981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hDrvMain - The DrvMain object
950981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  eStatus  - The process result (TI_OK if succeeded, TI_NOK if failed)
951981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
952981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     drvMain_Create
953981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
954981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_InitHwCb (TI_HANDLE hDrvMain, TI_STATUS eStatus)
955981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
956981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    HANDLE_CALLBACKS_FAILURE_STATUS(hDrvMain, eStatus);
957981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    drvMain_SmEvent (hDrvMain, SM_EVENT_HW_INIT_COMPLETE);
958981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
959981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
960981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_InitFwCb (TI_HANDLE hDrvMain, TI_STATUS eStatus)
961981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
962981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    HANDLE_CALLBACKS_FAILURE_STATUS(hDrvMain, eStatus);
963981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    drvMain_SmEvent (hDrvMain, SM_EVENT_FW_INIT_COMPLETE);
964981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
965981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
966981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_ConfigFwCb (TI_HANDLE hDrvMain, TI_STATUS eStatus)
967981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
968981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    HANDLE_CALLBACKS_FAILURE_STATUS(hDrvMain, eStatus);
969981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    drvMain_SmEvent (hDrvMain, SM_EVENT_FW_CONFIG_COMPLETE);
970981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
971981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
972981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_TwdStopCb (TI_HANDLE hDrvMain, TI_STATUS eStatus)
973981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
974981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    HANDLE_CALLBACKS_FAILURE_STATUS(hDrvMain, eStatus);
975981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    drvMain_SmEvent (hDrvMain, SM_EVENT_STOP_COMPLETE);
976981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
977981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
978981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_InitFailCb (TI_HANDLE hDrvMain, TI_STATUS eStatus)
979981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
980981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    drvMain_SmEvent (hDrvMain, SM_EVENT_FAILURE);
981981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*
982981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     * Note that this call will pass the SM to the FAILED state, since this event
983981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *     is not handled by any state.
984981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     */
985981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
986981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
987981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_InvokeAction (TI_HANDLE hDrvMain)
988981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
989981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain *pDrvMain = (TDrvMain *)hDrvMain;
990981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
991981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (pDrvMain->eAction)
992981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
993653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    case ACTION_TYPE_START:
994653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        drvMain_SmEvent (hDrvMain, SM_EVENT_START);
995653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        break;
996653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    case ACTION_TYPE_STOP:
997653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        drvMain_SmEvent (hDrvMain, SM_EVENT_STOP);
998653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        break;
999981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        default:
1000981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE1(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_ERROR , "drvMain_InvokeAction(): Action=%d\n", pDrvMain->eAction);
1001981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1002981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1003981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1004981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_GetFileCb (TI_HANDLE hDrvMain)
1005981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1006981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain *pDrvMain = (TDrvMain *)hDrvMain;
1007981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    ESmEvent  eSmEvent;
1008981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1009981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (pDrvMain->tFileInfo.eFileType)
1010981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1011981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case FILE_TYPE_INI:     eSmEvent = SM_EVENT_INI_FILE_READY;    break;
1012981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case FILE_TYPE_NVS:     eSmEvent = SM_EVENT_NVS_FILE_READY;    break;
1013981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case FILE_TYPE_FW:      eSmEvent = SM_EVENT_FW_FILE_READY;     break;
1014981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        case FILE_TYPE_FW_NEXT: eSmEvent = SM_EVENT_FW_FILE_READY;     break;
1015981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        default:
1016981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE1(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_ERROR , "drvMain_GetFileCb(): Unknown eFileType=%d\n", pDrvMain->tFileInfo.eFileType);
1017981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            return;
1018981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1019981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    drvMain_SmEvent (hDrvMain, eSmEvent);
1020981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1021981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1022981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1023981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1024981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_InitLocals
1025981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Init DrvMain module
1026981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1027981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Init the DrvMain variables, register to other modules and set device power to off.
1028981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1029981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
1030981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pDrvMain - The DrvMain object
1031981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
1032981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     drvMain_Init
1033981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1034981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_InitLocals (TDrvMain *pDrvMain)
1035981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1036653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    /* Initialize the module's local varniables to default values */
1037653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pDrvMain->tFileInfo.eFileType   = FILE_TYPE_INI;
1038653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pDrvMain->tFileInfo.fCbFunc     = drvMain_GetFileCb;
1039653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pDrvMain->tFileInfo.hCbHndl     = (TI_HANDLE)pDrvMain;
1040653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pDrvMain->eSmState              = SM_STATE_IDLE;
1041653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pDrvMain->uPendingEventsCount   = 0;
1042653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pDrvMain->bRecovery             = TI_FALSE;
1043653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pDrvMain->eAction               = ACTION_TYPE_NONE;
1044653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1045653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    /* Register the Action callback to the context engine and get the client ID */
1046653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pDrvMain->uContextId = context_RegisterClient (pDrvMain->tStadHandles.hContext,
1047981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                   drvMain_InvokeAction,
1048981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                   (TI_HANDLE)pDrvMain,
1049981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                   TI_TRUE,
1050981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                   "ACTION",
1051981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                                                   sizeof("ACTION"));
1052981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1053653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    /* Platform specific HW preparations */
105412d754a18612383f03b960dfad4dbcaba72df370Dmitry Shmidt	hPlatform_Wlan_Hardware_Init(pDrvMain->tStadHandles.hOs);
1055981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1056653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    /* Insure that device power is off (expected to be) */
1057653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    hPlatform_DevicePowerOff ();
1058981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1059981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1060981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1061981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1062981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_InitHw & drvMain_InitFw
1063981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Init HW and Init FW sequences
1064981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1065981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * drvMain_InitHw - HW init sequence which writes and reads some HW registers
1066981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *                      that are needed prior to FW download.
1067981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * drvMain_InitFw - FW init sequence which downloads the FW image and waits for
1068981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *                      FW init-complete indication.
1069981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1070981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
1071981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hDrvMain - The DrvMain object
1072981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pBuf     - The file data (NVS for HW-init, FW-Image for FW-init).
1073981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  uLength  - The file length.
1074981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return TI_OK if succeeded, TI_NOK if failed.
1075981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
1076981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1077981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS drvMain_InitHw (TI_HANDLE hDrvMain, TI_UINT8 *pbuf, TI_UINT32 uLength)
1078981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1079981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain   *pDrvMain = (TDrvMain *) hDrvMain;
1080981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1081981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TWD_InitHw (pDrvMain->tStadHandles.hTWD, pbuf, uLength);
1082981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1083981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1084981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS drvMain_InitFw (TI_HANDLE hDrvMain, TFileInfo *pFileInfo)
1085981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1086981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain   *pDrvMain = (TDrvMain *) hDrvMain;
1087981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1088981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TWD_InitFw (pDrvMain->tStadHandles.hTWD, pFileInfo);
1089981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1090981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1091981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1092981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1093981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_ConfigFw
1094981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Configure the FW
1095981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1096981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * The step that follows the FW Init (mainly FW download).
1097981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * The Command-Mailbox interface is enabled here and the FW is configured.
1098981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1099981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
1100981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pDrvMain - The DrvMain object
1101981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return TI_OK
1102981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     drvMain_Init
1103981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1104981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS drvMain_ConfigFw (TI_HANDLE hDrvMain)
1105981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1106981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain    *pDrvMain = (TDrvMain *) hDrvMain;
1107981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1108981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* get pointer to FW static info (already in driver memory) */
1109981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TFwInfo     *pFwInfo  = TWD_GetFWInfo (pDrvMain->tStadHandles.hTWD);
1110981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_UINT8    *pMacAddr = (TI_UINT8 *)pFwInfo->macAddress; /* STA MAC address */
1111981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1112981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Update driver's MAC address */
1113981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    wlanDrvIf_SetMacAddress (pDrvMain->tStadHandles.hOs, pMacAddr);
1114981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1115981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*
1116981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *  Exit from init mode should be before smeSM starts. this enable us to send
1117981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *  command to the MboxQueue(that store the command) while the interrupts are masked.
1118981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *  the interrupt would be enable at the end of the init process.
1119981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     */
1120981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TWD_ExitFromInitMode (pDrvMain->tStadHandles.hTWD);
1121981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1122981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Configure the FW from the TWD DB */
1123981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TWD_ConfigFw (pDrvMain->tStadHandles.hTWD);
1124981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1125981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE0(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_INIT , "EXIT FROM INIT\n");
1126981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1127981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Print the driver and firmware version and the mac address */
1128981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("\n"));
1129981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("--------------------------------------------------------------------\n"));
1130981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("Driver Version  : %s\n", SW_VERSION_STR));
1131981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("Firmware Version: %s\n", pFwInfo->fwVer));
1132981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("Station ID      : %02X-%02X-%02X-%02X-%02X-%02X\n",
1133981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                    pMacAddr[0], pMacAddr[1], pMacAddr[2], pMacAddr[3], pMacAddr[4], pMacAddr[5]));
1134981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("--------------------------------------------------------------------\n"));
1135981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT(("\n"));
1136981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1137981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1138981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1139981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1140981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1141981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1142981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_StopActivities
1143981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Freeze driver activities
1144981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1145981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Freeze all driver activities due to stop command or recovery process.
1146981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1147981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
1148981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pDrvMain - The DrvMain object
1149981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return TI_OK if succeeded, TI_NOK if failed.
1150981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     drvMain_EnableActivities
1151981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1152981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic TI_STATUS drvMain_StopActivities (TDrvMain *pDrvMain)
1153981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1154981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txPort_suspendTx (pDrvMain->tStadHandles.hTxPort);
1155981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1156981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Disable External Inputs (IRQs and commands) */
1157981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TWD_DisableInterrupts(pDrvMain->tStadHandles.hTWD);
1158981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdHndlr_Disable (pDrvMain->tStadHandles.hCmdHndlr);
1159981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1160981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Initiate TWD Restart */
1161981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TWD_Stop (pDrvMain->tStadHandles.hTWD);
1162981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1163981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1164981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1165981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1166981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_EnableActivities
1167981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Enable driver activities
1168981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1169981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Enable driver activities after init or recovery process completion.
1170981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1171981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
1172981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pDrvMain - The DrvMain object
1173981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
1174981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa     drvMain_StopActivities
1175981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1176981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_EnableActivities (TDrvMain *pDrvMain)
1177981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1178981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txPort_resumeTx (pDrvMain->tStadHandles.hTxPort);
1179981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1180981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt   /* Enable External Inputs (IRQ is enabled elsewhere) */
1181981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdHndlr_Enable (pDrvMain->tStadHandles.hCmdHndlr);
1182981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1183981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Enable external events from FW */
1184981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TWD_EnableExternalEvents (pDrvMain->tStadHandles.hTWD);
1185981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1186981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1187981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1188981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1189981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1190981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1191981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_ClearQueuedEvents
1192981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Enable driver activities
1193981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1194981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Clear all external events queues (Tx, commands and timers) upon driver stop.
1195981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1196981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
1197981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pDrvMain - The DrvMain object
1198981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
1199981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
1200981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1201981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_ClearQueuedEvents (TDrvMain *pDrvMain)
1202981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1203981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txDataQ_ClearQueues (pDrvMain->tStadHandles.hTxDataQ);
1204981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txMgmtQ_ClearQueues (pDrvMain->tStadHandles.hTxMgmtQ);
1205981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    cmdHndlr_ClearQueue (pDrvMain->tStadHandles.hCmdHndlr);
1206981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    tmr_ClearOperQueue (pDrvMain->tStadHandles.hTimer);
1207981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1208981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1209981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1210981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1211981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_InsertAction
1212981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Get start/stop action and trigger handling
1213981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1214981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Get start or stop action command from OAL, save it and trigger driver task
1215981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *     for handling it.
1216981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Wait on a signal object until the requested process is completed.
1217981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1218981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
1219981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hDrvMain - The DrvMain object
1220981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  eAction  - The requested action
1221981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
1222981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
1223981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1224981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS drvMain_InsertAction (TI_HANDLE hDrvMain, EActionType eAction)
1225981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1226981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain *pDrvMain = (TDrvMain *) hDrvMain;
1227981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1228981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->eAction == eAction)
1229981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1230981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_CONSOLE, "Action is identical to last action!\n");
1231981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        WLAN_OS_REPORT(("Action is identical to last action!\n"));
1232981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
1233981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1234981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1235981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Save the requested action */
1236981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->eAction = eAction;
1237981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1238981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Create signal object */
1239981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*
1240981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     * Notice that we must create the signal object before asking for ReSchedule,
1241981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     * because we might receive it immidiatly, and then we will be in a different context
1242981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     * with null signal object.
1243981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     */
1244653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    pDrvMain->hSignalObj = os_SignalObjectCreate (pDrvMain->tStadHandles.hOs);
1245981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->hSignalObj == NULL)
1246981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1247981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_ERROR , "drvMain_InsertAction(): Couldn't allocate signal object!\n");
1248981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
1249981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1250981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1251981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Request driver task schedule for action handling */
1252981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    context_RequestSchedule (pDrvMain->tStadHandles.hContext, pDrvMain->uContextId);
1253981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1254981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Wait for the action processing completion */
1255653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    os_SignalObjectWait (pDrvMain->tStadHandles.hOs, pDrvMain->hSignalObj);
1256981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1257653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    /* After "wait" - the action has already been processed in the driver's context */
1258981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1259653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    /* Free signalling object */
1260653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    os_SignalObjectFree (pDrvMain->tStadHandles.hOs, pDrvMain->hSignalObj);
1261981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1262981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->eSmState == SM_STATE_FAILED)
1263981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_NOK;
1264981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1265981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    return TI_OK;
1266981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1267981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1268981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1269981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1270981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_Recovery
1271981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Initiate recovery process
1272981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1273981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Initiate recovery process upon HW/FW error detection (in the Health-Monitor).
1274981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1275981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
1276981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hDrvMain - The DrvMain object
1277981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return TI_OK if started recovery, TI_NOK if recovery is already in progress.
1278981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
1279981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1280981801b95b81e6d1c7a2085967406e86af0f08fcDmitry ShmidtTI_STATUS drvMain_Recovery (TI_HANDLE hDrvMain)
1281981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1282981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain         *pDrvMain = (TDrvMain *) hDrvMain;
1283981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1284981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (!pDrvMain->bRecovery)
1285981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1286981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE1(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_CONSOLE,".....drvMain_Recovery, ts=%d\n", os_timeStampMs(pDrvMain->tStadHandles.hOs));
1287981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        WLAN_OS_REPORT((".....drvMain_Recovery, ts=%d\n", os_timeStampMs(pDrvMain->tStadHandles.hOs)));
1288981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pDrvMain->bRecovery = TI_TRUE;
1289981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_SmEvent (hDrvMain, SM_EVENT_RECOVERY);
1290981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_OK;
1291981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1292981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    else
1293981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1294981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE0(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_ERROR, "drvMain_Recovery: ****  Recovery already in progress!  ****\n");
1295981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return TI_NOK;
1296981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1297981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1298981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1299981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1300981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1301981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_RecoveryNotify
1302981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Notify STAD modules about recovery
1303981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1304981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Notify the relevant STAD modules that recovery took place (after completed).
1305981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1306981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
1307981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  pDrvMain - The DrvMain object
1308981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
1309981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
1310981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1311981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_RecoveryNotify (TDrvMain *pDrvMain)
1312981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1313981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    txCtrl_NotifyFwReset (pDrvMain->tStadHandles.hTxCtrl);
1314981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    scr_notifyFWReset (pDrvMain->tStadHandles.hSCR);
1315981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    PowerMgr_notifyFWReset (pDrvMain->tStadHandles.hPowerMgr);
1316981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1317981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE1(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_CONSOLE, ".....drvMain_RecoveryNotify: End Of Recovery, ts=%d\n", os_timeStampMs(pDrvMain->tStadHandles.hOs));
1318981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    WLAN_OS_REPORT((".....drvMain_RecoveryNotify: End Of Recovery, ts=%d\n", os_timeStampMs(pDrvMain->tStadHandles.hOs)));
1319981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1320981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1321981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1322981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1323981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_SmWatchdogTimeout
1324981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  SM watchdog timer expiry handler
1325981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1326981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * This is the callback function called upon expiartion of the watchdog timer.
1327981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * It is called by the OS-API in timer expiry context, and it issues a failure event to the SM.
1328981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Note that we can't switch to the driver task as for other timers, since we are using
1329981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *     this timer to protect the init processes, and anyway we just need to stop the driver.
1330981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1331981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note
1332981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hDrvMain - The DrvMain object
1333981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
1334981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
1335981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1336981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1337981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#if 0
1338981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_SmWatchdogTimeout (TI_HANDLE hDrvMain)
1339981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1340981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain *pDrvMain = (TDrvMain *)hDrvMain;
1341981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1342981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE1(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_ERROR , "drvMain_SmWatchdogTimeout():  State = %d\n", pDrvMain->eSmState);
1343981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1344981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Send failure event directly to the SM (so the drvMain_SmEvent won't block it).  */
1345981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1346981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    drvMain_Sm ((TI_HANDLE)pDrvMain, SM_EVENT_FAILURE);
1347981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1348981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt#endif
1349981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1350981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1351981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_SmEvent
1352981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  Issue DrvMain SM event
1353981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1354981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * Each event that is handled by the DrvMain state machine, is introduced through this function.
1355981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * To prevent SM recursion, the SM is invoeked only if it's not already handling the
1356981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *      previous event.
1357981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * If the SM is busy, the current event is saved until the previous handling is completed.
1358981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1359981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note   Recursion may happen because some SM activities generate SM events in the same context.
1360981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hDrvMain - The DrvMain object
1361981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  eEvent   - The event issued to the SM
1362981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
1363981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
1364981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1365981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_SmEvent (TI_HANDLE hDrvMain, ESmEvent eEvent)
1366981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1367981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain *pDrvMain = (TDrvMain *)hDrvMain;
1368981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1369981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Increment pending events counter and save last event. */
1370981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->uPendingEventsCount++;
1371981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    pDrvMain->ePendingEvent = eEvent;
1372981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1373981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* If the SM is busy, save event and exit (will be handled when current event is finished) */
1374981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if (pDrvMain->uPendingEventsCount > 1)
1375981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1376981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Only one pending event is expected (in addition to the handled one, so two together). */
1377981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (pDrvMain->uPendingEventsCount > 2)
1378981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1379981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TRACE3(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_ERROR , "drvMain_SmEvent():  Multiple pending events (%d), State = %d, Event = %d\n", pDrvMain->uPendingEventsCount, pDrvMain->eSmState, eEvent);
1380981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1381981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1382981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Exit. The current event will be handled by the following while loop of the first instance. */
1383981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        return;
1384981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1385981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1386981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Invoke the SM with the current event and further events issued by the last SM invocation. */
1387981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    while (pDrvMain->uPendingEventsCount > 0)
1388981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1389981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        drvMain_Sm (hDrvMain, pDrvMain->ePendingEvent);
1390981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1391981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*
1392981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Note: The SM may issue another event by calling this function and incrementing
1393981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         *           the counter.
1394981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         *       In this case, only the upper part of this function is run, and the pending
1395981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         *           event is hanlded in the next while loo[.
1396981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1397981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1398981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pDrvMain->uPendingEventsCount--;
1399981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1400981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1401981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1402981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1403981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt/*
1404981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \fn     drvMain_Sm
1405981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \brief  The DrvMain state machine
1406981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1407981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * The DrvMain state machine, which handles all driver init, recovery and stop processes.
1408981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *
1409981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \note   Since the SM may be called back from its own context, recursion is prevented
1410981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt *             by postponing the last event.
1411981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  hDrvMain - The DrvMain object
1412981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \param  eEvent   - The event that triggers the SM
1413981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \return void
1414981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt * \sa
1415981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt */
1416981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidtstatic void drvMain_Sm (TI_HANDLE hDrvMain, ESmEvent eEvent)
1417981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt{
1418981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TDrvMain    *pDrvMain   = (TDrvMain *)hDrvMain;
1419981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_STATUS    eStatus    = TI_NOK;
1420981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TI_HANDLE    hOs        = pDrvMain->tStadHandles.hOs;
1421653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    TI_UINT32    uSdioConIndex = 0;
1422981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1423981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    TRACE2(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_INFORMATION , "drvMain_Sm():  State = %d, Event = %d\n", pDrvMain->eSmState, eEvent);
1424981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1425981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /*
1426981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *  General explenations:
1427981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *  =====================
1428981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *  1) This SM calls some functions that may complete their processing in another context.
1429981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *     All of these functions (wlanDrvIf_GetFile, drvMain_InitHw, drvMain_InitFw, drvMain_ConfigFw,
1430981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *         drvMain_StopActivities, smeSm_start, smeSm_stop) are provided with a callback which
1431981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *         they always call upon completion, even if they are completed in the original (SM) context.
1432981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *     Since these callbacks are calling the SM, a simple mechanism is added to prevent
1433981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *         recursion, by postponing the last event if the SM is still in the previous event's context.
1434981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *  2) In any case of unexpected event, the eStatus remains TI_NOK, leading to the FAILED state!
1435981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *     FAILED state is also reached if any of the functions listed in note 1 returns TI_NOK.
1436981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *     Note that if these functions detect a failure in another context, they may call their callback
1437981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *         with the eStatus parameter set to TI_NOK, or call the drvMain_InitFailCb callback.
1438981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *     All these cases lead to FAILED state which terminates all driver activities and wait for destroy.
1439981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *  3) Note that the wlanDrvIf_GetFile is always completed in the original context, and the
1440981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *         option of completion in a later context is only for future use.
1441981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *  4) All processes (Start, Stop, Relcovery) are protected by a watchdog timer to let
1442981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     *         the user free the driver in case of deadlock during the process.
1443981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt     */
1444981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1445981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    switch (pDrvMain->eSmState)
1446981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1447981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_IDLE:
1448981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*
1449981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * We get a START action after all modules are created and linked.
1450981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Disable further actions, start watchdog timer and request for the ini-file.
1451981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1452981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (eEvent == SM_EVENT_START)
1453981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1454981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* return thr timer later on */
1455981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /*os_timerStart (hOs, pDrvMain->hWatchdogTimer, SM_WATCHDOG_TIME_MS);*/
1456981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->eSmState = SM_STATE_WAIT_INI_FILE;
1457981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            context_DisableClient (pDrvMain->tStadHandles.hContext, pDrvMain->uContextId);
1458981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->tFileInfo.eFileType = FILE_TYPE_INI;
1459981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            eStatus = wlanDrvIf_GetFile (hOs, &pDrvMain->tFileInfo);
1460981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1461981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1462981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_WAIT_INI_FILE:
1463981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*
1464981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * We've got the ini-file.
1465981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Set STAD and TWD modules defaults according to the ini-file,
1466981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         *     turn on the device and request for the NVS file.
1467981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1468981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (eEvent == SM_EVENT_INI_FILE_READY)
1469981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1470981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->eSmState = SM_STATE_WAIT_NVS_FILE;
1471981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            drvMain_SetDefaults (hDrvMain, pDrvMain->tFileInfo.pBuffer, pDrvMain->tFileInfo.uLength);
1472981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            hPlatform_DevicePowerOn ();
1473981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1474981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->tFileInfo.eFileType = FILE_TYPE_NVS;
1475981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            eStatus = wlanDrvIf_GetFile (hOs, &pDrvMain->tFileInfo);
1476981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1477981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1478981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1479981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_WAIT_NVS_FILE:
1480981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1481653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        /* SDBus Connect connection validation  */
1482653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        for(uSdioConIndex=0; (uSdioConIndex < SDIO_CONNECT_THRESHOLD) && (eStatus != TI_OK); uSdioConIndex++)
1483981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1484653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt			/* : We should split the call to txnQ_ConnectBus to other state in order to support Async bus connection */
1485653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            eStatus = txnQ_ConnectBus(pDrvMain->tStadHandles.hTxnQ, &pDrvMain->tBusDrvCfg, NULL, NULL);
1486653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt
1487653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt			if((eStatus != TI_OK) &&
1488653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt			   (uSdioConIndex < (SDIO_CONNECT_THRESHOLD - 1)))
1489653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            {
1490653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                     TRACE0(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_WARNING , "SDBus Connect Failed\n");
1491653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                     WLAN_OS_REPORT(("Try to SDBus Connect again...\n"));
1492653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                     if (uSdioConIndex > 1)
1493653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt						hPlatform_DevicePowerOffSetLongerDelay();
1494653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt					 else
1495653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt						hPlatform_DevicePowerOff();
1496653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                     hPlatform_DevicePowerOn();
1497653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            }
1498981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1499981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1500653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt		if(eStatus != TI_OK)
1501653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt		{
1502653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt			WLAN_OS_REPORT(("SDBus Connect Failed, Set Object Event !!\r\n"));
1503653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt			TRACE0(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_ERROR , "SDBus Connect Failed, Set Object Event !!\r\n");
1504b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt			if (!pDrvMain->bRecovery)
1505b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt			{
1506b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt				os_SignalObjectSet(hOs, pDrvMain->hSignalObj);
1507b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt			}
1508b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt                        else
1509b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt			{
1510b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt				/* in case recovery fails, stop the sme which will send disassociation event to os */
1511b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt				sme_Stop(pDrvMain->tStadHandles.hSme);
1512b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt			}
1513653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt		}
1514653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt		else /* SDBus Connect success */
1515981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1516653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /*
1517653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             * We've got the NVS file.
1518653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             * Start HW-Init process providing the NVS file.
1519653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             */
1520653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt			if (eEvent == SM_EVENT_NVS_FILE_READY)
1521653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            {
1522653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                pDrvMain->eSmState = SM_STATE_HW_INIT;
1523653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                eStatus = drvMain_InitHw (hDrvMain, pDrvMain->tFileInfo.pBuffer, pDrvMain->tFileInfo.uLength);
1524653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            }
1525981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1526981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1527981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_HW_INIT:
1528b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt        /*
1529981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * HW-Init process is completed.
1530981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Request for the FW image file.
1531981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1532b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt        if (eEvent == SM_EVENT_HW_INIT_COMPLETE)
1533981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1534981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->tFileInfo.eFileType = FILE_TYPE_FW;
1535981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->eSmState = SM_STATE_DOWNLOAD_FW_FILE;
1536981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            eStatus = wlanDrvIf_GetFile (hOs, &pDrvMain->tFileInfo);
1537981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1538981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1539653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt    case SM_STATE_DOWNLOAD_FW_FILE:
1540b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt        if (eEvent == SM_EVENT_FW_FILE_READY)
1541981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1542653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            pDrvMain->tFileInfo.eFileType = FILE_TYPE_FW_NEXT;
1543653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            if (pDrvMain->tFileInfo.bLast == TI_TRUE)
1544653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            {
1545981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->eSmState = SM_STATE_FW_INIT;
1546653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            }
1547653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            else
1548653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            {
1549653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                pDrvMain->eSmState = SM_STATE_WAIT_FW_FILE;
1550653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            }
1551653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            /*
1552653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             * We've got the FW image file.
1553653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             * Start FW-Init process (mainly FW image download) providing the FW image file.
1554653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt             */
1555653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            eStatus = drvMain_InitFw (hDrvMain, &pDrvMain->tFileInfo);
1556653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        }
1557653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt        break;
1558981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_WAIT_FW_FILE:
1559b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt        if (eEvent == SM_EVENT_FW_INIT_COMPLETE)
1560981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1561653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            pDrvMain->eSmState = SM_STATE_DOWNLOAD_FW_FILE;
1562653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt            eStatus = wlanDrvIf_GetFile (hOs, &pDrvMain->tFileInfo);
1563981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1564981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1565981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_FW_INIT:
1566b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt        /*
1567981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * FW-Init process is completed.
1568981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Free the semaphore of the START action to enable the OS interface.
1569981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Enable interrupts (or polling for debug).
1570981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Start FW-Configuration process, and free the semaphore of the START action.
1571981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         *
1572981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Note that in some OSs, the semaphore must be released in order to enable the
1573981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         *     interrupts, and the interrupts are needed for the configuration process!
1574981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1575b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt        if (eEvent == SM_EVENT_FW_INIT_COMPLETE)
1576981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1577981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->eSmState = SM_STATE_FW_CONFIG;
1578b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt            if (!pDrvMain->bRecovery)
1579981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1580b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt		os_SignalObjectSet(hOs, pDrvMain->hSignalObj);
1581981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1582981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            TWD_EnableInterrupts(pDrvMain->tStadHandles.hTWD);
1583981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt          #ifdef PRIODIC_INTERRUPT
1584981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* Start periodic interrupts. It means that every period of time the FwEvent SM will be called */
1585981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            os_periodicIntrTimerStart (hOs);
1586981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt          #endif
1587981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            eStatus = drvMain_ConfigFw (hDrvMain);
1588981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1589981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1590981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_FW_CONFIG:
1591b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt        /*
1592981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * FW-configuration process is completed.
1593981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Stop watchdog timer.
1594981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * For recovery, notify the relevant STAD modules.
1595981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * For regular start, start the SME which handles the connection process.
1596981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Update timer and OAL about entering OPERATIONAL state (OAL ignores recovery)
1597981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Enable driver activities and external events.
1598981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Enable STOP action
1599981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * We are now in OPERATIONAL state, i.e. the driver is fully operational!
1600981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1601981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1602981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (eEvent == SM_EVENT_FW_CONFIG_COMPLETE)
1603981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1604981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->eSmState = SM_STATE_OPERATIONAL;
1605981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /* return thr timer later on */
1606981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            /*os_timerStop (hOs, pDrvMain->hWatchdogTimer);*/
1607981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (pDrvMain->bRecovery)
1608981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1609981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                drvMain_RecoveryNotify (pDrvMain);
1610981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pDrvMain->bRecovery = TI_FALSE;
1611981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1612981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
1613981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1614981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                sme_Start (pDrvMain->tStadHandles.hSme);
1615981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wlanDrvIf_UpdateDriverState (hOs, DRV_STATE_RUNNING);
1616981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1617981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            tmr_UpdateDriverState (pDrvMain->tStadHandles.hTimer, TI_TRUE);
1618981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            drvMain_EnableActivities (pDrvMain);
1619981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            context_EnableClient (pDrvMain->tStadHandles.hContext, pDrvMain->uContextId);
1620981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            eStatus = TI_OK;
1621981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1622981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1623981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1624981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_OPERATIONAL:
1625981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*
1626981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Disable start/stop commands and start watchdog timer.
1627981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Update timer and OAL about exiting OPERATIONAL state (OAL ignores recovery).
1628981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * For STOP, stop SME (handle disconnection) and move to DISCONNECTING state.
1629981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * For recovery, stop driver activities and move to STOPPING state.
1630981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Note that driver-stop process may be Async if we are during Async bus transaction.
1631981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1632981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1633981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        context_DisableClient (pDrvMain->tStadHandles.hContext, pDrvMain->uContextId);
1634981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* return thr timer later on */
1635981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*os_timerStart (hOs, pDrvMain->hWatchdogTimer, SM_WATCHDOG_TIME_MS);*/
1636981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        tmr_UpdateDriverState (pDrvMain->tStadHandles.hTimer, TI_FALSE);
1637981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (eEvent == SM_EVENT_STOP)
1638981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1639981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->eSmState = SM_STATE_DISCONNECTING;
1640981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            wlanDrvIf_UpdateDriverState (hOs, DRV_STATE_STOPING);
1641981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            sme_Stop (pDrvMain->tStadHandles.hSme);
1642981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            eStatus = TI_OK;
1643981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1644981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        else if (eEvent == SM_EVENT_RECOVERY)
1645981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1646981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->eSmState = SM_STATE_STOPPING;
1647981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            eStatus = drvMain_StopActivities (pDrvMain);
1648981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1649981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1650981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1651981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_DISCONNECTING:
1652981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*
1653981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Note that this state is not relevant for recovery.
1654981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * SME stop is completed
1655981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Stop driver activities and move to STOPPING state.
1656981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Note that driver stop process may be Async if we are during Async bus transaction.
1657981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1658981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1659981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (eEvent == SM_EVENT_DISCONNECTED)
1660981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1661981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->eSmState = SM_STATE_STOPPING;
1662981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            eStatus = drvMain_StopActivities (pDrvMain);
1663981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1664981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1665981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_STOPPING:
1666981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*
1667981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Driver stopping process is done.
1668981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Turn device power off.
1669981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * For recovery, turn device power back on, request NVS file and continue with
1670981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         *     the init process (recover back all the way to OPERATIONAL state).
1671981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * For STOP process, the driver is now fully stopped (STOPPED state), so stop watchdog timer,
1672981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         *     clear all events queues, free the semaphore of the STOP action and enable START action.
1673981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1674981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1675981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (eEvent == SM_EVENT_STOP_COMPLETE)
1676981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1677981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            txnQ_DisconnectBus (pDrvMain->tStadHandles.hTxnQ);
1678981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            hPlatform_DevicePowerOff ();
1679981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            if (pDrvMain->bRecovery)
1680981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1681981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                hPlatform_DevicePowerOn ();
1682981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pDrvMain->eSmState = SM_STATE_WAIT_NVS_FILE;
1683981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pDrvMain->tFileInfo.eFileType = FILE_TYPE_NVS;
1684981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                eStatus = wlanDrvIf_GetFile (hOs, &pDrvMain->tFileInfo);
1685981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1686981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            else
1687981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            {
1688981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                pDrvMain->eSmState = SM_STATE_STOPPED;
1689981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /* return thr timer later on */
1690981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                /*os_timerStop (hOs, pDrvMain->hWatchdogTimer);*/
1691981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                drvMain_ClearQueuedEvents (pDrvMain);
1692653850f71f9caaa41af19cadbab24bb5e655daf4Dmitry Shmidt                scr_notifyFWReset(pDrvMain->tStadHandles.hSCR);
1693981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                os_SignalObjectSet (hOs, pDrvMain->hSignalObj);
1694981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                context_EnableClient (pDrvMain->tStadHandles.hContext, pDrvMain->uContextId);
1695981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                wlanDrvIf_UpdateDriverState (hOs, DRV_STATE_STOPPED);
1696981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt                eStatus = TI_OK;
1697981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            }
1698981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1699981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1700981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1701981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_STOPPED:
1702981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*
1703981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * A START action command was inserted, so we go through the init process.
1704981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Disable further actions, start watchdog timer, turn on device and request NVS file.
1705981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1706981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1707981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        context_DisableClient (pDrvMain->tStadHandles.hContext, pDrvMain->uContextId);
1708981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* return thr timer later on */
1709981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*os_timerStart (hOs, pDrvMain->hWatchdogTimer, SM_WATCHDOG_TIME_MS);*/
1710981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        if (eEvent == SM_EVENT_START)
1711981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        {
1712981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            hPlatform_DevicePowerOn ();
1713981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->eSmState = SM_STATE_WAIT_NVS_FILE;
1714981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            pDrvMain->tFileInfo.eFileType = FILE_TYPE_NVS;
1715981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt            eStatus = wlanDrvIf_GetFile (hOs, &pDrvMain->tFileInfo);
1716981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        }
1717981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1718981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_STOPPING_ON_FAIL:
1719981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*
1720981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Driver stopping process upon failure is completed.
1721981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Turn off the device and move to FAILED state.
1722981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1723981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1724981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pDrvMain->eSmState = SM_STATE_FAILED;
1725981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        txnQ_DisconnectBus (pDrvMain->tStadHandles.hTxnQ);
1726981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        hPlatform_DevicePowerOff ();
1727981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        WLAN_OS_REPORT(("[WLAN] Exit application\n"));
1728b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt        if (!pDrvMain->bRecovery)
1729b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt        {
1730b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt            os_SignalObjectSet (hOs, pDrvMain->hSignalObj);
1731b1c7adde70f3a7dd380758004b9d274dc9abe9eaDmitry Shmidt        }
1732981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1733981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    case SM_STATE_FAILED:
1734981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Nothing to do except waiting for Destroy */
1735981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1736981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt default:
1737981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE2(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_ERROR , "drvMain_Sm: Unknown state, eEvent=%u at state=%u\n", eEvent, pDrvMain->eSmState);
1738981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /* Note: Handled below as a failure since the status remains TI_NOK */
1739981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        break;
1740981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1741981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1742981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    /* Handle failures (status = NOK) if not handled yet */
1743981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    if ((eStatus == TI_NOK) &&
1744981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        (pDrvMain->eSmState != SM_STATE_FAILED) &&
1745981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        (pDrvMain->eSmState != SM_STATE_STOPPING_ON_FAIL))
1746981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    {
1747981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        TRACE3(pDrvMain->tStadHandles.hReport, REPORT_SEVERITY_ERROR , "drvMain_Sm: eEvent=%u at state=%u, status=%d\n", eEvent, pDrvMain->eSmState, eStatus);
1748981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        pDrvMain->eSmState = SM_STATE_STOPPING_ON_FAIL;
1749981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        wlanDrvIf_UpdateDriverState (hOs, DRV_STATE_FAILED);
1750981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt
1751981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        /*
1752981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * Stop all activities. This may be completed in a different context if
1753981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         *     we should wait for an Async bus transaction completion.
1754981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         * The drvMain_TwdStopCb is called from the TWD in any case to pass
1755981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         *     us to the SM_STATE_FAILED state (where we wait for Destroy).
1756981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt         */
1757981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt        eStatus = drvMain_StopActivities (pDrvMain);
1758981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt    }
1759981801b95b81e6d1c7a2085967406e86af0f08fcDmitry Shmidt}
1760