]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DebugSupportDxe/Ia32/PlDebugSupport.h
ECC clean up.
[mirror_edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / Ia32 / PlDebugSupport.h
1 /** @file
2 IA32 specific debug support macros, typedefs and prototypes.
3
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
9
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.
12
13 **/
14
15 #ifndef _PLDEBUG_SUPPORT_H_
16 #define _PLDEBUG_SUPPORT_H_
17
18
19 #include <Uefi.h>
20
21 #include <Protocol/DebugSupport.h>
22 #include <Protocol/LoadedImage.h>
23
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>
31
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)
41
42 typedef UINT64 DESCRIPTOR;
43
44 typedef
45 VOID
46 (*DEBUG_PROC) (
47 VOID
48 );
49
50 typedef struct {
51 DESCRIPTOR OrigDesc;
52 DEBUG_PROC OrigVector;
53 DESCRIPTOR NewDesc;
54 DEBUG_PROC StubEntry;
55 VOID (*RegisteredCallback) ();
56 } IDT_ENTRY;
57
58 extern EFI_SYSTEM_CONTEXT SystemContext;
59 extern UINT8 InterruptEntryStub[];
60 extern UINT32 StubSize;
61 extern VOID (*OrigVector) (VOID);
62
63 /**
64 Generic IDT entry.
65
66 **/
67 VOID
68 CommonIdtEntry (
69 VOID
70 );
71
72 /**
73 Check whether FXSTOR is supported
74
75 @retval TRUE FXSTOR is supported.
76 @retval FALSE FXSTOR is not supported.
77
78 **/
79 BOOLEAN
80 FxStorSupport (
81 VOID
82 );
83
84 /**
85 Return the physical address of IDTR.
86
87 @return The physical address of IDTR.
88
89 **/
90 DESCRIPTOR *
91 GetIdtr (
92 VOID
93 );
94
95 /**
96 Encodes an IDT descriptor with the given physical address.
97
98 @param DestDesc The IDT descriptor address.
99 @param Vecotr The interrupt vector entry.
100
101 **/
102 VOID
103 Vect2Desc (
104 DESCRIPTOR * DestDesc,
105 VOID (*Vector) (VOID)
106 );
107
108 /**
109 Programs interrupt flag to the requested state and returns previous
110 state.
111
112 @param NewState New interrupt status.
113
114 @retval TRUE Old interrupt status is TRUE.
115 @retval FALSE Old interrupt status is FALSE
116
117 **/
118 BOOLEAN
119 WriteInterruptFlag (
120 BOOLEAN NewState
121 );
122
123 /**
124 Initializes driver's handler registration databas.
125
126 This code executes in boot services context
127 Must be public because it's referenced from DebugSupport.c
128
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.
133
134 **/
135 EFI_STATUS
136 PlInitializeDebugSupportDriver (
137 VOID
138 );
139
140 /**
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.
144
145 @param ImageHandle The firmware allocated handle for the EFI image.
146
147 @retval EFI_SUCCESS Always.
148
149 **/
150 EFI_STATUS
151 EFIAPI
152 PlUnloadDebugSupportDriver (
153 IN EFI_HANDLE ImageHandle
154 );
155
156 /**
157 This is a DebugSupport protocol member function, hard
158 coded to support only 1 processor for now.
159
160 @param This The DebugSupport instance
161 @param MaxProcessorIndex The maximuim supported processor index
162
163 @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.
164
165 **/
166 EFI_STATUS
167 EFIAPI
168 GetMaximumProcessorIndex (
169 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
170 OUT UINTN *MaxProcessorIndex
171 );
172
173 /**
174 DebugSupport protocol member function.
175
176 @param This The DebugSupport instance
177 @param ProcessorIndex Which processor the callback applies to.
178 @param PeriodicCallback Callback function
179
180 @retval EFI_SUCCESS Indicates the callback was registered.
181 @retval others Callback was not registered.
182
183 **/
184 EFI_STATUS
185 EFIAPI
186 RegisterPeriodicCallback (
187 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
188 IN UINTN ProcessorIndex,
189 IN EFI_PERIODIC_CALLBACK PeriodicCallback
190 );
191
192 /**
193 DebugSupport protocol member function.
194
195 This code executes in boot services context.
196
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
201
202 @retval EFI_SUCCESS Indicates the callback was registered.
203 @retval others Callback was not registered.
204
205 **/
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
213 );
214
215 /**
216 DebugSupport protocol member function. Calls assembly routine to flush cache.
217
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
222
223 @retval EFI_SUCCESS Always returned.
224
225 **/
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
233 );
234
235 #endif