]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | IPF specific types, macros, and definitions for Debug Support Driver.\r | |
3 | \r | |
4 | Copyright (c) 2004 - 2010, Intel Corporation\r | |
5 | All rights reserved. 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 _PLDEBUG_SUPPORT_H_\r | |
16 | #define _PLDEBUG_SUPPORT_H_\r | |
17 | \r | |
18 | #include <Uefi.h>\r | |
19 | \r | |
20 | #include <Protocol/DebugSupport.h>\r | |
21 | #include <Protocol/LoadedImage.h>\r | |
22 | \r | |
23 | #include <Library/DebugLib.h>\r | |
24 | #include <Library/UefiDriverEntryPoint.h>\r | |
25 | #include <Library/BaseMemoryLib.h>\r | |
26 | #include <Library/MemoryAllocationLib.h>\r | |
27 | #include <Library/UefiBootServicesTableLib.h>\r | |
28 | \r | |
29 | #define DISABLE_INTERRUPTS 0UL\r | |
30 | \r | |
31 | #define EFI_ISA IsaIpf\r | |
32 | \r | |
33 | typedef struct {\r | |
34 | UINT64 Low;\r | |
35 | UINT64 High;\r | |
36 | } BUNDLE;\r | |
37 | \r | |
38 | typedef\r | |
39 | VOID\r | |
40 | (*CALLBACK_FUNC) (\r | |
41 | );\r | |
42 | \r | |
43 | /**\r | |
44 | IPF specific DebugSupport driver initialization.\r | |
45 | \r | |
46 | Must be public because it's referenced from DebugSupport.c\r | |
47 | \r | |
48 | @retval EFI_SUCCESS Always.\r | |
49 | \r | |
50 | **/\r | |
51 | EFI_STATUS\r | |
52 | PlInitializeDebugSupportDriver (\r | |
53 | VOID\r | |
54 | );\r | |
55 | \r | |
56 | /**\r | |
57 | Unload handler that is called during UnloadImage() - deallocates pool memory\r | |
58 | used by the driver.\r | |
59 | \r | |
60 | Must be public because it's referenced from DebugSuport.c\r | |
61 | \r | |
62 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
63 | \r | |
64 | @retval EFI_SUCCESS Always.\r | |
65 | \r | |
66 | **/\r | |
67 | EFI_STATUS\r | |
68 | EFIAPI\r | |
69 | PlUnloadDebugSupportDriver (\r | |
70 | IN EFI_HANDLE ImageHandle\r | |
71 | );\r | |
72 | \r | |
73 | /**\r | |
74 | C callable function to obtain the current value of IVA.\r | |
75 | \r | |
76 | @return Current value of IVA.\r | |
77 | \r | |
78 | **/\r | |
79 | VOID *\r | |
80 | GetIva (\r | |
81 | VOID\r | |
82 | );\r | |
83 | \r | |
84 | /**\r | |
85 | C callable function that HookStub will be copied from it's loaded location into the IVT when\r | |
86 | an IVT entry is hooked.\r | |
87 | \r | |
88 | **/\r | |
89 | VOID\r | |
90 | HookStub (\r | |
91 | VOID\r | |
92 | );\r | |
93 | \r | |
94 | /**\r | |
95 | C callable function to chain an interrupt handler.\r | |
96 | \r | |
97 | **/\r | |
98 | VOID\r | |
99 | ChainHandler (\r | |
100 | VOID\r | |
101 | );\r | |
102 | \r | |
103 | /**\r | |
104 | C callable function to unchain an interrupt handler.\r | |
105 | \r | |
106 | **/\r | |
107 | VOID\r | |
108 | UnchainHandler (\r | |
109 | VOID\r | |
110 | );\r | |
111 | \r | |
112 | /**\r | |
113 | C callable function to enable/disable interrupts.\r | |
114 | \r | |
115 | @param NewInterruptState New Interrupt State.\r | |
116 | \r | |
117 | @return Previous state of psr.ic.\r | |
118 | \r | |
119 | **/\r | |
120 | UINT64\r | |
121 | ProgramInterruptFlags (\r | |
122 | IN UINT64 NewInterruptState\r | |
123 | );\r | |
124 | \r | |
125 | /**\r | |
126 | Flushes instruction cache for specified number of bytes.\r | |
127 | \r | |
128 | @param StartAddress Cache Start Address.\r | |
129 | @param SizeInBytes Cache Size.\r | |
130 | \r | |
131 | **/\r | |
132 | VOID\r | |
133 | InstructionCacheFlush (\r | |
134 | IN VOID *StartAddress,\r | |
135 | IN UINTN SizeInBytes\r | |
136 | );\r | |
137 | \r | |
138 | /**\r | |
139 | Returns the maximum value that may be used for the ProcessorIndex parameter in\r | |
140 | RegisterPeriodicCallback() and RegisterExceptionCallback().\r | |
141 | \r | |
142 | Hard coded to support only 1 processor for now.\r | |
143 | \r | |
144 | @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r | |
145 | @param MaxProcessorIndex Pointer to a caller-allocated UINTN in which the maximum supported\r | |
146 | processor index is returned. Always 0 returned.\r | |
147 | \r | |
148 | @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.\r | |
149 | \r | |
150 | **/\r | |
151 | EFI_STATUS\r | |
152 | EFIAPI\r | |
153 | GetMaximumProcessorIndex (\r | |
154 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
155 | OUT UINTN *MaxProcessorIndex\r | |
156 | );\r | |
157 | \r | |
158 | /**\r | |
159 | Registers a function to be called back periodically in interrupt context.\r | |
160 | \r | |
161 | @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r | |
162 | @param ProcessorIndex Specifies which processor the callback function applies to.\r | |
163 | @param PeriodicCallback A pointer to a function of type PERIODIC_CALLBACK that is the main\r | |
164 | periodic entry point of the debug agent.\r | |
165 | \r | |
166 | @retval EFI_SUCCESS The function completed successfully.\r | |
167 | @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback\r | |
168 | function was previously registered.\r | |
169 | @retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback\r | |
170 | function.\r | |
171 | **/\r | |
172 | EFI_STATUS\r | |
173 | EFIAPI\r | |
174 | RegisterPeriodicCallback (\r | |
175 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
176 | IN UINTN ProcessorIndex,\r | |
177 | IN EFI_PERIODIC_CALLBACK PeriodicCallback\r | |
178 | );\r | |
179 | \r | |
180 | /**\r | |
181 | Registers a function to be called when a given processor exception occurs.\r | |
182 | \r | |
183 | This code executes in boot services context.\r | |
184 | \r | |
185 | @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r | |
186 | @param ProcessorIndex Specifies which processor the callback function applies to.\r | |
187 | @param ExceptionCallback A pointer to a function of type EXCEPTION_CALLBACK that is called\r | |
188 | when the processor exception specified by ExceptionType occurs. \r | |
189 | @param ExceptionType Specifies which processor exception to hook.\r | |
190 | \r | |
191 | @retval EFI_SUCCESS The function completed successfully.\r | |
192 | @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback\r | |
193 | function was previously registered.\r | |
194 | @retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback\r | |
195 | function.\r | |
196 | **/\r | |
197 | EFI_STATUS\r | |
198 | EFIAPI\r | |
199 | RegisterExceptionCallback (\r | |
200 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
201 | IN UINTN ProcessorIndex,\r | |
202 | IN EFI_EXCEPTION_CALLBACK ExceptionCallback,\r | |
203 | IN EFI_EXCEPTION_TYPE ExceptionType\r | |
204 | );\r | |
205 | \r | |
206 | /**\r | |
207 | Invalidates processor instruction cache for a memory range. Subsequent execution in this range\r | |
208 | causes a fresh memory fetch to retrieve code to be executed.\r | |
209 | \r | |
210 | @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.\r | |
211 | @param ProcessorIndex Specifies which processor's instruction cache is to be invalidated.\r | |
212 | @param Start Specifies the physical base of the memory range to be invalidated.\r | |
213 | @param Length Specifies the minimum number of bytes in the processor's instruction\r | |
214 | cache to invalidate.\r | |
215 | \r | |
216 | @retval EFI_SUCCESS Always returned.\r | |
217 | \r | |
218 | **/\r | |
219 | EFI_STATUS\r | |
220 | EFIAPI\r | |
221 | InvalidateInstructionCache (\r | |
222 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
223 | IN UINTN ProcessorIndex,\r | |
224 | IN VOID *Start,\r | |
225 | IN UINTN Length\r | |
226 | );\r | |
227 | \r | |
228 | /**\r | |
229 | C routine that is called for all registered exceptions. This is the main\r | |
230 | exception dispatcher.\r | |
231 | \r | |
232 | Must be public because it's referenced from AsmFuncs.s.\r | |
233 | \r | |
234 | @param ExceptionType Specifies which processor exception.\r | |
235 | @param Context System Context.\r | |
236 | **/\r | |
237 | VOID\r | |
238 | CommonHandler (\r | |
239 | IN EFI_EXCEPTION_TYPE ExceptionType,\r | |
240 | IN EFI_SYSTEM_CONTEXT Context\r | |
241 | );\r | |
242 | \r | |
243 | /**\r | |
244 | This is the worker function that uninstalls and removes all handlers.\r | |
245 | \r | |
246 | @param ExceptionType Specifies which processor exception.\r | |
247 | @param NewBundles New Boundles.\r | |
248 | @param NewCallback A pointer to the new function to be registered.\r | |
249 | \r | |
250 | @retval EFI_ALEADY_STARTED Ivt already hooked.\r | |
251 | @retval EFI_SUCCESS Successfully uninstalled.\r | |
252 | \r | |
253 | **/\r | |
254 | EFI_STATUS\r | |
255 | ManageIvtEntryTable (\r | |
256 | IN EFI_EXCEPTION_TYPE ExceptionType,\r | |
257 | IN BUNDLE NewBundles[4],\r | |
258 | IN CALLBACK_FUNC NewCallback\r | |
259 | );\r | |
260 | \r | |
261 | /**\r | |
262 | Saves original IVT contents and inserts a few new bundles which are fixed up\r | |
263 | to store the ExceptionType and then call the common handler.\r | |
264 | \r | |
265 | @param ExceptionType Specifies which processor exception.\r | |
266 | @param NewBundles New Boundles.\r | |
267 | @param NewCallback A pointer to the new function to be hooked.\r | |
268 | \r | |
269 | **/\r | |
270 | VOID\r | |
271 | HookEntry (\r | |
272 | IN EFI_EXCEPTION_TYPE ExceptionType,\r | |
273 | IN BUNDLE NewBundles[4],\r | |
274 | IN CALLBACK_FUNC NewCallback\r | |
275 | );\r | |
276 | \r | |
277 | /**\r | |
278 | Restores original IVT contents when unregistering a callback function.\r | |
279 | \r | |
280 | @param ExceptionType Specifies which processor exception.\r | |
281 | \r | |
282 | **/\r | |
283 | VOID\r | |
284 | UnhookEntry (\r | |
285 | IN EFI_EXCEPTION_TYPE ExceptionType\r | |
286 | );\r | |
287 | \r | |
288 | /**\r | |
289 | Sets up cache flush and calls assembly function to chain external interrupt.\r | |
290 | \r | |
291 | Records new callback in IvtEntryTable.\r | |
292 | \r | |
293 | @param NewCallback A pointer to the interrupt handle.\r | |
294 | \r | |
295 | **/\r | |
296 | VOID\r | |
297 | ChainExternalInterrupt (\r | |
298 | IN CALLBACK_FUNC NewCallback\r | |
299 | );\r | |
300 | \r | |
301 | /**\r | |
302 | Sets up cache flush and calls assembly function to restore external interrupt.\r | |
303 | Removes registered callback from IvtEntryTable.\r | |
304 | \r | |
305 | **/\r | |
306 | VOID\r | |
307 | UnchainExternalInterrupt (\r | |
308 | VOID\r | |
309 | );\r | |
310 | \r | |
311 | /**\r | |
312 | Given an integer number, return the physical address of the entry point in the IFT.\r | |
313 | \r | |
314 | @param HandlerIndex Index of the Handler\r | |
315 | @param EntryPoint IFT Entrypoint\r | |
316 | \r | |
317 | **/\r | |
318 | VOID\r | |
319 | GetHandlerEntryPoint (\r | |
320 | UINTN HandlerIndex,\r | |
321 | VOID **EntryPoint\r | |
322 | );\r | |
323 | \r | |
324 | #endif\r |