TianoCore EDK2 master
Loading...
Searching...
No Matches
FirmwarePerformanceDxe.c
Go to the documentation of this file.
1
13#include <PiDxe.h>
14
16#include <Protocol/AcpiTable.h>
17#include <Protocol/LockBox.h>
18#include <Protocol/Variable.h>
19#include <Protocol/VariablePolicy.h>
20
21#include <Guid/Acpi.h>
23
26#include <Library/BaseLib.h>
27#include <Library/DebugLib.h>
29#include <Library/TimerLib.h>
32#include <Library/PcdLib.h>
33#include <Library/HobLib.h>
34#include <Library/LockBoxLib.h>
35#include <Library/UefiLib.h>
36#include <Library/VariablePolicyHelperLib.h>
38
39#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
40
41EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;
42
43BOOLEAN mLockBoxReady = FALSE;
44EFI_EVENT mReadyToBootEvent;
45EFI_EVENT mLegacyBootEvent;
46static EFI_EVENT mExitBootServicesEvent;
47UINTN mFirmwarePerformanceTableTemplateKey = 0;
48BOOLEAN mDxeCoreReportStatusCodeEnable = FALSE;
49
50BOOT_PERFORMANCE_TABLE *mAcpiBootPerformanceTable = NULL;
51BOOT_PERFORMANCE_TABLE *mReceivedAcpiBootPerformanceTable = NULL;
52S3_PERFORMANCE_TABLE *mAcpiS3PerformanceTable = NULL;
53
54FIRMWARE_PERFORMANCE_TABLE mFirmwarePerformanceTableTemplate = {
55 {
59 0x00, // Checksum will be updated at runtime
60 //
61 // It is expected that these values will be updated at EntryPoint.
62 //
63 { 0x00 }, // OEM ID is a 6 bytes long field
64 0x00, // OEM Table ID(8 bytes long)
65 0x00, // OEM Revision
66 0x00, // Creator ID
67 0x00, // Creator Revision
68 },
69 //
70 // Firmware Basic Boot Performance Table Pointer Record.
71 //
72 {
73 {
77 },
78 0, // Reserved
79 0 // BootPerformanceTablePointer will be updated at runtime.
80 },
81 //
82 // S3 Performance Table Pointer Record.
83 //
84 {
85 {
86 EFI_ACPI_5_0_FPDT_RECORD_TYPE_S3_PERFORMANCE_TABLE_POINTER, // Type
88 EFI_ACPI_5_0_FPDT_RECORD_REVISION_S3_PERFORMANCE_TABLE_POINTER // Revision
89 },
90 0, // Reserved
91 0 // S3PerformanceTablePointer will be updated at runtime.
92 }
93};
94
95BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate = {
96 {
99 },
100 {
101 {
102 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT, // Type
104 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT // Revision
105 },
106 0, // Reserved
107 //
108 // These values will be updated at runtime.
109 //
110 0, // ResetEnd
111 0, // OsLoaderLoadImageStart
112 0, // OsLoaderStartImageStart
113 0, // ExitBootServicesEntry
114 0 // ExitBootServicesExit
115 }
116};
117
118S3_PERFORMANCE_TABLE mS3PerformanceTableTemplate = {
119 {
121 sizeof (S3_PERFORMANCE_TABLE)
122 },
123 {
124 {
126 sizeof (EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD), // Length
128 },
129 //
130 // These values will be updated by Firmware Performance PEIM.
131 //
132 0, // ResumeCount
133 0, // FullResume
134 0 // AverageResume
135 },
136 {
137 {
138 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_SUSPEND, // Type
139 sizeof (EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD), // Length
140 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_SUSPEND // Revision
141 },
142 //
143 // These values will be updated bye Firmware Performance SMM driver.
144 //
145 0, // SuspendStart
146 0 // SuspendEnd
147 }
148};
149
157VOID
159 IN UINT8 *Buffer,
160 IN UINTN Size
161 )
162{
163 UINTN ChecksumOffset;
164
165 ChecksumOffset = OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Checksum);
166
167 //
168 // Set checksum to 0 first.
169 //
170 Buffer[ChecksumOffset] = 0;
171
172 //
173 // Update checksum value.
174 //
175 Buffer[ChecksumOffset] = CalculateCheckSum8 (Buffer, Size);
176}
177
185VOID
186EFIAPI
188 IN EFI_EVENT Event,
189 IN VOID *Context
190 )
191{
192 EFI_STATUS Status;
193 VOID *Interface;
194 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
195 UINTN Size;
196 EFI_PHYSICAL_ADDRESS S3PerformanceTablePointer;
197
198 if (mLockBoxReady && (mAcpiS3PerformanceTable != NULL)) {
199 //
200 // The memory for S3 performance table should have been ready,
201 // and the pointer should have been saved to LockBox, just return.
202 //
203 return;
204 }
205
206 if (!mLockBoxReady) {
207 Status = gBS->LocateProtocol (&gEfiLockBoxProtocolGuid, NULL, &Interface);
208 if (!EFI_ERROR (Status)) {
209 //
210 // LockBox services has been ready.
211 //
212 mLockBoxReady = TRUE;
213 }
214 }
215
216 if (mAcpiS3PerformanceTable == NULL) {
217 Status = gBS->LocateProtocol (&gEfiVariableArchProtocolGuid, NULL, &Interface);
218 if (!EFI_ERROR (Status)) {
219 //
220 // Try to allocate the same runtime buffer as last time boot.
221 //
222 ZeroMem (&PerformanceVariable, sizeof (PerformanceVariable));
223 Size = sizeof (PerformanceVariable);
224 Status = gRT->GetVariable (
225 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
226 &gEfiFirmwarePerformanceGuid,
227 NULL,
228 &Size,
229 &PerformanceVariable
230 );
231 if (!EFI_ERROR (Status)) {
232 Status = gBS->AllocatePages (
236 &PerformanceVariable.S3PerformanceTablePointer
237 );
238 if (!EFI_ERROR (Status)) {
239 mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *)(UINTN)PerformanceVariable.S3PerformanceTablePointer;
240 }
241 }
242
243 if (mAcpiS3PerformanceTable == NULL) {
244 //
245 // Fail to allocate at specified address, continue to allocate at any address.
246 //
247 mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *)AllocatePeiAccessiblePages (
250 );
251 }
252
253 DEBUG ((DEBUG_INFO, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable));
254 if (mAcpiS3PerformanceTable != NULL) {
255 CopyMem (mAcpiS3PerformanceTable, &mS3PerformanceTableTemplate, sizeof (mS3PerformanceTableTemplate));
256 }
257 }
258 }
259
260 if (mLockBoxReady && (mAcpiS3PerformanceTable != NULL)) {
261 //
262 // If LockBox services has been ready and memory for FPDT S3 performance table has been allocated,
263 // save the pointer to LockBox for use in S3 resume.
264 //
265 S3PerformanceTablePointer = (EFI_PHYSICAL_ADDRESS)(UINTN)mAcpiS3PerformanceTable;
266 Status = SaveLockBox (
267 &gFirmwarePerformanceS3PointerGuid,
268 &S3PerformanceTablePointer,
269 sizeof (EFI_PHYSICAL_ADDRESS)
270 );
271 ASSERT_EFI_ERROR (Status);
272 }
273}
274
283 VOID
284 )
285{
286 EFI_STATUS Status;
287 EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;
288 UINTN BootPerformanceDataSize;
289 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
290 UINTN Size;
291 EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicyProtocol;
292
293 //
294 // Get AcpiTable Protocol.
295 //
296 Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTableProtocol);
297 if (EFI_ERROR (Status)) {
298 return Status;
299 }
300
301 //
302 // Get VariablePolicy Protocol.
303 //
304 Status = gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL, (VOID **)&VariablePolicyProtocol);
305 if (EFI_ERROR (Status)) {
306 return Status;
307 }
308
309 if (mReceivedAcpiBootPerformanceTable != NULL) {
310 mAcpiBootPerformanceTable = mReceivedAcpiBootPerformanceTable;
311 mAcpiBootPerformanceTable->BasicBoot.ResetEnd = mBootPerformanceTableTemplate.BasicBoot.ResetEnd;
312 } else {
313 //
314 // Try to allocate the same runtime buffer as last time boot.
315 //
316 BootPerformanceDataSize = sizeof (BOOT_PERFORMANCE_TABLE);
317 ZeroMem (&PerformanceVariable, sizeof (PerformanceVariable));
318 Size = sizeof (PerformanceVariable);
319 Status = gRT->GetVariable (
320 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
321 &gEfiFirmwarePerformanceGuid,
322 NULL,
323 &Size,
324 &PerformanceVariable
325 );
326 if (!EFI_ERROR (Status)) {
327 Status = gBS->AllocatePages (
330 EFI_SIZE_TO_PAGES (BootPerformanceDataSize),
331 &PerformanceVariable.BootPerformanceTablePointer
332 );
333 if (!EFI_ERROR (Status)) {
334 mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *)(UINTN)PerformanceVariable.BootPerformanceTablePointer;
335 }
336 }
337
338 if (mAcpiBootPerformanceTable == NULL) {
339 //
340 // Fail to allocate at specified address, continue to allocate at any address.
341 //
342 mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *)AllocatePeiAccessiblePages (
344 EFI_SIZE_TO_PAGES (BootPerformanceDataSize)
345 );
346 }
347
348 DEBUG ((DEBUG_INFO, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));
349 if (mAcpiBootPerformanceTable == NULL) {
350 return EFI_OUT_OF_RESOURCES;
351 }
352
353 //
354 // Fill Basic Boot record to Boot Performance Table.
355 //
356 CopyMem (mAcpiBootPerformanceTable, &mBootPerformanceTableTemplate, sizeof (mBootPerformanceTableTemplate));
357 }
358
359 BootPerformanceDataSize = mAcpiBootPerformanceTable->Header.Length;
360
361 //
362 // Save Boot Performance Table address to Variable for use in S4 resume.
363 //
364 PerformanceVariable.BootPerformanceTablePointer = (EFI_PHYSICAL_ADDRESS)(UINTN)mAcpiBootPerformanceTable;
365 //
366 // Update Boot Performance Table Pointer in template.
367 //
368 mFirmwarePerformanceTableTemplate.BootPointerRecord.BootPerformanceTablePointer = (UINT64)(UINTN)mAcpiBootPerformanceTable;
369
370 //
371 // Save S3 Performance Table address to Variable for use in S4 resume.
372 //
373 PerformanceVariable.S3PerformanceTablePointer = (EFI_PHYSICAL_ADDRESS)(UINTN)mAcpiS3PerformanceTable;
374 //
375 // Update S3 Performance Table Pointer in template.
376 //
377 mFirmwarePerformanceTableTemplate.S3PointerRecord.S3PerformanceTablePointer = (UINT64)(UINTN)mAcpiS3PerformanceTable;
378 //
379 // Save Runtime Performance Table pointers to Variable.
380 // Don't check SetVariable return status. It doesn't impact FPDT table generation.
381 //
382 gRT->SetVariable (
383 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
384 &gEfiFirmwarePerformanceGuid,
385 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
386 sizeof (PerformanceVariable),
387 &PerformanceVariable
388 );
389
390 //
391 // Lock the variable which stores the Performance Table pointers.
392 //
393 Status = RegisterBasicVariablePolicy (
394 VariablePolicyProtocol,
395 &gEfiFirmwarePerformanceGuid,
396 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
397 VARIABLE_POLICY_NO_MIN_SIZE,
398 VARIABLE_POLICY_NO_MAX_SIZE,
399 VARIABLE_POLICY_NO_MUST_ATTR,
400 VARIABLE_POLICY_NO_CANT_ATTR,
401 VARIABLE_POLICY_TYPE_LOCK_NOW
402 );
403 if (EFI_ERROR (Status)) {
404 DEBUG ((DEBUG_ERROR, "[FirmwarePerformanceDxe] Error when lock variable %s, Status = %r\n", EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME, Status));
405 ASSERT_EFI_ERROR (Status);
406 }
407
408 //
409 // Publish Firmware Performance Data Table.
410 //
411 FpdtAcpiTableChecksum ((UINT8 *)&mFirmwarePerformanceTableTemplate, mFirmwarePerformanceTableTemplate.Header.Length);
412 Status = AcpiTableProtocol->InstallAcpiTable (
413 AcpiTableProtocol,
414 &mFirmwarePerformanceTableTemplate,
415 mFirmwarePerformanceTableTemplate.Header.Length,
416 &mFirmwarePerformanceTableTemplateKey
417 );
418 if (EFI_ERROR (Status)) {
419 if (mAcpiBootPerformanceTable != NULL) {
420 FreePages (mAcpiBootPerformanceTable, EFI_SIZE_TO_PAGES (BootPerformanceDataSize));
421 }
422
423 if (mAcpiS3PerformanceTable != NULL) {
424 FreePages (mAcpiS3PerformanceTable, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE)));
425 }
426
427 mAcpiBootPerformanceTable = NULL;
428 mAcpiS3PerformanceTable = NULL;
429 return Status;
430 }
431
432 return EFI_SUCCESS;
433}
434
455EFIAPI
457 IN EFI_STATUS_CODE_TYPE CodeType,
459 IN UINT32 Instance,
460 IN EFI_GUID *CallerId,
462 )
463{
464 EFI_STATUS Status;
465
466 //
467 // Check whether status code is what we are interested in.
468 //
469 if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) {
470 return EFI_UNSUPPORTED;
471 }
472
473 if (Value == (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT)) {
474 //
475 // DxeCore ReportStatusCode Enable so that the capability can be supported.
476 //
477 mDxeCoreReportStatusCodeEnable = TRUE;
478 }
479
480 Status = EFI_SUCCESS;
481 if (Value == PcdGet32 (PcdProgressCodeOsLoaderLoad)) {
482 //
483 // Progress code for OS Loader LoadImage.
484 //
485 if (mAcpiBootPerformanceTable == NULL) {
486 return Status;
487 }
488
489 //
490 // Update OS Loader LoadImage Start for UEFI boot.
491 //
493 } else if (Value == PcdGet32 (PcdProgressCodeOsLoaderStart)) {
494 //
495 // Progress code for OS Loader StartImage.
496 //
497 if (mAcpiBootPerformanceTable == NULL) {
498 return Status;
499 }
500
501 //
502 // Update OS Loader StartImage Start for UEFI boot.
503 //
505 } else if (Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) {
506 //
507 // Unregister boot time report status code listener.
508 //
509 mRscHandlerProtocol->Unregister (FpdtStatusCodeListenerDxe);
510
511 //
512 // Progress code for ExitBootServices.
513 //
514 if (mAcpiBootPerformanceTable == NULL) {
515 return Status;
516 }
517
518 //
519 // Update ExitBootServicesExit for UEFI boot.
520 //
522 } else if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT)) {
523 if (mAcpiBootPerformanceTable == NULL) {
524 //
525 // Firmware Performance Data Table not installed, do nothing.
526 //
527 return Status;
528 }
529
530 //
531 // Update Firmware Basic Boot Performance Record for legacy boot.
532 //
534
535 //
536 // Dump FPDT Boot Performance record.
537 //
538 DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd));
539 DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = 0\n"));
540 DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart));
541 DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = 0\n"));
542 DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - ExitBootServicesExit = 0\n"));
543 } else if ((Data != NULL) && CompareGuid (&Data->Type, &gEdkiiFpdtExtendedFirmwarePerformanceGuid)) {
544 //
545 // Get the Boot performance table and then install it to ACPI table.
546 //
547 CopyMem (&mReceivedAcpiBootPerformanceTable, Data + 1, Data->Size);
549 } else if ((Data != NULL) && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) {
550 DEBUG ((DEBUG_ERROR, "FpdtStatusCodeListenerDxe: Performance data reported through gEfiFirmwarePerformanceGuid will not be collected by FirmwarePerformanceDataTableDxe\n"));
551 Status = EFI_UNSUPPORTED;
552 } else {
553 //
554 // Ignore else progress code.
555 //
556 Status = EFI_UNSUPPORTED;
557 }
558
559 return Status;
560}
561
571VOID
572EFIAPI
574 IN EFI_EVENT Event,
575 IN VOID *Context
576 )
577{
578 //
579 // When performance is enabled, the FPDT will be installed when DxeCorePerformanceLib report the data to FimwarePerformanceDxe.
580 // This is used to install the FPDT for the basic boot recods when performance infrastructure is not enabled.
581 //
582 if ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0) {
583 return;
584 }
585
586 ASSERT (mReceivedAcpiBootPerformanceTable == NULL);
588}
589
598VOID
599EFIAPI
601 IN EFI_EVENT Event,
602 IN VOID *Context
603 )
604{
605 if (!mDxeCoreReportStatusCodeEnable) {
606 //
607 // When DxeCore Report Status Code is disabled,
608 // Unregister boot time report status code listener at ExitBootService Event.
609 //
610 mRscHandlerProtocol->Unregister (FpdtStatusCodeListenerDxe);
611 }
612
613 if (mAcpiBootPerformanceTable == NULL) {
614 //
615 // Firmware Performance Data Table not installed, do nothing.
616 //
617 return;
618 }
619
620 //
621 // Update Firmware Basic Boot Performance Record for UEFI boot.
622 //
624
625 //
626 // Dump FPDT Boot Performance record.
627 //
628 DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd));
629 DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderLoadImageStart));
630 DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart));
631 DEBUG ((DEBUG_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry));
632 //
633 // ExitBootServicesExit will be updated later, so don't dump it here.
634 //
635}
636
648EFIAPI
650 IN EFI_HANDLE ImageHandle,
651 IN EFI_SYSTEM_TABLE *SystemTable
652 )
653{
654 EFI_STATUS Status;
655 EFI_HOB_GUID_TYPE *GuidHob;
656 FIRMWARE_SEC_PERFORMANCE *Performance;
657 VOID *Registration;
658 UINT64 OemTableId;
659 EFI_EVENT EndOfDxeEvent;
660
661 CopyMem (
662 mFirmwarePerformanceTableTemplate.Header.OemId,
663 PcdGetPtr (PcdAcpiDefaultOemId),
664 sizeof (mFirmwarePerformanceTableTemplate.Header.OemId)
665 );
666 OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
667 CopyMem (&mFirmwarePerformanceTableTemplate.Header.OemTableId, &OemTableId, sizeof (UINT64));
668 mFirmwarePerformanceTableTemplate.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
669 mFirmwarePerformanceTableTemplate.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
670 mFirmwarePerformanceTableTemplate.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
671
672 //
673 // Get Report Status Code Handler Protocol.
674 //
675 Status = gBS->LocateProtocol (&gEfiRscHandlerProtocolGuid, NULL, (VOID **)&mRscHandlerProtocol);
676 ASSERT_EFI_ERROR (Status);
677
678 //
679 // Register report status code listener for OS Loader load and start.
680 //
681 Status = mRscHandlerProtocol->Register (FpdtStatusCodeListenerDxe, TPL_HIGH_LEVEL);
682 ASSERT_EFI_ERROR (Status);
683
684 //
685 // Register the notify function to install FPDT at EndOfDxe.
686 //
687 Status = gBS->CreateEventEx (
688 EVT_NOTIFY_SIGNAL,
689 TPL_NOTIFY,
691 NULL,
692 &gEfiEndOfDxeEventGroupGuid,
693 &EndOfDxeEvent
694 );
695 ASSERT_EFI_ERROR (Status);
696
697 //
698 // Register the notify function to update FPDT on ExitBootServices Event.
699 //
700 Status = gBS->CreateEventEx (
701 EVT_NOTIFY_SIGNAL,
702 TPL_NOTIFY,
704 NULL,
705 &gEfiEventExitBootServicesGuid,
706 &mExitBootServicesEvent
707 );
708 ASSERT_EFI_ERROR (Status);
709
710 //
711 // Retrieve GUID HOB data that contains the ResetEnd.
712 //
713 GuidHob = GetFirstGuidHob (&gEfiFirmwarePerformanceGuid);
714 if (GuidHob != NULL) {
715 Performance = (FIRMWARE_SEC_PERFORMANCE *)GET_GUID_HOB_DATA (GuidHob);
716 mBootPerformanceTableTemplate.BasicBoot.ResetEnd = Performance->ResetEnd;
717 } else {
718 //
719 // SEC Performance Data Hob not found, ResetEnd in ACPI FPDT table will be 0.
720 //
721 DEBUG ((DEBUG_WARN, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n"));
722 }
723
724 if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support)) {
725 //
726 // Register callback function upon VariableArchProtocol and LockBoxProtocol
727 // to allocate S3 performance table memory and save the pointer to LockBox.
728 //
730 &gEfiVariableArchProtocolGuid,
731 TPL_CALLBACK,
733 NULL,
734 &Registration
735 );
737 &gEfiLockBoxProtocolGuid,
738 TPL_CALLBACK,
740 NULL,
741 &Registration
742 );
743 } else {
744 //
745 // Exclude S3 Performance Table Pointer from FPDT table template.
746 //
747 mFirmwarePerformanceTableTemplate.Header.Length -= sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD);
748 }
749
750 return EFI_SUCCESS;
751}
UINT64 UINTN
#define EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE
Definition: Acpi50.h:1240
#define EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
Definition: Acpi50.h:1940
#define EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_REVISION
Definition: Acpi50.h:1117
#define EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_RESUME
Definition: Acpi50.h:1141
#define EFI_ACPI_5_0_FPDT_RECORD_TYPE_FIRMWARE_BASIC_BOOT_POINTER
Definition: Acpi50.h:1122
#define EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE
Definition: Acpi50.h:1225
#define EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_RESUME
Definition: Acpi50.h:1134
#define EFI_ACPI_5_0_FPDT_RECORD_REVISION_FIRMWARE_BASIC_BOOT_POINTER
Definition: Acpi50.h:1128
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
UINT64 EFIAPI GetPerformanceCounter(VOID)
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
UINT8 EFIAPI CalculateCheckSum8(IN CONST UINT8 *Buffer, IN UINTN Length)
Definition: CheckSum.c:71
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocatePeiAccessiblePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages)
Definition: Allocate.c:31
VOID EFIAPI FreePages(IN VOID *Buffer, IN UINTN Pages)
VOID EFIAPI FpdtEndOfDxeEventNotify(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS InstallFirmwarePerformanceDataTable(VOID)
VOID FpdtAcpiTableChecksum(IN UINT8 *Buffer, IN UINTN Size)
VOID EFIAPI FpdtExitBootServicesEventNotify(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI FpdtStatusCodeListenerDxe(IN EFI_STATUS_CODE_TYPE CodeType, IN EFI_STATUS_CODE_VALUE Value, IN UINT32 Instance, IN EFI_GUID *CallerId, IN EFI_STATUS_CODE_DATA *Data)
EFI_STATUS EFIAPI FirmwarePerformanceDxeEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID EFIAPI FpdtAllocateS3PerformanceTableMemory(IN EFI_EVENT Event, IN VOID *Context)
RETURN_STATUS EFIAPI SaveLockBox(IN GUID *Guid, IN VOID *Buffer, IN UINTN Length)
EFI_RUNTIME_SERVICES * gRT
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OFFSET_OF(TYPE, Field)
Definition: Base.h:758
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define PcdGet64(TokenName)
Definition: PcdLib.h:375
#define PcdGet8(TokenName)
Definition: PcdLib.h:336
#define PcdGet32(TokenName)
Definition: PcdLib.h:362
#define PcdGetPtr(TokenName)
Definition: PcdLib.h:388
#define FeaturePcdGet(TokenName)
Definition: PcdLib.h:50
#define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED
UINT32 EFI_STATUS_CODE_VALUE
Definition: PiStatusCode.h:67
#define EFI_PROGRESS_CODE
Definition: PiStatusCode.h:43
UINT32 EFI_STATUS_CODE_TYPE
Definition: PiStatusCode.h:24
#define EFI_STATUS_CODE_TYPE_MASK
Definition: PiStatusCode.h:32
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
#define EFI_SIZE_TO_PAGES(Size)
Definition: UefiBaseType.h:200
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_EVENT EFIAPI EfiCreateProtocolNotifyEvent(IN EFI_GUID *ProtocolGuid, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext OPTIONAL, OUT VOID **Registration)
Definition: UefiLib.c:134
@ EfiReservedMemoryType
#define EFI_VARIABLE_NON_VOLATILE
@ AllocateAddress
Definition: UefiSpec.h:42
EFI_ACPI_5_0_FPDT_PERFORMANCE_TABLE_HEADER Header
Common ACPI table header.
EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD BasicBoot
Basic Boot Resume performance record.
EFI_ACPI_DESCRIPTION_HEADER Header
Common ACPI description table header.
EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD S3PointerRecord
S3 Performance Table Pointer record.
EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_POINTER_RECORD BootPointerRecord
Basic Boot Performance Table Pointer record.
EFI_PHYSICAL_ADDRESS S3PerformanceTablePointer
Pointer to S3 Performance Table.
EFI_PHYSICAL_ADDRESS BootPerformanceTablePointer
Pointer to Boot Performance Table.
UINT64 ResetEnd
Timer value logged at the beginning of firmware image execution, in unit of nanosecond.
Definition: Base.h:213