3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
15 #include <Library/ArmLib.h>
16 #include <Library/ArmMmuLib.h>
17 #include <Library/BaseMemoryLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/PcdLib.h>
20 #include <Library/UefiBootServicesTableLib.h>
21 #include <Library/DxeServicesTableLib.h>
22 #include <Library/CacheMaintenanceLib.h>
23 #include <Library/PeCoffGetEntryPointLib.h>
24 #include <Library/UefiLib.h>
25 #include <Library/CpuLib.h>
26 #include <Library/DefaultExceptionHandlerLib.h>
27 #include <Library/DebugLib.h>
29 #include <Guid/DebugImageInfoTable.h>
30 #include <Protocol/Cpu.h>
31 #include <Protocol/DebugSupport.h>
32 #include <Protocol/LoadedImage.h>
34 extern BOOLEAN mIsFlushingGCD
;
37 This function registers and enables the handler specified by InterruptHandler for a processor
38 interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
39 handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
40 The installed handler is called once for each processor interrupt or exception.
42 @param InterruptType A pointer to the processor's current interrupt state. Set to TRUE if interrupts
43 are enabled and FALSE if interrupts are disabled.
44 @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
45 when a processor interrupt occurs. If this parameter is NULL, then the handler
48 @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
49 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was
51 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not
53 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.
57 RegisterInterruptHandler (
58 IN EFI_EXCEPTION_TYPE InterruptType
,
59 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
63 This function registers and enables the handler specified by InterruptHandler for a processor
64 interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
65 handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
66 The installed handler is called once for each processor interrupt or exception.
68 @param InterruptType A pointer to the processor's current interrupt state. Set to TRUE if interrupts
69 are enabled and FALSE if interrupts are disabled.
70 @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
71 when a processor interrupt occurs. If this parameter is NULL, then the handler
74 @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
75 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was
77 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not
79 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.
83 RegisterDebuggerInterruptHandler (
84 IN EFI_EXCEPTION_TYPE InterruptType
,
85 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
90 CpuSetMemoryAttributes (
91 IN EFI_CPU_ARCH_PROTOCOL
*This
,
92 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
98 InitializeExceptions (
99 IN EFI_CPU_ARCH_PROTOCOL
*Cpu
104 IN EFI_CPU_ARCH_PROTOCOL
*CpuProtocol
107 // The ARM Attributes might be defined on 64-bit (case of the long format description table)
109 EfiAttributeToArmAttribute (
110 IN UINT64 EfiAttributes
115 IN OUT UINTN
*BaseAddress
,
116 OUT UINTN
*RegionLength
,
117 OUT UINTN
*RegionAttributes
121 SetGcdMemorySpaceAttributes (
122 IN EFI_GCD_MEMORY_SPACE_DESCRIPTOR
*MemorySpaceMap
,
123 IN UINTN NumberOfDescriptors
,
124 IN EFI_PHYSICAL_ADDRESS BaseAddress
,