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 This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #include <Protocol/ReportStatusCodeHandler.h>
22 #include <Protocol/AcpiTable.h>
23 #include <Protocol/LockBox.h>
24 #include <Protocol/Variable.h>
26 #include <Guid/Acpi.h>
27 #include <Guid/FirmwarePerformance.h>
28 #include <Guid/EventGroup.h>
29 #include <Guid/EventLegacyBios.h>
31 #include <Library/UefiBootServicesTableLib.h>
32 #include <Library/UefiRuntimeServicesTableLib.h>
33 #include <Library/BaseLib.h>
34 #include <Library/DebugLib.h>
35 #include <Library/DxeServicesLib.h>
36 #include <Library/TimerLib.h>
37 #include <Library/BaseMemoryLib.h>
38 #include <Library/MemoryAllocationLib.h>
39 #include <Library/PcdLib.h>
40 #include <Library/HobLib.h>
41 #include <Library/LockBoxLib.h>
42 #include <Library/UefiLib.h>
44 #define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
46 EFI_RSC_HANDLER_PROTOCOL
*mRscHandlerProtocol
= NULL
;
48 BOOLEAN mLockBoxReady
= FALSE
;
49 EFI_EVENT mReadyToBootEvent
;
50 EFI_EVENT mLegacyBootEvent
;
51 EFI_EVENT mExitBootServicesEvent
;
52 UINTN mFirmwarePerformanceTableTemplateKey
= 0;
53 BOOLEAN mDxeCoreReportStatusCodeEnable
= FALSE
;
55 BOOT_PERFORMANCE_TABLE
*mAcpiBootPerformanceTable
= NULL
;
56 BOOT_PERFORMANCE_TABLE
*mReceivedAcpiBootPerformanceTable
= NULL
;
57 S3_PERFORMANCE_TABLE
*mAcpiS3PerformanceTable
= NULL
;
59 FIRMWARE_PERFORMANCE_TABLE mFirmwarePerformanceTableTemplate
= {
61 EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
,
62 sizeof (FIRMWARE_PERFORMANCE_TABLE
),
63 EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_REVISION
, // Revision
64 0x00, // Checksum will be updated at runtime
66 // It is expected that these values will be updated at EntryPoint.
68 {0x00}, // OEM ID is a 6 bytes long field
69 0x00, // OEM Table ID(8 bytes long)
72 0x00, // Creator Revision
75 // Firmware Basic Boot Performance Table Pointer Record.
79 EFI_ACPI_5_0_FPDT_RECORD_TYPE_FIRMWARE_BASIC_BOOT_POINTER
, // Type
80 sizeof (EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_POINTER_RECORD
), // Length
81 EFI_ACPI_5_0_FPDT_RECORD_REVISION_FIRMWARE_BASIC_BOOT_POINTER
// Revision
84 0 // BootPerformanceTablePointer will be updated at runtime.
87 // S3 Performance Table Pointer Record.
91 EFI_ACPI_5_0_FPDT_RECORD_TYPE_S3_PERFORMANCE_TABLE_POINTER
, // Type
92 sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD
), // Length
93 EFI_ACPI_5_0_FPDT_RECORD_REVISION_S3_PERFORMANCE_TABLE_POINTER
// Revision
96 0 // S3PerformanceTablePointer will be updated at runtime.
100 BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate
= {
102 EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE
,
103 sizeof (BOOT_PERFORMANCE_TABLE
)
107 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT
, // Type
108 sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD
), // Length
109 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT
// Revision
113 // These values will be updated at runtime.
116 0, // OsLoaderLoadImageStart
117 0, // OsLoaderStartImageStart
118 0, // ExitBootServicesEntry
119 0 // ExitBootServicesExit
123 S3_PERFORMANCE_TABLE mS3PerformanceTableTemplate
= {
125 EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE
,
126 sizeof (S3_PERFORMANCE_TABLE
)
130 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_RESUME
, // Type
131 sizeof (EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD
), // Length
132 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_RESUME
// Revision
135 // These values will be updated by Firmware Performance PEIM.
143 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_SUSPEND
, // Type
144 sizeof (EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD
), // Length
145 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_SUSPEND
// Revision
148 // These values will be updated bye Firmware Performance SMM driver.
156 This function calculates and updates an UINT8 checksum.
158 @param[in] Buffer Pointer to buffer to checksum
159 @param[in] Size Number of bytes to checksum
163 FpdtAcpiTableChecksum (
168 UINTN ChecksumOffset
;
170 ChecksumOffset
= OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
, Checksum
);
173 // Set checksum to 0 first.
175 Buffer
[ChecksumOffset
] = 0;
178 // Update checksum value.
180 Buffer
[ChecksumOffset
] = CalculateCheckSum8 (Buffer
, Size
);
184 Callback function upon VariableArchProtocol and LockBoxProtocol
185 to allocate S3 performance table memory and save the pointer to LockBox.
187 @param[in] Event Event whose notification function is being invoked.
188 @param[in] Context Pointer to the notification function's context.
192 FpdtAllocateS3PerformanceTableMemory (
199 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
201 EFI_PHYSICAL_ADDRESS S3PerformanceTablePointer
;
203 if (mLockBoxReady
&& (mAcpiS3PerformanceTable
!= NULL
)) {
205 // The memory for S3 performance table should have been ready,
206 // and the pointer should have been saved to LockBox, just return.
211 if (!mLockBoxReady
) {
212 Status
= gBS
->LocateProtocol (&gEfiLockBoxProtocolGuid
, NULL
, &Interface
);
213 if (!EFI_ERROR (Status
)) {
215 // LockBox services has been ready.
217 mLockBoxReady
= TRUE
;
221 if (mAcpiS3PerformanceTable
== NULL
) {
222 Status
= gBS
->LocateProtocol (&gEfiVariableArchProtocolGuid
, NULL
, &Interface
);
223 if (!EFI_ERROR (Status
)) {
225 // Try to allocate the same runtime buffer as last time boot.
227 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
228 Size
= sizeof (PerformanceVariable
);
229 Status
= gRT
->GetVariable (
230 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
231 &gEfiFirmwarePerformanceGuid
,
236 if (!EFI_ERROR (Status
)) {
237 Status
= gBS
->AllocatePages (
239 EfiReservedMemoryType
,
240 EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
)),
241 &PerformanceVariable
.S3PerformanceTablePointer
243 if (!EFI_ERROR (Status
)) {
244 mAcpiS3PerformanceTable
= (S3_PERFORMANCE_TABLE
*) (UINTN
) PerformanceVariable
.S3PerformanceTablePointer
;
247 if (mAcpiS3PerformanceTable
== NULL
) {
249 // Fail to allocate at specified address, continue to allocate at any address.
251 mAcpiS3PerformanceTable
= (S3_PERFORMANCE_TABLE
*) AllocatePeiAccessiblePages (
252 EfiReservedMemoryType
,
253 EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
))
256 DEBUG ((EFI_D_INFO
, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable
));
257 if (mAcpiS3PerformanceTable
!= NULL
) {
258 CopyMem (mAcpiS3PerformanceTable
, &mS3PerformanceTableTemplate
, sizeof (mS3PerformanceTableTemplate
));
263 if (mLockBoxReady
&& (mAcpiS3PerformanceTable
!= NULL
)) {
265 // If LockBox services has been ready and memory for FPDT S3 performance table has been allocated,
266 // save the pointer to LockBox for use in S3 resume.
268 S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiS3PerformanceTable
;
269 Status
= SaveLockBox (
270 &gFirmwarePerformanceS3PointerGuid
,
271 &S3PerformanceTablePointer
,
272 sizeof (EFI_PHYSICAL_ADDRESS
)
274 ASSERT_EFI_ERROR (Status
);
279 Install ACPI Firmware Performance Data Table (FPDT).
285 InstallFirmwarePerformanceDataTable (
290 EFI_ACPI_TABLE_PROTOCOL
*AcpiTableProtocol
;
291 UINTN BootPerformanceDataSize
;
292 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
296 // Get AcpiTable Protocol.
298 Status
= gBS
->LocateProtocol (&gEfiAcpiTableProtocolGuid
, NULL
, (VOID
**) &AcpiTableProtocol
);
299 if (EFI_ERROR (Status
)) {
303 if (mReceivedAcpiBootPerformanceTable
!= NULL
) {
304 mAcpiBootPerformanceTable
= mReceivedAcpiBootPerformanceTable
;
305 mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
= mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
;
308 // Try to allocate the same runtime buffer as last time boot.
310 BootPerformanceDataSize
= sizeof (BOOT_PERFORMANCE_TABLE
);
311 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
312 Size
= sizeof (PerformanceVariable
);
313 Status
= gRT
->GetVariable (
314 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
315 &gEfiFirmwarePerformanceGuid
,
320 if (!EFI_ERROR (Status
)) {
321 Status
= gBS
->AllocatePages (
323 EfiReservedMemoryType
,
324 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
),
325 &PerformanceVariable
.BootPerformanceTablePointer
327 if (!EFI_ERROR (Status
)) {
328 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) (UINTN
) PerformanceVariable
.BootPerformanceTablePointer
;
331 if (mAcpiBootPerformanceTable
== NULL
) {
333 // Fail to allocate at specified address, continue to allocate at any address.
335 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) AllocatePeiAccessiblePages (
336 EfiReservedMemoryType
,
337 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
)
340 DEBUG ((DEBUG_INFO
, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable
));
341 if (mAcpiBootPerformanceTable
== NULL
) {
342 return EFI_OUT_OF_RESOURCES
;
345 // Fill Basic Boot record to Boot Performance Table.
347 CopyMem (mAcpiBootPerformanceTable
, &mBootPerformanceTableTemplate
, sizeof (mBootPerformanceTableTemplate
));
349 BootPerformanceDataSize
= mAcpiBootPerformanceTable
->Header
.Length
;
352 // Save Boot Performance Table address to Variable for use in S4 resume.
354 PerformanceVariable
.BootPerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiBootPerformanceTable
;
356 // Update Boot Performance Table Pointer in template.
358 mFirmwarePerformanceTableTemplate
.BootPointerRecord
.BootPerformanceTablePointer
= (UINT64
) (UINTN
) mAcpiBootPerformanceTable
;
361 // Save S3 Performance Table address to Variable for use in S4 resume.
363 PerformanceVariable
.S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiS3PerformanceTable
;
365 // Update S3 Performance Table Pointer in template.
367 mFirmwarePerformanceTableTemplate
.S3PointerRecord
.S3PerformanceTablePointer
= (UINT64
) (UINTN
) mAcpiS3PerformanceTable
;
369 // Save Runtime Performance Table pointers to Variable.
370 // Don't check SetVariable return status. It doesn't impact FPDT table generation.
373 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
374 &gEfiFirmwarePerformanceGuid
,
375 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
376 sizeof (PerformanceVariable
),
381 // Publish Firmware Performance Data Table.
383 FpdtAcpiTableChecksum ((UINT8
*) &mFirmwarePerformanceTableTemplate
, mFirmwarePerformanceTableTemplate
.Header
.Length
);
384 Status
= AcpiTableProtocol
->InstallAcpiTable (
386 &mFirmwarePerformanceTableTemplate
,
387 mFirmwarePerformanceTableTemplate
.Header
.Length
,
388 &mFirmwarePerformanceTableTemplateKey
390 if (EFI_ERROR (Status
)) {
391 if (mAcpiBootPerformanceTable
!= NULL
) {
392 FreePages (mAcpiBootPerformanceTable
, EFI_SIZE_TO_PAGES (BootPerformanceDataSize
));
394 if (mAcpiS3PerformanceTable
!= NULL
) {
395 FreePages (mAcpiS3PerformanceTable
, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
)));
397 mAcpiBootPerformanceTable
= NULL
;
398 mAcpiS3PerformanceTable
= NULL
;
405 Report status code listener of FPDT. This is used to collect performance data
406 for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT.
408 @param[in] CodeType Indicates the type of status code being reported.
409 @param[in] Value Describes the current status of a hardware or software entity.
410 This included information about the class and subclass that is used to
411 classify the entity as well as an operation.
412 @param[in] Instance The enumeration of a hardware or software entity within
413 the system. Valid instance numbers start with 1.
414 @param[in] CallerId This optional parameter may be used to identify the caller.
415 This parameter allows the status code driver to apply different rules to
417 @param[in] Data This optional parameter may be used to pass additional data.
419 @retval EFI_SUCCESS Status code is what we expected.
420 @retval EFI_UNSUPPORTED Status code not supported.
425 FpdtStatusCodeListenerDxe (
426 IN EFI_STATUS_CODE_TYPE CodeType
,
427 IN EFI_STATUS_CODE_VALUE Value
,
429 IN EFI_GUID
*CallerId
,
430 IN EFI_STATUS_CODE_DATA
*Data
436 // Check whether status code is what we are interested in.
438 if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) != EFI_PROGRESS_CODE
) {
439 return EFI_UNSUPPORTED
;
442 if (Value
== (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT
)) {
444 // DxeCore ReportStatusCode Enable so that the capability can be supported.
446 mDxeCoreReportStatusCodeEnable
= TRUE
;
449 Status
= EFI_SUCCESS
;
450 if (Value
== PcdGet32 (PcdProgressCodeOsLoaderLoad
)) {
452 // Progress code for OS Loader LoadImage.
454 if (mAcpiBootPerformanceTable
== NULL
) {
459 // Update OS Loader LoadImage Start for UEFI boot.
461 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderLoadImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
462 } else if (Value
== PcdGet32 (PcdProgressCodeOsLoaderStart
)) {
464 // Progress code for OS Loader StartImage.
466 if (mAcpiBootPerformanceTable
== NULL
) {
471 // Update OS Loader StartImage Start for UEFI boot.
473 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
474 } else if (Value
== (EFI_SOFTWARE_EFI_BOOT_SERVICE
| EFI_SW_BS_PC_EXIT_BOOT_SERVICES
)) {
476 // Unregister boot time report status code listener.
478 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
481 // Progress code for ExitBootServices.
483 if (mAcpiBootPerformanceTable
== NULL
) {
488 // Update ExitBootServicesExit for UEFI boot.
490 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesExit
= GetTimeInNanoSecond (GetPerformanceCounter ());
491 } else if (Value
== (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT
)) {
492 if (mAcpiBootPerformanceTable
== NULL
) {
494 // Firmware Performance Data Table not installed, do nothing.
500 // Update Firmware Basic Boot Performance Record for legacy boot.
502 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
505 // Dump FPDT Boot Performance record.
507 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
));
508 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderLoadImageStart = 0\n"));
509 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
));
510 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesEntry = 0\n"));
511 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesExit = 0\n"));
512 } else if (Value
== (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT
)) {
513 if (mAcpiBootPerformanceTable
== NULL
) {
515 // ACPI Firmware Performance Data Table not installed yet, install it now.
517 InstallFirmwarePerformanceDataTable ();
519 } else if (Data
!= NULL
&& CompareGuid (&Data
->Type
, &gEdkiiFpdtExtendedFirmwarePerformanceGuid
)) {
521 // Get the Boot performance table and then install it to ACPI table.
523 CopyMem (&mReceivedAcpiBootPerformanceTable
, Data
+ 1, Data
->Size
);
524 } else if (Data
!= NULL
&& CompareGuid (&Data
->Type
, &gEfiFirmwarePerformanceGuid
)) {
525 DEBUG ((DEBUG_ERROR
, "FpdtStatusCodeListenerDxe: Performance data reported through gEfiFirmwarePerformanceGuid will not be collected by FirmwarePerformanceDataTableDxe\n"));
526 Status
= EFI_UNSUPPORTED
;
529 // Ignore else progress code.
531 Status
= EFI_UNSUPPORTED
;
539 Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record
540 performance data for ExitBootServicesEntry in FPDT.
542 @param[in] Event The Event that is being processed.
543 @param[in] Context The Event Context.
548 FpdtExitBootServicesEventNotify (
553 if (!mDxeCoreReportStatusCodeEnable
) {
555 // When DxeCore Report Status Code is disabled,
556 // Unregister boot time report status code listener at ExitBootService Event.
558 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
561 if (mAcpiBootPerformanceTable
== NULL
) {
563 // Firmware Performance Data Table not installed, do nothing.
569 // Update Firmware Basic Boot Performance Record for UEFI boot.
571 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesEntry
= GetTimeInNanoSecond (GetPerformanceCounter ());
574 // Dump FPDT Boot Performance record.
576 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
));
577 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderLoadImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderLoadImageStart
));
578 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
));
579 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesEntry = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesEntry
));
581 // ExitBootServicesExit will be updated later, so don't dump it here.
586 The module Entry Point of the Firmware Performance Data Table DXE driver.
588 @param[in] ImageHandle The firmware allocated handle for the EFI image.
589 @param[in] SystemTable A pointer to the EFI System Table.
591 @retval EFI_SUCCESS The entry point is executed successfully.
592 @retval Other Some error occurs when executing this entry point.
597 FirmwarePerformanceDxeEntryPoint (
598 IN EFI_HANDLE ImageHandle
,
599 IN EFI_SYSTEM_TABLE
*SystemTable
603 EFI_HOB_GUID_TYPE
*GuidHob
;
604 FIRMWARE_SEC_PERFORMANCE
*Performance
;
609 mFirmwarePerformanceTableTemplate
.Header
.OemId
,
610 PcdGetPtr (PcdAcpiDefaultOemId
),
611 sizeof (mFirmwarePerformanceTableTemplate
.Header
.OemId
)
613 OemTableId
= PcdGet64 (PcdAcpiDefaultOemTableId
);
614 CopyMem (&mFirmwarePerformanceTableTemplate
.Header
.OemTableId
, &OemTableId
, sizeof (UINT64
));
615 mFirmwarePerformanceTableTemplate
.Header
.OemRevision
= PcdGet32 (PcdAcpiDefaultOemRevision
);
616 mFirmwarePerformanceTableTemplate
.Header
.CreatorId
= PcdGet32 (PcdAcpiDefaultCreatorId
);
617 mFirmwarePerformanceTableTemplate
.Header
.CreatorRevision
= PcdGet32 (PcdAcpiDefaultCreatorRevision
);
620 // Get Report Status Code Handler Protocol.
622 Status
= gBS
->LocateProtocol (&gEfiRscHandlerProtocolGuid
, NULL
, (VOID
**) &mRscHandlerProtocol
);
623 ASSERT_EFI_ERROR (Status
);
626 // Register report status code listener for OS Loader load and start.
628 Status
= mRscHandlerProtocol
->Register (FpdtStatusCodeListenerDxe
, TPL_HIGH_LEVEL
);
629 ASSERT_EFI_ERROR (Status
);
632 // Register the notify function to update FPDT on ExitBootServices Event.
634 Status
= gBS
->CreateEventEx (
637 FpdtExitBootServicesEventNotify
,
639 &gEfiEventExitBootServicesGuid
,
640 &mExitBootServicesEvent
642 ASSERT_EFI_ERROR (Status
);
645 // Retrieve GUID HOB data that contains the ResetEnd.
647 GuidHob
= GetFirstGuidHob (&gEfiFirmwarePerformanceGuid
);
648 if (GuidHob
!= NULL
) {
649 Performance
= (FIRMWARE_SEC_PERFORMANCE
*) GET_GUID_HOB_DATA (GuidHob
);
650 mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
= Performance
->ResetEnd
;
653 // SEC Performance Data Hob not found, ResetEnd in ACPI FPDT table will be 0.
655 DEBUG ((DEBUG_WARN
, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n"));
658 if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support
)) {
660 // Register callback function upon VariableArchProtocol and LockBoxProtocol
661 // to allocate S3 performance table memory and save the pointer to LockBox.
663 EfiCreateProtocolNotifyEvent (
664 &gEfiVariableArchProtocolGuid
,
666 FpdtAllocateS3PerformanceTableMemory
,
670 EfiCreateProtocolNotifyEvent (
671 &gEfiLockBoxProtocolGuid
,
673 FpdtAllocateS3PerformanceTableMemory
,
679 // Exclude S3 Performance Table Pointer from FPDT table template.
681 mFirmwarePerformanceTableTemplate
.Header
.Length
-= sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD
);