]>
Commit | Line | Data |
---|---|---|
9e604fe4 | 1 | /** @file\r |
c1f23d63 | 2 | IA32 specific debug support macros, typedefs and prototypes.\r |
3 | \r | |
9e604fe4 | 4 | Copyright (c) 2006 - 2008, Intel Corporation \r |
c1f23d63 | 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 | |
9e604fe4 | 15 | #ifndef _PLDEBUG_SUPPORT_H_\r |
16 | #define _PLDEBUG_SUPPORT_H_\r | |
c1f23d63 | 17 | \r |
ed7748fe | 18 | \r |
60c93673 | 19 | #include <Uefi.h>\r |
ed7748fe | 20 | \r |
c1f23d63 | 21 | #include <Protocol/DebugSupport.h>\r |
22 | #include <Protocol/LoadedImage.h>\r | |
ed7748fe | 23 | \r |
c1f23d63 | 24 | #include <Library/DebugLib.h>\r |
25 | #include <Library/UefiDriverEntryPoint.h>\r | |
26 | #include <Library/BaseMemoryLib.h>\r | |
27 | #include <Library/MemoryAllocationLib.h>\r | |
28 | #include <Library/UefiBootServicesTableLib.h>\r | |
29 | #include <Library/BaseLib.h>\r | |
30 | #include <Library/PcdLib.h>\r | |
31 | \r | |
32 | #define NUM_IDT_ENTRIES 0x78\r | |
33 | #define SYSTEM_TIMER_VECTOR 0x68\r | |
34 | #define VECTOR_ENTRY_PAGES 1\r | |
9e604fe4 | 35 | #define COPY_DESCRIPTOR(Dest, Src) CopyMem ((Dest), (Src), sizeof (DESCRIPTOR))\r |
36 | #define READ_IDT(Vector, Dest) COPY_DESCRIPTOR ((Dest), &((GetIdtr ())[(Vector)]))\r | |
37 | #define WRITE_IDT(Vector, Src) COPY_DESCRIPTOR (&((GetIdtr ())[(Vector)]), (Src))\r | |
38 | #define COMPARE_DESCRIPTOR(Desc1, Desc2) CompareMem ((Desc1), (Desc2), sizeof (DESCRIPTOR))\r | |
c1f23d63 | 39 | #define EFI_ISA IsaIa32\r |
40 | #define FF_FXSR (1 << 24)\r | |
41 | \r | |
42 | typedef UINT64 DESCRIPTOR;\r | |
43 | \r | |
44 | typedef\r | |
45 | VOID\r | |
46 | (*DEBUG_PROC) (\r | |
47 | VOID\r | |
ed66e1bc | 48 | );\r |
c1f23d63 | 49 | \r |
50 | typedef struct {\r | |
51 | DESCRIPTOR OrigDesc;\r | |
52 | DEBUG_PROC OrigVector;\r | |
53 | DESCRIPTOR NewDesc;\r | |
54 | DEBUG_PROC StubEntry;\r | |
55 | VOID (*RegisteredCallback) ();\r | |
56 | } IDT_ENTRY;\r | |
57 | \r | |
58 | extern EFI_SYSTEM_CONTEXT SystemContext;\r | |
59 | extern UINT8 InterruptEntryStub[];\r | |
60 | extern UINT32 StubSize;\r | |
61 | extern VOID (*OrigVector) (VOID);\r | |
62 | \r | |
9e604fe4 | 63 | /**\r |
64 | Generic IDT entry.\r | |
65 | \r | |
66 | **/\r | |
c1f23d63 | 67 | VOID\r |
68 | CommonIdtEntry (\r | |
69 | VOID\r | |
9e604fe4 | 70 | );\r |
c1f23d63 | 71 | \r |
9e604fe4 | 72 | /**\r |
73 | Check whether FXSTOR is supported\r | |
c1f23d63 | 74 | \r |
9e604fe4 | 75 | @retval TRUE FXSTOR is supported.\r |
76 | @retval FALSE FXSTOR is not supported.\r | |
c1f23d63 | 77 | \r |
9e604fe4 | 78 | **/\r |
c1f23d63 | 79 | BOOLEAN\r |
80 | FxStorSupport (\r | |
81 | VOID\r | |
9e604fe4 | 82 | );\r |
c1f23d63 | 83 | \r |
9e604fe4 | 84 | /**\r |
85 | Return the physical address of IDTR.\r | |
c1f23d63 | 86 | \r |
9e604fe4 | 87 | @return The physical address of IDTR.\r |
c1f23d63 | 88 | \r |
9e604fe4 | 89 | **/\r |
c1f23d63 | 90 | DESCRIPTOR *\r |
91 | GetIdtr (\r | |
92 | VOID\r | |
9e604fe4 | 93 | );\r |
c1f23d63 | 94 | \r |
9e604fe4 | 95 | /**\r |
96 | Encodes an IDT descriptor with the given physical address.\r | |
c1f23d63 | 97 | \r |
9e604fe4 | 98 | @param DestDesc The IDT descriptor address.\r |
99 | @param Vecotr The interrupt vector entry.\r | |
c1f23d63 | 100 | \r |
9e604fe4 | 101 | **/\r |
c1f23d63 | 102 | VOID\r |
103 | Vect2Desc (\r | |
104 | DESCRIPTOR * DestDesc,\r | |
105 | VOID (*Vector) (VOID)\r | |
9e604fe4 | 106 | );\r |
c1f23d63 | 107 | \r |
9e604fe4 | 108 | /**\r |
109 | Programs interrupt flag to the requested state and returns previous\r | |
110 | state.\r | |
c1f23d63 | 111 | \r |
9e604fe4 | 112 | @param NewState New interrupt status.\r |
c1f23d63 | 113 | \r |
9e604fe4 | 114 | @retval TRUE Old interrupt status is TRUE.\r |
115 | @retval FALSE Old interrupt status is FALSE\r | |
c1f23d63 | 116 | \r |
9e604fe4 | 117 | **/\r |
c1f23d63 | 118 | BOOLEAN\r |
119 | WriteInterruptFlag (\r | |
120 | BOOLEAN NewState\r | |
9e604fe4 | 121 | );\r |
c1f23d63 | 122 | \r |
9e604fe4 | 123 | /**\r |
124 | Initializes driver's handler registration databas. \r | |
125 | \r | |
126 | This code executes in boot services context\r | |
127 | Must be public because it's referenced from DebugSupport.c\r | |
c1f23d63 | 128 | \r |
9e604fe4 | 129 | @retval EFI_UNSUPPORTED If IA32 processor does not support FXSTOR/FXRSTOR instructions,\r |
130 | the context save will fail, so these processor's are not supported.\r | |
131 | @retval EFI_OUT_OF_RESOURCES Fails to allocate memory.\r | |
132 | @retval EFI_SUCCESS Initializes successfully.\r | |
c1f23d63 | 133 | \r |
9e604fe4 | 134 | **/\r |
c1f23d63 | 135 | EFI_STATUS\r |
9e604fe4 | 136 | PlInitializeDebugSupportDriver (\r |
c1f23d63 | 137 | VOID\r |
9e604fe4 | 138 | );\r |
c1f23d63 | 139 | \r |
9e604fe4 | 140 | /**\r |
141 | This is the callback that is written to the LoadedImage protocol instance\r | |
142 | on the image handle. It uninstalls all registered handlers and frees all entry\r | |
143 | stub memory.\r | |
c1f23d63 | 144 | \r |
9e604fe4 | 145 | @param ImageHandle The firmware allocated handle for the EFI image.\r |
c1f23d63 | 146 | \r |
9e604fe4 | 147 | @retval EFI_SUCCESS Always.\r |
c1f23d63 | 148 | \r |
9e604fe4 | 149 | **/\r |
c1f23d63 | 150 | EFI_STATUS\r |
151 | EFIAPI\r | |
9e604fe4 | 152 | PlUnloadDebugSupportDriver (\r |
c1f23d63 | 153 | IN EFI_HANDLE ImageHandle\r |
9e604fe4 | 154 | );\r |
c1f23d63 | 155 | \r |
9e604fe4 | 156 | /**\r |
157 | This is a DebugSupport protocol member function, hard\r | |
158 | coded to support only 1 processor for now.\r | |
c1f23d63 | 159 | \r |
9e604fe4 | 160 | @param This The DebugSupport instance\r |
161 | @param MaxProcessorIndex The maximuim supported processor index\r | |
c1f23d63 | 162 | \r |
9e604fe4 | 163 | @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.\r |
c1f23d63 | 164 | \r |
9e604fe4 | 165 | **/\r |
c1f23d63 | 166 | EFI_STATUS\r |
167 | EFIAPI\r | |
168 | GetMaximumProcessorIndex (\r | |
169 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
170 | OUT UINTN *MaxProcessorIndex\r | |
9e604fe4 | 171 | );\r |
c1f23d63 | 172 | \r |
9e604fe4 | 173 | /**\r |
174 | DebugSupport protocol member function.\r | |
c1f23d63 | 175 | \r |
9e604fe4 | 176 | @param This The DebugSupport instance\r |
177 | @param ProcessorIndex Which processor the callback applies to.\r | |
178 | @param PeriodicCallback Callback function\r | |
c1f23d63 | 179 | \r |
9e604fe4 | 180 | @retval EFI_SUCCESS Indicates the callback was registered.\r |
181 | @retval others Callback was not registered.\r | |
c1f23d63 | 182 | \r |
9e604fe4 | 183 | **/\r |
c1f23d63 | 184 | EFI_STATUS\r |
185 | EFIAPI\r | |
186 | RegisterPeriodicCallback (\r | |
187 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
188 | IN UINTN ProcessorIndex,\r | |
189 | IN EFI_PERIODIC_CALLBACK PeriodicCallback\r | |
9e604fe4 | 190 | );\r |
c1f23d63 | 191 | \r |
9e604fe4 | 192 | /**\r |
193 | DebugSupport protocol member function.\r | |
c1f23d63 | 194 | \r |
9e604fe4 | 195 | This code executes in boot services context.\r |
c1f23d63 | 196 | \r |
9e604fe4 | 197 | @param This The DebugSupport instance\r |
198 | @param ProcessorIndex Which processor the callback applies to.\r | |
199 | @param NewCallback Callback function\r | |
200 | @param ExceptionType Which exception to hook\r | |
c1f23d63 | 201 | \r |
9e604fe4 | 202 | @retval EFI_SUCCESS Indicates the callback was registered.\r |
203 | @retval others Callback was not registered.\r | |
c1f23d63 | 204 | \r |
9e604fe4 | 205 | **/\r |
c1f23d63 | 206 | EFI_STATUS\r |
207 | EFIAPI\r | |
208 | RegisterExceptionCallback (\r | |
209 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
210 | IN UINTN ProcessorIndex,\r | |
211 | IN EFI_EXCEPTION_CALLBACK NewCallback,\r | |
212 | IN EFI_EXCEPTION_TYPE ExceptionType\r | |
9e604fe4 | 213 | );\r |
c1f23d63 | 214 | \r |
9e604fe4 | 215 | /**\r |
216 | DebugSupport protocol member function. Calls assembly routine to flush cache.\r | |
c1f23d63 | 217 | \r |
9e604fe4 | 218 | @param This The DebugSupport instance\r |
219 | @param ProcessorIndex Which processor the callback applies to.\r | |
220 | @param Start Physical base of the memory range to be invalidated\r | |
221 | @param Length mininum number of bytes in instruction cache to invalidate\r | |
c1f23d63 | 222 | \r |
9e604fe4 | 223 | @retval EFI_SUCCESS Always returned.\r |
c1f23d63 | 224 | \r |
9e604fe4 | 225 | **/\r |
c1f23d63 | 226 | EFI_STATUS\r |
227 | EFIAPI\r | |
228 | InvalidateInstructionCache (\r | |
229 | IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r | |
230 | IN UINTN ProcessorIndex,\r | |
231 | IN VOID *Start,\r | |
232 | IN UINT64 Length\r | |
9e604fe4 | 233 | );\r |
c1f23d63 | 234 | \r |
235 | #endif\r |