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
;
242 if (mAcpiS3PerformanceTable
== NULL
) {
244 // Fail to allocate at specified address, continue to allocate at any address.
246 mAcpiS3PerformanceTable
= (S3_PERFORMANCE_TABLE
*) AllocatePeiAccessiblePages (
247 EfiReservedMemoryType
,
248 EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
))
251 DEBUG ((EFI_D_INFO
, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable
));
252 if (mAcpiS3PerformanceTable
!= NULL
) {
253 CopyMem (mAcpiS3PerformanceTable
, &mS3PerformanceTableTemplate
, sizeof (mS3PerformanceTableTemplate
));
258 if (mLockBoxReady
&& (mAcpiS3PerformanceTable
!= NULL
)) {
260 // If LockBox services has been ready and memory for FPDT S3 performance table has been allocated,
261 // save the pointer to LockBox for use in S3 resume.
263 S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiS3PerformanceTable
;
264 Status
= SaveLockBox (
265 &gFirmwarePerformanceS3PointerGuid
,
266 &S3PerformanceTablePointer
,
267 sizeof (EFI_PHYSICAL_ADDRESS
)
269 ASSERT_EFI_ERROR (Status
);
274 Install ACPI Firmware Performance Data Table (FPDT).
280 InstallFirmwarePerformanceDataTable (
285 EFI_ACPI_TABLE_PROTOCOL
*AcpiTableProtocol
;
286 UINTN BootPerformanceDataSize
;
287 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
289 EDKII_VARIABLE_POLICY_PROTOCOL
*VariablePolicyProtocol
;
292 // Get AcpiTable Protocol.
294 Status
= gBS
->LocateProtocol (&gEfiAcpiTableProtocolGuid
, NULL
, (VOID
**) &AcpiTableProtocol
);
295 if (EFI_ERROR (Status
)) {
300 // Get VariablePolicy Protocol.
302 Status
= gBS
->LocateProtocol(&gEdkiiVariablePolicyProtocolGuid
, NULL
, (VOID
**)&VariablePolicyProtocol
);
303 if (EFI_ERROR (Status
)) {
307 if (mReceivedAcpiBootPerformanceTable
!= NULL
) {
308 mAcpiBootPerformanceTable
= mReceivedAcpiBootPerformanceTable
;
309 mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
= mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
;
312 // Try to allocate the same runtime buffer as last time boot.
314 BootPerformanceDataSize
= sizeof (BOOT_PERFORMANCE_TABLE
);
315 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
316 Size
= sizeof (PerformanceVariable
);
317 Status
= gRT
->GetVariable (
318 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
319 &gEfiFirmwarePerformanceGuid
,
324 if (!EFI_ERROR (Status
)) {
325 Status
= gBS
->AllocatePages (
327 EfiReservedMemoryType
,
328 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
),
329 &PerformanceVariable
.BootPerformanceTablePointer
331 if (!EFI_ERROR (Status
)) {
332 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) (UINTN
) PerformanceVariable
.BootPerformanceTablePointer
;
335 if (mAcpiBootPerformanceTable
== NULL
) {
337 // Fail to allocate at specified address, continue to allocate at any address.
339 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) AllocatePeiAccessiblePages (
340 EfiReservedMemoryType
,
341 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
)
344 DEBUG ((DEBUG_INFO
, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable
));
345 if (mAcpiBootPerformanceTable
== NULL
) {
346 return EFI_OUT_OF_RESOURCES
;
349 // Fill Basic Boot record to Boot Performance Table.
351 CopyMem (mAcpiBootPerformanceTable
, &mBootPerformanceTableTemplate
, sizeof (mBootPerformanceTableTemplate
));
353 BootPerformanceDataSize
= mAcpiBootPerformanceTable
->Header
.Length
;
356 // Save Boot Performance Table address to Variable for use in S4 resume.
358 PerformanceVariable
.BootPerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiBootPerformanceTable
;
360 // Update Boot Performance Table Pointer in template.
362 mFirmwarePerformanceTableTemplate
.BootPointerRecord
.BootPerformanceTablePointer
= (UINT64
) (UINTN
) mAcpiBootPerformanceTable
;
365 // Save S3 Performance Table address to Variable for use in S4 resume.
367 PerformanceVariable
.S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiS3PerformanceTable
;
369 // Update S3 Performance Table Pointer in template.
371 mFirmwarePerformanceTableTemplate
.S3PointerRecord
.S3PerformanceTablePointer
= (UINT64
) (UINTN
) mAcpiS3PerformanceTable
;
373 // Save Runtime Performance Table pointers to Variable.
374 // Don't check SetVariable return status. It doesn't impact FPDT table generation.
377 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
378 &gEfiFirmwarePerformanceGuid
,
379 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
380 sizeof (PerformanceVariable
),
385 // Lock the variable which stores the Performance Table pointers.
387 Status
= RegisterBasicVariablePolicy (
388 VariablePolicyProtocol
,
389 &gEfiFirmwarePerformanceGuid
,
390 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
391 VARIABLE_POLICY_NO_MIN_SIZE
,
392 VARIABLE_POLICY_NO_MAX_SIZE
,
393 VARIABLE_POLICY_NO_MUST_ATTR
,
394 VARIABLE_POLICY_NO_CANT_ATTR
,
395 VARIABLE_POLICY_TYPE_LOCK_NOW
397 if (EFI_ERROR(Status
)) {
398 DEBUG((DEBUG_ERROR
, "[FirmwarePerformanceDxe] Error when lock variable %s, Status = %r\n", EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
, Status
));
399 ASSERT_EFI_ERROR(Status
);
403 // Publish Firmware Performance Data Table.
405 FpdtAcpiTableChecksum ((UINT8
*) &mFirmwarePerformanceTableTemplate
, mFirmwarePerformanceTableTemplate
.Header
.Length
);
406 Status
= AcpiTableProtocol
->InstallAcpiTable (
408 &mFirmwarePerformanceTableTemplate
,
409 mFirmwarePerformanceTableTemplate
.Header
.Length
,
410 &mFirmwarePerformanceTableTemplateKey
412 if (EFI_ERROR (Status
)) {
413 if (mAcpiBootPerformanceTable
!= NULL
) {
414 FreePages (mAcpiBootPerformanceTable
, EFI_SIZE_TO_PAGES (BootPerformanceDataSize
));
416 if (mAcpiS3PerformanceTable
!= NULL
) {
417 FreePages (mAcpiS3PerformanceTable
, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
)));
419 mAcpiBootPerformanceTable
= NULL
;
420 mAcpiS3PerformanceTable
= NULL
;
427 Report status code listener of FPDT. This is used to collect performance data
428 for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT.
430 @param[in] CodeType Indicates the type of status code being reported.
431 @param[in] Value Describes the current status of a hardware or software entity.
432 This included information about the class and subclass that is used to
433 classify the entity as well as an operation.
434 @param[in] Instance The enumeration of a hardware or software entity within
435 the system. Valid instance numbers start with 1.
436 @param[in] CallerId This optional parameter may be used to identify the caller.
437 This parameter allows the status code driver to apply different rules to
439 @param[in] Data This optional parameter may be used to pass additional data.
441 @retval EFI_SUCCESS Status code is what we expected.
442 @retval EFI_UNSUPPORTED Status code not supported.
447 FpdtStatusCodeListenerDxe (
448 IN EFI_STATUS_CODE_TYPE CodeType
,
449 IN EFI_STATUS_CODE_VALUE Value
,
451 IN EFI_GUID
*CallerId
,
452 IN EFI_STATUS_CODE_DATA
*Data
458 // Check whether status code is what we are interested in.
460 if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) != EFI_PROGRESS_CODE
) {
461 return EFI_UNSUPPORTED
;
464 if (Value
== (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT
)) {
466 // DxeCore ReportStatusCode Enable so that the capability can be supported.
468 mDxeCoreReportStatusCodeEnable
= TRUE
;
471 Status
= EFI_SUCCESS
;
472 if (Value
== PcdGet32 (PcdProgressCodeOsLoaderLoad
)) {
474 // Progress code for OS Loader LoadImage.
476 if (mAcpiBootPerformanceTable
== NULL
) {
481 // Update OS Loader LoadImage Start for UEFI boot.
483 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderLoadImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
484 } else if (Value
== PcdGet32 (PcdProgressCodeOsLoaderStart
)) {
486 // Progress code for OS Loader StartImage.
488 if (mAcpiBootPerformanceTable
== NULL
) {
493 // Update OS Loader StartImage Start for UEFI boot.
495 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
496 } else if (Value
== (EFI_SOFTWARE_EFI_BOOT_SERVICE
| EFI_SW_BS_PC_EXIT_BOOT_SERVICES
)) {
498 // Unregister boot time report status code listener.
500 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
503 // Progress code for ExitBootServices.
505 if (mAcpiBootPerformanceTable
== NULL
) {
510 // Update ExitBootServicesExit for UEFI boot.
512 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesExit
= GetTimeInNanoSecond (GetPerformanceCounter ());
513 } else if (Value
== (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT
)) {
514 if (mAcpiBootPerformanceTable
== NULL
) {
516 // Firmware Performance Data Table not installed, do nothing.
522 // Update Firmware Basic Boot Performance Record for legacy boot.
524 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
527 // Dump FPDT Boot Performance record.
529 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
));
530 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderLoadImageStart = 0\n"));
531 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
));
532 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesEntry = 0\n"));
533 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesExit = 0\n"));
534 } else if (Data
!= NULL
&& CompareGuid (&Data
->Type
, &gEdkiiFpdtExtendedFirmwarePerformanceGuid
)) {
536 // Get the Boot performance table and then install it to ACPI table.
538 CopyMem (&mReceivedAcpiBootPerformanceTable
, Data
+ 1, Data
->Size
);
539 InstallFirmwarePerformanceDataTable ();
540 } else if (Data
!= NULL
&& CompareGuid (&Data
->Type
, &gEfiFirmwarePerformanceGuid
)) {
541 DEBUG ((DEBUG_ERROR
, "FpdtStatusCodeListenerDxe: Performance data reported through gEfiFirmwarePerformanceGuid will not be collected by FirmwarePerformanceDataTableDxe\n"));
542 Status
= EFI_UNSUPPORTED
;
545 // Ignore else progress code.
547 Status
= EFI_UNSUPPORTED
;
554 Notify function for event EndOfDxe.
556 This is used to install ACPI Firmware Performance Data Table for basic boot records.
558 @param[in] Event The Event that is being processed.
559 @param[in] Context The Event Context.
564 FpdtEndOfDxeEventNotify (
570 // When performance is enabled, the FPDT will be installed when DxeCorePerformanceLib report the data to FimwarePerformanceDxe.
571 // This is used to install the FPDT for the basic boot recods when performance infrastructure is not enabled.
573 if ((PcdGet8(PcdPerformanceLibraryPropertyMask
) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED
) != 0) {
576 ASSERT (mReceivedAcpiBootPerformanceTable
== NULL
);
577 InstallFirmwarePerformanceDataTable ();
581 Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record
582 performance data for ExitBootServicesEntry in FPDT.
584 @param[in] Event The Event that is being processed.
585 @param[in] Context The Event Context.
590 FpdtExitBootServicesEventNotify (
595 if (!mDxeCoreReportStatusCodeEnable
) {
597 // When DxeCore Report Status Code is disabled,
598 // Unregister boot time report status code listener at ExitBootService Event.
600 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
603 if (mAcpiBootPerformanceTable
== NULL
) {
605 // Firmware Performance Data Table not installed, do nothing.
611 // Update Firmware Basic Boot Performance Record for UEFI boot.
613 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesEntry
= GetTimeInNanoSecond (GetPerformanceCounter ());
616 // Dump FPDT Boot Performance record.
618 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
));
619 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderLoadImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderLoadImageStart
));
620 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
));
621 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesEntry = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesEntry
));
623 // ExitBootServicesExit will be updated later, so don't dump it here.
628 The module Entry Point of the Firmware Performance Data Table DXE driver.
630 @param[in] ImageHandle The firmware allocated handle for the EFI image.
631 @param[in] SystemTable A pointer to the EFI System Table.
633 @retval EFI_SUCCESS The entry point is executed successfully.
634 @retval Other Some error occurs when executing this entry point.
639 FirmwarePerformanceDxeEntryPoint (
640 IN EFI_HANDLE ImageHandle
,
641 IN EFI_SYSTEM_TABLE
*SystemTable
645 EFI_HOB_GUID_TYPE
*GuidHob
;
646 FIRMWARE_SEC_PERFORMANCE
*Performance
;
649 EFI_EVENT EndOfDxeEvent
;
652 mFirmwarePerformanceTableTemplate
.Header
.OemId
,
653 PcdGetPtr (PcdAcpiDefaultOemId
),
654 sizeof (mFirmwarePerformanceTableTemplate
.Header
.OemId
)
656 OemTableId
= PcdGet64 (PcdAcpiDefaultOemTableId
);
657 CopyMem (&mFirmwarePerformanceTableTemplate
.Header
.OemTableId
, &OemTableId
, sizeof (UINT64
));
658 mFirmwarePerformanceTableTemplate
.Header
.OemRevision
= PcdGet32 (PcdAcpiDefaultOemRevision
);
659 mFirmwarePerformanceTableTemplate
.Header
.CreatorId
= PcdGet32 (PcdAcpiDefaultCreatorId
);
660 mFirmwarePerformanceTableTemplate
.Header
.CreatorRevision
= PcdGet32 (PcdAcpiDefaultCreatorRevision
);
663 // Get Report Status Code Handler Protocol.
665 Status
= gBS
->LocateProtocol (&gEfiRscHandlerProtocolGuid
, NULL
, (VOID
**) &mRscHandlerProtocol
);
666 ASSERT_EFI_ERROR (Status
);
669 // Register report status code listener for OS Loader load and start.
671 Status
= mRscHandlerProtocol
->Register (FpdtStatusCodeListenerDxe
, TPL_HIGH_LEVEL
);
672 ASSERT_EFI_ERROR (Status
);
675 // Register the notify function to install FPDT at EndOfDxe.
677 Status
= gBS
->CreateEventEx (
680 FpdtEndOfDxeEventNotify
,
682 &gEfiEndOfDxeEventGroupGuid
,
685 ASSERT_EFI_ERROR (Status
);
688 // Register the notify function to update FPDT on ExitBootServices Event.
690 Status
= gBS
->CreateEventEx (
693 FpdtExitBootServicesEventNotify
,
695 &gEfiEventExitBootServicesGuid
,
696 &mExitBootServicesEvent
698 ASSERT_EFI_ERROR (Status
);
701 // Retrieve GUID HOB data that contains the ResetEnd.
703 GuidHob
= GetFirstGuidHob (&gEfiFirmwarePerformanceGuid
);
704 if (GuidHob
!= NULL
) {
705 Performance
= (FIRMWARE_SEC_PERFORMANCE
*) GET_GUID_HOB_DATA (GuidHob
);
706 mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
= Performance
->ResetEnd
;
709 // SEC Performance Data Hob not found, ResetEnd in ACPI FPDT table will be 0.
711 DEBUG ((DEBUG_WARN
, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n"));
714 if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support
)) {
716 // Register callback function upon VariableArchProtocol and LockBoxProtocol
717 // to allocate S3 performance table memory and save the pointer to LockBox.
719 EfiCreateProtocolNotifyEvent (
720 &gEfiVariableArchProtocolGuid
,
722 FpdtAllocateS3PerformanceTableMemory
,
726 EfiCreateProtocolNotifyEvent (
727 &gEfiLockBoxProtocolGuid
,
729 FpdtAllocateS3PerformanceTableMemory
,
735 // Exclude S3 Performance Table Pointer from FPDT table template.
737 mFirmwarePerformanceTableTemplate
.Header
.Length
-= sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD
);