2 IA32 specific debug support macros, typedefs and prototypes.
4 Copyright (c) 2006 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _PLDEBUG_SUPPORT_H_
16 #define _PLDEBUG_SUPPORT_H_
21 #include <Protocol/DebugSupport.h>
22 #include <Protocol/LoadedImage.h>
24 #include <Library/DebugLib.h>
25 #include <Library/UefiDriverEntryPoint.h>
26 #include <Library/BaseMemoryLib.h>
27 #include <Library/MemoryAllocationLib.h>
28 #include <Library/UefiBootServicesTableLib.h>
29 #include <Library/BaseLib.h>
30 #include <Library/PcdLib.h>
32 #define NUM_IDT_ENTRIES 0x78
33 #define SYSTEM_TIMER_VECTOR 0x68
34 #define VECTOR_ENTRY_PAGES 1
35 #define COPY_DESCRIPTOR(Dest, Src) CopyMem ((Dest), (Src), sizeof (DESCRIPTOR))
36 #define READ_IDT(Vector, Dest) COPY_DESCRIPTOR ((Dest), &((GetIdtr ())[(Vector)]))
37 #define WRITE_IDT(Vector, Src) COPY_DESCRIPTOR (&((GetIdtr ())[(Vector)]), (Src))
38 #define COMPARE_DESCRIPTOR(Desc1, Desc2) CompareMem ((Desc1), (Desc2), sizeof (DESCRIPTOR))
39 #define EFI_ISA IsaIa32
40 #define FF_FXSR (1 << 24)
42 typedef UINT64 DESCRIPTOR
;
52 DEBUG_PROC OrigVector
;
55 VOID (*RegisteredCallback
) ();
58 extern EFI_SYSTEM_CONTEXT SystemContext
;
59 extern UINT8 InterruptEntryStub
[];
60 extern UINT32 StubSize
;
61 extern VOID (*OrigVector
) (VOID
);
73 Check whether FXSTOR is supported
75 @retval TRUE FXSTOR is supported.
76 @retval FALSE FXSTOR is not supported.
85 Return the physical address of IDTR.
87 @return The physical address of IDTR.
96 Encodes an IDT descriptor with the given physical address.
98 @param DestDesc The IDT descriptor address.
99 @param Vecotr The interrupt vector entry.
104 DESCRIPTOR
* DestDesc
,
105 VOID (*Vector
) (VOID
)
109 Programs interrupt flag to the requested state and returns previous
112 @param NewState New interrupt status.
114 @retval TRUE Old interrupt status is TRUE.
115 @retval FALSE Old interrupt status is FALSE
124 Initializes driver's handler registration databas.
126 This code executes in boot services context
127 Must be public because it's referenced from DebugSupport.c
129 @retval EFI_UNSUPPORTED If IA32 processor does not support FXSTOR/FXRSTOR instructions,
130 the context save will fail, so these processor's are not supported.
131 @retval EFI_OUT_OF_RESOURCES Fails to allocate memory.
132 @retval EFI_SUCCESS Initializes successfully.
136 PlInitializeDebugSupportDriver (
141 This is the callback that is written to the LoadedImage protocol instance
142 on the image handle. It uninstalls all registered handlers and frees all entry
145 @param ImageHandle The firmware allocated handle for the EFI image.
147 @retval EFI_SUCCESS Always.
152 PlUnloadDebugSupportDriver (
153 IN EFI_HANDLE ImageHandle
157 This is a DebugSupport protocol member function, hard
158 coded to support only 1 processor for now.
160 @param This The DebugSupport instance
161 @param MaxProcessorIndex The maximuim supported processor index
163 @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.
168 GetMaximumProcessorIndex (
169 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
170 OUT UINTN
*MaxProcessorIndex
174 DebugSupport protocol member function.
176 @param This The DebugSupport instance
177 @param ProcessorIndex Which processor the callback applies to.
178 @param PeriodicCallback Callback function
180 @retval EFI_SUCCESS Indicates the callback was registered.
181 @retval others Callback was not registered.
186 RegisterPeriodicCallback (
187 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
188 IN UINTN ProcessorIndex
,
189 IN EFI_PERIODIC_CALLBACK PeriodicCallback
193 DebugSupport protocol member function.
195 This code executes in boot services context.
197 @param This The DebugSupport instance
198 @param ProcessorIndex Which processor the callback applies to.
199 @param NewCallback Callback function
200 @param ExceptionType Which exception to hook
202 @retval EFI_SUCCESS Indicates the callback was registered.
203 @retval others Callback was not registered.
208 RegisterExceptionCallback (
209 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
210 IN UINTN ProcessorIndex
,
211 IN EFI_EXCEPTION_CALLBACK NewCallback
,
212 IN EFI_EXCEPTION_TYPE ExceptionType
216 DebugSupport protocol member function. Calls assembly routine to flush cache.
218 @param This The DebugSupport instance
219 @param ProcessorIndex Which processor the callback applies to.
220 @param Start Physical base of the memory range to be invalidated
221 @param Length mininum number of bytes in instruction cache to invalidate
223 @retval EFI_SUCCESS Always returned.
228 InvalidateInstructionCache (
229 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
230 IN UINTN ProcessorIndex
,