2 This module install ACPI Firmware Performance Data Table (FPDT).
4 This module register report status code listener to collect performance data
5 for Firmware Basic Boot Performance Record and other boot performance records,
6 and install FPDT to ACPI table.
8 Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.<BR>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
15 #include <Protocol/ReportStatusCodeHandler.h>
16 #include <Protocol/AcpiTable.h>
17 #include <Protocol/LockBox.h>
18 #include <Protocol/Variable.h>
19 #include <Protocol/VariablePolicy.h>
21 #include <Guid/Acpi.h>
22 #include <Guid/FirmwarePerformance.h>
24 #include <Library/UefiBootServicesTableLib.h>
25 #include <Library/UefiRuntimeServicesTableLib.h>
26 #include <Library/BaseLib.h>
27 #include <Library/DebugLib.h>
28 #include <Library/DxeServicesLib.h>
29 #include <Library/TimerLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/MemoryAllocationLib.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>
37 #include <Library/PerformanceLib.h>
39 #define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
41 EFI_RSC_HANDLER_PROTOCOL
*mRscHandlerProtocol
= NULL
;
43 BOOLEAN mLockBoxReady
= FALSE
;
44 EFI_EVENT mReadyToBootEvent
;
45 EFI_EVENT mLegacyBootEvent
;
46 static EFI_EVENT mExitBootServicesEvent
;
47 UINTN mFirmwarePerformanceTableTemplateKey
= 0;
48 BOOLEAN mDxeCoreReportStatusCodeEnable
= FALSE
;
50 BOOT_PERFORMANCE_TABLE
*mAcpiBootPerformanceTable
= NULL
;
51 BOOT_PERFORMANCE_TABLE
*mReceivedAcpiBootPerformanceTable
= NULL
;
52 S3_PERFORMANCE_TABLE
*mAcpiS3PerformanceTable
= NULL
;
54 FIRMWARE_PERFORMANCE_TABLE mFirmwarePerformanceTableTemplate
= {
56 EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
,
57 sizeof (FIRMWARE_PERFORMANCE_TABLE
),
58 EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_REVISION
, // Revision
59 0x00, // Checksum will be updated at runtime
61 // It is expected that these values will be updated at EntryPoint.
63 { 0x00 }, // OEM ID is a 6 bytes long field
64 0x00, // OEM Table ID(8 bytes long)
67 0x00, // Creator Revision
70 // Firmware Basic Boot Performance Table Pointer Record.
74 EFI_ACPI_5_0_FPDT_RECORD_TYPE_FIRMWARE_BASIC_BOOT_POINTER
, // Type
75 sizeof (EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_POINTER_RECORD
), // Length
76 EFI_ACPI_5_0_FPDT_RECORD_REVISION_FIRMWARE_BASIC_BOOT_POINTER
// Revision
79 0 // BootPerformanceTablePointer will be updated at runtime.
82 // S3 Performance Table Pointer Record.
86 EFI_ACPI_5_0_FPDT_RECORD_TYPE_S3_PERFORMANCE_TABLE_POINTER
, // Type
87 sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD
), // Length
88 EFI_ACPI_5_0_FPDT_RECORD_REVISION_S3_PERFORMANCE_TABLE_POINTER
// Revision
91 0 // S3PerformanceTablePointer will be updated at runtime.
95 BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate
= {
97 EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE
,
98 sizeof (BOOT_PERFORMANCE_TABLE
)
102 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT
, // Type
103 sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD
), // Length
104 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT
// Revision
108 // These values will be updated at runtime.
111 0, // OsLoaderLoadImageStart
112 0, // OsLoaderStartImageStart
113 0, // ExitBootServicesEntry
114 0 // ExitBootServicesExit
118 S3_PERFORMANCE_TABLE mS3PerformanceTableTemplate
= {
120 EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE
,
121 sizeof (S3_PERFORMANCE_TABLE
)
125 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_RESUME
, // Type
126 sizeof (EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD
), // Length
127 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_RESUME
// Revision
130 // These values will be updated by Firmware Performance PEIM.
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
143 // These values will be updated bye Firmware Performance SMM driver.
151 This function calculates and updates an UINT8 checksum.
153 @param[in] Buffer Pointer to buffer to checksum
154 @param[in] Size Number of bytes to checksum
158 FpdtAcpiTableChecksum (
163 UINTN ChecksumOffset
;
165 ChecksumOffset
= OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
, Checksum
);
168 // Set checksum to 0 first.
170 Buffer
[ChecksumOffset
] = 0;
173 // Update checksum value.
175 Buffer
[ChecksumOffset
] = CalculateCheckSum8 (Buffer
, Size
);
179 Callback function upon VariableArchProtocol and LockBoxProtocol
180 to allocate S3 performance table memory and save the pointer to LockBox.
182 @param[in] Event Event whose notification function is being invoked.
183 @param[in] Context Pointer to the notification function's context.
187 FpdtAllocateS3PerformanceTableMemory (
194 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
196 EFI_PHYSICAL_ADDRESS S3PerformanceTablePointer
;
198 if (mLockBoxReady
&& (mAcpiS3PerformanceTable
!= NULL
)) {
200 // The memory for S3 performance table should have been ready,
201 // and the pointer should have been saved to LockBox, just return.
206 if (!mLockBoxReady
) {
207 Status
= gBS
->LocateProtocol (&gEfiLockBoxProtocolGuid
, NULL
, &Interface
);
208 if (!EFI_ERROR (Status
)) {
210 // LockBox services has been ready.
212 mLockBoxReady
= TRUE
;
216 if (mAcpiS3PerformanceTable
== NULL
) {
217 Status
= gBS
->LocateProtocol (&gEfiVariableArchProtocolGuid
, NULL
, &Interface
);
218 if (!EFI_ERROR (Status
)) {
220 // Try to allocate the same runtime buffer as last time boot.
222 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
223 Size
= sizeof (PerformanceVariable
);
224 Status
= gRT
->GetVariable (
225 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
226 &gEfiFirmwarePerformanceGuid
,
231 if (!EFI_ERROR (Status
)) {
232 Status
= gBS
->AllocatePages (
234 EfiReservedMemoryType
,
235 EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
)),
236 &PerformanceVariable
.S3PerformanceTablePointer
238 if (!EFI_ERROR (Status
)) {
239 mAcpiS3PerformanceTable
= (S3_PERFORMANCE_TABLE
*)(UINTN
)PerformanceVariable
.S3PerformanceTablePointer
;
243 if (mAcpiS3PerformanceTable
== NULL
) {
245 // Fail to allocate at specified address, continue to allocate at any address.
247 mAcpiS3PerformanceTable
= (S3_PERFORMANCE_TABLE
*)AllocatePeiAccessiblePages (
248 EfiReservedMemoryType
,
249 EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
))
253 DEBUG ((DEBUG_INFO
, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable
));
254 if (mAcpiS3PerformanceTable
!= NULL
) {
255 CopyMem (mAcpiS3PerformanceTable
, &mS3PerformanceTableTemplate
, sizeof (mS3PerformanceTableTemplate
));
260 if (mLockBoxReady
&& (mAcpiS3PerformanceTable
!= NULL
)) {
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.
265 S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)mAcpiS3PerformanceTable
;
266 Status
= SaveLockBox (
267 &gFirmwarePerformanceS3PointerGuid
,
268 &S3PerformanceTablePointer
,
269 sizeof (EFI_PHYSICAL_ADDRESS
)
271 ASSERT_EFI_ERROR (Status
);
276 Install ACPI Firmware Performance Data Table (FPDT).
282 InstallFirmwarePerformanceDataTable (
287 EFI_ACPI_TABLE_PROTOCOL
*AcpiTableProtocol
;
288 UINTN BootPerformanceDataSize
;
289 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
291 EDKII_VARIABLE_POLICY_PROTOCOL
*VariablePolicyProtocol
;
294 // Get AcpiTable Protocol.
296 Status
= gBS
->LocateProtocol (&gEfiAcpiTableProtocolGuid
, NULL
, (VOID
**)&AcpiTableProtocol
);
297 if (EFI_ERROR (Status
)) {
302 // Get VariablePolicy Protocol.
304 Status
= gBS
->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid
, NULL
, (VOID
**)&VariablePolicyProtocol
);
305 if (EFI_ERROR (Status
)) {
309 if (mReceivedAcpiBootPerformanceTable
!= NULL
) {
310 mAcpiBootPerformanceTable
= mReceivedAcpiBootPerformanceTable
;
311 mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
= mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
;
314 // Try to allocate the same runtime buffer as last time boot.
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
,
326 if (!EFI_ERROR (Status
)) {
327 Status
= gBS
->AllocatePages (
329 EfiReservedMemoryType
,
330 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
),
331 &PerformanceVariable
.BootPerformanceTablePointer
333 if (!EFI_ERROR (Status
)) {
334 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*)(UINTN
)PerformanceVariable
.BootPerformanceTablePointer
;
338 if (mAcpiBootPerformanceTable
== NULL
) {
340 // Fail to allocate at specified address, continue to allocate at any address.
342 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*)AllocatePeiAccessiblePages (
343 EfiReservedMemoryType
,
344 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
)
348 DEBUG ((DEBUG_INFO
, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable
));
349 if (mAcpiBootPerformanceTable
== NULL
) {
350 return EFI_OUT_OF_RESOURCES
;
354 // Fill Basic Boot record to Boot Performance Table.
356 CopyMem (mAcpiBootPerformanceTable
, &mBootPerformanceTableTemplate
, sizeof (mBootPerformanceTableTemplate
));
359 BootPerformanceDataSize
= mAcpiBootPerformanceTable
->Header
.Length
;
362 // Save Boot Performance Table address to Variable for use in S4 resume.
364 PerformanceVariable
.BootPerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)mAcpiBootPerformanceTable
;
366 // Update Boot Performance Table Pointer in template.
368 mFirmwarePerformanceTableTemplate
.BootPointerRecord
.BootPerformanceTablePointer
= (UINT64
)(UINTN
)mAcpiBootPerformanceTable
;
371 // Save S3 Performance Table address to Variable for use in S4 resume.
373 PerformanceVariable
.S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)mAcpiS3PerformanceTable
;
375 // Update S3 Performance Table Pointer in template.
377 mFirmwarePerformanceTableTemplate
.S3PointerRecord
.S3PerformanceTablePointer
= (UINT64
)(UINTN
)mAcpiS3PerformanceTable
;
379 // Save Runtime Performance Table pointers to Variable.
380 // Don't check SetVariable return status. It doesn't impact FPDT table generation.
383 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
384 &gEfiFirmwarePerformanceGuid
,
385 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
386 sizeof (PerformanceVariable
),
391 // Lock the variable which stores the Performance Table pointers.
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
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
);
409 // Publish Firmware Performance Data Table.
411 FpdtAcpiTableChecksum ((UINT8
*)&mFirmwarePerformanceTableTemplate
, mFirmwarePerformanceTableTemplate
.Header
.Length
);
412 Status
= AcpiTableProtocol
->InstallAcpiTable (
414 &mFirmwarePerformanceTableTemplate
,
415 mFirmwarePerformanceTableTemplate
.Header
.Length
,
416 &mFirmwarePerformanceTableTemplateKey
418 if (EFI_ERROR (Status
)) {
419 if (mAcpiBootPerformanceTable
!= NULL
) {
420 FreePages (mAcpiBootPerformanceTable
, EFI_SIZE_TO_PAGES (BootPerformanceDataSize
));
423 if (mAcpiS3PerformanceTable
!= NULL
) {
424 FreePages (mAcpiS3PerformanceTable
, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
)));
427 mAcpiBootPerformanceTable
= NULL
;
428 mAcpiS3PerformanceTable
= NULL
;
436 Report status code listener of FPDT. This is used to collect performance data
437 for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT.
439 @param[in] CodeType Indicates the type of status code being reported.
440 @param[in] Value Describes the current status of a hardware or software entity.
441 This included information about the class and subclass that is used to
442 classify the entity as well as an operation.
443 @param[in] Instance The enumeration of a hardware or software entity within
444 the system. Valid instance numbers start with 1.
445 @param[in] CallerId This optional parameter may be used to identify the caller.
446 This parameter allows the status code driver to apply different rules to
448 @param[in] Data This optional parameter may be used to pass additional data.
450 @retval EFI_SUCCESS Status code is what we expected.
451 @retval EFI_UNSUPPORTED Status code not supported.
456 FpdtStatusCodeListenerDxe (
457 IN EFI_STATUS_CODE_TYPE CodeType
,
458 IN EFI_STATUS_CODE_VALUE Value
,
460 IN EFI_GUID
*CallerId
,
461 IN EFI_STATUS_CODE_DATA
*Data
467 // Check whether status code is what we are interested in.
469 if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) != EFI_PROGRESS_CODE
) {
470 return EFI_UNSUPPORTED
;
473 if (Value
== (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT
)) {
475 // DxeCore ReportStatusCode Enable so that the capability can be supported.
477 mDxeCoreReportStatusCodeEnable
= TRUE
;
480 Status
= EFI_SUCCESS
;
481 if (Value
== PcdGet32 (PcdProgressCodeOsLoaderLoad
)) {
483 // Progress code for OS Loader LoadImage.
485 if (mAcpiBootPerformanceTable
== NULL
) {
490 // Update OS Loader LoadImage Start for UEFI boot.
492 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderLoadImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
493 } else if (Value
== PcdGet32 (PcdProgressCodeOsLoaderStart
)) {
495 // Progress code for OS Loader StartImage.
497 if (mAcpiBootPerformanceTable
== NULL
) {
502 // Update OS Loader StartImage Start for UEFI boot.
504 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
505 } else if (Value
== (EFI_SOFTWARE_EFI_BOOT_SERVICE
| EFI_SW_BS_PC_EXIT_BOOT_SERVICES
)) {
507 // Unregister boot time report status code listener.
509 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
512 // Progress code for ExitBootServices.
514 if (mAcpiBootPerformanceTable
== NULL
) {
519 // Update ExitBootServicesExit for UEFI boot.
521 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesExit
= GetTimeInNanoSecond (GetPerformanceCounter ());
522 } else if (Value
== (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT
)) {
523 if (mAcpiBootPerformanceTable
== NULL
) {
525 // Firmware Performance Data Table not installed, do nothing.
531 // Update Firmware Basic Boot Performance Record for legacy boot.
533 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
536 // Dump FPDT Boot Performance record.
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
)) {
545 // Get the Boot performance table and then install it to ACPI table.
547 CopyMem (&mReceivedAcpiBootPerformanceTable
, Data
+ 1, Data
->Size
);
548 InstallFirmwarePerformanceDataTable ();
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
;
554 // Ignore else progress code.
556 Status
= EFI_UNSUPPORTED
;
563 Notify function for event EndOfDxe.
565 This is used to install ACPI Firmware Performance Data Table for basic boot records.
567 @param[in] Event The Event that is being processed.
568 @param[in] Context The Event Context.
573 FpdtEndOfDxeEventNotify (
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.
582 if ((PcdGet8 (PcdPerformanceLibraryPropertyMask
) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED
) != 0) {
586 ASSERT (mReceivedAcpiBootPerformanceTable
== NULL
);
587 InstallFirmwarePerformanceDataTable ();
591 Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record
592 performance data for ExitBootServicesEntry in FPDT.
594 @param[in] Event The Event that is being processed.
595 @param[in] Context The Event Context.
600 FpdtExitBootServicesEventNotify (
605 if (!mDxeCoreReportStatusCodeEnable
) {
607 // When DxeCore Report Status Code is disabled,
608 // Unregister boot time report status code listener at ExitBootService Event.
610 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
613 if (mAcpiBootPerformanceTable
== NULL
) {
615 // Firmware Performance Data Table not installed, do nothing.
621 // Update Firmware Basic Boot Performance Record for UEFI boot.
623 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesEntry
= GetTimeInNanoSecond (GetPerformanceCounter ());
626 // Dump FPDT Boot Performance record.
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
));
633 // ExitBootServicesExit will be updated later, so don't dump it here.
638 The module Entry Point of the Firmware Performance Data Table DXE driver.
640 @param[in] ImageHandle The firmware allocated handle for the EFI image.
641 @param[in] SystemTable A pointer to the EFI System Table.
643 @retval EFI_SUCCESS The entry point is executed successfully.
644 @retval Other Some error occurs when executing this entry point.
649 FirmwarePerformanceDxeEntryPoint (
650 IN EFI_HANDLE ImageHandle
,
651 IN EFI_SYSTEM_TABLE
*SystemTable
655 EFI_HOB_GUID_TYPE
*GuidHob
;
656 FIRMWARE_SEC_PERFORMANCE
*Performance
;
659 EFI_EVENT EndOfDxeEvent
;
662 mFirmwarePerformanceTableTemplate
.Header
.OemId
,
663 PcdGetPtr (PcdAcpiDefaultOemId
),
664 sizeof (mFirmwarePerformanceTableTemplate
.Header
.OemId
)
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
);
673 // Get Report Status Code Handler Protocol.
675 Status
= gBS
->LocateProtocol (&gEfiRscHandlerProtocolGuid
, NULL
, (VOID
**)&mRscHandlerProtocol
);
676 ASSERT_EFI_ERROR (Status
);
679 // Register report status code listener for OS Loader load and start.
681 Status
= mRscHandlerProtocol
->Register (FpdtStatusCodeListenerDxe
, TPL_HIGH_LEVEL
);
682 ASSERT_EFI_ERROR (Status
);
685 // Register the notify function to install FPDT at EndOfDxe.
687 Status
= gBS
->CreateEventEx (
690 FpdtEndOfDxeEventNotify
,
692 &gEfiEndOfDxeEventGroupGuid
,
695 ASSERT_EFI_ERROR (Status
);
698 // Register the notify function to update FPDT on ExitBootServices Event.
700 Status
= gBS
->CreateEventEx (
703 FpdtExitBootServicesEventNotify
,
705 &gEfiEventExitBootServicesGuid
,
706 &mExitBootServicesEvent
708 ASSERT_EFI_ERROR (Status
);
711 // Retrieve GUID HOB data that contains the ResetEnd.
713 GuidHob
= GetFirstGuidHob (&gEfiFirmwarePerformanceGuid
);
714 if (GuidHob
!= NULL
) {
715 Performance
= (FIRMWARE_SEC_PERFORMANCE
*)GET_GUID_HOB_DATA (GuidHob
);
716 mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
= Performance
->ResetEnd
;
719 // SEC Performance Data Hob not found, ResetEnd in ACPI FPDT table will be 0.
721 DEBUG ((DEBUG_WARN
, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n"));
724 if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support
)) {
726 // Register callback function upon VariableArchProtocol and LockBoxProtocol
727 // to allocate S3 performance table memory and save the pointer to LockBox.
729 EfiCreateProtocolNotifyEvent (
730 &gEfiVariableArchProtocolGuid
,
732 FpdtAllocateS3PerformanceTableMemory
,
736 EfiCreateProtocolNotifyEvent (
737 &gEfiLockBoxProtocolGuid
,
739 FpdtAllocateS3PerformanceTableMemory
,
745 // Exclude S3 Performance Table Pointer from FPDT table template.
747 mFirmwarePerformanceTableTemplate
.Header
.Length
-= sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD
);