?? power_control.c
字號:
{
DEBUGMSG(PWC_ZONE_INIT,(_T("[PWRCON] %s : Process Detach\n"), _T(__FUNCTION__)));
}
return TRUE;
}
BOOL PWC_Deinit(DWORD pContext)
{
DEBUGMSG(PWC_ZONE_INIT,(_T("[PWRCON] ++%s(0x%08x)\n"), _T(__FUNCTION__), pContext));
g_bExitThread = TRUE;
if(g_hThreadPowerMon) // Make Sure if thread is exist
{
// Signal Thread to Finish
if (g_hMsgQueue)
{
CloseMsgQueue(g_hMsgQueue); // Closing the MsgQueue will force ReadMsgQueue to return
g_hMsgQueue = NULL;
}
// Wait for Thread to Finish
WaitForSingleObject(g_hThreadPowerMon, INFINITE);
CloseHandle(g_hThreadPowerMon);
g_hThreadPowerMon = NULL;
}
ReleaseResources();
DEBUGMSG(PWC_ZONE_INIT,(_T("[PWRCON] --%s\n"), _T(__FUNCTION__) ));
return TRUE;
}
DWORD
PWC_Init(DWORD dwContext)
{
DEBUGMSG(PWC_ZONE_INIT,(_T("[PWRCON:INF] ++%s(0x%08x)\n"), _T(__FUNCTION__), dwContext));
if (AllocResources() == FALSE)
{
RETAILMSG(PWC_ZONE_ERROR,(_T("[PWRCON:ERR] %s->AllocResources() Failed \n"), _T(__FUNCTION__)));
goto CleanUp;
}
PwrCon_initialize_register_address((void *)g_pSysConReg);
// Create power Monitor Thread, Singleton
g_hThreadPowerMon = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) PowerMonitorThread, NULL, 0, NULL);
if (g_hThreadPowerMon == NULL )
{
RETAILMSG(PWC_ZONE_ERROR,(_T("[PWRCON:ERR] %s->CreateThread() Power Monitor Failed \n"), _T(__FUNCTION__)));
goto CleanUp;
}
DEBUGMSG(PWC_ZONE_INIT,(_T("[PWRCON:INF] --%s()\n"), _T(__FUNCTION__)));
return TRUE;
CleanUp:
RETAILMSG(PWC_ZONE_ERROR,(_T("[PWRCON:ERR] --%s : Failed\n"), _T(__FUNCTION__)));
PWC_Deinit(0);
return FALSE;
}
DWORD
PWC_Open(DWORD pContext, DWORD dwAccess, DWORD dwShareMode)
{
DEBUGMSG(PWC_ZONE_ENTER,(_T("[PWRCON] %s(0x%08x, 0x%08x, 0x%08x)\n"), _T(__FUNCTION__), pContext, dwAccess, dwShareMode));
return TRUE;
}
BOOL
PWC_Close(DWORD pContext)
{
DEBUGMSG(PWC_ZONE_ENTER,(_T("[PWRCON] %s(0x%08x)\n"), _T(__FUNCTION__), pContext));
return TRUE;
}
DWORD
PWC_Read (DWORD pContext, LPVOID pBuf, DWORD Len)
{
DEBUGMSG(PWC_ZONE_ENTER,(_T("[PWRCON] %s(0x%08x, 0x%08x, 0x%08x)\n"), _T(__FUNCTION__), pContext, pBuf, Len));
return (0); // End of File
}
DWORD
PWC_Write(DWORD pContext, LPCVOID pBuf, DWORD Len)
{
DEBUGMSG(PWC_ZONE_ENTER,(_T("[PWRCON] %s(0x%08x, 0x%08x, 0x%08x)\n"), _T(__FUNCTION__), pContext, pBuf, Len));
return (0); // Number of Byte
}
DWORD
PWC_Seek (DWORD pContext, long pos, DWORD type)
{
DEBUGMSG(PWC_ZONE_ENTER,(_T("[PWRCON] %s(0x%08x, 0x%08x, 0x%08x)\n"), _T(__FUNCTION__), pContext, pos, type));
return (DWORD)-1; // Failure
}
BOOL
PWC_PowerUp(DWORD pContext)
{
DEBUGMSG(PWC_ZONE_ENTER,(_T("[PWRCON] %s(0x%08x)\n"), _T(__FUNCTION__), pContext));
return TRUE;
}
BOOL
PWC_PowerDown(DWORD pContext)
{
DEBUGMSG(PWC_ZONE_ENTER,(_T("[PWRCON] %s(0x%08x)\n"), _T(__FUNCTION__), pContext));
return TRUE;
}
BOOL
PWC_IOControl(DWORD pContext, DWORD dwCode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
BOOL bRet = TRUE;
DWORD dwIndex;
PVOID pMarshalledInBuf = NULL;
//if caller is not kernel mode, do not allow setting power state
if (GetDirectCallerProcessId() != GetCurrentProcessId()){
return ERROR_ACCESS_DENIED;
}
if ( !( (dwCode == IOCTL_PWRCON_SET_POWER_ON)
|| (dwCode == IOCTL_PWRCON_SET_POWER_OFF)
|| (dwCode == IOCTL_PWRCON_SET_SYSTEM_LEVEL)
|| (dwCode == IOCTL_PWRCON_QUERY_SYSTEM_LEVEL)
|| (dwCode == IOCTL_PWRCON_PROFILE_DVS)
))
{
RETAILMSG(PWC_ZONE_ERROR, (_T("[PWRCON:ERR] %s : Unknown IOCTL [0x%08x]\n"), _T(__FUNCTION__), dwCode));
SetLastError (ERROR_INVALID_ACCESS);
return FALSE;
}
if(FAILED(CeOpenCallerBuffer(&pMarshalledInBuf, pBufIn, dwLenIn, ARG_I_PTR, TRUE)))
{
RETAILMSG(1, (TEXT("PWC_IOControl: CeOpenCallerBuffer failed for input buffer.\r\n")));
return FALSE;
}
switch(dwCode)
{
case IOCTL_PWRCON_SET_POWER_ON:
if ((dwLenIn < sizeof(DWORD)) || (NULL == pMarshalledInBuf))
{
RETAILMSG(PWC_ZONE_ERROR, (_T("[PWRCON:ERR] %s(IOCTL_PWRCON_SET_POWER_ON) : Invalid Parameter\n"),_T(__FUNCTION__)));
SetLastError (ERROR_INVALID_PARAMETER);
bRet = FALSE;
break;
}
dwIndex = *(DWORD*)(pMarshalledInBuf);
EnterCriticalSection(&csPowerCon);
switch(dwIndex)
{
case PWR_IP_IROM:
g_aIPPowerStatus[dwIndex] = TRUE;
RETAILMSG(PWC_ZONE_BLK_PWR_ON,(_T("[PWRCON:INF] %s(SET_POWER_ON, %d) : IROM\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_on(BLKPWR_DOMAIN_IROM);
break;
case PWR_IP_ETM:
g_aIPPowerStatus[dwIndex] = TRUE;
RETAILMSG(PWC_ZONE_BLK_PWR_ON,(_T("[PWRCON:INF] %s(SET_POWER_ON, %d) : ETM\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_on(BLKPWR_DOMAIN_ETM);
break;
case PWR_IP_SDMA0: // Domain S
case PWR_IP_SDMA1:
case PWR_IP_SECURITY:
g_aIPPowerStatus[dwIndex] = TRUE;
RETAILMSG(PWC_ZONE_BLK_PWR_ON,(_T("[PWRCON:INF] %s(SET_POWER_ON, %d) : S\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_on(BLKPWR_DOMAIN_S);
break;
case PWR_IP_ROTATOR: // Domain F
case PWR_IP_POST:
case PWR_IP_DISPCON:
g_aIPPowerStatus[dwIndex] = TRUE;
RETAILMSG(PWC_ZONE_BLK_PWR_ON,(_T("[PWRCON:INF] %s(SET_POWER_ON, %d) : F\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_on(BLKPWR_DOMAIN_F);
break;
case PWR_IP_2D: // Domain P
case PWR_IP_TVENC:
case PWR_IP_TVSC:
g_aIPPowerStatus[dwIndex] = TRUE;
RETAILMSG(PWC_ZONE_BLK_PWR_ON,(_T("[PWRCON:INF] %s(SET_POWER_ON, %d) : P\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_on(BLKPWR_DOMAIN_P);
break;
case PWR_IP_JPEG: // Domain I
case PWR_IP_CAMIF:
g_aIPPowerStatus[dwIndex] = TRUE;
RETAILMSG(PWC_ZONE_BLK_PWR_ON,(_T("[PWRCON:INF] %s(SET_POWER_ON, %d) : I\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_on(BLKPWR_DOMAIN_I);
break;
case PWR_IP_MFC: // Domain V
g_aIPPowerStatus[dwIndex] = TRUE;
RETAILMSG(PWC_ZONE_BLK_PWR_ON,(_T("[PWRCON:INF] %s(SET_POWER_ON, %d) : V\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_on(BLKPWR_DOMAIN_V);
break;
default:
RETAILMSG(PWC_ZONE_ERROR, (_T("[PWRCON:ERR] %s(IOCTL_PWRCON_SET_POWER_ON, %d) : Invalid Parameter\n"), _T(__FUNCTION__), dwIndex));
SetLastError (ERROR_INVALID_PARAMETER);
bRet = FALSE;
}
LeaveCriticalSection(&csPowerCon);
break;
case IOCTL_PWRCON_SET_POWER_OFF:
if ((dwLenIn < sizeof(DWORD)) || (NULL == pMarshalledInBuf))
{
RETAILMSG(PWC_ZONE_ERROR, (_T("[PWRCON:ERR] %s(IOCTL_PWRCON_SET_POWER_OFF) : Invalid Parameter\n"), _T(__FUNCTION__)));
SetLastError (ERROR_INVALID_PARAMETER);
bRet = FALSE;
break;
}
dwIndex = *(DWORD*)(pMarshalledInBuf);
EnterCriticalSection(&csPowerCon);
switch(dwIndex)
{
case PWR_IP_IROM:
g_aIPPowerStatus[dwIndex] = FALSE;
RETAILMSG(PWC_ZONE_BLK_PWR_OFF,(_T("[PWRCON:INF] %s(SET_POWER_OFF, %d) : IROM\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_off(BLKPWR_DOMAIN_IROM);
break;
case PWR_IP_ETM:
g_aIPPowerStatus[dwIndex] = FALSE;
RETAILMSG(PWC_ZONE_BLK_PWR_OFF,(_T("[PWRCON:INF] %s(SET_POWER_OFF, %d) : ETM\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_off(BLKPWR_DOMAIN_ETM);
break;
case PWR_IP_SDMA0: // Domain S
case PWR_IP_SDMA1:
case PWR_IP_SECURITY:
g_aIPPowerStatus[dwIndex] = FALSE;
if ( (g_aIPPowerStatus[PWR_IP_SDMA0] == FALSE)
&& (g_aIPPowerStatus[PWR_IP_SDMA1] == FALSE)
&& (g_aIPPowerStatus[PWR_IP_SECURITY] == FALSE) )
{
RETAILMSG(PWC_ZONE_BLK_PWR_OFF, (_T("[PWRCON:INF] %s(SET_POWER_OFF, %d) : S\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_off(BLKPWR_DOMAIN_S);
}
break;
case PWR_IP_ROTATOR: // Domain F
case PWR_IP_POST:
case PWR_IP_DISPCON:
g_aIPPowerStatus[dwIndex] = FALSE;
if ( (g_aIPPowerStatus[PWR_IP_ROTATOR] == FALSE)
&& (g_aIPPowerStatus[PWR_IP_POST] == FALSE)
&& (g_aIPPowerStatus[PWR_IP_DISPCON] == FALSE) )
{
RETAILMSG(PWC_ZONE_BLK_PWR_OFF, (_T("[PWRCON:INF] %s(SET_POWER_OFF, %d) : F\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_off(BLKPWR_DOMAIN_F);
}
break;
case PWR_IP_2D: // Domain P
case PWR_IP_TVENC:
case PWR_IP_TVSC:
g_aIPPowerStatus[dwIndex] = FALSE;
if ( (g_aIPPowerStatus[PWR_IP_2D] == FALSE)
&& (g_aIPPowerStatus[PWR_IP_TVENC] == FALSE)
&& (g_aIPPowerStatus[PWR_IP_TVSC] == FALSE) )
{
RETAILMSG(PWC_ZONE_BLK_PWR_OFF, (_T("[PWRCON:INF] %s(SET_POWER_OFF, %d) : P\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_off(BLKPWR_DOMAIN_P);
}
break;
case PWR_IP_JPEG: // Domain I
case PWR_IP_CAMIF:
g_aIPPowerStatus[dwIndex] = FALSE;
if ( (g_aIPPowerStatus[PWR_IP_JPEG] == FALSE)
&& (g_aIPPowerStatus[PWR_IP_CAMIF] == FALSE) )
{
RETAILMSG(PWC_ZONE_BLK_PWR_OFF, (_T("[PWRCON:INF] %s(SET_POWER_OFF, %d) : I\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_off(BLKPWR_DOMAIN_I);
}
break;
case PWR_IP_MFC: // Domain V
g_aIPPowerStatus[dwIndex] = FALSE;
RETAILMSG(PWC_ZONE_BLK_PWR_OFF, (_T("[PWRCON:INF] %s(SET_POWER_OFF, %d) : V\n"), _T(__FUNCTION__), dwIndex));
PwrCon_set_block_power_off(BLKPWR_DOMAIN_V);
break;
default:
RETAILMSG(PWC_ZONE_ERROR, (_T("[PWRCON:ERR] %s(SET_POWER_OFF, %d) : Invalid Parameter\n"), _T(__FUNCTION__), dwIndex));
SetLastError (ERROR_INVALID_PARAMETER);
bRet = FALSE;
}
LeaveCriticalSection(&csPowerCon);
break;
case IOCTL_PWRCON_SET_SYSTEM_LEVEL:
RETAILMSG(PWC_ZONE_DVS_CHANGE, (_T("Set System Level\n")));
return KernelIoControl(IOCTL_HAL_SET_SYSTEM_LEVEL, pMarshalledInBuf, dwLenIn, pBufOut, dwLenOut, pdwActualOut);
break;
case IOCTL_PWRCON_QUERY_SYSTEM_LEVEL:
// KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &g_dwSysIntrPowerBtn, sizeof(DWORD), NULL, 0, NULL);
break;
#define DVS_LEVEL_PROFILE
#ifdef DVS_LEVEL_PROFILE
case IOCTL_PWRCON_PROFILE_DVS:
RETAILMSG(PWC_ZONE_DVS_PROFILE, (_T("Call HAL Profiler DVS Io Control\n")));
return KernelIoControl(IOCTL_HAL_PROFILE_DVS, pMarshalledInBuf, dwLenIn, pBufOut, dwLenOut, pdwActualOut);
break;
#endif
}
if(FAILED(CeCloseCallerBuffer(pMarshalledInBuf, pBufIn, dwLenIn, ARG_I_PTR)))
{
RETAILMSG(1, (TEXT("PWC_IOControl: CeCloseCallerBuffer failed for input buffer.\r\n")));
return FALSE;
}
return bRet;
}
// EOF
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -