1 /**********************************************************************
3 * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful but, except
10 * as otherwise stated in writing, without any warranty; without even the
11 * implied warranty of merchantability or fitness for a particular purpose.
12 * See the GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
21 * Contact Information:
22 * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23 * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
25 ******************************************************************************/
30 #include "sysconfig.h"
32 #include "servicesint.h"
38 #include "buffer_manager.h"
41 struct SYS_DEVICE_ID {
47 #define SYS_MAX_LOCAL_DEVMEM_ARENAS 4
51 struct SYS_DEVICE_ID sDeviceID[SYS_DEVICE_COUNT];
52 struct PVRSRV_DEVICE_NODE *psDeviceNodeList;
53 struct PVRSRV_POWER_DEV *psPowerDeviceList;
54 struct PVRSRV_RESOURCE sPowerStateChangeResource;
55 enum PVR_POWER_STATE eCurrentPowerState;
56 enum PVR_POWER_STATE eFailedPowerState;
57 u32 ui32CurrentOSPowerState;
58 struct PVRSRV_QUEUE_INFO *psQueueList;
59 struct PVRSRV_KERNEL_SYNC_INFO *psSharedSyncInfoList;
60 void *pvEnvSpecificData;
61 void *pvSysSpecificData;
62 struct PVRSRV_RESOURCE sQProcessResource;
64 void *hSOCTimerRegisterOSMemHandle;
65 u32 *pvSOCTimerRegisterKM;
66 void *pvSOCClockGateRegsBase;
67 u32 ui32SOCClockGateRegsSize;
68 IMG_BOOL (**ppfnCmdProcList[SYS_DEVICE_COUNT])(void *, u32, void *);
70 struct COMMAND_COMPLETE_DATA **ppsCmdCompleteData[SYS_DEVICE_COUNT];
72 IMG_BOOL bReProcessQueues;
74 struct RA_ARENA *apsLocalDevMemArena[SYS_MAX_LOCAL_DEVMEM_ARENAS];
76 char *pszVersionString;
77 struct PVRSRV_EVENTOBJECT *psGlobalEventObject;
80 enum PVRSRV_ERROR SysInitialise(void);
81 enum PVRSRV_ERROR SysFinalise(void);
83 u32 GetCPUTranslatedAddress(void);
85 enum PVRSRV_ERROR SysDeinitialise(struct SYS_DATA *psSysData);
87 enum PVRSRV_ERROR SysGetDeviceMemoryMap(enum PVRSRV_DEVICE_TYPE eDeviceType,
90 void SysRegisterExternalDevice(struct PVRSRV_DEVICE_NODE *psDeviceNode);
91 void SysRemoveExternalDevice(struct PVRSRV_DEVICE_NODE *psDeviceNode);
93 u32 SysGetInterruptSource(struct SYS_DATA *psSysData,
94 struct PVRSRV_DEVICE_NODE *psDeviceNode);
96 void SysClearInterrupts(struct SYS_DATA *psSysData,
99 enum PVRSRV_ERROR SysResetDevice(u32 ui32DeviceIndex);
101 enum PVRSRV_ERROR SysSystemPrePowerState(enum PVR_POWER_STATE eNewPowerState);
102 enum PVRSRV_ERROR SysSystemPostPowerState(enum PVR_POWER_STATE eNewPowerState);
103 enum PVRSRV_ERROR SysDevicePrePowerState(u32 ui32DeviceIndex,
104 enum PVR_POWER_STATE eNewPowerState,
105 enum PVR_POWER_STATE eCurrentPowerState);
106 enum PVRSRV_ERROR SysDevicePostPowerState(u32 ui32DeviceIndex,
107 enum PVR_POWER_STATE eNewPowerState,
111 enum PVRSRV_ERROR SysOEMFunction(u32 ui32ID,
114 void *pvOut, u32 ulOutSize);
116 struct IMG_DEV_PHYADDR SysCpuPAddrToDevPAddr(
117 enum PVRSRV_DEVICE_TYPE eDeviceType,
118 struct IMG_CPU_PHYADDR cpu_paddr);
119 struct IMG_DEV_PHYADDR SysSysPAddrToDevPAddr(
120 enum PVRSRV_DEVICE_TYPE eDeviceType,
121 struct IMG_SYS_PHYADDR SysPAddr);
122 struct IMG_SYS_PHYADDR SysDevPAddrToSysPAddr(
123 enum PVRSRV_DEVICE_TYPE eDeviceType,
124 struct IMG_DEV_PHYADDR SysPAddr);
125 struct IMG_CPU_PHYADDR SysSysPAddrToCpuPAddr(struct IMG_SYS_PHYADDR SysPAddr);
126 struct IMG_SYS_PHYADDR SysCpuPAddrToSysPAddr(struct IMG_CPU_PHYADDR cpu_paddr);
128 extern struct SYS_DATA *gpsSysData;
131 static inline enum PVRSRV_ERROR SysAcquireData(struct SYS_DATA **ppsSysData)
133 *ppsSysData = gpsSysData;
136 return PVRSRV_ERROR_GENERIC;
141 static inline enum PVRSRV_ERROR SysInitialiseCommon(struct SYS_DATA *psSysData)
143 enum PVRSRV_ERROR eError;
144 eError = PVRSRVInit(psSysData);
148 static inline void SysDeinitialiseCommon(struct SYS_DATA *psSysData)
150 PVRSRVDeInit(psSysData);
151 OSDestroyResource(&psSysData->sPowerStateChangeResource);
154 #define SysReadHWReg(p, o) OSReadHWReg(p, o)
155 #define SysWriteHWReg(p, o, v) OSWriteHWReg(p, o, v)