1 /*************************************************************************/ /*!
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
8 The contents of this file are subject to the MIT license as set out below.
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:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
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.
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.
32 This License is also included in this distribution in the file called
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 */ /**************************************************************************/
44 #ifndef _DBGDRVIF_SRV5_
45 #define _DBGDRVIF_SRV5_
48 #pragma warning(disable:4200)
51 #if defined(__linux__)
53 #define FILE_DEVICE_UNKNOWN 0
54 #define METHOD_BUFFERED 0
55 #define FILE_ANY_ACCESS 0
57 #define CTL_CODE( DeviceType, Function, Method, Access ) (Function)
58 #define MAKEIOCTLINDEX(i) ((i) & 0xFFF)
67 /*****************************************************************************
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 */
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
79 /*****************************************************************************
81 *****************************************************************************/
82 /* IOCTL values defined here so that the windows based OS layer of PDump
83 in the server can access the GetServiceTable method.
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
97 #define DEBUG_SERVICE_MAX_API 9
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
111 #error Debug driver name must be specified
113 #define DBGDRV_NT_DEVICE_NAME L"\\Device\\VLDbgDrv"
114 #define DBGDRV_NT_SYMLINK L"\\DosDevices\\VLDBGDRV"
118 /* symbolic link name */
119 #define DBGDRV_WIN32_DEVICE_NAME "\\\\.\\VLDBGDRV"
121 #define DBGDRV_WINCE_DEVICE_NAME L"DBD1:"
125 #define DBG_ALIGN(n) __attribute__ ((aligned (n)))
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
136 * ui64Ptr ensures the union is 64-bits wide in a 32-bit client.
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
144 /* native pointer type for UM to write to */
146 /* the pointer written by a 32-bit client */
148 /* force the union width */
150 } DBG_WIDEPTR DBG_ALIGN(8);
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.
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.
160 #if defined(CONFIG_COMPAT)
161 #define WIDEPTR_GET_PTR(p, bCompat) (bCompat ? \
162 (IMG_VOID *) (IMG_UINTPTR_T) (p).ui32Ptr : \
165 #define WIDEPTR_GET_PTR(p, bCompat) (p).pvPtr
168 typedef enum _DBG_EVENT_
170 DBG_EVENT_STREAM_DATA = 1
174 /*****************************************************************************
176 *****************************************************************************/
177 #if defined(__QNXNTO__)
178 typedef struct _DBG_IN_CREATESTREAM_
185 IMG_UINT32 ui32Pages;
186 IMG_UINT32 ui32CapMode;
187 IMG_UINT32 ui32OutMode;
188 }DBG_IN_CREATESTREAM, *PDBG_IN_CREATESTREAM;
190 typedef struct _DBG_OUT_CREATESTREAM_
195 } DBG_OUT_CREATESTREAM, *PDBG_OUT_CREATESTREAM;
198 typedef struct _DBG_IN_FINDSTREAM_
201 IMG_BOOL bResetStream;
202 }DBG_IN_FINDSTREAM, *PDBG_IN_FINDSTREAM;
204 #define DEBUG_READ_BUFID_MAIN 0
205 #define DEBUG_READ_BUFID_INIT 1
206 #define DEBUG_READ_BUFID_DEINIT 2
208 typedef struct _DBG_IN_READ_
210 DBG_WIDEPTR pui8OutBuffer;
212 IMG_UINT32 ui32BufID;
213 IMG_UINT32 ui32OutBufferSize;
214 } DBG_IN_READ, *PDBG_IN_READ;
216 typedef struct _DBG_OUT_READ_
218 IMG_UINT32 ui32DataRead;
219 IMG_UINT32 ui32SplitMarker;
220 } DBG_OUT_READ, *PDBG_OUT_READ;
222 typedef struct _DBG_IN_SETMARKER_
225 IMG_UINT32 ui32Marker;
226 } DBG_IN_SETMARKER, *PDBG_IN_SETMARKER;
229 DBG STREAM abstract types
232 typedef struct _DBG_STREAM_CONTROL_* PDBG_STREAM_CONTROL;
233 typedef struct _DBG_STREAM_* PDBG_STREAM;
236 Lookup identifiers for the GetState method in the KM service table.
238 #define DBG_GET_STATE_FLAG_IS_READONLY 0x03
241 /*****************************************************************************
242 Kernel mode service table
243 *****************************************************************************/
244 typedef struct _DBGKM_SERVICE_TABLE_
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;
256 #if defined(_MSC_VER)
257 #pragma warning(default:4200)
262 /*****************************************************************************
264 *****************************************************************************/