20093908+0m5+flat+Lindent
[sgx.git] / pvr / servicesint.h
1 /**********************************************************************
2  *
3  * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
4  * 
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.
8  * 
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.
13  * 
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.
17  * 
18  * The full GNU General Public License is included in this distribution in
19  * the file called "COPYING".
20  *
21  * Contact Information:
22  * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23  * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK 
24  *
25  ******************************************************************************/
26
27 #if !defined (__SERVICESINT_H__)
28 #define __SERVICESINT_H__
29
30 #if defined (__cplusplus)
31 extern "C" {
32 #endif
33
34 #include "services.h"
35 #include "sysinfo.h"
36
37 #define HWREC_DEFAULT_TIMEOUT   (500)
38
39 #define DRIVERNAME_MAXLENGTH    (100)
40
41         typedef struct _PVRSRV_KERNEL_MEM_INFO_ {
42
43                 IMG_PVOID pvLinAddrKM;
44
45                 IMG_DEV_VIRTADDR sDevVAddr;
46
47                 IMG_UINT32 ui32Flags;
48
49                 IMG_UINT32 ui32AllocSize;
50
51                 PVRSRV_MEMBLK sMemBlk;
52
53                 struct _PVRSRV_KERNEL_SYNC_INFO_ *psKernelSyncInfo;
54
55         } PVRSRV_KERNEL_MEM_INFO;
56
57         typedef struct _PVRSRV_KERNEL_SYNC_INFO_ {
58
59                 PVRSRV_SYNC_DATA *psSyncData;
60
61                 IMG_DEV_VIRTADDR sWriteOpsCompleteDevVAddr;
62
63                 IMG_DEV_VIRTADDR sReadOpsCompleteDevVAddr;
64
65                 PVRSRV_KERNEL_MEM_INFO *psSyncDataMemInfoKM;
66
67         } PVRSRV_KERNEL_SYNC_INFO;
68
69         typedef struct _PVRSRV_DEVICE_SYNC_OBJECT_ {
70                 IMG_UINT32 ui32ReadOpPendingVal;
71                 IMG_DEV_VIRTADDR sReadOpsCompleteDevVAddr;
72                 IMG_UINT32 ui32WriteOpPendingVal;
73                 IMG_DEV_VIRTADDR sWriteOpsCompleteDevVAddr;
74         } PVRSRV_DEVICE_SYNC_OBJECT;
75
76         typedef struct _PVRSRV_SYNC_OBJECT {
77                 PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfoKM;
78                 IMG_UINT32 ui32WriteOpsPending;
79                 IMG_UINT32 ui32ReadOpsPending;
80
81         } PVRSRV_SYNC_OBJECT, *PPVRSRV_SYNC_OBJECT;
82
83         typedef struct _PVRSRV_COMMAND {
84                 IMG_UINT32 ui32CmdSize;
85                 IMG_UINT32 ui32DevIndex;
86                 IMG_UINT32 CommandType;
87                 IMG_UINT32 ui32DstSyncCount;
88                 IMG_UINT32 ui32SrcSyncCount;
89                 PVRSRV_SYNC_OBJECT *psDstSync;
90                 PVRSRV_SYNC_OBJECT *psSrcSync;
91                 IMG_UINT32 ui32DataSize;
92                 IMG_UINT32 ui32ProcessID;
93                 IMG_VOID *pvData;
94         } PVRSRV_COMMAND, *PPVRSRV_COMMAND;
95
96         typedef struct _PVRSRV_QUEUE_INFO_ {
97                 IMG_VOID *pvLinQueueKM;
98                 IMG_VOID *pvLinQueueUM;
99                 volatile IMG_UINT32 ui32ReadOffset;
100                 volatile IMG_UINT32 ui32WriteOffset;
101                 IMG_UINT32 *pui32KickerAddrKM;
102                 IMG_UINT32 *pui32KickerAddrUM;
103                 IMG_UINT32 ui32QueueSize;
104
105                 IMG_UINT32 ui32ProcessID;
106
107                 IMG_HANDLE hMemBlock[2];
108
109                 struct _PVRSRV_QUEUE_INFO_ *psNextKM;
110         } PVRSRV_QUEUE_INFO;
111
112         typedef PVRSRV_ERROR(*PFN_INSERT_CMD) (PVRSRV_QUEUE_INFO *,
113                                                PVRSRV_COMMAND **,
114                                                IMG_UINT32,
115                                                IMG_UINT16,
116                                                IMG_UINT32,
117                                                PVRSRV_KERNEL_SYNC_INFO *[],
118                                                IMG_UINT32,
119                                                PVRSRV_KERNEL_SYNC_INFO *[],
120                                                IMG_UINT32);
121         typedef PVRSRV_ERROR(*PFN_SUBMIT_CMD) (PVRSRV_QUEUE_INFO *,
122                                                PVRSRV_COMMAND *, IMG_BOOL);
123
124         typedef struct PVRSRV_DEVICECLASS_BUFFER_TAG {
125                 PFN_GET_BUFFER_ADDR pfnGetBufferAddr;
126                 IMG_HANDLE hDevMemContext;
127                 IMG_HANDLE hExtDevice;
128                 IMG_HANDLE hExtBuffer;
129                 PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo;
130
131         } PVRSRV_DEVICECLASS_BUFFER;
132
133         typedef struct PVRSRV_CLIENT_DEVICECLASS_INFO_TAG {
134                 IMG_HANDLE hDeviceKM;
135                 IMG_HANDLE hServices;
136         } PVRSRV_CLIENT_DEVICECLASS_INFO;
137
138 #ifdef INLINE_IS_PRAGMA
139 #pragma inline(PVRSRVGetWriteOpsPending)
140 #endif
141         static INLINE
142             IMG_UINT32 PVRSRVGetWriteOpsPending(PVRSRV_KERNEL_SYNC_INFO *
143                                                 psSyncInfo,
144                                                 IMG_BOOL bIsReadOp) {
145                 IMG_UINT32 ui32WriteOpsPending;
146
147                 if (bIsReadOp) {
148                         ui32WriteOpsPending =
149                             psSyncInfo->psSyncData->ui32WriteOpsPending;
150                 } else {
151
152                         ui32WriteOpsPending =
153                             psSyncInfo->psSyncData->ui32WriteOpsPending++;
154                 }
155
156                 return ui32WriteOpsPending;
157         }
158
159 #ifdef INLINE_IS_PRAGMA
160 #pragma inline(PVRSRVGetReadOpsPending)
161 #endif
162         static INLINE
163             IMG_UINT32 PVRSRVGetReadOpsPending(PVRSRV_KERNEL_SYNC_INFO *
164                                                psSyncInfo, IMG_BOOL bIsReadOp) {
165                 IMG_UINT32 ui32ReadOpsPending;
166
167                 if (bIsReadOp) {
168                         ui32ReadOpsPending =
169                             psSyncInfo->psSyncData->ui32ReadOpsPending++;
170                 } else {
171                         ui32ReadOpsPending =
172                             psSyncInfo->psSyncData->ui32ReadOpsPending;
173                 }
174
175                 return ui32ReadOpsPending;
176         }
177
178         IMG_IMPORT
179             PVRSRV_ERROR PVRSRVQueueCommand(IMG_HANDLE hQueueInfo,
180                                             PVRSRV_COMMAND * psCommand);
181
182         IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV
183             PVRSRVGetMMUContextPDDevPAddr(const PVRSRV_CONNECTION *
184                                           psConnection,
185                                           IMG_HANDLE hDevMemContext,
186                                           IMG_DEV_PHYADDR * sPDDevPAddr);
187
188         IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV
189             PVRSRVAllocSharedSysMem(const PVRSRV_CONNECTION * psConnection,
190                                     IMG_UINT32 ui32Flags,
191                                     IMG_UINT32 ui32Size,
192                                     PVRSRV_CLIENT_MEM_INFO ** ppsClientMemInfo);
193
194         IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV
195             PVRSRVFreeSharedSysMem(const PVRSRV_CONNECTION * psConnection,
196                                    PVRSRV_CLIENT_MEM_INFO * psClientMemInfo);
197
198         IMG_IMPORT PVRSRV_ERROR
199             PVRSRVUnrefSharedSysMem(const PVRSRV_CONNECTION * psConnection,
200                                     PVRSRV_CLIENT_MEM_INFO * psClientMemInfo);
201
202         IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV
203             PVRSRVMapMemInfoMem(const PVRSRV_CONNECTION * psConnection,
204                                 IMG_HANDLE hKernelMemInfo,
205                                 PVRSRV_CLIENT_MEM_INFO ** ppsClientMemInfo);
206
207 #if defined (__cplusplus)
208 }
209 #endif
210 #endif