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

📄 sysconfig.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************
<module>
* Name         : sysconfig.c
* Title        : System Description
* Author       : Dave Roberts
* Created      : 12 / 10 / 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/Marathon
*
</module>
********************************************************************************/

#include "services_headers.h"
#include "syscommon.h"
#include "regpaths.h"

#ifdef MARATHON_INTEGRATION_BSP
#define SYSINTR_MARATHON (30)
#else
#include <oalintr.h>
#endif

#include "mbx.h"
#include "pdp.h"
#include "m24va.h"

#ifdef PDUMP
PVRSRV_PDUMP_MEMMAP	*gpsPDumpMemMap	= IMG_NULL;
#endif

/* Internal function prototypes */

static void FirstAllocateFromExternalHeap(void *pvHandle);
static void LastFreeFromExternalHeap(void *pvHandle);

/*!
******************************************************************************

 @Function	SysAcquireData
 
 @Description returns reference to to sysdata
 				creating one on first call
 
 @Input    ppsSysData - pointer to copy reference into

 @Return   PVRSRV_ERROR  : 

******************************************************************************/
PVRSRV_ERROR SysAcquireData(SYS_DATA **ppsSysData)
{
	PVRSRV_ERROR	eError;

	static SYS_DATA	*gpsSysData = (SYS_DATA *) IMG_NULL;

    if(gpsSysData == IMG_NULL)
	{
		/* Allocate general system data */
		gpsSysData = (SYS_DATA*)HostPageableByteAlloc (sizeof(SYS_DATA));

		if(gpsSysData == IMG_NULL)
		{
			PVR_DPF((PVR_DBG_ERROR,"CreateSysData: failed to allocate SysData"));

			return(PVRSRV_ERROR_OUT_OF_MEMORY);
		}
		
		HostMemSet(gpsSysData, 0, sizeof(SYS_DATA));
		
		eError = HostCreateResource(&gpsSysData->hQProcessResource);
		if (eError != PVRSRV_OK)
		{
			PVR_DPF((PVR_DBG_ERROR,"HostCreateResource: Failed to create resource !"));
			return PVRSRV_ERROR_INIT_FAILURE;
		}

		/* Initialise environment data */
		eError = HostInitEnvData(&gpsSysData->pvEnvSpecificData);
		if (eError != PVRSRV_OK)
		{
			PVR_DPF((PVR_DBG_ERROR,"HostInitEnvData: failed to setup env structure"));

			SysReleaseData(gpsSysData);
	        gpsSysData = IMG_NULL; 

			return(PVRSRV_ERROR_OUT_OF_MEMORY);
		}

		/* Allocate specific system data*/
		HostAllocMem(PVRSRV_HOST_NON_PAGEABLE_HEAP, 
					 sizeof (SYS_SPECIFIC_DATA), 
					 &gpsSysData->pvSysSpecificData, 
					 0);

		if(gpsSysData->pvSysSpecificData == IMG_NULL)
		{
			PVR_DPF((PVR_DBG_ERROR,"CreateSysData: failed to allocate SysSpecificData"));

			SysReleaseData(gpsSysData);
            gpsSysData = IMG_NULL; 

			return(PVRSRV_ERROR_OUT_OF_MEMORY);
		}

		/*
		 * Boot Marathon Device 
		 */

		eError = SysBoot();

		if(eError != PVRSRV_OK)
		{
			SysReleaseData(gpsSysData);
	        gpsSysData = IMG_NULL; 

			/* WARNING Marathon failed to boot */
			PVR_DPF((PVR_DBG_ERROR,"CreateSysData: failed to boot Marathon hardware"));
			PVR_ASSERT(IMG_FALSE);

			return(eError);
		}

		/*
		 * Initialise general system data structure
		 */

		gpsSysData->bStaticEnumeration	= IMG_TRUE;
		gpsSysData->ui32NumDevices		= MAX_DEVICE_IDENTIFIERS;
		gpsSysData->psDevInfoList		= IMG_NULL;
		gpsSysData->psQueueList			= IMG_NULL;
		gpsSysData->ui32InstalledISRs	= 0;
		gpsSysData->bBMInitialised		= IMG_FALSE;
		
		gpsSysData->asSysPool[0].name					= "Main Memory";
		gpsSysData->asSysPool[0].BaseSysPAddr.uiAddr	= 0;
		gpsSysData->asSysPool[0].uSize					= 0;
		gpsSysData->asSysPool[0].hook_first_alloc		= FirstAllocateFromExternalHeap;
		gpsSysData->asSysPool[0].hook_last_free			= LastFreeFromExternalHeap;
		gpsSysData->asSysPool[0].hook_handle			= IMG_NULL;
													
		gpsSysData->asSysPool[1].name					= "Internal Memory";
		gpsSysData->asSysPool[1].BaseSysPAddr.uiAddr	= 0;
		gpsSysData->asSysPool[1].uSize					= 0;
		gpsSysData->asSysPool[1].hook_first_alloc		= IMG_NULL;
		gpsSysData->asSysPool[1].hook_last_free			= IMG_NULL;
		gpsSysData->asSysPool[1].hook_handle			= IMG_NULL;

		/* 
		 * In this system, both devices are memory masters because there is no MMU - ie.
		 * either one can initialise the BM 
		 */

		gpsSysData->asDevIdList[0].eDeviceType		= PVRSRV_DEVICE_TYPE_MBX1_LITE;
		gpsSysData->asDevIdList[0].eDeviceClass		= PVRSRV_DEVICE_CLASS_3D;
		gpsSysData->asDevIdList[0].ui32DeviceIndex	= 0;
		gpsSysData->asDevIdList[0].ui8VersionMajor	= 1;
		gpsSysData->asDevIdList[0].ui8VersionMinor	= 0;
		gpsSysData->asDevIdList[0].bIsMemoryMaster	= IMG_TRUE;
		gpsSysData->asDevIdList[0].bIsKickerDevice	= IMG_TRUE;
		gpsSysData->asDevIdList[0].bInterruptSense	= IMG_TRUE;
		gpsSysData->asDevIdList[0].bResetSense		= IMG_TRUE;
	
		gpsSysData->asDevIdList[1].eDeviceType		= PVRSRV_DEVICE_TYPE_PDP;
		gpsSysData->asDevIdList[1].eDeviceClass		= PVRSRV_DEVICE_CLASS_DISPLAY;
		gpsSysData->asDevIdList[1].ui32DeviceIndex	= 1;
		gpsSysData->asDevIdList[1].ui8VersionMajor	= 1;
		gpsSysData->asDevIdList[1].ui8VersionMinor	= 0;
		gpsSysData->asDevIdList[1].bIsMemoryMaster	= IMG_TRUE;
		gpsSysData->asDevIdList[1].bIsKickerDevice	= IMG_FALSE;
		gpsSysData->asDevIdList[1].bInterruptSense	= IMG_TRUE;
		gpsSysData->asDevIdList[1].bResetSense		= IMG_TRUE;

		gpsSysData->asDevIdList[2].eDeviceType		= PVRSRV_DEVICE_TYPE_M24VA;
		gpsSysData->asDevIdList[2].eDeviceClass		= PVRSRV_DEVICE_CLASS_MPEG;
		gpsSysData->asDevIdList[2].ui32DeviceIndex	= 2;
		gpsSysData->asDevIdList[2].ui8VersionMajor	= 1;
		gpsSysData->asDevIdList[2].ui8VersionMinor	= 0;
		gpsSysData->asDevIdList[2].bIsMemoryMaster	= IMG_TRUE;
		gpsSysData->asDevIdList[2].bIsKickerDevice	= IMG_FALSE;
		gpsSysData->asDevIdList[2].bInterruptSense	= IMG_TRUE;
		gpsSysData->asDevIdList[2].bResetSense		= IMG_TRUE;

		PDUMPINIT(IMG_NULL);
   }
	
	/* copy pointer back */
	*ppsSysData = gpsSysData;
	
	return(PVRSRV_OK);
}


/*!
******************************************************************************

 @Function	SysReleaseData
 
 @Description reduces ref. count by one - frees psSysData when refcount==0
 
 @Input    psSysData - pointer sys data

 @Return   PVRSRV_ERROR  : 

******************************************************************************/
PVRSRV_ERROR SysReleaseData(SYS_DATA *psSysData)
{
/*! @todo - note that  ReleaseSysData always frees memory and shuts down memory management.
  Should reference count */
    PVRSRV_ERROR eError;
    
	eError = HostDestroyResource(&psSysData->hQProcessResource);
	if (eError != PVRSRV_OK)
	{
		return eError;
	}

	if(psSysData->pvSysSpecificData)	HostPageableByteFree(psSysData->pvSysSpecificData);
	if(psSysData->pvEnvSpecificData)	HostDeInitEnvData(psSysData->pvEnvSpecificData);

	HostPageableByteFree(psSysData);

	PDUMPCLOSE(IMG_NULL);

	return(PVRSRV_OK);	
}


/*!
******************************************************************************

 @Function	SysFindLocation
 
 @Description specifies devices in the systems memory map
 
 @Input    psDevInfo - devinfo structure

 @Return   PVRSRV_ERROR  : 

******************************************************************************/
PVRSRV_ERROR SysFindLocation(PPVRSRV_DEV_INFO psDevInfo)
{
	PVRSRV_DEV_LOCATION *psDevLocation	= &psDevInfo->sDevLocation;
	PVRSRV_ERROR		eError			= PVRSRV_OK;
 
	PSYS_SPECIFIC_DATA pMSysData;

	GET_MARATHON_SYS_DATA(pMSysData);

	switch (psDevInfo->sDevId.eDeviceClass)
	{
		case PVRSRV_DEVICE_CLASS_3D:
		
			/* Setup MBX registers */
			psDevLocation->sRegsPhysBase.uiAddr 	 = pMSysData->ui32PhysBase + MARATHON_REG_OFFSET + MBX_REG_OFFSET;
			psDevLocation->ui32RegSize			 	 = MBX_REG_SIZE;

			/* Information on specific slave ports */
			psDevLocation->sDeviceSpecific.sMBX.sTASlavePort.sPhysBase.uiAddr = 
				pMSysData->ui32SPPhysBase + MBX_SP_OFFSET + MBX_TA_SP_DATA_OFFSET;
			
			psDevLocation->sDeviceSpecific.sMBX.sTASlavePort.ui32DataRange = MBX_TA_SP_DATA_RANGE;
			
			psDevLocation->sDeviceSpecific.sMBX.s2DSlavePort.sPhysBase.uiAddr = 
				pMSysData->ui32SPPhysBase + MBX_SP_OFFSET + MBX_TA_SP_2D_DATA_OFFSET;
			
			psDevLocation->sDeviceSpecific.sMBX.s2DSlavePort.ui32DataRange = MBX_TA_SP_2D_DATA_RANGE;

			psDevLocation->sDeviceSpecific.sMBX.sTAControlSlavePort.sPhysBase.uiAddr = 
				pMSysData->ui32SPPhysBase + MBX_SP_OFFSET + MBX_TA_SP_TERM_OFFSET;
			
			psDevLocation->sDeviceSpecific.sMBX.sTAControlSlavePort.ui32DataRange = MBX_TA_SP_TERM_RANGE;

			break;	
				
		case PVRSRV_DEVICE_CLASS_DISPLAY:
			/* Setup  registers */
			psDevLocation->sRegsPhysBase.uiAddr 	 = pMSysData->ui32PhysBase + MARATHON_REG_OFFSET + DISPLAY_REG_OFFSET;
			psDevLocation->ui32RegSize			 	 = DISPLAY_REG_SIZE;
			break;

		case PVRSRV_DEVICE_CLASS_MPEG:

			/* Setup M24VA registers */
			psDevLocation->sRegsPhysBase.uiAddr 	 = pMSysData->ui32PhysBase + MARATHON_REG_OFFSET + M24VA_REG_OFFSET;
			psDevLocation->ui32RegSize			 	 = M24VA_REG_SIZE;

			/* M24VA Slave port block's location and size */
			psDevLocation->sDeviceSpecific.sM24VA.sSPPhysicalBase.uiAddr	= pMSysData->ui32SPPhysBase + M24VA_SP_OFFSET;
			psDevLocation->sDeviceSpecific.sM24VA.ui32SPSize				= M24VA_SP_SIZE;

			/* Information on specific slave ports */
			psDevLocation->sDeviceSpecific.sM24VA.ui32SPCmdRange			= M24VA_SP_CMD_RANGE;
			psDevLocation->sDeviceSpecific.sM24VA.ui32SPIDCTRange			= M24VA_SP_IDCT_RANGE;
			break;

		default :
			{
				PVR_DPF((PVR_DBG_ERROR,"DevFindLocation: unknown device class"));	
				eError = PVRSRV_ERROR_GENERIC;
				break;
			}		
	}
	
	if(eError == PVRSRV_OK)
	{
		/* Setup memory configuration information */
		psDevLocation->sPhysicalBase.uiAddr		 = pMSysData->ui32PhysBase  + MARATHON_FB_OFFSET;

		/* Setup System layer device information */
		psDevInfo->pvSysRegsPtr		= pMSysData->pvLinRegBaseAddr;
		psDevInfo->ui32RegsSize		= MARATHON_REG_SIZE;			

		psDevInfo->pvSysDataPtr		= pMSysData;
		psDevInfo->ui32DataSize		= sizeof(*pMSysData);
	}

	return(eError);
}



/*!
******************************************************************************

 @Function	SysInstallISR
 
 @Description 	installs a system ISR
 
 @Input    psDevInfo - devinfo structure

 @Return   PVRSRV_ERROR  : 

******************************************************************************/
PVRSRV_ERROR SysInstallISR(PPVRSRV_DEV_INFO psDevInfo)
{
	SYS_DATA		*psSysData;
	PVRSRV_ERROR	eError;

	eError = SysAcquireData(&psSysData);

	if(eError != PVRSRV_OK)
	{
		return(eError);
	}
		
	if(psSysData->ui32InstalledISRs == 0)
	{
		eError = HostInstallISR(SYSINTR_MARATHON, "MarathonISR", (IMG_VOID *)psSysData, IMG_TRUE);
	}
	
	psSysData->ui32InstalledISRs++;

	return(eError);
}


⌨️ 快捷键说明

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