📄 sysutils.c
字号:
/*******************************************************************************
<module>
* Name : sysutils.c
* Title : Shared (User/kernel) and System dependent utilities
* Author : Dave Roberts
* Created : 16 / 9 / 03
*
* Copyright : 2003 by Imagination Technologies Limited.
* All rights reserved. No part of this software, either
* material or conceptual may be copied or distributed,
* transmitted, transcribed, stored in a retrieval system
* or translated into any human or computer language in any
* form by any means, electronic, mechanical, manual or
* other-wise, or disclosed to third parties without the
* express written permission of Imagination Technologies
* Limited, Unit 8, HomePark Industrial Estate,
* King's Langley, Hertfordshire, WD4 8LZ, U.K.
*
* Description : This header provides system-specific functions
*
* Platform : WinCE
*
* Modifications:-
* $Log: sysutils.c $
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
* --- Revision Logs Removed ---
*
*
</module>
********************************************************************************/
#if defined(PVR_KERNEL)
#include "services_headers.h"
#else
#include "img_defs.h"
#include "services.h"
#include "hostfunc_um.h"
#include "pvr_debug.h"
#endif
#include "mbx1defs.h"
#include "pdpdefs.h"
#include "syscommon.h"
#include "sharedutils.h"
#ifdef LOCAL_MEMORY_SELF_REFRESH
extern void LockLocalMemoryFunction(void);
extern void UnLockLocalMemoryFunction(void);
#endif
/*!
******************************************************************************
@Function SysDecodeDeviceInterrupts
@Description decode device interrupts
@Return none
******************************************************************************/
IMG_UINT32 SysDecodeDeviceInterrupts(PVRSRV_DEV_INFO *psDevInfo, IMG_PVOID pvLinRegBaseAddr)
{
IMG_UINT32 ui32Offset = 0;
switch(psDevInfo->sDevId.eDeviceClass)
{
case PVRSRV_DEVICE_CLASS_3D :
{
ui32Offset = MBX1_GLOBREG_INT_STATUS;
break;
}
case PVRSRV_DEVICE_CLASS_DISPLAY :
{
ui32Offset = PDP_INTSTATUS;
break;
}
case PVRSRV_DEVICE_CLASS_MPEG :
/* TODO */
default :
{
PVR_DPF((PVR_DBG_ERROR, "DecodeInterrupts: invalid device class"));
PVR_ASSERT(0);
return 0;
}
}
/* just return what you read */
return ReadHWReg(pvLinRegBaseAddr, ui32Offset);
}
/*!
******************************************************************************
@Function SysEnableDeviceInterrupts
@Description enable device interrupts
@Return original state
******************************************************************************/
IMG_UINT32 SysEnableDeviceInterrupts(PVRSRV_DEV_INFO *psDevInfo,
IMG_PVOID pvLinRegBaseAddr,
IMG_UINT32 ui32Interrupts)
{
IMG_UINT32 ui32Offset, uOrigVal;
switch(psDevInfo->sDevId.eDeviceClass)
{
case PVRSRV_DEVICE_CLASS_3D :
{
ui32Offset = MBX1_GLOBREG_INT_MASK;
break;
}
case PVRSRV_DEVICE_CLASS_DISPLAY :
{
ui32Offset = PDP_INTENABLE;
break;
}
case PVRSRV_DEVICE_CLASS_MPEG :
/* TODO */
default :
{
PVR_DPF((PVR_DBG_ERROR, "EnableInterrupts: invalid device class"));
PVR_ASSERT(0);
return(0);
}
}
/* remember old value */
uOrigVal = ReadHWReg(pvLinRegBaseAddr, ui32Offset);
/* just mask out the specified value (no need to invert) */
WriteHWReg(pvLinRegBaseAddr, ui32Offset, uOrigVal | ui32Interrupts);
return uOrigVal;
}
/*!
******************************************************************************
@Function SysDisableDeviceInterrupts
@Description disable device interrupts
@Return original state
******************************************************************************/
IMG_UINT32 SysDisableDeviceInterrupts(PVRSRV_DEV_INFO *psDevInfo,
IMG_PVOID pvLinRegBaseAddr,
IMG_UINT32 ui32Interrupts)
{
IMG_UINT32 ui32Offset, uOrigVal;
switch(psDevInfo->sDevId.eDeviceClass)
{
case PVRSRV_DEVICE_CLASS_3D :
{
ui32Offset = MBX1_GLOBREG_INT_MASK;
break;
}
case PVRSRV_DEVICE_CLASS_DISPLAY :
{
ui32Offset = PDP_INTENABLE;
break;
}
case PVRSRV_DEVICE_CLASS_MPEG :
/* TODO */
default :
{
PVR_DPF((PVR_DBG_ERROR, "DisableInterrupts: invalid device class"));
PVR_ASSERT(0);
return 0;
}
}
/* remember old value */
uOrigVal = ReadHWReg(pvLinRegBaseAddr, ui32Offset);
WriteHWReg(pvLinRegBaseAddr, ui32Offset, uOrigVal & ~ui32Interrupts);
return uOrigVal;
}
/*!
******************************************************************************
@Function SysClearDeviceInterrupts
@Description clear device interrupts
@Return none
******************************************************************************/
IMG_VOID SysClearDeviceInterrupts(PVRSRV_DEV_INFO *psDevInfo,
IMG_PVOID pvLinRegBaseAddr,
IMG_UINT32 ui32Interrupts)
{
IMG_UINT32 ui32Offset;
switch(psDevInfo->sDevId.eDeviceClass)
{
case PVRSRV_DEVICE_CLASS_3D :
{
ui32Offset = MBX1_GLOBREG_INT_CLEAR;
break;
}
case PVRSRV_DEVICE_CLASS_DISPLAY :
/* n.b. this isn't wrong - we clear by writing to the status */
ui32Offset = PDP_INTSTATUS;
break;
case PVRSRV_DEVICE_CLASS_MPEG :
/* TODO */
default :
{
PVR_DPF((PVR_DBG_ERROR, "ClearInterrupts: invalid device class"));
PVR_ASSERT(0);
return;
}
}
/* just write the value directly (no need to invert) */
WriteHWReg(pvLinRegBaseAddr, ui32Offset, ui32Interrupts);
}
/*!
******************************************************************************
@Function SysKickCmdProc
@Description
kicks command processor
@Input pvLinRegBaseAddr
@Return none
******************************************************************************/
IMG_VOID SysKickCmdProc(IMG_UINT32 *pui32KickerAddr)
{
if(pui32KickerAddr == IMG_NULL)
{
PVR_DPF((PVR_DBG_ERROR, "SysKickCmdProc: address"));
return;
}
WriteHWReg(pui32KickerAddr, 0, SYS_KICKER_VALUE);
}
/*!
******************************************************************************
@Function SysCoreEnable
@Description
Turn on clock of the specified core
@Input psDevInfo
@Input eCGCore - id of core to disable
@Input bBlockMutex - block?
@Return PVRSRV_ERROR
******************************************************************************/
PVRSRV_ERROR SysCoreEnable(PPVRSRV_DEV_INFO psDevInfo, DEV_CLOCKGATE_CORE eCGCore, IMG_BOOL bBlockMutex)
{
#ifdef MAR_NO_CLOCKCONTROL
UNREFERENCED_PARAMETER(psDevInfo);
UNREFERENCED_PARAMETER(eCGCore);
#else
PVRSRV_ERROR eError;
PSYS_SPECIFIC_DATA pMSysData = psDevInfo->pvSysDataPtr;
IMG_PVOID pSysRegs = psDevInfo->pvSysRegsPtr;
/*
n.b. we only protect against concurrent execution for the same device (devinfo)
for example both M24VA and MBX code can run this function concurrently
*/
eError = HostAcquireMutex (&psDevInfo->hClockGateMutex, bBlockMutex);
if (eError != PVRSRV_OK)
{
return eError;
}
PDUMPSCRIPT("---- SysCoreEnable start");
PDUMPREGTAG(PDUMPTAGS_REG_MSOC, 0);
switch (eCGCore)
{
case DEV_CGCORE_MBX_2D:
PDUMPSCRIPT("---- Enabling MBX 2D");
if (pMSysData->bTAEnabled || pMSysData->b3DEnabled)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -