]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/DebugSupportDxe/X64/PlDebugSupport.h
Synchronize MdePkg/Library *.h files with c files
[mirror_edk2.git] / MdeModulePkg / Universal / DebugSupportDxe / X64 / PlDebugSupport.h
CommitLineData
9e604fe4 1/** @file\r
c1f23d63 2 X64 specific debug support macros, typedefs and prototypes.\r
3\r
9e604fe4 4Copyright (c) 2006 - 2008, Intel Corporation \r
c1f23d63 5All rights reserved. This program and the accompanying materials \r
6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT 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\r
31#include <Library/PcdLib.h>\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 IsaX64\r
40#define FF_FXSR (1 << 24)\r
41\r
42typedef struct {\r
43 UINT64 Low;\r
44 UINT64 High;\r
45} DESCRIPTOR;\r
46\r
47typedef\r
48VOID\r
49(*DEBUG_PROC) (\r
50 VOID\r
ed66e1bc 51 );\r
c1f23d63 52\r
53typedef struct {\r
54 DESCRIPTOR OrigDesc;\r
55 DEBUG_PROC OrigVector;\r
56 DESCRIPTOR NewDesc;\r
57 DEBUG_PROC StubEntry;\r
58 VOID (*RegisteredCallback) ();\r
59} IDT_ENTRY;\r
60\r
61extern EFI_SYSTEM_CONTEXT SystemContext;\r
62extern UINT8 InterruptEntryStub[];\r
63extern UINT32 StubSize;\r
64extern VOID (*OrigVector) (VOID);\r
65\r
9e604fe4 66/**\r
67 Generic IDT entry.\r
68\r
69**/\r
c1f23d63 70VOID\r
71CommonIdtEntry (\r
72 VOID\r
9e604fe4 73 );\r
c1f23d63 74\r
9e604fe4 75/**\r
76 Check whether FXSTOR is supported\r
c1f23d63 77\r
9e604fe4 78 @retval TRUE FXSTOR is supported.\r
79 @retval FALSE FXSTOR is not supported.\r
c1f23d63 80\r
9e604fe4 81**/\r
c1f23d63 82BOOLEAN\r
83FxStorSupport (\r
84 VOID\r
9e604fe4 85 );\r
c1f23d63 86\r
9e604fe4 87/**\r
88 Return the physical address of IDTR.\r
c1f23d63 89\r
9e604fe4 90 @return The physical address of IDTR.\r
c1f23d63 91\r
9e604fe4 92**/\r
c1f23d63 93DESCRIPTOR *\r
94GetIdtr (\r
95 VOID\r
9e604fe4 96 );\r
c1f23d63 97\r
9e604fe4 98/**\r
99 Encodes an IDT descriptor with the given physical address.\r
c1f23d63 100\r
9e604fe4 101 @param DestDesc The IDT descriptor address.\r
102 @param Vecotr The interrupt vector entry.\r
c1f23d63 103\r
9e604fe4 104**/\r
c1f23d63 105VOID\r
106Vect2Desc (\r
107 DESCRIPTOR * DestDesc,\r
108 VOID (*Vector) (VOID)\r
9e604fe4 109 );\r
c1f23d63 110\r
9e604fe4 111/**\r
112 Programs interrupt flag to the requested state and returns previous\r
113 state.\r
c1f23d63 114\r
9e604fe4 115 @param NewState New interrupt status.\r
c1f23d63 116\r
9e604fe4 117 @retval TRUE Old interrupt status is TRUE.\r
118 @retval FALSE Old interrupt status is FALSE\r
c1f23d63 119\r
9e604fe4 120**/\r
c1f23d63 121BOOLEAN\r
122WriteInterruptFlag (\r
123 BOOLEAN NewState\r
9e604fe4 124 );\r
c1f23d63 125\r
9e604fe4 126/**\r
127 Initializes driver's handler registration databas. \r
128 \r
129 This code executes in boot services context\r
130 Must be public because it's referenced from DebugSupport.c\r
c1f23d63 131\r
9e604fe4 132 @retval EFI_UNSUPPORTED If x64 processor does not support FXSTOR/FXRSTOR instructions,\r
133 the context save will fail, so these processor's are not supported.\r
134 @retval EFI_OUT_OF_RESOURCES Fails to allocate memory.\r
135 @retval EFI_SUCCESS Initializes successfully.\r
c1f23d63 136\r
9e604fe4 137**/\r
c1f23d63 138EFI_STATUS\r
9e604fe4 139PlInitializeDebugSupportDriver (\r
c1f23d63 140 VOID\r
9e604fe4 141 );\r
c1f23d63 142\r
9e604fe4 143/**\r
144 This is the callback that is written to the LoadedImage protocol instance\r
145 on the image handle. It uninstalls all registered handlers and frees all entry\r
146 stub memory.\r
c1f23d63 147\r
9e604fe4 148 @param ImageHandle The firmware allocated handle for the EFI image.\r
c1f23d63 149\r
9e604fe4 150 @retval EFI_SUCCESS Always.\r
c1f23d63 151\r
9e604fe4 152**/\r
c1f23d63 153EFI_STATUS\r
154EFIAPI\r
9e604fe4 155PlUnloadDebugSupportDriver (\r
c1f23d63 156 IN EFI_HANDLE ImageHandle\r
9e604fe4 157 );\r
c1f23d63 158\r
9e604fe4 159/**\r
160 This is a DebugSupport protocol member function, hard\r
161 coded to support only 1 processor for now.\r
c1f23d63 162\r
9e604fe4 163 @param This The DebugSupport instance\r
164 @param MaxProcessorIndex The maximuim supported processor index\r
c1f23d63 165\r
9e604fe4 166 @retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.\r
c1f23d63 167\r
9e604fe4 168**/\r
c1f23d63 169EFI_STATUS\r
170EFIAPI\r
171GetMaximumProcessorIndex (\r
172 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
173 OUT UINTN *MaxProcessorIndex\r
9e604fe4 174 );\r
c1f23d63 175\r
9e604fe4 176/**\r
177 DebugSupport protocol member function.\r
c1f23d63 178\r
9e604fe4 179 @param This The DebugSupport instance\r
180 @param ProcessorIndex Which processor the callback applies to.\r
181 @param PeriodicCallback Callback function\r
c1f23d63 182\r
9e604fe4 183 @retval EFI_SUCCESS Indicates the callback was registered.\r
184 @retval others Callback was not registered.\r
c1f23d63 185\r
9e604fe4 186**/\r
c1f23d63 187EFI_STATUS\r
188EFIAPI\r
189RegisterPeriodicCallback (\r
190 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
191 IN UINTN ProcessorIndex,\r
192 IN EFI_PERIODIC_CALLBACK PeriodicCallback\r
9e604fe4 193 );\r
c1f23d63 194\r
9e604fe4 195/**\r
196 DebugSupport protocol member function.\r
c1f23d63 197\r
9e604fe4 198 This code executes in boot services context.\r
c1f23d63 199\r
9e604fe4 200 @param This The DebugSupport instance\r
201 @param ProcessorIndex Which processor the callback applies to.\r
202 @param NewCallback Callback function\r
203 @param ExceptionType Which exception to hook\r
c1f23d63 204\r
9e604fe4 205 @retval EFI_SUCCESS Indicates the callback was registered.\r
206 @retval others Callback was not registered.\r
c1f23d63 207\r
9e604fe4 208**/\r
c1f23d63 209EFI_STATUS\r
210EFIAPI\r
211RegisterExceptionCallback (\r
212 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
213 IN UINTN ProcessorIndex,\r
214 IN EFI_EXCEPTION_CALLBACK NewCallback,\r
215 IN EFI_EXCEPTION_TYPE ExceptionType\r
9e604fe4 216 );\r
c1f23d63 217\r
9e604fe4 218/**\r
219 DebugSupport protocol member function. Calls assembly routine to flush cache.\r
c1f23d63 220\r
9e604fe4 221 @param This The DebugSupport instance\r
222 @param ProcessorIndex Which processor the callback applies to.\r
223 @param Start Physical base of the memory range to be invalidated\r
224 @param Length mininum number of bytes in instruction cache to invalidate\r
c1f23d63 225\r
9e604fe4 226 @retval EFI_SUCCESS Always returned.\r
c1f23d63 227\r
9e604fe4 228**/\r
c1f23d63 229EFI_STATUS\r
230EFIAPI\r
231InvalidateInstructionCache (\r
232 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
233 IN UINTN ProcessorIndex,\r
234 IN VOID *Start,\r
235 IN UINT64 Length\r
9e604fe4 236 );\r
c1f23d63 237\r
238#endif\r