2 X64 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>
31 #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 IsaX64
40 #define FF_FXSR (1 << 24)
55 DEBUG_PROC OrigVector
;
58 VOID (*RegisteredCallback
) ();
61 extern EFI_SYSTEM_CONTEXT SystemContext
;
62 extern UINT8 InterruptEntryStub
[];
63 extern UINT32 StubSize
;
64 extern VOID (*OrigVector
) (VOID
);
76 Check whether FXSTOR is supported
78 @retval TRUE FXSTOR is supported.
79 @retval FALSE FXSTOR is not supported.
88 Return the physical address of IDTR.
90 @return The physical address of IDTR.
99 Encodes an IDT descriptor with the given physical address.
101 @param DestDesc The IDT descriptor address.
102 @param Vecotr The interrupt vector entry.
107 DESCRIPTOR
* DestDesc
,
108 VOID (*Vector
) (VOID
)
112 Programs interrupt flag to the requested state and returns previous
115 @param NewState New interrupt status.
117 @retval TRUE Old interrupt status is TRUE.
118 @retval FALSE Old interrupt status is FALSE
127 Initializes driver's handler registration databas.
129 This code executes in boot services context
130 Must be public because it's referenced from DebugSupport.c
132 @retval EFI_UNSUPPORTED If x64 processor does not support FXSTOR/FXRSTOR instructions,
133 the context save will fail, so these processor's are not supported.
134 @retval EFI_OUT_OF_RESOURCES Fails to allocate memory.
135 @retval EFI_SUCCESS Initializes successfully.
139 PlInitializeDebugSupportDriver (
144 This is the callback that is written to the LoadedImage protocol instance
145 on the image handle. It uninstalls all registered handlers and frees all entry
148 @param ImageHandle The firmware allocated handle for the EFI image.
150 @retval EFI_SUCCESS Always.
155 PlUnloadDebugSupportDriver (
156 IN EFI_HANDLE ImageHandle
160 This is a DebugSupport protocol member function, hard
161 coded to support only 1 processor for now.
163 @param This The DebugSupport instance
164 @param MaxProcessorIndex The maximuim supported processor index
166 @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.
171 GetMaximumProcessorIndex (
172 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
173 OUT UINTN
*MaxProcessorIndex
177 DebugSupport protocol member function.
179 @param This The DebugSupport instance
180 @param ProcessorIndex Which processor the callback applies to.
181 @param PeriodicCallback Callback function
183 @retval EFI_SUCCESS Indicates the callback was registered.
184 @retval others Callback was not registered.
189 RegisterPeriodicCallback (
190 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
191 IN UINTN ProcessorIndex
,
192 IN EFI_PERIODIC_CALLBACK PeriodicCallback
196 DebugSupport protocol member function.
198 This code executes in boot services context.
200 @param This The DebugSupport instance
201 @param ProcessorIndex Which processor the callback applies to.
202 @param NewCallback Callback function
203 @param ExceptionType Which exception to hook
205 @retval EFI_SUCCESS Indicates the callback was registered.
206 @retval others Callback was not registered.
211 RegisterExceptionCallback (
212 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
213 IN UINTN ProcessorIndex
,
214 IN EFI_EXCEPTION_CALLBACK NewCallback
,
215 IN EFI_EXCEPTION_TYPE ExceptionType
219 DebugSupport protocol member function. Calls assembly routine to flush cache.
221 @param This The DebugSupport instance
222 @param ProcessorIndex Which processor the callback applies to.
223 @param Start Physical base of the memory range to be invalidated
224 @param Length mininum number of bytes in instruction cache to invalidate
226 @retval EFI_SUCCESS Always returned.
231 InvalidateInstructionCache (
232 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
233 IN UINTN ProcessorIndex
,