]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Library/CpuExceptionHandlerLib.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Include / Library / CpuExceptionHandlerLib.h
CommitLineData
1e172d6b 1/** @file\r
57f360f2
JF
2 CPU Exception library provides the default CPU interrupt/exception handler.\r
3 It also provides capability to register user interrupt/exception handler.\r
1e172d6b 4\r
2a09527e 5 Copyright (c) 2012 - 2022, Intel Corporation. All rights reserved.<BR>\r
9d510e61 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
1e172d6b 7\r
8**/\r
9\r
57f360f2
JF
10#ifndef __CPU_EXCEPTION_HANDLER_LIB_H__\r
11#define __CPU_EXCEPTION_HANDLER_LIB_H__\r
12\r
13#include <Ppi/VectorHandoffInfo.h>\r
14#include <Protocol/Cpu.h>\r
1e172d6b 15\r
16/**\r
57f360f2 17 Initializes all CPU exceptions entries and provides the default exception handlers.\r
d1102dba 18\r
57f360f2
JF
19 Caller should try to get an array of interrupt and/or exception vectors that are in use and need to\r
20 persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.\r
d1102dba 21 If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.\r
57f360f2
JF
22 If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.\r
23\r
24 @param[in] VectorInfo Pointer to reserved vector list.\r
d1102dba
LG
25\r
26 @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized\r
57f360f2
JF
27 with default exception handlers.\r
28 @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.\r
29 @retval EFI_UNSUPPORTED This function is not supported.\r
30\r
1e172d6b 31**/\r
57f360f2
JF
32EFI_STATUS\r
33EFIAPI\r
34InitializeCpuExceptionHandlers (\r
1436aea4 35 IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL\r
57f360f2
JF
36 );\r
37\r
408b8330 38/**\r
e7abb94d 39 Setup separate stacks for certain exception handlers.\r
0f7bccf5 40 If the input Buffer and BufferSize are both NULL, use global variable if possible.\r
408b8330 41\r
0f7bccf5
ZL
42 @param[in] Buffer Point to buffer used to separate exception stack.\r
43 @param[in, out] BufferSize On input, it indicates the byte size of Buffer.\r
44 If the size is not enough, the return status will\r
45 be EFI_BUFFER_TOO_SMALL, and output BufferSize\r
46 will be the size it needs.\r
408b8330 47\r
e7abb94d 48 @retval EFI_SUCCESS The stacks are assigned successfully.\r
408b8330 49 @retval EFI_UNSUPPORTED This function is not supported.\r
0f7bccf5 50 @retval EFI_BUFFER_TOO_SMALL This BufferSize is too small.\r
408b8330
JW
51**/\r
52EFI_STATUS\r
53EFIAPI\r
e7abb94d 54InitializeSeparateExceptionStacks (\r
0f7bccf5
ZL
55 IN VOID *Buffer,\r
56 IN OUT UINTN *BufferSize\r
408b8330
JW
57 );\r
58\r
57f360f2
JF
59/**\r
60 Registers a function to be called from the processor interrupt handler.\r
61\r
d1102dba
LG
62 This function registers and enables the handler specified by InterruptHandler for a processor\r
63 interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the\r
64 handler for the processor interrupt or exception type specified by InterruptType is uninstalled.\r
57f360f2 65 The installed handler is called once for each processor interrupt or exception.\r
2a09527e
RN
66 NOTE: This function should be invoked after InitializeCpuExceptionHandlers() is invoked,\r
67 otherwise EFI_UNSUPPORTED returned.\r
57f360f2
JF
68\r
69 @param[in] InterruptType Defines which interrupt or exception to hook.\r
70 @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called\r
71 when a processor interrupt occurs. If this parameter is NULL, then the handler\r
72 will be uninstalled.\r
73\r
74 @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.\r
75 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was\r
76 previously installed.\r
77 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not\r
78 previously installed.\r
79 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported,\r
80 or this function is not supported.\r
3f25e6ea 81**/\r
57f360f2 82EFI_STATUS\r
1e172d6b 83EFIAPI\r
57f360f2 84RegisterCpuInterruptHandler (\r
1436aea4
MK
85 IN EFI_EXCEPTION_TYPE InterruptType,\r
86 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler\r
1e172d6b 87 );\r
88\r
e2884d2c
JF
89/**\r
90 Display processor context.\r
91\r
92 @param[in] ExceptionType Exception type.\r
93 @param[in] SystemContext Processor context to be display.\r
94**/\r
95VOID\r
96EFIAPI\r
97DumpCpuContext (\r
1436aea4
MK
98 IN EFI_EXCEPTION_TYPE ExceptionType,\r
99 IN EFI_SYSTEM_CONTEXT SystemContext\r
e2884d2c 100 );\r
d1102dba 101\r
1e172d6b 102#endif\r