]>
Commit | Line | Data |
---|---|---|
5811eea0 EC |
1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
4 | Portions Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>\r | |
5 | \r | |
4059386c | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
5811eea0 EC |
7 | \r |
8 | **/\r | |
9 | \r | |
10 | #include "CpuDxe.h"\r | |
11 | #include <Library/CpuExceptionHandlerLib.h>\r | |
12 | #include <Guid/VectorHandoffTable.h>\r | |
13 | \r | |
14 | EFI_STATUS\r | |
15 | InitializeExceptions (\r | |
16 | IN EFI_CPU_ARCH_PROTOCOL *Cpu\r | |
17 | ) {\r | |
18 | EFI_STATUS Status;\r | |
19 | EFI_VECTOR_HANDOFF_INFO *VectorInfoList;\r | |
20 | EFI_VECTOR_HANDOFF_INFO *VectorInfo;\r | |
21 | BOOLEAN IrqEnabled;\r | |
22 | BOOLEAN FiqEnabled;\r | |
23 | \r | |
24 | VectorInfo = (EFI_VECTOR_HANDOFF_INFO *)NULL;\r | |
25 | Status = EfiGetSystemConfigurationTable(&gEfiVectorHandoffTableGuid, (VOID **)&VectorInfoList);\r | |
26 | if (Status == EFI_SUCCESS && VectorInfoList != NULL) {\r | |
27 | VectorInfo = VectorInfoList;\r | |
28 | }\r | |
29 | \r | |
30 | // intialize the CpuExceptionHandlerLib so we take over the exception vector table from the DXE Core\r | |
31 | InitializeCpuExceptionHandlers(VectorInfo);\r | |
32 | \r | |
33 | Status = EFI_SUCCESS;\r | |
34 | \r | |
35 | //\r | |
36 | // Disable interrupts\r | |
37 | //\r | |
38 | Cpu->GetInterruptState (Cpu, &IrqEnabled);\r | |
39 | Cpu->DisableInterrupt (Cpu);\r | |
40 | \r | |
41 | //\r | |
42 | // EFI does not use the FIQ, but a debugger might so we must disable\r | |
43 | // as we take over the exception vectors.\r | |
44 | //\r | |
45 | FiqEnabled = ArmGetFiqState ();\r | |
46 | ArmDisableFiq ();\r | |
47 | \r | |
48 | if (FiqEnabled) {\r | |
49 | ArmEnableFiq ();\r | |
50 | }\r | |
51 | \r | |
52 | if (IrqEnabled) {\r | |
53 | //\r | |
54 | // Restore interrupt state\r | |
55 | //\r | |
56 | Status = Cpu->EnableInterrupt (Cpu);\r | |
57 | }\r | |
58 | \r | |
3b3593b5 AB |
59 | //\r |
60 | // On a DEBUG build, unmask SErrors so they are delivered right away rather\r | |
61 | // than when the OS unmasks them. This gives us a better chance of figuring\r | |
62 | // out the cause.\r | |
63 | //\r | |
64 | DEBUG_CODE (\r | |
65 | ArmEnableAsynchronousAbort ();\r | |
66 | );\r | |
67 | \r | |
5811eea0 EC |
68 | return Status;\r |
69 | }\r | |
70 | \r | |
71 | /**\r | |
72 | This function registers and enables the handler specified by InterruptHandler for a processor\r | |
73 | interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the\r | |
74 | handler for the processor interrupt or exception type specified by InterruptType is uninstalled.\r | |
75 | The installed handler is called once for each processor interrupt or exception.\r | |
76 | \r | |
77 | @param InterruptType A pointer to the processor's current interrupt state. Set to TRUE if interrupts\r | |
78 | are enabled and FALSE if interrupts are disabled.\r | |
79 | @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called\r | |
80 | when a processor interrupt occurs. If this parameter is NULL, then the handler\r | |
81 | will be uninstalled.\r | |
82 | \r | |
83 | @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.\r | |
84 | @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was\r | |
85 | previously installed.\r | |
86 | @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not\r | |
87 | previously installed.\r | |
88 | @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.\r | |
89 | \r | |
90 | **/\r | |
91 | EFI_STATUS\r | |
92 | RegisterInterruptHandler(\r | |
93 | IN EFI_EXCEPTION_TYPE InterruptType,\r | |
94 | IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler\r | |
95 | ) {\r | |
96 | // pass down to CpuExceptionHandlerLib\r | |
97 | return (EFI_STATUS)RegisterCpuInterruptHandler(InterruptType, InterruptHandler);\r | |
98 | }\r |