acbb46475b7c88c816376cb76e271c6668622ffa
[platform/kernel/linux-starfive.git] /
1 /*******************************************************************************
2 @File
3 @Title          Direct client bridge for devicememhistory
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Implements the client side of the bridge for devicememhistory
6                 which is used in calls from Server context.
7 @License        Dual MIT/GPLv2
8
9 The contents of this file are subject to the MIT license as set out below.
10
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
21 Alternatively, the contents of this file may be used under the terms of
22 the GNU General Public License Version 2 ("GPL") in which case the provisions
23 of GPL are applicable instead of those above.
24
25 If you wish to allow use of your version of this file only under the terms of
26 GPL, and not to allow others to use your version of this file under the terms
27 of the MIT license, indicate your decision by deleting the provisions above
28 and replace them with the notice and other provisions required by GPL as set
29 out in the file called "GPL-COPYING" included in this distribution. If you do
30 not delete the provisions above, a recipient may use your version of this file
31 under the terms of either the MIT license or GPL.
32
33 This License is also included in this distribution in the file called
34 "MIT-COPYING".
35
36 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
37 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
40 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
41 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 *******************************************************************************/
44
45 #include "client_devicememhistory_bridge.h"
46 #include "img_defs.h"
47 #include "pvr_debug.h"
48
49 /* Module specific includes */
50 #include "img_types.h"
51 #include "img_defs.h"
52 #include "devicemem_typedefs.h"
53
54 #include "devicemem_history_server.h"
55
56 IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryMap(IMG_HANDLE hBridge,
57                                                     IMG_HANDLE hPMR,
58                                                     IMG_DEVMEM_SIZE_T uiOffset,
59                                                     IMG_DEV_VIRTADDR sDevVAddr,
60                                                     IMG_DEVMEM_SIZE_T uiSize,
61                                                     const IMG_CHAR * puiText,
62                                                     IMG_UINT32 ui32Log2PageSize,
63                                                     IMG_UINT32 ui32AllocationIndex,
64                                                     IMG_UINT32 * pui32AllocationIndexOut)
65 {
66         PVRSRV_ERROR eError;
67         PMR *psPMRInt;
68         PVR_UNREFERENCED_PARAMETER(hBridge);
69
70         psPMRInt = (PMR *) hPMR;
71
72         eError =
73             DevicememHistoryMapKM(psPMRInt,
74                                   uiOffset,
75                                   sDevVAddr,
76                                   uiSize,
77                                   puiText,
78                                   ui32Log2PageSize, ui32AllocationIndex, pui32AllocationIndexOut);
79
80         return eError;
81 }
82
83 IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryUnmap(IMG_HANDLE hBridge,
84                                                       IMG_HANDLE hPMR,
85                                                       IMG_DEVMEM_SIZE_T uiOffset,
86                                                       IMG_DEV_VIRTADDR sDevVAddr,
87                                                       IMG_DEVMEM_SIZE_T uiSize,
88                                                       const IMG_CHAR * puiText,
89                                                       IMG_UINT32 ui32Log2PageSize,
90                                                       IMG_UINT32 ui32AllocationIndex,
91                                                       IMG_UINT32 * pui32AllocationIndexOut)
92 {
93         PVRSRV_ERROR eError;
94         PMR *psPMRInt;
95         PVR_UNREFERENCED_PARAMETER(hBridge);
96
97         psPMRInt = (PMR *) hPMR;
98
99         eError =
100             DevicememHistoryUnmapKM(psPMRInt,
101                                     uiOffset,
102                                     sDevVAddr,
103                                     uiSize,
104                                     puiText,
105                                     ui32Log2PageSize, ui32AllocationIndex, pui32AllocationIndexOut);
106
107         return eError;
108 }
109
110 IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryMapVRange(IMG_HANDLE hBridge,
111                                                           IMG_DEV_VIRTADDR sBaseDevVAddr,
112                                                           IMG_UINT32 ui32ui32StartPage,
113                                                           IMG_UINT32 ui32NumPages,
114                                                           IMG_DEVMEM_SIZE_T uiAllocSize,
115                                                           const IMG_CHAR * puiText,
116                                                           IMG_UINT32 ui32Log2PageSize,
117                                                           IMG_UINT32 ui32AllocationIndex,
118                                                           IMG_UINT32 * pui32AllocationIndexOut)
119 {
120         PVRSRV_ERROR eError;
121
122         eError =
123             DevicememHistoryMapVRangeKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
124                                         sBaseDevVAddr,
125                                         ui32ui32StartPage,
126                                         ui32NumPages,
127                                         uiAllocSize,
128                                         puiText,
129                                         ui32Log2PageSize,
130                                         ui32AllocationIndex, pui32AllocationIndexOut);
131
132         return eError;
133 }
134
135 IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistoryUnmapVRange(IMG_HANDLE hBridge,
136                                                             IMG_DEV_VIRTADDR sBaseDevVAddr,
137                                                             IMG_UINT32 ui32ui32StartPage,
138                                                             IMG_UINT32 ui32NumPages,
139                                                             IMG_DEVMEM_SIZE_T uiAllocSize,
140                                                             const IMG_CHAR * puiText,
141                                                             IMG_UINT32 ui32Log2PageSize,
142                                                             IMG_UINT32 ui32AllocationIndex,
143                                                             IMG_UINT32 * pui32AllocationIndexOut)
144 {
145         PVRSRV_ERROR eError;
146
147         eError =
148             DevicememHistoryUnmapVRangeKM(NULL, (PVRSRV_DEVICE_NODE *) ((void *)hBridge),
149                                           sBaseDevVAddr,
150                                           ui32ui32StartPage,
151                                           ui32NumPages,
152                                           uiAllocSize,
153                                           puiText,
154                                           ui32Log2PageSize,
155                                           ui32AllocationIndex, pui32AllocationIndexOut);
156
157         return eError;
158 }
159
160 IMG_INTERNAL PVRSRV_ERROR BridgeDevicememHistorySparseChange(IMG_HANDLE hBridge,
161                                                              IMG_HANDLE hPMR,
162                                                              IMG_DEVMEM_SIZE_T uiOffset,
163                                                              IMG_DEV_VIRTADDR sDevVAddr,
164                                                              IMG_DEVMEM_SIZE_T uiSize,
165                                                              const IMG_CHAR * puiText,
166                                                              IMG_UINT32 ui32Log2PageSize,
167                                                              IMG_UINT32 ui32AllocPageCount,
168                                                              IMG_UINT32 * pui32AllocPageIndices,
169                                                              IMG_UINT32 ui32FreePageCount,
170                                                              IMG_UINT32 * pui32FreePageIndices,
171                                                              IMG_UINT32 ui32AllocationIndex,
172                                                              IMG_UINT32 * pui32AllocationIndexOut)
173 {
174         PVRSRV_ERROR eError;
175         PMR *psPMRInt;
176         PVR_UNREFERENCED_PARAMETER(hBridge);
177
178         psPMRInt = (PMR *) hPMR;
179
180         eError =
181             DevicememHistorySparseChangeKM(psPMRInt,
182                                            uiOffset,
183                                            sDevVAddr,
184                                            uiSize,
185                                            puiText,
186                                            ui32Log2PageSize,
187                                            ui32AllocPageCount,
188                                            pui32AllocPageIndices,
189                                            ui32FreePageCount,
190                                            pui32FreePageIndices,
191                                            ui32AllocationIndex, pui32AllocationIndexOut);
192
193         return eError;
194 }