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/TimerLib.h>
36 #include <Library/BaseMemoryLib.h>
37 #include <Library/MemoryAllocationLib.h>
38 #include <Library/PcdLib.h>
39 #include <Library/HobLib.h>
40 #include <Library/LockBoxLib.h>
41 #include <Library/UefiLib.h>
43 #define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
45 EFI_RSC_HANDLER_PROTOCOL
*mRscHandlerProtocol
= NULL
;
47 BOOLEAN mLockBoxReady
= FALSE
;
48 EFI_EVENT mReadyToBootEvent
;
49 EFI_EVENT mLegacyBootEvent
;
50 EFI_EVENT mExitBootServicesEvent
;
51 UINTN mFirmwarePerformanceTableTemplateKey
= 0;
52 BOOLEAN mDxeCoreReportStatusCodeEnable
= FALSE
;
54 BOOT_PERFORMANCE_TABLE
*mAcpiBootPerformanceTable
= NULL
;
55 BOOT_PERFORMANCE_TABLE
*mReceivedAcpiBootPerformanceTable
= NULL
;
56 S3_PERFORMANCE_TABLE
*mAcpiS3PerformanceTable
= NULL
;
58 FIRMWARE_PERFORMANCE_TABLE mFirmwarePerformanceTableTemplate
= {
60 EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
,
61 sizeof (FIRMWARE_PERFORMANCE_TABLE
),
62 EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_REVISION
, // Revision
63 0x00, // Checksum will be updated at runtime
65 // It is expected that these values will be updated at EntryPoint.
67 {0x00}, // OEM ID is a 6 bytes long field
68 0x00, // OEM Table ID(8 bytes long)
71 0x00, // Creator Revision
74 // Firmware Basic Boot Performance Table Pointer Record.
78 EFI_ACPI_5_0_FPDT_RECORD_TYPE_FIRMWARE_BASIC_BOOT_POINTER
, // Type
79 sizeof (EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_POINTER_RECORD
), // Length
80 EFI_ACPI_5_0_FPDT_RECORD_REVISION_FIRMWARE_BASIC_BOOT_POINTER
// Revision
83 0 // BootPerformanceTablePointer will be updated at runtime.
86 // S3 Performance Table Pointer Record.
90 EFI_ACPI_5_0_FPDT_RECORD_TYPE_S3_PERFORMANCE_TABLE_POINTER
, // Type
91 sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD
), // Length
92 EFI_ACPI_5_0_FPDT_RECORD_REVISION_S3_PERFORMANCE_TABLE_POINTER
// Revision
95 0 // S3PerformanceTablePointer will be updated at runtime.
99 BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate
= {
101 EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE
,
102 sizeof (BOOT_PERFORMANCE_TABLE
)
106 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT
, // Type
107 sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD
), // Length
108 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT
// Revision
112 // These values will be updated at runtime.
115 0, // OsLoaderLoadImageStart
116 0, // OsLoaderStartImageStart
117 0, // ExitBootServicesEntry
118 0 // ExitBootServicesExit
122 S3_PERFORMANCE_TABLE mS3PerformanceTableTemplate
= {
124 EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_SIGNATURE
,
125 sizeof (S3_PERFORMANCE_TABLE
)
129 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_RESUME
, // Type
130 sizeof (EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD
), // Length
131 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_RESUME
// Revision
134 // These values will be updated by Firmware Performance PEIM.
142 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_S3_SUSPEND
, // Type
143 sizeof (EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD
), // Length
144 EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_S3_SUSPEND
// Revision
147 // These values will be updated bye Firmware Performance SMM driver.
155 This function calculates and updates an UINT8 checksum.
157 @param[in] Buffer Pointer to buffer to checksum
158 @param[in] Size Number of bytes to checksum
162 FpdtAcpiTableChecksum (
167 UINTN ChecksumOffset
;
169 ChecksumOffset
= OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
, Checksum
);
172 // Set checksum to 0 first.
174 Buffer
[ChecksumOffset
] = 0;
177 // Update checksum value.
179 Buffer
[ChecksumOffset
] = CalculateCheckSum8 (Buffer
, Size
);
183 Allocate EfiReservedMemoryType below 4G memory address.
185 This function allocates EfiReservedMemoryType below 4G memory address.
187 @param[in] Size Size of memory to allocate.
189 @return Allocated address for output.
193 FpdtAllocateReservedMemoryBelow4G (
198 EFI_PHYSICAL_ADDRESS Address
;
203 Pages
= EFI_SIZE_TO_PAGES (Size
);
204 Address
= 0xffffffff;
206 Status
= gBS
->AllocatePages (
208 EfiReservedMemoryType
,
212 ASSERT_EFI_ERROR (Status
);
214 if (!EFI_ERROR (Status
)) {
215 Buffer
= (VOID
*) (UINTN
) Address
;
216 ZeroMem (Buffer
, Size
);
223 Callback function upon VariableArchProtocol and LockBoxProtocol
224 to allocate S3 performance table memory and save the pointer to LockBox.
226 @param[in] Event Event whose notification function is being invoked.
227 @param[in] Context Pointer to the notification function's context.
231 FpdtAllocateS3PerformanceTableMemory (
238 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
240 EFI_PHYSICAL_ADDRESS S3PerformanceTablePointer
;
242 if (mLockBoxReady
&& (mAcpiS3PerformanceTable
!= NULL
)) {
244 // The memory for S3 performance table should have been ready,
245 // and the pointer should have been saved to LockBox, just return.
250 if (!mLockBoxReady
) {
251 Status
= gBS
->LocateProtocol (&gEfiLockBoxProtocolGuid
, NULL
, &Interface
);
252 if (!EFI_ERROR (Status
)) {
254 // LockBox services has been ready.
256 mLockBoxReady
= TRUE
;
260 if (mAcpiS3PerformanceTable
== NULL
) {
261 Status
= gBS
->LocateProtocol (&gEfiVariableArchProtocolGuid
, NULL
, &Interface
);
262 if (!EFI_ERROR (Status
)) {
264 // Try to allocate the same runtime buffer as last time boot.
266 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
267 Size
= sizeof (PerformanceVariable
);
268 Status
= gRT
->GetVariable (
269 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
270 &gEfiFirmwarePerformanceGuid
,
275 if (!EFI_ERROR (Status
)) {
276 Status
= gBS
->AllocatePages (
278 EfiReservedMemoryType
,
279 EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
)),
280 &PerformanceVariable
.S3PerformanceTablePointer
282 if (!EFI_ERROR (Status
)) {
283 mAcpiS3PerformanceTable
= (S3_PERFORMANCE_TABLE
*) (UINTN
) PerformanceVariable
.S3PerformanceTablePointer
;
286 if (mAcpiS3PerformanceTable
== NULL
) {
288 // Fail to allocate at specified address, continue to allocate at any address.
290 mAcpiS3PerformanceTable
= (S3_PERFORMANCE_TABLE
*) FpdtAllocateReservedMemoryBelow4G (sizeof (S3_PERFORMANCE_TABLE
));
292 DEBUG ((EFI_D_INFO
, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable
));
293 if (mAcpiS3PerformanceTable
!= NULL
) {
294 CopyMem (mAcpiS3PerformanceTable
, &mS3PerformanceTableTemplate
, sizeof (mS3PerformanceTableTemplate
));
299 if (mLockBoxReady
&& (mAcpiS3PerformanceTable
!= NULL
)) {
301 // If LockBox services has been ready and memory for FPDT S3 performance table has been allocated,
302 // save the pointer to LockBox for use in S3 resume.
304 S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiS3PerformanceTable
;
305 Status
= SaveLockBox (
306 &gFirmwarePerformanceS3PointerGuid
,
307 &S3PerformanceTablePointer
,
308 sizeof (EFI_PHYSICAL_ADDRESS
)
310 ASSERT_EFI_ERROR (Status
);
315 Install ACPI Firmware Performance Data Table (FPDT).
321 InstallFirmwarePerformanceDataTable (
326 EFI_ACPI_TABLE_PROTOCOL
*AcpiTableProtocol
;
327 UINTN BootPerformanceDataSize
;
328 FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable
;
332 // Get AcpiTable Protocol.
334 Status
= gBS
->LocateProtocol (&gEfiAcpiTableProtocolGuid
, NULL
, (VOID
**) &AcpiTableProtocol
);
335 if (EFI_ERROR (Status
)) {
339 if (mReceivedAcpiBootPerformanceTable
!= NULL
) {
340 mAcpiBootPerformanceTable
= mReceivedAcpiBootPerformanceTable
;
341 mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
= mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
;
344 // Try to allocate the same runtime buffer as last time boot.
346 BootPerformanceDataSize
= sizeof (BOOT_PERFORMANCE_TABLE
);
347 ZeroMem (&PerformanceVariable
, sizeof (PerformanceVariable
));
348 Size
= sizeof (PerformanceVariable
);
349 Status
= gRT
->GetVariable (
350 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
351 &gEfiFirmwarePerformanceGuid
,
356 if (!EFI_ERROR (Status
)) {
357 Status
= gBS
->AllocatePages (
359 EfiReservedMemoryType
,
360 EFI_SIZE_TO_PAGES (BootPerformanceDataSize
),
361 &PerformanceVariable
.BootPerformanceTablePointer
363 if (!EFI_ERROR (Status
)) {
364 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) (UINTN
) PerformanceVariable
.BootPerformanceTablePointer
;
367 if (mAcpiBootPerformanceTable
== NULL
) {
369 // Fail to allocate at specified address, continue to allocate at any address.
371 mAcpiBootPerformanceTable
= (BOOT_PERFORMANCE_TABLE
*) FpdtAllocateReservedMemoryBelow4G (BootPerformanceDataSize
);
373 DEBUG ((DEBUG_INFO
, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable
));
374 if (mAcpiBootPerformanceTable
== NULL
) {
375 return EFI_OUT_OF_RESOURCES
;
378 // Fill Basic Boot record to Boot Performance Table.
380 CopyMem (mAcpiBootPerformanceTable
, &mBootPerformanceTableTemplate
, sizeof (mBootPerformanceTableTemplate
));
382 BootPerformanceDataSize
= mAcpiBootPerformanceTable
->Header
.Length
;
385 // Save Boot Performance Table address to Variable for use in S4 resume.
387 PerformanceVariable
.BootPerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiBootPerformanceTable
;
389 // Update Boot Performance Table Pointer in template.
391 mFirmwarePerformanceTableTemplate
.BootPointerRecord
.BootPerformanceTablePointer
= (UINT64
) (UINTN
) mAcpiBootPerformanceTable
;
394 // Save S3 Performance Table address to Variable for use in S4 resume.
396 PerformanceVariable
.S3PerformanceTablePointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) mAcpiS3PerformanceTable
;
398 // Update S3 Performance Table Pointer in template.
400 mFirmwarePerformanceTableTemplate
.S3PointerRecord
.S3PerformanceTablePointer
= (UINT64
) (UINTN
) mAcpiS3PerformanceTable
;
402 // Save Runtime Performance Table pointers to Variable.
403 // Don't check SetVariable return status. It doesn't impact FPDT table generation.
406 EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME
,
407 &gEfiFirmwarePerformanceGuid
,
408 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
409 sizeof (PerformanceVariable
),
414 // Publish Firmware Performance Data Table.
416 FpdtAcpiTableChecksum ((UINT8
*) &mFirmwarePerformanceTableTemplate
, mFirmwarePerformanceTableTemplate
.Header
.Length
);
417 Status
= AcpiTableProtocol
->InstallAcpiTable (
419 &mFirmwarePerformanceTableTemplate
,
420 mFirmwarePerformanceTableTemplate
.Header
.Length
,
421 &mFirmwarePerformanceTableTemplateKey
423 if (EFI_ERROR (Status
)) {
424 if (mAcpiBootPerformanceTable
!= NULL
) {
425 FreePages (mAcpiBootPerformanceTable
, EFI_SIZE_TO_PAGES (BootPerformanceDataSize
));
427 if (mAcpiS3PerformanceTable
!= NULL
) {
428 FreePages (mAcpiS3PerformanceTable
, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE
)));
430 mAcpiBootPerformanceTable
= NULL
;
431 mAcpiS3PerformanceTable
= NULL
;
438 Report status code listener of FPDT. This is used to collect performance data
439 for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT.
441 @param[in] CodeType Indicates the type of status code being reported.
442 @param[in] Value Describes the current status of a hardware or software entity.
443 This included information about the class and subclass that is used to
444 classify the entity as well as an operation.
445 @param[in] Instance The enumeration of a hardware or software entity within
446 the system. Valid instance numbers start with 1.
447 @param[in] CallerId This optional parameter may be used to identify the caller.
448 This parameter allows the status code driver to apply different rules to
450 @param[in] Data This optional parameter may be used to pass additional data.
452 @retval EFI_SUCCESS Status code is what we expected.
453 @retval EFI_UNSUPPORTED Status code not supported.
458 FpdtStatusCodeListenerDxe (
459 IN EFI_STATUS_CODE_TYPE CodeType
,
460 IN EFI_STATUS_CODE_VALUE Value
,
462 IN EFI_GUID
*CallerId
,
463 IN EFI_STATUS_CODE_DATA
*Data
469 // Check whether status code is what we are interested in.
471 if ((CodeType
& EFI_STATUS_CODE_TYPE_MASK
) != EFI_PROGRESS_CODE
) {
472 return EFI_UNSUPPORTED
;
475 if (Value
== (EFI_SOFTWARE_DXE_CORE
| EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT
)) {
477 // DxeCore ReportStatusCode Enable so that the capability can be supported.
479 mDxeCoreReportStatusCodeEnable
= TRUE
;
482 Status
= EFI_SUCCESS
;
483 if (Value
== PcdGet32 (PcdProgressCodeOsLoaderLoad
)) {
485 // Progress code for OS Loader LoadImage.
487 if (mAcpiBootPerformanceTable
== NULL
) {
492 // Update OS Loader LoadImage Start for UEFI boot.
494 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderLoadImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
495 } else if (Value
== PcdGet32 (PcdProgressCodeOsLoaderStart
)) {
497 // Progress code for OS Loader StartImage.
499 if (mAcpiBootPerformanceTable
== NULL
) {
504 // Update OS Loader StartImage Start for UEFI boot.
506 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
507 } else if (Value
== (EFI_SOFTWARE_EFI_BOOT_SERVICE
| EFI_SW_BS_PC_EXIT_BOOT_SERVICES
)) {
509 // Unregister boot time report status code listener.
511 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
514 // Progress code for ExitBootServices.
516 if (mAcpiBootPerformanceTable
== NULL
) {
521 // Update ExitBootServicesExit for UEFI boot.
523 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesExit
= GetTimeInNanoSecond (GetPerformanceCounter ());
524 } else if (Value
== (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT
)) {
525 if (mAcpiBootPerformanceTable
== NULL
) {
527 // Firmware Performance Data Table not installed, do nothing.
533 // Update Firmware Basic Boot Performance Record for legacy boot.
535 mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
= GetTimeInNanoSecond (GetPerformanceCounter ());
538 // Dump FPDT Boot Performance record.
540 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
));
541 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderLoadImageStart = 0\n"));
542 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
));
543 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesEntry = 0\n"));
544 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesExit = 0\n"));
545 } else if (Value
== (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT
)) {
546 if (mAcpiBootPerformanceTable
== NULL
) {
548 // ACPI Firmware Performance Data Table not installed yet, install it now.
550 InstallFirmwarePerformanceDataTable ();
552 } else if (Data
!= NULL
&& CompareGuid (&Data
->Type
, &gEdkiiFpdtExtendedFirmwarePerformanceGuid
)) {
554 // Get the Boot performance table and then install it to ACPI table.
556 CopyMem (&mReceivedAcpiBootPerformanceTable
, Data
+ 1, Data
->Size
);
557 } else if (Data
!= NULL
&& CompareGuid (&Data
->Type
, &gEfiFirmwarePerformanceGuid
)) {
558 DEBUG ((DEBUG_ERROR
, "FpdtStatusCodeListenerDxe: Performance data reported through gEfiFirmwarePerformanceGuid will not be collected by FirmwarePerformanceDataTableDxe\n"));
559 Status
= EFI_UNSUPPORTED
;
562 // Ignore else progress code.
564 Status
= EFI_UNSUPPORTED
;
572 Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record
573 performance data for ExitBootServicesEntry in FPDT.
575 @param[in] Event The Event that is being processed.
576 @param[in] Context The Event Context.
581 FpdtExitBootServicesEventNotify (
586 if (!mDxeCoreReportStatusCodeEnable
) {
588 // When DxeCore Report Status Code is disabled,
589 // Unregister boot time report status code listener at ExitBootService Event.
591 mRscHandlerProtocol
->Unregister (FpdtStatusCodeListenerDxe
);
594 if (mAcpiBootPerformanceTable
== NULL
) {
596 // Firmware Performance Data Table not installed, do nothing.
602 // Update Firmware Basic Boot Performance Record for UEFI boot.
604 mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesEntry
= GetTimeInNanoSecond (GetPerformanceCounter ());
607 // Dump FPDT Boot Performance record.
609 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ResetEnd
));
610 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderLoadImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderLoadImageStart
));
611 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.OsLoaderStartImageStart
));
612 DEBUG ((EFI_D_INFO
, "FPDT: Boot Performance - ExitBootServicesEntry = %ld\n", mAcpiBootPerformanceTable
->BasicBoot
.ExitBootServicesEntry
));
614 // ExitBootServicesExit will be updated later, so don't dump it here.
619 The module Entry Point of the Firmware Performance Data Table DXE driver.
621 @param[in] ImageHandle The firmware allocated handle for the EFI image.
622 @param[in] SystemTable A pointer to the EFI System Table.
624 @retval EFI_SUCCESS The entry point is executed successfully.
625 @retval Other Some error occurs when executing this entry point.
630 FirmwarePerformanceDxeEntryPoint (
631 IN EFI_HANDLE ImageHandle
,
632 IN EFI_SYSTEM_TABLE
*SystemTable
636 EFI_HOB_GUID_TYPE
*GuidHob
;
637 FIRMWARE_SEC_PERFORMANCE
*Performance
;
642 mFirmwarePerformanceTableTemplate
.Header
.OemId
,
643 PcdGetPtr (PcdAcpiDefaultOemId
),
644 sizeof (mFirmwarePerformanceTableTemplate
.Header
.OemId
)
646 OemTableId
= PcdGet64 (PcdAcpiDefaultOemTableId
);
647 CopyMem (&mFirmwarePerformanceTableTemplate
.Header
.OemTableId
, &OemTableId
, sizeof (UINT64
));
648 mFirmwarePerformanceTableTemplate
.Header
.OemRevision
= PcdGet32 (PcdAcpiDefaultOemRevision
);
649 mFirmwarePerformanceTableTemplate
.Header
.CreatorId
= PcdGet32 (PcdAcpiDefaultCreatorId
);
650 mFirmwarePerformanceTableTemplate
.Header
.CreatorRevision
= PcdGet32 (PcdAcpiDefaultCreatorRevision
);
653 // Get Report Status Code Handler Protocol.
655 Status
= gBS
->LocateProtocol (&gEfiRscHandlerProtocolGuid
, NULL
, (VOID
**) &mRscHandlerProtocol
);
656 ASSERT_EFI_ERROR (Status
);
659 // Register report status code listener for OS Loader load and start.
661 Status
= mRscHandlerProtocol
->Register (FpdtStatusCodeListenerDxe
, TPL_HIGH_LEVEL
);
662 ASSERT_EFI_ERROR (Status
);
665 // Register the notify function to update FPDT on ExitBootServices Event.
667 Status
= gBS
->CreateEventEx (
670 FpdtExitBootServicesEventNotify
,
672 &gEfiEventExitBootServicesGuid
,
673 &mExitBootServicesEvent
675 ASSERT_EFI_ERROR (Status
);
678 // Retrieve GUID HOB data that contains the ResetEnd.
680 GuidHob
= GetFirstGuidHob (&gEfiFirmwarePerformanceGuid
);
681 if (GuidHob
!= NULL
) {
682 Performance
= (FIRMWARE_SEC_PERFORMANCE
*) GET_GUID_HOB_DATA (GuidHob
);
683 mBootPerformanceTableTemplate
.BasicBoot
.ResetEnd
= Performance
->ResetEnd
;
686 // SEC Performance Data Hob not found, ResetEnd in ACPI FPDT table will be 0.
688 DEBUG ((DEBUG_WARN
, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n"));
691 if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support
)) {
693 // Register callback function upon VariableArchProtocol and LockBoxProtocol
694 // to allocate S3 performance table memory and save the pointer to LockBox.
696 EfiCreateProtocolNotifyEvent (
697 &gEfiVariableArchProtocolGuid
,
699 FpdtAllocateS3PerformanceTableMemory
,
703 EfiCreateProtocolNotifyEvent (
704 &gEfiLockBoxProtocolGuid
,
706 FpdtAllocateS3PerformanceTableMemory
,
712 // Exclude S3 Performance Table Pointer from FPDT table template.
714 mFirmwarePerformanceTableTemplate
.Header
.Length
-= sizeof (EFI_ACPI_5_0_FPDT_S3_PERFORMANCE_TABLE_POINTER_RECORD
);