Synchronize MdePkg/Library *.h files with c files
[edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / Ia32 / PlDebugSupport.h
blob1566f3e8b7601c3a84a0f617ff1af19c7eee37a4
1 /** @file
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.
13 **/
15 #ifndef _PLDEBUG_SUPPORT_H_
16 #define _PLDEBUG_SUPPORT_H_
19 #include <Uefi.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;
44 typedef
45 VOID
46 (*DEBUG_PROC) (
47 VOID
50 typedef struct {
51 DESCRIPTOR OrigDesc;
52 DEBUG_PROC OrigVector;
53 DESCRIPTOR NewDesc;
54 DEBUG_PROC StubEntry;
55 VOID (*RegisteredCallback) ();
56 } IDT_ENTRY;
58 extern EFI_SYSTEM_CONTEXT SystemContext;
59 extern UINT8 InterruptEntryStub[];
60 extern UINT32 StubSize;
61 extern VOID (*OrigVector) (VOID);
63 /**
64 Generic IDT entry.
66 **/
67 VOID
68 CommonIdtEntry (
69 VOID
72 /**
73 Check whether FXSTOR is supported
75 @retval TRUE FXSTOR is supported.
76 @retval FALSE FXSTOR is not supported.
78 **/
79 BOOLEAN
80 FxStorSupport (
81 VOID
84 /**
85 Return the physical address of IDTR.
87 @return The physical address of IDTR.
89 **/
90 DESCRIPTOR *
91 GetIdtr (
92 VOID
95 /**
96 Encodes an IDT descriptor with the given physical address.
98 @param DestDesc The IDT descriptor address.
99 @param Vecotr The interrupt vector entry.
102 VOID
103 Vect2Desc (
104 DESCRIPTOR * DestDesc,
105 VOID (*Vector) (VOID)
109 Programs interrupt flag to the requested state and returns previous
110 state.
112 @param NewState New interrupt status.
114 @retval TRUE Old interrupt status is TRUE.
115 @retval FALSE Old interrupt status is FALSE
118 BOOLEAN
119 WriteInterruptFlag (
120 BOOLEAN NewState
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.
135 EFI_STATUS
136 PlInitializeDebugSupportDriver (
137 VOID
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
143 stub memory.
145 @param ImageHandle The firmware allocated handle for the EFI image.
147 @retval EFI_SUCCESS Always.
150 EFI_STATUS
151 EFIAPI
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.
166 EFI_STATUS
167 EFIAPI
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.
184 EFI_STATUS
185 EFIAPI
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.
206 EFI_STATUS
207 EFIAPI
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.
226 EFI_STATUS
227 EFIAPI
228 InvalidateInstructionCache (
229 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
230 IN UINTN ProcessorIndex,
231 IN VOID *Start,
232 IN UINT64 Length
235 #endif