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