📄 hw.c
字号:
/******************************************************************************
<module>
* Name : hw.c
* Title : Hardware Register Access
* Author(s) : Imagination Technologies
* Created : 14 May 2003
*
* 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 : Implements basic access to core registers.
*
* Platform : ALL
*
</module>
*/
#include "services_headers.h"
#include "mbx1defs.h"
#include "hw.h"
#include "buffer_manager.h"
/*----------------------------------------------------------------------------
<function>
FUNCTION: HW_Define
PURPOSE: Initialise a device descriptor.
PARAMETERS: Out: pDev - pointer to an empty device descriptor.
In: registers - host virtual address of device registers.
RETURNS: None.
</function>
-----------------------------------------------------------------------------*/
void
HW_Define ( struct device_tag *pDev,
IMG_CPU_VIRTADDR registers,
IMG_CPU_VIRTADDR slaveport2D,
IMG_UINT32 ui32CoreConfig)
{
PVR_ASSERT (pDev!=IMG_NULL);
PVR_DPF ((PVR_DBG_MESSAGE,
"hw_define (pDev=0x%x, registers=0x%x)", pDev, registers));
pDev->pRegisters = (volatile IMG_UINT32 *) registers;
pDev->bHaveMMU = IMG_FALSE;
pDev->p2DSlaveport = IMG_NULL;
if (ui32CoreConfig & MBX1_CONFIGURATION_MMU_PRESENT)
{
pDev->bHaveMMU = IMG_TRUE;
pDev->p2DSlaveport = slaveport2D;
}
PVR_DPF ((PVR_DBG_MESSAGE, "..haveMMU=%d", pDev->bHaveMMU));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: HW_ReadReg
PURPOSE: Read a register.
PARAMETERS: In: pDev - device descriptor.
In: uOffset - register offset.
RETURNS: Out: read register value.
</function>
-----------------------------------------------------------------------------*/
IMG_UINT32
HW_ReadReg (struct device_tag* pDev, IMG_UINT32 uOffset)
{
IMG_UINT32 r;
PVR_ASSERT (pDev!=IMG_NULL);
PVR_ASSERT (pDev->pRegisters!=0);
PVR_ASSERT ((uOffset & 3) == 0);
r = (IMG_UINT32)(((volatile IMG_UINT32*) (pDev->pRegisters)) [uOffset >> 2]);
PVR_DPF ((PVR_DBG_MESSAGE, "HW_ReadReg(base=0x%x offset=0x%x) = 0x%x", (pDev->pRegisters), uOffset, r));
return r;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: HW_WriteReg
PURPOSE: Write a register.
PARAMETERS: In: pDev - device descriptor.
In: uOffset - register offset.
In: uValue - register value to write.
RETURNS: None.
</function>
-----------------------------------------------------------------------------*/
void
HW_WriteReg (struct device_tag* pDev, unsigned uOffset, IMG_UINT32 uValue)
{
PVR_ASSERT (pDev!=IMG_NULL);
PVR_ASSERT (pDev->pRegisters!=0);
PVR_ASSERT ((uOffset & 3) == 0);
PVR_DPF ((PVR_DBG_MESSAGE,
"HW_WriteReg(base=0x%x offset=0x%x, value=0x%x)",
(pDev->pRegisters), uOffset,
uValue));
((volatile IMG_UINT32*) (pDev->pRegisters)) [uOffset >> 2] = uValue;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: HW_ModifyReg
PURPOSE: Modify a register.
PARAMETERS: In: pDev - device descriptor.
In: uOffset - register offset.
In: uMask - mask of bits to modify.
In: uValue - register value to write.
RETURNS: None.
</function>
-----------------------------------------------------------------------------*/
void
HW_ModifyReg (struct device_tag* pDev,
IMG_UINT32 uOffset,
IMG_UINT32 uMask,
IMG_UINT32 uValue)
{
IMG_UINT32 uRegValue;
PVR_ASSERT (pDev!=IMG_NULL);
PVR_ASSERT (pDev->pRegisters!=0);
PVR_ASSERT ((uOffset & 3) == 0);
uRegValue = HW_ReadReg (pDev, uOffset);
uRegValue = (uRegValue & (~uMask)) | uValue;
HW_WriteReg (pDev, uOffset, uRegValue);
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: HW_Write2DSlavePort
PURPOSE: Write to 2D slave port.
PARAMETERS: In: pDev - device descriptor.
In: uValue - register value to write.
RETURNS: None.
</function>
-----------------------------------------------------------------------------*/
void
HW_Write2DSlavePort (struct device_tag* pDev, IMG_UINT32 uValue)
{
PVR_ASSERT (pDev!=IMG_NULL);
PVR_ASSERT (pDev->p2DSlaveport!=0);
PVR_DPF ((PVR_DBG_MESSAGE,
"HW_Write2DSlavePort (device=0x%x, uValue=%lu", pDev, uValue));
#ifndef STUB
((volatile IMG_UINT32 *) (pDev->p2DSlaveport))[0] = uValue;
#endif
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: HW_FlushFifo
PURPOSE: Flush the contents of the slaveport fifo.
PARAMETERS: In: pDev - device descriptor.
RETURNS: None.
</function>
-----------------------------------------------------------------------------*/
void
HW_FlushFifo (struct device_tag *pDev)
{
while (HW_ReadReg (pDev, MBX1_GLOBREG_INT_STATUS) & MBX1_INT_TA_FREEVCOUNT_MASK)
;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -