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