📄 off.c
字号:
// Function: OALIoCtlHalEnableWake
//
// Called when a IOCTL_HAL_ENABLE_WAKE interrupt occurs. This function will
// set the requested interrupt as a wake source.
//
// Parameters:
// code
// [in] IOCTL_HAL_ENABLE_WAKE.
//
// pInpBuffer
// [in] The interrupt that is being set as a wake source.
//
// inpSize
// [in] The size of a UINT32.
//
// pOutBuffer
// [out] Ignored.
//
// outSize
// [in] Ignored.
//
// pOutSize
// [out] Ignored.
//
// Returns:
// TRUE if the IOCTL was successfully processed. FALSE if an error
// occurs while processing the IOCTL.
//
//-----------------------------------------------------------------------------
BOOL
OALIoCtlHalEnableWake(UINT32 code, VOID* pInpBuffer, UINT32 inpSize,
VOID* pOutBuffer, UINT32 outSize, UINT32 *pOutSize)
{
UINT32 sysIntr;
BOOL rc = FALSE;
UINT32 count = 1;
const UINT32 *irq;
OALMSG(OAL_FUNC&&OAL_POWER, (_T("+OALIoCtlHalEnableWake\r\n")));
if (pInpBuffer == NULL || inpSize < sizeof(UINT32)) {
NKSetLastError(ERROR_INVALID_PARAMETER);
OALMSG(OAL_WARN, (
L"WARN: IOCTL_HAL_ENABLE_WAKE invalid parameters\r\n"
));
goto cleanUp;
}
sysIntr = *(UINT32*)pInpBuffer;
// Retrieve list of irqs for the specified SYSINTR
if (!OALIntrTranslateSysIntr(sysIntr, &count, &irq))
{
OALMSG(OAL_ERROR,
(_T("ERROR: OALIntrTranslateSysIntr failed for IOCTL_HAL_ENABLE_WAKE,\r\n")));
goto cleanUp;
}
g_avicWakeMask.QuadPart |= g_oalIrqMask[*irq].QuadPart;
g_gpioWakeMask[DDK_GPIO_PORT1] |= g_oalGpioMask[DDK_GPIO_PORT1][*irq];
g_gpioWakeMask[DDK_GPIO_PORT2] |= g_oalGpioMask[DDK_GPIO_PORT2][*irq];
g_gpioWakeMask[DDK_GPIO_PORT3] |= g_oalGpioMask[DDK_GPIO_PORT3][*irq];
rc = TRUE;
cleanUp:
OALMSG(OAL_FUNC&&OAL_POWER, (_T("-OALIoCtlHalEnableWake (rc = %d)\r\n"), rc));
return rc;
}
//-----------------------------------------------------------------------------
//
// Function: OALIoCtlHalDisableWake
//
// Called when a IOCTL_HAL_DISABLE_WAKE interrupt occurs. This function will
// disable the requested interrupt as a wake source.
//
// Parameters:
// code
// [in] IOCTL_HAL_DISABLE_WAKE.
//
// pInpBuffer
// [in] The interrupt that is being set as a wake source.
//
// inpSize
// [in] The size of a UINT32.
//
// pOutBuffer
// [out] Ignored.
//
// outSize
// [in] Ignored.
//
// pOutSize
// [out] Ignored.
//
// Returns:
// TRUE if the IOCTL was successfully processed. FALSE if an error
// occurs while processing the IOCTL.
//
//-----------------------------------------------------------------------------
BOOL
OALIoCtlHalDisableWake(UINT32 code, VOID* pInpBuffer, UINT32 inpSize,
VOID* pOutBuffer, UINT32 outSize, UINT32 *pOutSize)
{
UINT32 sysIntr;
BOOL rc = FALSE;
UINT32 count = 1;
const UINT32 *irq;
OALMSG(OAL_FUNC&&OAL_POWER, (_T("+OALIoCtlHalDisableWake\r\n")));
if (pInpBuffer == NULL || inpSize < sizeof(UINT32)) {
NKSetLastError(ERROR_INVALID_PARAMETER);
OALMSG(OAL_WARN, (
L"WARN: IOCTL_HAL_DISABLE_WAKE invalid parameters\r\n"
));
goto cleanUp;
}
sysIntr = *(UINT32*)pInpBuffer;
// Retrieve list of irqs for the specified SYSINTR
if (!OALIntrTranslateSysIntr(sysIntr, &count, &irq))
{
OALMSG(OAL_ERROR,
(_T("ERROR: OALIntrTranslateSysIntr failed for IOCTL_HAL_DISABLE_WAKE,\r\n")));
goto cleanUp;
}
g_avicWakeMask.QuadPart &= ~(g_oalIrqMask[*irq].QuadPart);
g_gpioWakeMask[DDK_GPIO_PORT1] &= ~(g_oalGpioMask[DDK_GPIO_PORT1][*irq]);
g_gpioWakeMask[DDK_GPIO_PORT2] &= ~(g_oalGpioMask[DDK_GPIO_PORT2][*irq]);
g_gpioWakeMask[DDK_GPIO_PORT3] &= ~(g_oalGpioMask[DDK_GPIO_PORT3][*irq]);
rc = TRUE;
cleanUp:
OALMSG(OAL_FUNC&&OAL_POWER, (_T("-OALIoCtlHalDisableWake (rc = %d)\r\n"), rc));
return rc;
}
//-----------------------------------------------------------------------------
//
// Function: OALIoCtlHalGetWakeSource
//
// Called when a IOCTL_HAL_GET_WAKE_SOURCE interrupt occurs. This function
// returns the interrupts that are the current wake sources.
//
// Parameters:
// code
// [in] IOCTL_HAL_GET_WAKE_SOURCE.
//
// pInpBuffer
// [in] Ignored
//
// inpSize
// [in] Ignored.
//
// pOutBuffer
// [out] The system interrupts that wake up the core.
//
// outSize
// [in] The size of pOutBuffer. Must be the size of an UINT64.
//
// pOutSize
// [out] The actual size of pOutBuffer.
//
// Returns:
// TRUE if the IOCTL was successfully processed, FALSE otherwise.
//
//-----------------------------------------------------------------------------
BOOL
OALIoCtlHalGetWakeSource(UINT32 code, VOID* pInpBuffer, UINT32 inpSize,
VOID* pOutBuffer, UINT32 outSize, UINT32 *pOutSize)
{
BOOL rc = FALSE;
OALMSG(OAL_FUNC&&OAL_POWER, (_T("+OALIoCtlHalGetWakeSource\r\n")));
if ((pOutBuffer == NULL) || (outSize < sizeof(UINT32))) {
NKSetLastError(ERROR_INVALID_PARAMETER);
OALMSG(OAL_WARN, (
L"WARN: IOCTL_HAL_GET_WAKE_SOURCE invalid parameters\r\n"
));
goto cleanUp;
}
*(UINT32*)pOutBuffer = g_WakeSource;
if (pOutSize != NULL) {
*pOutSize = sizeof(UINT32);
}
rc = TRUE;
cleanUp:
OALMSG(OAL_FUNC&&OAL_POWER, (_T("-OALIoCtlHalGetWakeSource (rc = %d)\r\n"), rc));
return rc;
}
//-----------------------------------------------------------------------------
//
// Function: OALClockSetGatingMode
//
// This function provides the OAL a safe mechanism for setting the clock
// gating mode of peripherals.
//
// Parameters:
// index
// [in] Index for referencing the peripheral clock gating control
// bits.
//
// mode
// [in] Requested clock gating mode for the peripheral.
//
// Returns:
// None
//
//-----------------------------------------------------------------------------
VOID OALClockSetGatingMode(DDK_CLOCK_GATE_INDEX index, DDK_CLOCK_GATE_MODE mode)
{
BOOL fEnable;
// CGR is a shared register so we must disable interrupts temporarily for
// safe access
fEnable = INTERRUPTS_ENABLE(FALSE);
// Update the clock gating mode
INSREG32(&g_pCCM->CGR[CCM_CGR_INDEX(index)], CCM_CGR_MASK(index),
CCM_CGR_VAL(index, mode));
INTERRUPTS_ENABLE(fEnable);
}
//-----------------------------------------------------------------------------
//
// Function: OALClockEnableIIM
//
// This function enables/disables module clocks for the IIM module.
//
// Parameters:
// bClockEnable
// [in] Set TRUE to enable IIM module clocks. Set FALSE
// to disable IIM module clocks.
//
// Returns:
// None
//
//-----------------------------------------------------------------------------
VOID OALClockEnableIIM(BOOL bClockEnable)
{
DDK_CLOCK_GATE_MODE mode = bClockEnable ? DDK_CLOCK_GATE_MODE_ENABLED_ALL :
DDK_CLOCK_GATE_MODE_DISABLED;
OALClockSetGatingMode(DDK_CLOCK_GATE_INDEX_IIM, mode);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -