?? rilmain.cpp
字號:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Module Name:
rilmain.cpp
Abstract:
Notes:
--*/
#include "precomp.h"
#include "rilhand.h"
#include <Marshal.hpp>
//
// Globals
//
CRITICAL_SECTION g_csClosing;
#ifdef RIL_RADIO_RESILIENCE
extern CRITICAL_SECTION g_csReboot;
#else
HANDLE g_hCriticalErrorEvent; // = NULL;
#endif // ! RIL_RADIO_RESILIENCE
HANDLE g_hDriverPresentEvent; // = NULL;
HANDLE g_hNewDialOrHangupEvent; // = NULL;
CRilHandle* g_pRilHandleDevice = NULL;
DWORD g_dwReadyState;
DWORD g_dwRegStatus;
DWORD g_dwGPRSRegStatus;
BOOL g_rfExternalCalltypeDetermination = FALSE;
RILCALLTYPECALLBACK g_rlpfExternalCalltypeFunction = NULL;
HINSTANCE g_hCalltypeLib = NULL;
DWORD g_dwPrintSIMPINInfo;
const RILPDDParams* g_rppPDDParams = NULL;
extern RILCALLINFO g_rgfCallStates[RIL_MAX_TRACKED_CALL_ID];
extern RINGINGCALLDATA g_rcdRingingCallData;
// CS required for safe access - see RINGINGCALLDATA definition for details
CRITICAL_SECTION g_csRingingCallData;
extern DIALEDCALLDATA g_rcdDialedCallData;
// CS required for safe access - see DIALEDCALLDATA definition for details
CRITICAL_SECTION g_csDialedCallData;
extern WAITINGCALLDATA g_rcdWaitingCallData;
// No CS required for safe access - see WAITINGCALLDATA definition for details
// Storage for the SIM toolkit Terminal Profile settings
CRilSTKTerminalProfile g_RilSTKTerminalProfile;
#ifdef RIL_LAST_ERROR
DWORD g_dwLastError; // = 0;
#endif
#ifdef RIL_WATSON_REPORT
// Info Cache for Watson reporting
RilInfoCache g_RilInfoCache;
CRITICAL_SECTION g_csRilInfoCache;
BOOL g_fWatsonCalled;
// In-memory buffer to capture AT Cmd logs for Watson reports.
CRilATCmdLogBuffer g_RilATCmdLogBuffer;
// Unique platform identifier used as a Watson parameter
const TCHAR* gc_szWatsonDeviceType = TEXT("Generic");
DWORD g_WatsonThreadId = NULL;
#endif
const char *g_pcszCPHS = NULL;
#ifdef RIL_ENABLE_EONS
EONS g_eons;
EONSCache g_eonscache;
#endif
DBGPARAM dpCurSettings =
{
L"RILDrv",
{
L"Init", L"Info", L"Trace", L"NDIS",
L"NDIS Pkt", L"EventLog", L"EONS", L"ATCMD",
L"Undefined", L"Undefined", L"Undefined", L"Undefined",
L"Alloc", L"Function", L"Warning", L"Error"
},
ZONEMASK_ERROR | ZONEMASK_WARNING | ZONEMASK_ATCMD | ZONEMASK_EONS
};
//
// Stubs for unsupported RILDrv_ functions
//
#define UNSUPPORTED(n, m) \
HRESULT n m \
{ \
FUNCTION_TRACE(n); \
DEBUGMSG(ZONE_ERROR, (TEXT(#n) TEXT("RILDrv : E : : E_NOTIMPL\r\n"))); \
return E_NOTIMPL; \
}
UNSUPPORTED(RILDrv_SetDTMFMonitoring, (DWORD, BOOL));
UNSUPPORTED(RILDrv_GetAudioDevices, (DWORD));
UNSUPPORTED(RILDrv_FetchSimToolkitCmd, (DWORD));
UNSUPPORTED(RILDrv_GetCCBSStatus, (DWORD, DWORD));
UNSUPPORTED(RILDrv_ClearCCBSRegistration, (DWORD, DWORD));
UNSUPPORTED(RILDrv_GetSystemTime, (DWORD));
UNSUPPORTED(RILDrv_GetPacketByteCount, (DWORD));
UNSUPPORTED(RILDrv_ResetPacketByteCount, (DWORD));
UNSUPPORTED(RILDrv_SendFlash, (DWORD, RILADDRESS));
UNSUPPORTED(RILDrv_GetRoamingMode, (DWORD));
UNSUPPORTED(RILDrv_SetRoamingMode, (DWORD, DWORD));
UNSUPPORTED(RILDrv_GetPreferredPrivacyMode, (DWORD));
UNSUPPORTED(RILDrv_SetPreferredPrivacyMode, (DWORD, DWORD));
UNSUPPORTED(RILDrv_GetCurrentPrivacyStatus, (DWORD));
UNSUPPORTED(RILDrv_GetCurrentLocationStatus, (DWORD));
UNSUPPORTED(RILDrv_GetCurrentRoamingStatus, (DWORD));
UNSUPPORTED(RILDrv_SendAKey, (DWORD, LPCSTR));
// RIL logging global
CDebugEventLogging *g_pRilLog = NULL;
static void EnableEventLogging(void)
{
TCHAR pFileName[MAX_PATH];
DWORD cbData= MAX_PATH * sizeof(TCHAR);
*pFileName = L'\0';
if ( TRUE == GetRegistryEventLogging((BYTE*)pFileName, cbData ))
{
g_pRilLog = new CDebugEventLogging;
if ( g_pRilLog )
{
g_pRilLog->Init(pFileName);
}
}
}
static void DisableEventLogging(void)
{
if ( g_pRilLog )
{
g_pRilLog->DeInit();
delete g_pRilLog;
g_pRilLog = NULL;
}
}
static HRESULT ValidateRILPDDParams(const RILPDDParams* rppPDDParams)
{
ASSERT( ( NULL != rppPDDParams ) );
return( ( rppPDDParams->cbSize == sizeof( RILPDDParams ) ) ? S_OK : E_INVALIDARG );
/* TODO: Other potential PDD parameters to check below:
const LISTSTRINGMAP* plsmPhoneBookLocationCapsTable;
const UINT uiPhoneBookLocationCapsTableSize;
DWORD dwDevCapsSIMTKN_SetUpCall;
DWORD dwDevCapsSIMTKN_SendDTMF;
DWORD dwCRSMStatusCommandId;
const LPCSTR* pstrPhoneBookLocationTable;
const UINT uiPhoneBookLocationTableSize;
ENCODING_TYPE etMessageEncodingType;
const ERRORMAP* pemCMEErrorTable;
const UINT uiCMEErrorTableSize;
const ERRORMAP* pemCMSErrorTable;
const UINT uiCMSErrorTableSize;
const ERRORMAP* pemEXTErrorTable;
const UINT uiEXTErrorTableSize;
const char* pchSMSIntermediaryPrompt;
DWORD dwDefaultCOMMask;
ENCODING_TYPE etEncodingTECharset;
const INITSTRING_DATA* pisdInitStringDataTable;
const UINT uiInitStringDataTableSize;
*/
}
//
// DLL entry point
//
BOOL WINAPI DllMain(HANDLE hinstDll, DWORD dwReason, LPVOID lpReserved)
{
if (DLL_PROCESS_ATTACH == dwReason)
{
DEBUGREGISTER((HMODULE) hinstDll);
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : DllMain : DLL_PROCESS_ATTACH\r\n")));
EnableEventLogging();
}
else if (DLL_PROCESS_DETACH == dwReason)
{
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : DllMain : DLL_PROCESS_DETACH\r\n")));
DisableEventLogging();
}
return TRUE;
}
#ifdef RIL_ALLOW_DRIVER_REMOVAL_TESTING
CRilHandle * g_pDeviceAllowDriverRemovalTesting = NULL;
#define DRIVERCOOKIE_FROM_RILHANDLE(pDevice) (DWORD)(g_pDeviceAllowDriverRemovalTesting = pDevice)
#define RILHANDLE_FROM_DRIVERCOOKIE(dwData) (g_pDeviceAllowDriverRemovalTesting)
#else
#define DRIVERCOOKIE_FROM_RILHANDLE(pDevice) (DWORD)pDevice;
#define RILHANDLE_FROM_DRIVERCOOKIE(dwData) (CRilHandle*)dwData;
#endif
//
// RIL driver initialization
//
#ifdef __cplusplus
extern "C" DWORD RIL_Init(DWORD dwInfo)
#else
DWORD RIL_Init(DWORD dwInfo)
#endif
{
FUNCTION_TRACE(RIL_Init);
DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : RIL_Init : params: dwInfo = %d\r\n"), dwInfo));
CRilHandle* pDevice = NULL;
DWORD dwRet = 0;
HRESULT hr = E_FAIL;
// Initialize globals
InitializeCriticalSection(&g_csClosing);
#ifdef RIL_RADIO_RESILIENCE
InitializeCriticalSection(&g_csReboot);
memset(&g_LastResetTime, 0, sizeof(g_LastResetTime));
#else
g_hCriticalErrorEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!g_hCriticalErrorEvent)
{
goto Error;
}
#endif // ! RIL_RADIO_RESILIENCE
#ifdef RIL_WATSON_REPORT
InitializeCriticalSection(&g_csRilInfoCache);
#endif // RIL_WATSON_REPORT
InitializeCriticalSection(&g_csDeactCringLock);
InitializeCriticalSection(&g_csCallStates);
g_hDriverPresentEvent = CreateEvent(NULL, TRUE, FALSE, RILDRIVERPRESENT_EVENT);
if (!g_hDriverPresentEvent)
{
goto Error;
}
g_hNewDialOrHangupEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if (!g_hNewDialOrHangupEvent)
{
goto Error;
}
#ifdef RIL_WATSON_REPORT
// Initialize the info cache used for watson reporting
memset(&(g_RilInfoCache), 0, sizeof(g_RilInfoCache));
// Initialize flag used to prevent multiple Watson reporting of the same problem
g_fWatsonCalled = FALSE;
// Initialize the AT Cmd log
g_RilATCmdLogBuffer.Init(RILATCMDLOGSIZE);
#endif // RIL_WATSON_REPORT
// Initialize the default Terminal profile settings.
g_RilSTKTerminalProfile.InitializeDefault();
// Before starting any communication with the radio, initialize PDD and obtain PDD parameters
hr = PDD_Initialize( g_rppPDDParams );
if ( FAILED( hr ) || !g_rppPDDParams )
{
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : RIL_Init : error in PDD_Initialize, hr = [0x%08x], g_rppPDDParams = %p\r\n"), hr, g_rppPDDParams));
goto Error;
}
// Validate parameters obtained from PDD
hr = ValidateRILPDDParams( g_rppPDDParams );
if ( FAILED( hr ) )
{
DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : RIL_Init : PDD parameters invalid, hr = [0x%08x]\r\n"), hr));
goto Error;
}
// Allocate a device handle
pDevice = new CRilHandle;
if (!pDevice || !pDevice->StartInit())
{
goto Error;
}
// Need to save this off for use in broadcasting CPI data generated internally by the RIL.
g_pRilHandleDevice = pDevice;
dwRet = DRIVERCOOKIE_FROM_RILHANDLE(pDevice);
// Driver has started successfully, so set
// the event that says RIL driver is up.
SetEvent(g_hDriverPresentEvent);
RIL_EVENTLOG_MSG((RILLOG_EVENT_RADIOPRESENT));
DWORD dwEONSEnabled = 0;
#ifdef RIL_ENABLE_EONS
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -