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