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