]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c
UefiCpuPkg/ExceptionLib: Add CommonExceptionHandlerWorker()
[mirror_edk2.git] / UefiCpuPkg / Library / CpuExceptionHandlerLib / SmmException.c
CommitLineData
e41aad15
JF
1/** @file\r
2 CPU exception handler library implemenation for SMM modules.\r
3\r
2c5873fe 4 Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>\r
e41aad15
JF
5 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
15#include <PiSmm.h>\r
16#include "CpuExceptionCommon.h"\r
17\r
18CONST UINTN mDoFarReturnFlag = 1; \r
19\r
ab95e54d
JF
20extern RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM];\r
21extern EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM];\r
2c5873fe 22EXCEPTION_HANDLER_DATA mExceptionHandlerData;\r
44ecbc28
JF
23/**\r
24 Common exception handler.\r
25\r
26 @param ExceptionType Exception type.\r
27 @param SystemContext Pointer to EFI_SYSTEM_CONTEXT.\r
28**/\r
29VOID\r
30EFIAPI\r
31CommonExceptionHandler (\r
32 IN EFI_EXCEPTION_TYPE ExceptionType, \r
33 IN EFI_SYSTEM_CONTEXT SystemContext\r
34 )\r
35{\r
36 CommonExceptionHandlerWorker (ExceptionType, SystemContext, &mExceptionHandlerData);\r
37}\r
38\r
e41aad15
JF
39/**\r
40 Initializes all CPU exceptions entries and provides the default exception handlers.\r
41 \r
42 Caller should try to get an array of interrupt and/or exception vectors that are in use and need to\r
43 persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.\r
44 If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. \r
45 If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.\r
46\r
47 @param[in] VectorInfo Pointer to reserved vector list.\r
48 \r
49 @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized \r
50 with default exception handlers.\r
51 @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.\r
52 @retval EFI_UNSUPPORTED This function is not supported.\r
53\r
54**/\r
55EFI_STATUS\r
56EFIAPI\r
57InitializeCpuExceptionHandlers (\r
58 IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL\r
59 )\r
60{\r
ab95e54d
JF
61 mExceptionHandlerData.ReservedVectors = mReservedVectorsData;\r
62 mExceptionHandlerData.ExternalInterruptHandler = mExternalInterruptHandlerTable;\r
63 InitializeSpinLock (&mExceptionHandlerData.DisplayMessageSpinLock);\r
64 return InitializeCpuExceptionHandlersWorker (VectorInfo, &mExceptionHandlerData);\r
e41aad15
JF
65}\r
66\r
67/**\r
68 Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.\r
69 \r
70 Caller should try to get an array of interrupt and/or exception vectors that are in use and need to\r
71 persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.\r
72 If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL. \r
73 If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.\r
74\r
75 @param[in] VectorInfo Pointer to reserved vector list.\r
76 \r
77 @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized \r
78 with default interrupt/exception handlers.\r
79 @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.\r
80 @retval EFI_UNSUPPORTED This function is not supported.\r
81\r
82**/\r
83EFI_STATUS\r
84EFIAPI\r
85InitializeCpuInterruptHandlers (\r
86 IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL\r
87 )\r
88{\r
89 return EFI_UNSUPPORTED;\r
90}\r
91\r
92/**\r
93 Registers a function to be called from the processor interrupt handler.\r
94\r
95 This function registers and enables the handler specified by InterruptHandler for a processor \r
96 interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the \r
97 handler for the processor interrupt or exception type specified by InterruptType is uninstalled. \r
98 The installed handler is called once for each processor interrupt or exception.\r
99 NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or\r
100 InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned.\r
101\r
102 @param[in] InterruptType Defines which interrupt or exception to hook.\r
103 @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called\r
104 when a processor interrupt occurs. If this parameter is NULL, then the handler\r
105 will be uninstalled.\r
106\r
107 @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.\r
108 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was\r
109 previously installed.\r
110 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not\r
111 previously installed.\r
112 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported,\r
113 or this function is not supported.\r
3f25e6ea 114**/\r
e41aad15
JF
115EFI_STATUS\r
116EFIAPI\r
117RegisterCpuInterruptHandler (\r
118 IN EFI_EXCEPTION_TYPE InterruptType,\r
119 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler\r
120 )\r
121{\r
670f13af 122 return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData);\r
e41aad15 123}