diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:17:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:17:27 +0000 |
commit | f215e02bf85f68d3a6106c2a1f4f7f063f819064 (patch) | |
tree | 6bb5b92c046312c4e95ac2620b10ddf482d3fa8b /src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures | |
parent | Initial commit. (diff) | |
download | virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.tar.xz virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.zip |
Adding upstream version 7.0.14-dfsg.upstream/7.0.14-dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures')
8 files changed, 363 insertions, 0 deletions
diff --git a/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c new file mode 100644 index 00000000..11896ded --- /dev/null +++ b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c @@ -0,0 +1,136 @@ +/** @file + CPU Features DXE driver to initialize CPU features. + + Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR> + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include <PiDxe.h> + +#include <Library/BaseLib.h> +#include <Library/DebugLib.h> +#include <Library/UefiLib.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/RegisterCpuFeaturesLib.h> +#include <Library/HobLib.h> + +#include <Protocol/SmmConfiguration.h> +#include <Guid/CpuFeaturesInitDone.h> + + +/** + Worker function to perform CPU feature initialization. + +**/ +VOID +CpuFeaturesInitializeWorker ( + VOID + ) +{ + EFI_STATUS Status; + EFI_HANDLE Handle; + + CpuFeaturesDetect (); + + CpuFeaturesInitialize (); + + // + // Install CPU Features Init Done Protocol + // + Handle = NULL; + Status = gBS->InstallProtocolInterface ( + &Handle, + &gEdkiiCpuFeaturesInitDoneGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); +} + +/** + Event notification that initialize CPU features when gEfiSmmConfigurationProtocol installs. + + @param[in] Event The Event that is being processed, not used. + @param[in] Context Event Context, not used. +**/ +VOID +EFIAPI +SmmConfigurationEventNotify ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration; + + // + // Make sure this notification is for this handler + // + Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID **)&SmmConfiguration); + if (EFI_ERROR (Status)) { + return; + } + + CpuFeaturesInitializeWorker (); +} + +/** + CPU Features driver entry point function. + + If PcdCpuFeaturesInitAfterSmmRelocation is TRUE, it will register one + SMM Configuration Protocol notify function to perform CPU features + initialization. Otherwise, it will perform CPU features initialization + directly. + + @param ImageHandle Image handle this driver. + @param SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS CPU Features is initialized successfully. +**/ +EFI_STATUS +EFIAPI +CpuFeaturesDxeInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + VOID *Registration; + EFI_STATUS Status; + EFI_HANDLE Handle; + + if (GetFirstGuidHob (&gEdkiiCpuFeaturesInitDoneGuid) != NULL) { + // + // Try to find HOB first. This HOB exist means CPU features have + // been initialized by CpuFeaturesPei driver, just install + // gEdkiiCpuFeaturesInitDoneGuid. + // + Handle = NULL; + Status = gBS->InstallProtocolInterface ( + &Handle, + &gEdkiiCpuFeaturesInitDoneGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + return Status; + } + + if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) { + // + // Install notification callback on SMM Configuration Protocol + // + EfiCreateProtocolNotifyEvent ( + &gEfiSmmConfigurationProtocolGuid, + TPL_CALLBACK, + SmmConfigurationEventNotify, + NULL, + &Registration + ); + } else { + CpuFeaturesInitializeWorker (); + } + + return EFI_SUCCESS; +} + diff --git a/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf new file mode 100644 index 00000000..b80ee549 --- /dev/null +++ b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf @@ -0,0 +1,48 @@ +## @file +# CPU Features DXE driver. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CpuFeaturesDxe + MODULE_UNI_FILE = CpuFeaturesDxe.uni + FILE_GUID = 63EB1B62-10C9-4693-88AC-AE0999EA87F8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + + ENTRY_POINT = CpuFeaturesDxeInitialize + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiLib + UefiDriverEntryPoint + UefiBootServicesTableLib + RegisterCpuFeaturesLib + HobLib + +[Sources] + CpuFeaturesDxe.c + +[Guids] + gEdkiiCpuFeaturesInitDoneGuid ## PRODUCES ## UNDEFINED # protocol GUID installed + +[Protocols] + gEfiSmmConfigurationProtocolGuid ## NOTIFY + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation ## CONSUMES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + CpuFeaturesDxeExtra.uni diff --git a/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni new file mode 100644 index 00000000..e970eb30 --- /dev/null +++ b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni @@ -0,0 +1,16 @@ +// /** @file
+// CPU Features DXE driver.
+//
+// CPU Features DXE driver.
+//
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT #language en-US "CPU Features DXE driver to initialize CPU features."
+
+#string STR_MODULE_DESCRIPTION #language en-US "CPU Features DXE driver to initialize CPU features."
+
diff --git a/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni new file mode 100644 index 00000000..82cb70c9 --- /dev/null +++ b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni @@ -0,0 +1,14 @@ +// /** @file
+// CpuFeaturesDxe Localized Strings and Content
+//
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+// **/
+
+#string STR_PROPERTIES_MODULE_NAME
+#language en-US
+"CPU Features DXE Driver"
+
+
diff --git a/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c new file mode 100644 index 00000000..f631797a --- /dev/null +++ b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c @@ -0,0 +1,75 @@ +/** @file + CPU Features PEIM driver to initialize CPU features. + + Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include <PiPei.h> + +#include <Library/BaseLib.h> +#include <Library/DebugLib.h> +#include <Library/PeiServicesLib.h> +#include <Library/RegisterCpuFeaturesLib.h> +#include <Library/HobLib.h> + +#include <Guid/CpuFeaturesInitDone.h> + +EFI_PEI_PPI_DESCRIPTOR mPeiCpuFeaturesInitDonePpiDesc = { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEdkiiCpuFeaturesInitDoneGuid, + NULL +}; + +/** + CPU Features driver entry point function. + + It will perform CPU features initialization, except for + PcdCpuFeaturesInitOnS3Resume is FALSE on S3 resume. + + @param FileHandle Handle of the file being invoked. + @param PeiServices Describes the list of possible PEI Services. + + @retval EFI_SUCCESS CPU Features is initialized successfully. +**/ +EFI_STATUS +EFIAPI +CpuFeaturesPeimInitialize ( + IN EFI_PEI_FILE_HANDLE FileHandle, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; + + Status = PeiServicesGetBootMode (&BootMode); + ASSERT_EFI_ERROR (Status); + + if (BootMode == BOOT_ON_S3_RESUME && + !PcdGetBool (PcdCpuFeaturesInitOnS3Resume)) { + // + // Does nothing when if PcdCpuFeaturesInitOnS3Resume is FLASE + // on S3 boot mode + // + return EFI_SUCCESS; + } + + CpuFeaturesDetect (); + + CpuFeaturesInitialize (); + + // + // Install CPU Features Init Done PPI + // + Status = PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc); + ASSERT_EFI_ERROR (Status); + + // + // Build HOB to let CpuFeatureDxe driver skip the initialization process. + // + BuildGuidHob (&gEdkiiCpuFeaturesInitDoneGuid, 0); + + return EFI_SUCCESS; +} + diff --git a/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf new file mode 100644 index 00000000..9fbf6109 --- /dev/null +++ b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf @@ -0,0 +1,44 @@ +## @file +# CPU Features PEIM driver. +# +# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = CpuFeaturesPei + MODULE_UNI_FILE = CpuFeaturesPei.uni + FILE_GUID = 183BB3E1-A1E5-4445-8AC9-0E83B6547E0E + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + + ENTRY_POINT = CpuFeaturesPeimInitialize + +[Packages] + MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + PeimEntryPoint + PeiServicesLib + RegisterCpuFeaturesLib + HobLib + +[Sources] + CpuFeaturesPei.c + +[Guids] + gEdkiiCpuFeaturesInitDoneGuid ## PRODUCES ## UNDEFINED # PPI GUID installed + +[Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume ## CONSUMES + +[Depex] + TRUE + +[UserExtensions.TianoCore."ExtraFiles"] + CpuFeaturesPeiExtra.uni diff --git a/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni new file mode 100644 index 00000000..d57fa8fc --- /dev/null +++ b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni @@ -0,0 +1,16 @@ +// /** @file
+// CPU Features PEIM driver.
+//
+// CPU Features PEIM driver.
+//
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT #language en-US "CPU Features PEIM driver to initialize CPU features."
+
+#string STR_MODULE_DESCRIPTION #language en-US "CPU Features PEIM driver to initialize CPU features."
+
diff --git a/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni new file mode 100644 index 00000000..dcc8fc71 --- /dev/null +++ b/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni @@ -0,0 +1,14 @@ +// /** @file
+// CpuFeaturesPei Localized Strings and Content
+//
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+// **/
+
+#string STR_PROPERTIES_MODULE_NAME
+#language en-US
+"CPU Features PEIM Driver"
+
+
|