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