⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rilmain.cpp

📁 windows mobile RIL软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                RILCALLTYPECALLBACK rctcb = (RILCALLTYPECALLBACK)GetProcAddress(hCalltypeLib,tszCalltypeFunction);
                if (!rctcb)
                {
                    DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : RIL_Init : Calltype Lib GetProcAddress failed, err = 0x%08x.\r\n"),GetLastError()));
                    FreeLibrary(hCalltypeLib);
                }
                else
                {
                    g_rfExternalCalltypeDetermination = TRUE;
                    g_rlpfExternalCalltypeFunction = rctcb;
                    g_hCalltypeLib = hCalltypeLib;
                    InitializeCriticalSection(&g_csDialedCallData);
                    InitializeCriticalSection(&g_csRingingCallData);
                    DEBUGMSG(ZONE_INFO, (TEXT("RILDrv : i : RIL_Init : Calltype Callback registered, dll = %s, function = %s.\r\n"),tszCalltypeDll,tszCalltypeFunction));
                }
            }
        }
    }

    // Initialize global structures
    memset(&g_rcdRingingCallData, 0, sizeof(g_rcdRingingCallData));
    g_rcdRingingCallData.dwCallId = RIL_MAX_TRACKED_CALL_ID;
    
    memset(&g_rcdDialedCallData, 0, sizeof(g_rcdDialedCallData));
    memset(&g_rcdWaitingCallData, 0, sizeof(g_rcdWaitingCallData));

    memset(&g_rgfCallStates, 0, sizeof(g_rgfCallStates));

    DEBUGMSG(ZONE_TRACE, (TEXT("RILDrv : t : RIL_Init : Started successfully\r\n")));
#if defined(PHILIP_DRIVER)

    // Open Wave driver 
    g_hWavDev = CreateFile(TEXT("WAV1:"),
        GENERIC_READ | GENERIC_WRITE,
        0, NULL,
        OPEN_EXISTING,
        0, NULL);

    if (g_hWavDev == INVALID_HANDLE_VALUE)
    {
        TBD_OUTPUT(TBDCT_INFO, TBDOL_ERROR, TEXT("RIL_Init : failed to open WavDev driver"));
        //goto Error;
    }

#endif

    Error:
    if (!dwRet)
    {
        DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : E : RIL_Init : RIL failed to initialize\r\n")));

        g_RilLog.LogEvent(RILLOG_ZONE_ERROR, RILLOG_EVENT_DRVINITFAILED);

        delete pDevice;
        if (g_hDriverPresentEvent)
        {
            (void)CloseHandle(g_hDriverPresentEvent);
            g_hDriverPresentEvent = NULL;
        }
#ifdef OEM2_DRIVER
        if (g_hCPINNEvent)
        {
            (void)CloseHandle(g_hCPINNEvent);
            g_hCPINNEvent = NULL;
        }
#endif // OEM2_DRIVER
#ifdef RIL_RADIO_RESILIENCE
        DeleteCriticalSection(&g_csReboot);
#else
        if (g_hCriticalErrorEvent)
        {
            (void)CloseHandle(g_hCriticalErrorEvent);
            g_hCriticalErrorEvent = NULL;
        }
#endif // ! RIL_RADIO_RESILIENCE
        DeleteCriticalSection(&g_csClosing);
#ifdef RIL_WATSON_REPORT
        DeleteCriticalSection(&g_csRilInfoCache);
#endif // RIL_WATSON_REPORT

#if defined(OEM1_GPRS_DEACT) || defined(EMP_DRIVER)
    DeleteCriticalSection(&g_csGPRSDeactLock);    
#endif // defined(OEM1_GPRS_DEACT) || defined(EMP_DRIVER)

    DeleteCriticalSection(&g_csDeactCringLock); 
    }

    return dwRet;
}

//
// Driver de-initialization
//
BOOL RIL_Deinit(DWORD dwData)
{
    FUNCTION_TRACE(RIL_Deinit);
    DEBUGCHK(dwData != 0);

    CRilHandle* pDevice = RILHANDLE_FROM_DRIVERCOOKIE(dwData);
    BOOL fRet = FALSE;

    // Driver is going away. Clear event that
    // says RIL driver is up.
    if (g_hDriverPresentEvent)
    {
        ResetEvent(g_hDriverPresentEvent);
        (void)CloseHandle(g_hDriverPresentEvent);
        g_hDriverPresentEvent = NULL;
        g_RilLog.LogEvent(RILLOG_ZONE_PRESENCE, RILLOG_EVENT_RADIOREMOVED);
    }

    if (g_rfExternalCalltypeDetermination)
    {
        g_rfExternalCalltypeDetermination = FALSE;
        g_rlpfExternalCalltypeFunction = NULL;
        if (NULL != g_hCalltypeLib)
            FreeLibrary(g_hCalltypeLib);
        g_hCalltypeLib = NULL;
        DeleteCriticalSection(&g_csRingingCallData);    
        DeleteCriticalSection(&g_csDialedCallData);    
    }


#if defined(OEM1_DRIVER) || defined(PHILIP_DRIVER)
    // Close the wavedev driver
    if ((g_hWavDev != NULL) && (g_hWavDev != INVALID_HANDLE_VALUE))
    {
        CloseHandle(g_hWavDev);
    }
#endif

    if (!pDevice)
    {
        goto Error;
    }
    delete pDevice;

    
#ifdef OEM2_DRIVER
    if (g_hCPINNEvent)
    {
        (void)CloseHandle(g_hCPINNEvent);
        g_hCPINNEvent = NULL;
    }
#endif // OEM2_DRIVER
#ifdef RIL_RADIO_RESILIENCE
    g_cbLastLockCapsSize = 0;
    FreeBlob(g_pLastLockCaps);
    DeleteCriticalSection(&g_csReboot);
#else
    if (g_hCriticalErrorEvent)
    {
        (void)CloseHandle(g_hCriticalErrorEvent);
        g_hCriticalErrorEvent = NULL;
    }
#endif // ! RIL_RADIO_RESILIENCE

#ifdef RIL_WATSON_REPORT
    DeleteCriticalSection(&g_csRilInfoCache);    
#endif // RIL_WATSON_REPORT

#if defined(OEM1_GPRS_DEACT) || defined(EMP_DRIVER)
    DeleteCriticalSection(&g_csGPRSDeactLock);    
#endif // defined(OEM1_GPRS_DEACT) || defined(EMP_DRIVER)

    DeleteCriticalSection(&g_csDeactCringLock); 

    DeleteCriticalSection(&g_csClosing);
    fRet = TRUE;

    Error:
    return fRet;
}


//
// Open a driver instance
//
DWORD RIL_Open(DWORD dwData, DWORD dwAccess, DWORD dwShareMode)
{
    FUNCTION_TRACE(RIL_Open);
    DEBUGCHK(dwData != 0);
	DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : +RIL_Open()\r\n")));
	
    CRilInstanceHandle* pHandle = NULL;
    CRilHandle* pDevice = RILHANDLE_FROM_DRIVERCOOKIE(dwData);

	DEBUGMSG(ZONE_ERROR, (TEXT("RILDrv : RIL_Open: CrilHandle = %0x!!\r\n"), pDevice));
	
#ifdef RIL_ALLOW_DRIVER_REMOVAL_TESTING
    if (!g_pDeviceAllowDriverRemovalTesting)
    {
        return 0x4321;
    }
#endif
    DWORD dwRet = 0;

    // Wait until the COM port is initialized
    if (!pDevice /* || !pDevice->WaitForInit(MAX_DRIVERINIT_TIME) */ )
    {
        goto Error;
    }

    pHandle = new CRilInstanceHandle;
    if (!pHandle || !pHandle->Init(pDevice))
    {
        goto Error;
    }

    // Insert new handle into the handle list
    if (!pDevice->AddToList(pHandle))
    {
        goto Error;
    }

    dwRet = (DWORD)pHandle;

    Error:
    if (!dwRet)
    {
        delete pHandle;
    }
    return dwRet;
}


//
// Close a driver instance
//
BOOL RIL_Close(DWORD dwOpenData)
{
    FUNCTION_TRACE(RIL_Close);
    DEBUGCHK(dwOpenData != 0);

#ifdef RIL_ALLOW_DRIVER_REMOVAL_TESTING
    if (dwOpenData == 0x4321 || !g_pDeviceAllowDriverRemovalTesting)
    {
        return TRUE;
    }
#endif
    CRilInstanceHandle* pHandle = (CRilInstanceHandle*)dwOpenData;
    BOOL fRet = FALSE;

    if (!pHandle)
    {
        goto Error;
    }

    {
        SYNCBLOCK(g_csClosing);

        // Make sure no commands refer to this handle
        pHandle->GetCmdList()->Enum(ClearCmdHandle, 0);
    }

    DEBUGCHK(pHandle->GetDevice() != 0);

    // Remove the handle from the handle list
    if (!pHandle->GetDevice()->RemoveFromList(pHandle))
    {
        goto Error;
    }

    delete pHandle;
    fRet = TRUE;

    Error:
    return fRet;
}



//
// Emulate serial read
//
DWORD RIL_Read(DWORD dwOpenData, LPVOID pBuf, DWORD len)
{
#ifdef RIL_ALLOW_DRIVER_REMOVAL_TESTING
    if (g_pDeviceAllowDriverRemovalTesting)
    {
        RIL_Close(dwOpenData);
        RIL_Deinit(1);
        g_pDeviceAllowDriverRemovalTesting = NULL;
    }
#endif
    return 0;
}


//
// Emulate serial write
//
DWORD RIL_Write(DWORD dwOpenData, LPCVOID pBuf, DWORD len)
{
#ifdef RIL_ALLOW_DRIVER_REMOVAL_TESTING
    if (!g_pDeviceAllowDriverRemovalTesting)
    {
        ASSERT(dwOpenData == 0x4321);
        RIL_Init(1);
    }
#endif
    return 0;
}


//
//
//
DWORD RIL_Seek(DWORD dwOpenData, long pos, DWORD type)
{
    return (DWORD)-1;
}


#ifdef PHILIP_DRIVER

//By Alan Luo

void RIL_IOControl_Show(DWORD dwCode, PBYTE pBufOut, DWORD dwLenOut)

{
	//NKDbgPrintfW(TEXT("RIL_IOControl_Show dwCode = %x\r\n"), dwCode);
		
	switch (dwCode)
	{
	        // CPM is ready for us to register with it
	        case IOCTL_RIL_REGISTERWITHCPM:
	            {
	#ifdef RIL_RADIO_RESILIENCE
							NKDbgPrintfW(_T("IOCTL_RIL_REGISTERWITHCPM\r\n"));
	#else
							NKDbgPrintfW(_T("else IOCTL_RIL_REGISTERWITHCPM\r\n"));
	#endif // ! RIL_RADIO_RESILIENCE
	            }
	            break;
	
	        case IOCTL_RIL_EMERGENCYSTATUS:
	            NKDbgPrintfW(_T("IOCTL_RIL_EMERGENCYSTATUS\r\n"));
	            break;
	
	            // Initialize notification delivery
	        case IOCTL_RIL_INITNOTIFICATIONS:
		     NKDbgPrintfW(_T("IOCTL_RIL_INITNOTIFICATIONS\r\n"));
	            break;
	
	            // Get next RIL notification
	        case IOCTL_RIL_GETNEXTNOTIFICATION:
		     NKDbgPrintfW(_T("IOCTL_RIL_GETNEXTNOTIFICATION\r\n"));
	            break;
	
	            // RIL_GetSerialPortStatistics()
	        case IOCTL_RIL_GETSERIALPORTSTATISTICS:
	            {
			  NKDbgPrintfW(_T("IOCTL_RIL_GETSERIALPORTSTATISTICS\r\n"));
	                break;
	            }
	
	            // RIL_GetDriverVersion()
	        case IOCTL_RIL_GETDRIVERVERSION:
	            {
			  NKDbgPrintfW(_T("IOCTL_RIL_GETDRIVERVERSION\r\n"));
	                break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -