]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/DebugSupportDxe/Ia32/PlDebugSupport.h
ECC clean up.
[mirror_edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / Ia32 / PlDebugSupport.h
... / ...
CommitLineData
1/** @file\r
2 IA32 specific debug support macros, typedefs and prototypes.\r
3\r
4Copyright (c) 2006 - 2008, Intel Corporation \r
5All rights reserved. This program and the accompanying materials \r
6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13**/\r
14\r
15#ifndef _PLDEBUG_SUPPORT_H_\r
16#define _PLDEBUG_SUPPORT_H_\r
17\r
18\r
19#include <Uefi.h>\r
20\r
21#include <Protocol/DebugSupport.h>\r
22#include <Protocol/LoadedImage.h>\r
23\r
24#include <Library/DebugLib.h>\r
25#include <Library/UefiDriverEntryPoint.h>\r
26#include <Library/BaseMemoryLib.h>\r
27#include <Library/MemoryAllocationLib.h>\r
28#include <Library/UefiBootServicesTableLib.h>\r
29#include <Library/BaseLib.h>\r
30#include <Library/PcdLib.h>\r
31\r
32#define NUM_IDT_ENTRIES 0x78\r
33#define SYSTEM_TIMER_VECTOR 0x68\r
34#define VECTOR_ENTRY_PAGES 1\r
35#define COPY_DESCRIPTOR(Dest, Src) CopyMem ((Dest), (Src), sizeof (DESCRIPTOR))\r
36#define READ_IDT(Vector, Dest) COPY_DESCRIPTOR ((Dest), &((GetIdtr ())[(Vector)]))\r
37#define WRITE_IDT(Vector, Src) COPY_DESCRIPTOR (&((GetIdtr ())[(Vector)]), (Src))\r
38#define COMPARE_DESCRIPTOR(Desc1, Desc2) CompareMem ((Desc1), (Desc2), sizeof (DESCRIPTOR))\r
39#define EFI_ISA IsaIa32\r
40#define FF_FXSR (1 << 24)\r
41\r
42typedef UINT64 DESCRIPTOR;\r
43\r
44typedef\r
45VOID\r
46(*DEBUG_PROC) (\r
47 VOID\r
48 );\r
49\r
50typedef struct {\r
51 DESCRIPTOR OrigDesc;\r
52 DEBUG_PROC OrigVector;\r
53 DESCRIPTOR NewDesc;\r
54 DEBUG_PROC StubEntry;\r
55 VOID (*RegisteredCallback) ();\r
56} IDT_ENTRY;\r
57\r
58extern EFI_SYSTEM_CONTEXT SystemContext;\r
59extern UINT8 InterruptEntryStub[];\r
60extern UINT32 StubSize;\r
61extern VOID (*OrigVector) (VOID);\r
62\r
63/**\r
64 Generic IDT entry.\r
65\r
66**/\r
67VOID\r
68CommonIdtEntry (\r
69 VOID\r
70 );\r
71\r
72/**\r
73 Check whether FXSTOR is supported\r
74\r
75 @retval TRUE FXSTOR is supported.\r
76 @retval FALSE FXSTOR is not supported.\r
77\r
78**/\r
79BOOLEAN\r
80FxStorSupport (\r
81 VOID\r
82 );\r
83\r
84/**\r
85 Return the physical address of IDTR.\r
86\r
87 @return The physical address of IDTR.\r
88\r
89**/\r
90DESCRIPTOR *\r
91GetIdtr (\r
92 VOID\r
93 );\r
94\r
95/**\r
96 Encodes an IDT descriptor with the given physical address.\r
97\r
98 @param DestDesc The IDT descriptor address.\r
99 @param Vecotr The interrupt vector entry.\r
100\r
101**/\r
102VOID\r
103Vect2Desc (\r
104 DESCRIPTOR * DestDesc,\r
105 VOID (*Vector) (VOID)\r
106 );\r
107\r
108/**\r
109 Programs interrupt flag to the requested state and returns previous\r
110 state.\r
111\r
112 @param NewState New interrupt status.\r
113\r
114 @retval TRUE Old interrupt status is TRUE.\r
115 @retval FALSE Old interrupt status is FALSE\r
116\r
117**/\r
118BOOLEAN\r
119WriteInterruptFlag (\r
120 BOOLEAN NewState\r
121 );\r
122\r
123/**\r
124 Initializes driver's handler registration databas. \r
125 \r
126 This code executes in boot services context\r
127 Must be public because it's referenced from DebugSupport.c\r
128\r
129 @retval EFI_UNSUPPORTED If IA32 processor does not support FXSTOR/FXRSTOR instructions,\r
130 the context save will fail, so these processor's are not supported.\r
131 @retval EFI_OUT_OF_RESOURCES Fails to allocate memory.\r
132 @retval EFI_SUCCESS Initializes successfully.\r
133\r
134**/\r
135EFI_STATUS\r
136PlInitializeDebugSupportDriver (\r
137 VOID\r
138 );\r
139\r
140/**\r
141 This is the callback that is written to the LoadedImage protocol instance\r
142 on the image handle. It uninstalls all registered handlers and frees all entry\r
143 stub memory.\r
144\r
145 @param ImageHandle The firmware allocated handle for the EFI image.\r
146\r
147 @retval EFI_SUCCESS Always.\r
148\r
149**/\r
150EFI_STATUS\r
151EFIAPI\r
152PlUnloadDebugSupportDriver (\r
153 IN EFI_HANDLE ImageHandle\r
154 );\r
155\r
156/**\r
157 This is a DebugSupport protocol member function, hard\r
158 coded to support only 1 processor for now.\r
159\r
160 @param This The DebugSupport instance\r
161 @param MaxProcessorIndex The maximuim supported processor index\r
162\r
163 @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.\r
164\r
165**/\r
166EFI_STATUS\r
167EFIAPI\r
168GetMaximumProcessorIndex (\r
169 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
170 OUT UINTN *MaxProcessorIndex\r
171 );\r
172\r
173/**\r
174 DebugSupport protocol member function.\r
175\r
176 @param This The DebugSupport instance\r
177 @param ProcessorIndex Which processor the callback applies to.\r
178 @param PeriodicCallback Callback function\r
179\r
180 @retval EFI_SUCCESS Indicates the callback was registered.\r
181 @retval others Callback was not registered.\r
182\r
183**/\r
184EFI_STATUS\r
185EFIAPI\r
186RegisterPeriodicCallback (\r
187 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
188 IN UINTN ProcessorIndex,\r
189 IN EFI_PERIODIC_CALLBACK PeriodicCallback\r
190 );\r
191\r
192/**\r
193 DebugSupport protocol member function.\r
194\r
195 This code executes in boot services context.\r
196\r
197 @param This The DebugSupport instance\r
198 @param ProcessorIndex Which processor the callback applies to.\r
199 @param NewCallback Callback function\r
200 @param ExceptionType Which exception to hook\r
201\r
202 @retval EFI_SUCCESS Indicates the callback was registered.\r
203 @retval others Callback was not registered.\r
204\r
205**/\r
206EFI_STATUS\r
207EFIAPI\r
208RegisterExceptionCallback (\r
209 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
210 IN UINTN ProcessorIndex,\r
211 IN EFI_EXCEPTION_CALLBACK NewCallback,\r
212 IN EFI_EXCEPTION_TYPE ExceptionType\r
213 );\r
214\r
215/**\r
216 DebugSupport protocol member function. Calls assembly routine to flush cache.\r
217\r
218 @param This The DebugSupport instance\r
219 @param ProcessorIndex Which processor the callback applies to.\r
220 @param Start Physical base of the memory range to be invalidated\r
221 @param Length mininum number of bytes in instruction cache to invalidate\r
222\r
223 @retval EFI_SUCCESS Always returned.\r
224\r
225**/\r
226EFI_STATUS\r
227EFIAPI\r
228InvalidateInstructionCache (\r
229 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
230 IN UINTN ProcessorIndex,\r
231 IN VOID *Start,\r
232 IN UINT64 Length\r
233 );\r
234\r
235#endif\r