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 - 2018, 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>
20 #include <Guid/Acpi.h>
21 #include <Guid/FirmwarePerformance.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <Library/UefiRuntimeServicesTableLib.h>
25 #include <Library/BaseLib.h>
26 #include <Library/DebugLib.h>
27 #include <Library/DxeServicesLib.h>
28 #include <Library/TimerLib.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/MemoryAllocationLib.h>
31 #include <Library/PcdLib.h>
32 #include <Library/HobLib.h>
33 #include <Library/LockBoxLib.h>
34 #include <Library/UefiLib.h>
36 #define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
38 EFI_RSC_HANDLER_PROTOCOL
*mRscHandlerProtocol
= NULL
;
40 BOOLEAN mLockBoxReady
= FALSE
;
41 EFI_EVENT mReadyToBootEvent
;
42 EFI_EVENT mLegacyBootEvent
;
43 EFI_EVENT mExitBootServicesEvent
;
44 UINTN mFirmwarePerformanceTableTemplateKey
= 0;
45 BOOLEAN mDxeCoreReportStatusCodeEnable
= FALSE
;
47 BOOT_PERFORMANCE_TABLE
*mAcpiBootPerformanceTable
= NULL
;
48 BOOT_PERFORMANCE_TABLE
*mReceivedAcpiBootPerformanceTable
= NULL
;
49 S3_PERFORMANCE_TABLE
*mAcpiS3PerformanceTable
= NULL
;
51 FIRMWARE_PERFORMANCE_TABLE mFirmwarePerformanceTableTemplate
= {
53 EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
,
54 sizeof (FIRMWARE_PERFORMANCE_TABLE
),
55 EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_REVISION
, // Revision
56 0x00, // Checksum will be updated at runtime
58 // It is expected that these values will be updated at EntryPoint.
60 {0x00}, // OEM ID is a 6 bytes long field
61 0x00, // OEM Table ID(8 bytes long)
64 0x00, // Creator Revision
67 // Firmware Basic Boot Performance Table Pointer Record.
71 EFI_ACPI_5_0_FPDT_RECORD_TYPE_FIRMWARE_BASIC_BOOT_POINTER
, // Type
72 sizeof (EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_POINTER_RECORD
), // Length
73 EFI_ACPI_5_0_FPDT_RECORD_REVISION_FIRMWARE_BASIC_BOOT_POINTER
// Revision
76 0 // BootPerformanceTablePointer will be updated at runtime.
79 // S3 Performance Table Pointer Record.
83 EFI_ACPI_5_0_FPDT_RECORD_TYPE_S3_PERFORMANCE_TABLE_POINTER
, // Type
84 sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD
), // Length
85 EFI_ACPI_5_0_FPDT_RECORD_REVISION_S3_PERFORMANCE_TABLE_POINTER
// Revision
88 0 // S3PerformanceTablePointer will be updated at runtime.
92 BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate
= {
94 EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE
,
95 sizeof (BOOT_PERFORMANCE_TABLE
)
99 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT
, // Type
100 sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD
), // Length
101 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT
// Revision
105 // These values will be updated at runtime.
108 0, // OsLoaderLoadImageStart
109 0, // OsLoaderStartImageStart
110 0, // ExitBootServicesEntry
111 0 // ExitBootServicesExit
115 S3_PERFORMANCE_TABLE mS3PerformanceTableTemplate
= {
117 EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE
,
118 sizeof (S3_PERFORMANCE_TABLE
)
122 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_RESUME
, // Type
123 sizeof (EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD
), // Length
124 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_RESUME
// Revision
127 // These values will be updated by Firmware Performance PEIM.
135 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_SUSPEND
, // Type
136 sizeof (EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD
), // Length
137 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_SUSPEND
// Revision
140 // These values will be updated bye Firmware Performance SMM driver.
148 This function calculates and updates an UINT8 checksum.
150 @param[in] Buffer Pointer to buffer to checksum
151 @param[in] Size Number of bytes to checksum
155 FpdtAcpiTableChecksum (
160 UINTN ChecksumOffset
;
162 ChecksumOffset
= OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
, Checksum
);
165 // Set checksum to 0 first.
167 Buffer
[ChecksumOffset
] = 0;
170 // Update checksum value.
172 Buffer
[ChecksumOffset
] = CalculateCheckSum8 (Buffer
, Size
);
176 Callback function upon VariableArchProtocol and LockBoxProtocol
177 to allocate S3 performance table memory and save the pointer to LockBox.
179 @param[in] Event Event whose notification function is being invoked.
180 @param[in] Context Pointer to the notification function's context.
184 FpdtAllocateS3PerformanceTableMemory (
191 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
193 EFI_PHYSICAL_ADDRESS S3PerformanceTablePointer
;
195 if (mLockBoxReady
&& (mAcpiS3PerformanceTable
!= NULL
)) {
197 // The memory for S3 performance table should have been ready,
198 // and the pointer should have been saved to LockBox, just return.
203 if (!mLockBoxReady
) {
204 Status
= gBS
->LocateProtocol (&gEfiLockBoxProtocolGuid
, NULL
, &Interface
);
205 if (!EFI_ERROR (Status
)) {
207 // LockBox services has been ready.
209 mLockBoxReady
= TRUE
;
213 if (mAcpiS3PerformanceTable
== NULL
) {
214 Status
= gBS
->LocateProtocol (&gEfiVariableArchProtocolGuid
, NULL
, &Interface
);
215 if (!EFI_ERROR (Status
)) {
217 // Try to allocate the same runtime buffer as last time boot.
219 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
220 Size
= sizeof (PerformanceVariable
);
221 Status
= gRT
->GetVariable (
222 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
223 &gEfiFirmwarePerformanceGuid
,
228 if (!EFI_ERROR (Status
)) {
229 Status
= gBS
->AllocatePages (
231 EfiReservedMemoryType
,
232 EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
)),
233 &PerformanceVariable
.S3PerformanceTablePointer
235 if (!EFI_ERROR (Status
)) {
236 mAcpiS3PerformanceTable
= (S3_PERFORMANCE_TABLE
*) (UINTN
) PerformanceVariable
.S3PerformanceTablePointer
;
239 if (mAcpiS3PerformanceTable
== NULL
) {
241 // Fail to allocate at specified address, continue to allocate at any address.
243 mAcpiS3PerformanceTable
= (S3_PERFORMANCE_TABLE
*) AllocatePeiAccessiblePages (
244 EfiReservedMemoryType
,
245 EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
))
248 DEBUG ((EFI_D_INFO
, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable
));
249 if (mAcpiS3PerformanceTable
!= NULL
) {
250 CopyMem (mAcpiS3PerformanceTable
, &mS3PerformanceTableTemplate
, sizeof (mS3PerformanceTableTemplate
));
255 if (mLockBoxReady
&& (mAcpiS3PerformanceTable
!= NULL
)) {
257 // If LockBox services has been ready and memory for FPDT S3 performance table has been allocated,
258 // save the pointer to LockBox for use in S3 resume.
260 S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiS3PerformanceTable
;
261 Status
= SaveLockBox (
262 &gFirmwarePerformanceS3PointerGuid
,
263 &S3PerformanceTablePointer
,
264 sizeof (EFI_PHYSICAL_ADDRESS
)
266 ASSERT_EFI_ERROR (Status
);
271 Install ACPI Firmware Performance Data Table (FPDT).
277 InstallFirmwarePerformanceDataTable (
282 EFI_ACPI_TABLE_PROTOCOL
*AcpiTableProtocol
;
283 UINTN BootPerformanceDataSize
;
284 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
288 // Get AcpiTable Protocol.
290 Status
= gBS
->LocateProtocol (&gEfiAcpiTableProtocolGuid
, NULL
, (VOID
**) &AcpiTableProtocol
);
291 if (EFI_ERROR (Status
)) {
295 if (mReceivedAcpiBootPerformanceTable
!= NULL
) {
296 mAcpiBootPerformanceTable
= mReceivedAcpiBootPerformanceTable
;
297 mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
= mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
;
300 // Try to allocate the same runtime buffer as last time boot.
302 BootPerformanceDataSize
= sizeof (BOOT_PERFORMANCE_TABLE
);
303 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
304 Size
= sizeof (PerformanceVariable
);
305 Status
= gRT
->GetVariable (
306 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
307 &gEfiFirmwarePerformanceGuid
,
312 if (!EFI_ERROR (Status
)) {
313 Status
= gBS
->AllocatePages (
315 EfiReservedMemoryType
,
316 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
),
317 &PerformanceVariable
.BootPerformanceTablePointer
319 if (!EFI_ERROR (Status
)) {
320 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) (UINTN
) PerformanceVariable
.BootPerformanceTablePointer
;
323 if (mAcpiBootPerformanceTable
== NULL
) {
325 // Fail to allocate at specified address, continue to allocate at any address.
327 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) AllocatePeiAccessiblePages (
328 EfiReservedMemoryType
,
329 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
)
332 DEBUG ((DEBUG_INFO
, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable
));
333 if (mAcpiBootPerformanceTable
== NULL
) {
334 return EFI_OUT_OF_RESOURCES
;
337 // Fill Basic Boot record to Boot Performance Table.
339 CopyMem (mAcpiBootPerformanceTable
, &mBootPerformanceTableTemplate
, sizeof (mBootPerformanceTableTemplate
));
341 BootPerformanceDataSize
= mAcpiBootPerformanceTable
->Header
.Length
;
344 // Save Boot Performance Table address to Variable for use in S4 resume.
346 PerformanceVariable
.BootPerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiBootPerformanceTable
;
348 // Update Boot Performance Table Pointer in template.
350 mFirmwarePerformanceTableTemplate
.BootPointerRecord
.BootPerformanceTablePointer
= (UINT64
) (UINTN
) mAcpiBootPerformanceTable
;
353 // Save S3 Performance Table address to Variable for use in S4 resume.
355 PerformanceVariable
.S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiS3PerformanceTable
;
357 // Update S3 Performance Table Pointer in template.
359 mFirmwarePerformanceTableTemplate
.S3PointerRecord
.S3PerformanceTablePointer
= (UINT64
) (UINTN
) mAcpiS3PerformanceTable
;
361 // Save Runtime Performance Table pointers to Variable.
362 // Don't check SetVariable return status. It doesn't impact FPDT table generation.
365 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
366 &gEfiFirmwarePerformanceGuid
,
367 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
368 sizeof (PerformanceVariable
),
373 // Publish Firmware Performance Data Table.
375 FpdtAcpiTableChecksum ((UINT8
*) &mFirmwarePerformanceTableTemplate
, mFirmwarePerformanceTableTemplate
.Header
.Length
);
376 Status
= AcpiTableProtocol
->InstallAcpiTable (
378 &mFirmwarePerformanceTableTemplate
,
379 mFirmwarePerformanceTableTemplate
.Header
.Length
,
380 &mFirmwarePerformanceTableTemplateKey
382 if (EFI_ERROR (Status
)) {
383 if (mAcpiBootPerformanceTable
!= NULL
) {
384 FreePages (mAcpiBootPerformanceTable
, EFI_SIZE_TO_PAGES (BootPerformanceDataSize
));
386 if (mAcpiS3PerformanceTable
!= NULL
) {
387 FreePages (mAcpiS3PerformanceTable
, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
)));
389 mAcpiBootPerformanceTable
= NULL
;
390 mAcpiS3PerformanceTable
= NULL
;
397 Report status code listener of FPDT. This is used to collect performance data
398 for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT.
400 @param[in] CodeType Indicates the type of status code being reported.
401 @param[in] Value Describes the current status of a hardware or software entity.
402 This included information about the class and subclass that is used to
403 classify the entity as well as an operation.
404 @param[in] Instance The enumeration of a hardware or software entity within
405 the system. Valid instance numbers start with 1.
406 @param[in] CallerId This optional parameter may be used to identify the caller.
407 This parameter allows the status code driver to apply different rules to
409 @param[in] Data This optional parameter may be used to pass additional data.
411 @retval EFI_SUCCESS Status code is what we expected.
412 @retval EFI_UNSUPPORTED Status code not supported.
417 FpdtStatusCodeListenerDxe (
418 IN EFI_STATUS_CODE_TYPE CodeType
,
419 IN EFI_STATUS_CODE_VALUE Value
,
421 IN EFI_GUID
*CallerId
,
422 IN EFI_STATUS_CODE_DATA
*Data
428 // Check whether status code is what we are interested in.
430 if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) != EFI_PROGRESS_CODE
) {
431 return EFI_UNSUPPORTED
;
434 if (Value
== (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT
)) {
436 // DxeCore ReportStatusCode Enable so that the capability can be supported.
438 mDxeCoreReportStatusCodeEnable
= TRUE
;
441 Status
= EFI_SUCCESS
;
442 if (Value
== PcdGet32 (PcdProgressCodeOsLoaderLoad
)) {
444 // Progress code for OS Loader LoadImage.
446 if (mAcpiBootPerformanceTable
== NULL
) {
451 // Update OS Loader LoadImage Start for UEFI boot.
453 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderLoadImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
454 } else if (Value
== PcdGet32 (PcdProgressCodeOsLoaderStart
)) {
456 // Progress code for OS Loader StartImage.
458 if (mAcpiBootPerformanceTable
== NULL
) {
463 // Update OS Loader StartImage Start for UEFI boot.
465 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
466 } else if (Value
== (EFI_SOFTWARE_EFI_BOOT_SERVICE
| EFI_SW_BS_PC_EXIT_BOOT_SERVICES
)) {
468 // Unregister boot time report status code listener.
470 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
473 // Progress code for ExitBootServices.
475 if (mAcpiBootPerformanceTable
== NULL
) {
480 // Update ExitBootServicesExit for UEFI boot.
482 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesExit
= GetTimeInNanoSecond (GetPerformanceCounter ());
483 } else if (Value
== (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT
)) {
484 if (mAcpiBootPerformanceTable
== NULL
) {
486 // Firmware Performance Data Table not installed, do nothing.
492 // Update Firmware Basic Boot Performance Record for legacy boot.
494 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
497 // Dump FPDT Boot Performance record.
499 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
));
500 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderLoadImageStart = 0\n"));
501 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
));
502 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesEntry = 0\n"));
503 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesExit = 0\n"));
504 } else if (Value
== (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT
)) {
505 if (mAcpiBootPerformanceTable
== NULL
) {
507 // ACPI Firmware Performance Data Table not installed yet, install it now.
509 InstallFirmwarePerformanceDataTable ();
511 } else if (Data
!= NULL
&& CompareGuid (&Data
->Type
, &gEdkiiFpdtExtendedFirmwarePerformanceGuid
)) {
513 // Get the Boot performance table and then install it to ACPI table.
515 CopyMem (&mReceivedAcpiBootPerformanceTable
, Data
+ 1, Data
->Size
);
516 } else if (Data
!= NULL
&& CompareGuid (&Data
->Type
, &gEfiFirmwarePerformanceGuid
)) {
517 DEBUG ((DEBUG_ERROR
, "FpdtStatusCodeListenerDxe: Performance data reported through gEfiFirmwarePerformanceGuid will not be collected by FirmwarePerformanceDataTableDxe\n"));
518 Status
= EFI_UNSUPPORTED
;
521 // Ignore else progress code.
523 Status
= EFI_UNSUPPORTED
;
531 Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record
532 performance data for ExitBootServicesEntry in FPDT.
534 @param[in] Event The Event that is being processed.
535 @param[in] Context The Event Context.
540 FpdtExitBootServicesEventNotify (
545 if (!mDxeCoreReportStatusCodeEnable
) {
547 // When DxeCore Report Status Code is disabled,
548 // Unregister boot time report status code listener at ExitBootService Event.
550 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
553 if (mAcpiBootPerformanceTable
== NULL
) {
555 // Firmware Performance Data Table not installed, do nothing.
561 // Update Firmware Basic Boot Performance Record for UEFI boot.
563 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesEntry
= GetTimeInNanoSecond (GetPerformanceCounter ());
566 // Dump FPDT Boot Performance record.
568 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
));
569 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderLoadImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderLoadImageStart
));
570 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
));
571 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesEntry = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesEntry
));
573 // ExitBootServicesExit will be updated later, so don't dump it here.
578 The module Entry Point of the Firmware Performance Data Table DXE driver.
580 @param[in] ImageHandle The firmware allocated handle for the EFI image.
581 @param[in] SystemTable A pointer to the EFI System Table.
583 @retval EFI_SUCCESS The entry point is executed successfully.
584 @retval Other Some error occurs when executing this entry point.
589 FirmwarePerformanceDxeEntryPoint (
590 IN EFI_HANDLE ImageHandle
,
591 IN EFI_SYSTEM_TABLE
*SystemTable
595 EFI_HOB_GUID_TYPE
*GuidHob
;
596 FIRMWARE_SEC_PERFORMANCE
*Performance
;
601 mFirmwarePerformanceTableTemplate
.Header
.OemId
,
602 PcdGetPtr (PcdAcpiDefaultOemId
),
603 sizeof (mFirmwarePerformanceTableTemplate
.Header
.OemId
)
605 OemTableId
= PcdGet64 (PcdAcpiDefaultOemTableId
);
606 CopyMem (&mFirmwarePerformanceTableTemplate
.Header
.OemTableId
, &OemTableId
, sizeof (UINT64
));
607 mFirmwarePerformanceTableTemplate
.Header
.OemRevision
= PcdGet32 (PcdAcpiDefaultOemRevision
);
608 mFirmwarePerformanceTableTemplate
.Header
.CreatorId
= PcdGet32 (PcdAcpiDefaultCreatorId
);
609 mFirmwarePerformanceTableTemplate
.Header
.CreatorRevision
= PcdGet32 (PcdAcpiDefaultCreatorRevision
);
612 // Get Report Status Code Handler Protocol.
614 Status
= gBS
->LocateProtocol (&gEfiRscHandlerProtocolGuid
, NULL
, (VOID
**) &mRscHandlerProtocol
);
615 ASSERT_EFI_ERROR (Status
);
618 // Register report status code listener for OS Loader load and start.
620 Status
= mRscHandlerProtocol
->Register (FpdtStatusCodeListenerDxe
, TPL_HIGH_LEVEL
);
621 ASSERT_EFI_ERROR (Status
);
624 // Register the notify function to update FPDT on ExitBootServices Event.
626 Status
= gBS
->CreateEventEx (
629 FpdtExitBootServicesEventNotify
,
631 &gEfiEventExitBootServicesGuid
,
632 &mExitBootServicesEvent
634 ASSERT_EFI_ERROR (Status
);
637 // Retrieve GUID HOB data that contains the ResetEnd.
639 GuidHob
= GetFirstGuidHob (&gEfiFirmwarePerformanceGuid
);
640 if (GuidHob
!= NULL
) {
641 Performance
= (FIRMWARE_SEC_PERFORMANCE
*) GET_GUID_HOB_DATA (GuidHob
);
642 mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
= Performance
->ResetEnd
;
645 // SEC Performance Data Hob not found, ResetEnd in ACPI FPDT table will be 0.
647 DEBUG ((DEBUG_WARN
, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n"));
650 if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support
)) {
652 // Register callback function upon VariableArchProtocol and LockBoxProtocol
653 // to allocate S3 performance table memory and save the pointer to LockBox.
655 EfiCreateProtocolNotifyEvent (
656 &gEfiVariableArchProtocolGuid
,
658 FpdtAllocateS3PerformanceTableMemory
,
662 EfiCreateProtocolNotifyEvent (
663 &gEfiLockBoxProtocolGuid
,
665 FpdtAllocateS3PerformanceTableMemory
,
671 // Exclude S3 Performance Table Pointer from FPDT table template.
673 mFirmwarePerformanceTableTemplate
.Header
.Length
-= sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD
);