ArmPkg: only attempt buildin MmCommunicationDxe for AArch64
[mirror_edk2.git] / EmbeddedPkg / Include / Library / AcpiLib.h
1 /** @file
2 Helper Library for ACPI
3
4 Copyright (c) 2014-2016, ARM Ltd. All rights reserved.
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef __ACPI_LIB_H__
11 #define __ACPI_LIB_H__
12
13 #include <Uefi.h>
14
15 #include <IndustryStandard/Acpi10.h>
16
17 //
18 // Macros for the Generic Address Space
19 //
20 #define NULL_GAS { EFI_ACPI_5_0_SYSTEM_MEMORY, 0, 0, EFI_ACPI_5_0_UNDEFINED, 0L }
21 #define ARM_GAS8(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 8, 0, EFI_ACPI_5_0_BYTE, Address }
22 #define ARM_GAS16(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 16, 0, EFI_ACPI_5_0_WORD, Address }
23 #define ARM_GAS32(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 32, 0, EFI_ACPI_5_0_DWORD, Address }
24 #define ARM_GASN(Address) { EFI_ACPI_5_0_SYSTEM_MEMORY, 0, 0, EFI_ACPI_5_0_DWORD, Address }
25
26 //
27 // Macros for the Multiple APIC Description Table (MADT)
28 //
29 #define EFI_ACPI_5_0_GIC_DISTRIBUTOR_INIT(GicDistHwId, GicDistBase, GicDistVector) \
30 { \
31 EFI_ACPI_5_0_GICD, sizeof (EFI_ACPI_5_0_GIC_DISTRIBUTOR_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
32 GicDistHwId, GicDistBase, GicDistVector, EFI_ACPI_RESERVED_DWORD \
33 }
34
35 #define EFI_ACPI_6_0_GIC_DISTRIBUTOR_INIT(GicDistHwId, GicDistBase, GicDistVector, GicVersion) \
36 { \
37 EFI_ACPI_6_0_GICD, sizeof (EFI_ACPI_6_0_GIC_DISTRIBUTOR_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
38 GicDistHwId, GicDistBase, GicDistVector, GicVersion, \
39 {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE} \
40 }
41
42 // Note the parking protocol is configured by UEFI if required
43 #define EFI_ACPI_5_0_GIC_STRUCTURE_INIT(GicId, AcpiCpuId, Flags, PmuIrq, GicBase) \
44 { \
45 EFI_ACPI_5_0_GIC, sizeof (EFI_ACPI_5_0_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
46 GicId, AcpiCpuId, Flags, 0, PmuIrq, 0, GicBase \
47 }
48
49 // Note the parking protocol is configured by UEFI if required
50 #define EFI_ACPI_5_1_GICC_STRUCTURE_INIT(GicId, AcpiCpuUid, Mpidr, Flags, PmuIrq, \
51 GicBase, GicVBase, GicHBase, GsivId, GicRBase) \
52 { \
53 EFI_ACPI_5_1_GIC, sizeof (EFI_ACPI_5_1_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
54 GicId, AcpiCpuUid, Flags, 0, PmuIrq, 0, GicBase, GicVBase, GicHBase, \
55 GsivId, GicRBase, Mpidr \
56 }
57
58 #define EFI_ACPI_6_0_GICC_STRUCTURE_INIT(GicId, AcpiCpuUid, Mpidr, Flags, PmuIrq, \
59 GicBase, GicVBase, GicHBase, GsivId, GicRBase, Efficiency) \
60 { \
61 EFI_ACPI_6_0_GIC, sizeof (EFI_ACPI_6_0_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
62 GicId, AcpiCpuUid, Flags, 0, PmuIrq, 0, GicBase, GicVBase, GicHBase, \
63 GsivId, GicRBase, Mpidr, Efficiency, \
64 {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE} \
65 }
66
67 #define EFI_ACPI_6_3_GICC_STRUCTURE_INIT(GicId, AcpiCpuUid, Mpidr, Flags, PmuIrq, \
68 GicBase, GicVBase, GicHBase, GsivId, GicRBase, Efficiency, SpeOvflIrq) \
69 { \
70 EFI_ACPI_6_0_GIC, sizeof (EFI_ACPI_6_3_GIC_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
71 GicId, AcpiCpuUid, Flags, 0, PmuIrq, 0, GicBase, GicVBase, GicHBase, \
72 GsivId, GicRBase, Mpidr, Efficiency, EFI_ACPI_RESERVED_BYTE, SpeOvflIrq \
73 }
74
75 #define EFI_ACPI_6_0_GIC_MSI_FRAME_INIT(GicMsiFrameId, PhysicalBaseAddress, Flags, SPICount, SPIBase) \
76 { \
77 EFI_ACPI_6_0_GIC_MSI_FRAME, sizeof (EFI_ACPI_6_0_GIC_MSI_FRAME_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
78 GicMsiFrameId, PhysicalBaseAddress, Flags, SPICount, SPIBase \
79 }
80
81 //
82 // SBSA Generic Watchdog
83 //
84 #define EFI_ACPI_5_1_SBSA_GENERIC_WATCHDOG_STRUCTURE_INIT(RefreshFramePhysicalAddress, \
85 ControlFramePhysicalAddress, WatchdogTimerGSIV, WatchdogTimerFlags) \
86 { \
87 EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG, sizeof(EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE), \
88 EFI_ACPI_RESERVED_BYTE, RefreshFramePhysicalAddress, ControlFramePhysicalAddress, \
89 WatchdogTimerGSIV, WatchdogTimerFlags \
90 }
91
92 typedef
93 BOOLEAN
94 (EFIAPI *EFI_LOCATE_ACPI_CHECK) (
95 IN EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader
96 );
97
98 /**
99 Locate and Install the ACPI tables from the Firmware Volume if it verifies
100 the function condition.
101
102 @param AcpiFile Guid of the ACPI file into the Firmware Volume
103 @param CheckAcpiTableFunction Function that checks if the ACPI table should be installed
104
105 @return EFI_SUCCESS The function completed successfully.
106 @return EFI_NOT_FOUND The protocol could not be located.
107 @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
108
109 **/
110 EFI_STATUS
111 LocateAndInstallAcpiFromFvConditional (
112 IN CONST EFI_GUID* AcpiFile,
113 IN EFI_LOCATE_ACPI_CHECK CheckAcpiTableFunction
114 );
115
116 /**
117 Locate and Install the ACPI tables from the Firmware Volume
118
119 @param AcpiFile Guid of the ACPI file into the Firmware Volume
120
121 @return EFI_SUCCESS The function completed successfully.
122 @return EFI_NOT_FOUND The protocol could not be located.
123 @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
124
125 **/
126 EFI_STATUS
127 LocateAndInstallAcpiFromFv (
128 IN CONST EFI_GUID* AcpiFile
129 );
130
131 #endif // __ACPI_LIB_H__