1 /** @file
2   CPU Exception Handler library implementition with empty functions.
3 
4   Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
5   SPDX-License-Identifier: BSD-2-Clause-Patent
6 
7 **/
8 #include <PiPei.h>
9 #include <Library/CpuExceptionHandlerLib.h>
10 
11 /**
12   Initializes all CPU exceptions entries and provides the default exception handlers.
13 
14   Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
15   persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
16   If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
17   If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
18 
19   @param[in]  VectorInfo    Pointer to reserved vector list.
20 
21   @retval EFI_SUCCESS           CPU Exception Entries have been successfully initialized
22                                 with default exception handlers.
23   @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
24   @retval EFI_UNSUPPORTED       This function is not supported.
25 
26 **/
27 EFI_STATUS
28 EFIAPI
InitializeCpuExceptionHandlers(IN EFI_VECTOR_HANDOFF_INFO * VectorInfo OPTIONAL)29 InitializeCpuExceptionHandlers (
30   IN EFI_VECTOR_HANDOFF_INFO       *VectorInfo OPTIONAL
31   )
32 {
33   return EFI_SUCCESS;
34 }
35 
36 /**
37   Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.
38 
39   Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
40   persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
41   If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
42   If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
43 
44   @param[in]  VectorInfo    Pointer to reserved vector list.
45 
46   @retval EFI_SUCCESS           All CPU interrupt/exception entries have been successfully initialized
47                                 with default interrupt/exception handlers.
48   @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
49   @retval EFI_UNSUPPORTED       This function is not supported.
50 
51 **/
52 EFI_STATUS
53 EFIAPI
InitializeCpuInterruptHandlers(IN EFI_VECTOR_HANDOFF_INFO * VectorInfo OPTIONAL)54 InitializeCpuInterruptHandlers (
55   IN EFI_VECTOR_HANDOFF_INFO       *VectorInfo OPTIONAL
56   )
57 {
58   return EFI_SUCCESS;
59 }
60 
61 /**
62   Registers a function to be called from the processor interrupt handler.
63 
64   This function registers and enables the handler specified by InterruptHandler for a processor
65   interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
66   handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
67   The installed handler is called once for each processor interrupt or exception.
68   NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or
69   InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned.
70 
71   @param[in]  InterruptType     Defines which interrupt or exception to hook.
72   @param[in]  InterruptHandler  A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
73                                 when a processor interrupt occurs. If this parameter is NULL, then the handler
74                                 will be uninstalled.
75 
76   @retval EFI_SUCCESS           The handler for the processor interrupt was successfully installed or uninstalled.
77   @retval EFI_ALREADY_STARTED   InterruptHandler is not NULL, and a handler for InterruptType was
78                                 previously installed.
79   @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not
80                                 previously installed.
81   @retval EFI_UNSUPPORTED       The interrupt specified by InterruptType is not supported,
82                                 or this function is not supported.
83 **/
84 EFI_STATUS
85 EFIAPI
RegisterCpuInterruptHandler(IN EFI_EXCEPTION_TYPE InterruptType,IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler)86 RegisterCpuInterruptHandler (
87   IN EFI_EXCEPTION_TYPE            InterruptType,
88   IN EFI_CPU_INTERRUPT_HANDLER     InterruptHandler
89   )
90 {
91   return EFI_UNSUPPORTED;
92 }
93 
94 /**
95   Display processor context.
96 
97   @param[in] ExceptionType  Exception type.
98   @param[in] SystemContext  Processor context to be display.
99 **/
100 VOID
101 EFIAPI
DumpCpuContext(IN EFI_EXCEPTION_TYPE ExceptionType,IN EFI_SYSTEM_CONTEXT SystemContext)102 DumpCpuContext (
103   IN EFI_EXCEPTION_TYPE   ExceptionType,
104   IN EFI_SYSTEM_CONTEXT   SystemContext
105   )
106 {
107 }
108 
109 /**
110   Initializes all CPU exceptions entries with optional extra initializations.
111 
112   By default, this method should include all functionalities implemented by
113   InitializeCpuExceptionHandlers(), plus extra initialization works, if any.
114   This could be done by calling InitializeCpuExceptionHandlers() directly
115   in this method besides the extra works.
116 
117   InitData is optional and its use and content are processor arch dependent.
118   The typical usage of it is to convey resources which have to be reserved
119   elsewhere and are necessary for the extra initializations of exception.
120 
121   @param[in]  VectorInfo    Pointer to reserved vector list.
122   @param[in]  InitData      Pointer to data optional for extra initializations
123                             of exception.
124 
125   @retval EFI_SUCCESS             The exceptions have been successfully
126                                   initialized.
127   @retval EFI_INVALID_PARAMETER   VectorInfo or InitData contains invalid
128                                   content.
129   @retval EFI_UNSUPPORTED         This function is not supported.
130 
131 **/
132 EFI_STATUS
133 EFIAPI
InitializeCpuExceptionHandlersEx(IN EFI_VECTOR_HANDOFF_INFO * VectorInfo OPTIONAL,IN CPU_EXCEPTION_INIT_DATA * InitData OPTIONAL)134 InitializeCpuExceptionHandlersEx (
135   IN EFI_VECTOR_HANDOFF_INFO            *VectorInfo OPTIONAL,
136   IN CPU_EXCEPTION_INIT_DATA            *InitData OPTIONAL
137   )
138 {
139   return InitializeCpuExceptionHandlers (VectorInfo);
140 }
141 
142