]> git.proxmox.com Git - mirror_edk2.git/blob - SourceLevelDebugPkg/Include/TransferProtocol.h
This revision can only work with Intel(c) UDK Debugger Tool version 1.2 or greater...
[mirror_edk2.git] / SourceLevelDebugPkg / Include / TransferProtocol.h
1 /** @file
2 Transfer protocol defintions used by debug agent and host. It is only
3 intended to be used by Debug related module implementation.
4
5 Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __TRANSFER_PROTOCOL_H__
17 #define __TRANSFER_PROTOCOL_H__
18
19 #include "ProcessorContext.h"
20
21 //
22 // Current revision of transfer protocol
23 //
24 #define DEBUG_AGENT_REVISION ((0 << 16) | 02)
25 #define DEBUG_AGENT_CAPABILITIES 0
26
27 //
28 // Definitions for break command.
29 //
30 #define DEBUG_STARTING_SYMBOL_BREAK (0xFC)
31
32 //
33 // Definitions for attach command
34 //
35 #define DEBUG_STARTING_SYMBOL_ATTACH (0xFA)
36
37 //
38 // Definition for starting symbol of a normal debug packet. Choose a non-ASCII to avoid conflict with other serial output.
39 //
40 #define DEBUG_STARTING_SYMBOL_NORMAL (0xFE)
41
42
43 #pragma pack(1)
44
45 //
46 // Definition for debug packet header for normal debug packets (not including break/attach command)
47 //
48 typedef struct {
49 UINT8 StartSymbol;
50 UINT8 Command;
51 UINT8 Length; // Length of Debug Packet including header and payload in byte
52 UINT8 CheckSum;
53 } DEBUG_PACKET_HEADER;
54
55 //
56 // Definition for Command field for debug packets
57 //
58 #define DEBUG_COMMAND_REQUEST (0 << 7)
59 #define DEBUG_COMMAND_RESPONSE (1 << 7)
60
61 //
62 // HOST initiated commands
63 //
64 #define DEBUG_COMMAND_RESET (DEBUG_COMMAND_REQUEST | 0x00)
65 #define DEBUG_COMMAND_GO (DEBUG_COMMAND_REQUEST | 0x01)
66 #define DEBUG_COMMAND_BREAK_CAUSE (DEBUG_COMMAND_REQUEST | 0x02)
67 #define DEBUG_COMMAND_SET_HW_BREAKPOINT (DEBUG_COMMAND_REQUEST | 0x03)
68 #define DEBUG_COMMAND_CLEAR_HW_BREAKPOINT (DEBUG_COMMAND_REQUEST | 0x04)
69 #define DEBUG_COMMAND_SINGLE_STEPPING (DEBUG_COMMAND_REQUEST | 0x05)
70 #define DEBUG_COMMAND_SET_SW_BREAKPOINT (DEBUG_COMMAND_REQUEST | 0x06)
71 #define DEBUG_COMMAND_READ_MEMORY (DEBUG_COMMAND_REQUEST | 0x07)
72 #define DEBUG_COMMAND_WRITE_MEMORY (DEBUG_COMMAND_REQUEST | 0x08)
73 #define DEBUG_COMMAND_READ_IO (DEBUG_COMMAND_REQUEST | 0x09)
74 #define DEBUG_COMMAND_WRITE_IO (DEBUG_COMMAND_REQUEST | 0x0A)
75 #define DEBUG_COMMAND_READ_REGISTER (DEBUG_COMMAND_REQUEST | 0x0B)
76 #define DEBUG_COMMAND_WRITE_REGISTER (DEBUG_COMMAND_REQUEST | 0x0C)
77 #define DEBUG_COMMAND_READ_ALL_REGISTERS (DEBUG_COMMAND_REQUEST | 0x0D)
78 #define DEBUG_COMMAND_ARCH_MODE (DEBUG_COMMAND_REQUEST | 0x0E)
79 #define DEBUG_COMMAND_READ_MSR (DEBUG_COMMAND_REQUEST | 0x0F)
80 #define DEBUG_COMMAND_WRITE_MSR (DEBUG_COMMAND_REQUEST | 0x10)
81 #define DEBUG_COMMAND_SET_DEBUG_SETTING (DEBUG_COMMAND_REQUEST | 0x11)
82 #define DEBUG_COMMAND_GET_REVISION (DEBUG_COMMAND_REQUEST | 0x12)
83 #define DEBUG_COMMAND_GET_EXCEPTION (DEBUG_COMMAND_REQUEST | 0x13)
84 #define DEBUG_COMMAND_SET_VIEWPOINT (DEBUG_COMMAND_REQUEST | 0x14)
85 #define DEBUG_COMMAND_GET_VIEWPOINT (DEBUG_COMMAND_REQUEST | 0x15)
86 #define DEBUG_COMMAND_DETACH (DEBUG_COMMAND_REQUEST | 0x16)
87 #define DEBUG_COMMAND_CPUID (DEBUG_COMMAND_REQUEST | 0x17)
88 #define DEBUG_COMMAND_SEARCH_SIGNATURE (DEBUG_COMMAND_REQUEST | 0x18)
89
90 //
91 // TARGET initiated commands
92 //
93 #define DEBUG_COMMAND_INIT_BREAK (DEBUG_COMMAND_REQUEST | 0x3F)
94 #define DEBUG_COMMAND_BREAK_POINT (DEBUG_COMMAND_REQUEST | 0x3E)
95 #define DEBUG_COMMAND_MEMORY_READY (DEBUG_COMMAND_REQUEST | 0x3D)
96 #define DEBUG_COMMAND_PRINT_MESSAGE (DEBUG_COMMAND_REQUEST | 0x3C)
97
98 //
99 // Response commands
100 //
101 #define DEBUG_COMMAND_OK (DEBUG_COMMAND_RESPONSE | 0x00)
102 #define DEBUG_COMMAND_RESEND (DEBUG_COMMAND_RESPONSE | 0x01)
103 #define DEBUG_COMMAND_ABORT (DEBUG_COMMAND_RESPONSE | 0x02)
104 //
105 // The below 2 commands are used when transferring big data (like > ~250 bytes).
106 // The sequence is:
107 // HOST TARGET
108 // Request =>
109 // <= IN_PROGRESS with partial data
110 // CONTINUE =>
111 // (could have multiple IN_PROGRESS and CONTINUE interactions)
112 // <= OK with the last part of data
113 // OK (no data as ACK) =>
114 //
115 #define DEBUG_COMMAND_IN_PROGRESS (DEBUG_COMMAND_RESPONSE | 0x03)
116 #define DEBUG_COMMAND_CONTINUE (DEBUG_COMMAND_RESPONSE | 0x04)
117 //
118 // The below 2 commands are used to support deferred halt:
119 // TARGET returns HALT_DEFERRED when it receives a HALT request in inter-active mode.
120 // TARGET returns HALT_PROCESSED when it receives a GO request and has a pending HALT request.
121 //
122 #define DEBUG_COMMAND_HALT_DEFERRED (DEBUG_COMMAND_RESPONSE | 0x05)
123 #define DEBUG_COMMAND_HALT_PROCESSED (DEBUG_COMMAND_RESPONSE | 0x06)
124
125 #define DEBUG_COMMAND_TIMEOUT (DEBUG_COMMAND_RESPONSE | 0x07)
126 #define DEBUG_COMMAND_NOT_SUPPORTED (DEBUG_COMMAND_RESPONSE | 0x0F)
127
128 //
129 // Definition for data field for debug packets
130 //
131 #define DEBUG_DATA_UPPER_LIMIT 0xff // Upper limit for the data size, by the limit of the packet header definition.
132
133 #define DEBUG_DATA_MAXIMUM_REAL_DATA (DEBUG_DATA_UPPER_LIMIT - sizeof (DEBUG_PACKET_HEADER))
134
135 //
136 // Response data for DEBUG_COMMAND_BREAK_CAUSE
137 //
138 typedef struct {
139 UINT8 Cause;
140 UINT64 StopAddress;
141 } DEBUG_DATA_RESPONSE_BREAK_CAUSE;
142 //
143 // Break type defintions for DEBUG_DATA_BREAK_CAUSE
144 //
145 #define DEBUG_DATA_BREAK_CAUSE_UNKNOWN 0
146 #define DEBUG_DATA_BREAK_CAUSE_HW_BREAKPOINT 1
147 #define DEBUG_DATA_BREAK_CAUSE_STEPPING 2
148 #define DEBUG_DATA_BREAK_CAUSE_SW_BREAKPOINT 3
149 #define DEBUG_DATA_BREAK_CAUSE_USER_HALT 4
150 #define DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD 5
151 #define DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD 6
152 #define DEBUG_DATA_BREAK_CAUSE_SYSTEM_RESET 7
153 #define DEBUG_DATA_BREAK_CAUSE_EXCEPTION 8
154 #define DEBUG_DATA_BREAK_CAUSE_MEMORY_READY 9
155
156 //
157 // Response data for DEBUG_COMMAND_ARCH_MODE, defined as SOFT_DEBUGGER_PROCESSOR_...
158 //
159 typedef struct {
160 UINT8 CpuMode;
161 } DEBUG_DATA_RESPONSE_ARCH_MODE;
162 //
163 // Cpu architecture defintions for DEBUG_DATA_RESPONSE_ARCH_MODE
164 //
165 #define DEBUG_DATA_BREAK_CPU_ARCH_IA16 0
166 #define DEBUG_DATA_BREAK_CPU_ARCH_IA32 1
167 #define DEBUG_DATA_BREAK_CPU_ARCH_X64 2
168
169 typedef struct {
170 UINT8 Length:2; // Refer to below DEBUG_DATA_BREAKPOINT_LENGTH_XX macros
171 UINT8 Access:2; // Refer to below DEBUG_DATA_BREAKPOINT_ACCESS_XX macros
172 UINT8 Index:2; // Index of debug register
173 UINT8 Reserved:2;
174 } DEBUG_DATA_BREAKPOINT_TYPE;
175 #define DEBUG_DATA_BREAKPOINT_MEMORY_ACCESS (0x3)
176 #define DEBUG_DATA_BREAKPOINT_IO_ACCESS (0x2)
177 #define DEBUG_DATA_BREAKPOINT_MEMORY_WRITE (0x1)
178 #define DEBUG_DATA_BREAKPOINT_MEMORY_EXECUTE (0x0)
179 #define DEBUG_DATA_BREAKPOINT_LENGTH_32 (0x3)
180 #define DEBUG_DATA_BREAKPOINT_LENGTH_64 (0x2)
181 #define DEBUG_DATA_BREAKPOINT_LENGTH_16 (0x1)
182 #define DEBUG_DATA_BREAKPOINT_LENGTH_8 (0x0)
183
184 //
185 // Request data for DEBUG_COMMAND_SET_HW_BREAKPOINT
186 //
187 typedef struct {
188 DEBUG_DATA_BREAKPOINT_TYPE Type;
189 UINT64 Address;
190 } DEBUG_DATA_SET_HW_BREAKPOINT;
191
192 //
193 // Request data for DEBUG_COMMAND_CLEAR_HW_BREAKPOINT
194 //
195 typedef struct {
196 UINT8 IndexMask; // 0x0f will clear all hw breakpoints
197 } DEBUG_DATA_CLEAR_HW_BREAKPOINT;
198
199 //
200 // Request and response data for DEBUG_COMMAND_SET_SW_BREAKPOINT
201 //
202 typedef struct {
203 UINT64 Address;
204 } DEBUG_DATA_SET_SW_BREAKPOINT;
205
206 typedef struct {
207 UINT8 OriginalData;
208 } DEBUG_DATA_RESPONSE_SET_SW_BREAKPOINT;
209
210 //
211 // Request data for DEBUG_COMMAND_READ_MEMORY
212 //
213 typedef struct {
214 UINT64 Address;
215 UINT8 Width;
216 UINT16 Count;
217 } DEBUG_DATA_READ_MEMORY;
218
219 //
220 // Request data for DEBUG_COMMAND_WRITE_MEMORY
221 //
222 typedef struct {
223 UINT64 Address;
224 UINT8 Width;
225 UINT16 Count;
226 UINT8 Data[1]; // The actual length is (Width * Count)
227 } DEBUG_DATA_WRITE_MEMORY;
228
229 //
230 // Request and response data for DEBUG_COMMAND_READ_IO
231 //
232 typedef struct {
233 UINT64 Port;
234 UINT8 Width;
235 } DEBUG_DATA_READ_IO;
236
237 typedef struct {
238 UINT8 Data[1]; // The actual length depends on the packet header
239 } DEBUG_DATA_RESPONSE_READ_IO;
240
241 //
242 // Request data for DEBUG_COMMAND_WRITE_IO
243 //
244 typedef struct {
245 UINT64 Port;
246 UINT8 Width;
247 UINT8 Data[1]; // The actual length is Width
248 } DEBUG_DATA_WRITE_IO;
249
250 //
251 // Request data for DEBUG_COMMAND_READ_REGISTER
252 //
253 typedef struct {
254 UINT8 Index; // defined as SOFT_DEBUGGER_REGISTER_XX
255 } DEBUG_DATA_READ_REGISTER;
256
257 //
258 // Request data for DEBUG_COMMAND_WRITE_REGISTER
259 //
260 typedef struct {
261 UINT8 Index; // defined as SOFT_DEBUGGER_REGISTER_XX
262 UINT8 Length;
263 UINT8 Data[1]; // The actual length is Length
264 } DEBUG_DATA_WRITE_REGISTER;
265
266 //
267 // Request and response data for DEBUG_COMMAND_READ_MSR
268 //
269 typedef struct {
270 UINT32 Index;
271 } DEBUG_DATA_READ_MSR;
272
273 typedef struct {
274 UINT64 Value;
275 } DEBUG_DATA_RESPONSE_READ_MSR;
276
277 //
278 // Request data for DEBUG_COMMAND_WRITE_MSR
279 //
280 typedef struct {
281 UINT32 Index;
282 UINT64 Value;
283 } DEBUG_DATA_WRITE_MSR;
284
285 //
286 // Response data for DEBUG_COMMAND_GET_REVISION
287 //
288 typedef struct {
289 UINT32 Revision;
290 UINT32 Capabilities;
291 } DEBUG_DATA_RESPONSE_GET_REVISION;
292
293 //
294 // Response data for DEBUG_COMMAND_GET_EXCEPTION
295 //
296 typedef struct {
297 UINT8 ExceptionNum;
298 UINT32 ExceptionData;
299 } DEBUG_DATA_RESPONSE_GET_EXCEPTION;
300
301 //
302 // Request data for DEBUG_DATA_SET_DEBUG_SETTING
303 //
304 typedef struct {
305 UINT8 Key;
306 UINT8 Value;
307 } DEBUG_DATA_SET_DEBUG_SETTING;
308 //
309 // Supported keys
310 //
311 #define DEBUG_AGENT_SETTING_SMM_ENTRY_BREAK 1
312 #define DEBUG_AGENT_SETTING_PRINT_ERROR_LEVEL 2
313 //
314 // Bitmask of print error level for debug message
315 //
316 #define DEBUG_AGENT_ERROR BIT0
317 #define DEBUG_AGENT_WARNING BIT1
318 #define DEBUG_AGENT_INFO BIT2
319 #define DEBUG_AGENT_VERBOSE BIT3
320
321 //
322 // Request data for DEBUG_COMMAND_SET_VIEWPOINT
323 //
324 typedef struct {
325 UINT32 ViewPoint; // The index of viewpoint will be set
326 } DEBUG_DATA_SET_VIEWPOINT;
327
328 //
329 // Response data for DEBUG_COMMAND_GET_VIEWPOINT
330 //
331 typedef struct {
332 UINT32 ViewPoint; // The index of viewpoint will be returned
333 } DEBUG_DATA_RESPONSE_GET_VIEWPOINT;
334
335 //
336 // Request and response data for DEBUG_COMMAND_CPUID
337 //
338 typedef struct {
339 UINT32 Eax; // The value of EAX prior to invoking the CPUID instruction
340 UINT32 Ecx; // The value of ECX prior to invoking the CPUID instruction
341 } DEBUG_DATA_CPUID;
342
343 typedef struct {
344 UINT32 Eax; // The value of EAX returned by the CPUID instruction
345 UINT32 Ebx; // The value of EBX returned by the CPUID instruction
346 UINT32 Ecx; // The value of ECX returned by the CPUID instruction
347 UINT32 Edx; // The value of EDX returned by the CPUID instruction
348 } DEBUG_DATA_RESPONSE_CPUID;
349
350 //
351 // Request and response data for DEBUG_COMMAND_SEARCH_SIGNATURE
352 //
353 typedef struct {
354 UINT64 Start;
355 UINT32 Count;
356 UINT32 Alignment;
357 BOOLEAN Positive; // TRUE to search in higher address memory
358 UINT8 DataLength;
359 UINT8 Data[1];
360 } DEBUG_DATA_SEARCH_SIGNATURE;
361
362 typedef struct {
363 UINT64 Address; // -1 indicates not found
364 } DEBUG_DATA_RESPONSE_SEARCH_SIGNATURE;
365
366 #pragma pack()
367
368 #endif
369