TianoCore EDK2 master
Loading...
Searching...
No Matches
AcpiTableFactory.c
Go to the documentation of this file.
1
12#include <Library/BaseLib.h>
14#include <Library/DebugLib.h>
15#include <Protocol/AcpiTable.h>
16
17// Module specific include files.
18#include <AcpiTableGenerator.h>
22
23#include "DynamicTableFactory.h"
24
26
41EFIAPI
46 )
47{
48 UINT16 TableId;
50
51 ASSERT (This != NULL);
52
53 FactoryInfo = This->TableFactoryInfo;
54
55 if (Generator == NULL) {
56 DEBUG ((DEBUG_ERROR, "ERROR: Invalid Generator pointer\n"));
57 return EFI_INVALID_PARAMETER;
58 }
59
60 if (!IS_GENERATOR_TYPE_ACPI (GeneratorId)) {
61 DEBUG ((DEBUG_ERROR, "ERROR: Generator Type is not ACPI\n"));
62 return EFI_INVALID_PARAMETER;
63 }
64
65 *Generator = NULL;
66 TableId = GET_TABLE_ID (GeneratorId);
67 if (IS_GENERATOR_NAMESPACE_STD (GeneratorId)) {
68 if (TableId >= EStdAcpiTableIdMax) {
69 ASSERT (TableId < EStdAcpiTableIdMax);
70 return EFI_INVALID_PARAMETER;
71 }
72
73 if (FactoryInfo->StdAcpiTableGeneratorList[TableId] != NULL) {
74 *Generator = FactoryInfo->StdAcpiTableGeneratorList[TableId];
75 } else {
76 return EFI_NOT_FOUND;
77 }
78 } else {
79 if (TableId > FixedPcdGet16 (PcdMaxCustomACPIGenerators)) {
80 ASSERT (TableId <= FixedPcdGet16 (PcdMaxCustomACPIGenerators));
81 return EFI_INVALID_PARAMETER;
82 }
83
84 if (FactoryInfo->CustomAcpiTableGeneratorList[TableId] != NULL) {
85 *Generator = FactoryInfo->CustomAcpiTableGeneratorList[TableId];
86 } else {
87 return EFI_NOT_FOUND;
88 }
89 }
90
91 return EFI_SUCCESS;
92}
93
109EFIAPI
112 )
113{
114 UINT16 TableId;
115
116 if (Generator == NULL) {
117 DEBUG ((DEBUG_ERROR, "ERROR: ACPI register - Invalid Generator\n"));
118 return EFI_INVALID_PARAMETER;
119 }
120
121 if (!IS_GENERATOR_TYPE_ACPI (Generator->GeneratorID)) {
122 DEBUG ((
123 DEBUG_ERROR,
124 "ERROR: ACPI register - Generator" \
125 " Type is not ACPI\n"
126 ));
127 return EFI_INVALID_PARAMETER;
128 }
129
130 DEBUG ((DEBUG_INFO, "Registering %s\n", Generator->Description));
131
132 TableId = GET_TABLE_ID (Generator->GeneratorID);
133 if (IS_GENERATOR_NAMESPACE_STD (Generator->GeneratorID)) {
134 if (TableId >= EStdAcpiTableIdMax) {
135 ASSERT (TableId < EStdAcpiTableIdMax);
136 return EFI_INVALID_PARAMETER;
137 }
138
141 } else {
142 return EFI_ALREADY_STARTED;
143 }
144 } else {
145 if (TableId > FixedPcdGet16 (PcdMaxCustomACPIGenerators)) {
146 ASSERT (TableId <= FixedPcdGet16 (PcdMaxCustomACPIGenerators));
147 return EFI_INVALID_PARAMETER;
148 }
149
152 } else {
153 return EFI_ALREADY_STARTED;
154 }
155 }
156
157 return EFI_SUCCESS;
158}
159
173EFIAPI
176 )
177{
178 UINT16 TableId;
179
180 if (Generator == NULL) {
181 DEBUG ((DEBUG_ERROR, "ERROR: ACPI deregister - Invalid Generator\n"));
182 return EFI_INVALID_PARAMETER;
183 }
184
185 if (!IS_GENERATOR_TYPE_ACPI (Generator->GeneratorID)) {
186 DEBUG ((
187 DEBUG_ERROR,
188 "ERROR: ACPI deregister - Generator" \
189 " Type is not ACPI\n"
190 ));
191 return EFI_INVALID_PARAMETER;
192 }
193
194 TableId = GET_TABLE_ID (Generator->GeneratorID);
195 if (IS_GENERATOR_NAMESPACE_STD (Generator->GeneratorID)) {
196 if (TableId >= EStdAcpiTableIdMax) {
197 ASSERT (TableId < EStdAcpiTableIdMax);
198 return EFI_INVALID_PARAMETER;
199 }
200
203 return EFI_INVALID_PARAMETER;
204 }
205
207 } else {
208 return EFI_NOT_FOUND;
209 }
210 } else {
211 if (TableId > FixedPcdGet16 (PcdMaxCustomACPIGenerators)) {
212 ASSERT (TableId <= FixedPcdGet16 (PcdMaxCustomACPIGenerators));
213 return EFI_INVALID_PARAMETER;
214 }
215
217 if (Generator !=
219 {
220 return EFI_INVALID_PARAMETER;
221 }
222
224 } else {
225 return EFI_NOT_FOUND;
226 }
227 }
228
229 DEBUG ((DEBUG_INFO, "Deregistering %s\n", Generator->Description));
230 return EFI_SUCCESS;
231}
EFI_STATUS EFIAPI GetAcpiTableGenerator(IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST This, IN CONST ACPI_TABLE_GENERATOR_ID GeneratorId, OUT CONST ACPI_TABLE_GENERATOR **CONST Generator)
EDKII_DYNAMIC_TABLE_FACTORY_INFO TableFactoryInfo
EFI_STATUS EFIAPI RegisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
EFI_STATUS EFIAPI DeregisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
#define IS_GENERATOR_TYPE_ACPI(TableGeneratorId)
TABLE_GENERATOR_ID ACPI_TABLE_GENERATOR_ID
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define FixedPcdGet16(TokenName)
Definition: PcdLib.h:78
#define GET_TABLE_ID(TableGeneratorId)
#define IS_GENERATOR_NAMESPACE_STD(TableGeneratorId)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
CONST ACPI_TABLE_GENERATOR * StdAcpiTableGeneratorList[EStdAcpiTableIdMax]
An array for holding the list of Standard ACPI Table Generators.
CONST ACPI_TABLE_GENERATOR * CustomAcpiTableGeneratorList[FixedPcdGet16(PcdMaxCustomACPIGenerators)]
An array for holding the list of Custom ACPI Table Generators.