]> git.proxmox.com Git - mirror_edk2.git/blob - EmbeddedPkg/Include/Library/AcpiLib.h
EmbeddedPkg: Replace BSD License with BSD+Patent License
[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_0_GIC_MSI_FRAME_INIT(GicMsiFrameId, PhysicalBaseAddress, Flags, SPICount, SPIBase) \
68 { \
69 EFI_ACPI_6_0_GIC_MSI_FRAME, sizeof (EFI_ACPI_6_0_GIC_MSI_FRAME_STRUCTURE), EFI_ACPI_RESERVED_WORD, \
70 GicMsiFrameId, PhysicalBaseAddress, Flags, SPICount, SPIBase \
71 }
72
73 //
74 // SBSA Generic Watchdog
75 //
76 #define EFI_ACPI_5_1_SBSA_GENERIC_WATCHDOG_STRUCTURE_INIT(RefreshFramePhysicalAddress, \
77 ControlFramePhysicalAddress, WatchdogTimerGSIV, WatchdogTimerFlags) \
78 { \
79 EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG, sizeof(EFI_ACPI_5_1_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE), \
80 EFI_ACPI_RESERVED_BYTE, RefreshFramePhysicalAddress, ControlFramePhysicalAddress, \
81 WatchdogTimerGSIV, WatchdogTimerFlags \
82 }
83
84 typedef
85 BOOLEAN
86 (EFIAPI *EFI_LOCATE_ACPI_CHECK) (
87 IN EFI_ACPI_DESCRIPTION_HEADER *AcpiHeader
88 );
89
90 /**
91 Locate and Install the ACPI tables from the Firmware Volume if it verifies
92 the function condition.
93
94 @param AcpiFile Guid of the ACPI file into the Firmware Volume
95 @param CheckAcpiTableFunction Function that checks if the ACPI table should be installed
96
97 @return EFI_SUCCESS The function completed successfully.
98 @return EFI_NOT_FOUND The protocol could not be located.
99 @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
100
101 **/
102 EFI_STATUS
103 LocateAndInstallAcpiFromFvConditional (
104 IN CONST EFI_GUID* AcpiFile,
105 IN EFI_LOCATE_ACPI_CHECK CheckAcpiTableFunction
106 );
107
108 /**
109 Locate and Install the ACPI tables from the Firmware Volume
110
111 @param AcpiFile Guid of the ACPI file into the Firmware Volume
112
113 @return EFI_SUCCESS The function completed successfully.
114 @return EFI_NOT_FOUND The protocol could not be located.
115 @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
116
117 **/
118 EFI_STATUS
119 LocateAndInstallAcpiFromFv (
120 IN CONST EFI_GUID* AcpiFile
121 );
122
123 #endif // __ACPI_LIB_H__