]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/device-ti-proprietary-open.git/blob - jacinto6/sgx_src/eurasia_km/services4/srvkm/bridged/bridged_pvr_bridge.h
jacinto6: sgx: update DDK version to 1.12/2701748
[android-sdk/device-ti-proprietary-open.git] / jacinto6 / sgx_src / eurasia_km / services4 / srvkm / bridged / bridged_pvr_bridge.h
1 /*************************************************************************/ /*!
2 @Title          PVR Bridge Functionality
3 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @Description    Header for the PVR Bridge code
5 @License        Dual MIT/GPLv2
7 The contents of this file are subject to the MIT license as set out below.
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
19 Alternatively, the contents of this file may be used under the terms of
20 the GNU General Public License Version 2 ("GPL") in which case the provisions
21 of GPL are applicable instead of those above.
23 If you wish to allow use of your version of this file only under the terms of
24 GPL, and not to allow others to use your version of this file under the terms
25 of the MIT license, indicate your decision by deleting the provisions above
26 and replace them with the notice and other provisions required by GPL as set
27 out in the file called "GPL-COPYING" included in this distribution. If you do
28 not delete the provisions above, a recipient may use your version of this file
29 under the terms of either the MIT license or GPL.
31 This License is also included in this distribution in the file called
32 "MIT-COPYING".
34 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 */ /**************************************************************************/
43 #ifndef __BRIDGED_PVR_BRIDGE_H__
44 #define __BRIDGED_PVR_BRIDGE_H__
46 #include "pvr_bridge.h"
48 #if defined(__cplusplus)
49 extern "C" {
50 #endif
52 #if defined(__linux__)
53 #define PVRSRV_GET_BRIDGE_ID(X) _IOC_NR(X)
54 #else
55 #define PVRSRV_GET_BRIDGE_ID(X) ((X) - PVRSRV_IOWR(PVRSRV_BRIDGE_UMKM_CMD_FIRST))
56 #endif
58 #ifndef ENOMEM
59 #define ENOMEM  12
60 #endif
61 #ifndef EFAULT
62 #define EFAULT  14
63 #endif
64 #ifndef ENOTTY
65 #define ENOTTY  25
66 #endif
68 #if defined(DEBUG_BRIDGE_KM)
69 PVRSRV_ERROR
70 CopyFromUserWrapper(PVRSRV_PER_PROCESS_DATA *pProcData,
71                                         IMG_UINT32 ui32BridgeID,
72                                         IMG_VOID *pvDest,
73                                         IMG_VOID *pvSrc,
74                                         IMG_UINT32 ui32Size);
75 PVRSRV_ERROR
76 CopyToUserWrapper(PVRSRV_PER_PROCESS_DATA *pProcData, 
77                                   IMG_UINT32 ui32BridgeID,
78                                   IMG_VOID *pvDest,
79                                   IMG_VOID *pvSrc,
80                                   IMG_UINT32 ui32Size);
81 #else
82 #define CopyFromUserWrapper(pProcData, ui32BridgeID, pvDest, pvSrc, ui32Size) \
83         OSCopyFromUser(pProcData, pvDest, pvSrc, ui32Size)
84 #define CopyToUserWrapper(pProcData, ui32BridgeID, pvDest, pvSrc, ui32Size) \
85         OSCopyToUser(pProcData, pvDest, pvSrc, ui32Size)
86 #endif
89 #define ASSIGN_AND_RETURN_ON_ERROR(error, src, res)             \
90         do                                                      \
91         {                                                       \
92                 (error) = (src);                                \
93                 if ((error) != PVRSRV_OK)                       \
94                 {                                               \
95                         return (res);                           \
96                 }                                               \
97         } while ((error) != PVRSRV_OK);
99 #define ASSIGN_AND_EXIT_ON_ERROR(error, src)            \
100         ASSIGN_AND_RETURN_ON_ERROR(error, src, 0)
102 #if defined(PVR_SECURE_HANDLES)
103 #ifdef INLINE_IS_PRAGMA
104 #pragma inline(NewHandleBatch)
105 #endif
106 static INLINE PVRSRV_ERROR
107 NewHandleBatch(PVRSRV_PER_PROCESS_DATA *psPerProc,
108                                         IMG_UINT32 ui32BatchSize)
110         PVRSRV_ERROR eError;
112         PVR_ASSERT(!psPerProc->bHandlesBatched);
114         eError = PVRSRVNewHandleBatch(psPerProc->psHandleBase, ui32BatchSize);
116         if (eError == PVRSRV_OK)
117         {
118                 psPerProc->bHandlesBatched = IMG_TRUE;
119         }
121         return eError;
124 #define NEW_HANDLE_BATCH_OR_ERROR(error, psPerProc, ui32BatchSize)      \
125         ASSIGN_AND_EXIT_ON_ERROR(error, NewHandleBatch(psPerProc, ui32BatchSize))
127 #ifdef INLINE_IS_PRAGMA
128 #pragma inline(CommitHandleBatch)
129 #endif
130 static INLINE PVRSRV_ERROR
131 CommitHandleBatch(PVRSRV_PER_PROCESS_DATA *psPerProc)
133         PVR_ASSERT(psPerProc->bHandlesBatched);
135         psPerProc->bHandlesBatched = IMG_FALSE;
137         return PVRSRVCommitHandleBatch(psPerProc->psHandleBase);
141 #define COMMIT_HANDLE_BATCH_OR_ERROR(error, psPerProc)                  \
142         ASSIGN_AND_EXIT_ON_ERROR(error, CommitHandleBatch(psPerProc))
144 #ifdef INLINE_IS_PRAGMA
145 #pragma inline(ReleaseHandleBatch)
146 #endif
147 static INLINE IMG_VOID
148 ReleaseHandleBatch(PVRSRV_PER_PROCESS_DATA *psPerProc)
150         if (psPerProc->bHandlesBatched)
151         {
152                 psPerProc->bHandlesBatched = IMG_FALSE;
154                 PVRSRVReleaseHandleBatch(psPerProc->psHandleBase);
155         }
157 #else   /* defined(PVR_SECURE_HANDLES) */
158 #define NEW_HANDLE_BATCH_OR_ERROR(error, psPerProc, ui32BatchSize)
159 #define COMMIT_HANDLE_BATCH_OR_ERROR(error, psPerProc)
160 #define ReleaseHandleBatch(psPerProc)
161 #endif  /* defined(PVR_SECURE_HANDLES) */
163 IMG_INT
164 DummyBW(IMG_UINT32 ui32BridgeID,
165                 IMG_VOID *psBridgeIn,
166                 IMG_VOID *psBridgeOut,
167                 PVRSRV_PER_PROCESS_DATA *psPerProc);
169 typedef IMG_INT (*BridgeWrapperFunction)(IMG_UINT32 ui32BridgeID,
170                                                                          IMG_VOID *psBridgeIn,
171                                                                          IMG_VOID *psBridgeOut,
172                                                                          PVRSRV_PER_PROCESS_DATA *psPerProc);
174 typedef struct _PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY
176         BridgeWrapperFunction pfFunction; /*!< The wrapper function that validates the ioctl
177                                                                                 arguments before calling into srvkm proper */
178 #if defined(DEBUG_BRIDGE_KM)
179         const IMG_CHAR *pszIOCName; /*!< Name of the ioctl: e.g. "PVRSRV_BRIDGE_CONNECT_SERVICES" */
180         const IMG_CHAR *pszFunctionName; /*!< Name of the wrapper function: e.g. "PVRSRVConnectBW" */
181         IMG_UINT32 ui32CallCount; /*!< The total number of times the ioctl has been called */
182         IMG_UINT32 ui32CopyFromUserTotalBytes; /*!< The total number of bytes copied from
183                                                                                          userspace within this ioctl */
184         IMG_UINT32 ui32CopyToUserTotalBytes; /*!< The total number of bytes copied from
185                                                                                    userspace within this ioctl */
186 #endif
187 }PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY;
189 #if defined(SUPPORT_VGX) || defined(SUPPORT_MSVDX)
190         #if defined(SUPPORT_VGX)
191                 #define BRIDGE_DISPATCH_TABLE_ENTRY_COUNT (PVRSRV_BRIDGE_LAST_VGX_CMD+1)
192                 #define PVRSRV_BRIDGE_LAST_DEVICE_CMD      PVRSRV_BRIDGE_LAST_VGX_CMD
193         #else
194                 #define BRIDGE_DISPATCH_TABLE_ENTRY_COUNT (PVRSRV_BRIDGE_LAST_MSVDX_CMD+1)
195                 #define PVRSRV_BRIDGE_LAST_DEVICE_CMD      PVRSRV_BRIDGE_LAST_MSVDX_CMD
196         #endif
197 #else
198         #if defined(SUPPORT_SGX)
199                 #define BRIDGE_DISPATCH_TABLE_ENTRY_COUNT (PVRSRV_BRIDGE_LAST_SGX_CMD+1)
200                 #define PVRSRV_BRIDGE_LAST_DEVICE_CMD      PVRSRV_BRIDGE_LAST_SGX_CMD
201         #else
202                 #define BRIDGE_DISPATCH_TABLE_ENTRY_COUNT (PVRSRV_BRIDGE_LAST_NON_DEVICE_CMD+1)
203                 #define PVRSRV_BRIDGE_LAST_DEVICE_CMD      PVRSRV_BRIDGE_LAST_NON_DEVICE_CMD
204         #endif
205 #endif
207 extern PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY g_BridgeDispatchTable[BRIDGE_DISPATCH_TABLE_ENTRY_COUNT];
209 IMG_VOID
210 _SetDispatchTableEntry(IMG_UINT32 ui32Index,
211                                            const IMG_CHAR *pszIOCName,
212                                            BridgeWrapperFunction pfFunction,
213                                            const IMG_CHAR *pszFunctionName);
216 /* PRQA S 0884,3410 2*/ /* macro relies on the lack of brackets */
217 #define SetDispatchTableEntry(ui32Index, pfFunction) \
218         _SetDispatchTableEntry(PVRSRV_GET_BRIDGE_ID(ui32Index), #ui32Index, (BridgeWrapperFunction)pfFunction, #pfFunction)
220 #define DISPATCH_TABLE_GAP_THRESHOLD 5
222 #if defined(DEBUG)
223 #define PVRSRV_BRIDGE_ASSERT_CMD(X, Y) PVR_ASSERT(X == PVRSRV_GET_BRIDGE_ID(Y))
224 #else
225 #define PVRSRV_BRIDGE_ASSERT_CMD(X, Y) PVR_UNREFERENCED_PARAMETER(X)
226 #endif
229 #if defined(DEBUG_BRIDGE_KM)
230 typedef struct _PVRSRV_BRIDGE_GLOBAL_STATS
232         IMG_UINT32 ui32IOCTLCount;
233         IMG_UINT32 ui32TotalCopyFromUserBytes;
234         IMG_UINT32 ui32TotalCopyToUserBytes;
235 }PVRSRV_BRIDGE_GLOBAL_STATS;
237 /* OS specific code way want to report the stats held here and within the
238  * BRIDGE_DISPATCH_TABLE_ENTRYs (E.g. on Linux we report these via a
239  * proc entry /proc/pvr/bridge_stats. Ref printLinuxBridgeStats()) */
240 extern PVRSRV_BRIDGE_GLOBAL_STATS g_BridgeGlobalStats;
241 #endif
244 PVRSRV_ERROR CommonBridgeInit(IMG_VOID);
246 IMG_INT BridgedDispatchKM(PVRSRV_PER_PROCESS_DATA * psPerProc,
247                                           PVRSRV_BRIDGE_PACKAGE   * psBridgePackageKM);
249 #if defined (__cplusplus)
251 #endif
253 #endif /* __BRIDGED_PVR_BRIDGE_H__ */
255 /******************************************************************************
256  End of file (bridged_pvr_bridge.h)
257 ******************************************************************************/