RK3368 GPU version: Rogue L 0.22
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue / generated / devicememhistory_bridge / server_devicememhistory_bridge.c
1 /*************************************************************************/ /*!
2 @File
3 @Title          Server bridge for devicememhistory
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Implements the server side of the bridge for devicememhistory
6 @License        Dual MIT/GPLv2
7
8 The contents of this file are subject to the MIT license as set out below.
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
23
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
43
44 #include <stddef.h>
45 #include <asm/uaccess.h>
46
47 #include "img_defs.h"
48
49 #include "devicemem_history_server.h"
50
51
52 #include "common_devicememhistory_bridge.h"
53
54 #include "allocmem.h"
55 #include "pvr_debug.h"
56 #include "connection_server.h"
57 #include "pvr_bridge.h"
58 #include "rgx_bridge.h"
59 #include "srvcore.h"
60 #include "handle.h"
61
62 #if defined (SUPPORT_AUTH)
63 #include "osauth.h"
64 #endif
65
66 #include <linux/slab.h>
67
68 /* ***************************************************************************
69  * Bridge proxy functions
70  */
71
72
73
74 /* ***************************************************************************
75  * Server-side bridge entry points
76  */
77  
78 static IMG_INT
79 PVRSRVBridgeDevicememHistoryMap(IMG_UINT32 ui32BridgeID,
80                                          PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYMAP *psDevicememHistoryMapIN,
81                                          PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYMAP *psDevicememHistoryMapOUT,
82                                          CONNECTION_DATA *psConnection)
83 {
84         IMG_CHAR *uiTextInt = IMG_NULL;
85
86         PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYMAP);
87
88         PVR_UNREFERENCED_PARAMETER(psConnection);
89
90
91
92         
93         {
94                 uiTextInt = OSAllocMem(DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR));
95                 if (!uiTextInt)
96                 {
97                         psDevicememHistoryMapOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
98         
99                         goto DevicememHistoryMap_exit;
100                 }
101         }
102
103                         /* Copy the data over */
104                         if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psDevicememHistoryMapIN->puiText, DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR))
105                                 || (OSCopyFromUser(NULL, uiTextInt, psDevicememHistoryMapIN->puiText,
106                                 DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) != PVRSRV_OK) )
107                         {
108                                 psDevicememHistoryMapOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
109
110                                 goto DevicememHistoryMap_exit;
111                         }
112
113         psDevicememHistoryMapOUT->eError =
114                 DevicememHistoryMapKM(
115                                         psDevicememHistoryMapIN->sDevVAddr,
116                                         psDevicememHistoryMapIN->uiSize,
117                                         uiTextInt);
118
119
120
121 DevicememHistoryMap_exit:
122         if (uiTextInt)
123                 OSFreeMem(uiTextInt);
124
125         return 0;
126 }
127
128 static IMG_INT
129 PVRSRVBridgeDevicememHistoryUnmap(IMG_UINT32 ui32BridgeID,
130                                          PVRSRV_BRIDGE_IN_DEVICEMEMHISTORYUNMAP *psDevicememHistoryUnmapIN,
131                                          PVRSRV_BRIDGE_OUT_DEVICEMEMHISTORYUNMAP *psDevicememHistoryUnmapOUT,
132                                          CONNECTION_DATA *psConnection)
133 {
134         IMG_CHAR *uiTextInt = IMG_NULL;
135
136         PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYUNMAP);
137
138         PVR_UNREFERENCED_PARAMETER(psConnection);
139
140
141
142         
143         {
144                 uiTextInt = OSAllocMem(DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR));
145                 if (!uiTextInt)
146                 {
147                         psDevicememHistoryUnmapOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY;
148         
149                         goto DevicememHistoryUnmap_exit;
150                 }
151         }
152
153                         /* Copy the data over */
154                         if ( !OSAccessOK(PVR_VERIFY_READ, (IMG_VOID*) psDevicememHistoryUnmapIN->puiText, DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR))
155                                 || (OSCopyFromUser(NULL, uiTextInt, psDevicememHistoryUnmapIN->puiText,
156                                 DEVICEMEM_HISTORY_TEXT_BUFSZ * sizeof(IMG_CHAR)) != PVRSRV_OK) )
157                         {
158                                 psDevicememHistoryUnmapOUT->eError = PVRSRV_ERROR_INVALID_PARAMS;
159
160                                 goto DevicememHistoryUnmap_exit;
161                         }
162
163         psDevicememHistoryUnmapOUT->eError =
164                 DevicememHistoryUnmapKM(
165                                         psDevicememHistoryUnmapIN->sDevVAddr,
166                                         psDevicememHistoryUnmapIN->uiSize,
167                                         uiTextInt);
168
169
170
171 DevicememHistoryUnmap_exit:
172         if (uiTextInt)
173                 OSFreeMem(uiTextInt);
174
175         return 0;
176 }
177
178
179
180 /* *************************************************************************** 
181  * Server bridge dispatch related glue 
182  */
183  
184 PVRSRV_ERROR RegisterDEVICEMEMHISTORYFunctions(IMG_VOID);
185 IMG_VOID UnregisterDEVICEMEMHISTORYFunctions(IMG_VOID);
186
187 /*
188  * Register all DEVICEMEMHISTORY functions with services
189  */
190 PVRSRV_ERROR RegisterDEVICEMEMHISTORYFunctions(IMG_VOID)
191 {
192         SetDispatchTableEntry(PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYMAP, PVRSRVBridgeDevicememHistoryMap);
193         SetDispatchTableEntry(PVRSRV_BRIDGE_DEVICEMEMHISTORY_DEVICEMEMHISTORYUNMAP, PVRSRVBridgeDevicememHistoryUnmap);
194
195         return PVRSRV_OK;
196 }
197
198 /*
199  * Unregister all devicememhistory functions with services
200  */
201 IMG_VOID UnregisterDEVICEMEMHISTORYFunctions(IMG_VOID)
202 {
203 }