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