RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / include / dbgdrvif_srv5.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          Debug driver for Services 5
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Debug Driver Interface
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 #ifndef _DBGDRVIF_SRV5_
45 #define _DBGDRVIF_SRV5_
46
47 #if defined(_MSC_VER) 
48 #pragma  warning(disable:4200)
49 #endif
50
51 #if defined(__linux__)
52
53 #define FILE_DEVICE_UNKNOWN             0
54 #define METHOD_BUFFERED                 0
55 #define FILE_ANY_ACCESS                 0
56
57 #define CTL_CODE( DeviceType, Function, Method, Access ) (Function) 
58 #define MAKEIOCTLINDEX(i)       ((i) & 0xFFF)
59
60 #else
61
62 #include "ioctldef.h"
63
64 #endif
65
66
67 /*****************************************************************************
68  Stream mode stuff.
69 *****************************************************************************/
70 #define DEBUG_CAPMODE_FRAMED                    0x00000001UL /* Default capture mode, set when streams created */
71 #define DEBUG_CAPMODE_CONTINUOUS                0x00000002UL /* Only set in WDDM, streams created with it set to this mode */
72
73 #define DEBUG_FLAGS_USE_NONPAGED_MEM    0x00000001UL /* Only set in WDDM */
74 #define DEBUG_FLAGS_NO_BUF_EXPANDSION   0x00000002UL
75 #define DEBUG_FLAGS_READONLY                    0x00000008UL
76 #define DEBUG_FLAGS_WRITEONLY                   0x00000010UL
77 #define DEBUG_FLAGS_CIRCULAR                    0x00000020UL
78
79 /*****************************************************************************
80  IOCTL values.
81 *****************************************************************************/
82 /* IOCTL values defined here so that the windows based OS layer of PDump
83    in the server can access the GetServiceTable method.
84  */
85 #define DEBUG_SERVICE_IOCTL_BASE                0x800UL
86 #define DEBUG_SERVICE_GETSERVICETABLE   CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x01, METHOD_BUFFERED, FILE_ANY_ACCESS)
87 #define DEBUG_SERVICE_GETSTREAM                 CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x02, METHOD_BUFFERED, FILE_ANY_ACCESS)
88 #define DEBUG_SERVICE_READ                              CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x03, METHOD_BUFFERED, FILE_ANY_ACCESS)
89 #define DEBUG_SERVICE_SETMARKER                 CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x04, METHOD_BUFFERED, FILE_ANY_ACCESS)
90 #define DEBUG_SERVICE_GETMARKER                 CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x05, METHOD_BUFFERED, FILE_ANY_ACCESS)
91 #define DEBUG_SERVICE_WAITFOREVENT              CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x06, METHOD_BUFFERED, FILE_ANY_ACCESS)
92 #define DEBUG_SERVICE_GETFRAME                  CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x07, METHOD_BUFFERED, FILE_ANY_ACCESS)
93 #if defined(__QNXNTO__)
94 #define DEBUG_SERVICE_CREATESTREAM              CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x08, METHOD_BUFFERED, FILE_ANY_ACCESS)
95 #define DEBUG_SERVICE_MAX_API                   8
96 #else
97 #define DEBUG_SERVICE_MAX_API                   9
98 #endif
99
100
101 #if defined(_WIN32)
102 /*****************************************************************************
103  Debug driver device name
104 *****************************************************************************/
105 #if defined (DBGDRV_MODULE_NAME)
106 #define REGISTRY_PATH_TO_DEBUG_DRIVER \
107         L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" DBGDRV_MODULE_NAME
108 #define DBGDRV_NT_DEVICE_NAME                           L"\\Device\\" DBGDRV_MODULE_NAME
109 #define DBGDRV_NT_SYMLINK                                       L"\\DosDevices\\" DBGDRV_MODULE_NAME
110 #else
111 #error Debug driver name must be specified
112 /*
113 #define DBGDRV_NT_DEVICE_NAME                           L"\\Device\\VLDbgDrv"
114 #define DBGDRV_NT_SYMLINK                                       L"\\DosDevices\\VLDBGDRV"
115 */
116 #endif
117
118 /* symbolic link name */
119 #define DBGDRV_WIN32_DEVICE_NAME                        "\\\\.\\VLDBGDRV"
120
121 #define DBGDRV_WINCE_DEVICE_NAME                        L"DBD1:"
122 #endif
123
124 #ifdef __GNUC__
125 #define DBG_ALIGN(n) __attribute__ ((aligned (n)))
126 #else
127 #define DBG_ALIGN(n)
128 #endif
129
130 /* A pointer type which is at least 64 bits wide. The fixed width ensures
131  * consistency in structures between 32 and 64-bit code.
132  * The UM code (be it 32 or 64 bit) can simply write to the native pointer type (pvPtr).
133  * 64-bit KM code must read ui32Ptr if in the case of a 32-bit client, otherwise it can
134  * just read pvPtr if the client is also 64-bit
135  *
136  * ui64Ptr ensures the union is 64-bits wide in a 32-bit client.
137  *
138  * The union is explicitly 64-bit aligned as it was found gcc on x32 only
139  * aligns it to 32-bit, as the ABI permits aligning 64-bit types to a 32-bit
140  * boundary.
141  */
142 typedef union
143 {
144         /* native pointer type for UM to write to */
145         IMG_VOID *pvPtr;
146         /* the pointer written by a 32-bit client */
147         IMG_UINT32 ui32Ptr;
148         /* force the union width */
149         IMG_UINT64 ui64Ptr;
150 } DBG_WIDEPTR DBG_ALIGN(8);
151
152 /* Helper macro for dbgdriv (KM) to get the pointer value from the WIDEPTR type,
153  * depending on whether the client is 32 or 64-bit.
154  *
155  * note: double cast is required to avoid
156  * 'cast to pointer from integer of different size' warning.
157  * this is solved by first casting to an integer type.
158  */
159
160 #if defined(CONFIG_COMPAT)
161 #define WIDEPTR_GET_PTR(p, bCompat) (bCompat ? \
162                                         (IMG_VOID *) (IMG_UINTPTR_T) (p).ui32Ptr : \
163                                         (p).pvPtr)
164 #else
165 #define WIDEPTR_GET_PTR(p, bCompat) (p).pvPtr
166 #endif
167
168 typedef enum _DBG_EVENT_
169 {
170         DBG_EVENT_STREAM_DATA = 1
171 } DBG_EVENT;
172
173
174 /*****************************************************************************
175  In/Out Structures
176 *****************************************************************************/
177 #if defined(__QNXNTO__)
178 typedef struct _DBG_IN_CREATESTREAM_
179 {
180         union
181         {
182                 IMG_CHAR *pszName;
183                 IMG_UINT64 ui64Name;
184         } u;
185         IMG_UINT32 ui32Pages;
186         IMG_UINT32 ui32CapMode;
187         IMG_UINT32 ui32OutMode;
188 }DBG_IN_CREATESTREAM, *PDBG_IN_CREATESTREAM;
189
190 typedef struct _DBG_OUT_CREATESTREAM_
191 {
192         IMG_HANDLE phInit;
193         IMG_HANDLE phMain;
194         IMG_HANDLE phDeinit;
195 } DBG_OUT_CREATESTREAM, *PDBG_OUT_CREATESTREAM;
196 #endif
197
198 typedef struct _DBG_IN_FINDSTREAM_
199 {
200         DBG_WIDEPTR pszName;
201         IMG_BOOL bResetStream;
202 }DBG_IN_FINDSTREAM, *PDBG_IN_FINDSTREAM;
203
204 #define DEBUG_READ_BUFID_MAIN                   0
205 #define DEBUG_READ_BUFID_INIT                   1
206 #define DEBUG_READ_BUFID_DEINIT                 2
207
208 typedef struct _DBG_IN_READ_
209 {
210         DBG_WIDEPTR pui8OutBuffer;
211         IMG_SID hStream;
212         IMG_UINT32 ui32BufID;
213         IMG_UINT32 ui32OutBufferSize;
214 } DBG_IN_READ, *PDBG_IN_READ;
215
216 typedef struct _DBG_OUT_READ_
217 {
218         IMG_UINT32 ui32DataRead;
219         IMG_UINT32 ui32SplitMarker;
220 } DBG_OUT_READ, *PDBG_OUT_READ;
221
222 typedef struct _DBG_IN_SETMARKER_
223 {
224         IMG_SID hStream;
225         IMG_UINT32 ui32Marker;
226 } DBG_IN_SETMARKER, *PDBG_IN_SETMARKER;
227
228 /*
229         DBG STREAM abstract types
230 */
231
232 typedef struct _DBG_STREAM_CONTROL_* PDBG_STREAM_CONTROL;
233 typedef struct _DBG_STREAM_* PDBG_STREAM;
234
235 /*
236         Lookup identifiers for the GetState method in the KM service table.
237  */
238 #define DBG_GET_STATE_FLAG_IS_READONLY    0x03
239
240
241 /*****************************************************************************
242  Kernel mode service table
243 *****************************************************************************/
244 typedef struct _DBGKM_SERVICE_TABLE_
245 {
246         IMG_UINT32 ui32Size;
247         IMG_BOOL        (IMG_CALLCONV *pfnCreateStream)                 (IMG_CHAR * pszName,IMG_UINT32 ui32Flags,IMG_UINT32 ui32Pages, IMG_HANDLE* phInit, IMG_HANDLE* phMain, IMG_HANDLE* phDeinit);
248         IMG_VOID        (IMG_CALLCONV *pfnDestroyStream)                (IMG_HANDLE hInit, IMG_HANDLE hMain, IMG_HANDLE hDeinit);
249         IMG_UINT32      (IMG_CALLCONV *pfnDBGDrivWrite2)                (PDBG_STREAM psStream, IMG_UINT8 *pui8InBuf,IMG_UINT32 ui32InBuffSize);
250         IMG_VOID        (IMG_CALLCONV *pfnSetMarker)                    (PDBG_STREAM psStream, IMG_UINT32 ui32Marker);
251         IMG_VOID        (IMG_CALLCONV *pfnWaitForEvent)                 (DBG_EVENT eEvent);
252         IMG_UINT32  (IMG_CALLCONV *pfnGetCtrlState)                     (PDBG_STREAM psStream, IMG_UINT32 ui32StateID);
253         IMG_VOID        (IMG_CALLCONV *pfnSetFrame)                             (IMG_UINT32 ui32Frame);
254 } DBGKM_SERVICE_TABLE, *PDBGKM_SERVICE_TABLE;
255
256 #if defined(_MSC_VER) 
257 #pragma  warning(default:4200)
258 #endif
259
260 #endif
261
262 /*****************************************************************************
263  End of file
264 *****************************************************************************/