]> git.proxmox.com Git - mirror_edk2.git/blame - SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h
Fix infinite loop bug in secure boot UI driver.
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugAgent / DebugAgentCommon / DebugAgent.h
CommitLineData
18b144ea 1/** @file\r
2 Command header of for Debug Agent library instance.\r
3\r
b4ebbaff 4 Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
18b144ea 5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php.\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _DEBUG_AGENT_H_\r
16#define _DEBUG_AGENT_H_\r
17\r
18#include <Register/LocalApic.h>\r
19\r
20#include <Guid/DebugAgentGuid.h>\r
21\r
22#include <Library/BaseLib.h>\r
23#include <Library/BaseMemoryLib.h>\r
24#include <Library/ResetSystemLib.h>\r
25#include <Library/IoLib.h>\r
26#include <Library/HobLib.h>\r
27#include <Library/DebugCommunicationLib.h>\r
28#include <Library/DebugAgentLib.h>\r
29#include <Library/PcdLib.h>\r
30#include <Library/SynchronizationLib.h>\r
31#include <Library/LocalApicLib.h>\r
e2104834 32#include <Library/DebugLib.h>\r
b4ebbaff 33#include <Library/TimerLib.h>\r
93c0bdec 34#include <Library/PrintLib.h>\r
18b144ea 35\r
36#include <TransferProtocol.h>\r
37#include <ImageDebugSupport.h>\r
38\r
39#include "DebugMp.h"\r
40#include "DebugTimer.h"\r
41#include "ArchDebugSupport.h"\r
42\r
18b144ea 43#define DEBUG_INT1_VECTOR 1\r
44#define DEBUG_INT3_VECTOR 3\r
45#define DEBUG_TIMER_VECTOR 32\r
46#define DEBUG_MAILBOX_VECTOR 33\r
47\r
48#define SOFT_INTERRUPT_SIGNATURE SIGNATURE_32('S','O','F','T')\r
49#define SYSTEM_RESET_SIGNATURE SIGNATURE_32('S','Y','S','R')\r
50#define MEMORY_READY_SIGNATURE SIGNATURE_32('M','E','M','R')\r
51\r
52extern UINTN Exception0Handle;\r
53extern UINTN TimerInterruptHandle;\r
54extern UINT16 ExceptionStubHeaderSize;\r
55\r
93c0bdec 56//\r
57// CPU exception information issued by debug agent\r
58//\r
59typedef struct {\r
60 //\r
61 // This field is used to save CPU content before executing HOST command\r
62 //\r
63 BASE_LIBRARY_JUMP_BUFFER JumpBuffer;\r
64 //\r
65 // This filed returens the exception information issued by HOST command\r
66 //\r
67 DEBUG_DATA_RESPONSE_GET_EXCEPTION ExceptionContent;\r
68} DEBUG_AGENT_EXCEPTION_BUFFER;\r
18b144ea 69\r
70#pragma pack(1)\r
93c0bdec 71typedef struct {\r
72 //\r
73 // Lower 32 bits to store the status of DebugAgent\r
74 //\r
75 UINT32 HostAttached : 1; // 1: HOST is attached\r
76 UINT32 AgentInProgress : 1; // 1: Debug Agent is communicating with HOST\r
77 UINT32 MemoryReady : 1; // 1: Memory is ready\r
78 UINT32 SteppingFlag : 1; // 1: Agent is running stepping command\r
79 UINT32 Reserved1 : 28;\r
80\r
81 //\r
82 // Higher 32bits to control the behavior of DebugAgent\r
83 //\r
84 UINT32 BreakOnNextSmi : 1; // 1: Break on next SMI\r
85 UINT32 PrintErrorLevel : 8; // Bitmask of print error level for debug message\r
86 UINT32 Reserved2 : 23;\r
87} DEBUG_AGENT_FLAG;\r
88\r
18b144ea 89typedef struct {\r
90 DEBUG_AGENT_FLAG DebugFlag;\r
91 UINT64 DebugPortHandle;\r
93c0bdec 92 //\r
93 // Pointer to DEBUG_AGENT_EXCEPTION_BUFFER\r
94 //\r
95 UINT64 ExceptionBufferPointer;\r
18b144ea 96} DEBUG_AGENT_MAILBOX;\r
97#pragma pack()\r
98\r
99typedef union {\r
100 struct {\r
101 UINT32 LimitLow : 16;\r
102 UINT32 BaseLow : 16;\r
103 UINT32 BaseMid : 8;\r
104 UINT32 Type : 4;\r
105 UINT32 System : 1;\r
106 UINT32 Dpl : 2;\r
107 UINT32 Present : 1;\r
108 UINT32 LimitHigh : 4;\r
109 UINT32 Software : 1;\r
110 UINT32 Reserved : 1;\r
111 UINT32 DefaultSize : 1;\r
112 UINT32 Granularity : 1;\r
113 UINT32 BaseHigh : 8;\r
114 } Bits;\r
115 UINT64 Uint64;\r
116} IA32_GDT;\r
117\r
118/**\r
119 Caller provided function to be invoked at the end of DebugPortInitialize().\r
120\r
121 Refer to the descrption for DebugPortInitialize() for more details.\r
122\r
123 @param[in] Context The first input argument of DebugPortInitialize().\r
124 @param[in] DebugPortHandle Debug port handle created by Debug Communication Libary.\r
125\r
126**/\r
127VOID\r
128EFIAPI\r
129InitializeDebugAgentPhase2 (\r
130 IN VOID *Context,\r
131 IN DEBUG_PORT_HANDLE DebugPortHandle\r
132 );\r
133\r
134/**\r
135 Initialize IDT entries to support source level debug.\r
136\r
137**/\r
138VOID\r
139InitializeDebugIdt (\r
140 VOID\r
141 );\r
142\r
18b144ea 143/**\r
144 Read register value from saved CPU context.\r
145\r
146 @param[in] CpuContext Pointer to saved CPU context.\r
147 @param[in] Index Register index value.\r
18b144ea 148 @param[in] Width Data width to read.\r
149\r
150 @return The address of register value.\r
151\r
152**/\r
153UINT8 *\r
154ArchReadRegisterBuffer (\r
155 IN DEBUG_CPU_CONTEXT *CpuContext,\r
156 IN UINT8 Index,\r
18b144ea 157 IN UINT8 *Width\r
158 );\r
159\r
160/**\r
161 Send packet with response data to HOST.\r
162\r
18b144ea 163 @param[in] Data Pointer to response data buffer.\r
164 @param[in] DataSize Size of response data in byte.\r
165\r
166 @retval RETURN_SUCCESS Response data was sent successfully.\r
167 @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.\r
168\r
169**/\r
170RETURN_STATUS\r
171SendDataResponsePacket (\r
18b144ea 172 IN UINT8 *Data,\r
173 IN UINT16 DataSize\r
174 );\r
175\r
176/**\r
93c0bdec 177 Check if HOST is attached based on Mailbox.\r
18b144ea 178\r
93c0bdec 179 @retval TRUE HOST is attached.\r
180 @retval FALSE HOST is not attached.\r
18b144ea 181\r
182**/\r
93c0bdec 183BOOLEAN\r
184IsHostAttached (\r
185 VOID\r
18b144ea 186 );\r
187\r
188/**\r
93c0bdec 189 Get Debug Agent Mailbox pointer.\r
18b144ea 190\r
93c0bdec 191 @return Mailbox pointer.\r
18b144ea 192\r
193**/\r
93c0bdec 194DEBUG_AGENT_MAILBOX *\r
195GetMailboxPointer (\r
196 VOID\r
18b144ea 197 );\r
198\r
199/**\r
93c0bdec 200 Get debug port handle.\r
18b144ea 201\r
93c0bdec 202 @return Debug port handle.\r
18b144ea 203\r
204**/\r
93c0bdec 205DEBUG_PORT_HANDLE\r
206GetDebugPortHandle (\r
207 VOID\r
18b144ea 208 );\r
209\r
210/**\r
93c0bdec 211 Read the Attach/Break-in symbols from the debug port.\r
18b144ea 212\r
93c0bdec 213 @param[in] Handle Pointer to Debug Port handle.\r
214 @param[out] BreakSymbol Returned break symbol.\r
18b144ea 215\r
93c0bdec 216 @retval EFI_SUCCESS Read the symbol in BreakSymbol.\r
217 @retval EFI_NOT_FOUND No read the break symbol.\r
18b144ea 218\r
219**/\r
93c0bdec 220EFI_STATUS\r
221DebugReadBreakSymbol (\r
222 IN DEBUG_PORT_HANDLE Handle,\r
223 OUT UINT8 *BreakSymbol\r
18b144ea 224 );\r
225\r
226/**\r
93c0bdec 227 Prints a debug message to the debug port if the specified error level is enabled.\r
18b144ea 228\r
93c0bdec 229 If any bit in ErrorLevel is also set in Mainbox, then print the message specified\r
230 by Format and the associated variable argument list to the debug port.\r
18b144ea 231\r
93c0bdec 232 @param[in] ErrorLevel The error level of the debug message.\r
233 @param[in] Format Format string for the debug message to print.\r
234 @param[in] ... Variable argument list whose contents are accessed \r
235 based on the format string specified by Format.\r
18b144ea 236\r
237**/\r
93c0bdec 238VOID\r
239EFIAPI\r
240DebugAgentMsgPrint (\r
241 IN UINT8 ErrorLevel,\r
242 IN CHAR8 *Format,\r
243 ...\r
18b144ea 244 );\r
18b144ea 245#endif\r
246\r