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>
29 #include <Library/UefiBootServicesTableLib.h>
30 #include <Library/UefiRuntimeServicesTableLib.h>
31 #include <Library/BaseLib.h>
32 #include <Library/DebugLib.h>
33 #include <Library/DxeServicesLib.h>
34 #include <Library/TimerLib.h>
35 #include <Library/BaseMemoryLib.h>
36 #include <Library/MemoryAllocationLib.h>
37 #include <Library/PcdLib.h>
38 #include <Library/HobLib.h>
39 #include <Library/LockBoxLib.h>
40 #include <Library/UefiLib.h>
42 #define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
44 EFI_RSC_HANDLER_PROTOCOL
*mRscHandlerProtocol
= NULL
;
46 BOOLEAN mLockBoxReady
= FALSE
;
47 EFI_EVENT mReadyToBootEvent
;
48 EFI_EVENT mLegacyBootEvent
;
49 EFI_EVENT mExitBootServicesEvent
;
50 UINTN mFirmwarePerformanceTableTemplateKey
= 0;
51 BOOLEAN mDxeCoreReportStatusCodeEnable
= FALSE
;
53 BOOT_PERFORMANCE_TABLE
*mAcpiBootPerformanceTable
= NULL
;
54 BOOT_PERFORMANCE_TABLE
*mReceivedAcpiBootPerformanceTable
= NULL
;
55 S3_PERFORMANCE_TABLE
*mAcpiS3PerformanceTable
= NULL
;
57 FIRMWARE_PERFORMANCE_TABLE mFirmwarePerformanceTableTemplate
= {
59 EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
,
60 sizeof (FIRMWARE_PERFORMANCE_TABLE
),
61 EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_REVISION
, // Revision
62 0x00, // Checksum will be updated at runtime
64 // It is expected that these values will be updated at EntryPoint.
66 {0x00}, // OEM ID is a 6 bytes long field
67 0x00, // OEM Table ID(8 bytes long)
70 0x00, // Creator Revision
73 // Firmware Basic Boot Performance Table Pointer Record.
77 EFI_ACPI_5_0_FPDT_RECORD_TYPE_FIRMWARE_BASIC_BOOT_POINTER
, // Type
78 sizeof (EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_POINTER_RECORD
), // Length
79 EFI_ACPI_5_0_FPDT_RECORD_REVISION_FIRMWARE_BASIC_BOOT_POINTER
// Revision
82 0 // BootPerformanceTablePointer will be updated at runtime.
85 // S3 Performance Table Pointer Record.
89 EFI_ACPI_5_0_FPDT_RECORD_TYPE_S3_PERFORMANCE_TABLE_POINTER
, // Type
90 sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD
), // Length
91 EFI_ACPI_5_0_FPDT_RECORD_REVISION_S3_PERFORMANCE_TABLE_POINTER
// Revision
94 0 // S3PerformanceTablePointer will be updated at runtime.
98 BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate
= {
100 EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE
,
101 sizeof (BOOT_PERFORMANCE_TABLE
)
105 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT
, // Type
106 sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD
), // Length
107 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT
// Revision
111 // These values will be updated at runtime.
114 0, // OsLoaderLoadImageStart
115 0, // OsLoaderStartImageStart
116 0, // ExitBootServicesEntry
117 0 // ExitBootServicesExit
121 S3_PERFORMANCE_TABLE mS3PerformanceTableTemplate
= {
123 EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE
,
124 sizeof (S3_PERFORMANCE_TABLE
)
128 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_RESUME
, // Type
129 sizeof (EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD
), // Length
130 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_RESUME
// Revision
133 // These values will be updated by Firmware Performance PEIM.
141 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_SUSPEND
, // Type
142 sizeof (EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD
), // Length
143 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_SUSPEND
// Revision
146 // These values will be updated bye Firmware Performance SMM driver.
154 This function calculates and updates an UINT8 checksum.
156 @param[in] Buffer Pointer to buffer to checksum
157 @param[in] Size Number of bytes to checksum
161 FpdtAcpiTableChecksum (
166 UINTN ChecksumOffset
;
168 ChecksumOffset
= OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
, Checksum
);
171 // Set checksum to 0 first.
173 Buffer
[ChecksumOffset
] = 0;
176 // Update checksum value.
178 Buffer
[ChecksumOffset
] = CalculateCheckSum8 (Buffer
, Size
);
182 Callback function upon VariableArchProtocol and LockBoxProtocol
183 to allocate S3 performance table memory and save the pointer to LockBox.
185 @param[in] Event Event whose notification function is being invoked.
186 @param[in] Context Pointer to the notification function's context.
190 FpdtAllocateS3PerformanceTableMemory (
197 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
199 EFI_PHYSICAL_ADDRESS S3PerformanceTablePointer
;
201 if (mLockBoxReady
&& (mAcpiS3PerformanceTable
!= NULL
)) {
203 // The memory for S3 performance table should have been ready,
204 // and the pointer should have been saved to LockBox, just return.
209 if (!mLockBoxReady
) {
210 Status
= gBS
->LocateProtocol (&gEfiLockBoxProtocolGuid
, NULL
, &Interface
);
211 if (!EFI_ERROR (Status
)) {
213 // LockBox services has been ready.
215 mLockBoxReady
= TRUE
;
219 if (mAcpiS3PerformanceTable
== NULL
) {
220 Status
= gBS
->LocateProtocol (&gEfiVariableArchProtocolGuid
, NULL
, &Interface
);
221 if (!EFI_ERROR (Status
)) {
223 // Try to allocate the same runtime buffer as last time boot.
225 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
226 Size
= sizeof (PerformanceVariable
);
227 Status
= gRT
->GetVariable (
228 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
229 &gEfiFirmwarePerformanceGuid
,
234 if (!EFI_ERROR (Status
)) {
235 Status
= gBS
->AllocatePages (
237 EfiReservedMemoryType
,
238 EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
)),
239 &PerformanceVariable
.S3PerformanceTablePointer
241 if (!EFI_ERROR (Status
)) {
242 mAcpiS3PerformanceTable
= (S3_PERFORMANCE_TABLE
*) (UINTN
) PerformanceVariable
.S3PerformanceTablePointer
;
245 if (mAcpiS3PerformanceTable
== NULL
) {
247 // Fail to allocate at specified address, continue to allocate at any address.
249 mAcpiS3PerformanceTable
= (S3_PERFORMANCE_TABLE
*) AllocatePeiAccessiblePages (
250 EfiReservedMemoryType
,
251 EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
))
254 DEBUG ((EFI_D_INFO
, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable
));
255 if (mAcpiS3PerformanceTable
!= NULL
) {
256 CopyMem (mAcpiS3PerformanceTable
, &mS3PerformanceTableTemplate
, sizeof (mS3PerformanceTableTemplate
));
261 if (mLockBoxReady
&& (mAcpiS3PerformanceTable
!= NULL
)) {
263 // If LockBox services has been ready and memory for FPDT S3 performance table has been allocated,
264 // save the pointer to LockBox for use in S3 resume.
266 S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiS3PerformanceTable
;
267 Status
= SaveLockBox (
268 &gFirmwarePerformanceS3PointerGuid
,
269 &S3PerformanceTablePointer
,
270 sizeof (EFI_PHYSICAL_ADDRESS
)
272 ASSERT_EFI_ERROR (Status
);
277 Install ACPI Firmware Performance Data Table (FPDT).
283 InstallFirmwarePerformanceDataTable (
288 EFI_ACPI_TABLE_PROTOCOL
*AcpiTableProtocol
;
289 UINTN BootPerformanceDataSize
;
290 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
294 // Get AcpiTable Protocol.
296 Status
= gBS
->LocateProtocol (&gEfiAcpiTableProtocolGuid
, NULL
, (VOID
**) &AcpiTableProtocol
);
297 if (EFI_ERROR (Status
)) {
301 if (mReceivedAcpiBootPerformanceTable
!= NULL
) {
302 mAcpiBootPerformanceTable
= mReceivedAcpiBootPerformanceTable
;
303 mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
= mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
;
306 // Try to allocate the same runtime buffer as last time boot.
308 BootPerformanceDataSize
= sizeof (BOOT_PERFORMANCE_TABLE
);
309 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
310 Size
= sizeof (PerformanceVariable
);
311 Status
= gRT
->GetVariable (
312 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
313 &gEfiFirmwarePerformanceGuid
,
318 if (!EFI_ERROR (Status
)) {
319 Status
= gBS
->AllocatePages (
321 EfiReservedMemoryType
,
322 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
),
323 &PerformanceVariable
.BootPerformanceTablePointer
325 if (!EFI_ERROR (Status
)) {
326 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) (UINTN
) PerformanceVariable
.BootPerformanceTablePointer
;
329 if (mAcpiBootPerformanceTable
== NULL
) {
331 // Fail to allocate at specified address, continue to allocate at any address.
333 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) AllocatePeiAccessiblePages (
334 EfiReservedMemoryType
,
335 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
)
338 DEBUG ((DEBUG_INFO
, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable
));
339 if (mAcpiBootPerformanceTable
== NULL
) {
340 return EFI_OUT_OF_RESOURCES
;
343 // Fill Basic Boot record to Boot Performance Table.
345 CopyMem (mAcpiBootPerformanceTable
, &mBootPerformanceTableTemplate
, sizeof (mBootPerformanceTableTemplate
));
347 BootPerformanceDataSize
= mAcpiBootPerformanceTable
->Header
.Length
;
350 // Save Boot Performance Table address to Variable for use in S4 resume.
352 PerformanceVariable
.BootPerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiBootPerformanceTable
;
354 // Update Boot Performance Table Pointer in template.
356 mFirmwarePerformanceTableTemplate
.BootPointerRecord
.BootPerformanceTablePointer
= (UINT64
) (UINTN
) mAcpiBootPerformanceTable
;
359 // Save S3 Performance Table address to Variable for use in S4 resume.
361 PerformanceVariable
.S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiS3PerformanceTable
;
363 // Update S3 Performance Table Pointer in template.
365 mFirmwarePerformanceTableTemplate
.S3PointerRecord
.S3PerformanceTablePointer
= (UINT64
) (UINTN
) mAcpiS3PerformanceTable
;
367 // Save Runtime Performance Table pointers to Variable.
368 // Don't check SetVariable return status. It doesn't impact FPDT table generation.
371 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
372 &gEfiFirmwarePerformanceGuid
,
373 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
374 sizeof (PerformanceVariable
),
379 // Publish Firmware Performance Data Table.
381 FpdtAcpiTableChecksum ((UINT8
*) &mFirmwarePerformanceTableTemplate
, mFirmwarePerformanceTableTemplate
.Header
.Length
);
382 Status
= AcpiTableProtocol
->InstallAcpiTable (
384 &mFirmwarePerformanceTableTemplate
,
385 mFirmwarePerformanceTableTemplate
.Header
.Length
,
386 &mFirmwarePerformanceTableTemplateKey
388 if (EFI_ERROR (Status
)) {
389 if (mAcpiBootPerformanceTable
!= NULL
) {
390 FreePages (mAcpiBootPerformanceTable
, EFI_SIZE_TO_PAGES (BootPerformanceDataSize
));
392 if (mAcpiS3PerformanceTable
!= NULL
) {
393 FreePages (mAcpiS3PerformanceTable
, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
)));
395 mAcpiBootPerformanceTable
= NULL
;
396 mAcpiS3PerformanceTable
= NULL
;
403 Report status code listener of FPDT. This is used to collect performance data
404 for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT.
406 @param[in] CodeType Indicates the type of status code being reported.
407 @param[in] Value Describes the current status of a hardware or software entity.
408 This included information about the class and subclass that is used to
409 classify the entity as well as an operation.
410 @param[in] Instance The enumeration of a hardware or software entity within
411 the system. Valid instance numbers start with 1.
412 @param[in] CallerId This optional parameter may be used to identify the caller.
413 This parameter allows the status code driver to apply different rules to
415 @param[in] Data This optional parameter may be used to pass additional data.
417 @retval EFI_SUCCESS Status code is what we expected.
418 @retval EFI_UNSUPPORTED Status code not supported.
423 FpdtStatusCodeListenerDxe (
424 IN EFI_STATUS_CODE_TYPE CodeType
,
425 IN EFI_STATUS_CODE_VALUE Value
,
427 IN EFI_GUID
*CallerId
,
428 IN EFI_STATUS_CODE_DATA
*Data
434 // Check whether status code is what we are interested in.
436 if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) != EFI_PROGRESS_CODE
) {
437 return EFI_UNSUPPORTED
;
440 if (Value
== (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT
)) {
442 // DxeCore ReportStatusCode Enable so that the capability can be supported.
444 mDxeCoreReportStatusCodeEnable
= TRUE
;
447 Status
= EFI_SUCCESS
;
448 if (Value
== PcdGet32 (PcdProgressCodeOsLoaderLoad
)) {
450 // Progress code for OS Loader LoadImage.
452 if (mAcpiBootPerformanceTable
== NULL
) {
457 // Update OS Loader LoadImage Start for UEFI boot.
459 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderLoadImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
460 } else if (Value
== PcdGet32 (PcdProgressCodeOsLoaderStart
)) {
462 // Progress code for OS Loader StartImage.
464 if (mAcpiBootPerformanceTable
== NULL
) {
469 // Update OS Loader StartImage Start for UEFI boot.
471 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
472 } else if (Value
== (EFI_SOFTWARE_EFI_BOOT_SERVICE
| EFI_SW_BS_PC_EXIT_BOOT_SERVICES
)) {
474 // Unregister boot time report status code listener.
476 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
479 // Progress code for ExitBootServices.
481 if (mAcpiBootPerformanceTable
== NULL
) {
486 // Update ExitBootServicesExit for UEFI boot.
488 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesExit
= GetTimeInNanoSecond (GetPerformanceCounter ());
489 } else if (Value
== (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT
)) {
490 if (mAcpiBootPerformanceTable
== NULL
) {
492 // Firmware Performance Data Table not installed, do nothing.
498 // Update Firmware Basic Boot Performance Record for legacy boot.
500 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
503 // Dump FPDT Boot Performance record.
505 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
));
506 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderLoadImageStart = 0\n"));
507 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
));
508 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesEntry = 0\n"));
509 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesExit = 0\n"));
510 } else if (Value
== (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT
)) {
511 if (mAcpiBootPerformanceTable
== NULL
) {
513 // ACPI Firmware Performance Data Table not installed yet, install it now.
515 InstallFirmwarePerformanceDataTable ();
517 } else if (Data
!= NULL
&& CompareGuid (&Data
->Type
, &gEdkiiFpdtExtendedFirmwarePerformanceGuid
)) {
519 // Get the Boot performance table and then install it to ACPI table.
521 CopyMem (&mReceivedAcpiBootPerformanceTable
, Data
+ 1, Data
->Size
);
522 } else if (Data
!= NULL
&& CompareGuid (&Data
->Type
, &gEfiFirmwarePerformanceGuid
)) {
523 DEBUG ((DEBUG_ERROR
, "FpdtStatusCodeListenerDxe: Performance data reported through gEfiFirmwarePerformanceGuid will not be collected by FirmwarePerformanceDataTableDxe\n"));
524 Status
= EFI_UNSUPPORTED
;
527 // Ignore else progress code.
529 Status
= EFI_UNSUPPORTED
;
537 Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record
538 performance data for ExitBootServicesEntry in FPDT.
540 @param[in] Event The Event that is being processed.
541 @param[in] Context The Event Context.
546 FpdtExitBootServicesEventNotify (
551 if (!mDxeCoreReportStatusCodeEnable
) {
553 // When DxeCore Report Status Code is disabled,
554 // Unregister boot time report status code listener at ExitBootService Event.
556 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
559 if (mAcpiBootPerformanceTable
== NULL
) {
561 // Firmware Performance Data Table not installed, do nothing.
567 // Update Firmware Basic Boot Performance Record for UEFI boot.
569 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesEntry
= GetTimeInNanoSecond (GetPerformanceCounter ());
572 // Dump FPDT Boot Performance record.
574 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
));
575 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderLoadImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderLoadImageStart
));
576 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
));
577 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesEntry = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesEntry
));
579 // ExitBootServicesExit will be updated later, so don't dump it here.
584 The module Entry Point of the Firmware Performance Data Table DXE driver.
586 @param[in] ImageHandle The firmware allocated handle for the EFI image.
587 @param[in] SystemTable A pointer to the EFI System Table.
589 @retval EFI_SUCCESS The entry point is executed successfully.
590 @retval Other Some error occurs when executing this entry point.
595 FirmwarePerformanceDxeEntryPoint (
596 IN EFI_HANDLE ImageHandle
,
597 IN EFI_SYSTEM_TABLE
*SystemTable
601 EFI_HOB_GUID_TYPE
*GuidHob
;
602 FIRMWARE_SEC_PERFORMANCE
*Performance
;
607 mFirmwarePerformanceTableTemplate
.Header
.OemId
,
608 PcdGetPtr (PcdAcpiDefaultOemId
),
609 sizeof (mFirmwarePerformanceTableTemplate
.Header
.OemId
)
611 OemTableId
= PcdGet64 (PcdAcpiDefaultOemTableId
);
612 CopyMem (&mFirmwarePerformanceTableTemplate
.Header
.OemTableId
, &OemTableId
, sizeof (UINT64
));
613 mFirmwarePerformanceTableTemplate
.Header
.OemRevision
= PcdGet32 (PcdAcpiDefaultOemRevision
);
614 mFirmwarePerformanceTableTemplate
.Header
.CreatorId
= PcdGet32 (PcdAcpiDefaultCreatorId
);
615 mFirmwarePerformanceTableTemplate
.Header
.CreatorRevision
= PcdGet32 (PcdAcpiDefaultCreatorRevision
);
618 // Get Report Status Code Handler Protocol.
620 Status
= gBS
->LocateProtocol (&gEfiRscHandlerProtocolGuid
, NULL
, (VOID
**) &mRscHandlerProtocol
);
621 ASSERT_EFI_ERROR (Status
);
624 // Register report status code listener for OS Loader load and start.
626 Status
= mRscHandlerProtocol
->Register (FpdtStatusCodeListenerDxe
, TPL_HIGH_LEVEL
);
627 ASSERT_EFI_ERROR (Status
);
630 // Register the notify function to update FPDT on ExitBootServices Event.
632 Status
= gBS
->CreateEventEx (
635 FpdtExitBootServicesEventNotify
,
637 &gEfiEventExitBootServicesGuid
,
638 &mExitBootServicesEvent
640 ASSERT_EFI_ERROR (Status
);
643 // Retrieve GUID HOB data that contains the ResetEnd.
645 GuidHob
= GetFirstGuidHob (&gEfiFirmwarePerformanceGuid
);
646 if (GuidHob
!= NULL
) {
647 Performance
= (FIRMWARE_SEC_PERFORMANCE
*) GET_GUID_HOB_DATA (GuidHob
);
648 mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
= Performance
->ResetEnd
;
651 // SEC Performance Data Hob not found, ResetEnd in ACPI FPDT table will be 0.
653 DEBUG ((DEBUG_WARN
, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n"));
656 if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support
)) {
658 // Register callback function upon VariableArchProtocol and LockBoxProtocol
659 // to allocate S3 performance table memory and save the pointer to LockBox.
661 EfiCreateProtocolNotifyEvent (
662 &gEfiVariableArchProtocolGuid
,
664 FpdtAllocateS3PerformanceTableMemory
,
668 EfiCreateProtocolNotifyEvent (
669 &gEfiLockBoxProtocolGuid
,
671 FpdtAllocateS3PerformanceTableMemory
,
677 // Exclude S3 Performance Table Pointer from FPDT table template.
679 mFirmwarePerformanceTableTemplate
.Header
.Length
-= sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD
);