fixes for bc_cat
[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
31 #include "services.h"
32 #include "sysinfo.h"
33
34 #define HWREC_DEFAULT_TIMEOUT           500
35
36 #define DRIVERNAME_MAXLENGTH            100
37
38 struct PVRSRV_KERNEL_MEM_INFO {
39
40         void *pvLinAddrKM;
41         struct IMG_DEV_VIRTADDR sDevVAddr;
42         u32 ui32Flags;
43         u32 ui32AllocSize;
44         struct PVRSRV_MEMBLK sMemBlk;
45
46         void *pvSysBackupBuffer;
47
48         u32 ui32RefCount;
49
50         struct PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo;
51 };
52
53 struct PVRSRV_KERNEL_SYNC_INFO {
54         struct PVRSRV_SYNC_DATA *psSyncData;
55         struct IMG_DEV_VIRTADDR sWriteOpsCompleteDevVAddr;
56         struct IMG_DEV_VIRTADDR sReadOpsCompleteDevVAddr;
57         struct PVRSRV_KERNEL_MEM_INFO *psSyncDataMemInfoKM;
58
59         /*
60          * This stores the physical address of the buffer that
61          * this syncobject manages (if provided)
62          */
63         struct IMG_SYS_PHYADDR phys_addr;
64         void *dev_cookie;
65         u32 refcount;
66 };
67
68 struct PVRSRV_DEVICE_SYNC_OBJECT {
69
70         u32 ui32ReadOpsPendingVal;
71         struct IMG_DEV_VIRTADDR sReadOpsCompleteDevVAddr;
72         u32 ui32WriteOpsPendingVal;
73         struct IMG_DEV_VIRTADDR sWriteOpsCompleteDevVAddr;
74 };
75
76 struct PVRSRV_SYNC_OBJECT {
77         struct PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfoKM;
78         u32 ui32WriteOpsPending;
79         u32 ui32ReadOpsPending;
80 };
81
82 struct PVRSRV_COMMAND {
83         u32 ui32CmdSize;
84         u32 ui32DevIndex;
85         u32 CommandType;
86         u32 ui32DstSyncCount;
87         u32 ui32SrcSyncCount;
88         struct PVRSRV_SYNC_OBJECT *psDstSync;
89         struct PVRSRV_SYNC_OBJECT *psSrcSync;
90         u32 ui32DataSize;
91         u32 ui32ProcessID;
92         void *pvData;
93 };
94
95 struct PVRSRV_QUEUE_INFO {
96         void *pvLinQueueKM;
97         void *pvLinQueueUM;
98         volatile u32 ui32ReadOffset;
99         volatile u32 ui32WriteOffset;
100         u32 *pui32KickerAddrKM;
101         u32 *pui32KickerAddrUM;
102         u32 ui32QueueSize;
103
104         u32 ui32ProcessID;
105
106         void *hMemBlock[2];
107
108         struct PVRSRV_QUEUE_INFO *psNextKM;
109 };
110
111 struct PVRSRV_DEVICECLASS_BUFFER {
112         enum PVRSRV_ERROR (*pfnGetBufferAddr)(void *, void *,
113                                     struct IMG_SYS_PHYADDR **, u32 *,
114                                     void __iomem **, void **, IMG_BOOL *);
115         void *hDevMemContext;
116         void *hExtDevice;
117         void *hExtBuffer;
118         struct PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo;
119 };
120
121 struct PVRSRV_CLIENT_DEVICECLASS_INFO {
122         void *hDeviceKM;
123         void *hServices;
124 };
125
126 static inline u32 PVRSRVGetWriteOpsPending(
127                 struct PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_BOOL bIsReadOp)
128 {
129         u32 ui32WriteOpsPending;
130
131         if (bIsReadOp)
132                 ui32WriteOpsPending =
133                     psSyncInfo->psSyncData->ui32WriteOpsPending;
134         else
135                 ui32WriteOpsPending =
136                     psSyncInfo->psSyncData->ui32WriteOpsPending++;
137
138         return ui32WriteOpsPending;
139 }
140
141 static inline u32 PVRSRVGetReadOpsPending(
142                 struct PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, IMG_BOOL bIsReadOp)
143 {
144         u32 ui32ReadOpsPending;
145
146         if (bIsReadOp)
147                 ui32ReadOpsPending =
148                     psSyncInfo->psSyncData->ui32ReadOpsPending++;
149         else
150                 ui32ReadOpsPending = psSyncInfo->psSyncData->ui32ReadOpsPending;
151
152         return ui32ReadOpsPending;
153 }
154
155 enum PVRSRV_ERROR PVRSRVQueueCommand(void *hQueueInfo,
156                                     struct PVRSRV_COMMAND *psCommand);
157
158 enum PVRSRV_ERROR PVRSRVGetMMUContextPDDevPAddr(
159                         const struct PVRSRV_CONNECTION *psConnection,
160                         void *hDevMemContext,
161                         struct IMG_DEV_PHYADDR *sPDDevPAddr);
162
163 enum PVRSRV_ERROR PVRSRVAllocSharedSysMem(
164                         const struct PVRSRV_CONNECTION *psConnection,
165                         u32 ui32Flags, u32 ui32Size,
166                         struct PVRSRV_CLIENT_MEM_INFO **ppsClientMemInfo);
167
168 enum PVRSRV_ERROR PVRSRVFreeSharedSysMem(
169                         const struct PVRSRV_CONNECTION *psConnection,
170                         struct PVRSRV_CLIENT_MEM_INFO *psClientMemInfo);
171
172 enum PVRSRV_ERROR PVRSRVUnrefSharedSysMem(
173                         const struct PVRSRV_CONNECTION *psConnection,
174                         struct PVRSRV_CLIENT_MEM_INFO *psClientMemInfo);
175
176 enum PVRSRV_ERROR PVRSRVMapMemInfoMem(
177                         const struct PVRSRV_CONNECTION *psConnection,
178                         void *hKernelMemInfo,
179                         struct PVRSRV_CLIENT_MEM_INFO **ppsClientMemInfo);
180
181 #endif