]>
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 | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "CpuDxe.h"\r | |
17 | #include <Library/CpuExceptionHandlerLib.h>\r | |
18 | #include <Guid/VectorHandoffTable.h>\r | |
19 | \r | |
20 | EFI_STATUS\r | |
21 | InitializeExceptions (\r | |
22 | IN EFI_CPU_ARCH_PROTOCOL *Cpu\r | |
23 | ) {\r | |
24 | EFI_STATUS Status;\r | |
25 | EFI_VECTOR_HANDOFF_INFO *VectorInfoList;\r | |
26 | EFI_VECTOR_HANDOFF_INFO *VectorInfo;\r | |
27 | BOOLEAN IrqEnabled;\r | |
28 | BOOLEAN FiqEnabled;\r | |
29 | \r | |
30 | VectorInfo = (EFI_VECTOR_HANDOFF_INFO *)NULL;\r | |
31 | Status = EfiGetSystemConfigurationTable(&gEfiVectorHandoffTableGuid, (VOID **)&VectorInfoList);\r | |
32 | if (Status == EFI_SUCCESS && VectorInfoList != NULL) {\r | |
33 | VectorInfo = VectorInfoList;\r | |
34 | }\r | |
35 | \r | |
36 | // intialize the CpuExceptionHandlerLib so we take over the exception vector table from the DXE Core\r | |
37 | InitializeCpuExceptionHandlers(VectorInfo);\r | |
38 | \r | |
39 | Status = EFI_SUCCESS;\r | |
40 | \r | |
41 | //\r | |
42 | // Disable interrupts\r | |
43 | //\r | |
44 | Cpu->GetInterruptState (Cpu, &IrqEnabled);\r | |
45 | Cpu->DisableInterrupt (Cpu);\r | |
46 | \r | |
47 | //\r | |
48 | // EFI does not use the FIQ, but a debugger might so we must disable\r | |
49 | // as we take over the exception vectors.\r | |
50 | //\r | |
51 | FiqEnabled = ArmGetFiqState ();\r | |
52 | ArmDisableFiq ();\r | |
53 | \r | |
54 | if (FiqEnabled) {\r | |
55 | ArmEnableFiq ();\r | |
56 | }\r | |
57 | \r | |
58 | if (IrqEnabled) {\r | |
59 | //\r | |
60 | // Restore interrupt state\r | |
61 | //\r | |
62 | Status = Cpu->EnableInterrupt (Cpu);\r | |
63 | }\r | |
64 | \r | |
65 | return Status;\r | |
66 | }\r | |
67 | \r | |
68 | /**\r | |
69 | This function registers and enables the handler specified by InterruptHandler for a processor\r | |
70 | interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the\r | |
71 | handler for the processor interrupt or exception type specified by InterruptType is uninstalled.\r | |
72 | The installed handler is called once for each processor interrupt or exception.\r | |
73 | \r | |
74 | @param InterruptType A pointer to the processor's current interrupt state. Set to TRUE if interrupts\r | |
75 | are enabled and FALSE if interrupts are disabled.\r | |
76 | @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called\r | |
77 | when a processor interrupt occurs. If this parameter is NULL, then the handler\r | |
78 | will be uninstalled.\r | |
79 | \r | |
80 | @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.\r | |
81 | @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was\r | |
82 | previously installed.\r | |
83 | @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not\r | |
84 | previously installed.\r | |
85 | @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.\r | |
86 | \r | |
87 | **/\r | |
88 | EFI_STATUS\r | |
89 | RegisterInterruptHandler(\r | |
90 | IN EFI_EXCEPTION_TYPE InterruptType,\r | |
91 | IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler\r | |
92 | ) {\r | |
93 | // pass down to CpuExceptionHandlerLib\r | |
94 | return (EFI_STATUS)RegisterCpuInterruptHandler(InterruptType, InterruptHandler);\r | |
95 | }\r |