]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
MdeModulePkg/ACPI: Install ACPI table from HOB.
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / AcpiTableDxe / AcpiTable.h
1 /** @file
2 ACPI Table Protocol Driver
3
4 Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _ACPI_TABLE_H_
10 #define _ACPI_TABLE_H_
11
12
13 #include <PiDxe.h>
14
15 #include <Protocol/AcpiTable.h>
16 #include <Guid/Acpi.h>
17 #include <Protocol/AcpiSystemDescriptionTable.h>
18
19 #include <Library/BaseLib.h>
20 #include <Library/DebugLib.h>
21 #include <Library/UefiLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/UefiDriverEntryPoint.h>
24 #include <Library/MemoryAllocationLib.h>
25 #include <Library/UefiBootServicesTableLib.h>
26 #include <Library/PcdLib.h>
27 #include <Library/HobLib.h>
28 #include <UniversalPayload/AcpiTable.h>
29
30 //
31 // Statements that include other files
32 //
33 #include <IndustryStandard/Acpi.h>
34
35 #include "AcpiSdt.h"
36
37 //
38 // Great than or equal to 2.0.
39 //
40 #define ACPI_TABLE_VERSION_GTE_2_0 (EFI_ACPI_TABLE_VERSION_2_0 | \
41 EFI_ACPI_TABLE_VERSION_3_0 | \
42 EFI_ACPI_TABLE_VERSION_4_0 | \
43 EFI_ACPI_TABLE_VERSION_5_0)
44
45 //
46 // Private Driver Data
47 //
48 //
49 // ACPI Table Linked List Signature.
50 //
51 #define EFI_ACPI_TABLE_LIST_SIGNATURE SIGNATURE_32 ('E', 'A', 'T', 'L')
52
53 //
54 // ACPI Table Linked List Entry definition.
55 //
56 // Signature must be set to EFI_ACPI_TABLE_LIST_SIGNATURE
57 // Link is the linked list data.
58 // Version is the versions of the ACPI tables that this table belongs in.
59 // Table is a pointer to the table.
60 // TableSize is the size of the table
61 // Handle is used to identify a particular table.
62 // PoolAllocation carries the allocation type:
63 // FALSE: Table points to EFI_SIZE_TO_PAGES(TableSize) pages allocated using
64 // gBS->AllocatePages ()
65 // TRUE: Table points to TableSize bytes allocated using gBS->AllocatePool ()
66 //
67 typedef struct {
68 UINT32 Signature;
69 LIST_ENTRY Link;
70 EFI_ACPI_TABLE_VERSION Version;
71 EFI_ACPI_COMMON_HEADER *Table;
72 UINTN TableSize;
73 UINTN Handle;
74 BOOLEAN PoolAllocation;
75 } EFI_ACPI_TABLE_LIST;
76
77 //
78 // Containment record for ACPI Table linked list.
79 //
80 #define EFI_ACPI_TABLE_LIST_FROM_LINK(_link) CR (_link, EFI_ACPI_TABLE_LIST, Link, EFI_ACPI_TABLE_LIST_SIGNATURE)
81
82 //
83 // The maximum number of tables this driver supports
84 //
85 #define EFI_ACPI_MAX_NUM_TABLES 20
86
87 //
88 // Protocol private structure definition
89 //
90 //
91 // ACPI support protocol instance signature definition.
92 //
93 #define EFI_ACPI_TABLE_SIGNATURE SIGNATURE_32 ('S', 'T', 'A', 'E')
94
95 //
96 // ACPI support protocol instance data structure
97 //
98 typedef struct {
99 UINTN Signature;
100 EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp1; // Pointer to RSD_PTR structure
101 EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp3; // Pointer to RSD_PTR structure
102 EFI_ACPI_DESCRIPTION_HEADER *Rsdt1; // Pointer to RSDT table header
103 EFI_ACPI_DESCRIPTION_HEADER *Rsdt3; // Pointer to RSDT table header
104 EFI_ACPI_DESCRIPTION_HEADER *Xsdt; // Pointer to XSDT table header
105 EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt1; // Pointer to FADT table header
106 EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt3; // Pointer to FADT table header
107 EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs1; // Pointer to FACS table header
108 EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs3; // Pointer to FACS table header
109 EFI_ACPI_DESCRIPTION_HEADER *Dsdt1; // Pointer to DSDT table header
110 EFI_ACPI_DESCRIPTION_HEADER *Dsdt3; // Pointer to DSDT table header
111 LIST_ENTRY TableList;
112 UINTN NumberOfTableEntries1; // Number of ACPI 1.0 tables
113 UINTN NumberOfTableEntries3; // Number of ACPI 3.0 tables
114 UINTN CurrentHandle;
115 EFI_ACPI_TABLE_PROTOCOL AcpiTableProtocol;
116 EFI_ACPI_SDT_PROTOCOL AcpiSdtProtocol;
117 LIST_ENTRY NotifyList;
118 } EFI_ACPI_TABLE_INSTANCE;
119
120 //
121 // ACPI table protocol instance containing record macro
122 //
123 #define EFI_ACPI_TABLE_INSTANCE_FROM_THIS(a) \
124 CR (a, \
125 EFI_ACPI_TABLE_INSTANCE, \
126 AcpiTableProtocol, \
127 EFI_ACPI_TABLE_SIGNATURE \
128 )
129
130 //
131 // Protocol Constructor functions
132 //
133
134 /**
135 Constructor for the ACPI support protocol. Initializes instance
136 data.
137
138 @param AcpiTableInstance Instance to construct
139
140 @return EFI_SUCCESS Instance initialized.
141 @return EFI_OUT_OF_RESOURCES Unable to allocate required resources.
142
143 **/
144 EFI_STATUS
145 AcpiTableAcpiTableConstructor (
146 EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance
147 );
148
149
150 /**
151 Entry point of the ACPI table driver.
152 Creates and initializes an instance of the ACPI Table
153 Protocol and installs it on a new handle.
154
155 @param ImageHandle A handle for the image that is initializing this driver
156 @param SystemTable A pointer to the EFI system table
157
158 @return EFI_SUCCESS Driver initialized successfully
159 @return EFI_LOAD_ERROR Failed to Initialize or has been loaded
160 @return EFI_OUT_OF_RESOURCES Could not allocate needed resources
161
162 **/
163 EFI_STATUS
164 EFIAPI
165 InitializeAcpiTableDxe (
166 IN EFI_HANDLE ImageHandle,
167 IN EFI_SYSTEM_TABLE *SystemTable
168 );
169
170 /**
171
172 This function finds the table specified by the handle and returns a pointer to it.
173 If the handle is not found, EFI_NOT_FOUND is returned and the contents of Table are
174 undefined.
175
176 @param[in] Handle Table to find.
177 @param[in] TableList Table list to search
178 @param[out] Table Pointer to table found.
179
180 @retval EFI_SUCCESS The function completed successfully.
181 @retval EFI_NOT_FOUND No table found matching the handle specified.
182
183 **/
184 EFI_STATUS
185 FindTableByHandle (
186 IN UINTN Handle,
187 IN LIST_ENTRY *TableList,
188 OUT EFI_ACPI_TABLE_LIST **Table
189 );
190
191 /**
192
193 This function calculates and updates an UINT8 checksum.
194
195 @param[in] Buffer Pointer to buffer to checksum
196 @param[in] Size Number of bytes to checksum
197 @param[in] ChecksumOffset Offset to place the checksum result in
198
199 @retval EFI_SUCCESS The function completed successfully.
200
201 **/
202 EFI_STATUS
203 AcpiPlatformChecksum (
204 IN VOID *Buffer,
205 IN UINTN Size,
206 IN UINTN ChecksumOffset
207 );
208
209 /**
210 This function invokes ACPI notification.
211
212 @param[in] AcpiTableInstance Instance to AcpiTable
213 @param[in] Version Version(s) to set.
214 @param[in] Handle Handle of the table.
215 **/
216 VOID
217 SdtNotifyAcpiList (
218 IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance,
219 IN EFI_ACPI_TABLE_VERSION Version,
220 IN UINTN Handle
221 );
222
223 /**
224 This function initializes AcpiSdt protocol in ACPI table instance.
225
226 @param[in] AcpiTableInstance Instance to construct
227 **/
228 VOID
229 SdtAcpiTableAcpiSdtConstructor (
230 IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance
231 );
232
233 /**
234 Returns a requested ACPI table.
235
236 The following structures are not considered elements in the list of
237 ACPI tables:
238 - Root System Description Pointer (RSD_PTR)
239 - Root System Description Table (RSDT)
240 - Extended System Description Table (XSDT)
241 Version is updated with a bit map containing all the versions of ACPI of which the table is a
242 member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
243 the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
244
245 @param[in] AcpiTableInstance ACPI table Instance.
246 @param[in] Index The zero-based index of the table to retrieve.
247 @param[out] Table Pointer for returning the table buffer.
248 @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
249 EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
250 EFI_ACPI_SDT_PROTOCOL.
251 @param[out] TableKey On return, points to the table key for the specified ACPI system definition table.
252 This is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
253 The TableKey can be passed to EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
254 to uninstall the table.
255 @retval EFI_SUCCESS The function completed successfully.
256 @retval EFI_NOT_FOUND The requested index is too large and a table was not found.
257 **/
258 EFI_STATUS
259 SdtGetAcpiTable (
260 IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance,
261 IN UINTN Index,
262 OUT EFI_ACPI_SDT_HEADER **Table,
263 OUT EFI_ACPI_TABLE_VERSION *Version,
264 OUT UINTN *TableKey
265 );
266
267 //
268 // export PrivateData symbol, because we need that in AcpiSdtProtol implementation
269 //
270 extern EFI_HANDLE mHandle;
271 extern EFI_ACPI_TABLE_INSTANCE *mPrivateData;
272
273 #endif