TianoCore EDK2 master
Loading...
Searching...
No Matches
X64FadtGenerator.c
Go to the documentation of this file.
1
12#include <X64NameSpaceObjects.h>
14#include <Library/AcpiLib.h>
15#include <Library/DebugLib.h>
16#include <Protocol/AcpiTable.h>
17
18// Module specific include files.
19#include <AcpiTableGenerator.h>
24#include "FadtGenerator.h"
25
33 );
34
42 );
43
51 );
52
60 );
61
69 );
70
78 );
79
87 );
88
96 );
97
105 );
106
121EFIAPI
125 )
126{
127 EFI_STATUS Status;
128 CM_X64_FADT_SCI_INTERRUPT *SciInterrupt;
129 CM_X64_FADT_SCI_CMD_INFO *SciCmdinfo;
130 CM_X64_FADT_PM_BLOCK_INFO *PmBlockInfo;
131 CM_X64_FADT_GPE_BLOCK_INFO *GpeBlockInfo;
132 CM_X64_FADT_X_PM_BLOCK_INFO *XpmBlockInfo;
133 CM_X64_FADT_X_GPE_BLOCK_INFO *XgpeBlockInfo;
134 CM_X64_FADT_SLEEP_BLOCK_INFO *SleepBlockInfo;
135 CM_X64_FADT_RESET_BLOCK_INFO *ResetBlockInfo;
136 CM_X64_FADT_MISC_INFO *FadtMiscInfo;
137
138 ASSERT (CfgMgrProtocol != NULL);
139 ASSERT (Fadt != NULL);
140
141 // Get the SCI interrupt from the Platform Configuration Manager
142 Status = GetEX64ObjFadtSciInterrupt (
143 CfgMgrProtocol,
145 &SciInterrupt,
146 NULL
147 );
148 if (EFI_ERROR (Status)) {
149 DEBUG ((
150 DEBUG_ERROR,
151 "ERROR: FADT: Failed to get SCI Interrupt information." \
152 " Status = %r\n",
153 Status
154 ));
155 } else {
156 Fadt->SciInt = SciInterrupt->SciInterrupt;
157 }
158
159 // Get the SCI CMD information from the Platform Configuration Manager
160 Status = GetEX64ObjFadtSciCmdInfo (
161 CfgMgrProtocol,
163 &SciCmdinfo,
164 NULL
165 );
166 if (EFI_ERROR (Status)) {
167 DEBUG ((
168 DEBUG_ERROR,
169 "ERROR: FADT: Failed to get SCI CMD information." \
170 " Status = %r\n",
171 Status
172 ));
173 } else {
174 Fadt->SmiCmd = SciCmdinfo->SciCmd;
175 Fadt->AcpiEnable = SciCmdinfo->AcpiEnable;
176 Fadt->AcpiDisable = SciCmdinfo->AcpiDisable;
177 Fadt->S4BiosReq = SciCmdinfo->S4BiosReq;
178 Fadt->PstateCnt = SciCmdinfo->PstateCnt;
179 Fadt->CstCnt = SciCmdinfo->CstCnt;
180 }
181
182 // Get the SCI PM Block information from the Platform Configuration Manager
183 Status = GetEX64ObjFadtPmBlockInfo (
184 CfgMgrProtocol,
186 &PmBlockInfo,
187 NULL
188 );
189 if (EFI_ERROR (Status)) {
190 DEBUG ((
191 DEBUG_ERROR,
192 "ERROR: FADT: Failed to get PM Block information." \
193 " Status = %r\n",
194 Status
195 ));
196 } else {
197 Fadt->Pm1aEvtBlk = PmBlockInfo->Pm1aEvtBlk;
198 Fadt->Pm1bEvtBlk = PmBlockInfo->Pm1bEvtBlk;
199 Fadt->Pm1aCntBlk = PmBlockInfo->Pm1aCntBlk;
200 Fadt->Pm1bCntBlk = PmBlockInfo->Pm1bCntBlk;
201 Fadt->Pm2CntBlk = PmBlockInfo->Pm2CntBlk;
202 Fadt->PmTmrBlk = PmBlockInfo->PmTmrBlk;
203 Fadt->Pm1EvtLen = PmBlockInfo->Pm1EvtLen;
204 Fadt->Pm1CntLen = PmBlockInfo->Pm1CntLen;
205 Fadt->Pm2CntLen = PmBlockInfo->Pm2CntLen;
206 Fadt->PmTmrLen = PmBlockInfo->PmTmrLen;
207 }
208
209 // Get the SCI PM Block information from the Platform Configuration Manager
210 Status = GetEX64ObjFadtGpeBlockInfo (
211 CfgMgrProtocol,
213 &GpeBlockInfo,
214 NULL
215 );
216 if (EFI_ERROR (Status)) {
217 DEBUG ((
218 DEBUG_ERROR,
219 "ERROR: FADT: Failed to get PM Block information." \
220 " Status = %r\n",
221 Status
222 ));
223 } else {
224 Fadt->Gpe0Blk = GpeBlockInfo->Gpe0Blk;
225 Fadt->Gpe1Blk = GpeBlockInfo->Gpe1Blk;
226 Fadt->Gpe0BlkLen = GpeBlockInfo->Gpe0BlkLen;
227 Fadt->Gpe1BlkLen = GpeBlockInfo->Gpe1BlkLen;
228 Fadt->Gpe1Base = GpeBlockInfo->Gpe1Base;
229 }
230
231 // Get the 64-bit PM Block information from the Platform Configuration Manager
232 Status = GetEX64ObjFadtXpmBlockInfo (
233 CfgMgrProtocol,
235 &XpmBlockInfo,
236 NULL
237 );
238 if (EFI_ERROR (Status)) {
239 DEBUG ((
240 DEBUG_ERROR,
241 "ERROR: FADT: Failed to get 64-bit PM Block information." \
242 " Status = %r\n",
243 Status
244 ));
245 } else {
246 CopyMem (
247 &Fadt->XPm1aEvtBlk,
248 &XpmBlockInfo->XPm1aEvtBlk,
250 );
251 CopyMem (
252 &Fadt->XPm1bEvtBlk,
253 &XpmBlockInfo->XPm1bEvtBlk,
255 );
256 CopyMem (
257 &Fadt->XPm1aCntBlk,
258 &XpmBlockInfo->XPm1aCntBlk,
260 );
261 CopyMem (
262 &Fadt->XPm1bCntBlk,
263 &XpmBlockInfo->XPm1bCntBlk,
265 );
266 CopyMem (
267 &Fadt->XPm2CntBlk,
268 &XpmBlockInfo->XPm2CntBlk,
270 );
271 CopyMem (
272 &Fadt->XPmTmrBlk,
273 &XpmBlockInfo->XPmTmrBlk,
275 );
276 }
277
278 // Get the various platform information from the Platform Configuration manager
279 Status = GetEX64ObjFadtMiscInfo (
280 CfgMgrProtocol,
282 &FadtMiscInfo,
283 NULL
284 );
285 if (EFI_ERROR (Status)) {
286 DEBUG ((
287 DEBUG_ERROR,
288 "ERROR: FADT: Failed to get various platform information." \
289 " Status = %r\n",
290 Status
291 ));
292 } else {
293 Fadt->PLvl2Lat = FadtMiscInfo->PLvl2Lat;
294 Fadt->PLvl3Lat = FadtMiscInfo->PLvl3Lat;
295 Fadt->FlushSize = FadtMiscInfo->FlushSize;
296 Fadt->FlushStride = FadtMiscInfo->FlushStride;
297 Fadt->DutyOffset = FadtMiscInfo->DutyOffset;
298 Fadt->DutyWidth = FadtMiscInfo->DutyWidth;
299 Fadt->DayAlrm = FadtMiscInfo->DayAlrm;
300 Fadt->MonAlrm = FadtMiscInfo->MonAlrm;
301 Fadt->Century = FadtMiscInfo->Century;
302 }
303
304 // Get the 64-bit GPE Block information from the Platform Configuration Manager
305 Status = GetEX64ObjFadtXgpeBlockInfo (
306 CfgMgrProtocol,
308 &XgpeBlockInfo,
309 NULL
310 );
311 if (EFI_ERROR (Status)) {
312 DEBUG ((
313 DEBUG_ERROR,
314 "ERROR: FADT: Failed to get 64-bit GPE Block information." \
315 " Status = %r\n",
316 Status
317 ));
318 } else {
319 CopyMem (
320 &Fadt->XGpe0Blk,
321 &XgpeBlockInfo->XGpe0Blk,
323 );
324 CopyMem (
325 &Fadt->XGpe1Blk,
326 &XgpeBlockInfo->XGpe1Blk,
328 );
329 }
330
331 // Get the sleep Block information from the Platform Configuration Manager
332 Status = GetEX64ObjFadtSleepBlockInfo (
333 CfgMgrProtocol,
335 &SleepBlockInfo,
336 NULL
337 );
338 if (EFI_ERROR (Status)) {
339 DEBUG ((
340 DEBUG_ERROR,
341 "ERROR: FADT: Failed to get Sleep Block information." \
342 " Status = %r\n",
343 Status
344 ));
345 } else {
346 CopyMem (
347 &Fadt->SleepControlReg,
348 &SleepBlockInfo->SleepControlReg,
350 );
351 CopyMem (
352 &Fadt->SleepStatusReg,
353 &SleepBlockInfo->SleepStatusReg,
355 );
356 }
357
358 // Get the sleep Block information from the Platform Configuration Manager
359 Status = GetEX64ObjFadtResetBlockInfo (
360 CfgMgrProtocol,
362 &ResetBlockInfo,
363 NULL
364 );
365 if (EFI_ERROR (Status)) {
366 DEBUG ((
367 DEBUG_ERROR,
368 "ERROR: FADT: Failed to get Reset Block information." \
369 " Status = %r\n",
370 Status
371 ));
372 } else {
373 CopyMem (
374 &Fadt->ResetReg,
375 &ResetBlockInfo->ResetReg,
377 );
378 Fadt->ResetValue = ResetBlockInfo->ResetValue;
379 }
380
381 return Status;
382}
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type)
@ EObjNameSpaceX64
X64 Objects Namespace.
#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 CM_NULL_TOKEN
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
EFI_STATUS EFIAPI FadtArchUpdate(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN OUT EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *Fadt)
@ EX64ObjFadtPmBlockInfo
3 - FADT Power management block info
@ EX64ObjFadtXpmBlockInfo
5 - FADT 64-bit Power Management block info
@ EX64ObjFadtResetBlockInfo
8 - FADT Reset block info
@ EX64ObjFadtSleepBlockInfo
7 - FADT Sleep block info
@ EX64ObjFadtSciInterrupt
1 - FADT SCI Interrupt information
@ EX64ObjFadtSciCmdInfo
2 - FADT SCI CMD information
@ EX64ObjFadtGpeBlockInfo
4 - FADT GPE block info
@ EX64ObjFadtMiscInfo
9 - FADT Legacy fields info
@ EX64ObjFadtXgpeBlockInfo
6 - FADT 64-bit GPE block info
EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XGpe0Blk
EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk