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