-/** @file
- CPU Features DXE driver to initialize CPU features.
-
- Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <PiDxe.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/RegisterCpuFeaturesLib.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;
-
- if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) {
- //
- // Install notification callback on SMM Configuration Protocol
- //
- EfiCreateProtocolNotifyEvent (
- &gEfiSmmConfigurationProtocolGuid,
- TPL_CALLBACK,
- SmmConfigurationEventNotify,
- NULL,
- &Registration
- );
- } else {
- CpuFeaturesInitializeWorker ();
- }
-
- return EFI_SUCCESS;
-}
-
+/** @file\r
+ CPU Features DXE driver to initialize CPU features.\r
+\r
+ Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/RegisterCpuFeaturesLib.h>\r
+#include <Library/HobLib.h>\r
+\r
+#include <Protocol/SmmConfiguration.h>\r
+#include <Guid/CpuFeaturesInitDone.h>\r
+\r
+\r
+/**\r
+ Worker function to perform CPU feature initialization.\r
+\r
+**/\r
+VOID\r
+CpuFeaturesInitializeWorker (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE Handle;\r
+\r
+ CpuFeaturesDetect ();\r
+\r
+ CpuFeaturesInitialize ();\r
+\r
+ //\r
+ // Install CPU Features Init Done Protocol\r
+ //\r
+ Handle = NULL;\r
+ Status = gBS->InstallProtocolInterface (\r
+ &Handle,\r
+ &gEdkiiCpuFeaturesInitDoneGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+ Event notification that initialize CPU features when gEfiSmmConfigurationProtocol installs.\r
+\r
+ @param[in] Event The Event that is being processed, not used.\r
+ @param[in] Context Event Context, not used.\r
+**/\r
+VOID\r
+EFIAPI\r
+SmmConfigurationEventNotify (\r
+ IN EFI_EVENT Event,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_SMM_CONFIGURATION_PROTOCOL *SmmConfiguration;\r
+\r
+ //\r
+ // Make sure this notification is for this handler\r
+ //\r
+ Status = gBS->LocateProtocol (&gEfiSmmConfigurationProtocolGuid, NULL, (VOID **)&SmmConfiguration);\r
+ if (EFI_ERROR (Status)) {\r
+ return;\r
+ }\r
+\r
+ CpuFeaturesInitializeWorker ();\r
+}\r
+\r
+/**\r
+ CPU Features driver entry point function.\r
+\r
+ If PcdCpuFeaturesInitAfterSmmRelocation is TRUE, it will register one\r
+ SMM Configuration Protocol notify function to perform CPU features\r
+ initialization. Otherwise, it will perform CPU features initialization\r
+ directly.\r
+\r
+ @param ImageHandle Image handle this driver.\r
+ @param SystemTable Pointer to the System Table.\r
+\r
+ @retval EFI_SUCCESS CPU Features is initialized successfully.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuFeaturesDxeInitialize (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ VOID *Registration;\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE Handle;\r
+\r
+ if (GetFirstGuidHob (&gEdkiiCpuFeaturesInitDoneGuid) != NULL) {\r
+ //\r
+ // Try to find HOB first. This HOB exist means CPU features have\r
+ // been initialized by CpuFeaturesPei driver, just install\r
+ // gEdkiiCpuFeaturesInitDoneGuid.\r
+ //\r
+ Handle = NULL;\r
+ Status = gBS->InstallProtocolInterface (\r
+ &Handle,\r
+ &gEdkiiCpuFeaturesInitDoneGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ return Status;\r
+ }\r
+\r
+ if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) {\r
+ //\r
+ // Install notification callback on SMM Configuration Protocol\r
+ //\r
+ EfiCreateProtocolNotifyEvent (\r
+ &gEfiSmmConfigurationProtocolGuid,\r
+ TPL_CALLBACK,\r
+ SmmConfigurationEventNotify,\r
+ NULL,\r
+ &Registration\r
+ );\r
+ } else {\r
+ CpuFeaturesInitializeWorker ();\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r