TianoCore EDK2 master
Loading...
Searching...
No Matches
CpuExceptionCommon.h
Go to the documentation of this file.
1
9#ifndef _CPU_EXCEPTION_COMMON_H_
10#define _CPU_EXCEPTION_COMMON_H_
11
13#include <Protocol/Cpu.h>
14#include <Library/BaseLib.h>
16#include <Library/PrintLib.h>
22
23#define CPU_EXCEPTION_NUM 32
24#define CPU_INTERRUPT_NUM 256
25#define HOOKAFTER_STUB_SIZE 18
26
27//
28// Exception Error Code of Page-Fault Exception
29//
30#define IA32_PF_EC_P BIT0
31#define IA32_PF_EC_WR BIT1
32#define IA32_PF_EC_US BIT2
33#define IA32_PF_EC_RSVD BIT3
34#define IA32_PF_EC_ID BIT4
35#define IA32_PF_EC_PK BIT5
36#define IA32_PF_EC_SS BIT6
37#define IA32_PF_EC_SGX BIT15
38
39#include "ArchInterruptDefs.h"
40
41#define CPU_STACK_SWITCH_EXCEPTION_NUMBER \
42 FixedPcdGetSize (PcdCpuStackSwitchExceptionList)
43
44#define CPU_STACK_SWITCH_EXCEPTION_LIST \
45 FixedPcdGetPtr (PcdCpuStackSwitchExceptionList)
46
47#define CPU_KNOWN_GOOD_STACK_SIZE \
48 FixedPcdGet32 (PcdCpuKnownGoodStackSize)
49
50#define CPU_TSS_GDT_SIZE (SIZE_2KB + CPU_TSS_DESC_SIZE + CPU_TSS_SIZE)
51
52//
53// Record exception handler information
54//
55typedef struct {
56 UINTN ExceptionStart;
57 UINTN ExceptionStubHeaderSize;
58 UINTN HookAfterStubHeaderStart;
60
61typedef struct {
62 UINTN IdtEntryCount;
63 SPIN_LOCK DisplayMessageSpinLock;
64 RESERVED_VECTORS_DATA *ReservedVectors;
65 EFI_CPU_INTERRUPT_HANDLER *ExternalInterruptHandler;
67
68extern CONST UINT32 mErrorCodeFlag;
69extern CONST UINTN mDoFarReturnFlag;
70
77VOID
78EFIAPI
81 );
82
91VOID
93 OUT IA32_IDT_GATE_DESCRIPTOR *IdtEntry,
94 IN UINTN InterruptHandler
95 );
96
103UINTN
105 IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry
106 );
107
116VOID
117EFIAPI
119 IN CONST CHAR8 *Format,
120 ...
121 );
122
129VOID
131 IN UINTN CurrentEip
132 );
133
140VOID
142 IN EFI_EXCEPTION_TYPE ExceptionType,
143 IN EFI_SYSTEM_CONTEXT SystemContext
144 );
145
160 IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL,
161 IN OUT EXCEPTION_HANDLER_DATA *ExceptionHandlerData
162 );
163
183 IN EFI_EXCEPTION_TYPE InterruptType,
184 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler,
185 IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
186 );
187
197VOID
199 IN IA32_IDT_GATE_DESCRIPTOR *IdtTable,
201 IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
202 );
203
211VOID
213 IN UINTN ExceptionType,
214 IN EFI_SYSTEM_CONTEXT SystemContext,
215 IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
216 );
217
225VOID
227 IN UINTN ExceptionType,
228 IN EFI_SYSTEM_CONTEXT SystemContext,
229 IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
230 );
231
240VOID
241EFIAPI
243 IN VOID *NewVectorAddr,
244 IN UINT8 VectorNum,
245 IN VOID *OldVectorAddr
246 );
247
261 IN EFI_VECTOR_HANDOFF_INFO *VectorInfo,
262 OUT RESERVED_VECTORS_DATA *ReservedVector,
263 IN UINTN VectorCount
264 );
265
273CONST CHAR8 *
275 IN EFI_EXCEPTION_TYPE ExceptionType
276 );
277
285VOID
287 IN EFI_EXCEPTION_TYPE ExceptionType,
288 IN EFI_SYSTEM_CONTEXT SystemContext,
289 IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData
290 );
291
307 IN VOID *Buffer,
308 IN OUT UINTN *BufferSize
309 );
310
318VOID
319EFIAPI
322 );
323
324#endif
UINT64 UINTN
VOID(EFIAPI * EFI_CPU_INTERRUPT_HANDLER)(IN CONST EFI_EXCEPTION_TYPE InterruptType, IN CONST EFI_SYSTEM_CONTEXT SystemContext)
Definition: Cpu.h:52
VOID ArchSaveExceptionContext(IN UINTN ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext, IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
VOID EFIAPI AsmVectorNumFixup(IN VOID *NewVectorAddr, IN UINT8 VectorNum, IN VOID *OldVectorAddr)
VOID ArchRestoreExceptionContext(IN UINTN ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext, IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
VOID DumpImageAndCpuContent(IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext)
VOID EFIAPI AsmGetTemplateAddressMap(OUT EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap)
UINTN ArchGetIdtHandler(IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry)
EFI_STATUS ArchSetupExceptionStack(IN VOID *Buffer, IN OUT UINTN *BufferSize)
VOID DumpModuleImageInfo(IN UINTN CurrentEip)
EFI_STATUS RegisterCpuInterruptHandlerWorker(IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler, IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
VOID UpdateIdtTable(IN IA32_IDT_GATE_DESCRIPTOR *IdtTable, IN EXCEPTION_HANDLER_TEMPLATE_MAP *TemplateMap, IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
EFI_STATUS ReadAndVerifyVectorInfo(IN EFI_VECTOR_HANDOFF_INFO *VectorInfo, OUT RESERVED_VECTORS_DATA *ReservedVector, IN UINTN VectorCount)
EFI_STATUS InitializeCpuExceptionHandlersWorker(IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL, IN OUT EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
CONST CHAR8 * GetExceptionNameStr(IN EFI_EXCEPTION_TYPE ExceptionType)
VOID ArchUpdateIdtEntry(OUT IA32_IDT_GATE_DESCRIPTOR *IdtEntry, IN UINTN InterruptHandler)
VOID CommonExceptionHandlerWorker(IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext, IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
VOID EFIAPI AsmGetTssTemplateMap(OUT EXCEPTION_HANDLER_TEMPLATE_MAP *AddressMap)
VOID EFIAPI InternalPrintMessage(IN CONST CHAR8 *Format,...)
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
INTN EFI_EXCEPTION_TYPE
Definition: DebugSupport.h:35
volatile UINTN SPIN_LOCK
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29