aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/pvr/services4/srvkm/include/srvkm.h')
-rw-r--r--drivers/gpu/pvr/services4/srvkm/include/srvkm.h273
1 files changed, 273 insertions, 0 deletions
diff --git a/drivers/gpu/pvr/services4/srvkm/include/srvkm.h b/drivers/gpu/pvr/services4/srvkm/include/srvkm.h
new file mode 100644
index 000000000000..723037e284db
--- /dev/null
+++ b/drivers/gpu/pvr/services4/srvkm/include/srvkm.h
@@ -0,0 +1,273 @@
1/*************************************************************************/ /*!
2@Title Services kernel module internal header file
3@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4@License Dual MIT/GPLv2
5
6The contents of this file are subject to the MIT license as set out below.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18Alternatively, the contents of this file may be used under the terms of
19the GNU General Public License Version 2 ("GPL") in which case the provisions
20of GPL are applicable instead of those above.
21
22If you wish to allow use of your version of this file only under the terms of
23GPL, and not to allow others to use your version of this file under the terms
24of the MIT license, indicate your decision by deleting the provisions above
25and replace them with the notice and other provisions required by GPL as set
26out in the file called "GPL-COPYING" included in this distribution. If you do
27not delete the provisions above, a recipient may use your version of this file
28under the terms of either the MIT license or GPL.
29
30This License is also included in this distribution in the file called
31"MIT-COPYING".
32
33EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40*/ /**************************************************************************/
41
42#ifndef SRVKM_H
43#define SRVKM_H
44
45#include "servicesint.h"
46
47#if defined(__cplusplus)
48extern "C" {
49#endif
50
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
59
60 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVReleasePrintf(const IMG_CHAR *pszFormat, ...) IMG_FORMAT_PRINTF(1, 2);
61
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);
64
65 IMG_IMPORT IMG_VOID PVRSRVScheduleDevicesKM(IMG_VOID);
66
67#if defined(SUPPORT_PVRSRV_DEVICE_CLASS)
68 IMG_VOID IMG_CALLCONV PVRSRVSetDCState(IMG_UINT32 ui32State);
69#endif
70
71 PVRSRV_ERROR IMG_CALLCONV PVRSRVSaveRestoreLiveSegments(IMG_HANDLE hArena, IMG_PBYTE pbyBuffer, IMG_SIZE_T *puiBufSize, IMG_BOOL bSave);
72
73 IMG_VOID PVRSRVScheduleDeviceCallbacks(IMG_VOID);
74
75 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVDumpSyncs(IMG_BOOL bActiveOnly);
76
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)
90
91#define SYNC_OP_HAS_DATA 0x80000000UL
92#define SYNC_OP_TAKE 0x40000000UL
93#define SYNC_OP_ROLLBACK 0x20000000UL
94
95#ifdef INLINE_IS_PRAGMA
96#pragma inline(SyncTakeWriteOp)
97#endif
98static INLINE
99IMG_UINT32 SyncTakeWriteOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType)
100{
101#if defined(SUPPORT_PER_SYNC_DEBUG)
102 IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex;
103
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;
106
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++;
117}
118
119#ifdef INLINE_IS_PRAGMA
120#pragma inline(SyncTakeReadOp)
121#endif
122static INLINE
123IMG_UINT32 SyncTakeReadOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType)
124{
125#if defined(SUPPORT_PER_SYNC_DEBUG)
126 IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex;
127
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;
130
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++;
141}
142
143#ifdef INLINE_IS_PRAGMA
144#pragma inline(SyncTakeReadOp2)
145#endif
146static INLINE
147IMG_UINT32 SyncTakeReadOp2(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType)
148{
149#if defined(SUPPORT_PER_SYNC_DEBUG)
150 IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex;
151
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;
154
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++;
165}
166
167#ifdef INLINE_IS_PRAGMA
168#pragma inline(SyncRollBackWriteOp)
169#endif
170static INLINE
171IMG_UINT32 SyncRollBackWriteOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType)
172{
173#if defined(SUPPORT_PER_SYNC_DEBUG)
174 IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex;
175
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;
178
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--;
189}
190
191#ifdef INLINE_IS_PRAGMA
192#pragma inline(SyncRollBackReadOp)
193#endif
194static INLINE
195IMG_UINT32 SyncRollBackReadOp(PVRSRV_KERNEL_SYNC_INFO *psKernelSync, IMG_UINT32 ui32OpType)
196{
197#if defined(SUPPORT_PER_SYNC_DEBUG)
198 IMG_UINT32 ui32Index = psKernelSync->ui32HistoryIndex;
199
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;
202
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--;
213}
214
215
216
217#if defined (__cplusplus)
218}
219#endif
220
221/******************
222HIGHER LEVEL MACROS
223*******************/
224
225/*----------------------------------------------------------------------------
226Repeats the body of the loop for a certain minimum time, or until the body
227exits by its own means (break, return, goto, etc.)
228
229Example of usage:
230
231LOOP_UNTIL_TIMEOUT(MAX_HW_TIME_US)
232{
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();
241
242-----------------------------------------------------------------------------*/
243
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)
258
259#define END_LOOP_UNTIL_TIMEOUT() \
260}
261
262/*!
263 ******************************************************************************
264
265 @Function PVRSRVGetErrorStringKM
266
267 @Description Returns a text string relating to the PVRSRV_ERROR enum.
268
269 ******************************************************************************/
270IMG_IMPORT
271const IMG_CHAR *PVRSRVGetErrorStringKM(PVRSRV_ERROR eError);
272
273#endif /* SRVKM_H */