]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/vendor-ti-am57x.git/blob - sgx_km/eurasia_km/services4/srvkm/include/srvkm.h
sgx_km: Build SGX KM from source
[android/vendor-ti-am57x.git] / sgx_km / eurasia_km / services4 / srvkm / include / srvkm.h
1 /*************************************************************************/ /*!
2 @Title          Services kernel module internal header file
3 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @License        Dual MIT/GPLv2
6 The contents of this file are subject to the MIT license as set out below.
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
18 Alternatively, the contents of this file may be used under the terms of
19 the GNU General Public License Version 2 ("GPL") in which case the provisions
20 of GPL are applicable instead of those above.
22 If you wish to allow use of your version of this file only under the terms of
23 GPL, and not to allow others to use your version of this file under the terms
24 of the MIT license, indicate your decision by deleting the provisions above
25 and replace them with the notice and other provisions required by GPL as set
26 out in the file called "GPL-COPYING" included in this distribution. If you do
27 not delete the provisions above, a recipient may use your version of this file
28 under the terms of either the MIT license or GPL.
30 This License is also included in this distribution in the file called
31 "MIT-COPYING".
33 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 */ /**************************************************************************/
42 #ifndef SRVKM_H
43 #define SRVKM_H
45 #include "servicesint.h"
47 #if defined(__cplusplus)
48 extern "C" {
49 #endif
51         /**     Use PVR_DPF() unless message is necessary in release build
52          */
53         #ifdef PVR_DISABLE_LOGGING
54         #define PVR_LOG(X)
55         #else
56         /* PRQA S 3410 1 */ /* this macro requires no brackets in order to work */
57         #define PVR_LOG(X)                      PVRSRVReleasePrintf X;
58         #endif
60         IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVReleasePrintf(const IMG_CHAR *pszFormat, ...) IMG_FORMAT_PRINTF(1, 2);
62         IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVProcessConnect(IMG_UINT32    ui32PID, IMG_UINT32 ui32Flags);
63         IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVProcessDisconnect(IMG_UINT32     ui32PID);
65         IMG_IMPORT IMG_VOID PVRSRVScheduleDevicesKM(IMG_VOID);
67 #if defined(SUPPORT_PVRSRV_DEVICE_CLASS)
68         IMG_VOID IMG_CALLCONV PVRSRVSetDCState(IMG_UINT32 ui32State);
69 #endif
71         PVRSRV_ERROR IMG_CALLCONV PVRSRVSaveRestoreLiveSegments(IMG_HANDLE hArena, IMG_PBYTE pbyBuffer, IMG_SIZE_T *puiBufSize, IMG_BOOL bSave);
73         IMG_VOID PVRSRVScheduleDeviceCallbacks(IMG_VOID);
75         IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDumpSyncs(IMG_BOOL bActiveOnly);
77 #define SYNC_OP_CLASS_MASK                      0x0000ffffUL
78 #define SYNC_OP_CLASS_SHIFT                     0
79 #define SYNC_OP_CLASS_MODOBJ            (1<<0)
80 #define SYNC_OP_CLASS_QUEUE                     (1<<1)
81 #define SYNC_OP_CLASS_KICKTA            (1<<2)
82 #define SYNC_OP_CLASS_TQ_3D                     (1<<3)
83 #define SYNC_OP_CLASS_TQ_2D                     (1<<4)
84 #define SYNC_OP_CLASS_LINUX_FENCE               (1<<5)
85 #define SYNC_OP_TYPE_MASK                       0x00f0000UL
86 #define SYNC_OP_TYPE_SHIFT                      16
87 #define SYNC_OP_TYPE_READOP                     (1<<0)
88 #define SYNC_OP_TYPE_WRITEOP            (1<<1)
89 #define SYNC_OP_TYPE_READOP2            (1<<2)
91 #define SYNC_OP_HAS_DATA                        0x80000000UL
92 #define SYNC_OP_TAKE                            0x40000000UL
93 #define SYNC_OP_ROLLBACK                        0x20000000UL
95 #ifdef INLINE_IS_PRAGMA
96 #pragma inline(SyncTakeWriteOp)
97 #endif
98 static INLINE
99 IMG_UINT32 SyncTakeWriteOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType)
101 #if defined(SUPPORT_PER_SYNC_DEBUG)
102         IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex;
104         /* Record a history of all the classes of operation taken on this sync */
105         psKernelSync->ui32OperationMask |= (ui32OpType & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT;
107         /* Add this operation to the history buffer */
108         psKernelSync->aui32OpInfo[ui32Index] = SYNC_OP_HAS_DATA | ui32OpType | (SYNC_OP_TYPE_WRITEOP << SYNC_OP_TYPE_SHIFT) | SYNC_OP_TAKE;
109         psKernelSync->aui32ReadOpSample[ui32Index] = psKernelSync->psSyncData->ui32ReadOpsPending;
110         psKernelSync->aui32WriteOpSample[ui32Index] = psKernelSync->psSyncData->ui32WriteOpsPending;
111         psKernelSync->aui32ReadOp2Sample[ui32Index] = psKernelSync->psSyncData->ui32ReadOps2Pending;
112         psKernelSync->ui32HistoryIndex++;
113         psKernelSync->ui32HistoryIndex = psKernelSync->ui32HistoryIndex % PER_SYNC_HISTORY;
114 #endif
115         PVR_UNREFERENCED_PARAMETER(ui32OpType);
116         return psKernelSync->psSyncData->ui32WriteOpsPending++;
119 #ifdef INLINE_IS_PRAGMA
120 #pragma inline(SyncTakeReadOp)
121 #endif
122 static INLINE
123 IMG_UINT32 SyncTakeReadOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType)
125 #if defined(SUPPORT_PER_SYNC_DEBUG)
126         IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex;
128         /* Record a history of all the classes of operation taken on this sync */
129         psKernelSync->ui32OperationMask |= (ui32OpType & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT;
131         /* Add this operation to the history buffer */
132         psKernelSync->aui32OpInfo[ui32Index] = SYNC_OP_HAS_DATA | ui32OpType | (SYNC_OP_TYPE_READOP << SYNC_OP_TYPE_SHIFT) | SYNC_OP_TAKE;
133         psKernelSync->aui32ReadOpSample[ui32Index] = psKernelSync->psSyncData->ui32ReadOpsPending;
134         psKernelSync->aui32WriteOpSample[ui32Index] = psKernelSync->psSyncData->ui32WriteOpsPending;
135         psKernelSync->aui32ReadOp2Sample[ui32Index] = psKernelSync->psSyncData->ui32ReadOps2Pending;
136         psKernelSync->ui32HistoryIndex++;
137         psKernelSync->ui32HistoryIndex = psKernelSync->ui32HistoryIndex % PER_SYNC_HISTORY;
138 #endif
139         PVR_UNREFERENCED_PARAMETER(ui32OpType);
140         return psKernelSync->psSyncData->ui32ReadOpsPending++;
143 #ifdef INLINE_IS_PRAGMA
144 #pragma inline(SyncTakeReadOp2)
145 #endif
146 static INLINE
147 IMG_UINT32 SyncTakeReadOp2(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType)
149 #if defined(SUPPORT_PER_SYNC_DEBUG)
150         IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex;
152         /* Record a history of all the classes of operation taken on this sync */
153         psKernelSync->ui32OperationMask |= (ui32OpType & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT;
155         /* Add this operation to the history buffer */
156         psKernelSync->aui32OpInfo[ui32Index] = SYNC_OP_HAS_DATA | ui32OpType | (SYNC_OP_TYPE_READOP2 << SYNC_OP_TYPE_SHIFT) | SYNC_OP_TAKE;
157         psKernelSync->aui32ReadOpSample[ui32Index] = psKernelSync->psSyncData->ui32ReadOpsPending;
158         psKernelSync->aui32WriteOpSample[ui32Index] = psKernelSync->psSyncData->ui32WriteOpsPending;
159         psKernelSync->aui32ReadOp2Sample[ui32Index] = psKernelSync->psSyncData->ui32ReadOps2Pending;
160         psKernelSync->ui32HistoryIndex++;
161         psKernelSync->ui32HistoryIndex = psKernelSync->ui32HistoryIndex % PER_SYNC_HISTORY;
162 #endif
163         PVR_UNREFERENCED_PARAMETER(ui32OpType);
164         return psKernelSync->psSyncData->ui32ReadOps2Pending++;
167 #ifdef INLINE_IS_PRAGMA
168 #pragma inline(SyncRollBackWriteOp)
169 #endif
170 static INLINE
171 IMG_UINT32 SyncRollBackWriteOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType)
173 #if defined(SUPPORT_PER_SYNC_DEBUG)
174         IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex;
176         /* Record a history of all the classes of operation taken on this sync */
177         psKernelSync->ui32OperationMask |= (ui32OpType & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT;
179         /* Add this operation to the history buffer */
180         psKernelSync->aui32OpInfo[ui32Index] = SYNC_OP_HAS_DATA | ui32OpType | (SYNC_OP_TYPE_WRITEOP << SYNC_OP_TYPE_SHIFT) | SYNC_OP_ROLLBACK;
181         psKernelSync->aui32ReadOpSample[ui32Index] = psKernelSync->psSyncData->ui32ReadOpsPending;
182         psKernelSync->aui32WriteOpSample[ui32Index] = psKernelSync->psSyncData->ui32WriteOpsPending;
183         psKernelSync->aui32ReadOp2Sample[ui32Index] = psKernelSync->psSyncData->ui32ReadOps2Pending;
184         psKernelSync->ui32HistoryIndex++;
185         psKernelSync->ui32HistoryIndex = psKernelSync->ui32HistoryIndex % PER_SYNC_HISTORY;
186 #endif
187         PVR_UNREFERENCED_PARAMETER(ui32OpType);
188         return psKernelSync->psSyncData->ui32WriteOpsPending--;
191 #ifdef INLINE_IS_PRAGMA
192 #pragma inline(SyncRollBackReadOp)
193 #endif
194 static INLINE
195 IMG_UINT32 SyncRollBackReadOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType)
197 #if defined(SUPPORT_PER_SYNC_DEBUG)
198         IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex;
200         /* Record a history of all the classes of operation taken on this sync */
201         psKernelSync->ui32OperationMask |= (ui32OpType & SYNC_OP_CLASS_MASK) >> SYNC_OP_CLASS_SHIFT;
203         /* Add this operation to the history buffer */
204         psKernelSync->aui32OpInfo[ui32Index] = SYNC_OP_HAS_DATA | ui32OpType | (SYNC_OP_TYPE_READOP << SYNC_OP_TYPE_SHIFT) | SYNC_OP_ROLLBACK;
205         psKernelSync->aui32ReadOpSample[ui32Index] = psKernelSync->psSyncData->ui32ReadOpsPending;
206         psKernelSync->aui32WriteOpSample[ui32Index] = psKernelSync->psSyncData->ui32WriteOpsPending;
207         psKernelSync->aui32ReadOp2Sample[ui32Index] = psKernelSync->psSyncData->ui32ReadOps2Pending;
208         psKernelSync->ui32HistoryIndex++;
209         psKernelSync->ui32HistoryIndex = psKernelSync->ui32HistoryIndex % PER_SYNC_HISTORY;
210 #endif
211         PVR_UNREFERENCED_PARAMETER(ui32OpType);
212         return psKernelSync->psSyncData->ui32ReadOpsPending--;
217 #if defined (__cplusplus)
219 #endif
221 /******************
222 HIGHER LEVEL MACROS
223 *******************/
225 /*----------------------------------------------------------------------------
226 Repeats the body of the loop for a certain minimum time, or until the body
227 exits by its own means (break, return, goto, etc.)
229 Example of usage:
231 LOOP_UNTIL_TIMEOUT(MAX_HW_TIME_US)
233         if(psQueueInfo->ui32ReadOffset == psQueueInfo->ui32WriteOffset)
234         {
235                 bTimeout = IMG_FALSE;
236                 break;
237         }
238         
239         OSWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT);
240 } END_LOOP_UNTIL_TIMEOUT();
242 -----------------------------------------------------------------------------*/
244 /*      uiNotLastLoop will remain at 1 until the timeout has expired, at which time             
245  *      it will be decremented and the loop executed one final time. This is necessary
246  *      when preemption is enabled. 
247  */
248 /* PRQA S 3411,3431 12 */ /* critical format, leave alone */
249 #define LOOP_UNTIL_TIMEOUT(TIMEOUT) \
250 {\
251         IMG_UINT32 uiOffset, uiStart, uiCurrent; \
252         IMG_INT32 iNotLastLoop;                                  \
253         for(uiOffset = 0, uiStart = OSClockus(), uiCurrent = uiStart + 1, iNotLastLoop = 1;\
254                 ((uiCurrent - uiStart + uiOffset) < (TIMEOUT)) || iNotLastLoop--;                               \
255                 uiCurrent = OSClockus(),                                                                                                        \
256                 uiOffset = uiCurrent < uiStart ? IMG_UINT32_MAX - uiStart : uiOffset,           \
257                 uiStart = uiCurrent < uiStart ? 0 : uiStart)
259 #define END_LOOP_UNTIL_TIMEOUT() \
262 /*!
263  ******************************************************************************
265  @Function              PVRSRVGetErrorStringKM
267  @Description   Returns a text string relating to the PVRSRV_ERROR enum.
269  ******************************************************************************/
270 IMG_IMPORT
271 const IMG_CHAR *PVRSRVGetErrorStringKM(PVRSRV_ERROR eError);
273 #endif /* SRVKM_H */