]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Drivers/CpuDxe/Exception.c
ArmPkg: delete references to unused guids/Pcds from CpuDxe
[mirror_edk2.git] / ArmPkg / Drivers / CpuDxe / Exception.c
1 /** @file
2
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Portions Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
5
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include "CpuDxe.h"
17 #include <Library/CpuExceptionHandlerLib.h>
18 #include <Guid/VectorHandoffTable.h>
19
20 EFI_STATUS
21 InitializeExceptions (
22 IN EFI_CPU_ARCH_PROTOCOL *Cpu
23 ) {
24 EFI_STATUS Status;
25 EFI_VECTOR_HANDOFF_INFO *VectorInfoList;
26 EFI_VECTOR_HANDOFF_INFO *VectorInfo;
27 BOOLEAN IrqEnabled;
28 BOOLEAN FiqEnabled;
29
30 VectorInfo = (EFI_VECTOR_HANDOFF_INFO *)NULL;
31 Status = EfiGetSystemConfigurationTable(&gEfiVectorHandoffTableGuid, (VOID **)&VectorInfoList);
32 if (Status == EFI_SUCCESS && VectorInfoList != NULL) {
33 VectorInfo = VectorInfoList;
34 }
35
36 // intialize the CpuExceptionHandlerLib so we take over the exception vector table from the DXE Core
37 InitializeCpuExceptionHandlers(VectorInfo);
38
39 Status = EFI_SUCCESS;
40
41 //
42 // Disable interrupts
43 //
44 Cpu->GetInterruptState (Cpu, &IrqEnabled);
45 Cpu->DisableInterrupt (Cpu);
46
47 //
48 // EFI does not use the FIQ, but a debugger might so we must disable
49 // as we take over the exception vectors.
50 //
51 FiqEnabled = ArmGetFiqState ();
52 ArmDisableFiq ();
53
54 if (FiqEnabled) {
55 ArmEnableFiq ();
56 }
57
58 if (IrqEnabled) {
59 //
60 // Restore interrupt state
61 //
62 Status = Cpu->EnableInterrupt (Cpu);
63 }
64
65 //
66 // On a DEBUG build, unmask SErrors so they are delivered right away rather
67 // than when the OS unmasks them. This gives us a better chance of figuring
68 // out the cause.
69 //
70 DEBUG_CODE (
71 ArmEnableAsynchronousAbort ();
72 );
73
74 return Status;
75 }
76
77 /**
78 This function registers and enables the handler specified by InterruptHandler for a processor
79 interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
80 handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
81 The installed handler is called once for each processor interrupt or exception.
82
83 @param InterruptType A pointer to the processor's current interrupt state. Set to TRUE if interrupts
84 are enabled and FALSE if interrupts are disabled.
85 @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
86 when a processor interrupt occurs. If this parameter is NULL, then the handler
87 will be uninstalled.
88
89 @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
90 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was
91 previously installed.
92 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not
93 previously installed.
94 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.
95
96 **/
97 EFI_STATUS
98 RegisterInterruptHandler(
99 IN EFI_EXCEPTION_TYPE InterruptType,
100 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
101 ) {
102 // pass down to CpuExceptionHandlerLib
103 return (EFI_STATUS)RegisterCpuInterruptHandler(InterruptType, InterruptHandler);
104 }