TianoCore EDK2 master
Loading...
Searching...
No Matches
DeviceTreeTableFactory.c
Go to the documentation of this file.
1
12#include <Library/BaseLib.h>
14#include <Library/DebugLib.h>
15
16// Module specific include files.
21
22#include "DynamicTableFactory.h"
23
25
40EFIAPI
43 IN CONST DT_TABLE_GENERATOR_ID GeneratorId,
45 )
46{
47 UINT16 TableId;
49
50 ASSERT (This != NULL);
51
52 FactoryInfo = This->TableFactoryInfo;
53
54 if (Generator == NULL) {
55 DEBUG ((DEBUG_ERROR, "ERROR: Invalid Generator pointer\n"));
56 return EFI_INVALID_PARAMETER;
57 }
58
59 if (!IS_GENERATOR_TYPE_DT (GeneratorId)) {
60 DEBUG ((DEBUG_ERROR, "ERROR: Generator Type is not DT\n"));
61 return EFI_INVALID_PARAMETER;
62 }
63
64 *Generator = NULL;
65 TableId = GET_TABLE_ID (GeneratorId);
66 if (IS_GENERATOR_NAMESPACE_STD (GeneratorId)) {
67 if (TableId >= EStdDtTableIdMax) {
68 ASSERT (TableId < EStdDtTableIdMax);
69 return EFI_INVALID_PARAMETER;
70 }
71
72 if (FactoryInfo->StdDtTableGeneratorList[TableId] != NULL) {
73 *Generator = FactoryInfo->StdDtTableGeneratorList[TableId];
74 } else {
75 return EFI_NOT_FOUND;
76 }
77 } else {
78 if (TableId > FixedPcdGet16 (PcdMaxCustomDTGenerators)) {
79 ASSERT (TableId <= FixedPcdGet16 (PcdMaxCustomDTGenerators));
80 return EFI_INVALID_PARAMETER;
81 }
82
83 if (FactoryInfo->CustomDtTableGeneratorList[TableId] != NULL) {
84 *Generator = FactoryInfo->CustomDtTableGeneratorList[TableId];
85 } else {
86 return EFI_NOT_FOUND;
87 }
88 }
89
90 return EFI_SUCCESS;
91}
92
108EFIAPI
111 )
112{
113 UINT16 TableId;
114
115 if (Generator == NULL) {
116 DEBUG ((DEBUG_ERROR, "ERROR: DT register - Invalid Generator\n"));
117 return EFI_INVALID_PARAMETER;
118 }
119
120 if (!IS_GENERATOR_TYPE_DT (Generator->GeneratorID)) {
121 DEBUG ((
122 DEBUG_ERROR,
123 "ERROR: DT register - Generator" \
124 " Type is not DT\n"
125 ));
126 return EFI_INVALID_PARAMETER;
127 }
128
129 DEBUG ((DEBUG_INFO, "Registering %s\n", Generator->Description));
130
131 TableId = GET_TABLE_ID (Generator->GeneratorID);
132 if (IS_GENERATOR_NAMESPACE_STD (Generator->GeneratorID)) {
133 if (TableId >= EStdDtTableIdMax) {
134 ASSERT (TableId < EStdDtTableIdMax);
135 return EFI_INVALID_PARAMETER;
136 }
137
140 } else {
141 return EFI_ALREADY_STARTED;
142 }
143 } else {
144 if (TableId > FixedPcdGet16 (PcdMaxCustomDTGenerators)) {
145 ASSERT (TableId <= FixedPcdGet16 (PcdMaxCustomDTGenerators));
146 return EFI_INVALID_PARAMETER;
147 }
148
151 } else {
152 return EFI_ALREADY_STARTED;
153 }
154 }
155
156 return EFI_SUCCESS;
157}
158
172EFIAPI
175 )
176{
177 UINT16 TableId;
178
179 if (Generator == NULL) {
180 DEBUG ((DEBUG_ERROR, "ERROR: DT deregister - Invalid Generator\n"));
181 return EFI_INVALID_PARAMETER;
182 }
183
184 if (!IS_GENERATOR_TYPE_DT (Generator->GeneratorID)) {
185 DEBUG ((
186 DEBUG_ERROR,
187 "ERROR: DT deregister - Generator" \
188 " Type is not DT\n"
189 ));
190 return EFI_INVALID_PARAMETER;
191 }
192
193 TableId = GET_TABLE_ID (Generator->GeneratorID);
194 if (IS_GENERATOR_NAMESPACE_STD (Generator->GeneratorID)) {
195 if (TableId >= EStdDtTableIdMax) {
196 ASSERT (TableId < EStdDtTableIdMax);
197 return EFI_INVALID_PARAMETER;
198 }
199
202 return EFI_INVALID_PARAMETER;
203 }
204
206 } else {
207 return EFI_NOT_FOUND;
208 }
209 } else {
210 if (TableId > FixedPcdGet16 (PcdMaxCustomDTGenerators)) {
211 ASSERT (TableId <= FixedPcdGet16 (PcdMaxCustomDTGenerators));
212 return EFI_INVALID_PARAMETER;
213 }
214
216 if (Generator !=
218 {
219 return EFI_INVALID_PARAMETER;
220 }
221
223 } else {
224 return EFI_NOT_FOUND;
225 }
226 }
227
228 DEBUG ((DEBUG_INFO, "Deregistering %s\n", Generator->Description));
229 return EFI_SUCCESS;
230}
EFI_STATUS EFIAPI RegisterDtTableGenerator(IN CONST DT_TABLE_GENERATOR *CONST Generator)
EDKII_DYNAMIC_TABLE_FACTORY_INFO TableFactoryInfo
EFI_STATUS EFIAPI GetDtTableGenerator(IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST This, IN CONST DT_TABLE_GENERATOR_ID GeneratorId, OUT CONST DT_TABLE_GENERATOR **CONST Generator)
EFI_STATUS EFIAPI DeregisterDtTableGenerator(IN CONST DT_TABLE_GENERATOR *CONST Generator)
TABLE_GENERATOR_ID DT_TABLE_GENERATOR_ID
#define IS_GENERATOR_TYPE_DT(TableGeneratorId)
#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 DT_TABLE_GENERATOR * StdDtTableGeneratorList[EStdDtTableIdMax]
An array for holding the list of Standard DT Table Generators.
CONST DT_TABLE_GENERATOR * CustomDtTableGeneratorList[FixedPcdGet16(PcdMaxCustomDTGenerators)]
An array for holding the list of Custom DT Table Generators.