]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / AcpiTableDxe / AcpiTable.h
1 /** @file
2 ACPI Table Protocol Driver
3
4 Copyright (c) 2006 - 2018, 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
28 //
29 // Statements that include other files
30 //
31 #include <IndustryStandard/Acpi.h>
32
33 #include "AcpiSdt.h"
34
35 //
36 // Great than or equal to 2.0.
37 //
38 #define ACPI_TABLE_VERSION_GTE_2_0 (EFI_ACPI_TABLE_VERSION_2_0 | \
39 EFI_ACPI_TABLE_VERSION_3_0 | \
40 EFI_ACPI_TABLE_VERSION_4_0 | \
41 EFI_ACPI_TABLE_VERSION_5_0)
42
43 //
44 // Private Driver Data
45 //
46 //
47 // ACPI Table Linked List Signature.
48 //
49 #define EFI_ACPI_TABLE_LIST_SIGNATURE SIGNATURE_32 ('E', 'A', 'T', 'L')
50
51 //
52 // ACPI Table Linked List Entry definition.
53 //
54 // Signature must be set to EFI_ACPI_TABLE_LIST_SIGNATURE
55 // Link is the linked list data.
56 // Version is the versions of the ACPI tables that this table belongs in.
57 // Table is a pointer to the table.
58 // PageAddress is the address of the pages allocated for the table.
59 // NumberOfPages is the number of pages allocated at PageAddress.
60 // Handle is used to identify a particular table.
61 //
62 typedef struct {
63 UINT32 Signature;
64 LIST_ENTRY Link;
65 EFI_ACPI_TABLE_VERSION Version;
66 EFI_ACPI_COMMON_HEADER *Table;
67 EFI_PHYSICAL_ADDRESS PageAddress;
68 UINTN NumberOfPages;
69 UINTN Handle;
70 } EFI_ACPI_TABLE_LIST;
71
72 //
73 // Containment record for ACPI Table linked list.
74 //
75 #define EFI_ACPI_TABLE_LIST_FROM_LINK(_link) CR (_link, EFI_ACPI_TABLE_LIST, Link, EFI_ACPI_TABLE_LIST_SIGNATURE)
76
77 //
78 // The maximum number of tables this driver supports
79 //
80 #define EFI_ACPI_MAX_NUM_TABLES 20
81
82 //
83 // Protocol private structure definition
84 //
85 //
86 // ACPI support protocol instance signature definition.
87 //
88 #define EFI_ACPI_TABLE_SIGNATURE SIGNATURE_32 ('S', 'T', 'A', 'E')
89
90 //
91 // ACPI support protocol instance data structure
92 //
93 typedef struct {
94 UINTN Signature;
95 EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp1; // Pointer to RSD_PTR structure
96 EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp3; // Pointer to RSD_PTR structure
97 EFI_ACPI_DESCRIPTION_HEADER *Rsdt1; // Pointer to RSDT table header
98 EFI_ACPI_DESCRIPTION_HEADER *Rsdt3; // Pointer to RSDT table header
99 EFI_ACPI_DESCRIPTION_HEADER *Xsdt; // Pointer to XSDT table header
100 EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt1; // Pointer to FADT table header
101 EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt3; // Pointer to FADT table header
102 EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs1; // Pointer to FACS table header
103 EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs3; // Pointer to FACS table header
104 EFI_ACPI_DESCRIPTION_HEADER *Dsdt1; // Pointer to DSDT table header
105 EFI_ACPI_DESCRIPTION_HEADER *Dsdt3; // Pointer to DSDT table header
106 LIST_ENTRY TableList;
107 UINTN NumberOfTableEntries1; // Number of ACPI 1.0 tables
108 UINTN NumberOfTableEntries3; // Number of ACPI 3.0 tables
109 UINTN CurrentHandle;
110 EFI_ACPI_TABLE_PROTOCOL AcpiTableProtocol;
111 EFI_ACPI_SDT_PROTOCOL AcpiSdtProtocol;
112 LIST_ENTRY NotifyList;
113 } EFI_ACPI_TABLE_INSTANCE;
114
115 //
116 // ACPI table protocol instance containing record macro
117 //
118 #define EFI_ACPI_TABLE_INSTANCE_FROM_THIS(a) \
119 CR (a, \
120 EFI_ACPI_TABLE_INSTANCE, \
121 AcpiTableProtocol, \
122 EFI_ACPI_TABLE_SIGNATURE \
123 )
124
125 //
126 // Protocol Constructor functions
127 //
128
129 /**
130 Constructor for the ACPI support protocol. Initializes instance
131 data.
132
133 @param AcpiTableInstance Instance to construct
134
135 @return EFI_SUCCESS Instance initialized.
136 @return EFI_OUT_OF_RESOURCES Unable to allocate required resources.
137
138 **/
139 EFI_STATUS
140 AcpiTableAcpiTableConstructor (
141 EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance
142 );
143
144
145 /**
146 Entry point of the ACPI table driver.
147 Creates and initializes an instance of the ACPI Table
148 Protocol and installs it on a new handle.
149
150 @param ImageHandle A handle for the image that is initializing this driver
151 @param SystemTable A pointer to the EFI system table
152
153 @return EFI_SUCCESS Driver initialized successfully
154 @return EFI_LOAD_ERROR Failed to Initialize or has been loaded
155 @return EFI_OUT_OF_RESOURCES Could not allocate needed resources
156
157 **/
158 EFI_STATUS
159 EFIAPI
160 InitializeAcpiTableDxe (
161 IN EFI_HANDLE ImageHandle,
162 IN EFI_SYSTEM_TABLE *SystemTable
163 );
164
165 /**
166
167 This function finds the table specified by the handle and returns a pointer to it.
168 If the handle is not found, EFI_NOT_FOUND is returned and the contents of Table are
169 undefined.
170
171 @param[in] Handle Table to find.
172 @param[in] TableList Table list to search
173 @param[out] Table Pointer to table found.
174
175 @retval EFI_SUCCESS The function completed successfully.
176 @retval EFI_NOT_FOUND No table found matching the handle specified.
177
178 **/
179 EFI_STATUS
180 FindTableByHandle (
181 IN UINTN Handle,
182 IN LIST_ENTRY *TableList,
183 OUT EFI_ACPI_TABLE_LIST **Table
184 );
185
186 /**
187
188 This function calculates and updates an UINT8 checksum.
189
190 @param[in] Buffer Pointer to buffer to checksum
191 @param[in] Size Number of bytes to checksum
192 @param[in] ChecksumOffset Offset to place the checksum result in
193
194 @retval EFI_SUCCESS The function completed successfully.
195
196 **/
197 EFI_STATUS
198 AcpiPlatformChecksum (
199 IN VOID *Buffer,
200 IN UINTN Size,
201 IN UINTN ChecksumOffset
202 );
203
204 /**
205 This function invokes ACPI notification.
206
207 @param[in] AcpiTableInstance Instance to AcpiTable
208 @param[in] Version Version(s) to set.
209 @param[in] Handle Handle of the table.
210 **/
211 VOID
212 SdtNotifyAcpiList (
213 IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance,
214 IN EFI_ACPI_TABLE_VERSION Version,
215 IN UINTN Handle
216 );
217
218 /**
219 This function initializes AcpiSdt protocol in ACPI table instance.
220
221 @param[in] AcpiTableInstance Instance to construct
222 **/
223 VOID
224 SdtAcpiTableAcpiSdtConstructor (
225 IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance
226 );
227
228 //
229 // export PrivateData symbol, because we need that in AcpiSdtProtol implementation
230 //
231 extern EFI_HANDLE mHandle;
232 extern EFI_ACPI_TABLE_INSTANCE *mPrivateData;
233
234 #endif