1 /**************************************************************************/ /*!
3 @Title PVR Bridge Functionality
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Header for the PVR Bridge code
6 @License Dual MIT/GPLv2
8 The contents of this file are subject to the MIT license as set out below.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
32 This License is also included in this distribution in the file called
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /***************************************************************************/
44 #ifndef __BRIDGED_PVR_BRIDGE_H__
45 #define __BRIDGED_PVR_BRIDGE_H__
47 #include "lock_types.h"
48 #include "connection_server.h"
49 #include "pvr_debug.h"
51 #include "pvr_bridge.h"
52 #if defined(SUPPORT_RGX)
53 #include "rgx_bridge.h"
57 CopyFromUserWrapper(CONNECTION_DATA *psConnection,
58 IMG_UINT32 ui32DispatchTableEntry,
63 CopyToUserWrapper(CONNECTION_DATA *psConnection,
64 IMG_UINT32 ui32DispatchTableEntry,
70 DummyBW(IMG_UINT32 ui32DispatchTableEntry,
73 CONNECTION_DATA *psConnection);
75 typedef IMG_INT (*BridgeWrapperFunction)(IMG_UINT32 ui32DispatchTableEntry,
78 CONNECTION_DATA *psConnection);
80 typedef struct _PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY
82 BridgeWrapperFunction pfFunction; /*!< The wrapper function that validates the ioctl
83 arguments before calling into srvkm proper */
84 POS_LOCK hBridgeLock; /*!< The bridge lock which needs to be acquired
85 before calling the above wrapper */
86 IMG_BOOL bUseLock; /*!< Specify whether to use a bridge lock at all */
87 #if defined(DEBUG_BRIDGE_KM)
88 const IMG_CHAR *pszIOCName; /*!< Name of the ioctl: e.g. "PVRSRV_BRIDGE_CONNECT_SERVICES" */
89 const IMG_CHAR *pszFunctionName; /*!< Name of the wrapper function: e.g. "PVRSRVConnectBW" */
90 const IMG_CHAR *pszBridgeLockName; /*!< Name of bridge lock which will be acquired */
91 IMG_UINT32 ui32CallCount; /*!< The total number of times the ioctl has been called */
92 IMG_UINT32 ui32CopyFromUserTotalBytes; /*!< The total number of bytes copied from
93 userspace within this ioctl */
94 IMG_UINT32 ui32CopyToUserTotalBytes; /*!< The total number of bytes copied from
95 userspace within this ioctl */
96 IMG_UINT64 ui64TotalTimeNS; /*!< The total amount of time spent in this bridge function */
97 IMG_UINT64 ui64MaxTimeNS; /*!< The maximum amount of time for a single call to this bridge function */
99 }PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY;
101 #if defined(SUPPORT_RGX)
102 #define BRIDGE_DISPATCH_TABLE_ENTRY_COUNT (PVRSRV_BRIDGE_RGX_DISPATCH_LAST+1)
103 #define BRIDGE_DISPATCH_TABLE_START_ENTRY_COUNT (PVRSRV_BRIDGE_RGX_LAST+1)
105 #define BRIDGE_DISPATCH_TABLE_ENTRY_COUNT (PVRSRV_BRIDGE_DISPATCH_LAST+1)
106 #define BRIDGE_DISPATCH_TABLE_START_ENTRY_COUNT (PVRSRV_BRIDGE_LAST+1)
109 extern PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY g_BridgeDispatchTable[BRIDGE_DISPATCH_TABLE_ENTRY_COUNT];
111 void BridgeDispatchTableStartOffsetsInit(void);
114 _SetDispatchTableEntry(IMG_UINT32 ui32BridgeGroup,
115 IMG_UINT32 ui32Index,
116 const IMG_CHAR *pszIOCName,
117 BridgeWrapperFunction pfFunction,
118 const IMG_CHAR *pszFunctionName,
119 POS_LOCK hBridgeLock,
120 const IMG_CHAR* pszBridgeLockName,
124 /* PRQA S 0884,3410 2*/ /* macro relies on the lack of brackets */
125 #define SetDispatchTableEntry(ui32BridgeGroup, ui32Index, pfFunction,\
126 hBridgeLock, bUseLock) \
127 _SetDispatchTableEntry(ui32BridgeGroup, ui32Index, #ui32Index, (BridgeWrapperFunction)pfFunction, #pfFunction,\
128 (POS_LOCK)hBridgeLock, #hBridgeLock, bUseLock )
130 #define DISPATCH_TABLE_GAP_THRESHOLD 5
133 #if defined(DEBUG_BRIDGE_KM)
134 typedef struct _PVRSRV_BRIDGE_GLOBAL_STATS
136 IMG_UINT32 ui32IOCTLCount;
137 IMG_UINT32 ui32TotalCopyFromUserBytes;
138 IMG_UINT32 ui32TotalCopyToUserBytes;
139 } PVRSRV_BRIDGE_GLOBAL_STATS;
141 /* OS specific code may want to report the stats held here and within the
142 * BRIDGE_DISPATCH_TABLE_ENTRYs (E.g. on Linux we report these via a
143 * debugfs entry /sys/kernel/debug/pvr/bridge_stats) */
144 extern PVRSRV_BRIDGE_GLOBAL_STATS g_BridgeGlobalStats;
147 PVRSRV_ERROR BridgeInit(void);
148 void BridgeDeinit(void);
150 PVRSRV_ERROR BridgedDispatchKM(CONNECTION_DATA * psConnection,
151 PVRSRV_BRIDGE_PACKAGE * psBridgePackageKM);
155 PVRSRVConnectKM(CONNECTION_DATA *psConnection,
156 PVRSRV_DEVICE_NODE * psDeviceNode,
157 IMG_UINT32 ui32Flags,
158 IMG_UINT32 ui32ClientBuildOptions,
159 IMG_UINT32 ui32ClientDDKVersion,
160 IMG_UINT32 ui32ClientDDKBuild,
161 IMG_UINT8 *pui8KernelArch,
162 IMG_UINT32 *ui32CapabilityFlags,
163 IMG_UINT32 *ui32PVRBridges,
164 IMG_UINT32 *ui32RGXBridges);
167 PVRSRVDisconnectKM(void);
170 PVRSRVInitSrvDisconnectKM(CONNECTION_DATA *psConnection,
171 PVRSRV_DEVICE_NODE *psDeviceNode,
172 IMG_BOOL bInitSuccesful,
173 IMG_UINT32 ui32ClientBuildOptions);
176 PVRSRVAcquireGlobalEventObjectKM(IMG_HANDLE *phGlobalEventObject);
179 PVRSRVReleaseGlobalEventObjectKM(IMG_HANDLE hGlobalEventObject);
182 PVRSRVDumpDebugInfoKM(CONNECTION_DATA *psConnection,
183 PVRSRV_DEVICE_NODE *psDeviceNode,
184 IMG_UINT32 ui32VerbLevel);
187 PVRSRVGetDevClockSpeedKM(CONNECTION_DATA * psConnection,
188 PVRSRV_DEVICE_NODE *psDeviceNode,
189 IMG_PUINT32 pui32RGXClockSpeed);
192 PVRSRVHWOpTimeoutKM(CONNECTION_DATA *psConnection,
193 PVRSRV_DEVICE_NODE *psDeviceNode);
195 PVRSRV_ERROR PVRSRVAlignmentCheckKM(CONNECTION_DATA *psConnection,
196 PVRSRV_DEVICE_NODE * psDeviceNode,
197 IMG_UINT32 ui32FWAlignChecksSize,
198 IMG_UINT32 aui32FWAlignChecks[]);
200 PVRSRV_ERROR PVRSRVGetDeviceStatusKM(CONNECTION_DATA *psConnection,
201 PVRSRV_DEVICE_NODE *psDeviceNode,
202 IMG_UINT32 *pui32DeviceStatus);
204 #endif /* __BRIDGED_PVR_BRIDGE_H__ */
206 /******************************************************************************
207 End of file (srvcore.h)
208 ******************************************************************************/