]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuFeatures: Change files format to DOS
authorJeff Fan <jeff.fan@intel.com>
Wed, 5 Apr 2017 08:33:16 +0000 (16:33 +0800)
committerJeff Fan <jeff.fan@intel.com>
Wed, 5 Apr 2017 08:33:16 +0000 (16:33 +0800)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
35 files changed:
UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c
UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf
UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.uni
UefiCpuPkg/CpuFeatures/CpuFeaturesDxeExtra.uni
UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c
UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf
UefiCpuPkg/CpuFeatures/CpuFeaturesPei.uni
UefiCpuPkg/CpuFeatures/CpuFeaturesPeiExtra.uni
UefiCpuPkg/Include/Guid/CpuFeaturesInitDone.h
UefiCpuPkg/Include/Guid/CpuFeaturesSetDone.h
UefiCpuPkg/Include/Library/RegisterCpuFeaturesLib.h
UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeatures.h
UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.uni
UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/FastStrings.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c
UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c
UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf
UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf
UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesDxe.uni
UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c

index f4f70cf32076e24507a48a0deb93332d71288650..b0b186d36d6d4e2affe24db47bc14130b6648490 100644 (file)
-/** @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, 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
+\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
+\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
index dee44e6974a7bd9f260c5989c1767dc82e631645..175e8a9797af5c976668b233044b2102daf436b4 100644 (file)
@@ -1,53 +1,53 @@
-## @file
-#  CPU Features DXE driver.
-#
-#  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.
-#
-##
-
-[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
-
-[Sources]
-  CpuFeaturesDxe.c
-
-[Guids]
-  gEdkiiCpuFeaturesInitDoneGuid                       ## PRODUCES ## UNDEFINED # protocol GUID installed
-
-[Protocols]
-  gEfiSmmConfigurationProtocolGuid                                ## NOTIFY
-
-[Pcd]
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation  ## CONSUMES
-
-[Depex]
-  TRUE
-
-[UserExtensions.TianoCore."ExtraFiles"]
-  CpuFeaturesDxeExtra.uni
+## @file\r
+#  CPU Features DXE driver.\r
+#\r
+#  Copyright (c) 2017, 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
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = CpuFeaturesDxe\r
+  MODULE_UNI_FILE                = CpuFeaturesDxe.uni\r
+  FILE_GUID                      = 63EB1B62-10C9-4693-88AC-AE0999EA87F8\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = CpuFeaturesDxeInitialize\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
+  UefiLib\r
+  UefiDriverEntryPoint\r
+  UefiBootServicesTableLib\r
+  RegisterCpuFeaturesLib\r
+\r
+[Sources]\r
+  CpuFeaturesDxe.c\r
+\r
+[Guids]\r
+  gEdkiiCpuFeaturesInitDoneGuid                       ## PRODUCES ## UNDEFINED # protocol GUID installed\r
+\r
+[Protocols]\r
+  gEfiSmmConfigurationProtocolGuid                                ## NOTIFY\r
+\r
+[Pcd]\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation  ## CONSUMES\r
+\r
+[Depex]\r
+  TRUE\r
+\r
+[UserExtensions.TianoCore."ExtraFiles"]\r
+  CpuFeaturesDxeExtra.uni\r
index 6f27bb98dbe7585d4e725dbe808533bb0c0fcc6a..c42e4daf43118ad6146c5893de911035cbc846e0 100644 (file)
@@ -1,22 +1,22 @@
-// /** @file
-// CPU Features DXE driver.
-//
-// CPU Features DXE driver.
-//
-// 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.
-//
-// **/
-
-
-#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."
-
+// /** @file\r
+// CPU Features DXE driver.\r
+//\r
+// CPU Features DXE driver.\r
+//\r
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+//\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
+\r
+#string STR_MODULE_ABSTRACT             #language en-US "CPU Features DXE driver to initialize CPU features."\r
+\r
+#string STR_MODULE_DESCRIPTION          #language en-US "CPU Features DXE driver to initialize CPU features."\r
+\r
index a236e1e3e730225616c1ecd037b85c405e5761e7..39a943e5a9b3eaa4514378cfa554341f9508ce1c 100644 (file)
@@ -1,20 +1,20 @@
-// /** @file
-// CpuFeaturesDxe Localized Strings and Content
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"CPU Features DXE Driver"
-
-
+// /** @file\r
+// CpuFeaturesDxe Localized Strings and Content\r
+//\r
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+//\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
+#string STR_PROPERTIES_MODULE_NAME\r
+#language en-US\r
+"CPU Features DXE Driver"\r
+\r
+\r
index 6292f5bf873c1dcf08a2b9e3229ea5f50f747317..b052d554a91985bce7d0946200fb9d359d340447 100644 (file)
@@ -1,75 +1,75 @@
-/** @file
-  CPU Features PEIM 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 <PiPei.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PeiServicesLib.h>
-#include <Library/RegisterCpuFeaturesLib.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);
-
-  return EFI_SUCCESS;
-}
-
+/** @file\r
+  CPU Features PEIM driver to initialize CPU features.\r
+\r
+  Copyright (c) 2017, 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 <PiPei.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/RegisterCpuFeaturesLib.h>\r
+\r
+#include <Guid/CpuFeaturesInitDone.h>\r
+\r
+EFI_PEI_PPI_DESCRIPTOR           mPeiCpuFeaturesInitDonePpiDesc = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEdkiiCpuFeaturesInitDoneGuid,\r
+  NULL\r
+};\r
+\r
+/**\r
+  CPU Features driver entry point function.\r
+\r
+  It will perform CPU features initialization, except for\r
+  PcdCpuFeaturesInitOnS3Resume is FALSE on S3 resume.\r
+\r
+  @param  FileHandle    Handle of the file being invoked.\r
+  @param  PeiServices   Describes the list of possible PEI Services.\r
+\r
+  @retval EFI_SUCCESS   CPU Features is initialized successfully.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuFeaturesPeimInitialize (\r
+  IN       EFI_PEI_FILE_HANDLE  FileHandle,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  EFI_STATUS                 Status;\r
+  EFI_BOOT_MODE              BootMode;\r
+\r
+  Status = PeiServicesGetBootMode (&BootMode);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  if (BootMode == BOOT_ON_S3_RESUME &&\r
+      !PcdGetBool (PcdCpuFeaturesInitOnS3Resume)) {\r
+    //\r
+    // Does nothing when if PcdCpuFeaturesInitOnS3Resume is FLASE\r
+    // on S3 boot mode\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
+  CpuFeaturesDetect ();\r
+\r
+  CpuFeaturesInitialize ();\r
+\r
+  //\r
+  // Install CPU Features Init Done PPI\r
+  //\r
+  Status = PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
index 2fb84b1b6657bfa706fcdaa1ef3c41760b10e7b4..dd4b388c9adc5bd25be69dab8703c7897a57098d 100644 (file)
@@ -1,49 +1,49 @@
-## @file
-#  CPU Features PEIM driver.
-#
-#  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.
-#
-##
-
-[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
-
-[Sources]
-  CpuFeaturesPei.c
-
-[Guids]
-  gEdkiiCpuFeaturesInitDoneGuid                       ## PRODUCES ## UNDEFINED # PPI GUID installed
-
-[Pcd]
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume          ## CONSUMES
-
-[Depex]
-  TRUE
-
-[UserExtensions.TianoCore."ExtraFiles"]
-  CpuFeaturesPeiExtra.uni
+## @file\r
+#  CPU Features PEIM driver.\r
+#\r
+#  Copyright (c) 2017, 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
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = CpuFeaturesPei\r
+  MODULE_UNI_FILE                = CpuFeaturesPei.uni\r
+  FILE_GUID                      = 183BB3E1-A1E5-4445-8AC9-0E83B6547E0E\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = CpuFeaturesPeimInitialize\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
+  PeimEntryPoint\r
+  PeiServicesLib\r
+  RegisterCpuFeaturesLib\r
+\r
+[Sources]\r
+  CpuFeaturesPei.c\r
+\r
+[Guids]\r
+  gEdkiiCpuFeaturesInitDoneGuid                       ## PRODUCES ## UNDEFINED # PPI GUID installed\r
+\r
+[Pcd]\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume          ## CONSUMES\r
+\r
+[Depex]\r
+  TRUE\r
+\r
+[UserExtensions.TianoCore."ExtraFiles"]\r
+  CpuFeaturesPeiExtra.uni\r
index f56dbd1eb960e9902f3c53be72fe282c4bf84b1c..b03754aee676b1b37c280c406f359dd5286349c1 100644 (file)
@@ -1,22 +1,22 @@
-// /** @file
-// CPU Features PEIM driver.
-//
-// CPU Features PEIM driver.
-//
-// 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.
-//
-// **/
-
-
-#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."
-
+// /** @file\r
+// CPU Features PEIM driver.\r
+//\r
+// CPU Features PEIM driver.\r
+//\r
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+//\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
+\r
+#string STR_MODULE_ABSTRACT             #language en-US "CPU Features PEIM driver to initialize CPU features."\r
+\r
+#string STR_MODULE_DESCRIPTION          #language en-US "CPU Features PEIM driver to initialize CPU features."\r
+\r
index 0ffc61923d9b350c68bd007f88518eced2a4918c..43dbe96197ba23cbc78f9882af22f642a0edc5c8 100644 (file)
@@ -1,20 +1,20 @@
-// /** @file
-// CpuFeaturesPei Localized Strings and Content
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"CPU Features PEIM Driver"
-
-
+// /** @file\r
+// CpuFeaturesPei Localized Strings and Content\r
+//\r
+// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+//\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
+#string STR_PROPERTIES_MODULE_NAME\r
+#language en-US\r
+"CPU Features PEIM Driver"\r
+\r
+\r
index ef17da51af08a206a9627d7648ee371db9c7d4ab..70b5c704d5d0eddde687b034f7d190de8ea70aa4 100644 (file)
@@ -1,26 +1,26 @@
-/** @file
-  CPU Features Init Done PPI/Protocol should be installed after CPU features
-  are initialized.
-
-Copyright (c) 2016, 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.
-
-**/
-
-#ifndef _CPU_FEATURES_INIT_DONE_H_
-#define _CPU_FEATURES_INIT_DONE_H_
-
-#define EDKII_CPU_FEATURES_INIT_DONE_GUID \
-  { \
-    { 0xc77c3a41, 0x61ab, 0x4143, { 0x98, 0x3e, 0x33, 0x39, 0x28, 0x6, 0x28, 0xe5 } \
-  }
-
-extern EFI_GUID gEdkiiCpuFeaturesInitDoneGuid;
-
-#endif
+/** @file\r
+  CPU Features Init Done PPI/Protocol should be installed after CPU features\r
+  are initialized.\r
+\r
+Copyright (c) 2016, 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
+#ifndef _CPU_FEATURES_INIT_DONE_H_\r
+#define _CPU_FEATURES_INIT_DONE_H_\r
+\r
+#define EDKII_CPU_FEATURES_INIT_DONE_GUID \\r
+  { \\r
+    { 0xc77c3a41, 0x61ab, 0x4143, { 0x98, 0x3e, 0x33, 0x39, 0x28, 0x6, 0x28, 0xe5 } \\r
+  }\r
+\r
+extern EFI_GUID gEdkiiCpuFeaturesInitDoneGuid;\r
+\r
+#endif\r
index 8b1592e3599de71e0fd84a85e2ab95caf318bc4b..bf085c726cd0945963f7f3c963bd247b3f813ce9 100644 (file)
@@ -1,26 +1,26 @@
-/** @file
-  CPU Features Set Done PPI/Protocol should be installed after CPU features
-  configuration are set.
-
-Copyright (c) 2016, 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.
-
-**/
-
-#ifndef _CPU_FEATURES_INIT_DONE_H_
-#define _CPU_FEATURES_INIT_DONE_H_
-
-#define EDKII_CPU_FEATURES_SET_DONE_GUID \
-  { \
-    { 0xa82485ce, 0xad6b, 0x4101, { 0x99, 0xd3, 0xe1, 0x35, 0x8c, 0x9e, 0x7e, 0x37 } \
-  }
-
-extern EFI_GUID gEdkiiCpuFeaturesSetDoneGuid;
-
-#endif
+/** @file\r
+  CPU Features Set Done PPI/Protocol should be installed after CPU features\r
+  configuration are set.\r
+\r
+Copyright (c) 2016, 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
+#ifndef _CPU_FEATURES_INIT_DONE_H_\r
+#define _CPU_FEATURES_INIT_DONE_H_\r
+\r
+#define EDKII_CPU_FEATURES_SET_DONE_GUID \\r
+  { \\r
+    { 0xa82485ce, 0xad6b, 0x4101, { 0x99, 0xd3, 0xe1, 0x35, 0x8c, 0x9e, 0x7e, 0x37 } \\r
+  }\r
+\r
+extern EFI_GUID gEdkiiCpuFeaturesSetDoneGuid;\r
+\r
+#endif\r
index 81a1f4bc38d0fa6d42cbe4ee48f9383d7d159c51..4765bc36b8007bc6e34e607633dfbb8a8a87735b 100644 (file)
-/** @file
-  Register CPU Features Library to register and manage 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.
-
-**/
-
-#ifndef __REGISTER_CPU_FEATURES_LIB_H__
-#define __REGISTER_CPU_FEATURES_LIB_H__
-
-#include <AcpiCpuData.h>
-#include <Register/Cpuid.h>
-#include <Protocol/MpService.h>
-
-///
-/// Defines used to identify a CPU feature.  The lower 16-bits are used to
-/// identify a unique CPU feature and the value represents a bit number in
-/// a bit mask.  The upper 16-bits are bit mask values that are used as
-/// modifiers of a CPU feature.  When used in a list, the define value
-/// CPU_FEATURE_END is used to terminate a list of CPU feature values.
-/// @{
-#define CPU_FEATURE_AESNI                           0
-#define CPU_FEATURE_TURBO_MODE                      1
-#define CPU_FEATURE_MWAIT                           2
-#define CPU_FEATURE_ACPI                            3
-#define CPU_FEATURE_EIST                            4
-#define CPU_FEATURE_XD                              5
-#define CPU_FEATURE_FASTSTRINGS                     6
-#define CPU_FEATURE_VMX                             7
-#define CPU_FEATURE_SMX                             8
-#define CPU_FEATURE_SENTER                          9
-#define CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER   10
-#define CPU_FEATURE_LIMIT_CPUID_MAX_VAL             11
-#define CPU_FEATURE_MCE                             12
-#define CPU_FEATURE_MCA                             13
-#define CPU_FEATURE_MCG_CTL                         14
-#define CPU_FEATURE_PENDING_BREAK                   15
-#define CPU_FEATURE_C1E                             16
-#define CPU_FEATURE_C1_AUTO_DEMOTION                17
-#define CPU_FEATURE_C3_AUTO_DEMOTION                18
-#define CPU_FEATURE_C1_AUTO_UNDEMOTION              19
-#define CPU_FEATURE_C3_AUTO_UNDEMOTION              20
-#define CPU_FEATURE_C_STATE                         21
-#define CPU_FEATURE_TM                              22
-#define CPU_FEATURE_TM2                             23
-#define CPU_FEATURE_X2APIC                          24
-#define CPU_FEATURE_RESERVED_25                     25
-#define CPU_FEATURE_RESERVED_26                     26
-#define CPU_FEATURE_RESERVED_27                     27
-#define CPU_FEATURE_RESERVED_28                     28
-#define CPU_FEATURE_RESERVED_29                     29
-#define CPU_FEATURE_RESERVED_30                     30
-#define CPU_FEATURE_RESERVED_31                     31
-
-#define CPU_FEATURE_L2_PREFETCHER                   (32+0)
-#define CPU_FEATURE_L1_DATA_PREFETCHER              (32+1)
-#define CPU_FEATURE_HARDWARE_PREFETCHER             (32+2)
-#define CPU_FEATURE_ADJACENT_CACHE_LINE_PREFETCH    (32+3)
-#define CPU_FEATURE_DCU_PREFETCHER                  (32+4)
-#define CPU_FEATURE_IP_PREFETCHER                   (32+5)
-#define CPU_FEATURE_MLC_STREAMER_PREFETCHER         (32+6)
-#define CPU_FEATURE_MLC_SPATIAL_PREFETCHER          (32+7)
-#define CPU_FEATURE_THREE_STRICK_COUNTER            (32+8)
-#define CPU_FEATURE_APIC_TPR_UPDATE_MESSAGE         (32+9)
-#define CPU_FEATURE_ENERGY_PERFORMANCE_BIAS         (32+10)
-
-#define CPU_FEATURE_BEFORE_ALL                      BIT27
-#define CPU_FEATURE_AFTER_ALL                       BIT28
-#define CPU_FEATURE_BEFORE                          BIT29
-#define CPU_FEATURE_AFTER                           BIT30
-#define CPU_FEATURE_END                             MAX_UINT32
-/// @}
-
-///
-/// CPU Information passed into the SupportFunc and InitializeFunc of the
-/// RegisterCpuFeature() library function.  This structure contains information
-/// that is commonly used during CPU feature detection and initialization.
-///
-typedef struct {
-  ///
-  /// The package that the CPU resides
-  ///
-  EFI_PROCESSOR_INFORMATION            ProcessorInfo;
-  ///
-  /// The Display Family of the CPU computed from CPUID leaf CPUID_VERSION_INFO
-  ///
-  UINT32                               DisplayFamily;
-  ///
-  /// The Display Model of the CPU computed from CPUID leaf CPUID_VERSION_INFO
-  ///
-  UINT32                               DisplayModel;
-  ///
-  /// The Stepping ID of the CPU computed from CPUID leaf CPUID_VERSION_INFO
-  ///
-  UINT32                               SteppingId;
-  ///
-  /// The Processor Type of the CPU computed from CPUID leaf CPUID_VERSION_INFO
-  ///
-  UINT32                               ProcessorType;
-  ///
-  /// Bit field structured returned in ECX from CPUID leaf CPUID_VERSION_INFO
-  ///
-  CPUID_VERSION_INFO_ECX               CpuIdVersionInfoEcx;
-  ///
-  /// Bit field structured returned in EDX from CPUID leaf CPUID_VERSION_INFO
-  ///
-  CPUID_VERSION_INFO_EDX               CpuIdVersionInfoEdx;
-} REGISTER_CPU_FEATURE_INFORMATION;
-
-/**
-  Determines if a CPU feature is enabled in PcdCpuFeaturesSupport bit mask.
-  If a CPU feature is disabled in PcdCpuFeaturesSupport then all the code/data
-  associated with that feature should be optimized away if compiler
-  optimizations are enabled.
-
-  @param[in]  Feature  The bit number of the CPU feature to check in the PCD
-                       PcdCpuFeaturesSupport.
-
-  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesSupport.
-  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesSupport.
-
-  @note This service could be called by BSP only.
-**/
-BOOLEAN
-EFIAPI
-IsCpuFeatureSupported (
-  IN UINT32              Feature
-  );
-
-/**
-  Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask.
-
-  @param[in]  Feature  The bit number of the CPU feature to check in the PCD
-                       PcdCpuFeaturesSetting.
-
-  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesSetting.
-  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesSetting.
-
-  @note This service could be called by BSP only.
-**/
-BOOLEAN
-EFIAPI
-IsCpuFeatureInSetting (
-  IN UINT32              Feature
-  );
-
-/**
-  Determines if a CPU feature is set in PcdCpuFeaturesCapability bit mask.
-
-  @param[in]  Feature  The bit number of the CPU feature to check in the PCD
-                       PcdCpuFeaturesCapability.
-
-  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesCapability.
-  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesCapability.
-
-  @note This service could be called by BSP only.
-**/
-BOOLEAN
-EFIAPI
-IsCpuFeatureCapability (
-  IN UINT32              Feature
-  );
-
-/**
-  Determines if a CPU feature is set in PcdCpuFeaturesUserConfiguration bit mask.
-
-  @param[in]  Feature  The bit number of the CPU feature to check in the PCD
-                       PcdCpuFeaturesUserConfiguration.
-
-  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesUserConfiguration.
-  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesUserConfiguration.
-
-  @note This service could be called by BSP only.
-**/
-BOOLEAN
-EFIAPI
-IsCpuFeatureUserConfiguration (
-  IN UINT32              Feature
-  );
-
-/**
-  Prepares for the data used by CPU feature detection and initialization.
-
-  @param[in]  NumberOfProcessors  The number of CPUs in the platform.
-
-  @return  Pointer to a buffer of CPU related configuration data.
-
-  @note This service could be called by BSP only.
-**/
-typedef
-VOID *
-(EFIAPI *CPU_FEATURE_GET_CONFIG_DATA)(
-  IN UINTN               NumberOfProcessors
-  );
-
-/**
-  Detects if CPU feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     CPU feature is supported.
-  @retval FALSE    CPU feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-typedef
-BOOLEAN
-(EFIAPI *CPU_FEATURE_SUPPORT)(
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes CPU feature to specific state.
-
-  This service does not initialize hardware and only produces entries in the
-  Register Table for specified processor. Hardware initialization on BSP/APs
-  will be done in CpuFeaturesInitialize().
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the CPU feature must be enabled.
-                               If FALSE, then the CPU feature must be disabled.
-
-  @retval RETURN_SUCCESS       CPU feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-typedef
-RETURN_STATUS
-(EFIAPI *CPU_FEATURE_INITIALIZE)(
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Registers a CPU Feature.
-
-  @param[in]  FeatureName        A Null-terminated Ascii string indicates CPU feature
-                                 name.
-  @param[in]  GetConfigDataFunc  CPU feature get configuration data function.  This
-                                 is an optional parameter that may be NULL.  If NULL,
-                                 then the most recently registered function for the
-                                 CPU feature is used.  If no functions are registered
-                                 for a CPU feature, then the CPU configuration data
-                                 for the registered feature is NULL.
-  @param[in]  SupportFunc        CPU feature support function.  This is an optional
-                                 parameter that may be NULL.  If NULL, then the most
-                                 recently registered function for the CPU feature is
-                                 used. If no functions are registered for a CPU
-                                 feature, then the CPU feature is assumed to be
-                                 supported by all CPUs.
-  @param[in]  InitializeFunc     CPU feature initialize function.  This is an optional
-                                 parameter that may be NULL.  If NULL, then the most
-                                 recently registered function for the CPU feature is
-                                 used. If no functions are registered for a CPU
-                                 feature, then the CPU feature initialization is
-                                 skipped.
-  @param[in]  ...                Variable argument list of UINT32 CPU feature value.
-                                 Values with no modifiers are the features provided
-                                 by the registered functions.
-                                 Values with CPU_FEATURE_BEFORE modifier are features
-                                 that must be initialized after the features provided
-                                 by the registered functions are used.
-                                 Values with CPU_FEATURE_AFTER modifier are features
-                                 that must be initialized before the features provided
-                                 by the registered functions are used.
-                                 The last argument in this variable argument list must
-                                 always be CPU_FEATURE_END.
-
-  @retval  RETURN_SUCCESS           The CPU feature was successfully registered.
-  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources to register
-                                    the CPU feature.
-  @retval  RETURN_UNSUPPORTED       Registration of the CPU feature is not
-                                    supported due to a circular dependency between
-                                    BEFORE and AFTER features.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-RegisterCpuFeature (
-  IN CHAR8                             *FeatureName,       OPTIONAL
-  IN CPU_FEATURE_GET_CONFIG_DATA       GetConfigDataFunc,  OPTIONAL
-  IN CPU_FEATURE_SUPPORT               SupportFunc,        OPTIONAL
-  IN CPU_FEATURE_INITIALIZE            InitializeFunc,     OPTIONAL
-  ...
-  );
-
-/**
-  Performs CPU features detection.
-
-  This service will invoke MP service to check CPU features'
-  capabilities on BSP/APs.
-
-  @note This service could be called by BSP only.
-**/
-VOID
-EFIAPI
-CpuFeaturesDetect (
-  VOID
-  );
-
-/**
-  Performs CPU features Initialization.
-
-  This service will invoke MP service to perform CPU features
-  initialization on BSP/APs per user configuration.
-
-  @note This service could be called by BSP only.
-**/
-VOID
-EFIAPI
-CpuFeaturesInitialize (
-  VOID
-  );
-
-/**
-  Switches to assigned BSP after CPU features initialization.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-
-  @note This service could be called by BSP only.
-**/
-VOID
-EFIAPI
-SwitchBspAfterFeaturesInitialize (
-  IN UINTN               ProcessorNumber
-  );
-
-/**
-  Adds an entry in specified register table.
-
-  This function adds an entry in specified register table, with given register type,
-  register index, bit section and value.
-
-  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.
-  @param[in]  RegisterType     Type of the register to program
-  @param[in]  Index            Index of the register to program
-  @param[in]  ValueMask        Mask of bits in register to write
-  @param[in]  Value            Value to write
-
-  @note This service could be called by BSP only.
-**/
-VOID
-EFIAPI
-CpuRegisterTableWrite (
-  IN UINTN               ProcessorNumber,
-  IN REGISTER_TYPE       RegisterType,
-  IN UINT64              Index,
-  IN UINT64              ValueMask,
-  IN UINT64              Value
-  );
-
-/**
-  Adds an entry in specified Pre-SMM register table.
-
-  This function adds an entry in specified register table, with given register type,
-  register index, bit section and value.
-
-  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.
-  @param[in]  RegisterType     Type of the register to program
-  @param[in]  Index            Index of the register to program
-  @param[in]  ValueMask        Mask of bits in register to write
-  @param[in]  Value            Value to write
-
-  @note This service could be called by BSP only.
-**/
-VOID
-EFIAPI
-PreSmmCpuRegisterTableWrite (
-  IN UINTN               ProcessorNumber,
-  IN REGISTER_TYPE       RegisterType,
-  IN UINT64              Index,
-  IN UINT64              ValueMask,
-  IN UINT64              Value
-  );
-
-/**
-  Adds a 32-bit register write entry in specified register table.
-
-  This macro adds an entry in specified register table, with given register type,
-  register index, and value.
-
-  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.
-  @param[in]  RegisterType     Type of the register to program
-  @param[in]  Index            Index of the register to program
-  @param[in]  Value            Value to write
-
-  @note This service could be called by BSP only.
-**/
-#define CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value)       \
-  do {                                                                                \
-    CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value);  \
-  } while(FALSE);
-
-/**
-  Adds a 64-bit register write entry in specified register table.
-
-  This macro adds an entry in specified register table, with given register type,
-  register index, and value.
-
-  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.
-  @param[in]  RegisterType     Type of the register to program
-  @param[in]  Index            Index of the register to program
-  @param[in]  Value            Value to write
-
-  @note This service could be called by BSP only.
-**/
-#define CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value)       \
-  do {                                                                                \
-    CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value);  \
-  } while(FALSE);
-
-/**
-  Adds a bit field write entry in specified register table.
-
-  This macro adds an entry in specified register table, with given register type,
-  register index, bit field section, and value.
-
-  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.
-  @param[in]  RegisterType     Type of the register to program.
-  @param[in]  Index            Index of the register to program.
-  @param[in]  Type             The data type name of a register structure.
-  @param[in]  Field            The bit fiel name in register structure to write.
-  @param[in]  Value            Value to write to the bit field.
-
-  @note This service could be called by BSP only.
-**/
-#define CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \
-  do {                                                                                           \
-    UINT64  ValueMask;                                                                           \
-    ValueMask = MAX_UINT64;                                                                      \
-    ((Type *)(&ValueMask))->Field = 0;                                                           \
-    CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value);             \
-  } while(FALSE);
-
-/**
-  Adds a 32-bit register write entry in specified register table.
-
-  This macro adds an entry in specified register table, with given register type,
-  register index, and value.
-
-  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.
-  @param[in]  RegisterType     Type of the register to program
-  @param[in]  Index            Index of the register to program
-  @param[in]  Value            Value to write
-
-  @note This service could be called by BSP only.
-**/
-#define PRE_SMM_CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value)    \
-  do {                                                                                     \
-    PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \
-  } while(FALSE);
-
-/**
-  Adds a 64-bit register write entry in specified register table.
-
-  This macro adds an entry in specified register table, with given register type,
-  register index, and value.
-
-  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.
-  @param[in]  RegisterType     Type of the register to program
-  @param[in]  Index            Index of the register to program
-  @param[in]  Value            Value to write
-
-  @note This service could be called by BSP only.
-**/
-#define PRE_SMM_CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value)    \
-  do {                                                                                     \
-    PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \
-  } while(FALSE);
-
-/**
-  Adds a bit field write entry in specified register table.
-
-  This macro adds an entry in specified register table, with given register type,
-  register index, bit field section, and value.
-
-  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.
-  @param[in]  RegisterType     Type of the register to program.
-  @param[in]  Index            Index of the register to program.
-  @param[in]  Type             The data type name of a register structure.
-  @param[in]  Field            The bit fiel name in register structure to write.
-  @param[in]  Value            Value to write to the bit field.
-
-  @note This service could be called by BSP only.
-**/
-#define PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \
-  do {                                                                                                   \
-    UINT64  ValueMask;                                                                                   \
-    ValueMask = MAX_UINT64;                                                                              \
-    ((Type *)(&ValueMask))->Field = 0;                                                                   \
-    PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value);                \
-  } while(FALSE);
-
-#endif
+/** @file\r
+  Register CPU Features Library to register and manage CPU features.\r
+\r
+  Copyright (c) 2017, 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
+#ifndef __REGISTER_CPU_FEATURES_LIB_H__\r
+#define __REGISTER_CPU_FEATURES_LIB_H__\r
+\r
+#include <AcpiCpuData.h>\r
+#include <Register/Cpuid.h>\r
+#include <Protocol/MpService.h>\r
+\r
+///\r
+/// Defines used to identify a CPU feature.  The lower 16-bits are used to\r
+/// identify a unique CPU feature and the value represents a bit number in\r
+/// a bit mask.  The upper 16-bits are bit mask values that are used as\r
+/// modifiers of a CPU feature.  When used in a list, the define value\r
+/// CPU_FEATURE_END is used to terminate a list of CPU feature values.\r
+/// @{\r
+#define CPU_FEATURE_AESNI                           0\r
+#define CPU_FEATURE_TURBO_MODE                      1\r
+#define CPU_FEATURE_MWAIT                           2\r
+#define CPU_FEATURE_ACPI                            3\r
+#define CPU_FEATURE_EIST                            4\r
+#define CPU_FEATURE_XD                              5\r
+#define CPU_FEATURE_FASTSTRINGS                     6\r
+#define CPU_FEATURE_VMX                             7\r
+#define CPU_FEATURE_SMX                             8\r
+#define CPU_FEATURE_SENTER                          9\r
+#define CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER   10\r
+#define CPU_FEATURE_LIMIT_CPUID_MAX_VAL             11\r
+#define CPU_FEATURE_MCE                             12\r
+#define CPU_FEATURE_MCA                             13\r
+#define CPU_FEATURE_MCG_CTL                         14\r
+#define CPU_FEATURE_PENDING_BREAK                   15\r
+#define CPU_FEATURE_C1E                             16\r
+#define CPU_FEATURE_C1_AUTO_DEMOTION                17\r
+#define CPU_FEATURE_C3_AUTO_DEMOTION                18\r
+#define CPU_FEATURE_C1_AUTO_UNDEMOTION              19\r
+#define CPU_FEATURE_C3_AUTO_UNDEMOTION              20\r
+#define CPU_FEATURE_C_STATE                         21\r
+#define CPU_FEATURE_TM                              22\r
+#define CPU_FEATURE_TM2                             23\r
+#define CPU_FEATURE_X2APIC                          24\r
+#define CPU_FEATURE_RESERVED_25                     25\r
+#define CPU_FEATURE_RESERVED_26                     26\r
+#define CPU_FEATURE_RESERVED_27                     27\r
+#define CPU_FEATURE_RESERVED_28                     28\r
+#define CPU_FEATURE_RESERVED_29                     29\r
+#define CPU_FEATURE_RESERVED_30                     30\r
+#define CPU_FEATURE_RESERVED_31                     31\r
+\r
+#define CPU_FEATURE_L2_PREFETCHER                   (32+0)\r
+#define CPU_FEATURE_L1_DATA_PREFETCHER              (32+1)\r
+#define CPU_FEATURE_HARDWARE_PREFETCHER             (32+2)\r
+#define CPU_FEATURE_ADJACENT_CACHE_LINE_PREFETCH    (32+3)\r
+#define CPU_FEATURE_DCU_PREFETCHER                  (32+4)\r
+#define CPU_FEATURE_IP_PREFETCHER                   (32+5)\r
+#define CPU_FEATURE_MLC_STREAMER_PREFETCHER         (32+6)\r
+#define CPU_FEATURE_MLC_SPATIAL_PREFETCHER          (32+7)\r
+#define CPU_FEATURE_THREE_STRICK_COUNTER            (32+8)\r
+#define CPU_FEATURE_APIC_TPR_UPDATE_MESSAGE         (32+9)\r
+#define CPU_FEATURE_ENERGY_PERFORMANCE_BIAS         (32+10)\r
+\r
+#define CPU_FEATURE_BEFORE_ALL                      BIT27\r
+#define CPU_FEATURE_AFTER_ALL                       BIT28\r
+#define CPU_FEATURE_BEFORE                          BIT29\r
+#define CPU_FEATURE_AFTER                           BIT30\r
+#define CPU_FEATURE_END                             MAX_UINT32\r
+/// @}\r
+\r
+///\r
+/// CPU Information passed into the SupportFunc and InitializeFunc of the\r
+/// RegisterCpuFeature() library function.  This structure contains information\r
+/// that is commonly used during CPU feature detection and initialization.\r
+///\r
+typedef struct {\r
+  ///\r
+  /// The package that the CPU resides\r
+  ///\r
+  EFI_PROCESSOR_INFORMATION            ProcessorInfo;\r
+  ///\r
+  /// The Display Family of the CPU computed from CPUID leaf CPUID_VERSION_INFO\r
+  ///\r
+  UINT32                               DisplayFamily;\r
+  ///\r
+  /// The Display Model of the CPU computed from CPUID leaf CPUID_VERSION_INFO\r
+  ///\r
+  UINT32                               DisplayModel;\r
+  ///\r
+  /// The Stepping ID of the CPU computed from CPUID leaf CPUID_VERSION_INFO\r
+  ///\r
+  UINT32                               SteppingId;\r
+  ///\r
+  /// The Processor Type of the CPU computed from CPUID leaf CPUID_VERSION_INFO\r
+  ///\r
+  UINT32                               ProcessorType;\r
+  ///\r
+  /// Bit field structured returned in ECX from CPUID leaf CPUID_VERSION_INFO\r
+  ///\r
+  CPUID_VERSION_INFO_ECX               CpuIdVersionInfoEcx;\r
+  ///\r
+  /// Bit field structured returned in EDX from CPUID leaf CPUID_VERSION_INFO\r
+  ///\r
+  CPUID_VERSION_INFO_EDX               CpuIdVersionInfoEdx;\r
+} REGISTER_CPU_FEATURE_INFORMATION;\r
+\r
+/**\r
+  Determines if a CPU feature is enabled in PcdCpuFeaturesSupport bit mask.\r
+  If a CPU feature is disabled in PcdCpuFeaturesSupport then all the code/data\r
+  associated with that feature should be optimized away if compiler\r
+  optimizations are enabled.\r
+\r
+  @param[in]  Feature  The bit number of the CPU feature to check in the PCD\r
+                       PcdCpuFeaturesSupport.\r
+\r
+  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesSupport.\r
+  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesSupport.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsCpuFeatureSupported (\r
+  IN UINT32              Feature\r
+  );\r
+\r
+/**\r
+  Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask.\r
+\r
+  @param[in]  Feature  The bit number of the CPU feature to check in the PCD\r
+                       PcdCpuFeaturesSetting.\r
+\r
+  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesSetting.\r
+  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesSetting.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsCpuFeatureInSetting (\r
+  IN UINT32              Feature\r
+  );\r
+\r
+/**\r
+  Determines if a CPU feature is set in PcdCpuFeaturesCapability bit mask.\r
+\r
+  @param[in]  Feature  The bit number of the CPU feature to check in the PCD\r
+                       PcdCpuFeaturesCapability.\r
+\r
+  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesCapability.\r
+  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesCapability.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsCpuFeatureCapability (\r
+  IN UINT32              Feature\r
+  );\r
+\r
+/**\r
+  Determines if a CPU feature is set in PcdCpuFeaturesUserConfiguration bit mask.\r
+\r
+  @param[in]  Feature  The bit number of the CPU feature to check in the PCD\r
+                       PcdCpuFeaturesUserConfiguration.\r
+\r
+  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesUserConfiguration.\r
+  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesUserConfiguration.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsCpuFeatureUserConfiguration (\r
+  IN UINT32              Feature\r
+  );\r
+\r
+/**\r
+  Prepares for the data used by CPU feature detection and initialization.\r
+\r
+  @param[in]  NumberOfProcessors  The number of CPUs in the platform.\r
+\r
+  @return  Pointer to a buffer of CPU related configuration data.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+typedef\r
+VOID *\r
+(EFIAPI *CPU_FEATURE_GET_CONFIG_DATA)(\r
+  IN UINTN               NumberOfProcessors\r
+  );\r
+\r
+/**\r
+  Detects if CPU feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     CPU feature is supported.\r
+  @retval FALSE    CPU feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *CPU_FEATURE_SUPPORT)(\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes CPU feature to specific state.\r
+\r
+  This service does not initialize hardware and only produces entries in the\r
+  Register Table for specified processor. Hardware initialization on BSP/APs\r
+  will be done in CpuFeaturesInitialize().\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the CPU feature must be enabled.\r
+                               If FALSE, then the CPU feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       CPU feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+typedef\r
+RETURN_STATUS\r
+(EFIAPI *CPU_FEATURE_INITIALIZE)(\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Registers a CPU Feature.\r
+\r
+  @param[in]  FeatureName        A Null-terminated Ascii string indicates CPU feature\r
+                                 name.\r
+  @param[in]  GetConfigDataFunc  CPU feature get configuration data function.  This\r
+                                 is an optional parameter that may be NULL.  If NULL,\r
+                                 then the most recently registered function for the\r
+                                 CPU feature is used.  If no functions are registered\r
+                                 for a CPU feature, then the CPU configuration data\r
+                                 for the registered feature is NULL.\r
+  @param[in]  SupportFunc        CPU feature support function.  This is an optional\r
+                                 parameter that may be NULL.  If NULL, then the most\r
+                                 recently registered function for the CPU feature is\r
+                                 used. If no functions are registered for a CPU\r
+                                 feature, then the CPU feature is assumed to be\r
+                                 supported by all CPUs.\r
+  @param[in]  InitializeFunc     CPU feature initialize function.  This is an optional\r
+                                 parameter that may be NULL.  If NULL, then the most\r
+                                 recently registered function for the CPU feature is\r
+                                 used. If no functions are registered for a CPU\r
+                                 feature, then the CPU feature initialization is\r
+                                 skipped.\r
+  @param[in]  ...                Variable argument list of UINT32 CPU feature value.\r
+                                 Values with no modifiers are the features provided\r
+                                 by the registered functions.\r
+                                 Values with CPU_FEATURE_BEFORE modifier are features\r
+                                 that must be initialized after the features provided\r
+                                 by the registered functions are used.\r
+                                 Values with CPU_FEATURE_AFTER modifier are features\r
+                                 that must be initialized before the features provided\r
+                                 by the registered functions are used.\r
+                                 The last argument in this variable argument list must\r
+                                 always be CPU_FEATURE_END.\r
+\r
+  @retval  RETURN_SUCCESS           The CPU feature was successfully registered.\r
+  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources to register\r
+                                    the CPU feature.\r
+  @retval  RETURN_UNSUPPORTED       Registration of the CPU feature is not\r
+                                    supported due to a circular dependency between\r
+                                    BEFORE and AFTER features.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+RegisterCpuFeature (\r
+  IN CHAR8                             *FeatureName,       OPTIONAL\r
+  IN CPU_FEATURE_GET_CONFIG_DATA       GetConfigDataFunc,  OPTIONAL\r
+  IN CPU_FEATURE_SUPPORT               SupportFunc,        OPTIONAL\r
+  IN CPU_FEATURE_INITIALIZE            InitializeFunc,     OPTIONAL\r
+  ...\r
+  );\r
+\r
+/**\r
+  Performs CPU features detection.\r
+\r
+  This service will invoke MP service to check CPU features'\r
+  capabilities on BSP/APs.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuFeaturesDetect (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Performs CPU features Initialization.\r
+\r
+  This service will invoke MP service to perform CPU features\r
+  initialization on BSP/APs per user configuration.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuFeaturesInitialize (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Switches to assigned BSP after CPU features initialization.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID\r
+EFIAPI\r
+SwitchBspAfterFeaturesInitialize (\r
+  IN UINTN               ProcessorNumber\r
+  );\r
+\r
+/**\r
+  Adds an entry in specified register table.\r
+\r
+  This function adds an entry in specified register table, with given register type,\r
+  register index, bit section and value.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.\r
+  @param[in]  RegisterType     Type of the register to program\r
+  @param[in]  Index            Index of the register to program\r
+  @param[in]  ValueMask        Mask of bits in register to write\r
+  @param[in]  Value            Value to write\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuRegisterTableWrite (\r
+  IN UINTN               ProcessorNumber,\r
+  IN REGISTER_TYPE       RegisterType,\r
+  IN UINT64              Index,\r
+  IN UINT64              ValueMask,\r
+  IN UINT64              Value\r
+  );\r
+\r
+/**\r
+  Adds an entry in specified Pre-SMM register table.\r
+\r
+  This function adds an entry in specified register table, with given register type,\r
+  register index, bit section and value.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.\r
+  @param[in]  RegisterType     Type of the register to program\r
+  @param[in]  Index            Index of the register to program\r
+  @param[in]  ValueMask        Mask of bits in register to write\r
+  @param[in]  Value            Value to write\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID\r
+EFIAPI\r
+PreSmmCpuRegisterTableWrite (\r
+  IN UINTN               ProcessorNumber,\r
+  IN REGISTER_TYPE       RegisterType,\r
+  IN UINT64              Index,\r
+  IN UINT64              ValueMask,\r
+  IN UINT64              Value\r
+  );\r
+\r
+/**\r
+  Adds a 32-bit register write entry in specified register table.\r
+\r
+  This macro adds an entry in specified register table, with given register type,\r
+  register index, and value.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.\r
+  @param[in]  RegisterType     Type of the register to program\r
+  @param[in]  Index            Index of the register to program\r
+  @param[in]  Value            Value to write\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+#define CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value)       \\r
+  do {                                                                                \\r
+    CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value);  \\r
+  } while(FALSE);\r
+\r
+/**\r
+  Adds a 64-bit register write entry in specified register table.\r
+\r
+  This macro adds an entry in specified register table, with given register type,\r
+  register index, and value.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.\r
+  @param[in]  RegisterType     Type of the register to program\r
+  @param[in]  Index            Index of the register to program\r
+  @param[in]  Value            Value to write\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+#define CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value)       \\r
+  do {                                                                                \\r
+    CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value);  \\r
+  } while(FALSE);\r
+\r
+/**\r
+  Adds a bit field write entry in specified register table.\r
+\r
+  This macro adds an entry in specified register table, with given register type,\r
+  register index, bit field section, and value.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.\r
+  @param[in]  RegisterType     Type of the register to program.\r
+  @param[in]  Index            Index of the register to program.\r
+  @param[in]  Type             The data type name of a register structure.\r
+  @param[in]  Field            The bit fiel name in register structure to write.\r
+  @param[in]  Value            Value to write to the bit field.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+#define CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \\r
+  do {                                                                                           \\r
+    UINT64  ValueMask;                                                                           \\r
+    ValueMask = MAX_UINT64;                                                                      \\r
+    ((Type *)(&ValueMask))->Field = 0;                                                           \\r
+    CpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value);             \\r
+  } while(FALSE);\r
+\r
+/**\r
+  Adds a 32-bit register write entry in specified register table.\r
+\r
+  This macro adds an entry in specified register table, with given register type,\r
+  register index, and value.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.\r
+  @param[in]  RegisterType     Type of the register to program\r
+  @param[in]  Index            Index of the register to program\r
+  @param[in]  Value            Value to write\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+#define PRE_SMM_CPU_REGISTER_TABLE_WRITE32(ProcessorNumber, RegisterType, Index, Value)    \\r
+  do {                                                                                     \\r
+    PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT32, Value); \\r
+  } while(FALSE);\r
+\r
+/**\r
+  Adds a 64-bit register write entry in specified register table.\r
+\r
+  This macro adds an entry in specified register table, with given register type,\r
+  register index, and value.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.\r
+  @param[in]  RegisterType     Type of the register to program\r
+  @param[in]  Index            Index of the register to program\r
+  @param[in]  Value            Value to write\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+#define PRE_SMM_CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value)    \\r
+  do {                                                                                     \\r
+    PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, MAX_UINT64, Value); \\r
+  } while(FALSE);\r
+\r
+/**\r
+  Adds a bit field write entry in specified register table.\r
+\r
+  This macro adds an entry in specified register table, with given register type,\r
+  register index, bit field section, and value.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.\r
+  @param[in]  RegisterType     Type of the register to program.\r
+  @param[in]  Index            Index of the register to program.\r
+  @param[in]  Type             The data type name of a register structure.\r
+  @param[in]  Field            The bit fiel name in register structure to write.\r
+  @param[in]  Value            Value to write to the bit field.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+#define PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD(ProcessorNumber, RegisterType, Index, Type, Field, Value) \\r
+  do {                                                                                                   \\r
+    UINT64  ValueMask;                                                                                   \\r
+    ValueMask = MAX_UINT64;                                                                              \\r
+    ((Type *)(&ValueMask))->Field = 0;                                                                   \\r
+    PreSmmCpuRegisterTableWrite (ProcessorNumber, RegisterType, Index, ~ValueMask, Value);                \\r
+  } while(FALSE);\r
+\r
+#endif\r
index d889410f4242f9c496a785ffd33493c806f6a388..178bfb50abcfb11d766a9746be0a5c2d29b72896 100644 (file)
-/** @file
-  AESNI feature.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Prepares for the data used by CPU feature detection and initialization.
-
-  @param[in]  NumberOfProcessors  The number of CPUs in the platform.
-
-  @return  Pointer to a buffer of CPU related configuration data.
-
-  @note This service could be called by BSP only.
-**/
-VOID *
-EFIAPI
-AesniGetConfigData (
-  IN UINTN  NumberOfProcessors
-  )
-{
-  UINT64                            *ConfigData;
-
-  ConfigData = AllocateZeroPool (sizeof (UINT64) * NumberOfProcessors);
-  ASSERT (ConfigData != NULL);
-  return ConfigData;
-}
-
-/**
-  Detects if AESNI feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     AESNI feature is supported.
-  @retval FALSE    AESNI feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-AesniSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER   *MsrFeatureConfig;
-
-  if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
-      IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
-      IS_XEON_5600_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
-      IS_XEON_E7_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
-      IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
-    MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData;
-    MsrFeatureConfig[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG);
-    return (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI == 1);
-  }
-  return FALSE;
-}
-
-/**
-  Initializes AESNI feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the AESNI feature must be enabled.
-                               If FALSE, then the AESNI feature must be disabled.
-
-  @retval RETURN_SUCCESS       AESNI feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-AesniInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER   *MsrFeatureConfig;
-
-  //
-  // SANDY_BRIDGE, SILVERMONT, XEON_5600, XEON_7, and XEON_PHI have the same MSR index,
-  // Simply use MSR_SANDY_BRIDGE_FEATURE_CONFIG here
-  //
-  // The scope of the MSR_SANDY_BRIDGE_FEATURE_CONFIG is Core, only program MSR_FEATURE_CONFIG for thread 0
-  // of each core. Otherwise, once a thread in the core disabled AES, the other thread will cause GP when
-  // programming it.
-  //
-  if (CpuInfo->ProcessorInfo.Location.Thread == 0) {
-    MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData;
-    if ((MsrFeatureConfig[ProcessorNumber].Bits.AESConfiguration & BIT0) == 0) {
-      CPU_REGISTER_TABLE_WRITE_FIELD (
-        ProcessorNumber,
-        Msr,
-        MSR_SANDY_BRIDGE_FEATURE_CONFIG,
-        MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER,
-        Bits.AESConfiguration,
-        BIT1 | ((State) ? 0 : BIT0)
-        );
-    }
-  }
-  return RETURN_SUCCESS;
-}
+/** @file\r
+  AESNI feature.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Prepares for the data used by CPU feature detection and initialization.\r
+\r
+  @param[in]  NumberOfProcessors  The number of CPUs in the platform.\r
+\r
+  @return  Pointer to a buffer of CPU related configuration data.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID *\r
+EFIAPI\r
+AesniGetConfigData (\r
+  IN UINTN  NumberOfProcessors\r
+  )\r
+{\r
+  UINT64                            *ConfigData;\r
+\r
+  ConfigData = AllocateZeroPool (sizeof (UINT64) * NumberOfProcessors);\r
+  ASSERT (ConfigData != NULL);\r
+  return ConfigData;\r
+}\r
+\r
+/**\r
+  Detects if AESNI feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     AESNI feature is supported.\r
+  @retval FALSE    AESNI feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesniSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER   *MsrFeatureConfig;\r
+\r
+  if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+      IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+      IS_XEON_5600_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+      IS_XEON_E7_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+      IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {\r
+    MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData;\r
+    MsrFeatureConfig[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG);\r
+    return (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI == 1);\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Initializes AESNI feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the AESNI feature must be enabled.\r
+                               If FALSE, then the AESNI feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       AESNI feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AesniInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER   *MsrFeatureConfig;\r
+\r
+  //\r
+  // SANDY_BRIDGE, SILVERMONT, XEON_5600, XEON_7, and XEON_PHI have the same MSR index,\r
+  // Simply use MSR_SANDY_BRIDGE_FEATURE_CONFIG here\r
+  //\r
+  // The scope of the MSR_SANDY_BRIDGE_FEATURE_CONFIG is Core, only program MSR_FEATURE_CONFIG for thread 0\r
+  // of each core. Otherwise, once a thread in the core disabled AES, the other thread will cause GP when\r
+  // programming it.\r
+  //\r
+  if (CpuInfo->ProcessorInfo.Location.Thread == 0) {\r
+    MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData;\r
+    if ((MsrFeatureConfig[ProcessorNumber].Bits.AESConfiguration & BIT0) == 0) {\r
+      CPU_REGISTER_TABLE_WRITE_FIELD (\r
+        ProcessorNumber,\r
+        Msr,\r
+        MSR_SANDY_BRIDGE_FEATURE_CONFIG,\r
+        MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER,\r
+        Bits.AESConfiguration,\r
+        BIT1 | ((State) ? 0 : BIT0)\r
+        );\r
+    }\r
+  }\r
+  return RETURN_SUCCESS;\r
+}\r
index 116590fecd88b957f6afe363a3e821ecf6968b86..47116355a8ff392d0277a18f49d3f3cf8a5f3382 100644 (file)
@@ -1,79 +1,79 @@
-/** @file
-  C1E feature.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Detects if C1E feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     C1E feature is supported.
-  @retval FALSE    C1E feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-C1eSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  return IS_NEHALEM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel);
-}
-
-/**
-  Initializes C1E feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the C1E feature must be enabled.
-                               If FALSE, then the C1E feature must be disabled.
-
-  @retval RETURN_SUCCESS       C1E feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-C1eInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  CPU_REGISTER_TABLE_WRITE_FIELD (
-    ProcessorNumber,
-    Msr,
-    MSR_NEHALEM_POWER_CTL,
-    MSR_NEHALEM_POWER_CTL_REGISTER,
-    Bits.C1EEnable,
-    (State) ? 1 : 0
-    );
-  return RETURN_SUCCESS;
-}
+/** @file\r
+  C1E feature.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Detects if C1E feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     C1E feature is supported.\r
+  @retval FALSE    C1E feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+C1eSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  return IS_NEHALEM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel);\r
+}\r
+\r
+/**\r
+  Initializes C1E feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the C1E feature must be enabled.\r
+                               If FALSE, then the C1E feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       C1E feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+C1eInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  CPU_REGISTER_TABLE_WRITE_FIELD (\r
+    ProcessorNumber,\r
+    Msr,\r
+    MSR_NEHALEM_POWER_CTL,\r
+    MSR_NEHALEM_POWER_CTL_REGISTER,\r
+    Bits.C1EEnable,\r
+    (State) ? 1 : 0\r
+    );\r
+  return RETURN_SUCCESS;\r
+}\r
index adbe075acb3e4ca2f13c47cc155d653e56ac82d1..56e53561e9de0f9fab0a51698f4016d983cac6d8 100644 (file)
-/** @file
-  Clock Modulation feature.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Detects if Clock Modulation feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Clock Modulation feature is supported.
-  @retval FALSE    Clock Modulation feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-ClockModulationSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  return (CpuInfo->CpuIdVersionInfoEdx.Bits.ACPI == 1);
-}
-
-/**
-  Initializes Clock Modulation feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Clock Modulation feature must be enabled.
-                               If FALSE, then the Clock Modulation feature must be disabled.
-
-  @retval RETURN_SUCCESS       Clock Modulation feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-ClockModulationInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
-    CPU_REGISTER_TABLE_WRITE_FIELD (
-      ProcessorNumber,
-      Msr,
-      MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION,
-      MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER,
-      Bits.OnDemandClockModulationDutyCycle,
-      PcdGet8 (PcdCpuClockModulationDutyCycle)
-      );
-    CPU_REGISTER_TABLE_WRITE_FIELD (
-      ProcessorNumber,
-      Msr,
-      MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION,
-      MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER,
-      Bits.OnDemandClockModulationEnable,
-      (State) ? 1 : 0
-      );
-  } else {
-    CPU_REGISTER_TABLE_WRITE_FIELD (
-      ProcessorNumber,
-      Msr,
-      MSR_IA32_CLOCK_MODULATION,
-      MSR_IA32_CLOCK_MODULATION_REGISTER,
-      Bits.OnDemandClockModulationDutyCycle,
-      PcdGet8 (PcdCpuClockModulationDutyCycle)
-      );
-    CPU_REGISTER_TABLE_WRITE_FIELD (
-      ProcessorNumber,
-      Msr,
-      MSR_IA32_CLOCK_MODULATION,
-      MSR_IA32_CLOCK_MODULATION_REGISTER,
-      Bits.OnDemandClockModulationEnable,
-      (State) ? 1 : 0
-      );
-  }
-  return RETURN_SUCCESS;
-}
+/** @file\r
+  Clock Modulation feature.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Detects if Clock Modulation feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Clock Modulation feature is supported.\r
+  @retval FALSE    Clock Modulation feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ClockModulationSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  return (CpuInfo->CpuIdVersionInfoEdx.Bits.ACPI == 1);\r
+}\r
+\r
+/**\r
+  Initializes Clock Modulation feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Clock Modulation feature must be enabled.\r
+                               If FALSE, then the Clock Modulation feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Clock Modulation feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ClockModulationInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {\r
+    CPU_REGISTER_TABLE_WRITE_FIELD (\r
+      ProcessorNumber,\r
+      Msr,\r
+      MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION,\r
+      MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER,\r
+      Bits.OnDemandClockModulationDutyCycle,\r
+      PcdGet8 (PcdCpuClockModulationDutyCycle)\r
+      );\r
+    CPU_REGISTER_TABLE_WRITE_FIELD (\r
+      ProcessorNumber,\r
+      Msr,\r
+      MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION,\r
+      MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER,\r
+      Bits.OnDemandClockModulationEnable,\r
+      (State) ? 1 : 0\r
+      );\r
+  } else {\r
+    CPU_REGISTER_TABLE_WRITE_FIELD (\r
+      ProcessorNumber,\r
+      Msr,\r
+      MSR_IA32_CLOCK_MODULATION,\r
+      MSR_IA32_CLOCK_MODULATION_REGISTER,\r
+      Bits.OnDemandClockModulationDutyCycle,\r
+      PcdGet8 (PcdCpuClockModulationDutyCycle)\r
+      );\r
+    CPU_REGISTER_TABLE_WRITE_FIELD (\r
+      ProcessorNumber,\r
+      Msr,\r
+      MSR_IA32_CLOCK_MODULATION,\r
+      MSR_IA32_CLOCK_MODULATION_REGISTER,\r
+      Bits.OnDemandClockModulationEnable,\r
+      (State) ? 1 : 0\r
+      );\r
+  }\r
+  return RETURN_SUCCESS;\r
+}\r
index 8118c1f3943d5d7e1306eed467e931b24822bb76..aa6d1122b1a290448ec33e351a9a3eb363681aff 100644 (file)
-/** @file
-  CPU Common features library header file.
-
-  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.
-
-**/
-
-#ifndef _CPU_COMMON_FEATURES_H_
-#define _CPU_COMMON_FEATURES_H_
-
-#include <PiDxe.h>
-
-#include <Library/BaseLib.h>
-#include <Library/PcdLib.h>
-#include <Library/DebugLib.h>
-#include <Library/RegisterCpuFeaturesLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/LocalApicLib.h>
-
-#include <Register/Cpuid.h>
-#include <Register/Msr.h>
-
-/**
-  Prepares for the data used by CPU feature detection and initialization.
-
-  @param[in]  NumberOfProcessors  The number of CPUs in the platform.
-
-  @return  Pointer to a buffer of CPU related configuration data.
-
-  @note This service could be called by BSP only.
-**/
-VOID *
-EFIAPI
-AesniGetConfigData (
-  IN UINTN  NumberOfProcessors
-  );
-
-/**
-  Detects if AESNI feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     AESNI feature is supported.
-  @retval FALSE    AESNI feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-AesniSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes AESNI feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the AESNI feature must be enabled.
-                               If FALSE, then the AESNI feature must be disabled.
-
-  @retval RETURN_SUCCESS       AESNI feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-AesniInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if Clock Modulation feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Clock Modulation feature is supported.
-  @retval FALSE    Clock Modulation feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-ClockModulationSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes Clock Modulation feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Clock Modulation feature must be enabled.
-                               If FALSE, then the Clock Modulation feature must be disabled.
-
-  @retval RETURN_SUCCESS       Clock Modulation feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-ClockModulationInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if Enhanced Intel SpeedStep feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Enhanced Intel SpeedStep feature is supported.
-  @retval FALSE    Enhanced Intel SpeedStep feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-EistSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes Enhanced Intel SpeedStep feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Enhanced Intel SpeedStep feature
-                               must be enabled.
-                               If FALSE, then the Enhanced Intel SpeedStep feature
-                               must be disabled.
-
-  @retval RETURN_SUCCESS       Enhanced Intel SpeedStep feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-EistInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if Execute Disable feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Execute Disable feature is supported.
-  @retval FALSE    Execute Disable feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-ExecuteDisableSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes Execute Disable feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Execute Disable feature must be enabled.
-                               If FALSE, then the Execute Disable feature must be disabled.
-
-  @retval RETURN_SUCCESS       Execute Disable feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-ExecuteDisableInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Initializes Fast-Strings feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Fast-Strings feature must be enabled.
-                               If FALSE, then the Fast-Strings feature must be disabled.
-
-  @retval RETURN_SUCCESS       Fast-Strings feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-FastStringsInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if MONITOR/MWAIT feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     MONITOR/MWAIT feature is supported.
-  @retval FALSE    MONITOR/MWAIT feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-MonitorMwaitSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes MONITOR/MWAIT feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the MONITOR/MWAIT feature must be enabled.
-                               If FALSE, then the MONITOR/MWAIT feature must be disabled.
-
-  @retval RETURN_SUCCESS       MONITOR/MWAIT feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-MonitorMwaitInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if VMX feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     VMX feature is supported.
-  @retval FALSE    VMX feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-VmxSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes VMX inside SMX feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the VMX inside SMX feature must be enabled.
-                               If FALSE, then the VMX inside SMX feature must be disabled.
-
-  @retval RETURN_SUCCESS       VMX inside SMX feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-VmxInsideSmxInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Initializes SENTER feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the SENTER feature must be enabled.
-                               If FALSE, then the SENTER feature must be disabled.
-
-  @retval RETURN_SUCCESS       SENTER feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-SenterInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if Lock Feature Control Register feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Lock Feature Control Register feature is supported.
-  @retval FALSE    Lock Feature Control Register feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-LockFeatureControlRegisterSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes Lock Feature Control Register feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Lock Feature Control Register feature must be enabled.
-                               If FALSE, then the Lock Feature Control Register feature must be disabled.
-
-  @retval RETURN_SUCCESS       Lock Feature Control Register feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-LockFeatureControlRegisterInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if SMX feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     SMX feature is supported.
-  @retval FALSE    SMX feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-SmxSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes VMX outside SMX feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the VMX outside SMX feature must be enabled.
-                               If FALSE, then the VMX outside SMX feature must be disabled.
-
-  @retval RETURN_SUCCESS       VMX outside SMX feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-VmxOutsideSmxInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if LimitCpuidMaxval feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     LimitCpuidMaxval feature is supported.
-  @retval FALSE    LimitCpuidMaxval feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-LimitCpuidMaxvalSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes LimitCpuidMaxval feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the LimitCpuidMaxval feature must be enabled.
-                               If FALSE, then the LimitCpuidMaxval feature must be disabled.
-
-  @retval RETURN_SUCCESS       LimitCpuidMaxval feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-LimitCpuidMaxvalInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if Machine Check Exception feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Machine Check Exception feature is supported.
-  @retval FALSE    Machine Check Exception feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-MceSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes Machine Check Exception feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Machine Check Exception feature must be enabled.
-                               If FALSE, then the Machine Check Exception feature must be disabled.
-
-  @retval RETURN_SUCCESS       Machine Check Exception feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-MceInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if Machine Check Architecture feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Machine Check Architecture feature is supported.
-  @retval FALSE    Machine Check Architecture feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-McaSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes Machine Check Architecture feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Machine Check Architecture feature must be enabled.
-                               If FALSE, then the Machine Check Architecture feature must be disabled.
-
-  @retval RETURN_SUCCESS       Machine Check Architecture feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-McaInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if IA32_MCG_CTL feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     IA32_MCG_CTL feature is supported.
-  @retval FALSE    IA32_MCG_CTL feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-McgCtlSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes IA32_MCG_CTL feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the IA32_MCG_CTL feature must be enabled.
-                               If FALSE, then the IA32_MCG_CTL feature must be disabled.
-
-  @retval RETURN_SUCCESS       IA32_MCG_CTL feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-McgCtlInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if Pending Break feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Pending Break feature is supported.
-  @retval FALSE    Pending Break feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-PendingBreakSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes Pending Break feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Pending Break feature must be enabled.
-                               If FALSE, then the Pending Break feature must be disabled.
-
-  @retval RETURN_SUCCESS       Pending Break feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-PendingBreakInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if C1E feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     C1E feature is supported.
-  @retval FALSE    C1E feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-C1eSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes C1E feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the C1E feature must be enabled.
-                               If FALSE, then the C1E feature must be disabled.
-
-  @retval RETURN_SUCCESS       C1E feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-C1eInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Detects if X2Apci feature supported on current processor.
-
-  Detect if X2Apci has been already enabled.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     X2Apci feature is supported.
-  @retval FALSE    X2Apci feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-X2ApicSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  );
-
-/**
-  Initializes X2Apci feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the X2Apci feature must be enabled.
-                               If FALSE, then the X2Apci feature must be disabled.
-
-  @retval RETURN_SUCCESS       X2Apci feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-X2ApicInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  );
-
-/**
-  Prepares for the data used by CPU feature detection and initialization.
-
-  @param[in]  NumberOfProcessors  The number of CPUs in the platform.
-
-  @return  Pointer to a buffer of CPU related configuration data.
-
-  @note This service could be called by BSP only.
-**/
-VOID *
-EFIAPI
-FeatureControlGetConfigData (
-  IN UINTN               NumberOfProcessors
-  );
-
-#endif
+/** @file\r
+  CPU Common features library header file.\r
+\r
+  Copyright (c) 2017, 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
+#ifndef _CPU_COMMON_FEATURES_H_\r
+#define _CPU_COMMON_FEATURES_H_\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/RegisterCpuFeaturesLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/LocalApicLib.h>\r
+\r
+#include <Register/Cpuid.h>\r
+#include <Register/Msr.h>\r
+\r
+/**\r
+  Prepares for the data used by CPU feature detection and initialization.\r
+\r
+  @param[in]  NumberOfProcessors  The number of CPUs in the platform.\r
+\r
+  @return  Pointer to a buffer of CPU related configuration data.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID *\r
+EFIAPI\r
+AesniGetConfigData (\r
+  IN UINTN  NumberOfProcessors\r
+  );\r
+\r
+/**\r
+  Detects if AESNI feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     AESNI feature is supported.\r
+  @retval FALSE    AESNI feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AesniSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes AESNI feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the AESNI feature must be enabled.\r
+                               If FALSE, then the AESNI feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       AESNI feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AesniInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if Clock Modulation feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Clock Modulation feature is supported.\r
+  @retval FALSE    Clock Modulation feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ClockModulationSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes Clock Modulation feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Clock Modulation feature must be enabled.\r
+                               If FALSE, then the Clock Modulation feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Clock Modulation feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ClockModulationInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if Enhanced Intel SpeedStep feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Enhanced Intel SpeedStep feature is supported.\r
+  @retval FALSE    Enhanced Intel SpeedStep feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EistSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes Enhanced Intel SpeedStep feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Enhanced Intel SpeedStep feature\r
+                               must be enabled.\r
+                               If FALSE, then the Enhanced Intel SpeedStep feature\r
+                               must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Enhanced Intel SpeedStep feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+EistInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if Execute Disable feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Execute Disable feature is supported.\r
+  @retval FALSE    Execute Disable feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ExecuteDisableSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes Execute Disable feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Execute Disable feature must be enabled.\r
+                               If FALSE, then the Execute Disable feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Execute Disable feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExecuteDisableInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Initializes Fast-Strings feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Fast-Strings feature must be enabled.\r
+                               If FALSE, then the Fast-Strings feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Fast-Strings feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+FastStringsInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if MONITOR/MWAIT feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     MONITOR/MWAIT feature is supported.\r
+  @retval FALSE    MONITOR/MWAIT feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+MonitorMwaitSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes MONITOR/MWAIT feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the MONITOR/MWAIT feature must be enabled.\r
+                               If FALSE, then the MONITOR/MWAIT feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       MONITOR/MWAIT feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+MonitorMwaitInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if VMX feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     VMX feature is supported.\r
+  @retval FALSE    VMX feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+VmxSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes VMX inside SMX feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the VMX inside SMX feature must be enabled.\r
+                               If FALSE, then the VMX inside SMX feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       VMX inside SMX feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+VmxInsideSmxInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Initializes SENTER feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the SENTER feature must be enabled.\r
+                               If FALSE, then the SENTER feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       SENTER feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SenterInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if Lock Feature Control Register feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Lock Feature Control Register feature is supported.\r
+  @retval FALSE    Lock Feature Control Register feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LockFeatureControlRegisterSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes Lock Feature Control Register feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Lock Feature Control Register feature must be enabled.\r
+                               If FALSE, then the Lock Feature Control Register feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Lock Feature Control Register feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LockFeatureControlRegisterInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if SMX feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     SMX feature is supported.\r
+  @retval FALSE    SMX feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SmxSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes VMX outside SMX feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the VMX outside SMX feature must be enabled.\r
+                               If FALSE, then the VMX outside SMX feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       VMX outside SMX feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+VmxOutsideSmxInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if LimitCpuidMaxval feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     LimitCpuidMaxval feature is supported.\r
+  @retval FALSE    LimitCpuidMaxval feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LimitCpuidMaxvalSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes LimitCpuidMaxval feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the LimitCpuidMaxval feature must be enabled.\r
+                               If FALSE, then the LimitCpuidMaxval feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       LimitCpuidMaxval feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LimitCpuidMaxvalInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if Machine Check Exception feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Machine Check Exception feature is supported.\r
+  @retval FALSE    Machine Check Exception feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+MceSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes Machine Check Exception feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Machine Check Exception feature must be enabled.\r
+                               If FALSE, then the Machine Check Exception feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Machine Check Exception feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+MceInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if Machine Check Architecture feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Machine Check Architecture feature is supported.\r
+  @retval FALSE    Machine Check Architecture feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+McaSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes Machine Check Architecture feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Machine Check Architecture feature must be enabled.\r
+                               If FALSE, then the Machine Check Architecture feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Machine Check Architecture feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+McaInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if IA32_MCG_CTL feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     IA32_MCG_CTL feature is supported.\r
+  @retval FALSE    IA32_MCG_CTL feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+McgCtlSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes IA32_MCG_CTL feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the IA32_MCG_CTL feature must be enabled.\r
+                               If FALSE, then the IA32_MCG_CTL feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       IA32_MCG_CTL feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+McgCtlInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if Pending Break feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Pending Break feature is supported.\r
+  @retval FALSE    Pending Break feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PendingBreakSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes Pending Break feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Pending Break feature must be enabled.\r
+                               If FALSE, then the Pending Break feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Pending Break feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PendingBreakInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if C1E feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     C1E feature is supported.\r
+  @retval FALSE    C1E feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+C1eSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes C1E feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the C1E feature must be enabled.\r
+                               If FALSE, then the C1E feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       C1E feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+C1eInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Detects if X2Apci feature supported on current processor.\r
+\r
+  Detect if X2Apci has been already enabled.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     X2Apci feature is supported.\r
+  @retval FALSE    X2Apci feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X2ApicSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes X2Apci feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the X2Apci feature must be enabled.\r
+                               If FALSE, then the X2Apci feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       X2Apci feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+X2ApicInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  );\r
+\r
+/**\r
+  Prepares for the data used by CPU feature detection and initialization.\r
+\r
+  @param[in]  NumberOfProcessors  The number of CPUs in the platform.\r
+\r
+  @return  Pointer to a buffer of CPU related configuration data.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID *\r
+EFIAPI\r
+FeatureControlGetConfigData (\r
+  IN UINTN               NumberOfProcessors\r
+  );\r
+\r
+#endif\r
index 65ed756cc578fcda55f0fab415a5d981a1f04b0b..3390aa8f2a7af75994cc55a40c125467ade84662 100644 (file)
-/** @file
-  This library registers CPU features defined in Intel(R) 64 and IA-32
-  Architectures Software Developer's Manual.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Register CPU features.
-
-  @retval  RETURN_SUCCESS            Register successfully
-**/
-RETURN_STATUS
-EFIAPI
-CpuCommonFeaturesLibConstructor (
-  VOID
-  )
-{
-  RETURN_STATUS         Status;
-
-  if (IsCpuFeatureSupported (CPU_FEATURE_AESNI)) {
-    Status = RegisterCpuFeature (
-               "AESNI",
-               AesniGetConfigData,
-               AesniSupport,
-               AesniInitialize,
-               CPU_FEATURE_AESNI,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_MWAIT)) {
-    Status = RegisterCpuFeature (
-               "MWAIT",
-               NULL,
-               MonitorMwaitSupport,
-               MonitorMwaitInitialize,
-               CPU_FEATURE_MWAIT,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_ACPI)) {
-    Status = RegisterCpuFeature (
-               "ACPI",
-               NULL,
-               ClockModulationSupport,
-               ClockModulationInitialize,
-               CPU_FEATURE_ACPI,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_EIST)) {
-    Status = RegisterCpuFeature (
-               "EIST",
-               NULL,
-               EistSupport,
-               EistInitialize,
-               CPU_FEATURE_EIST,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_XD)) {
-    Status = RegisterCpuFeature (
-               "Execute Disable",
-               NULL,
-               ExecuteDisableSupport,
-               ExecuteDisableInitialize,
-               CPU_FEATURE_XD,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_FASTSTRINGS)) {
-    Status = RegisterCpuFeature (
-               "FastStrings",
-               NULL,
-               NULL,
-               FastStringsInitialize,
-               CPU_FEATURE_FASTSTRINGS,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER)) {
-    Status = RegisterCpuFeature (
-               "Lock Feature Control Register",
-               FeatureControlGetConfigData,
-               LockFeatureControlRegisterSupport,
-               LockFeatureControlRegisterInitialize,
-               CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_SENTER)) {
-    Status = RegisterCpuFeature (
-               "SENTER",
-               FeatureControlGetConfigData,
-               VmxSupport,
-               SenterInitialize,
-               CPU_FEATURE_SENTER,
-               CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,
-               CPU_FEATURE_SMX | CPU_FEATURE_AFTER,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_SMX)) {
-    Status = RegisterCpuFeature (
-               "SMX",
-               FeatureControlGetConfigData,
-               SmxSupport,
-               VmxInsideSmxInitialize,
-               CPU_FEATURE_SMX,
-               CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_VMX)) {
-    Status = RegisterCpuFeature (
-               "VMX",
-               FeatureControlGetConfigData,
-               SmxSupport,
-               VmxOutsideSmxInitialize,
-               CPU_FEATURE_VMX,
-               CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_LIMIT_CPUID_MAX_VAL)) {
-    Status = RegisterCpuFeature (
-               "Limit CpuId Maximum Value",
-               NULL,
-               LimitCpuidMaxvalSupport,
-               LimitCpuidMaxvalInitialize,
-               CPU_FEATURE_LIMIT_CPUID_MAX_VAL,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_MCE)) {
-    Status = RegisterCpuFeature (
-               "Machine Check Enable",
-               NULL,
-               MceSupport,
-               MceInitialize,
-               CPU_FEATURE_MCE,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_MCA)) {
-    Status = RegisterCpuFeature (
-               "Machine Check Architect",
-               NULL,
-               McaSupport,
-               McaInitialize,
-               CPU_FEATURE_MCA,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_MCG_CTL)) {
-    Status = RegisterCpuFeature (
-               "MCG_CTL",
-               NULL,
-               McgCtlSupport,
-               McgCtlInitialize,
-               CPU_FEATURE_MCG_CTL,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_PENDING_BREAK)) {
-    Status = RegisterCpuFeature (
-               "Pending Break",
-               NULL,
-               PendingBreakSupport,
-               PendingBreakInitialize,
-               CPU_FEATURE_PENDING_BREAK,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_C1E)) {
-    Status = RegisterCpuFeature (
-               "C1E",
-               NULL,
-               C1eSupport,
-               C1eInitialize,
-               CPU_FEATURE_C1E,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-  if (IsCpuFeatureSupported (CPU_FEATURE_X2APIC)) {
-    Status = RegisterCpuFeature (
-               "X2Apic",
-               NULL,
-               X2ApicSupport,
-               X2ApicInitialize,
-               CPU_FEATURE_X2APIC,
-               CPU_FEATURE_END
-               );
-    ASSERT_EFI_ERROR (Status);
-  }
-
-  return RETURN_SUCCESS;
-}
-
-
-
+/** @file\r
+  This library registers CPU features defined in Intel(R) 64 and IA-32\r
+  Architectures Software Developer's Manual.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Register CPU features.\r
+\r
+  @retval  RETURN_SUCCESS            Register successfully\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+CpuCommonFeaturesLibConstructor (\r
+  VOID\r
+  )\r
+{\r
+  RETURN_STATUS         Status;\r
+\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_AESNI)) {\r
+    Status = RegisterCpuFeature (\r
+               "AESNI",\r
+               AesniGetConfigData,\r
+               AesniSupport,\r
+               AesniInitialize,\r
+               CPU_FEATURE_AESNI,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_MWAIT)) {\r
+    Status = RegisterCpuFeature (\r
+               "MWAIT",\r
+               NULL,\r
+               MonitorMwaitSupport,\r
+               MonitorMwaitInitialize,\r
+               CPU_FEATURE_MWAIT,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_ACPI)) {\r
+    Status = RegisterCpuFeature (\r
+               "ACPI",\r
+               NULL,\r
+               ClockModulationSupport,\r
+               ClockModulationInitialize,\r
+               CPU_FEATURE_ACPI,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_EIST)) {\r
+    Status = RegisterCpuFeature (\r
+               "EIST",\r
+               NULL,\r
+               EistSupport,\r
+               EistInitialize,\r
+               CPU_FEATURE_EIST,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_XD)) {\r
+    Status = RegisterCpuFeature (\r
+               "Execute Disable",\r
+               NULL,\r
+               ExecuteDisableSupport,\r
+               ExecuteDisableInitialize,\r
+               CPU_FEATURE_XD,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_FASTSTRINGS)) {\r
+    Status = RegisterCpuFeature (\r
+               "FastStrings",\r
+               NULL,\r
+               NULL,\r
+               FastStringsInitialize,\r
+               CPU_FEATURE_FASTSTRINGS,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER)) {\r
+    Status = RegisterCpuFeature (\r
+               "Lock Feature Control Register",\r
+               FeatureControlGetConfigData,\r
+               LockFeatureControlRegisterSupport,\r
+               LockFeatureControlRegisterInitialize,\r
+               CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_SENTER)) {\r
+    Status = RegisterCpuFeature (\r
+               "SENTER",\r
+               FeatureControlGetConfigData,\r
+               VmxSupport,\r
+               SenterInitialize,\r
+               CPU_FEATURE_SENTER,\r
+               CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,\r
+               CPU_FEATURE_SMX | CPU_FEATURE_AFTER,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_SMX)) {\r
+    Status = RegisterCpuFeature (\r
+               "SMX",\r
+               FeatureControlGetConfigData,\r
+               SmxSupport,\r
+               VmxInsideSmxInitialize,\r
+               CPU_FEATURE_SMX,\r
+               CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_VMX)) {\r
+    Status = RegisterCpuFeature (\r
+               "VMX",\r
+               FeatureControlGetConfigData,\r
+               SmxSupport,\r
+               VmxOutsideSmxInitialize,\r
+               CPU_FEATURE_VMX,\r
+               CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_LIMIT_CPUID_MAX_VAL)) {\r
+    Status = RegisterCpuFeature (\r
+               "Limit CpuId Maximum Value",\r
+               NULL,\r
+               LimitCpuidMaxvalSupport,\r
+               LimitCpuidMaxvalInitialize,\r
+               CPU_FEATURE_LIMIT_CPUID_MAX_VAL,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_MCE)) {\r
+    Status = RegisterCpuFeature (\r
+               "Machine Check Enable",\r
+               NULL,\r
+               MceSupport,\r
+               MceInitialize,\r
+               CPU_FEATURE_MCE,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_MCA)) {\r
+    Status = RegisterCpuFeature (\r
+               "Machine Check Architect",\r
+               NULL,\r
+               McaSupport,\r
+               McaInitialize,\r
+               CPU_FEATURE_MCA,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_MCG_CTL)) {\r
+    Status = RegisterCpuFeature (\r
+               "MCG_CTL",\r
+               NULL,\r
+               McgCtlSupport,\r
+               McgCtlInitialize,\r
+               CPU_FEATURE_MCG_CTL,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_PENDING_BREAK)) {\r
+    Status = RegisterCpuFeature (\r
+               "Pending Break",\r
+               NULL,\r
+               PendingBreakSupport,\r
+               PendingBreakInitialize,\r
+               CPU_FEATURE_PENDING_BREAK,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_C1E)) {\r
+    Status = RegisterCpuFeature (\r
+               "C1E",\r
+               NULL,\r
+               C1eSupport,\r
+               C1eInitialize,\r
+               CPU_FEATURE_C1E,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+  if (IsCpuFeatureSupported (CPU_FEATURE_X2APIC)) {\r
+    Status = RegisterCpuFeature (\r
+               "X2Apic",\r
+               NULL,\r
+               X2ApicSupport,\r
+               X2ApicInitialize,\r
+               CPU_FEATURE_X2APIC,\r
+               CPU_FEATURE_END\r
+               );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+\r
+\r
index 435819603898fcf122fed976f90f42e8e64a1c3b..e68936be25b7ea39c989eae886d5764875b9a8fb 100644 (file)
@@ -1,68 +1,68 @@
-## @file
-#  NULL instance to register CPU features.
-#
-#  This library registers CPU features defined in Intel(R) 64 and IA-32
-#  Architectures Software Developer's Manual.
-#
-# 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.
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = CpuCommonFeaturesLib
-  MODULE_UNI_FILE                = CpuCommonFeaturesLib.uni
-  FILE_GUID                      = 6D69F79F-9535-4893-9DD7-93929898252C
-  MODULE_TYPE                    = BASE
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = NULL
-
-  CONSTRUCTOR                    = CpuCommonFeaturesLibConstructor
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-#  VALID_ARCHITECTURES           = IA32 X64
-#
-
-[Sources]
-  CpuCommonFeaturesLib.c
-  CpuCommonFeatures.h
-  Aesni.c
-  C1e.c
-  ClockModulation.c
-  Eist.c
-  ExecuteDisable.c
-  FastStrings.c
-  FeatureControl.c
-  LimitCpuIdMaxval.c
-  MachineCheck.c
-  MonitorMwait.c
-  PendingBreak.c
-  X2Apic.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  UefiCpuPkg/UefiCpuPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  PcdLib
-  DebugLib
-  RegisterCpuFeaturesLib
-  BaseMemoryLib
-  MemoryAllocationLib
-  LocalApicLib
-
-[Pcd]
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport            ## CONSUMES
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle   ## SOMETIMES_CONSUMES
-  gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset                ## SOMETIMES_CONSUMES
-
+## @file\r
+#  NULL instance to register CPU features.\r
+#\r
+#  This library registers CPU features defined in Intel(R) 64 and IA-32\r
+#  Architectures Software Developer's Manual.\r
+#\r
+# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+#\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
+#  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
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = CpuCommonFeaturesLib\r
+  MODULE_UNI_FILE                = CpuCommonFeaturesLib.uni\r
+  FILE_GUID                      = 6D69F79F-9535-4893-9DD7-93929898252C\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = NULL\r
+\r
+  CONSTRUCTOR                    = CpuCommonFeaturesLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources]\r
+  CpuCommonFeaturesLib.c\r
+  CpuCommonFeatures.h\r
+  Aesni.c\r
+  C1e.c\r
+  ClockModulation.c\r
+  Eist.c\r
+  ExecuteDisable.c\r
+  FastStrings.c\r
+  FeatureControl.c\r
+  LimitCpuIdMaxval.c\r
+  MachineCheck.c\r
+  MonitorMwait.c\r
+  PendingBreak.c\r
+  X2Apic.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  PcdLib\r
+  DebugLib\r
+  RegisterCpuFeaturesLib\r
+  BaseMemoryLib\r
+  MemoryAllocationLib\r
+  LocalApicLib\r
+\r
+[Pcd]\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport            ## CONSUMES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle   ## SOMETIMES_CONSUMES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset                ## SOMETIMES_CONSUMES\r
+\r
index 620766e3288a5331c589ab06016ca2480ed2e751..d1a90c32d47f0b8510acccd7c68330c6681b0f07 100644 (file)
@@ -1,25 +1,25 @@
-// /** @file
-// Dxe Crc32 Guided Section Extract library.
-//
-// This library doesn't produce any library class. The constructor function uses
-// ExtractGuidedSectionLib service to register CRC32 guided section handler
-// that parses CRC32 encapsulation section and extracts raw data.
-//
-// It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value.
-//
-// Copyright (c) 2006 - 2014, 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT             #language en-US "Dxe Crc32 Guided Section Extract library."
-
-#string STR_MODULE_DESCRIPTION          #language en-US "This library doesn't produce any library class. The constructor function uses ExtractGuidedSectionLib service to register CRC32 guided section handler that parses CRC32 encapsulation section and extracts raw data. It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value."
-
+// /** @file\r
+// Dxe Crc32 Guided Section Extract library.\r
+//\r
+// This library doesn't produce any library class. The constructor function uses\r
+// ExtractGuidedSectionLib service to register CRC32 guided section handler\r
+// that parses CRC32 encapsulation section and extracts raw data.\r
+//\r
+// It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value.\r
+//\r
+// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+//\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
+// 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
+\r
+#string STR_MODULE_ABSTRACT             #language en-US "Dxe Crc32 Guided Section Extract library."\r
+\r
+#string STR_MODULE_DESCRIPTION          #language en-US "This library doesn't produce any library class. The constructor function uses ExtractGuidedSectionLib service to register CRC32 guided section handler that parses CRC32 encapsulation section and extracts raw data. It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value."\r
+\r
index e1d3d42d9995bf4c57a59bf04ca0f439338e438d..2038171a14c3e207bf91612c9740225bbcc0e8d9 100644 (file)
@@ -1,81 +1,81 @@
-/** @file
-  Enhanced Intel SpeedStep feature.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Detects if Enhanced Intel SpeedStep feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Enhanced Intel SpeedStep feature is supported.
-  @retval FALSE    Enhanced Intel SpeedStep feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-EistSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  return (CpuInfo->CpuIdVersionInfoEcx.Bits.EIST == 1);
-}
-
-/**
-  Initializes Enhanced Intel SpeedStep feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Enhanced Intel SpeedStep feature
-                               must be enabled.
-                               If FALSE, then the Enhanced Intel SpeedStep feature
-                               must be disabled.
-
-  @retval RETURN_SUCCESS       Enhanced Intel SpeedStep feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-EistInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  CPU_REGISTER_TABLE_WRITE_FIELD (
-    ProcessorNumber,
-    Msr,
-    MSR_IA32_MISC_ENABLE,
-    MSR_IA32_MISC_ENABLE_REGISTER,
-    Bits.EIST,
-    (State) ? 1 : 0
-    );
-  return RETURN_SUCCESS;
-}
+/** @file\r
+  Enhanced Intel SpeedStep feature.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Detects if Enhanced Intel SpeedStep feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Enhanced Intel SpeedStep feature is supported.\r
+  @retval FALSE    Enhanced Intel SpeedStep feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EistSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  return (CpuInfo->CpuIdVersionInfoEcx.Bits.EIST == 1);\r
+}\r
+\r
+/**\r
+  Initializes Enhanced Intel SpeedStep feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Enhanced Intel SpeedStep feature\r
+                               must be enabled.\r
+                               If FALSE, then the Enhanced Intel SpeedStep feature\r
+                               must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Enhanced Intel SpeedStep feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+EistInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  CPU_REGISTER_TABLE_WRITE_FIELD (\r
+    ProcessorNumber,\r
+    Msr,\r
+    MSR_IA32_MISC_ENABLE,\r
+    MSR_IA32_MISC_ENABLE_REGISTER,\r
+    Bits.EIST,\r
+    (State) ? 1 : 0\r
+    );\r
+  return RETURN_SUCCESS;\r
+}\r
index dd4293ee38d75792df712039230c480f2d4f3c14..921656a1e86989e27117e3db01c7a49c18138cd2 100644 (file)
@@ -1,91 +1,91 @@
-/** @file
-  Execute Disable feature.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Detects if Execute Disable feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Execute Disable feature is supported.
-  @retval FALSE    Execute Disable feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-ExecuteDisableSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  UINT32                         Eax;
-  CPUID_EXTENDED_CPU_SIG_EDX     Edx;
-
-  AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL);
-  if (Eax <= CPUID_EXTENDED_FUNCTION) {
-    //
-    // Extended CPUID functions are not supported on this processor.
-    //
-    return FALSE;
-  }
-
-  AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32);
-  return (Edx.Bits.NX != 0);
-}
-
-/**
-  Initializes Execute Disable feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Execute Disable feature must be enabled.
-                               If FALSE, then the Execute Disable feature must be disabled.
-
-  @retval RETURN_SUCCESS       Execute Disable feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-ExecuteDisableInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  CPU_REGISTER_TABLE_WRITE_FIELD (
-    ProcessorNumber,
-    Msr,
-    MSR_IA32_EFER,
-    MSR_IA32_EFER_REGISTER,
-    Bits.NXE,
-    (State) ? 1 : 0
-    );
-  return RETURN_SUCCESS;
-}
+/** @file\r
+  Execute Disable feature.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Detects if Execute Disable feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Execute Disable feature is supported.\r
+  @retval FALSE    Execute Disable feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ExecuteDisableSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  UINT32                         Eax;\r
+  CPUID_EXTENDED_CPU_SIG_EDX     Edx;\r
+\r
+  AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL);\r
+  if (Eax <= CPUID_EXTENDED_FUNCTION) {\r
+    //\r
+    // Extended CPUID functions are not supported on this processor.\r
+    //\r
+    return FALSE;\r
+  }\r
+\r
+  AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32);\r
+  return (Edx.Bits.NX != 0);\r
+}\r
+\r
+/**\r
+  Initializes Execute Disable feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Execute Disable feature must be enabled.\r
+                               If FALSE, then the Execute Disable feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Execute Disable feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+ExecuteDisableInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  CPU_REGISTER_TABLE_WRITE_FIELD (\r
+    ProcessorNumber,\r
+    Msr,\r
+    MSR_IA32_EFER,\r
+    MSR_IA32_EFER_REGISTER,\r
+    Bits.NXE,\r
+    (State) ? 1 : 0\r
+    );\r
+  return RETURN_SUCCESS;\r
+}\r
index 4c3000d00c314f877209f80f48a08060dc3639be..029bcf87b3ce7dfa5f6aafc67f1f1c5f9cf7fa15 100644 (file)
@@ -1,52 +1,52 @@
-/** @file
-  Fast-Strings feature.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Initializes Fast-Strings feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Fast-Strings feature must be enabled.
-                               If FALSE, then the Fast-Strings feature must be disabled.
-
-  @retval RETURN_SUCCESS       Fast-Strings feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-FastStringsInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  CPU_REGISTER_TABLE_WRITE_FIELD (
-    ProcessorNumber,
-    Msr,
-    MSR_IA32_MISC_ENABLE,
-    MSR_IA32_MISC_ENABLE_REGISTER,
-    Bits.FastStrings,
-    (State) ? 1 : 0
-    );
-  return RETURN_SUCCESS;
-}
+/** @file\r
+  Fast-Strings feature.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Initializes Fast-Strings feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Fast-Strings feature must be enabled.\r
+                               If FALSE, then the Fast-Strings feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Fast-Strings feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+FastStringsInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  CPU_REGISTER_TABLE_WRITE_FIELD (\r
+    ProcessorNumber,\r
+    Msr,\r
+    MSR_IA32_MISC_ENABLE,\r
+    MSR_IA32_MISC_ENABLE_REGISTER,\r
+    Bits.FastStrings,\r
+    (State) ? 1 : 0\r
+    );\r
+  return RETURN_SUCCESS;\r
+}\r
index e627a65dfdfc1addfa229bcb529a61999120d52c..0b5c161f87a02afd24aff4eb5179ec7620f77352 100644 (file)
-/** @file
-  Features in MSR_IA32_FEATURE_CONTROL register.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Prepares for the data used by CPU feature detection and initialization.
-
-  @param[in]  NumberOfProcessors  The number of CPUs in the platform.
-
-  @return  Pointer to a buffer of CPU related configuration data.
-
-  @note This service could be called by BSP only.
-**/
-VOID *
-EFIAPI
-FeatureControlGetConfigData (
-  IN UINTN               NumberOfProcessors
-  )
-{
-  VOID          *ConfigData;
-
-  ConfigData = AllocateZeroPool (sizeof (MSR_IA32_FEATURE_CONTROL_REGISTER) * NumberOfProcessors);
-  ASSERT (ConfigData != NULL);
-  return ConfigData;
-}
-
-/**
-  Detects if VMX feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     VMX feature is supported.
-  @retval FALSE    VMX feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-VmxSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;
-
-  ASSERT (ConfigData != NULL);
-  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
-  MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);
-  return (CpuInfo->CpuIdVersionInfoEcx.Bits.VMX == 1);
-}
-
-/**
-  Initializes VMX inside SMX feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the VMX inside SMX feature must be enabled.
-                               If FALSE, then the VMX inside SMX feature must be disabled.
-
-  @retval RETURN_SUCCESS       VMX inside SMX feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-VmxInsideSmxInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;
-
-  ASSERT (ConfigData != NULL);
-  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
-  if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
-    CPU_REGISTER_TABLE_WRITE_FIELD (
-      ProcessorNumber,
-      Msr,
-      MSR_IA32_FEATURE_CONTROL,
-      MSR_IA32_FEATURE_CONTROL_REGISTER,
-      Bits.EnableVmxInsideSmx,
-      (State) ? 1 : 0
-      );
-  }
-  return RETURN_SUCCESS;
-}
-
-/**
-  Initializes SENTER feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the SENTER feature must be enabled.
-                               If FALSE, then the SENTER feature must be disabled.
-
-  @retval RETURN_SUCCESS       SENTER feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-SenterInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;
-
-  ASSERT (ConfigData != NULL);
-  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
-  if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
-    CPU_REGISTER_TABLE_WRITE_FIELD (
-      ProcessorNumber,
-      Msr,
-      MSR_IA32_FEATURE_CONTROL,
-      MSR_IA32_FEATURE_CONTROL_REGISTER,
-      Bits.SenterLocalFunctionEnables,
-      (State) ? 0x7F : 0
-      );
-
-    CPU_REGISTER_TABLE_WRITE_FIELD (
-      ProcessorNumber,
-      Msr,
-      MSR_IA32_FEATURE_CONTROL,
-      MSR_IA32_FEATURE_CONTROL_REGISTER,
-      Bits.SenterGlobalEnable,
-      (State) ? 1 : 0
-      );
-  }
-  return RETURN_SUCCESS;
-}
-
-/**
-  Detects if Lock Feature Control Register feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Lock Feature Control Register feature is supported.
-  @retval FALSE    Lock Feature Control Register feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-LockFeatureControlRegisterSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;
-
-  ASSERT (ConfigData != NULL);
-  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
-  MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);
-  return TRUE;
-}
-
-/**
-  Initializes Lock Feature Control Register feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Lock Feature Control Register feature must be enabled.
-                               If FALSE, then the Lock Feature Control Register feature must be disabled.
-
-  @retval RETURN_SUCCESS       Lock Feature Control Register feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-LockFeatureControlRegisterInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;
-
-  ASSERT (ConfigData != NULL);
-  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
-  if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
-    CPU_REGISTER_TABLE_WRITE_FIELD (
-      ProcessorNumber,
-      Msr,
-      MSR_IA32_FEATURE_CONTROL,
-      MSR_IA32_FEATURE_CONTROL_REGISTER,
-      Bits.Lock,
-      1
-      );
-  }
-  return RETURN_SUCCESS;
-}
-
-/**
-  Detects if SMX feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     SMX feature is supported.
-  @retval FALSE    SMX feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-SmxSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;
-
-  ASSERT (ConfigData != NULL);
-  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
-  MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);
-  return (CpuInfo->CpuIdVersionInfoEcx.Bits.SMX == 1);
-}
-
-/**
-  Initializes VMX outside SMX feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the VMX outside SMX feature must be enabled.
-                               If FALSE, then the VMX outside SMX feature must be disabled.
-
-  @retval RETURN_SUCCESS       VMX outside SMX feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-VmxOutsideSmxInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;
-
-  ASSERT (ConfigData != NULL);
-  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
-  if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
-    CPU_REGISTER_TABLE_WRITE_FIELD (
-      ProcessorNumber,
-      Msr,
-      MSR_IA32_FEATURE_CONTROL,
-      MSR_IA32_FEATURE_CONTROL_REGISTER,
-      Bits.EnableVmxOutsideSmx,
-      (State) ? 1 : 0
-      );
-  }
-  return RETURN_SUCCESS;
-}
+/** @file\r
+  Features in MSR_IA32_FEATURE_CONTROL register.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Prepares for the data used by CPU feature detection and initialization.\r
+\r
+  @param[in]  NumberOfProcessors  The number of CPUs in the platform.\r
+\r
+  @return  Pointer to a buffer of CPU related configuration data.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID *\r
+EFIAPI\r
+FeatureControlGetConfigData (\r
+  IN UINTN               NumberOfProcessors\r
+  )\r
+{\r
+  VOID          *ConfigData;\r
+\r
+  ConfigData = AllocateZeroPool (sizeof (MSR_IA32_FEATURE_CONTROL_REGISTER) * NumberOfProcessors);\r
+  ASSERT (ConfigData != NULL);\r
+  return ConfigData;\r
+}\r
+\r
+/**\r
+  Detects if VMX feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     VMX feature is supported.\r
+  @retval FALSE    VMX feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+VmxSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;\r
+\r
+  ASSERT (ConfigData != NULL);\r
+  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;\r
+  MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);\r
+  return (CpuInfo->CpuIdVersionInfoEcx.Bits.VMX == 1);\r
+}\r
+\r
+/**\r
+  Initializes VMX inside SMX feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the VMX inside SMX feature must be enabled.\r
+                               If FALSE, then the VMX inside SMX feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       VMX inside SMX feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+VmxInsideSmxInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;\r
+\r
+  ASSERT (ConfigData != NULL);\r
+  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;\r
+  if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {\r
+    CPU_REGISTER_TABLE_WRITE_FIELD (\r
+      ProcessorNumber,\r
+      Msr,\r
+      MSR_IA32_FEATURE_CONTROL,\r
+      MSR_IA32_FEATURE_CONTROL_REGISTER,\r
+      Bits.EnableVmxInsideSmx,\r
+      (State) ? 1 : 0\r
+      );\r
+  }\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Initializes SENTER feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the SENTER feature must be enabled.\r
+                               If FALSE, then the SENTER feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       SENTER feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SenterInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;\r
+\r
+  ASSERT (ConfigData != NULL);\r
+  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;\r
+  if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {\r
+    CPU_REGISTER_TABLE_WRITE_FIELD (\r
+      ProcessorNumber,\r
+      Msr,\r
+      MSR_IA32_FEATURE_CONTROL,\r
+      MSR_IA32_FEATURE_CONTROL_REGISTER,\r
+      Bits.SenterLocalFunctionEnables,\r
+      (State) ? 0x7F : 0\r
+      );\r
+\r
+    CPU_REGISTER_TABLE_WRITE_FIELD (\r
+      ProcessorNumber,\r
+      Msr,\r
+      MSR_IA32_FEATURE_CONTROL,\r
+      MSR_IA32_FEATURE_CONTROL_REGISTER,\r
+      Bits.SenterGlobalEnable,\r
+      (State) ? 1 : 0\r
+      );\r
+  }\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Detects if Lock Feature Control Register feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Lock Feature Control Register feature is supported.\r
+  @retval FALSE    Lock Feature Control Register feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LockFeatureControlRegisterSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;\r
+\r
+  ASSERT (ConfigData != NULL);\r
+  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;\r
+  MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Initializes Lock Feature Control Register feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Lock Feature Control Register feature must be enabled.\r
+                               If FALSE, then the Lock Feature Control Register feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Lock Feature Control Register feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LockFeatureControlRegisterInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;\r
+\r
+  ASSERT (ConfigData != NULL);\r
+  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;\r
+  if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {\r
+    CPU_REGISTER_TABLE_WRITE_FIELD (\r
+      ProcessorNumber,\r
+      Msr,\r
+      MSR_IA32_FEATURE_CONTROL,\r
+      MSR_IA32_FEATURE_CONTROL_REGISTER,\r
+      Bits.Lock,\r
+      1\r
+      );\r
+  }\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Detects if SMX feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     SMX feature is supported.\r
+  @retval FALSE    SMX feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SmxSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;\r
+\r
+  ASSERT (ConfigData != NULL);\r
+  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;\r
+  MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);\r
+  return (CpuInfo->CpuIdVersionInfoEcx.Bits.SMX == 1);\r
+}\r
+\r
+/**\r
+  Initializes VMX outside SMX feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the VMX outside SMX feature must be enabled.\r
+                               If FALSE, then the VMX outside SMX feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       VMX outside SMX feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+VmxOutsideSmxInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  MSR_IA32_FEATURE_CONTROL_REGISTER    *MsrRegister;\r
+\r
+  ASSERT (ConfigData != NULL);\r
+  MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;\r
+  if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {\r
+    CPU_REGISTER_TABLE_WRITE_FIELD (\r
+      ProcessorNumber,\r
+      Msr,\r
+      MSR_IA32_FEATURE_CONTROL,\r
+      MSR_IA32_FEATURE_CONTROL_REGISTER,\r
+      Bits.EnableVmxOutsideSmx,\r
+      (State) ? 1 : 0\r
+      );\r
+  }\r
+  return RETURN_SUCCESS;\r
+}\r
index 0f51fb3e98a258b412f6f0f13ec1c42250a77bc9..40cc9d5fe0cf16d48f398d875663b52be2572c2a 100644 (file)
@@ -1,82 +1,82 @@
-/** @file
-  LimitCpuidMaxval Feature.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Detects if LimitCpuidMaxval feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     LimitCpuidMaxval feature is supported.
-  @retval FALSE    LimitCpuidMaxval feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-LimitCpuidMaxvalSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  UINT32  Eax;
-
-  AsmCpuid (CPUID_SIGNATURE, &Eax, NULL, NULL, NULL);
-  return (Eax > 3);
-}
-
-/**
-  Initializes LimitCpuidMaxval feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the LimitCpuidMaxval feature must be enabled.
-                               If FALSE, then the LimitCpuidMaxval feature must be disabled.
-
-  @retval RETURN_SUCCESS       LimitCpuidMaxval feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-LimitCpuidMaxvalInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  CPU_REGISTER_TABLE_WRITE_FIELD (
-    ProcessorNumber,
-    Msr,
-    MSR_IA32_MISC_ENABLE,
-    MSR_IA32_MISC_ENABLE_REGISTER,
-    Bits.LimitCpuidMaxval,
-    (State) ? 1 : 0
-    );
-  return RETURN_SUCCESS;
-}
+/** @file\r
+  LimitCpuidMaxval Feature.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Detects if LimitCpuidMaxval feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     LimitCpuidMaxval feature is supported.\r
+  @retval FALSE    LimitCpuidMaxval feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LimitCpuidMaxvalSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  UINT32  Eax;\r
+\r
+  AsmCpuid (CPUID_SIGNATURE, &Eax, NULL, NULL, NULL);\r
+  return (Eax > 3);\r
+}\r
+\r
+/**\r
+  Initializes LimitCpuidMaxval feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the LimitCpuidMaxval feature must be enabled.\r
+                               If FALSE, then the LimitCpuidMaxval feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       LimitCpuidMaxval feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LimitCpuidMaxvalInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  CPU_REGISTER_TABLE_WRITE_FIELD (\r
+    ProcessorNumber,\r
+    Msr,\r
+    MSR_IA32_MISC_ENABLE,\r
+    MSR_IA32_MISC_ENABLE_REGISTER,\r
+    Bits.LimitCpuidMaxval,\r
+    (State) ? 1 : 0\r
+    );\r
+  return RETURN_SUCCESS;\r
+}\r
index 2d9501b91a8260fc4b439b73e80c8d99a4a76449..72f665d32e36ec442dec20deb307622405ae4e68 100644 (file)
-/** @file
-  Machine Check 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 "CpuCommonFeatures.h"
-
-/**
-  Detects if Machine Check Exception feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Machine Check Exception feature is supported.
-  @retval FALSE    Machine Check Exception feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-MceSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCE == 1);
-}
-
-/**
-  Initializes Machine Check Exception feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Machine Check Exception feature must be enabled.
-                               If FALSE, then the Machine Check Exception feature must be disabled.
-
-  @retval RETURN_SUCCESS       Machine Check Exception feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-MceInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  //
-  // Set MCE bit in CR4
-  //
-  CPU_REGISTER_TABLE_WRITE_FIELD (
-    ProcessorNumber,
-    ControlRegister,
-    4,
-    IA32_CR4,
-    Bits.MCE,
-    (State) ? 1 : 0
-    );
-  return RETURN_SUCCESS;
-}
-
-/**
-  Detects if Machine Check Architecture feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Machine Check Architecture feature is supported.
-  @retval FALSE    Machine Check Architecture feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-McaSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCA == 1);
-}
-
-/**
-  Initializes Machine Check Architecture feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Machine Check Architecture feature must be enabled.
-                               If FALSE, then the Machine Check Architecture feature must be disabled.
-
-  @retval RETURN_SUCCESS       Machine Check Architecture feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-McaInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  MSR_IA32_MCG_CAP_REGISTER  McgCap;
-  UINT32                     BankIndex;
-
-  McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);
-  for (BankIndex = 0; BankIndex < (UINT32) McgCap.Bits.Count; BankIndex++) {
-    CPU_REGISTER_TABLE_WRITE64 (
-      ProcessorNumber,
-      Msr,
-      MSR_IA32_MC0_CTL + BankIndex * 4,
-      MAX_UINT64
-      );
-  }
-
-  if (PcdGetBool (PcdIsPowerOnReset)) {
-    for (BankIndex = 0; BankIndex < (UINTN) McgCap.Bits.Count; BankIndex++) {
-      CPU_REGISTER_TABLE_WRITE64 (
-        ProcessorNumber,
-        Msr,
-        MSR_IA32_MC0_STATUS + BankIndex * 4,
-        0
-        );
-    }
-  }
-
-  return RETURN_SUCCESS;
-}
-
-/**
-  Detects if IA32_MCG_CTL feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     IA32_MCG_CTL feature is supported.
-  @retval FALSE    IA32_MCG_CTL feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-McgCtlSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  MSR_IA32_MCG_CAP_REGISTER  McgCap;
-
-  if (!McaSupport (ProcessorNumber, CpuInfo, ConfigData)) {
-    return FALSE;
-  }
-  McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);
-  return (McgCap.Bits.MCG_CTL_P == 1);
-}
-
-/**
-  Initializes IA32_MCG_CTL feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the IA32_MCG_CTL feature must be enabled.
-                               If FALSE, then the IA32_MCG_CTL feature must be disabled.
-
-  @retval RETURN_SUCCESS       IA32_MCG_CTL feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-McgCtlInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  CPU_REGISTER_TABLE_WRITE64 (
-    ProcessorNumber,
-    Msr,
-    MSR_IA32_MCG_CTL,
-    (State)? MAX_UINT64 : 0
-    );
-  return RETURN_SUCCESS;
-}
-
+/** @file\r
+  Machine Check features.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Detects if Machine Check Exception feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Machine Check Exception feature is supported.\r
+  @retval FALSE    Machine Check Exception feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+MceSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCE == 1);\r
+}\r
+\r
+/**\r
+  Initializes Machine Check Exception feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Machine Check Exception feature must be enabled.\r
+                               If FALSE, then the Machine Check Exception feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Machine Check Exception feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+MceInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  //\r
+  // Set MCE bit in CR4\r
+  //\r
+  CPU_REGISTER_TABLE_WRITE_FIELD (\r
+    ProcessorNumber,\r
+    ControlRegister,\r
+    4,\r
+    IA32_CR4,\r
+    Bits.MCE,\r
+    (State) ? 1 : 0\r
+    );\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Detects if Machine Check Architecture feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Machine Check Architecture feature is supported.\r
+  @retval FALSE    Machine Check Architecture feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+McaSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCA == 1);\r
+}\r
+\r
+/**\r
+  Initializes Machine Check Architecture feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Machine Check Architecture feature must be enabled.\r
+                               If FALSE, then the Machine Check Architecture feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Machine Check Architecture feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+McaInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  MSR_IA32_MCG_CAP_REGISTER  McgCap;\r
+  UINT32                     BankIndex;\r
+\r
+  McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);\r
+  for (BankIndex = 0; BankIndex < (UINT32) McgCap.Bits.Count; BankIndex++) {\r
+    CPU_REGISTER_TABLE_WRITE64 (\r
+      ProcessorNumber,\r
+      Msr,\r
+      MSR_IA32_MC0_CTL + BankIndex * 4,\r
+      MAX_UINT64\r
+      );\r
+  }\r
+\r
+  if (PcdGetBool (PcdIsPowerOnReset)) {\r
+    for (BankIndex = 0; BankIndex < (UINTN) McgCap.Bits.Count; BankIndex++) {\r
+      CPU_REGISTER_TABLE_WRITE64 (\r
+        ProcessorNumber,\r
+        Msr,\r
+        MSR_IA32_MC0_STATUS + BankIndex * 4,\r
+        0\r
+        );\r
+    }\r
+  }\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Detects if IA32_MCG_CTL feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     IA32_MCG_CTL feature is supported.\r
+  @retval FALSE    IA32_MCG_CTL feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+McgCtlSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  MSR_IA32_MCG_CAP_REGISTER  McgCap;\r
+\r
+  if (!McaSupport (ProcessorNumber, CpuInfo, ConfigData)) {\r
+    return FALSE;\r
+  }\r
+  McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);\r
+  return (McgCap.Bits.MCG_CTL_P == 1);\r
+}\r
+\r
+/**\r
+  Initializes IA32_MCG_CTL feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the IA32_MCG_CTL feature must be enabled.\r
+                               If FALSE, then the IA32_MCG_CTL feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       IA32_MCG_CTL feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+McgCtlInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  CPU_REGISTER_TABLE_WRITE64 (\r
+    ProcessorNumber,\r
+    Msr,\r
+    MSR_IA32_MCG_CTL,\r
+    (State)? MAX_UINT64 : 0\r
+    );\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
index b1c18bc638846ff458dddbe1dee31ab4f625305c..1d43bd128afe8a31b6c157e73325facda02fac88 100644 (file)
@@ -1,79 +1,79 @@
-/** @file
-  MonitorMwait feature.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Detects if MONITOR/MWAIT feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     MONITOR/MWAIT feature is supported.
-  @retval FALSE    MONITOR/MWAIT feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-MonitorMwaitSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  return (CpuInfo->CpuIdVersionInfoEcx.Bits.MONITOR == 1);
-}
-
-/**
-  Initializes MONITOR/MWAIT feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the MONITOR/MWAIT feature must be enabled.
-                               If FALSE, then the MONITOR/MWAIT feature must be disabled.
-
-  @retval RETURN_SUCCESS       MONITOR/MWAIT feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-MonitorMwaitInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  CPU_REGISTER_TABLE_WRITE_FIELD (
-    ProcessorNumber,
-    Msr,
-    MSR_IA32_MISC_ENABLE,
-    MSR_IA32_MISC_ENABLE_REGISTER,
-    Bits.MONITOR,
-    (State) ? 1 : 0
-    );
-  return RETURN_SUCCESS;
-}
+/** @file\r
+  MonitorMwait feature.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Detects if MONITOR/MWAIT feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     MONITOR/MWAIT feature is supported.\r
+  @retval FALSE    MONITOR/MWAIT feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+MonitorMwaitSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  return (CpuInfo->CpuIdVersionInfoEcx.Bits.MONITOR == 1);\r
+}\r
+\r
+/**\r
+  Initializes MONITOR/MWAIT feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the MONITOR/MWAIT feature must be enabled.\r
+                               If FALSE, then the MONITOR/MWAIT feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       MONITOR/MWAIT feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+MonitorMwaitInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  CPU_REGISTER_TABLE_WRITE_FIELD (\r
+    ProcessorNumber,\r
+    Msr,\r
+    MSR_IA32_MISC_ENABLE,\r
+    MSR_IA32_MISC_ENABLE_REGISTER,\r
+    Bits.MONITOR,\r
+    (State) ? 1 : 0\r
+    );\r
+  return RETURN_SUCCESS;\r
+}\r
index 2a1fd95eae070f29141e18b161e85ce66a273e96..8cafba4f4a87991206605c96d23b821bd5aa43d7 100644 (file)
@@ -1,90 +1,90 @@
-/** @file
-  Pending Break feature.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Detects if Pending Break feature supported on current processor.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     Pending Break feature is supported.
-  @retval FALSE    Pending Break feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-PendingBreakSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  if (IS_ATOM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
-      IS_CORE2_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
-      IS_CORE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
-      IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
-      IS_PENTIUM_M_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
-    return (CpuInfo->CpuIdVersionInfoEdx.Bits.PBE == 1);
-  }
-  return FALSE;
-}
-
-/**
-  Initializes Pending Break feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the Pending Break feature must be enabled.
-                               If FALSE, then the Pending Break feature must be disabled.
-
-  @retval RETURN_SUCCESS       Pending Break feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-PendingBreakInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  //
-  // ATOM, CORE2, CORE, PENTIUM_4 and IS_PENTIUM_M_PROCESSOR have the same MSR index,
-  // Simply use MSR_ATOM_IA32_MISC_ENABLE here
-  //
-  CPU_REGISTER_TABLE_WRITE_FIELD (
-    ProcessorNumber,
-    Msr,
-    MSR_ATOM_IA32_MISC_ENABLE,
-    MSR_ATOM_IA32_MISC_ENABLE_REGISTER,
-    Bits.FERR,
-    (State) ? 1 : 0
-    );
-  return RETURN_SUCCESS;
-}
+/** @file\r
+  Pending Break feature.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Detects if Pending Break feature supported on current processor.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     Pending Break feature is supported.\r
+  @retval FALSE    Pending Break feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PendingBreakSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  if (IS_ATOM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+      IS_CORE2_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+      IS_CORE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+      IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+      IS_PENTIUM_M_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {\r
+    return (CpuInfo->CpuIdVersionInfoEdx.Bits.PBE == 1);\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Initializes Pending Break feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the Pending Break feature must be enabled.\r
+                               If FALSE, then the Pending Break feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       Pending Break feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PendingBreakInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  //\r
+  // ATOM, CORE2, CORE, PENTIUM_4 and IS_PENTIUM_M_PROCESSOR have the same MSR index,\r
+  // Simply use MSR_ATOM_IA32_MISC_ENABLE here\r
+  //\r
+  CPU_REGISTER_TABLE_WRITE_FIELD (\r
+    ProcessorNumber,\r
+    Msr,\r
+    MSR_ATOM_IA32_MISC_ENABLE,\r
+    MSR_ATOM_IA32_MISC_ENABLE_REGISTER,\r
+    Bits.FERR,\r
+    (State) ? 1 : 0\r
+    );\r
+  return RETURN_SUCCESS;\r
+}\r
index 7720540281dcc481382cfca90d9300e64e0d56a0..9c2ad9ad313e8a57260b1a10d3d0e9aa524b7275 100644 (file)
@@ -1,81 +1,81 @@
-/** @file
-  X2Apic feature.
-
-  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 "CpuCommonFeatures.h"
-
-/**
-  Detects if X2Apci feature supported on current processor.
-
-  Detect if X2Apci has been already enabled.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-
-  @retval TRUE     X2Apci feature is supported.
-  @retval FALSE    X2Apci feature is not supported.
-
-  @note This service could be called by BSP/APs.
-**/
-BOOLEAN
-EFIAPI
-X2ApicSupport (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData  OPTIONAL
-  )
-{
-  return (GetApicMode () == LOCAL_APIC_MODE_X2APIC);
-}
-
-/**
-  Initializes X2Apci feature to specific state.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION
-                               structure for the CPU executing this function.
-  @param[in]  ConfigData       A pointer to the configuration buffer returned
-                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if
-                               CPU_FEATURE_GET_CONFIG_DATA was not provided in
-                               RegisterCpuFeature().
-  @param[in]  State            If TRUE, then the X2Apci feature must be enabled.
-                               If FALSE, then the X2Apci feature must be disabled.
-
-  @retval RETURN_SUCCESS       X2Apci feature is initialized.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-X2ApicInitialize (
-  IN UINTN                             ProcessorNumber,
-  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,
-  IN VOID                              *ConfigData,  OPTIONAL
-  IN BOOLEAN                           State
-  )
-{
-  PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD (
-    ProcessorNumber,
-    Msr,
-    MSR_IA32_APIC_BASE,
-    MSR_IA32_APIC_BASE_REGISTER,
-    Bits.EXTD,
-    (State) ? 1 : 0
-    );
-  return RETURN_SUCCESS;
-}
+/** @file\r
+  X2Apic feature.\r
+\r
+  Copyright (c) 2017, 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 "CpuCommonFeatures.h"\r
+\r
+/**\r
+  Detects if X2Apci feature supported on current processor.\r
+\r
+  Detect if X2Apci has been already enabled.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+\r
+  @retval TRUE     X2Apci feature is supported.\r
+  @retval FALSE    X2Apci feature is not supported.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X2ApicSupport (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData  OPTIONAL\r
+  )\r
+{\r
+  return (GetApicMode () == LOCAL_APIC_MODE_X2APIC);\r
+}\r
+\r
+/**\r
+  Initializes X2Apci feature to specific state.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+  @param[in]  CpuInfo          A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r
+                               structure for the CPU executing this function.\r
+  @param[in]  ConfigData       A pointer to the configuration buffer returned\r
+                               by CPU_FEATURE_GET_CONFIG_DATA.  NULL if\r
+                               CPU_FEATURE_GET_CONFIG_DATA was not provided in\r
+                               RegisterCpuFeature().\r
+  @param[in]  State            If TRUE, then the X2Apci feature must be enabled.\r
+                               If FALSE, then the X2Apci feature must be disabled.\r
+\r
+  @retval RETURN_SUCCESS       X2Apci feature is initialized.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+X2ApicInitialize (\r
+  IN UINTN                             ProcessorNumber,\r
+  IN REGISTER_CPU_FEATURE_INFORMATION  *CpuInfo,\r
+  IN VOID                              *ConfigData,  OPTIONAL\r
+  IN BOOLEAN                           State\r
+  )\r
+{\r
+  PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD (\r
+    ProcessorNumber,\r
+    Msr,\r
+    MSR_IA32_APIC_BASE,\r
+    MSR_IA32_APIC_BASE_REGISTER,\r
+    Bits.EXTD,\r
+    (State) ? 1 : 0\r
+    );\r
+  return RETURN_SUCCESS;\r
+}\r
index e0fe38c9352138c8e2e37d3397b0cf57d0770f69..5e11b2b21cf3754dfa53bf9ac43c11a40f92316d 100644 (file)
-/** @file
-  CPU Features Initialize functions.
-
-  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 "RegisterCpuFeatures.h"
-
-/**
-  Worker function to save PcdCpuFeaturesCapability.
-
-  @param[in]  SupportedFeatureMask  The pointer to CPU feature bits mask buffer
-**/
-VOID
-SetCapabilityPcd (
-  IN UINT8               *SupportedFeatureMask
-  )
-{
-  EFI_STATUS             Status;
-  UINTN                  BitMaskSize;
-
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesCapability);
-  Status = PcdSetPtrS (PcdCpuFeaturesCapability, &BitMaskSize, SupportedFeatureMask);
-  ASSERT_EFI_ERROR (Status);
-}
-
-/**
-  Worker function to save PcdCpuFeaturesSetting.
-
-  @param[in]  SupportedFeatureMask  The pointer to CPU feature bits mask buffer
-**/
-VOID
-SetSettingPcd (
-  IN UINT8               *SupportedFeatureMask
-  )
-{
-  EFI_STATUS             Status;
-  UINTN                  BitMaskSize;
-
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSetting);
-  Status = PcdSetPtrS (PcdCpuFeaturesSetting, &BitMaskSize, SupportedFeatureMask);
-  ASSERT_EFI_ERROR (Status);
-}
-
-/**
-  Worker function to get PcdCpuFeaturesSupport.
-
-  @return  The pointer to CPU feature bits mask buffer.
-**/
-UINT8 *
-GetSupportPcds (
-  VOID
-  )
-{
-  UINTN                  BitMaskSize;
-  UINT8                  *SupportBitMask;
-
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
-  SupportBitMask = AllocateZeroPool (BitMaskSize);
-  ASSERT (SupportBitMask != NULL);
-  SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport);
-
-  return SupportBitMask;
-}
-
-/**
-  Worker function to get PcdCpuFeaturesUserConfiguration.
-
-  @return  The pointer to CPU feature bits mask buffer.
-**/
-UINT8 *
-GetConfigurationPcds (
-  VOID
-  )
-{
-  UINTN                  BitMaskSize;
-  UINT8                  *SupportBitMask;
-
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesUserConfiguration);
-  SupportBitMask = AllocateZeroPool (BitMaskSize);
-  ASSERT (SupportBitMask != NULL);
-  SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesUserConfiguration);
-
-  return SupportBitMask;
-}
-
-/**
-  Collects CPU type and feature information.
-
-  @param[in, out]  CpuInfo  The pointer to CPU feature information
-**/
-VOID
-FillProcessorInfo (
-  IN OUT REGISTER_CPU_FEATURE_INFORMATION        *CpuInfo
-  )
-{
-  CPUID_VERSION_INFO_EAX Eax;
-  CPUID_VERSION_INFO_ECX Ecx;
-  CPUID_VERSION_INFO_EDX Edx;
-  UINT32                 DisplayedFamily;
-  UINT32                 DisplayedModel;
-
-  AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, &Ecx.Uint32, &Edx.Uint32);
-
-  DisplayedFamily = Eax.Bits.FamilyId;
-  if (Eax.Bits.FamilyId == 0x0F) {
-    DisplayedFamily |= (Eax.Bits.ExtendedFamilyId << 4);
-  }
-
-  DisplayedModel = Eax.Bits.Model;
-  if (Eax.Bits.FamilyId == 0x06 || Eax.Bits.FamilyId == 0x0f) {
-    DisplayedModel |= (Eax.Bits.ExtendedModelId << 4);
-  }
-
-  CpuInfo->DisplayFamily = DisplayedFamily;
-  CpuInfo->DisplayModel  = DisplayedModel;
-  CpuInfo->SteppingId    = Eax.Bits.SteppingId;
-  CpuInfo->ProcessorType = Eax.Bits.ProcessorType;
-  CpuInfo->CpuIdVersionInfoEcx.Uint32 = Ecx.Uint32;
-  CpuInfo->CpuIdVersionInfoEdx.Uint32 = Edx.Uint32;
-}
-
-/**
-  Prepares for private data used for CPU features.
-
-  @param[in]  NumberOfCpus  Number of processor in system
-**/
-VOID
-CpuInitDataInitialize (
-  IN UINTN                             NumberOfCpus
-  )
-{
-  EFI_STATUS                           Status;
-  UINTN                                ProcessorNumber;
-  EFI_PROCESSOR_INFORMATION            ProcessorInfoBuffer;
-  CPU_FEATURES_ENTRY                   *CpuFeature;
-  CPU_FEATURES_INIT_ORDER              *InitOrder;
-  CPU_FEATURES_DATA                    *CpuFeaturesData;
-  LIST_ENTRY                           *Entry;
-
-  CpuFeaturesData = GetCpuFeaturesData ();
-  CpuFeaturesData->InitOrder = AllocateZeroPool (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus);
-  ASSERT (CpuFeaturesData->InitOrder != NULL);
-  CpuFeaturesData->BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
-
-  //
-  // Collect CPU Features information
-  //
-  Entry = GetFirstNode (&CpuFeaturesData->FeatureList);
-  while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {
-    CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);
-    ASSERT (CpuFeature->InitializeFunc != NULL);
-    if (CpuFeature->GetConfigDataFunc != NULL) {
-      CpuFeature->ConfigData = CpuFeature->GetConfigDataFunc (NumberOfCpus);
-    }
-    Entry = Entry->ForwardLink;
-  }
-
-  for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) {
-    InitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber];
-    InitOrder->FeaturesSupportedMask = AllocateZeroPool (CpuFeaturesData->BitMaskSize);
-    ASSERT (InitOrder->FeaturesSupportedMask != NULL);
-    InitializeListHead (&InitOrder->OrderList);
-    Status = GetProcessorInformation (ProcessorNumber, &ProcessorInfoBuffer);
-    ASSERT_EFI_ERROR (Status);
-    CopyMem (
-      &InitOrder->CpuInfo.ProcessorInfo,
-      &ProcessorInfoBuffer,
-      sizeof (EFI_PROCESSOR_INFORMATION)
-      );
-  }
-  //
-  // Get support and configuration PCDs
-  //
-  CpuFeaturesData->SupportPcds       = GetSupportPcds ();
-  CpuFeaturesData->ConfigurationPcds = GetConfigurationPcds ();
-}
-
-/**
-  Worker function to do OR operation on CPU feature supported bits mask buffer.
-
-  @param[in]  SupportedFeatureMask  The pointer to CPU feature bits mask buffer
-  @param[in]  OrFeatureBitMask      The feature bit mask to do OR operation
-**/
-VOID
-SupportedMaskOr (
-  IN UINT8               *SupportedFeatureMask,
-  IN UINT8               *OrFeatureBitMask
-  )
-{
-  UINTN                  Index;
-  UINTN                  BitMaskSize;
-  UINT8                  *Data1;
-  UINT8                  *Data2;
-
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
-  Data1 = SupportedFeatureMask;
-  Data2 = OrFeatureBitMask;
-  for (Index = 0; Index < BitMaskSize; Index++) {
-    *(Data1++) |=  *(Data2++);
-  }
-}
-
-/**
-  Worker function to do AND operation on CPU feature supported bits mask buffer.
-
-  @param[in]  SupportedFeatureMask  The pointer to CPU feature bits mask buffer
-  @param[in]  AndFeatureBitMask     The feature bit mask to do AND operation
-**/
-VOID
-SupportedMaskAnd (
-  IN UINT8               *SupportedFeatureMask,
-  IN UINT8               *AndFeatureBitMask
-  )
-{
-  UINTN                  Index;
-  UINTN                  BitMaskSize;
-  UINT8                  *Data1;
-  UINT8                  *Data2;
-
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
-  Data1 = SupportedFeatureMask;
-  Data2 = AndFeatureBitMask;
-  for (Index = 0; Index < BitMaskSize; Index++) {
-    *(Data1++) &=  *(Data2++);
-  }
-}
-
-/**
-  Worker function to check if the compared CPU feature set in the CPU feature
-  supported bits mask buffer.
-
-  @param[in]  SupportedFeatureMask   The pointer to CPU feature bits mask buffer
-  @param[in]  ComparedFeatureBitMask The feature bit mask to be compared
-
-  @retval TRUE   The ComparedFeatureBitMask is set in CPU feature supported bits
-                 mask buffer.
-  @retval FALSE  The ComparedFeatureBitMask is not set in CPU feature supported bits
-                 mask buffer.
-**/
-BOOLEAN
-IsBitMaskMatch (
-  IN UINT8               *SupportedFeatureMask,
-  IN UINT8               *ComparedFeatureBitMask
-  )
-{
-  UINTN                  Index;
-  UINTN                  BitMaskSize;
-  UINT8                  *Data1;
-  UINT8                  *Data2;
-
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
-
-  Data1 = SupportedFeatureMask;
-  Data2 = ComparedFeatureBitMask;
-  for (Index = 0; Index < BitMaskSize; Index++) {
-    if (((*(Data1++)) & (*(Data2++))) != 0) {
-      return TRUE;
-    }
-  }
-  return FALSE;
-}
-
-/**
-  Collects processor data for calling processor.
-
-  @param[in,out]  Buffer  The pointer to private data buffer.
-**/
-VOID
-EFIAPI
-CollectProcessorData (
-  IN OUT VOID                          *Buffer
-  )
-{
-  UINTN                                ProcessorNumber;
-  CPU_FEATURES_ENTRY                   *CpuFeature;
-  REGISTER_CPU_FEATURE_INFORMATION     *CpuInfo;
-  LIST_ENTRY                           *Entry;
-  CPU_FEATURES_DATA                    *CpuFeaturesData;
-
-  CpuFeaturesData = GetCpuFeaturesData ();
-  ProcessorNumber = GetProcessorIndex ();
-  CpuInfo = &CpuFeaturesData->InitOrder[ProcessorNumber].CpuInfo;
-  //
-  // collect processor information
-  //
-  FillProcessorInfo (CpuInfo);
-  Entry = GetFirstNode (&CpuFeaturesData->FeatureList);
-  while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {
-    CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);
-    if (IsBitMaskMatch (CpuFeaturesData->SupportPcds, CpuFeature->FeatureMask)) {
-      if (CpuFeature->SupportFunc == NULL) {
-        //
-        // If SupportFunc is NULL, then the feature is supported.
-        //
-        SupportedMaskOr (
-          CpuFeaturesData->InitOrder[ProcessorNumber].FeaturesSupportedMask,
-          CpuFeature->FeatureMask
-          );
-      } else if (CpuFeature->SupportFunc (ProcessorNumber, CpuInfo, CpuFeature->ConfigData)) {
-        SupportedMaskOr (
-          CpuFeaturesData->InitOrder[ProcessorNumber].FeaturesSupportedMask,
-          CpuFeature->FeatureMask
-          );
-      }
-    }
-    Entry = Entry->ForwardLink;
-  }
-}
-
-/**
-  Dump the contents of a CPU register table.
-
-  @param[in]  ProcessorNumber  The index of the CPU to show the register table contents
-
-  @note This service could be called by BSP only.
-**/
-VOID
-DumpRegisterTableOnProcessor (
-  IN UINTN                             ProcessorNumber
-  )
-{
-  CPU_FEATURES_DATA                    *CpuFeaturesData;
-  UINTN                                FeatureIndex;
-  CPU_REGISTER_TABLE                   *RegisterTable;
-  CPU_REGISTER_TABLE_ENTRY             *RegisterTableEntry;
-  CPU_REGISTER_TABLE_ENTRY             *RegisterTableEntryHead;
-  UINT32                               DebugPrintErrorLevel;
-
-  DebugPrintErrorLevel = (ProcessorNumber == 0) ? DEBUG_INFO : DEBUG_VERBOSE;
-  CpuFeaturesData      = GetCpuFeaturesData ();
-  //
-  // Debug information
-  //
-  RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber];
-  DEBUG ((DebugPrintErrorLevel, "RegisterTable->TableLength = %d\n", RegisterTable->TableLength));
-
-  RegisterTableEntryHead = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry;
-
-  for (FeatureIndex = 0; FeatureIndex < RegisterTable->TableLength; FeatureIndex++) {
-    RegisterTableEntry = &RegisterTableEntryHead[FeatureIndex];
-    switch (RegisterTableEntry->RegisterType) {
-    case Msr:
-      DEBUG ((
-        DebugPrintErrorLevel,
-        "Processor: %d:   MSR: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n",
-        ProcessorNumber,
-        RegisterTableEntry->Index,
-        RegisterTableEntry->ValidBitStart,
-        RegisterTableEntry->ValidBitLength,
-        RegisterTableEntry->Value
-        ));
-      break;
-    case ControlRegister:
-      DEBUG ((
-        DebugPrintErrorLevel,
-        "Processor: %d:    CR: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n",
-        ProcessorNumber,
-        RegisterTableEntry->Index,
-        RegisterTableEntry->ValidBitStart,
-        RegisterTableEntry->ValidBitLength,
-        RegisterTableEntry->Value
-        ));
-      break;
-    case MemoryMapped:
-      DEBUG ((
-        DebugPrintErrorLevel,
-        "Processor: %d:  MMIO: %lx, Bit Start: %d, Bit Length: %d, Value: %lx\r\n",
-        ProcessorNumber,
-        RegisterTableEntry->Index | LShiftU64 (RegisterTableEntry->HighIndex, 32),
-        RegisterTableEntry->ValidBitStart,
-        RegisterTableEntry->ValidBitLength,
-        RegisterTableEntry->Value
-        ));
-      break;
-    case CacheControl:
-      DEBUG ((
-        DebugPrintErrorLevel,
-        "Processor: %d: CACHE: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n",
-        ProcessorNumber,
-        RegisterTableEntry->Index,
-        RegisterTableEntry->ValidBitStart,
-        RegisterTableEntry->ValidBitLength,
-        RegisterTableEntry->Value
-        ));
-      break;
-    default:
-      break;
-    }
-  }
-}
-
-/**
-  Analysis register CPU features on each processor and save CPU setting in CPU register table.
-
-  @param[in]  NumberOfCpus  Number of processor in system
-
-**/
-VOID
-AnalysisProcessorFeatures (
-  IN UINTN                             NumberOfCpus
-  )
-{
-  EFI_STATUS                           Status;
-  UINTN                                ProcessorNumber;
-  CPU_FEATURES_ENTRY                   *CpuFeature;
-  CPU_FEATURES_ENTRY                   *CpuFeatureInOrder;
-  CPU_FEATURES_INIT_ORDER              *CpuInitOrder;
-  REGISTER_CPU_FEATURE_INFORMATION     *CpuInfo;
-  LIST_ENTRY                           *Entry;
-  CPU_FEATURES_DATA                    *CpuFeaturesData;
-
-  CpuFeaturesData = GetCpuFeaturesData ();
-  CpuFeaturesData->CapabilityPcds = AllocatePool (CpuFeaturesData->BitMaskSize);
-  ASSERT (CpuFeaturesData->CapabilityPcds != NULL);
-  SetMem (CpuFeaturesData->CapabilityPcds, CpuFeaturesData->BitMaskSize, 0xFF);
-  for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) {
-    CpuInitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber];
-    //
-    // Calculate the last capability on all processors
-    //
-    SupportedMaskAnd (CpuFeaturesData->CapabilityPcds, CpuInitOrder->FeaturesSupportedMask);
-  }
-  //
-  // Calculate the last setting
-  //
-
-  CpuFeaturesData->SettingPcds = AllocateCopyPool (CpuFeaturesData->BitMaskSize, CpuFeaturesData->CapabilityPcds);
-  ASSERT (CpuFeaturesData->SettingPcds != NULL);
-  SupportedMaskAnd (CpuFeaturesData->SettingPcds, CpuFeaturesData->ConfigurationPcds);
-
-  //
-  // Save PCDs and display CPU PCDs
-  //
-  SetCapabilityPcd (CpuFeaturesData->CapabilityPcds);
-  SetSettingPcd (CpuFeaturesData->SettingPcds);
-
-  //
-  // Dump the last CPU feature list
-  //
-  DEBUG_CODE (
-    DEBUG ((DEBUG_INFO, "Last CPU features list...\n"));
-    Entry = GetFirstNode (&CpuFeaturesData->FeatureList);
-    while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {
-      CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);
-      if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcds)) {
-        if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->SettingPcds)) {
-          DEBUG ((DEBUG_INFO, "[Enable   ] "));
-        } else {
-          DEBUG ((DEBUG_INFO, "[Disable  ] "));
-        }
-      } else {
-        DEBUG ((DEBUG_INFO, "[Unsupport] "));
-      }
-      DumpCpuFeature (CpuFeature);
-      Entry = Entry->ForwardLink;
-    }
-    DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSupport:\n"));
-    DumpCpuFeatureMask (CpuFeaturesData->SupportPcds);
-    DEBUG ((DEBUG_INFO, "PcdCpuFeaturesUserConfiguration:\n"));
-    DumpCpuFeatureMask (CpuFeaturesData->ConfigurationPcds);
-    DEBUG ((DEBUG_INFO, "PcdCpuFeaturesCapability:\n"));
-    DumpCpuFeatureMask (CpuFeaturesData->CapabilityPcds);
-    DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSetting:\n"));
-    DumpCpuFeatureMask (CpuFeaturesData->SettingPcds);
-  );
-
-  for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) {
-    CpuInitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber];
-    Entry = GetFirstNode (&CpuFeaturesData->FeatureList);
-    while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {
-      //
-      // Insert each feature into processor's order list
-      //
-      CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);
-      if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcds)) {
-        CpuFeatureInOrder = AllocateCopyPool (sizeof (CPU_FEATURES_ENTRY), CpuFeature);
-        ASSERT (CpuFeatureInOrder != NULL);
-        InsertTailList (&CpuInitOrder->OrderList, &CpuFeatureInOrder->Link);
-      }
-      Entry = Entry->ForwardLink;
-    }
-    //
-    // Go through ordered feature list to initialize CPU features
-    //
-    CpuInfo = &CpuFeaturesData->InitOrder[ProcessorNumber].CpuInfo;
-    Entry = GetFirstNode (&CpuInitOrder->OrderList);
-    while (!IsNull (&CpuInitOrder->OrderList, Entry)) {
-      CpuFeatureInOrder = CPU_FEATURE_ENTRY_FROM_LINK (Entry);
-      if (IsBitMaskMatch (CpuFeatureInOrder->FeatureMask, CpuFeaturesData->SettingPcds)) {
-        Status = CpuFeatureInOrder->InitializeFunc (ProcessorNumber, CpuInfo, CpuFeatureInOrder->ConfigData, TRUE);
-      } else {
-        Status = CpuFeatureInOrder->InitializeFunc (ProcessorNumber, CpuInfo, CpuFeatureInOrder->ConfigData, FALSE);
-      }
-      ASSERT_EFI_ERROR (Status);
-      Entry = Entry->ForwardLink;
-    }
-    //
-    // Dump the RegisterTable
-    //
-    DumpRegisterTableOnProcessor (ProcessorNumber);
-  }
-}
-
-/**
-  Initialize the CPU registers from a register table.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-
-  @note This service could be called by BSP/APs.
-**/
-VOID
-ProgramProcessorRegister (
-  IN UINTN  ProcessorNumber
-  )
-{
-  CPU_FEATURES_DATA         *CpuFeaturesData;
-  CPU_REGISTER_TABLE        *RegisterTable;
-  CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntry;
-  UINTN                     Index;
-  UINTN                     Value;
-  CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntryHead;
-
-  CpuFeaturesData = GetCpuFeaturesData ();
-  RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber];
-
-  //
-  // Traverse Register Table of this logical processor
-  //
-  RegisterTableEntryHead = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry;
-
-  for (Index = 0; Index < RegisterTable->TableLength; Index++) {
-
-    RegisterTableEntry = &RegisterTableEntryHead[Index];
-
-    //
-    // Check the type of specified register
-    //
-    switch (RegisterTableEntry->RegisterType) {
-    //
-    // The specified register is Control Register
-    //
-    case ControlRegister:
-      switch (RegisterTableEntry->Index) {
-      case 0:
-        Value = AsmReadCr0 ();
-        Value = (UINTN) BitFieldWrite64 (
-                          Value,
-                          RegisterTableEntry->ValidBitStart,
-                          RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,
-                          RegisterTableEntry->Value
-                          );
-        AsmWriteCr0 (Value);
-        break;
-      case 2:
-        Value = AsmReadCr2 ();
-        Value = (UINTN) BitFieldWrite64 (
-                          Value,
-                          RegisterTableEntry->ValidBitStart,
-                          RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,
-                          RegisterTableEntry->Value
-                          );
-        AsmWriteCr2 (Value);
-        break;
-      case 3:
-        Value = AsmReadCr3 ();
-        Value = (UINTN) BitFieldWrite64 (
-                          Value,
-                          RegisterTableEntry->ValidBitStart,
-                          RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,
-                          RegisterTableEntry->Value
-                          );
-        AsmWriteCr3 (Value);
-        break;
-      case 4:
-        Value = AsmReadCr4 ();
-        Value = (UINTN) BitFieldWrite64 (
-                          Value,
-                          RegisterTableEntry->ValidBitStart,
-                          RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,
-                          RegisterTableEntry->Value
-                          );
-        AsmWriteCr4 (Value);
-        break;
-      case 8:
-        //
-        //  Do we need to support CR8?
-        //
-        break;
-      default:
-        break;
-      }
-      break;
-    //
-    // The specified register is Model Specific Register
-    //
-    case Msr:
-      //
-      // Get lock to avoid Package/Core scope MSRs programming issue in parallel execution mode
-      //
-      AcquireSpinLock (&CpuFeaturesData->MsrLock);
-      if (RegisterTableEntry->ValidBitLength >= 64) {
-        //
-        // If length is not less than 64 bits, then directly write without reading
-        //
-        AsmWriteMsr64 (
-          RegisterTableEntry->Index,
-          RegisterTableEntry->Value
-          );
-      } else {
-        //
-        // Set the bit section according to bit start and length
-        //
-        AsmMsrBitFieldWrite64 (
-          RegisterTableEntry->Index,
-          RegisterTableEntry->ValidBitStart,
-          RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,
-          RegisterTableEntry->Value
-          );
-      }
-      ReleaseSpinLock (&CpuFeaturesData->MsrLock);
-      break;
-    //
-    // MemoryMapped operations
-    //
-    case MemoryMapped:
-      AcquireSpinLock (&CpuFeaturesData->MemoryMappedLock);
-      MmioBitFieldWrite32 (
-        (UINTN)(RegisterTableEntry->Index | LShiftU64 (RegisterTableEntry->HighIndex, 32)),
-        RegisterTableEntry->ValidBitStart,
-        RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,
-        (UINT32)RegisterTableEntry->Value
-        );
-      ReleaseSpinLock (&CpuFeaturesData->MemoryMappedLock);
-      break;
-    //
-    // Enable or disable cache
-    //
-    case CacheControl:
-      //
-      // If value of the entry is 0, then disable cache.  Otherwise, enable cache.
-      //
-      if (RegisterTableEntry->Value == 0) {
-        AsmDisableCache ();
-      } else {
-        AsmEnableCache ();
-      }
-      break;
-
-    default:
-      break;
-    }
-  }
-}
-
-/**
-  Programs registers for the calling processor.
-
-  @param[in,out] Buffer  The pointer to private data buffer.
-
-**/
-VOID
-EFIAPI
-SetProcessorRegister (
-  IN OUT VOID            *Buffer
-  )
-{
-  UINTN                  ProcessorNumber;
-
-  ProcessorNumber = GetProcessorIndex ();
-  ProgramProcessorRegister (ProcessorNumber);
-}
-
-/**
-  Performs CPU features detection.
-
-  This service will invoke MP service to check CPU features'
-  capabilities on BSP/APs.
-
-  @note This service could be called by BSP only.
-**/
-VOID
-EFIAPI
-CpuFeaturesDetect (
-  VOID
-  )
-{
-  UINTN                  NumberOfCpus;
-  UINTN                  NumberOfEnabledProcessors;
-
-  GetNumberOfProcessor (&NumberOfCpus, &NumberOfEnabledProcessors);
-
-  CpuInitDataInitialize (NumberOfCpus);
-
-  //
-  // Wakeup all APs for data collection.
-  //
-  StartupAPsWorker (CollectProcessorData);
-
-  //
-  // Collect data on BSP
-  //
-  CollectProcessorData (NULL);
-
-  AnalysisProcessorFeatures (NumberOfCpus);
-}
-
-/**
-  Performs CPU features Initialization.
-
-  This service will invoke MP service to perform CPU features
-  initialization on BSP/APs per user configuration.
-
-  @note This service could be called by BSP only.
-**/
-VOID
-EFIAPI
-CpuFeaturesInitialize (
-  VOID
-  )
-{
-  CPU_FEATURES_DATA      *CpuFeaturesData;
-  UINTN                  OldBspNumber;
-
-  CpuFeaturesData = GetCpuFeaturesData ();
-
-  OldBspNumber = GetProcessorIndex();
-  CpuFeaturesData->BspNumber = OldBspNumber;
-  //
-  // Wakeup all APs for programming.
-  //
-  StartupAPsWorker (SetProcessorRegister);
-  //
-  // Programming BSP
-  //
-  SetProcessorRegister (NULL);
-  //
-  // Switch to new BSP if required
-  //
-  if (CpuFeaturesData->BspNumber != OldBspNumber) {
-    SwitchNewBsp (CpuFeaturesData->BspNumber);
-  }
-}
+/** @file\r
+  CPU Features Initialize functions.\r
+\r
+  Copyright (c) 2017, 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 "RegisterCpuFeatures.h"\r
+\r
+/**\r
+  Worker function to save PcdCpuFeaturesCapability.\r
+\r
+  @param[in]  SupportedFeatureMask  The pointer to CPU feature bits mask buffer\r
+**/\r
+VOID\r
+SetCapabilityPcd (\r
+  IN UINT8               *SupportedFeatureMask\r
+  )\r
+{\r
+  EFI_STATUS             Status;\r
+  UINTN                  BitMaskSize;\r
+\r
+  BitMaskSize = PcdGetSize (PcdCpuFeaturesCapability);\r
+  Status = PcdSetPtrS (PcdCpuFeaturesCapability, &BitMaskSize, SupportedFeatureMask);\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Worker function to save PcdCpuFeaturesSetting.\r
+\r
+  @param[in]  SupportedFeatureMask  The pointer to CPU feature bits mask buffer\r
+**/\r
+VOID\r
+SetSettingPcd (\r
+  IN UINT8               *SupportedFeatureMask\r
+  )\r
+{\r
+  EFI_STATUS             Status;\r
+  UINTN                  BitMaskSize;\r
+\r
+  BitMaskSize = PcdGetSize (PcdCpuFeaturesSetting);\r
+  Status = PcdSetPtrS (PcdCpuFeaturesSetting, &BitMaskSize, SupportedFeatureMask);\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Worker function to get PcdCpuFeaturesSupport.\r
+\r
+  @return  The pointer to CPU feature bits mask buffer.\r
+**/\r
+UINT8 *\r
+GetSupportPcds (\r
+  VOID\r
+  )\r
+{\r
+  UINTN                  BitMaskSize;\r
+  UINT8                  *SupportBitMask;\r
+\r
+  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
+  SupportBitMask = AllocateZeroPool (BitMaskSize);\r
+  ASSERT (SupportBitMask != NULL);\r
+  SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport);\r
+\r
+  return SupportBitMask;\r
+}\r
+\r
+/**\r
+  Worker function to get PcdCpuFeaturesUserConfiguration.\r
+\r
+  @return  The pointer to CPU feature bits mask buffer.\r
+**/\r
+UINT8 *\r
+GetConfigurationPcds (\r
+  VOID\r
+  )\r
+{\r
+  UINTN                  BitMaskSize;\r
+  UINT8                  *SupportBitMask;\r
+\r
+  BitMaskSize = PcdGetSize (PcdCpuFeaturesUserConfiguration);\r
+  SupportBitMask = AllocateZeroPool (BitMaskSize);\r
+  ASSERT (SupportBitMask != NULL);\r
+  SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesUserConfiguration);\r
+\r
+  return SupportBitMask;\r
+}\r
+\r
+/**\r
+  Collects CPU type and feature information.\r
+\r
+  @param[in, out]  CpuInfo  The pointer to CPU feature information\r
+**/\r
+VOID\r
+FillProcessorInfo (\r
+  IN OUT REGISTER_CPU_FEATURE_INFORMATION        *CpuInfo\r
+  )\r
+{\r
+  CPUID_VERSION_INFO_EAX Eax;\r
+  CPUID_VERSION_INFO_ECX Ecx;\r
+  CPUID_VERSION_INFO_EDX Edx;\r
+  UINT32                 DisplayedFamily;\r
+  UINT32                 DisplayedModel;\r
+\r
+  AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, &Ecx.Uint32, &Edx.Uint32);\r
+\r
+  DisplayedFamily = Eax.Bits.FamilyId;\r
+  if (Eax.Bits.FamilyId == 0x0F) {\r
+    DisplayedFamily |= (Eax.Bits.ExtendedFamilyId << 4);\r
+  }\r
+\r
+  DisplayedModel = Eax.Bits.Model;\r
+  if (Eax.Bits.FamilyId == 0x06 || Eax.Bits.FamilyId == 0x0f) {\r
+    DisplayedModel |= (Eax.Bits.ExtendedModelId << 4);\r
+  }\r
+\r
+  CpuInfo->DisplayFamily = DisplayedFamily;\r
+  CpuInfo->DisplayModel  = DisplayedModel;\r
+  CpuInfo->SteppingId    = Eax.Bits.SteppingId;\r
+  CpuInfo->ProcessorType = Eax.Bits.ProcessorType;\r
+  CpuInfo->CpuIdVersionInfoEcx.Uint32 = Ecx.Uint32;\r
+  CpuInfo->CpuIdVersionInfoEdx.Uint32 = Edx.Uint32;\r
+}\r
+\r
+/**\r
+  Prepares for private data used for CPU features.\r
+\r
+  @param[in]  NumberOfCpus  Number of processor in system\r
+**/\r
+VOID\r
+CpuInitDataInitialize (\r
+  IN UINTN                             NumberOfCpus\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  UINTN                                ProcessorNumber;\r
+  EFI_PROCESSOR_INFORMATION            ProcessorInfoBuffer;\r
+  CPU_FEATURES_ENTRY                   *CpuFeature;\r
+  CPU_FEATURES_INIT_ORDER              *InitOrder;\r
+  CPU_FEATURES_DATA                    *CpuFeaturesData;\r
+  LIST_ENTRY                           *Entry;\r
+\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+  CpuFeaturesData->InitOrder = AllocateZeroPool (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus);\r
+  ASSERT (CpuFeaturesData->InitOrder != NULL);\r
+  CpuFeaturesData->BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
+\r
+  //\r
+  // Collect CPU Features information\r
+  //\r
+  Entry = GetFirstNode (&CpuFeaturesData->FeatureList);\r
+  while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {\r
+    CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);\r
+    ASSERT (CpuFeature->InitializeFunc != NULL);\r
+    if (CpuFeature->GetConfigDataFunc != NULL) {\r
+      CpuFeature->ConfigData = CpuFeature->GetConfigDataFunc (NumberOfCpus);\r
+    }\r
+    Entry = Entry->ForwardLink;\r
+  }\r
+\r
+  for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) {\r
+    InitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber];\r
+    InitOrder->FeaturesSupportedMask = AllocateZeroPool (CpuFeaturesData->BitMaskSize);\r
+    ASSERT (InitOrder->FeaturesSupportedMask != NULL);\r
+    InitializeListHead (&InitOrder->OrderList);\r
+    Status = GetProcessorInformation (ProcessorNumber, &ProcessorInfoBuffer);\r
+    ASSERT_EFI_ERROR (Status);\r
+    CopyMem (\r
+      &InitOrder->CpuInfo.ProcessorInfo,\r
+      &ProcessorInfoBuffer,\r
+      sizeof (EFI_PROCESSOR_INFORMATION)\r
+      );\r
+  }\r
+  //\r
+  // Get support and configuration PCDs\r
+  //\r
+  CpuFeaturesData->SupportPcds       = GetSupportPcds ();\r
+  CpuFeaturesData->ConfigurationPcds = GetConfigurationPcds ();\r
+}\r
+\r
+/**\r
+  Worker function to do OR operation on CPU feature supported bits mask buffer.\r
+\r
+  @param[in]  SupportedFeatureMask  The pointer to CPU feature bits mask buffer\r
+  @param[in]  OrFeatureBitMask      The feature bit mask to do OR operation\r
+**/\r
+VOID\r
+SupportedMaskOr (\r
+  IN UINT8               *SupportedFeatureMask,\r
+  IN UINT8               *OrFeatureBitMask\r
+  )\r
+{\r
+  UINTN                  Index;\r
+  UINTN                  BitMaskSize;\r
+  UINT8                  *Data1;\r
+  UINT8                  *Data2;\r
+\r
+  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
+  Data1 = SupportedFeatureMask;\r
+  Data2 = OrFeatureBitMask;\r
+  for (Index = 0; Index < BitMaskSize; Index++) {\r
+    *(Data1++) |=  *(Data2++);\r
+  }\r
+}\r
+\r
+/**\r
+  Worker function to do AND operation on CPU feature supported bits mask buffer.\r
+\r
+  @param[in]  SupportedFeatureMask  The pointer to CPU feature bits mask buffer\r
+  @param[in]  AndFeatureBitMask     The feature bit mask to do AND operation\r
+**/\r
+VOID\r
+SupportedMaskAnd (\r
+  IN UINT8               *SupportedFeatureMask,\r
+  IN UINT8               *AndFeatureBitMask\r
+  )\r
+{\r
+  UINTN                  Index;\r
+  UINTN                  BitMaskSize;\r
+  UINT8                  *Data1;\r
+  UINT8                  *Data2;\r
+\r
+  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
+  Data1 = SupportedFeatureMask;\r
+  Data2 = AndFeatureBitMask;\r
+  for (Index = 0; Index < BitMaskSize; Index++) {\r
+    *(Data1++) &=  *(Data2++);\r
+  }\r
+}\r
+\r
+/**\r
+  Worker function to check if the compared CPU feature set in the CPU feature\r
+  supported bits mask buffer.\r
+\r
+  @param[in]  SupportedFeatureMask   The pointer to CPU feature bits mask buffer\r
+  @param[in]  ComparedFeatureBitMask The feature bit mask to be compared\r
+\r
+  @retval TRUE   The ComparedFeatureBitMask is set in CPU feature supported bits\r
+                 mask buffer.\r
+  @retval FALSE  The ComparedFeatureBitMask is not set in CPU feature supported bits\r
+                 mask buffer.\r
+**/\r
+BOOLEAN\r
+IsBitMaskMatch (\r
+  IN UINT8               *SupportedFeatureMask,\r
+  IN UINT8               *ComparedFeatureBitMask\r
+  )\r
+{\r
+  UINTN                  Index;\r
+  UINTN                  BitMaskSize;\r
+  UINT8                  *Data1;\r
+  UINT8                  *Data2;\r
+\r
+  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
+\r
+  Data1 = SupportedFeatureMask;\r
+  Data2 = ComparedFeatureBitMask;\r
+  for (Index = 0; Index < BitMaskSize; Index++) {\r
+    if (((*(Data1++)) & (*(Data2++))) != 0) {\r
+      return TRUE;\r
+    }\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Collects processor data for calling processor.\r
+\r
+  @param[in,out]  Buffer  The pointer to private data buffer.\r
+**/\r
+VOID\r
+EFIAPI\r
+CollectProcessorData (\r
+  IN OUT VOID                          *Buffer\r
+  )\r
+{\r
+  UINTN                                ProcessorNumber;\r
+  CPU_FEATURES_ENTRY                   *CpuFeature;\r
+  REGISTER_CPU_FEATURE_INFORMATION     *CpuInfo;\r
+  LIST_ENTRY                           *Entry;\r
+  CPU_FEATURES_DATA                    *CpuFeaturesData;\r
+\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+  ProcessorNumber = GetProcessorIndex ();\r
+  CpuInfo = &CpuFeaturesData->InitOrder[ProcessorNumber].CpuInfo;\r
+  //\r
+  // collect processor information\r
+  //\r
+  FillProcessorInfo (CpuInfo);\r
+  Entry = GetFirstNode (&CpuFeaturesData->FeatureList);\r
+  while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {\r
+    CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);\r
+    if (IsBitMaskMatch (CpuFeaturesData->SupportPcds, CpuFeature->FeatureMask)) {\r
+      if (CpuFeature->SupportFunc == NULL) {\r
+        //\r
+        // If SupportFunc is NULL, then the feature is supported.\r
+        //\r
+        SupportedMaskOr (\r
+          CpuFeaturesData->InitOrder[ProcessorNumber].FeaturesSupportedMask,\r
+          CpuFeature->FeatureMask\r
+          );\r
+      } else if (CpuFeature->SupportFunc (ProcessorNumber, CpuInfo, CpuFeature->ConfigData)) {\r
+        SupportedMaskOr (\r
+          CpuFeaturesData->InitOrder[ProcessorNumber].FeaturesSupportedMask,\r
+          CpuFeature->FeatureMask\r
+          );\r
+      }\r
+    }\r
+    Entry = Entry->ForwardLink;\r
+  }\r
+}\r
+\r
+/**\r
+  Dump the contents of a CPU register table.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU to show the register table contents\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID\r
+DumpRegisterTableOnProcessor (\r
+  IN UINTN                             ProcessorNumber\r
+  )\r
+{\r
+  CPU_FEATURES_DATA                    *CpuFeaturesData;\r
+  UINTN                                FeatureIndex;\r
+  CPU_REGISTER_TABLE                   *RegisterTable;\r
+  CPU_REGISTER_TABLE_ENTRY             *RegisterTableEntry;\r
+  CPU_REGISTER_TABLE_ENTRY             *RegisterTableEntryHead;\r
+  UINT32                               DebugPrintErrorLevel;\r
+\r
+  DebugPrintErrorLevel = (ProcessorNumber == 0) ? DEBUG_INFO : DEBUG_VERBOSE;\r
+  CpuFeaturesData      = GetCpuFeaturesData ();\r
+  //\r
+  // Debug information\r
+  //\r
+  RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber];\r
+  DEBUG ((DebugPrintErrorLevel, "RegisterTable->TableLength = %d\n", RegisterTable->TableLength));\r
+\r
+  RegisterTableEntryHead = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry;\r
+\r
+  for (FeatureIndex = 0; FeatureIndex < RegisterTable->TableLength; FeatureIndex++) {\r
+    RegisterTableEntry = &RegisterTableEntryHead[FeatureIndex];\r
+    switch (RegisterTableEntry->RegisterType) {\r
+    case Msr:\r
+      DEBUG ((\r
+        DebugPrintErrorLevel,\r
+        "Processor: %d:   MSR: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n",\r
+        ProcessorNumber,\r
+        RegisterTableEntry->Index,\r
+        RegisterTableEntry->ValidBitStart,\r
+        RegisterTableEntry->ValidBitLength,\r
+        RegisterTableEntry->Value\r
+        ));\r
+      break;\r
+    case ControlRegister:\r
+      DEBUG ((\r
+        DebugPrintErrorLevel,\r
+        "Processor: %d:    CR: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n",\r
+        ProcessorNumber,\r
+        RegisterTableEntry->Index,\r
+        RegisterTableEntry->ValidBitStart,\r
+        RegisterTableEntry->ValidBitLength,\r
+        RegisterTableEntry->Value\r
+        ));\r
+      break;\r
+    case MemoryMapped:\r
+      DEBUG ((\r
+        DebugPrintErrorLevel,\r
+        "Processor: %d:  MMIO: %lx, Bit Start: %d, Bit Length: %d, Value: %lx\r\n",\r
+        ProcessorNumber,\r
+        RegisterTableEntry->Index | LShiftU64 (RegisterTableEntry->HighIndex, 32),\r
+        RegisterTableEntry->ValidBitStart,\r
+        RegisterTableEntry->ValidBitLength,\r
+        RegisterTableEntry->Value\r
+        ));\r
+      break;\r
+    case CacheControl:\r
+      DEBUG ((\r
+        DebugPrintErrorLevel,\r
+        "Processor: %d: CACHE: %x, Bit Start: %d, Bit Length: %d, Value: %lx\r\n",\r
+        ProcessorNumber,\r
+        RegisterTableEntry->Index,\r
+        RegisterTableEntry->ValidBitStart,\r
+        RegisterTableEntry->ValidBitLength,\r
+        RegisterTableEntry->Value\r
+        ));\r
+      break;\r
+    default:\r
+      break;\r
+    }\r
+  }\r
+}\r
+\r
+/**\r
+  Analysis register CPU features on each processor and save CPU setting in CPU register table.\r
+\r
+  @param[in]  NumberOfCpus  Number of processor in system\r
+\r
+**/\r
+VOID\r
+AnalysisProcessorFeatures (\r
+  IN UINTN                             NumberOfCpus\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  UINTN                                ProcessorNumber;\r
+  CPU_FEATURES_ENTRY                   *CpuFeature;\r
+  CPU_FEATURES_ENTRY                   *CpuFeatureInOrder;\r
+  CPU_FEATURES_INIT_ORDER              *CpuInitOrder;\r
+  REGISTER_CPU_FEATURE_INFORMATION     *CpuInfo;\r
+  LIST_ENTRY                           *Entry;\r
+  CPU_FEATURES_DATA                    *CpuFeaturesData;\r
+\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+  CpuFeaturesData->CapabilityPcds = AllocatePool (CpuFeaturesData->BitMaskSize);\r
+  ASSERT (CpuFeaturesData->CapabilityPcds != NULL);\r
+  SetMem (CpuFeaturesData->CapabilityPcds, CpuFeaturesData->BitMaskSize, 0xFF);\r
+  for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) {\r
+    CpuInitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber];\r
+    //\r
+    // Calculate the last capability on all processors\r
+    //\r
+    SupportedMaskAnd (CpuFeaturesData->CapabilityPcds, CpuInitOrder->FeaturesSupportedMask);\r
+  }\r
+  //\r
+  // Calculate the last setting\r
+  //\r
+\r
+  CpuFeaturesData->SettingPcds = AllocateCopyPool (CpuFeaturesData->BitMaskSize, CpuFeaturesData->CapabilityPcds);\r
+  ASSERT (CpuFeaturesData->SettingPcds != NULL);\r
+  SupportedMaskAnd (CpuFeaturesData->SettingPcds, CpuFeaturesData->ConfigurationPcds);\r
+\r
+  //\r
+  // Save PCDs and display CPU PCDs\r
+  //\r
+  SetCapabilityPcd (CpuFeaturesData->CapabilityPcds);\r
+  SetSettingPcd (CpuFeaturesData->SettingPcds);\r
+\r
+  //\r
+  // Dump the last CPU feature list\r
+  //\r
+  DEBUG_CODE (\r
+    DEBUG ((DEBUG_INFO, "Last CPU features list...\n"));\r
+    Entry = GetFirstNode (&CpuFeaturesData->FeatureList);\r
+    while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {\r
+      CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);\r
+      if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcds)) {\r
+        if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->SettingPcds)) {\r
+          DEBUG ((DEBUG_INFO, "[Enable   ] "));\r
+        } else {\r
+          DEBUG ((DEBUG_INFO, "[Disable  ] "));\r
+        }\r
+      } else {\r
+        DEBUG ((DEBUG_INFO, "[Unsupport] "));\r
+      }\r
+      DumpCpuFeature (CpuFeature);\r
+      Entry = Entry->ForwardLink;\r
+    }\r
+    DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSupport:\n"));\r
+    DumpCpuFeatureMask (CpuFeaturesData->SupportPcds);\r
+    DEBUG ((DEBUG_INFO, "PcdCpuFeaturesUserConfiguration:\n"));\r
+    DumpCpuFeatureMask (CpuFeaturesData->ConfigurationPcds);\r
+    DEBUG ((DEBUG_INFO, "PcdCpuFeaturesCapability:\n"));\r
+    DumpCpuFeatureMask (CpuFeaturesData->CapabilityPcds);\r
+    DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSetting:\n"));\r
+    DumpCpuFeatureMask (CpuFeaturesData->SettingPcds);\r
+  );\r
+\r
+  for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) {\r
+    CpuInitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber];\r
+    Entry = GetFirstNode (&CpuFeaturesData->FeatureList);\r
+    while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {\r
+      //\r
+      // Insert each feature into processor's order list\r
+      //\r
+      CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);\r
+      if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcds)) {\r
+        CpuFeatureInOrder = AllocateCopyPool (sizeof (CPU_FEATURES_ENTRY), CpuFeature);\r
+        ASSERT (CpuFeatureInOrder != NULL);\r
+        InsertTailList (&CpuInitOrder->OrderList, &CpuFeatureInOrder->Link);\r
+      }\r
+      Entry = Entry->ForwardLink;\r
+    }\r
+    //\r
+    // Go through ordered feature list to initialize CPU features\r
+    //\r
+    CpuInfo = &CpuFeaturesData->InitOrder[ProcessorNumber].CpuInfo;\r
+    Entry = GetFirstNode (&CpuInitOrder->OrderList);\r
+    while (!IsNull (&CpuInitOrder->OrderList, Entry)) {\r
+      CpuFeatureInOrder = CPU_FEATURE_ENTRY_FROM_LINK (Entry);\r
+      if (IsBitMaskMatch (CpuFeatureInOrder->FeatureMask, CpuFeaturesData->SettingPcds)) {\r
+        Status = CpuFeatureInOrder->InitializeFunc (ProcessorNumber, CpuInfo, CpuFeatureInOrder->ConfigData, TRUE);\r
+      } else {\r
+        Status = CpuFeatureInOrder->InitializeFunc (ProcessorNumber, CpuInfo, CpuFeatureInOrder->ConfigData, FALSE);\r
+      }\r
+      ASSERT_EFI_ERROR (Status);\r
+      Entry = Entry->ForwardLink;\r
+    }\r
+    //\r
+    // Dump the RegisterTable\r
+    //\r
+    DumpRegisterTableOnProcessor (ProcessorNumber);\r
+  }\r
+}\r
+\r
+/**\r
+  Initialize the CPU registers from a register table.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+\r
+  @note This service could be called by BSP/APs.\r
+**/\r
+VOID\r
+ProgramProcessorRegister (\r
+  IN UINTN  ProcessorNumber\r
+  )\r
+{\r
+  CPU_FEATURES_DATA         *CpuFeaturesData;\r
+  CPU_REGISTER_TABLE        *RegisterTable;\r
+  CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntry;\r
+  UINTN                     Index;\r
+  UINTN                     Value;\r
+  CPU_REGISTER_TABLE_ENTRY  *RegisterTableEntryHead;\r
+\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+  RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber];\r
+\r
+  //\r
+  // Traverse Register Table of this logical processor\r
+  //\r
+  RegisterTableEntryHead = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry;\r
+\r
+  for (Index = 0; Index < RegisterTable->TableLength; Index++) {\r
+\r
+    RegisterTableEntry = &RegisterTableEntryHead[Index];\r
+\r
+    //\r
+    // Check the type of specified register\r
+    //\r
+    switch (RegisterTableEntry->RegisterType) {\r
+    //\r
+    // The specified register is Control Register\r
+    //\r
+    case ControlRegister:\r
+      switch (RegisterTableEntry->Index) {\r
+      case 0:\r
+        Value = AsmReadCr0 ();\r
+        Value = (UINTN) BitFieldWrite64 (\r
+                          Value,\r
+                          RegisterTableEntry->ValidBitStart,\r
+                          RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,\r
+                          RegisterTableEntry->Value\r
+                          );\r
+        AsmWriteCr0 (Value);\r
+        break;\r
+      case 2:\r
+        Value = AsmReadCr2 ();\r
+        Value = (UINTN) BitFieldWrite64 (\r
+                          Value,\r
+                          RegisterTableEntry->ValidBitStart,\r
+                          RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,\r
+                          RegisterTableEntry->Value\r
+                          );\r
+        AsmWriteCr2 (Value);\r
+        break;\r
+      case 3:\r
+        Value = AsmReadCr3 ();\r
+        Value = (UINTN) BitFieldWrite64 (\r
+                          Value,\r
+                          RegisterTableEntry->ValidBitStart,\r
+                          RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,\r
+                          RegisterTableEntry->Value\r
+                          );\r
+        AsmWriteCr3 (Value);\r
+        break;\r
+      case 4:\r
+        Value = AsmReadCr4 ();\r
+        Value = (UINTN) BitFieldWrite64 (\r
+                          Value,\r
+                          RegisterTableEntry->ValidBitStart,\r
+                          RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,\r
+                          RegisterTableEntry->Value\r
+                          );\r
+        AsmWriteCr4 (Value);\r
+        break;\r
+      case 8:\r
+        //\r
+        //  Do we need to support CR8?\r
+        //\r
+        break;\r
+      default:\r
+        break;\r
+      }\r
+      break;\r
+    //\r
+    // The specified register is Model Specific Register\r
+    //\r
+    case Msr:\r
+      //\r
+      // Get lock to avoid Package/Core scope MSRs programming issue in parallel execution mode\r
+      //\r
+      AcquireSpinLock (&CpuFeaturesData->MsrLock);\r
+      if (RegisterTableEntry->ValidBitLength >= 64) {\r
+        //\r
+        // If length is not less than 64 bits, then directly write without reading\r
+        //\r
+        AsmWriteMsr64 (\r
+          RegisterTableEntry->Index,\r
+          RegisterTableEntry->Value\r
+          );\r
+      } else {\r
+        //\r
+        // Set the bit section according to bit start and length\r
+        //\r
+        AsmMsrBitFieldWrite64 (\r
+          RegisterTableEntry->Index,\r
+          RegisterTableEntry->ValidBitStart,\r
+          RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,\r
+          RegisterTableEntry->Value\r
+          );\r
+      }\r
+      ReleaseSpinLock (&CpuFeaturesData->MsrLock);\r
+      break;\r
+    //\r
+    // MemoryMapped operations\r
+    //\r
+    case MemoryMapped:\r
+      AcquireSpinLock (&CpuFeaturesData->MemoryMappedLock);\r
+      MmioBitFieldWrite32 (\r
+        (UINTN)(RegisterTableEntry->Index | LShiftU64 (RegisterTableEntry->HighIndex, 32)),\r
+        RegisterTableEntry->ValidBitStart,\r
+        RegisterTableEntry->ValidBitStart + RegisterTableEntry->ValidBitLength - 1,\r
+        (UINT32)RegisterTableEntry->Value\r
+        );\r
+      ReleaseSpinLock (&CpuFeaturesData->MemoryMappedLock);\r
+      break;\r
+    //\r
+    // Enable or disable cache\r
+    //\r
+    case CacheControl:\r
+      //\r
+      // If value of the entry is 0, then disable cache.  Otherwise, enable cache.\r
+      //\r
+      if (RegisterTableEntry->Value == 0) {\r
+        AsmDisableCache ();\r
+      } else {\r
+        AsmEnableCache ();\r
+      }\r
+      break;\r
+\r
+    default:\r
+      break;\r
+    }\r
+  }\r
+}\r
+\r
+/**\r
+  Programs registers for the calling processor.\r
+\r
+  @param[in,out] Buffer  The pointer to private data buffer.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SetProcessorRegister (\r
+  IN OUT VOID            *Buffer\r
+  )\r
+{\r
+  UINTN                  ProcessorNumber;\r
+\r
+  ProcessorNumber = GetProcessorIndex ();\r
+  ProgramProcessorRegister (ProcessorNumber);\r
+}\r
+\r
+/**\r
+  Performs CPU features detection.\r
+\r
+  This service will invoke MP service to check CPU features'\r
+  capabilities on BSP/APs.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuFeaturesDetect (\r
+  VOID\r
+  )\r
+{\r
+  UINTN                  NumberOfCpus;\r
+  UINTN                  NumberOfEnabledProcessors;\r
+\r
+  GetNumberOfProcessor (&NumberOfCpus, &NumberOfEnabledProcessors);\r
+\r
+  CpuInitDataInitialize (NumberOfCpus);\r
+\r
+  //\r
+  // Wakeup all APs for data collection.\r
+  //\r
+  StartupAPsWorker (CollectProcessorData);\r
+\r
+  //\r
+  // Collect data on BSP\r
+  //\r
+  CollectProcessorData (NULL);\r
+\r
+  AnalysisProcessorFeatures (NumberOfCpus);\r
+}\r
+\r
+/**\r
+  Performs CPU features Initialization.\r
+\r
+  This service will invoke MP service to perform CPU features\r
+  initialization on BSP/APs per user configuration.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuFeaturesInitialize (\r
+  VOID\r
+  )\r
+{\r
+  CPU_FEATURES_DATA      *CpuFeaturesData;\r
+  UINTN                  OldBspNumber;\r
+\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+\r
+  OldBspNumber = GetProcessorIndex();\r
+  CpuFeaturesData->BspNumber = OldBspNumber;\r
+  //\r
+  // Wakeup all APs for programming.\r
+  //\r
+  StartupAPsWorker (SetProcessorRegister);\r
+  //\r
+  // Programming BSP\r
+  //\r
+  SetProcessorRegister (NULL);\r
+  //\r
+  // Switch to new BSP if required\r
+  //\r
+  if (CpuFeaturesData->BspNumber != OldBspNumber) {\r
+    SwitchNewBsp (CpuFeaturesData->BspNumber);\r
+  }\r
+}\r
index 74c658a16b49bc0cc8f13e037eca50abe8f5ec11..902a339529e2552aa32a2fefa86555f0c751900c 100644 (file)
-/** @file
-  CPU Register Table Library functions.
-
-  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/UefiBootServicesTableLib.h>
-
-#include "RegisterCpuFeatures.h"
-
-CPU_FEATURES_DATA          mCpuFeaturesData = {0};
-EFI_MP_SERVICES_PROTOCOL   *mCpuFeaturesMpServices = NULL;
-
-/**
-  Worker function to get CPU_FEATURES_DATA pointer.
-
-  @return Pointer to CPU_FEATURES_DATA.
-**/
-CPU_FEATURES_DATA *
-GetCpuFeaturesData (
-  VOID
-  )
-{
-  return &mCpuFeaturesData;
-}
-
-/**
-  Worker function to get EFI_MP_SERVICES_PROTOCOL pointer.
-
-  @return Pointer to EFI_MP_SERVICES_PROTOCOL.
-**/
-EFI_MP_SERVICES_PROTOCOL *
-GetMpProtocol (
-  VOID
-  )
-{
-  EFI_STATUS             Status;
-
-  if (mCpuFeaturesMpServices == NULL) {
-    //
-    // Get MP Services Protocol
-    //
-    Status = gBS->LocateProtocol (
-                  &gEfiMpServiceProtocolGuid,
-                  NULL,
-                  (VOID **)&mCpuFeaturesMpServices
-                  );
-    ASSERT_EFI_ERROR (Status);
-  }
-
-  ASSERT (mCpuFeaturesMpServices != NULL);
-  return mCpuFeaturesMpServices;
-}
-
-/**
-  Worker function to return processor index.
-
-  @return  The processor index.
-**/
-UINTN
-GetProcessorIndex (
-  VOID
-  )
-{
-  EFI_STATUS                           Status;
-  UINTN                                ProcessorIndex;
-  EFI_MP_SERVICES_PROTOCOL             *MpServices;
-
-  MpServices = GetMpProtocol ();
-  Status = MpServices->WhoAmI(MpServices, &ProcessorIndex);
-  ASSERT_EFI_ERROR (Status);
-  return ProcessorIndex;
-}
-
-/**
-  Gets detailed MP-related information on the requested processor at the
-  instant this call is made.
-
-  @param[in]  ProcessorNumber       The handle number of processor.
-  @param[out] ProcessorInfoBuffer   A pointer to the buffer where information for
-                                    the requested processor is deposited.
-
-  @return Status of MpServices->GetProcessorInfo().
-**/
-EFI_STATUS
-GetProcessorInformation (
-  IN  UINTN                            ProcessorNumber,
-  OUT EFI_PROCESSOR_INFORMATION        *ProcessorInfoBuffer
-  )
-{
-  EFI_STATUS                           Status;
-  EFI_MP_SERVICES_PROTOCOL             *MpServices;
-
-  MpServices = GetMpProtocol ();
-  Status = MpServices->GetProcessorInfo (
-               MpServices,
-               ProcessorNumber,
-               ProcessorInfoBuffer
-               );
-  return Status;
-}
-
-/**
-  Worker function to execute a caller provided function on all enabled APs.
-
-  @param[in]  Procedure               A pointer to the function to be run on
-                                      enabled APs of the system.
-**/
-VOID
-StartupAPsWorker (
-  IN  EFI_AP_PROCEDURE                 Procedure
-  )
-{
-  EFI_STATUS                           Status;
-  EFI_MP_SERVICES_PROTOCOL             *MpServices;
-
-  MpServices = GetMpProtocol ();
-  //
-  // Wakeup all APs
-  //
-  Status = MpServices->StartupAllAPs (
-                 MpServices,
-                 Procedure,
-                 FALSE,
-                 NULL,
-                 0,
-                 NULL,
-                 NULL
-                 );
-  ASSERT_EFI_ERROR (Status);
-}
-
-/**
-  Worker function to switch the requested AP to be the BSP from that point onward.
-
-  @param[in] ProcessorNumber   The handle number of AP that is to become the new BSP.
-**/
-VOID
-SwitchNewBsp (
-  IN  UINTN                            ProcessorNumber
-  )
-{
-  EFI_STATUS                           Status;
-  EFI_MP_SERVICES_PROTOCOL             *MpServices;
-
-  MpServices = GetMpProtocol ();
-  //
-  // Wakeup all APs
-  //
-  Status = MpServices->SwitchBSP (
-                 MpServices,
-                 ProcessorNumber,
-                 TRUE
-                 );
-  ASSERT_EFI_ERROR (Status);
-}
-
-/**
-  Worker function to retrieve the number of logical processor in the platform.
-
-  @param[out] NumberOfCpus                Pointer to the total number of logical
-                                          processors in the system, including the BSP
-                                          and disabled APs.
-  @param[out] NumberOfEnabledProcessors   Pointer to the number of enabled logical
-                                          processors that exist in system, including
-                                          the BSP.
-**/
-VOID
-GetNumberOfProcessor (
-  OUT UINTN                            *NumberOfCpus,
-  OUT UINTN                            *NumberOfEnabledProcessors
-  )
-{
-  EFI_STATUS                           Status;
-  EFI_MP_SERVICES_PROTOCOL             *MpServices;
-
-  MpServices = GetMpProtocol ();
-
-  //
-  // Get the number of CPUs
-  //
-  Status = MpServices->GetNumberOfProcessors (
-                         MpServices,
-                         NumberOfCpus,
-                         NumberOfEnabledProcessors
-                         );
-  ASSERT_EFI_ERROR (Status);
-}
-
-/**
-  Allocates ACPI NVS memory to save ACPI_CPU_DATA.
-
-  @return  Pointer to allocated ACPI_CPU_DATA.
-**/
-ACPI_CPU_DATA *
-AllocateAcpiCpuData (
-  VOID
-  )
-{
-  //
-  // CpuS3DataDxe will do it.
-  //
-  ASSERT (FALSE);
-  return NULL;
-}
-
-/**
-  Enlarges CPU register table for each processor.
-
-  @param[in, out]  RegisterTable   Pointer processor's CPU register table
-**/
-VOID
-EnlargeRegisterTable (
-  IN OUT CPU_REGISTER_TABLE            *RegisterTable
-  )
-{
-  EFI_STATUS            Status;
-  EFI_PHYSICAL_ADDRESS  Address;
-  UINTN                 AllocatePages;
-
-  Address = BASE_4GB - 1;
-  AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE;
-  Status  = gBS->AllocatePages (
-                   AllocateMaxAddress,
-                   EfiACPIMemoryNVS,
-                   AllocatePages + 1,
-                   &Address
-                   );
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // If there are records existing in the register table, then copy its contents
-  // to new region and free the old one.
-  //
-  if (RegisterTable->AllocatedSize > 0) {
-    CopyMem (
-      (VOID *) (UINTN) Address,
-      (VOID *) (UINTN) RegisterTable->RegisterTableEntry,
-      RegisterTable->AllocatedSize
-      );
-    //
-    // RegisterTableEntry is allocated by gBS->AllocatePages() service.
-    // So, gBS->FreePages() service is used to free it.
-    //
-    gBS->FreePages (
-      RegisterTable->RegisterTableEntry,
-      AllocatePages
-      );
-  }
-
-  //
-  // Adjust the allocated size and register table base address.
-  //
-  RegisterTable->AllocatedSize     += EFI_PAGE_SIZE;
-  RegisterTable->RegisterTableEntry = Address;
-}
+/** @file\r
+  CPU Register Table Library functions.\r
+\r
+  Copyright (c) 2017, 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/UefiBootServicesTableLib.h>\r
+\r
+#include "RegisterCpuFeatures.h"\r
+\r
+CPU_FEATURES_DATA          mCpuFeaturesData = {0};\r
+EFI_MP_SERVICES_PROTOCOL   *mCpuFeaturesMpServices = NULL;\r
+\r
+/**\r
+  Worker function to get CPU_FEATURES_DATA pointer.\r
+\r
+  @return Pointer to CPU_FEATURES_DATA.\r
+**/\r
+CPU_FEATURES_DATA *\r
+GetCpuFeaturesData (\r
+  VOID\r
+  )\r
+{\r
+  return &mCpuFeaturesData;\r
+}\r
+\r
+/**\r
+  Worker function to get EFI_MP_SERVICES_PROTOCOL pointer.\r
+\r
+  @return Pointer to EFI_MP_SERVICES_PROTOCOL.\r
+**/\r
+EFI_MP_SERVICES_PROTOCOL *\r
+GetMpProtocol (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS             Status;\r
+\r
+  if (mCpuFeaturesMpServices == NULL) {\r
+    //\r
+    // Get MP Services Protocol\r
+    //\r
+    Status = gBS->LocateProtocol (\r
+                  &gEfiMpServiceProtocolGuid,\r
+                  NULL,\r
+                  (VOID **)&mCpuFeaturesMpServices\r
+                  );\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  ASSERT (mCpuFeaturesMpServices != NULL);\r
+  return mCpuFeaturesMpServices;\r
+}\r
+\r
+/**\r
+  Worker function to return processor index.\r
+\r
+  @return  The processor index.\r
+**/\r
+UINTN\r
+GetProcessorIndex (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  UINTN                                ProcessorIndex;\r
+  EFI_MP_SERVICES_PROTOCOL             *MpServices;\r
+\r
+  MpServices = GetMpProtocol ();\r
+  Status = MpServices->WhoAmI(MpServices, &ProcessorIndex);\r
+  ASSERT_EFI_ERROR (Status);\r
+  return ProcessorIndex;\r
+}\r
+\r
+/**\r
+  Gets detailed MP-related information on the requested processor at the\r
+  instant this call is made.\r
+\r
+  @param[in]  ProcessorNumber       The handle number of processor.\r
+  @param[out] ProcessorInfoBuffer   A pointer to the buffer where information for\r
+                                    the requested processor is deposited.\r
+\r
+  @return Status of MpServices->GetProcessorInfo().\r
+**/\r
+EFI_STATUS\r
+GetProcessorInformation (\r
+  IN  UINTN                            ProcessorNumber,\r
+  OUT EFI_PROCESSOR_INFORMATION        *ProcessorInfoBuffer\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  EFI_MP_SERVICES_PROTOCOL             *MpServices;\r
+\r
+  MpServices = GetMpProtocol ();\r
+  Status = MpServices->GetProcessorInfo (\r
+               MpServices,\r
+               ProcessorNumber,\r
+               ProcessorInfoBuffer\r
+               );\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Worker function to execute a caller provided function on all enabled APs.\r
+\r
+  @param[in]  Procedure               A pointer to the function to be run on\r
+                                      enabled APs of the system.\r
+**/\r
+VOID\r
+StartupAPsWorker (\r
+  IN  EFI_AP_PROCEDURE                 Procedure\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  EFI_MP_SERVICES_PROTOCOL             *MpServices;\r
+\r
+  MpServices = GetMpProtocol ();\r
+  //\r
+  // Wakeup all APs\r
+  //\r
+  Status = MpServices->StartupAllAPs (\r
+                 MpServices,\r
+                 Procedure,\r
+                 FALSE,\r
+                 NULL,\r
+                 0,\r
+                 NULL,\r
+                 NULL\r
+                 );\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Worker function to switch the requested AP to be the BSP from that point onward.\r
+\r
+  @param[in] ProcessorNumber   The handle number of AP that is to become the new BSP.\r
+**/\r
+VOID\r
+SwitchNewBsp (\r
+  IN  UINTN                            ProcessorNumber\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  EFI_MP_SERVICES_PROTOCOL             *MpServices;\r
+\r
+  MpServices = GetMpProtocol ();\r
+  //\r
+  // Wakeup all APs\r
+  //\r
+  Status = MpServices->SwitchBSP (\r
+                 MpServices,\r
+                 ProcessorNumber,\r
+                 TRUE\r
+                 );\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Worker function to retrieve the number of logical processor in the platform.\r
+\r
+  @param[out] NumberOfCpus                Pointer to the total number of logical\r
+                                          processors in the system, including the BSP\r
+                                          and disabled APs.\r
+  @param[out] NumberOfEnabledProcessors   Pointer to the number of enabled logical\r
+                                          processors that exist in system, including\r
+                                          the BSP.\r
+**/\r
+VOID\r
+GetNumberOfProcessor (\r
+  OUT UINTN                            *NumberOfCpus,\r
+  OUT UINTN                            *NumberOfEnabledProcessors\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  EFI_MP_SERVICES_PROTOCOL             *MpServices;\r
+\r
+  MpServices = GetMpProtocol ();\r
+\r
+  //\r
+  // Get the number of CPUs\r
+  //\r
+  Status = MpServices->GetNumberOfProcessors (\r
+                         MpServices,\r
+                         NumberOfCpus,\r
+                         NumberOfEnabledProcessors\r
+                         );\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Allocates ACPI NVS memory to save ACPI_CPU_DATA.\r
+\r
+  @return  Pointer to allocated ACPI_CPU_DATA.\r
+**/\r
+ACPI_CPU_DATA *\r
+AllocateAcpiCpuData (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // CpuS3DataDxe will do it.\r
+  //\r
+  ASSERT (FALSE);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Enlarges CPU register table for each processor.\r
+\r
+  @param[in, out]  RegisterTable   Pointer processor's CPU register table\r
+**/\r
+VOID\r
+EnlargeRegisterTable (\r
+  IN OUT CPU_REGISTER_TABLE            *RegisterTable\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  Address;\r
+  UINTN                 AllocatePages;\r
+\r
+  Address = BASE_4GB - 1;\r
+  AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE;\r
+  Status  = gBS->AllocatePages (\r
+                   AllocateMaxAddress,\r
+                   EfiACPIMemoryNVS,\r
+                   AllocatePages + 1,\r
+                   &Address\r
+                   );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // If there are records existing in the register table, then copy its contents\r
+  // to new region and free the old one.\r
+  //\r
+  if (RegisterTable->AllocatedSize > 0) {\r
+    CopyMem (\r
+      (VOID *) (UINTN) Address,\r
+      (VOID *) (UINTN) RegisterTable->RegisterTableEntry,\r
+      RegisterTable->AllocatedSize\r
+      );\r
+    //\r
+    // RegisterTableEntry is allocated by gBS->AllocatePages() service.\r
+    // So, gBS->FreePages() service is used to free it.\r
+    //\r
+    gBS->FreePages (\r
+      RegisterTable->RegisterTableEntry,\r
+      AllocatePages\r
+      );\r
+  }\r
+\r
+  //\r
+  // Adjust the allocated size and register table base address.\r
+  //\r
+  RegisterTable->AllocatedSize     += EFI_PAGE_SIZE;\r
+  RegisterTable->RegisterTableEntry = Address;\r
+}\r
index abffd11194c8aad1f9836ef549a467757260dc03..62ac8a9635f728646e82545834675e4db007ba5e 100644 (file)
@@ -1,62 +1,62 @@
-## @file
-#  Register CPU Features Library DXE instance.
-#
-#  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.
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = DxeRegisterCpuFeaturesLib
-  MODULE_UNI_FILE                = DxeRegisterCpuFeaturesLib.uni
-  FILE_GUID                      = ADE8F745-AA2E-49f6-8ED4-746B34867E52
-  MODULE_TYPE                    = DXE_DRIVER
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = RegisterCpuFeaturesLib|DXE_DRIVER
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-#  VALID_ARCHITECTURES           = IA32 X64
-#
-
-[Sources.common]
-  DxeRegisterCpuFeaturesLib.c
-  RegisterCpuFeaturesLib.c
-  RegisterCpuFeatures.h
-  CpuFeaturesInitialize.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  UefiCpuPkg/UefiCpuPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  DebugLib
-  PcdLib
-  LocalApicLib
-  BaseMemoryLib
-  MemoryAllocationLib
-  SynchronizationLib
-  UefiBootServicesTableLib
-  IoLib
-
-[Protocols]
-  gEfiMpServiceProtocolGuid                                            ## CONSUMES
-
-[Pcd]
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress                        ## CONSUMES
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport                      ## CONSUMES
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration            ## CONSUMES
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability                   ## PRODUCES
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting                      ## PRODUCES
-
-[Depex]
-  gEfiMpServiceProtocolGuid AND gEdkiiCpuFeaturesSetDoneGuid
+## @file\r
+#  Register CPU Features Library DXE instance.\r
+#\r
+#  Copyright (c) 2017, 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
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DxeRegisterCpuFeaturesLib\r
+  MODULE_UNI_FILE                = DxeRegisterCpuFeaturesLib.uni\r
+  FILE_GUID                      = ADE8F745-AA2E-49f6-8ED4-746B34867E52\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = RegisterCpuFeaturesLib|DXE_DRIVER\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources.common]\r
+  DxeRegisterCpuFeaturesLib.c\r
+  RegisterCpuFeaturesLib.c\r
+  RegisterCpuFeatures.h\r
+  CpuFeaturesInitialize.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
+  PcdLib\r
+  LocalApicLib\r
+  BaseMemoryLib\r
+  MemoryAllocationLib\r
+  SynchronizationLib\r
+  UefiBootServicesTableLib\r
+  IoLib\r
+\r
+[Protocols]\r
+  gEfiMpServiceProtocolGuid                                            ## CONSUMES\r
+\r
+[Pcd]\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress                        ## CONSUMES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport                      ## CONSUMES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration            ## CONSUMES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability                   ## PRODUCES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting                      ## PRODUCES\r
+\r
+[Depex]\r
+  gEfiMpServiceProtocolGuid AND gEdkiiCpuFeaturesSetDoneGuid\r
index 8fde742dce3719e0e4531a28785dfa800db5fca0..6804eddf65d9f3c4affc97dbae02faca2fdb1b67 100644 (file)
-/** @file
-  CPU Register Table Library functions.
-
-  Copyright (c) 2016, 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 <PiPei.h>
-
-#include <Library/HobLib.h>
-#include <Library/PeiServicesLib.h>
-#include <Library/PeiServicesTablePointerLib.h>
-#include <Ppi/MpServices.h>
-#include "RegisterCpuFeatures.h"
-
-#define REGISTER_CPU_FEATURES_GUID \
-  { \
-    0xa694c467, 0x697a, 0x446b, { 0xb9, 0x29, 0x5b, 0x14, 0xa0, 0xcf, 0x39, 0xf } \
-  }
-
-EFI_GUID mRegisterCpuFeaturesHobGuid = REGISTER_CPU_FEATURES_GUID;
-
-/**
-  Worker function to get CPU_FEATURES_DATA pointer.
-
-  @return Pointer to CPU_FEATURES_DATA.
-**/
-CPU_FEATURES_DATA *
-GetCpuFeaturesData (
-  VOID
-  )
-{
-  CPU_FEATURES_DATA       *CpuInitData;
-  EFI_HOB_GUID_TYPE       *GuidHob;
-  VOID                    *DataInHob;
-  UINT64                  Data64;
-
-  CpuInitData = NULL;
-  GuidHob = GetFirstGuidHob (&mRegisterCpuFeaturesHobGuid);
-  if (GuidHob != NULL) {
-    DataInHob = GET_GUID_HOB_DATA (GuidHob);
-    CpuInitData = (CPU_FEATURES_DATA *) (*(UINTN *) DataInHob);
-    ASSERT (CpuInitData != NULL);
-  } else {
-    CpuInitData = AllocateZeroPool (sizeof (CPU_FEATURES_DATA));
-    ASSERT (CpuInitData != NULL);
-    //
-    // Build location of CPU MP DATA buffer in HOB
-    //
-    Data64 = (UINT64) (UINTN) CpuInitData;
-    BuildGuidDataHob (
-      &mRegisterCpuFeaturesHobGuid,
-      (VOID *) &Data64,
-      sizeof (UINT64)
-      );
-  }
-
-  return CpuInitData;
-}
-
-/**
-  Worker function to get MP PPI service pointer.
-
-  @return PEI PPI service pointer.
-**/
-EFI_PEI_MP_SERVICES_PPI *
-GetMpPpi (
-  VOID
-  )
-{
-  EFI_STATUS                 Status;
-  EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;
-
-  //
-  // Get MP Services Protocol
-  //
-  Status = PeiServicesLocatePpi (
-             &gEfiPeiMpServicesPpiGuid,
-             0,
-             NULL,
-             (VOID **)&CpuMpPpi
-             );
-  ASSERT_EFI_ERROR (Status);
-  return CpuMpPpi;
-}
-
-/**
-  Worker function to return processor index.
-
-  @return  The processor index.
-**/
-UINTN
-GetProcessorIndex (
-  VOID
-  )
-{
-  EFI_STATUS                 Status;
-  EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;
-  UINTN                      ProcessorIndex;
-
-  CpuMpPpi = GetMpPpi ();
-
-  Status = CpuMpPpi->WhoAmI(GetPeiServicesTablePointer (), CpuMpPpi, &ProcessorIndex);
-  ASSERT_EFI_ERROR (Status);
-  return ProcessorIndex;
-}
-
-/**
-  Worker function to MP-related information on the requested processor at the
-  instant this call is made.
-
-  @param[in]  ProcessorNumber       The handle number of processor.
-  @param[out] ProcessorInfoBuffer   A pointer to the buffer where information for
-                                    the requested processor is deposited.
-
-  @return Status of MpServices->GetProcessorInfo().
-**/
-EFI_STATUS
-GetProcessorInformation (
-  IN  UINTN                            ProcessorNumber,
-  OUT EFI_PROCESSOR_INFORMATION        *ProcessorInfoBuffer
-  )
-{
-  EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;
-  EFI_STATUS                 Status;
-
-  CpuMpPpi = GetMpPpi ();
-  Status = CpuMpPpi->GetProcessorInfo (
-               GetPeiServicesTablePointer(),
-               CpuMpPpi,
-               ProcessorNumber,
-               ProcessorInfoBuffer
-               );
-  return Status;
-}
-
-/**
-  Worker function to execute a caller provided function on all enabled APs.
-
-  @param[in]  Procedure               A pointer to the function to be run on
-                                      enabled APs of the system.
-**/
-VOID
-StartupAPsWorker (
-  IN  EFI_AP_PROCEDURE                 Procedure
-  )
-{
-  EFI_STATUS                           Status;
-  EFI_PEI_MP_SERVICES_PPI              *CpuMpPpi;
-
-  //
-  // Get MP Services Protocol
-  //
-  Status = PeiServicesLocatePpi (
-             &gEfiPeiMpServicesPpiGuid,
-             0,
-             NULL,
-             (VOID **)&CpuMpPpi
-             );
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // Wakeup all APs for data collection.
-  //
-  Status = CpuMpPpi->StartupAllAPs (
-                 GetPeiServicesTablePointer (),
-                 CpuMpPpi,
-                 Procedure,
-                 FALSE,
-                 0,
-                 NULL
-                 );
-  ASSERT_EFI_ERROR (Status);
-}
-
-/**
-  Worker function to switch the requested AP to be the BSP from that point onward.
-
-  @param[in] ProcessorNumber   The handle number of AP that is to become the new BSP.
-**/
-VOID
-SwitchNewBsp (
-  IN  UINTN                            ProcessorNumber
-  )
-{
-  EFI_STATUS                           Status;
-  EFI_PEI_MP_SERVICES_PPI              *CpuMpPpi;
-
-  //
-  // Get MP Services Protocol
-  //
-  Status = PeiServicesLocatePpi (
-             &gEfiPeiMpServicesPpiGuid,
-             0,
-             NULL,
-             (VOID **)&CpuMpPpi
-             );
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // Wakeup all APs for data collection.
-  //
-  Status = CpuMpPpi->SwitchBSP (
-                 GetPeiServicesTablePointer (),
-                 CpuMpPpi,
-                 ProcessorNumber,
-                 TRUE
-                 );
-  ASSERT_EFI_ERROR (Status);
-}
-
-/**
-  Worker function to retrieve the number of logical processor in the platform.
-
-  @param[out] NumberOfCpus                Pointer to the total number of logical
-                                          processors in the system, including the BSP
-                                          and disabled APs.
-  @param[out] NumberOfEnabledProcessors   Pointer to the number of enabled logical
-                                          processors that exist in system, including
-                                          the BSP.
-**/
-VOID
-GetNumberOfProcessor (
-  OUT UINTN                            *NumberOfCpus,
-  OUT UINTN                            *NumberOfEnabledProcessors
-  )
-{
-  EFI_STATUS                 Status;
-  EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;
-
-  //
-  // Get MP Services Protocol
-  //
-  Status = PeiServicesLocatePpi (
-             &gEfiPeiMpServicesPpiGuid,
-             0,
-             NULL,
-             (VOID **)&CpuMpPpi
-             );
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // Get the number of CPUs
-  //
-  Status = CpuMpPpi->GetNumberOfProcessors (
-                         GetPeiServicesTablePointer (),
-                         CpuMpPpi,
-                         NumberOfCpus,
-                         NumberOfEnabledProcessors
-                         );
-  ASSERT_EFI_ERROR (Status);
-}
-
-/**
-  Allocates ACPI NVS memory to save ACPI_CPU_DATA.
-
-  @return  Pointer to allocated ACPI_CPU_DATA.
-**/
-ACPI_CPU_DATA *
-AllocateAcpiCpuData (
-  VOID
-  )
-{
-  EFI_STATUS                           Status;
-  EFI_PEI_MP_SERVICES_PPI              *CpuMpPpi;
-  UINTN                                NumberOfCpus;
-  UINTN                                NumberOfEnabledProcessors;
-  ACPI_CPU_DATA                        *AcpiCpuData;
-  EFI_PHYSICAL_ADDRESS                 Address;
-  UINTN                                TableSize;
-  CPU_REGISTER_TABLE                   *RegisterTable;
-  UINTN                                Index;
-  EFI_PROCESSOR_INFORMATION            ProcessorInfoBuffer;
-
-  Status = PeiServicesAllocatePages (
-             EfiACPIMemoryNVS,
-             EFI_SIZE_TO_PAGES (sizeof (ACPI_CPU_DATA)),
-             &Address
-             );
-  ASSERT_EFI_ERROR (Status);
-  AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) Address;
-  ASSERT (AcpiCpuData != NULL);
-
-  //
-  // Get MP Services Protocol
-  //
-  Status = PeiServicesLocatePpi (
-             &gEfiPeiMpServicesPpiGuid,
-             0,
-             NULL,
-             (VOID **)&CpuMpPpi
-             );
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // Get the number of CPUs
-  //
-  Status = CpuMpPpi->GetNumberOfProcessors (
-                         GetPeiServicesTablePointer (),
-                         CpuMpPpi,
-                         &NumberOfCpus,
-                         &NumberOfEnabledProcessors
-                         );
-  ASSERT_EFI_ERROR (Status);
-  AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus;
-
-  //
-  // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs
-  //
-  TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE);
-  Status = PeiServicesAllocatePages (
-             EfiACPIMemoryNVS,
-             EFI_SIZE_TO_PAGES (TableSize),
-             &Address
-             );
-  ASSERT_EFI_ERROR (Status);
-  RegisterTable = (CPU_REGISTER_TABLE *) (UINTN) Address;
-
-  for (Index = 0; Index < NumberOfCpus; Index++) {
-    Status = CpuMpPpi->GetProcessorInfo (
-                         GetPeiServicesTablePointer (),
-                         CpuMpPpi,
-                         Index,
-                         &ProcessorInfoBuffer
-                         );
-    ASSERT_EFI_ERROR (Status);
-
-    RegisterTable[Index].InitialApicId      = (UINT32)ProcessorInfoBuffer.ProcessorId;
-    RegisterTable[Index].TableLength        = 0;
-    RegisterTable[Index].AllocatedSize      = 0;
-    RegisterTable[Index].RegisterTableEntry = 0;
-
-    RegisterTable[NumberOfCpus + Index].InitialApicId      = (UINT32)ProcessorInfoBuffer.ProcessorId;
-    RegisterTable[NumberOfCpus + Index].TableLength        = 0;
-    RegisterTable[NumberOfCpus + Index].AllocatedSize      = 0;
-    RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0;
-  }
-  AcpiCpuData->RegisterTable           = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable;
-  AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus);
-
-  return AcpiCpuData;
-}
-
-/**
-  Enlarges CPU register table for each processor.
-
-  @param[in, out]  RegisterTable   Pointer processor's CPU register table
-**/
-VOID
-EnlargeRegisterTable (
-  IN OUT CPU_REGISTER_TABLE            *RegisterTable
-  )
-{
-  EFI_STATUS                           Status;
-  EFI_PHYSICAL_ADDRESS                 Address;
-  UINTN                                AllocatePages;
-
-  AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE;
-  Status = PeiServicesAllocatePages (
-             EfiACPIMemoryNVS,
-             AllocatePages + 1,
-             &Address
-             );
-  ASSERT_EFI_ERROR (Status);
-
-  //
-  // If there are records existing in the register table, then copy its contents
-  // to new region and free the old one.
-  //
-  if (RegisterTable->AllocatedSize > 0) {
-    CopyMem (
-      (VOID *) (UINTN) Address,
-      (VOID *) (UINTN) RegisterTable->RegisterTableEntry,
-      RegisterTable->AllocatedSize
-      );
-  }
-
-  //
-  // Adjust the allocated size and register table base address.
-  //
-  RegisterTable->AllocatedSize += EFI_PAGE_SIZE;
-  RegisterTable->RegisterTableEntry = Address;
-}
+/** @file\r
+  CPU Register Table Library functions.\r
+\r
+  Copyright (c) 2016, 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 <PiPei.h>\r
+\r
+#include <Library/HobLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/PeiServicesTablePointerLib.h>\r
+#include <Ppi/MpServices.h>\r
+#include "RegisterCpuFeatures.h"\r
+\r
+#define REGISTER_CPU_FEATURES_GUID \\r
+  { \\r
+    0xa694c467, 0x697a, 0x446b, { 0xb9, 0x29, 0x5b, 0x14, 0xa0, 0xcf, 0x39, 0xf } \\r
+  }\r
+\r
+EFI_GUID mRegisterCpuFeaturesHobGuid = REGISTER_CPU_FEATURES_GUID;\r
+\r
+/**\r
+  Worker function to get CPU_FEATURES_DATA pointer.\r
+\r
+  @return Pointer to CPU_FEATURES_DATA.\r
+**/\r
+CPU_FEATURES_DATA *\r
+GetCpuFeaturesData (\r
+  VOID\r
+  )\r
+{\r
+  CPU_FEATURES_DATA       *CpuInitData;\r
+  EFI_HOB_GUID_TYPE       *GuidHob;\r
+  VOID                    *DataInHob;\r
+  UINT64                  Data64;\r
+\r
+  CpuInitData = NULL;\r
+  GuidHob = GetFirstGuidHob (&mRegisterCpuFeaturesHobGuid);\r
+  if (GuidHob != NULL) {\r
+    DataInHob = GET_GUID_HOB_DATA (GuidHob);\r
+    CpuInitData = (CPU_FEATURES_DATA *) (*(UINTN *) DataInHob);\r
+    ASSERT (CpuInitData != NULL);\r
+  } else {\r
+    CpuInitData = AllocateZeroPool (sizeof (CPU_FEATURES_DATA));\r
+    ASSERT (CpuInitData != NULL);\r
+    //\r
+    // Build location of CPU MP DATA buffer in HOB\r
+    //\r
+    Data64 = (UINT64) (UINTN) CpuInitData;\r
+    BuildGuidDataHob (\r
+      &mRegisterCpuFeaturesHobGuid,\r
+      (VOID *) &Data64,\r
+      sizeof (UINT64)\r
+      );\r
+  }\r
+\r
+  return CpuInitData;\r
+}\r
+\r
+/**\r
+  Worker function to get MP PPI service pointer.\r
+\r
+  @return PEI PPI service pointer.\r
+**/\r
+EFI_PEI_MP_SERVICES_PPI *\r
+GetMpPpi (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                 Status;\r
+  EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;\r
+\r
+  //\r
+  // Get MP Services Protocol\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiMpServicesPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&CpuMpPpi\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+  return CpuMpPpi;\r
+}\r
+\r
+/**\r
+  Worker function to return processor index.\r
+\r
+  @return  The processor index.\r
+**/\r
+UINTN\r
+GetProcessorIndex (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                 Status;\r
+  EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;\r
+  UINTN                      ProcessorIndex;\r
+\r
+  CpuMpPpi = GetMpPpi ();\r
+\r
+  Status = CpuMpPpi->WhoAmI(GetPeiServicesTablePointer (), CpuMpPpi, &ProcessorIndex);\r
+  ASSERT_EFI_ERROR (Status);\r
+  return ProcessorIndex;\r
+}\r
+\r
+/**\r
+  Worker function to MP-related information on the requested processor at the\r
+  instant this call is made.\r
+\r
+  @param[in]  ProcessorNumber       The handle number of processor.\r
+  @param[out] ProcessorInfoBuffer   A pointer to the buffer where information for\r
+                                    the requested processor is deposited.\r
+\r
+  @return Status of MpServices->GetProcessorInfo().\r
+**/\r
+EFI_STATUS\r
+GetProcessorInformation (\r
+  IN  UINTN                            ProcessorNumber,\r
+  OUT EFI_PROCESSOR_INFORMATION        *ProcessorInfoBuffer\r
+  )\r
+{\r
+  EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;\r
+  EFI_STATUS                 Status;\r
+\r
+  CpuMpPpi = GetMpPpi ();\r
+  Status = CpuMpPpi->GetProcessorInfo (\r
+               GetPeiServicesTablePointer(),\r
+               CpuMpPpi,\r
+               ProcessorNumber,\r
+               ProcessorInfoBuffer\r
+               );\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Worker function to execute a caller provided function on all enabled APs.\r
+\r
+  @param[in]  Procedure               A pointer to the function to be run on\r
+                                      enabled APs of the system.\r
+**/\r
+VOID\r
+StartupAPsWorker (\r
+  IN  EFI_AP_PROCEDURE                 Procedure\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  EFI_PEI_MP_SERVICES_PPI              *CpuMpPpi;\r
+\r
+  //\r
+  // Get MP Services Protocol\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiMpServicesPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&CpuMpPpi\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Wakeup all APs for data collection.\r
+  //\r
+  Status = CpuMpPpi->StartupAllAPs (\r
+                 GetPeiServicesTablePointer (),\r
+                 CpuMpPpi,\r
+                 Procedure,\r
+                 FALSE,\r
+                 0,\r
+                 NULL\r
+                 );\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Worker function to switch the requested AP to be the BSP from that point onward.\r
+\r
+  @param[in] ProcessorNumber   The handle number of AP that is to become the new BSP.\r
+**/\r
+VOID\r
+SwitchNewBsp (\r
+  IN  UINTN                            ProcessorNumber\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  EFI_PEI_MP_SERVICES_PPI              *CpuMpPpi;\r
+\r
+  //\r
+  // Get MP Services Protocol\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiMpServicesPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&CpuMpPpi\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Wakeup all APs for data collection.\r
+  //\r
+  Status = CpuMpPpi->SwitchBSP (\r
+                 GetPeiServicesTablePointer (),\r
+                 CpuMpPpi,\r
+                 ProcessorNumber,\r
+                 TRUE\r
+                 );\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Worker function to retrieve the number of logical processor in the platform.\r
+\r
+  @param[out] NumberOfCpus                Pointer to the total number of logical\r
+                                          processors in the system, including the BSP\r
+                                          and disabled APs.\r
+  @param[out] NumberOfEnabledProcessors   Pointer to the number of enabled logical\r
+                                          processors that exist in system, including\r
+                                          the BSP.\r
+**/\r
+VOID\r
+GetNumberOfProcessor (\r
+  OUT UINTN                            *NumberOfCpus,\r
+  OUT UINTN                            *NumberOfEnabledProcessors\r
+  )\r
+{\r
+  EFI_STATUS                 Status;\r
+  EFI_PEI_MP_SERVICES_PPI    *CpuMpPpi;\r
+\r
+  //\r
+  // Get MP Services Protocol\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiMpServicesPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&CpuMpPpi\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Get the number of CPUs\r
+  //\r
+  Status = CpuMpPpi->GetNumberOfProcessors (\r
+                         GetPeiServicesTablePointer (),\r
+                         CpuMpPpi,\r
+                         NumberOfCpus,\r
+                         NumberOfEnabledProcessors\r
+                         );\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
+/**\r
+  Allocates ACPI NVS memory to save ACPI_CPU_DATA.\r
+\r
+  @return  Pointer to allocated ACPI_CPU_DATA.\r
+**/\r
+ACPI_CPU_DATA *\r
+AllocateAcpiCpuData (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  EFI_PEI_MP_SERVICES_PPI              *CpuMpPpi;\r
+  UINTN                                NumberOfCpus;\r
+  UINTN                                NumberOfEnabledProcessors;\r
+  ACPI_CPU_DATA                        *AcpiCpuData;\r
+  EFI_PHYSICAL_ADDRESS                 Address;\r
+  UINTN                                TableSize;\r
+  CPU_REGISTER_TABLE                   *RegisterTable;\r
+  UINTN                                Index;\r
+  EFI_PROCESSOR_INFORMATION            ProcessorInfoBuffer;\r
+\r
+  Status = PeiServicesAllocatePages (\r
+             EfiACPIMemoryNVS,\r
+             EFI_SIZE_TO_PAGES (sizeof (ACPI_CPU_DATA)),\r
+             &Address\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+  AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) Address;\r
+  ASSERT (AcpiCpuData != NULL);\r
+\r
+  //\r
+  // Get MP Services Protocol\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+             &gEfiPeiMpServicesPpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&CpuMpPpi\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Get the number of CPUs\r
+  //\r
+  Status = CpuMpPpi->GetNumberOfProcessors (\r
+                         GetPeiServicesTablePointer (),\r
+                         CpuMpPpi,\r
+                         &NumberOfCpus,\r
+                         &NumberOfEnabledProcessors\r
+                         );\r
+  ASSERT_EFI_ERROR (Status);\r
+  AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus;\r
+\r
+  //\r
+  // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs\r
+  //\r
+  TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE);\r
+  Status = PeiServicesAllocatePages (\r
+             EfiACPIMemoryNVS,\r
+             EFI_SIZE_TO_PAGES (TableSize),\r
+             &Address\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+  RegisterTable = (CPU_REGISTER_TABLE *) (UINTN) Address;\r
+\r
+  for (Index = 0; Index < NumberOfCpus; Index++) {\r
+    Status = CpuMpPpi->GetProcessorInfo (\r
+                         GetPeiServicesTablePointer (),\r
+                         CpuMpPpi,\r
+                         Index,\r
+                         &ProcessorInfoBuffer\r
+                         );\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    RegisterTable[Index].InitialApicId      = (UINT32)ProcessorInfoBuffer.ProcessorId;\r
+    RegisterTable[Index].TableLength        = 0;\r
+    RegisterTable[Index].AllocatedSize      = 0;\r
+    RegisterTable[Index].RegisterTableEntry = 0;\r
+\r
+    RegisterTable[NumberOfCpus + Index].InitialApicId      = (UINT32)ProcessorInfoBuffer.ProcessorId;\r
+    RegisterTable[NumberOfCpus + Index].TableLength        = 0;\r
+    RegisterTable[NumberOfCpus + Index].AllocatedSize      = 0;\r
+    RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0;\r
+  }\r
+  AcpiCpuData->RegisterTable           = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable;\r
+  AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus);\r
+\r
+  return AcpiCpuData;\r
+}\r
+\r
+/**\r
+  Enlarges CPU register table for each processor.\r
+\r
+  @param[in, out]  RegisterTable   Pointer processor's CPU register table\r
+**/\r
+VOID\r
+EnlargeRegisterTable (\r
+  IN OUT CPU_REGISTER_TABLE            *RegisterTable\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  EFI_PHYSICAL_ADDRESS                 Address;\r
+  UINTN                                AllocatePages;\r
+\r
+  AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE;\r
+  Status = PeiServicesAllocatePages (\r
+             EfiACPIMemoryNVS,\r
+             AllocatePages + 1,\r
+             &Address\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // If there are records existing in the register table, then copy its contents\r
+  // to new region and free the old one.\r
+  //\r
+  if (RegisterTable->AllocatedSize > 0) {\r
+    CopyMem (\r
+      (VOID *) (UINTN) Address,\r
+      (VOID *) (UINTN) RegisterTable->RegisterTableEntry,\r
+      RegisterTable->AllocatedSize\r
+      );\r
+  }\r
+\r
+  //\r
+  // Adjust the allocated size and register table base address.\r
+  //\r
+  RegisterTable->AllocatedSize += EFI_PAGE_SIZE;\r
+  RegisterTable->RegisterTableEntry = Address;\r
+}\r
index 00907145a90175faba0a8bdd1315c94f649f6861..5e9ab2c30423c3b12ee37139cf7656fba4bc0397 100644 (file)
@@ -1,64 +1,64 @@
-## @file
-#  Register CPU Features Library PEI instance.
-#
-#  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.
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x00010005
-  BASE_NAME                      = PeiRegisterCpuFeaturesLib
-  MODULE_UNI_FILE                = PeiRegisterCpuFeaturesLib.uni
-  FILE_GUID                      = D8855DB3-8348-41B5-BDA4-385351767D41
-  MODULE_TYPE                    = PEIM
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = RegisterCpuFeaturesLib|PEIM
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-#  VALID_ARCHITECTURES           = IA32 X64
-#
-
-[Sources.common]
-  PeiRegisterCpuFeaturesLib.c
-  RegisterCpuFeaturesLib.c
-  RegisterCpuFeatures.h
-  CpuFeaturesInitialize.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  UefiCpuPkg/UefiCpuPkg.dec
-
-[LibraryClasses]
-  BaseLib
-  DebugLib
-  PcdLib
-  LocalApicLib
-  BaseMemoryLib
-  MemoryAllocationLib
-  SynchronizationLib
-  HobLib
-  PeiServicesLib
-  PeiServicesTablePointerLib
-  IoLib
-
-[Ppis]
-  gEfiPeiMpServicesPpiGuid                                             ## CONSUMES
-
-[Pcd]
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress                        ## CONSUMES
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport                      ## CONSUMES
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration            ## CONSUMES
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability                   ## PRODUCES
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting                      ## PRODUCES
-
-[Depex]
-  gEfiPeiMpServicesPpiGuid AND gEdkiiCpuFeaturesSetDoneGuid
+## @file\r
+#  Register CPU Features Library PEI instance.\r
+#\r
+#  Copyright (c) 2017, 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
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PeiRegisterCpuFeaturesLib\r
+  MODULE_UNI_FILE                = PeiRegisterCpuFeaturesLib.uni\r
+  FILE_GUID                      = D8855DB3-8348-41B5-BDA4-385351767D41\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = RegisterCpuFeaturesLib|PEIM\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources.common]\r
+  PeiRegisterCpuFeaturesLib.c\r
+  RegisterCpuFeaturesLib.c\r
+  RegisterCpuFeatures.h\r
+  CpuFeaturesInitialize.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
+  PcdLib\r
+  LocalApicLib\r
+  BaseMemoryLib\r
+  MemoryAllocationLib\r
+  SynchronizationLib\r
+  HobLib\r
+  PeiServicesLib\r
+  PeiServicesTablePointerLib\r
+  IoLib\r
+\r
+[Ppis]\r
+  gEfiPeiMpServicesPpiGuid                                             ## CONSUMES\r
+\r
+[Pcd]\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress                        ## CONSUMES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport                      ## CONSUMES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration            ## CONSUMES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability                   ## PRODUCES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting                      ## PRODUCES\r
+\r
+[Depex]\r
+  gEfiPeiMpServicesPpiGuid AND gEdkiiCpuFeaturesSetDoneGuid\r
index 11f8eb794def293e40009e3e4a9c9c84457d5d3a..7731f885b362d3501e78fde07707a8f2cb265ae4 100644 (file)
-/** @file
-  CPU Register Table Library definitions.
-
-  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.
-
-**/
-
-#ifndef _REGISTER_CPU_FEATURES_H_
-#define _REGISTER_CPU_FEATURES_H_
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/PcdLib.h>
-#include <Library/RegisterCpuFeaturesLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/SynchronizationLib.h>
-#include <Library/IoLib.h>
-
-#include <AcpiCpuData.h>
-
-#define CPU_FEATURE_ENTRY_SIGNATURE  SIGNATURE_32 ('C', 'F', 'E', 'S')
-
-#define CPU_FEATURE_NAME_SIZE        128
-
-typedef struct {
-  REGISTER_CPU_FEATURE_INFORMATION     CpuInfo;
-  UINT8                                *FeaturesSupportedMask;
-  LIST_ENTRY                           OrderList;
-} CPU_FEATURES_INIT_ORDER;
-
-typedef struct {
-  UINT32                       Signature;
-  LIST_ENTRY                   Link;
-  UINT8                        *FeatureMask;
-  CHAR8                        *FeatureName;
-  CPU_FEATURE_GET_CONFIG_DATA  GetConfigDataFunc;
-  CPU_FEATURE_SUPPORT          SupportFunc;
-  CPU_FEATURE_INITIALIZE       InitializeFunc;
-  UINT8                        *BeforeFeatureBitMask;
-  UINT8                        *AfterFeatureBitMask;
-  VOID                         *ConfigData;
-  BOOLEAN                      BeforeAll;
-  BOOLEAN                      AfterAll;
-} CPU_FEATURES_ENTRY;
-
-typedef struct {
-  UINTN                    FeaturesCount;
-  UINT32                   BitMaskSize;
-  SPIN_LOCK                MsrLock;
-  SPIN_LOCK                MemoryMappedLock;
-  LIST_ENTRY               FeatureList;
-
-  CPU_FEATURES_INIT_ORDER  *InitOrder;
-  UINT8                    *SupportPcds;
-  UINT8                    *CapabilityPcds;
-  UINT8                    *ConfigurationPcds;
-  UINT8                    *SettingPcds;
-
-  CPU_REGISTER_TABLE       *RegisterTable;
-  CPU_REGISTER_TABLE       *PreSmmRegisterTable;
-  UINTN                    BspNumber;
-} CPU_FEATURES_DATA;
-
-#define CPU_FEATURE_ENTRY_FROM_LINK(a) \
-  CR ( \
-  (a), \
-  CPU_FEATURES_ENTRY, \
-  Link, \
-  CPU_FEATURE_ENTRY_SIGNATURE \
-  )
-
-/**
-  Worker function to get CPU_FEATURES_DATA pointer.
-
-  @return Pointer to CPU_FEATURES_DATA.
-**/
-CPU_FEATURES_DATA *
-GetCpuFeaturesData (
-  VOID
-  );
-
-/**
-  Enlarges CPU register table for each processor.
-
-  @param[in, out]  RegisterTable   Pointer processor's CPU register table
-**/
-VOID
-EnlargeRegisterTable (
-  IN OUT CPU_REGISTER_TABLE            *RegisterTable
-  );
-
-/**
-  Allocates ACPI NVS memory to save ACPI_CPU_DATA.
-
-  @return  Pointer to allocated ACPI_CPU_DATA.
-**/
-ACPI_CPU_DATA *
-AllocateAcpiCpuData (
-  VOID
-  );
-
-/**
-  Worker function to return processor index.
-
-  @return  The processor index.
-**/
-UINTN
-GetProcessorIndex (
-  VOID
-  );
-
-/**
-  Gets detailed MP-related information on the requested processor at the
-  instant this call is made.
-
-  @param[in]  ProcessorNumber       The handle number of processor.
-  @param[out] ProcessorInfoBuffer   A pointer to the buffer where information for
-                                    the requested processor is deposited.
-
-  @return Status of MpServices->GetProcessorInfo().
-**/
-EFI_STATUS
-GetProcessorInformation (
-  IN  UINTN                            ProcessorNumber,
-  OUT EFI_PROCESSOR_INFORMATION        *ProcessorInfoBuffer
-  );
-
-/**
-  Worker function to execute a caller provided function on all enabled APs.
-
-  @param[in]  Procedure               A pointer to the function to be run on
-                                      enabled APs of the system.
-**/
-VOID
-StartupAPsWorker (
-  IN  EFI_AP_PROCEDURE                 Procedure
-  );
-
-/**
-  Worker function to retrieve the number of logical processor in the platform.
-
-  @param[out] NumberOfCpus                Pointer to the total number of logical
-                                          processors in the system, including the BSP
-                                          and disabled APs.
-  @param[out] NumberOfEnabledProcessors   Pointer to the number of enabled logical
-                                          processors that exist in system, including
-                                          the BSP.
-**/
-VOID
-GetNumberOfProcessor (
-  OUT UINTN                            *NumberOfCpus,
-  OUT UINTN                            *NumberOfEnabledProcessors
-  );
-
-/**
-  Worker function to switch the requested AP to be the BSP from that point onward.
-
-  @param[in] ProcessorNumber   The handle number of AP that is to become the new BSP.
-**/
-VOID
-SwitchNewBsp (
-  IN  UINTN                            ProcessorNumber
-  );
-
-/**
-  Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask.
-
-  @param[in]  FeatureMask  A pointer to the CPU feature bit mask.
-**/
-VOID
-DumpCpuFeatureMask (
-  IN UINT8               *FeatureMask
-  );
-
-/**
-  Dump CPU feature name or CPU feature bit mask.
-
-  @param[in]  CpuFeature   Pointer to CPU_FEATURES_ENTRY
-**/
-VOID
-DumpCpuFeature (
-  IN CPU_FEATURES_ENTRY  *CpuFeature
-  );
-
-#endif
+/** @file\r
+  CPU Register Table Library definitions.\r
+\r
+  Copyright (c) 2017, 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
+#ifndef _REGISTER_CPU_FEATURES_H_\r
+#define _REGISTER_CPU_FEATURES_H_\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/RegisterCpuFeaturesLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/SynchronizationLib.h>\r
+#include <Library/IoLib.h>\r
+\r
+#include <AcpiCpuData.h>\r
+\r
+#define CPU_FEATURE_ENTRY_SIGNATURE  SIGNATURE_32 ('C', 'F', 'E', 'S')\r
+\r
+#define CPU_FEATURE_NAME_SIZE        128\r
+\r
+typedef struct {\r
+  REGISTER_CPU_FEATURE_INFORMATION     CpuInfo;\r
+  UINT8                                *FeaturesSupportedMask;\r
+  LIST_ENTRY                           OrderList;\r
+} CPU_FEATURES_INIT_ORDER;\r
+\r
+typedef struct {\r
+  UINT32                       Signature;\r
+  LIST_ENTRY                   Link;\r
+  UINT8                        *FeatureMask;\r
+  CHAR8                        *FeatureName;\r
+  CPU_FEATURE_GET_CONFIG_DATA  GetConfigDataFunc;\r
+  CPU_FEATURE_SUPPORT          SupportFunc;\r
+  CPU_FEATURE_INITIALIZE       InitializeFunc;\r
+  UINT8                        *BeforeFeatureBitMask;\r
+  UINT8                        *AfterFeatureBitMask;\r
+  VOID                         *ConfigData;\r
+  BOOLEAN                      BeforeAll;\r
+  BOOLEAN                      AfterAll;\r
+} CPU_FEATURES_ENTRY;\r
+\r
+typedef struct {\r
+  UINTN                    FeaturesCount;\r
+  UINT32                   BitMaskSize;\r
+  SPIN_LOCK                MsrLock;\r
+  SPIN_LOCK                MemoryMappedLock;\r
+  LIST_ENTRY               FeatureList;\r
+\r
+  CPU_FEATURES_INIT_ORDER  *InitOrder;\r
+  UINT8                    *SupportPcds;\r
+  UINT8                    *CapabilityPcds;\r
+  UINT8                    *ConfigurationPcds;\r
+  UINT8                    *SettingPcds;\r
+\r
+  CPU_REGISTER_TABLE       *RegisterTable;\r
+  CPU_REGISTER_TABLE       *PreSmmRegisterTable;\r
+  UINTN                    BspNumber;\r
+} CPU_FEATURES_DATA;\r
+\r
+#define CPU_FEATURE_ENTRY_FROM_LINK(a) \\r
+  CR ( \\r
+  (a), \\r
+  CPU_FEATURES_ENTRY, \\r
+  Link, \\r
+  CPU_FEATURE_ENTRY_SIGNATURE \\r
+  )\r
+\r
+/**\r
+  Worker function to get CPU_FEATURES_DATA pointer.\r
+\r
+  @return Pointer to CPU_FEATURES_DATA.\r
+**/\r
+CPU_FEATURES_DATA *\r
+GetCpuFeaturesData (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Enlarges CPU register table for each processor.\r
+\r
+  @param[in, out]  RegisterTable   Pointer processor's CPU register table\r
+**/\r
+VOID\r
+EnlargeRegisterTable (\r
+  IN OUT CPU_REGISTER_TABLE            *RegisterTable\r
+  );\r
+\r
+/**\r
+  Allocates ACPI NVS memory to save ACPI_CPU_DATA.\r
+\r
+  @return  Pointer to allocated ACPI_CPU_DATA.\r
+**/\r
+ACPI_CPU_DATA *\r
+AllocateAcpiCpuData (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Worker function to return processor index.\r
+\r
+  @return  The processor index.\r
+**/\r
+UINTN\r
+GetProcessorIndex (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Gets detailed MP-related information on the requested processor at the\r
+  instant this call is made.\r
+\r
+  @param[in]  ProcessorNumber       The handle number of processor.\r
+  @param[out] ProcessorInfoBuffer   A pointer to the buffer where information for\r
+                                    the requested processor is deposited.\r
+\r
+  @return Status of MpServices->GetProcessorInfo().\r
+**/\r
+EFI_STATUS\r
+GetProcessorInformation (\r
+  IN  UINTN                            ProcessorNumber,\r
+  OUT EFI_PROCESSOR_INFORMATION        *ProcessorInfoBuffer\r
+  );\r
+\r
+/**\r
+  Worker function to execute a caller provided function on all enabled APs.\r
+\r
+  @param[in]  Procedure               A pointer to the function to be run on\r
+                                      enabled APs of the system.\r
+**/\r
+VOID\r
+StartupAPsWorker (\r
+  IN  EFI_AP_PROCEDURE                 Procedure\r
+  );\r
+\r
+/**\r
+  Worker function to retrieve the number of logical processor in the platform.\r
+\r
+  @param[out] NumberOfCpus                Pointer to the total number of logical\r
+                                          processors in the system, including the BSP\r
+                                          and disabled APs.\r
+  @param[out] NumberOfEnabledProcessors   Pointer to the number of enabled logical\r
+                                          processors that exist in system, including\r
+                                          the BSP.\r
+**/\r
+VOID\r
+GetNumberOfProcessor (\r
+  OUT UINTN                            *NumberOfCpus,\r
+  OUT UINTN                            *NumberOfEnabledProcessors\r
+  );\r
+\r
+/**\r
+  Worker function to switch the requested AP to be the BSP from that point onward.\r
+\r
+  @param[in] ProcessorNumber   The handle number of AP that is to become the new BSP.\r
+**/\r
+VOID\r
+SwitchNewBsp (\r
+  IN  UINTN                            ProcessorNumber\r
+  );\r
+\r
+/**\r
+  Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask.\r
+\r
+  @param[in]  FeatureMask  A pointer to the CPU feature bit mask.\r
+**/\r
+VOID\r
+DumpCpuFeatureMask (\r
+  IN UINT8               *FeatureMask\r
+  );\r
+\r
+/**\r
+  Dump CPU feature name or CPU feature bit mask.\r
+\r
+  @param[in]  CpuFeature   Pointer to CPU_FEATURES_ENTRY\r
+**/\r
+VOID\r
+DumpCpuFeature (\r
+  IN CPU_FEATURES_ENTRY  *CpuFeature\r
+  );\r
+\r
+#endif\r
index b0c313b1f092d23c7a711907a0a2c0605681d786..d9289525512d2121ec1da5cb57935bb03d2d14db 100644 (file)
@@ -1,22 +1,22 @@
-// /** @file
-// CPU Register Table Library instance.
-//
-// CPU Register Table Library instance.
-//
-// Copyright (c) 2016, 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT             #language en-US "CPU Register Table Library instance"
-
-#string STR_MODULE_DESCRIPTION          #language en-US "CPU Register Table Library instance."
-
+// /** @file\r
+// CPU Register Table Library instance.\r
+//\r
+// CPU Register Table Library instance.\r
+//\r
+// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+//\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
+\r
+#string STR_MODULE_ABSTRACT             #language en-US "CPU Register Table Library instance"\r
+\r
+#string STR_MODULE_DESCRIPTION          #language en-US "CPU Register Table Library instance."\r
+\r
index 7ef015537401b52e77fdcefa0aabbac447414c42..338f1a495cf4895f6ac638fe941b77923a80f27d 100644 (file)
-/** @file
-  CPU Register Table Library functions.
-
-  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 "RegisterCpuFeatures.h"
-
-/**
-  Checks if two CPU feature bit masks are equal.
-
-  @param[in]  FirstFeatureMask  The first input CPU feature bit mask
-  @param[in]  SecondFeatureMask The second input CPU feature bit mask
-
-  @retval TRUE  Two CPU feature bit masks are equal.
-  @retval FALSE Two CPU feature bit masks are not equal.
-**/
-BOOLEAN
-IsCpuFeatureMatch (
-  IN UINT8               *FirstFeatureMask,
-  IN UINT8               *SecondFeatureMask
-  )
-{
-  UINT32                 BitMaskSize;
-
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
-  if (CompareMem (FirstFeatureMask, SecondFeatureMask, BitMaskSize) == 0) {
-    return TRUE;
-  } else {
-    return FALSE;
-  }
-}
-
-/**
-  Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask.
-
-  @param[in]  FeatureMask  A pointer to the CPU feature bit mask.
-**/
-VOID
-DumpCpuFeatureMask (
-  IN UINT8               *FeatureMask
-  )
-{
-  UINTN                  Index;
-  UINT8                  *Data8;
-  UINT32                 BitMaskSize;
-
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
-  Data8       = (UINT8 *) FeatureMask;
-  for (Index = 0; Index < BitMaskSize; Index++) {
-    DEBUG ((DEBUG_INFO, " %02x ", *Data8++));
-  }
-  DEBUG ((DEBUG_INFO, "\n"));
-}
-
-/**
-  Dump CPU feature name or CPU feature bit mask.
-
-  @param[in]  CpuFeature   Pointer to CPU_FEATURES_ENTRY
-**/
-VOID
-DumpCpuFeature (
-  IN CPU_FEATURES_ENTRY  *CpuFeature
-  )
-{
-
-  if (CpuFeature->FeatureName != NULL) {
-    DEBUG ((DEBUG_INFO, "FeatureName: %a\n", CpuFeature->FeatureName));
-  } else {
-    DEBUG ((DEBUG_INFO, "FeatureMask = "));
-    DumpCpuFeatureMask (CpuFeature->FeatureMask);
-  }
-}
-
-/**
-  Determines if the feature bit mask is in dependent CPU feature bit mask buffer.
-
-  @param[in]  FeatureMask        Pointer to CPU feature bit mask
-  @param[in]  DependentBitMask   Pointer to dependent CPU feature bit mask buffer
-
-  @retval TRUE  The feature bit mask is in dependent CPU feature bit mask buffer.
-  @retval FALSE The feature bit mask is not in dependent CPU feature bit mask buffer.
-**/
-BOOLEAN
-IsBitMaskMatchCheck (
-  IN UINT8        *FeatureMask,
-  IN UINT8        *DependentBitMask
-  )
-{
-  UINTN      Index;
-  UINTN      BitMaskSize;
-  UINT8      *Data1;
-  UINT8      *Data2;
-
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
-
-  Data1 = FeatureMask;
-  Data2 = DependentBitMask;
-  for (Index = 0; Index < BitMaskSize; Index++) {
-    if (((*(Data1++)) & (*(Data2++))) != 0) {
-      return TRUE;
-    }
-  }
-  return FALSE;
-}
-
-/**
-  Checks and adjusts CPU features order per dependency relationship.
-
-  @param[in]  FeatureList        Pointer to CPU feature list
-**/
-VOID
-CheckCpuFeaturesDependency (
-  IN LIST_ENTRY              *FeatureList
-  )
-{
-  LIST_ENTRY                 *CurrentEntry;
-  CPU_FEATURES_ENTRY         *CpuFeature;
-  LIST_ENTRY                 *CheckEntry;
-  CPU_FEATURES_ENTRY         *CheckFeature;
-  BOOLEAN                    Swapped;
-  LIST_ENTRY                 *TempEntry;
-
-  CurrentEntry = GetFirstNode (FeatureList);
-  while (!IsNull (FeatureList, CurrentEntry)) {
-    Swapped = FALSE;
-    CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (CurrentEntry);
-    if (CpuFeature->BeforeAll) {
-      //
-      // Check all features dispatched before this entry
-      //
-      CheckEntry = GetFirstNode (FeatureList);
-      while (CheckEntry != CurrentEntry) {
-        CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry);
-        if (!CheckFeature->BeforeAll) {
-          //
-          // If this feature has no BeforeAll flag and is dispatched before CpuFeature,
-          // insert currentEntry before Checked feature
-          //
-          RemoveEntryList (CurrentEntry);
-          InsertTailList (CheckEntry, CurrentEntry);
-          Swapped = TRUE;
-          break;
-        }
-        CheckEntry = CheckEntry->ForwardLink;
-      }
-      if (Swapped) {
-        continue;
-      }
-    }
-
-    if (CpuFeature->AfterAll) {
-      //
-      // Check all features dispatched after this entry
-      //
-      CheckEntry = GetNextNode (FeatureList, CurrentEntry);
-      while (!IsNull (FeatureList, CheckEntry)) {
-        CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry);
-        if (!CheckFeature->AfterAll) {
-          //
-          // If this feature has no AfterAll flag and is dispatched after CpuFeature,
-          // insert currentEntry after Checked feature
-          //
-          TempEntry = GetNextNode (FeatureList, CurrentEntry);
-          RemoveEntryList (CurrentEntry);
-          InsertHeadList (CheckEntry, CurrentEntry);
-          CurrentEntry = TempEntry;
-          Swapped = TRUE;
-          break;
-        }
-        CheckEntry = CheckEntry->ForwardLink;
-      }
-      if (Swapped) {
-        continue;
-      }
-    }
-
-    if (CpuFeature->BeforeFeatureBitMask != NULL) {
-      //
-      // Check all features dispatched before this entry
-      //
-      CheckEntry = GetFirstNode (FeatureList);
-      while (CheckEntry != CurrentEntry) {
-        CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry);
-        if (IsBitMaskMatchCheck (CheckFeature->FeatureMask, CpuFeature->BeforeFeatureBitMask)) {
-          //
-          // If there is dependency, swap them
-          //
-          RemoveEntryList (CurrentEntry);
-          InsertTailList (CheckEntry, CurrentEntry);
-          Swapped = TRUE;
-          break;
-        }
-        CheckEntry = CheckEntry->ForwardLink;
-      }
-      if (Swapped) {
-        continue;
-      }
-    }
-
-    if (CpuFeature->AfterFeatureBitMask != NULL) {
-      //
-      // Check all features dispatched after this entry
-      //
-      CheckEntry = GetNextNode (FeatureList, CurrentEntry);
-      while (!IsNull (FeatureList, CheckEntry)) {
-        CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry);
-        if (IsBitMaskMatchCheck (CheckFeature->FeatureMask, CpuFeature->AfterFeatureBitMask)) {
-          //
-          // If there is dependency, swap them
-          //
-          TempEntry = GetNextNode (FeatureList, CurrentEntry);
-          RemoveEntryList (CurrentEntry);
-          InsertHeadList (CheckEntry, CurrentEntry);
-          CurrentEntry = TempEntry;
-          Swapped = TRUE;
-          break;
-        }
-        CheckEntry = CheckEntry->ForwardLink;
-      }
-      if (Swapped) {
-        continue;
-      }
-    }
-    //
-    // No swap happened, check the next feature
-    //
-    CurrentEntry = CurrentEntry->ForwardLink;
-  }
-}
-
-/**
-  Worker function to register CPU Feature.
-
-  @param[in]  CpuFeature            Pointer to CPU feature entry
-
-  @retval  RETURN_SUCCESS           The CPU feature was successfully registered.
-  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources to register
-                                    the CPU feature.
-  @retval  RETURN_UNSUPPORTED       Registration of the CPU feature is not
-                                    supported due to a circular dependency between
-                                    BEFORE and AFTER features.
-**/
-RETURN_STATUS
-RegisterCpuFeatureWorker (
-  IN CPU_FEATURES_ENTRY      *CpuFeature
-  )
-{
-  EFI_STATUS                 Status;
-  CPU_FEATURES_DATA          *CpuFeaturesData;
-  CPU_FEATURES_ENTRY         *CpuFeatureEntry;
-  LIST_ENTRY                 *Entry;
-  UINT32                     BitMaskSize;
-  BOOLEAN                    FeatureExist;
-
-  BitMaskSize     = PcdGetSize (PcdCpuFeaturesSupport);
-  CpuFeaturesData = GetCpuFeaturesData ();
-  if (CpuFeaturesData->FeaturesCount == 0) {
-    InitializeListHead (&CpuFeaturesData->FeatureList);
-    InitializeSpinLock (&CpuFeaturesData->MsrLock);
-    InitializeSpinLock (&CpuFeaturesData->MemoryMappedLock);
-    CpuFeaturesData->BitMaskSize = BitMaskSize;
-  }
-  ASSERT (CpuFeaturesData->BitMaskSize == BitMaskSize);
-
-  FeatureExist = FALSE;
-  CpuFeatureEntry = NULL;
-  Entry = GetFirstNode (&CpuFeaturesData->FeatureList);
-  while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {
-    CpuFeatureEntry = CPU_FEATURE_ENTRY_FROM_LINK (Entry);
-    if (IsCpuFeatureMatch (CpuFeature->FeatureMask, CpuFeatureEntry->FeatureMask)) {
-      //
-      // If this feature already registered
-      //
-      FeatureExist = TRUE;
-      break;
-    }
-    Entry = Entry->ForwardLink;
-  }
-
-  if (!FeatureExist) {
-    DEBUG ((DEBUG_INFO, "[NEW] "));
-    DumpCpuFeature (CpuFeature);
-    InsertTailList (&CpuFeaturesData->FeatureList, &CpuFeature->Link);
-    CpuFeaturesData->FeaturesCount++;
-  } else {
-    DEBUG ((DEBUG_INFO, "[OVERRIDE] "));
-    DumpCpuFeature (CpuFeature);
-    ASSERT (CpuFeatureEntry != NULL);
-    //
-    // Overwrite original parameters of CPU feature
-    //
-    if (CpuFeature->GetConfigDataFunc != NULL) {
-      CpuFeatureEntry->GetConfigDataFunc = CpuFeature->GetConfigDataFunc;
-    }
-    if (CpuFeature->SupportFunc != NULL) {
-      CpuFeatureEntry->SupportFunc = CpuFeature->SupportFunc;
-    }
-    if (CpuFeature->InitializeFunc != NULL) {
-      CpuFeatureEntry->InitializeFunc = CpuFeature->InitializeFunc;
-    }
-    if (CpuFeature->FeatureName != NULL) {
-      if (CpuFeatureEntry->FeatureName == NULL) {
-        CpuFeatureEntry->FeatureName = AllocatePool (CPU_FEATURE_NAME_SIZE);
-        ASSERT (CpuFeatureEntry->FeatureName != NULL);
-      }
-      Status = AsciiStrCpyS (CpuFeatureEntry->FeatureName, CPU_FEATURE_NAME_SIZE, CpuFeature->FeatureName);
-      ASSERT_EFI_ERROR (Status);
-      FreePool (CpuFeature->FeatureName);
-    }
-    if (CpuFeature->BeforeFeatureBitMask != NULL) {
-      if (CpuFeatureEntry->BeforeFeatureBitMask != NULL) {
-        FreePool (CpuFeatureEntry->BeforeFeatureBitMask);
-      }
-      CpuFeatureEntry->BeforeFeatureBitMask = CpuFeature->BeforeFeatureBitMask;
-    }
-    if (CpuFeature->AfterFeatureBitMask != NULL) {
-      if (CpuFeatureEntry->AfterFeatureBitMask != NULL) {
-        FreePool (CpuFeatureEntry->AfterFeatureBitMask);
-      }
-      CpuFeatureEntry->AfterFeatureBitMask = CpuFeature->AfterFeatureBitMask;
-    }
-    CpuFeatureEntry->BeforeAll = CpuFeature->BeforeAll;
-    CpuFeatureEntry->AfterAll  = CpuFeature->AfterAll;
-
-    FreePool (CpuFeature->FeatureMask);
-    FreePool (CpuFeature);
-  }
-  //
-  // Verify CPU features dependency can change CPU feature order
-  //
-  CheckCpuFeaturesDependency (&CpuFeaturesData->FeatureList);
-  return RETURN_SUCCESS;
-}
-
-/**
-  Sets CPU feature bit mask in CPU feature bit mask buffer.
-
-  @param[in]  FeaturesBitMask       Pointer to CPU feature bit mask buffer
-  @param[in]  Feature               The bit number of the CPU feature
-  @param[in]  BitMaskSize           CPU feature bit mask buffer size
-**/
-VOID
-SetCpuFeaturesBitMask (
-  IN UINT8               **FeaturesBitMask,
-  IN UINT32              Feature,
-  IN UINTN               BitMaskSize
-  )
-{
-  UINT8                  *CpuFeaturesBitMask;
-
-  ASSERT (FeaturesBitMask != NULL);
-  CpuFeaturesBitMask = *FeaturesBitMask;
-  if (CpuFeaturesBitMask == NULL) {
-    CpuFeaturesBitMask = AllocateZeroPool (BitMaskSize);
-    ASSERT (CpuFeaturesBitMask != NULL);
-    *FeaturesBitMask = CpuFeaturesBitMask;
-  }
-
-  CpuFeaturesBitMask  += (Feature / 8);
-  *CpuFeaturesBitMask |= (UINT8) (1 << (Feature % 8));
-}
-
-/**
-  Registers a CPU Feature.
-
-  @param[in]  FeatureName        A Null-terminated Ascii string indicates CPU feature
-                                 name.
-  @param[in]  GetConfigDataFunc  CPU feature get configuration data function.  This
-                                 is an optional parameter that may be NULL.  If NULL,
-                                 then the most recently registered function for the
-                                 CPU feature is used.  If no functions are registered
-                                 for a CPU feature, then the CPU configuration data
-                                 for the registered feature is NULL.
-  @param[in]  SupportFunc        CPU feature support function.  This is an optional
-                                 parameter that may be NULL.  If NULL, then the most
-                                 recently registered function for the CPU feature is
-                                 used. If no functions are registered for a CPU
-                                 feature, then the CPU feature is assumed to be
-                                 supported by all CPUs.
-  @param[in]  InitializeFunc     CPU feature initialize function.  This is an optional
-                                 parameter that may be NULL.  If NULL, then the most
-                                 recently registered function for the CPU feature is
-                                 used. If no functions are registered for a CPU
-                                 feature, then the CPU feature initialization is
-                                 skipped.
-  @param[in]  ...                Variable argument list of UINT32 CPU feature value.
-                                 Values with no modifiers are the features provided
-                                 by the registered functions.
-                                 Values with CPU_FEATURE_BEFORE modifier are features
-                                 that must be initialized after the features provided
-                                 by the registered functions are used.
-                                 Values with CPU_FEATURE_AFTER modifier are features
-                                 that must be initialized before the features provided
-                                 by the registered functions are used.
-                                 The last argument in this variable argument list must
-                                 always be CPU_FEATURE_END.
-
-  @retval  RETURN_SUCCESS           The CPU feature was successfully registered.
-  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources to register
-                                    the CPU feature.
-  @retval  RETURN_UNSUPPORTED       Registration of the CPU feature is not
-                                    supported due to a circular dependency between
-                                    BEFORE and AFTER features.
-
-  @note This service could be called by BSP only.
-**/
-RETURN_STATUS
-EFIAPI
-RegisterCpuFeature (
-  IN CHAR8                             *FeatureName,       OPTIONAL
-  IN CPU_FEATURE_GET_CONFIG_DATA       GetConfigDataFunc,  OPTIONAL
-  IN CPU_FEATURE_SUPPORT               SupportFunc,        OPTIONAL
-  IN CPU_FEATURE_INITIALIZE            InitializeFunc,     OPTIONAL
-  ...
-  )
-{
-  EFI_STATUS                 Status;
-  VA_LIST                    Marker;
-  UINT32                     Feature;
-  UINTN                      BitMaskSize;
-  CPU_FEATURES_ENTRY         *CpuFeature;
-  UINT8                      *FeatureMask;
-  UINT8                      *BeforeFeatureBitMask;
-  UINT8                      *AfterFeatureBitMask;
-  BOOLEAN                    BeforeAll;
-  BOOLEAN                    AfterAll;
-
-  FeatureMask          = NULL;
-  BeforeFeatureBitMask = NULL;
-  AfterFeatureBitMask  = NULL;
-  BeforeAll            = FALSE;
-  AfterAll             = FALSE;
-
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);
-
-  VA_START (Marker, InitializeFunc);
-  Feature = VA_ARG (Marker, UINT32);
-  while (Feature != CPU_FEATURE_END) {
-    ASSERT ((Feature & (CPU_FEATURE_BEFORE | CPU_FEATURE_AFTER))
-                    != (CPU_FEATURE_BEFORE | CPU_FEATURE_AFTER));
-    ASSERT ((Feature & (CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL))
-                    != (CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL));
-    if (Feature < CPU_FEATURE_BEFORE) {
-      BeforeAll = ((Feature & CPU_FEATURE_BEFORE_ALL) != 0) ? TRUE : FALSE;
-      AfterAll  = ((Feature & CPU_FEATURE_AFTER_ALL) != 0) ? TRUE : FALSE;
-      Feature  &= ~(CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL);
-      ASSERT (FeatureMask == NULL);
-      SetCpuFeaturesBitMask (&FeatureMask, Feature, BitMaskSize);
-    } else if ((Feature & CPU_FEATURE_BEFORE) != 0) {
-      SetCpuFeaturesBitMask (&BeforeFeatureBitMask, Feature & ~CPU_FEATURE_BEFORE, BitMaskSize);
-    } else if ((Feature & CPU_FEATURE_AFTER) != 0) {
-      SetCpuFeaturesBitMask (&AfterFeatureBitMask, Feature & ~CPU_FEATURE_AFTER, BitMaskSize);
-    }
-    Feature = VA_ARG (Marker, UINT32);
-  }
-  VA_END (Marker);
-
-  CpuFeature = AllocateZeroPool (sizeof (CPU_FEATURES_ENTRY));
-  ASSERT (CpuFeature != NULL);
-  CpuFeature->Signature            = CPU_FEATURE_ENTRY_SIGNATURE;
-  CpuFeature->FeatureMask          = FeatureMask;
-  CpuFeature->BeforeFeatureBitMask = BeforeFeatureBitMask;
-  CpuFeature->AfterFeatureBitMask  = AfterFeatureBitMask;
-  CpuFeature->BeforeAll            = BeforeAll;
-  CpuFeature->AfterAll             = AfterAll;
-  CpuFeature->GetConfigDataFunc    = GetConfigDataFunc;
-  CpuFeature->SupportFunc          = SupportFunc;
-  CpuFeature->InitializeFunc       = InitializeFunc;
-  if (FeatureName != NULL) {
-    CpuFeature->FeatureName          = AllocatePool (CPU_FEATURE_NAME_SIZE);
-    ASSERT (CpuFeature->FeatureName != NULL);
-    Status = AsciiStrCpyS (CpuFeature->FeatureName, CPU_FEATURE_NAME_SIZE, FeatureName);
-    ASSERT_EFI_ERROR (Status);
-  }
-
-  Status = RegisterCpuFeatureWorker (CpuFeature);
-  ASSERT_EFI_ERROR (Status);
-
-  return RETURN_SUCCESS;
-}
-
-/**
-  Add an entry in specified register table.
-
-  This function adds an entry in specified register table, with given register type,
-  register index, bit section and value.
-
-  @param[in]  PreSmmFlag       If TRUE, entry will be added into PreSmm register table
-                               If FALSE, entry will be added into register table
-  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry
-  @param[in]  RegisterType     Type of the register to program
-  @param[in]  Index            Index of the register to program
-  @param[in]  ValidBitStart    Start of the bit section
-  @param[in]  ValidBitLength   Length of the bit section
-  @param[in]  Value            Value to write
-**/
-VOID
-CpuRegisterTableWriteWorker (
-  IN BOOLEAN                 PreSmmFlag,
-  IN UINTN                   ProcessorNumber,
-  IN REGISTER_TYPE           RegisterType,
-  IN UINT64                  Index,
-  IN UINT8                   ValidBitStart,
-  IN UINT8                   ValidBitLength,
-  IN UINT64                  Value
-  )
-{
-  EFI_STATUS               Status;
-  CPU_FEATURES_DATA        *CpuFeaturesData;
-  ACPI_CPU_DATA            *AcpiCpuData;
-  CPU_REGISTER_TABLE       *RegisterTable;
-  CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry;
-
-  CpuFeaturesData = GetCpuFeaturesData ();
-  if (CpuFeaturesData->RegisterTable == NULL) {
-    AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) PcdGet64 (PcdCpuS3DataAddress);
-    if (AcpiCpuData == NULL) {
-      AcpiCpuData = AllocateAcpiCpuData ();
-      ASSERT (AcpiCpuData != NULL);
-      //
-      // Set PcdCpuS3DataAddress to the base address of the ACPI_CPU_DATA structure
-      //
-      Status = PcdSet64S (PcdCpuS3DataAddress, (UINT64)(UINTN)AcpiCpuData);
-      ASSERT_EFI_ERROR (Status);
-    }
-    ASSERT (AcpiCpuData->RegisterTable != 0);
-    CpuFeaturesData->RegisterTable = (CPU_REGISTER_TABLE *) (UINTN) AcpiCpuData->RegisterTable;
-    CpuFeaturesData->PreSmmRegisterTable = (CPU_REGISTER_TABLE *) (UINTN) AcpiCpuData->PreSmmInitRegisterTable;
-  }
-
-  if (PreSmmFlag) {
-    RegisterTable = &CpuFeaturesData->PreSmmRegisterTable[ProcessorNumber];
-  } else {
-    RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber];
-  }
-
-  if (RegisterTable->TableLength == RegisterTable->AllocatedSize / sizeof (CPU_REGISTER_TABLE_ENTRY)) {
-    EnlargeRegisterTable (RegisterTable);
-  }
-
-  //
-  // Append entry in the register table.
-  //
-  RegisterTableEntry = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry;
-  RegisterTableEntry[RegisterTable->TableLength].RegisterType   = RegisterType;
-  RegisterTableEntry[RegisterTable->TableLength].Index          = (UINT32) Index;
-  RegisterTableEntry[RegisterTable->TableLength].HighIndex      = (UINT32) RShiftU64 (Index, 32);
-  RegisterTableEntry[RegisterTable->TableLength].ValidBitStart  = ValidBitStart;
-  RegisterTableEntry[RegisterTable->TableLength].ValidBitLength = ValidBitLength;
-  RegisterTableEntry[RegisterTable->TableLength].Value          = Value;
-
-  RegisterTable->TableLength++;
-}
-
-/**
-  Adds an entry in specified register table.
-
-  This function adds an entry in specified register table, with given register type,
-  register index, bit section and value.
-
-  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry
-  @param[in]  RegisterType     Type of the register to program
-  @param[in]  Index            Index of the register to program
-  @param[in]  ValueMask        Mask of bits in register to write
-  @param[in]  Value            Value to write
-
-  @note This service could be called by BSP only.
-**/
-VOID
-EFIAPI
-CpuRegisterTableWrite (
-  IN UINTN               ProcessorNumber,
-  IN REGISTER_TYPE       RegisterType,
-  IN UINT64              Index,
-  IN UINT64              ValueMask,
-  IN UINT64              Value
-  )
-{
-  UINT8                   Start;
-  UINT8                   End;
-  UINT8                   Length;
-
-  Start  = (UINT8)LowBitSet64  (ValueMask);
-  End    = (UINT8)HighBitSet64 (ValueMask);
-  Length = End - Start + 1;
-  CpuRegisterTableWriteWorker (FALSE, ProcessorNumber, RegisterType, Index, Start, Length, Value);
-}
-
-/**
-  Adds an entry in specified Pre-SMM register table.
-
-  This function adds an entry in specified register table, with given register type,
-  register index, bit section and value.
-
-  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.
-  @param[in]  RegisterType     Type of the register to program
-  @param[in]  Index            Index of the register to program
-  @param[in]  ValueMask        Mask of bits in register to write
-  @param[in]  Value            Value to write
-
-  @note This service could be called by BSP only.
-**/
-VOID
-EFIAPI
-PreSmmCpuRegisterTableWrite (
-  IN UINTN               ProcessorNumber,
-  IN REGISTER_TYPE       RegisterType,
-  IN UINT64              Index,
-  IN UINT64              ValueMask,
-  IN UINT64              Value
-  )
-{
-  UINT8  Start;
-  UINT8  End;
-  UINT8  Length;
-
-  Start  = (UINT8)LowBitSet64  (ValueMask);
-  End    = (UINT8)HighBitSet64 (ValueMask);
-  Length = End - Start + 1;
-  CpuRegisterTableWriteWorker (TRUE, ProcessorNumber, RegisterType, Index, Start, Length, Value);
-}
-
-/**
-  Worker function to determine if a CPU feature is set in input CPU feature bit mask buffer.
-
-  @param[in]  CpuBitMask      CPU feature bit mask buffer
-  @param[in]  CpuBitMaskSize  The size of CPU feature bit mask buffer
-  @param[in]  Feature         The bit number of the CPU feature
-
-  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesSupport.
-  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesSupport.
-
-**/
-BOOLEAN
-IsCpuFeatureSetInCpuPcd (
-  IN UINT8               *CpuBitMask,
-  IN UINTN               CpuBitMaskSize,
-  IN UINT32              Feature
-  )
-{
-  if ((Feature >> 3) >= CpuBitMaskSize) {
-    return FALSE;
-  }
-  return ((*(CpuBitMask + (Feature >> 3)) & (1 << (Feature & 0x07))) != 0);
-}
-
-/**
-  Determines if a CPU feature is enabled in PcdCpuFeaturesSupport bit mask.
-  If a CPU feature is disabled in PcdCpuFeaturesSupport then all the code/data
-  associated with that feature should be optimized away if compiler
-  optimizations are enabled.
-
-  @param[in]  Feature  The bit number of the CPU feature to check in the PCD
-                       PcdCpuFeaturesSupport
-
-  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesSupport.
-  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesSupport.
-
-  @note This service could be called by BSP only.
-**/
-BOOLEAN
-EFIAPI
-IsCpuFeatureSupported (
-  IN UINT32              Feature
-  )
-{
-  return IsCpuFeatureSetInCpuPcd (
-           (UINT8 *)PcdGetPtr (PcdCpuFeaturesSupport),
-           PcdGetSize (PcdCpuFeaturesSupport),
-           Feature
-           );
-}
-
-/**
-  Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask.
-
-  @param[in]  Feature  The bit number of the CPU feature to check in the PCD
-                       PcdCpuFeaturesSetting
-
-  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesSetting.
-  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesSetting.
-
-  @note This service could be called by BSP only.
-**/
-BOOLEAN
-EFIAPI
-IsCpuFeatureInSetting (
-  IN UINT32              Feature
-  )
-{
-  return IsCpuFeatureSetInCpuPcd (
-           (UINT8 *)PcdGetPtr (PcdCpuFeaturesSetting),
-           PcdGetSize (PcdCpuFeaturesSetting),
-           Feature
-           );
-}
-
-/**
-  Determines if a CPU feature is set in PcdCpuFeaturesCapability bit mask.
-
-  @param[in]  Feature  The bit number of the CPU feature to check in the PCD
-                       PcdCpuFeaturesCapability
-
-  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesCapability.
-  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesCapability.
-
-  @note This service could be called by BSP only.
-**/
-BOOLEAN
-EFIAPI
-IsCpuFeatureCapability (
-  IN UINT32              Feature
-  )
-{
-  return IsCpuFeatureSetInCpuPcd (
-           (UINT8 *)PcdGetPtr (PcdCpuFeaturesCapability),
-           PcdGetSize (PcdCpuFeaturesCapability),
-           Feature
-           );
-
-}
-
-/**
-  Determines if a CPU feature is set in PcdCpuFeaturesUserConfiguration bit mask.
-
-  @param[in]  Feature  The bit number of the CPU feature to check in the PCD
-                       PcdCpuFeaturesUserConfiguration
-
-  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesUserConfiguration.
-  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesUserConfiguration.
-
-  @note This service could be called by BSP only.
-**/
-BOOLEAN
-EFIAPI
-IsCpuFeatureUserConfiguration (
-  IN UINT32              Feature
-  )
-{
-  return IsCpuFeatureSetInCpuPcd (
-           (UINT8 *)PcdGetPtr (PcdCpuFeaturesUserConfiguration),
-           PcdGetSize (PcdCpuFeaturesUserConfiguration),
-           Feature
-           );
-
-}
-
-/**
-  Switches to assigned BSP after CPU features initialization.
-
-  @param[in]  ProcessorNumber  The index of the CPU executing this function.
-
-  @note This service could be called by BSP only.
-**/
-VOID
-EFIAPI
-SwitchBspAfterFeaturesInitialize (
-  IN UINTN               ProcessorNumber
-  )
-{
-  CPU_FEATURES_DATA      *CpuFeaturesData;
-
-  CpuFeaturesData = GetCpuFeaturesData ();
-  CpuFeaturesData->BspNumber = ProcessorNumber;
-}
-
+/** @file\r
+  CPU Register Table Library functions.\r
+\r
+  Copyright (c) 2017, 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 "RegisterCpuFeatures.h"\r
+\r
+/**\r
+  Checks if two CPU feature bit masks are equal.\r
+\r
+  @param[in]  FirstFeatureMask  The first input CPU feature bit mask\r
+  @param[in]  SecondFeatureMask The second input CPU feature bit mask\r
+\r
+  @retval TRUE  Two CPU feature bit masks are equal.\r
+  @retval FALSE Two CPU feature bit masks are not equal.\r
+**/\r
+BOOLEAN\r
+IsCpuFeatureMatch (\r
+  IN UINT8               *FirstFeatureMask,\r
+  IN UINT8               *SecondFeatureMask\r
+  )\r
+{\r
+  UINT32                 BitMaskSize;\r
+\r
+  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
+  if (CompareMem (FirstFeatureMask, SecondFeatureMask, BitMaskSize) == 0) {\r
+    return TRUE;\r
+  } else {\r
+    return FALSE;\r
+  }\r
+}\r
+\r
+/**\r
+  Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask.\r
+\r
+  @param[in]  FeatureMask  A pointer to the CPU feature bit mask.\r
+**/\r
+VOID\r
+DumpCpuFeatureMask (\r
+  IN UINT8               *FeatureMask\r
+  )\r
+{\r
+  UINTN                  Index;\r
+  UINT8                  *Data8;\r
+  UINT32                 BitMaskSize;\r
+\r
+  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
+  Data8       = (UINT8 *) FeatureMask;\r
+  for (Index = 0; Index < BitMaskSize; Index++) {\r
+    DEBUG ((DEBUG_INFO, " %02x ", *Data8++));\r
+  }\r
+  DEBUG ((DEBUG_INFO, "\n"));\r
+}\r
+\r
+/**\r
+  Dump CPU feature name or CPU feature bit mask.\r
+\r
+  @param[in]  CpuFeature   Pointer to CPU_FEATURES_ENTRY\r
+**/\r
+VOID\r
+DumpCpuFeature (\r
+  IN CPU_FEATURES_ENTRY  *CpuFeature\r
+  )\r
+{\r
+\r
+  if (CpuFeature->FeatureName != NULL) {\r
+    DEBUG ((DEBUG_INFO, "FeatureName: %a\n", CpuFeature->FeatureName));\r
+  } else {\r
+    DEBUG ((DEBUG_INFO, "FeatureMask = "));\r
+    DumpCpuFeatureMask (CpuFeature->FeatureMask);\r
+  }\r
+}\r
+\r
+/**\r
+  Determines if the feature bit mask is in dependent CPU feature bit mask buffer.\r
+\r
+  @param[in]  FeatureMask        Pointer to CPU feature bit mask\r
+  @param[in]  DependentBitMask   Pointer to dependent CPU feature bit mask buffer\r
+\r
+  @retval TRUE  The feature bit mask is in dependent CPU feature bit mask buffer.\r
+  @retval FALSE The feature bit mask is not in dependent CPU feature bit mask buffer.\r
+**/\r
+BOOLEAN\r
+IsBitMaskMatchCheck (\r
+  IN UINT8        *FeatureMask,\r
+  IN UINT8        *DependentBitMask\r
+  )\r
+{\r
+  UINTN      Index;\r
+  UINTN      BitMaskSize;\r
+  UINT8      *Data1;\r
+  UINT8      *Data2;\r
+\r
+  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
+\r
+  Data1 = FeatureMask;\r
+  Data2 = DependentBitMask;\r
+  for (Index = 0; Index < BitMaskSize; Index++) {\r
+    if (((*(Data1++)) & (*(Data2++))) != 0) {\r
+      return TRUE;\r
+    }\r
+  }\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Checks and adjusts CPU features order per dependency relationship.\r
+\r
+  @param[in]  FeatureList        Pointer to CPU feature list\r
+**/\r
+VOID\r
+CheckCpuFeaturesDependency (\r
+  IN LIST_ENTRY              *FeatureList\r
+  )\r
+{\r
+  LIST_ENTRY                 *CurrentEntry;\r
+  CPU_FEATURES_ENTRY         *CpuFeature;\r
+  LIST_ENTRY                 *CheckEntry;\r
+  CPU_FEATURES_ENTRY         *CheckFeature;\r
+  BOOLEAN                    Swapped;\r
+  LIST_ENTRY                 *TempEntry;\r
+\r
+  CurrentEntry = GetFirstNode (FeatureList);\r
+  while (!IsNull (FeatureList, CurrentEntry)) {\r
+    Swapped = FALSE;\r
+    CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (CurrentEntry);\r
+    if (CpuFeature->BeforeAll) {\r
+      //\r
+      // Check all features dispatched before this entry\r
+      //\r
+      CheckEntry = GetFirstNode (FeatureList);\r
+      while (CheckEntry != CurrentEntry) {\r
+        CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry);\r
+        if (!CheckFeature->BeforeAll) {\r
+          //\r
+          // If this feature has no BeforeAll flag and is dispatched before CpuFeature,\r
+          // insert currentEntry before Checked feature\r
+          //\r
+          RemoveEntryList (CurrentEntry);\r
+          InsertTailList (CheckEntry, CurrentEntry);\r
+          Swapped = TRUE;\r
+          break;\r
+        }\r
+        CheckEntry = CheckEntry->ForwardLink;\r
+      }\r
+      if (Swapped) {\r
+        continue;\r
+      }\r
+    }\r
+\r
+    if (CpuFeature->AfterAll) {\r
+      //\r
+      // Check all features dispatched after this entry\r
+      //\r
+      CheckEntry = GetNextNode (FeatureList, CurrentEntry);\r
+      while (!IsNull (FeatureList, CheckEntry)) {\r
+        CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry);\r
+        if (!CheckFeature->AfterAll) {\r
+          //\r
+          // If this feature has no AfterAll flag and is dispatched after CpuFeature,\r
+          // insert currentEntry after Checked feature\r
+          //\r
+          TempEntry = GetNextNode (FeatureList, CurrentEntry);\r
+          RemoveEntryList (CurrentEntry);\r
+          InsertHeadList (CheckEntry, CurrentEntry);\r
+          CurrentEntry = TempEntry;\r
+          Swapped = TRUE;\r
+          break;\r
+        }\r
+        CheckEntry = CheckEntry->ForwardLink;\r
+      }\r
+      if (Swapped) {\r
+        continue;\r
+      }\r
+    }\r
+\r
+    if (CpuFeature->BeforeFeatureBitMask != NULL) {\r
+      //\r
+      // Check all features dispatched before this entry\r
+      //\r
+      CheckEntry = GetFirstNode (FeatureList);\r
+      while (CheckEntry != CurrentEntry) {\r
+        CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry);\r
+        if (IsBitMaskMatchCheck (CheckFeature->FeatureMask, CpuFeature->BeforeFeatureBitMask)) {\r
+          //\r
+          // If there is dependency, swap them\r
+          //\r
+          RemoveEntryList (CurrentEntry);\r
+          InsertTailList (CheckEntry, CurrentEntry);\r
+          Swapped = TRUE;\r
+          break;\r
+        }\r
+        CheckEntry = CheckEntry->ForwardLink;\r
+      }\r
+      if (Swapped) {\r
+        continue;\r
+      }\r
+    }\r
+\r
+    if (CpuFeature->AfterFeatureBitMask != NULL) {\r
+      //\r
+      // Check all features dispatched after this entry\r
+      //\r
+      CheckEntry = GetNextNode (FeatureList, CurrentEntry);\r
+      while (!IsNull (FeatureList, CheckEntry)) {\r
+        CheckFeature = CPU_FEATURE_ENTRY_FROM_LINK (CheckEntry);\r
+        if (IsBitMaskMatchCheck (CheckFeature->FeatureMask, CpuFeature->AfterFeatureBitMask)) {\r
+          //\r
+          // If there is dependency, swap them\r
+          //\r
+          TempEntry = GetNextNode (FeatureList, CurrentEntry);\r
+          RemoveEntryList (CurrentEntry);\r
+          InsertHeadList (CheckEntry, CurrentEntry);\r
+          CurrentEntry = TempEntry;\r
+          Swapped = TRUE;\r
+          break;\r
+        }\r
+        CheckEntry = CheckEntry->ForwardLink;\r
+      }\r
+      if (Swapped) {\r
+        continue;\r
+      }\r
+    }\r
+    //\r
+    // No swap happened, check the next feature\r
+    //\r
+    CurrentEntry = CurrentEntry->ForwardLink;\r
+  }\r
+}\r
+\r
+/**\r
+  Worker function to register CPU Feature.\r
+\r
+  @param[in]  CpuFeature            Pointer to CPU feature entry\r
+\r
+  @retval  RETURN_SUCCESS           The CPU feature was successfully registered.\r
+  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources to register\r
+                                    the CPU feature.\r
+  @retval  RETURN_UNSUPPORTED       Registration of the CPU feature is not\r
+                                    supported due to a circular dependency between\r
+                                    BEFORE and AFTER features.\r
+**/\r
+RETURN_STATUS\r
+RegisterCpuFeatureWorker (\r
+  IN CPU_FEATURES_ENTRY      *CpuFeature\r
+  )\r
+{\r
+  EFI_STATUS                 Status;\r
+  CPU_FEATURES_DATA          *CpuFeaturesData;\r
+  CPU_FEATURES_ENTRY         *CpuFeatureEntry;\r
+  LIST_ENTRY                 *Entry;\r
+  UINT32                     BitMaskSize;\r
+  BOOLEAN                    FeatureExist;\r
+\r
+  BitMaskSize     = PcdGetSize (PcdCpuFeaturesSupport);\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+  if (CpuFeaturesData->FeaturesCount == 0) {\r
+    InitializeListHead (&CpuFeaturesData->FeatureList);\r
+    InitializeSpinLock (&CpuFeaturesData->MsrLock);\r
+    InitializeSpinLock (&CpuFeaturesData->MemoryMappedLock);\r
+    CpuFeaturesData->BitMaskSize = BitMaskSize;\r
+  }\r
+  ASSERT (CpuFeaturesData->BitMaskSize == BitMaskSize);\r
+\r
+  FeatureExist = FALSE;\r
+  CpuFeatureEntry = NULL;\r
+  Entry = GetFirstNode (&CpuFeaturesData->FeatureList);\r
+  while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {\r
+    CpuFeatureEntry = CPU_FEATURE_ENTRY_FROM_LINK (Entry);\r
+    if (IsCpuFeatureMatch (CpuFeature->FeatureMask, CpuFeatureEntry->FeatureMask)) {\r
+      //\r
+      // If this feature already registered\r
+      //\r
+      FeatureExist = TRUE;\r
+      break;\r
+    }\r
+    Entry = Entry->ForwardLink;\r
+  }\r
+\r
+  if (!FeatureExist) {\r
+    DEBUG ((DEBUG_INFO, "[NEW] "));\r
+    DumpCpuFeature (CpuFeature);\r
+    InsertTailList (&CpuFeaturesData->FeatureList, &CpuFeature->Link);\r
+    CpuFeaturesData->FeaturesCount++;\r
+  } else {\r
+    DEBUG ((DEBUG_INFO, "[OVERRIDE] "));\r
+    DumpCpuFeature (CpuFeature);\r
+    ASSERT (CpuFeatureEntry != NULL);\r
+    //\r
+    // Overwrite original parameters of CPU feature\r
+    //\r
+    if (CpuFeature->GetConfigDataFunc != NULL) {\r
+      CpuFeatureEntry->GetConfigDataFunc = CpuFeature->GetConfigDataFunc;\r
+    }\r
+    if (CpuFeature->SupportFunc != NULL) {\r
+      CpuFeatureEntry->SupportFunc = CpuFeature->SupportFunc;\r
+    }\r
+    if (CpuFeature->InitializeFunc != NULL) {\r
+      CpuFeatureEntry->InitializeFunc = CpuFeature->InitializeFunc;\r
+    }\r
+    if (CpuFeature->FeatureName != NULL) {\r
+      if (CpuFeatureEntry->FeatureName == NULL) {\r
+        CpuFeatureEntry->FeatureName = AllocatePool (CPU_FEATURE_NAME_SIZE);\r
+        ASSERT (CpuFeatureEntry->FeatureName != NULL);\r
+      }\r
+      Status = AsciiStrCpyS (CpuFeatureEntry->FeatureName, CPU_FEATURE_NAME_SIZE, CpuFeature->FeatureName);\r
+      ASSERT_EFI_ERROR (Status);\r
+      FreePool (CpuFeature->FeatureName);\r
+    }\r
+    if (CpuFeature->BeforeFeatureBitMask != NULL) {\r
+      if (CpuFeatureEntry->BeforeFeatureBitMask != NULL) {\r
+        FreePool (CpuFeatureEntry->BeforeFeatureBitMask);\r
+      }\r
+      CpuFeatureEntry->BeforeFeatureBitMask = CpuFeature->BeforeFeatureBitMask;\r
+    }\r
+    if (CpuFeature->AfterFeatureBitMask != NULL) {\r
+      if (CpuFeatureEntry->AfterFeatureBitMask != NULL) {\r
+        FreePool (CpuFeatureEntry->AfterFeatureBitMask);\r
+      }\r
+      CpuFeatureEntry->AfterFeatureBitMask = CpuFeature->AfterFeatureBitMask;\r
+    }\r
+    CpuFeatureEntry->BeforeAll = CpuFeature->BeforeAll;\r
+    CpuFeatureEntry->AfterAll  = CpuFeature->AfterAll;\r
+\r
+    FreePool (CpuFeature->FeatureMask);\r
+    FreePool (CpuFeature);\r
+  }\r
+  //\r
+  // Verify CPU features dependency can change CPU feature order\r
+  //\r
+  CheckCpuFeaturesDependency (&CpuFeaturesData->FeatureList);\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Sets CPU feature bit mask in CPU feature bit mask buffer.\r
+\r
+  @param[in]  FeaturesBitMask       Pointer to CPU feature bit mask buffer\r
+  @param[in]  Feature               The bit number of the CPU feature\r
+  @param[in]  BitMaskSize           CPU feature bit mask buffer size\r
+**/\r
+VOID\r
+SetCpuFeaturesBitMask (\r
+  IN UINT8               **FeaturesBitMask,\r
+  IN UINT32              Feature,\r
+  IN UINTN               BitMaskSize\r
+  )\r
+{\r
+  UINT8                  *CpuFeaturesBitMask;\r
+\r
+  ASSERT (FeaturesBitMask != NULL);\r
+  CpuFeaturesBitMask = *FeaturesBitMask;\r
+  if (CpuFeaturesBitMask == NULL) {\r
+    CpuFeaturesBitMask = AllocateZeroPool (BitMaskSize);\r
+    ASSERT (CpuFeaturesBitMask != NULL);\r
+    *FeaturesBitMask = CpuFeaturesBitMask;\r
+  }\r
+\r
+  CpuFeaturesBitMask  += (Feature / 8);\r
+  *CpuFeaturesBitMask |= (UINT8) (1 << (Feature % 8));\r
+}\r
+\r
+/**\r
+  Registers a CPU Feature.\r
+\r
+  @param[in]  FeatureName        A Null-terminated Ascii string indicates CPU feature\r
+                                 name.\r
+  @param[in]  GetConfigDataFunc  CPU feature get configuration data function.  This\r
+                                 is an optional parameter that may be NULL.  If NULL,\r
+                                 then the most recently registered function for the\r
+                                 CPU feature is used.  If no functions are registered\r
+                                 for a CPU feature, then the CPU configuration data\r
+                                 for the registered feature is NULL.\r
+  @param[in]  SupportFunc        CPU feature support function.  This is an optional\r
+                                 parameter that may be NULL.  If NULL, then the most\r
+                                 recently registered function for the CPU feature is\r
+                                 used. If no functions are registered for a CPU\r
+                                 feature, then the CPU feature is assumed to be\r
+                                 supported by all CPUs.\r
+  @param[in]  InitializeFunc     CPU feature initialize function.  This is an optional\r
+                                 parameter that may be NULL.  If NULL, then the most\r
+                                 recently registered function for the CPU feature is\r
+                                 used. If no functions are registered for a CPU\r
+                                 feature, then the CPU feature initialization is\r
+                                 skipped.\r
+  @param[in]  ...                Variable argument list of UINT32 CPU feature value.\r
+                                 Values with no modifiers are the features provided\r
+                                 by the registered functions.\r
+                                 Values with CPU_FEATURE_BEFORE modifier are features\r
+                                 that must be initialized after the features provided\r
+                                 by the registered functions are used.\r
+                                 Values with CPU_FEATURE_AFTER modifier are features\r
+                                 that must be initialized before the features provided\r
+                                 by the registered functions are used.\r
+                                 The last argument in this variable argument list must\r
+                                 always be CPU_FEATURE_END.\r
+\r
+  @retval  RETURN_SUCCESS           The CPU feature was successfully registered.\r
+  @retval  RETURN_OUT_OF_RESOURCES  There are not enough resources to register\r
+                                    the CPU feature.\r
+  @retval  RETURN_UNSUPPORTED       Registration of the CPU feature is not\r
+                                    supported due to a circular dependency between\r
+                                    BEFORE and AFTER features.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+RegisterCpuFeature (\r
+  IN CHAR8                             *FeatureName,       OPTIONAL\r
+  IN CPU_FEATURE_GET_CONFIG_DATA       GetConfigDataFunc,  OPTIONAL\r
+  IN CPU_FEATURE_SUPPORT               SupportFunc,        OPTIONAL\r
+  IN CPU_FEATURE_INITIALIZE            InitializeFunc,     OPTIONAL\r
+  ...\r
+  )\r
+{\r
+  EFI_STATUS                 Status;\r
+  VA_LIST                    Marker;\r
+  UINT32                     Feature;\r
+  UINTN                      BitMaskSize;\r
+  CPU_FEATURES_ENTRY         *CpuFeature;\r
+  UINT8                      *FeatureMask;\r
+  UINT8                      *BeforeFeatureBitMask;\r
+  UINT8                      *AfterFeatureBitMask;\r
+  BOOLEAN                    BeforeAll;\r
+  BOOLEAN                    AfterAll;\r
+\r
+  FeatureMask          = NULL;\r
+  BeforeFeatureBitMask = NULL;\r
+  AfterFeatureBitMask  = NULL;\r
+  BeforeAll            = FALSE;\r
+  AfterAll             = FALSE;\r
+\r
+  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
+\r
+  VA_START (Marker, InitializeFunc);\r
+  Feature = VA_ARG (Marker, UINT32);\r
+  while (Feature != CPU_FEATURE_END) {\r
+    ASSERT ((Feature & (CPU_FEATURE_BEFORE | CPU_FEATURE_AFTER))\r
+                    != (CPU_FEATURE_BEFORE | CPU_FEATURE_AFTER));\r
+    ASSERT ((Feature & (CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL))\r
+                    != (CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL));\r
+    if (Feature < CPU_FEATURE_BEFORE) {\r
+      BeforeAll = ((Feature & CPU_FEATURE_BEFORE_ALL) != 0) ? TRUE : FALSE;\r
+      AfterAll  = ((Feature & CPU_FEATURE_AFTER_ALL) != 0) ? TRUE : FALSE;\r
+      Feature  &= ~(CPU_FEATURE_BEFORE_ALL | CPU_FEATURE_AFTER_ALL);\r
+      ASSERT (FeatureMask == NULL);\r
+      SetCpuFeaturesBitMask (&FeatureMask, Feature, BitMaskSize);\r
+    } else if ((Feature & CPU_FEATURE_BEFORE) != 0) {\r
+      SetCpuFeaturesBitMask (&BeforeFeatureBitMask, Feature & ~CPU_FEATURE_BEFORE, BitMaskSize);\r
+    } else if ((Feature & CPU_FEATURE_AFTER) != 0) {\r
+      SetCpuFeaturesBitMask (&AfterFeatureBitMask, Feature & ~CPU_FEATURE_AFTER, BitMaskSize);\r
+    }\r
+    Feature = VA_ARG (Marker, UINT32);\r
+  }\r
+  VA_END (Marker);\r
+\r
+  CpuFeature = AllocateZeroPool (sizeof (CPU_FEATURES_ENTRY));\r
+  ASSERT (CpuFeature != NULL);\r
+  CpuFeature->Signature            = CPU_FEATURE_ENTRY_SIGNATURE;\r
+  CpuFeature->FeatureMask          = FeatureMask;\r
+  CpuFeature->BeforeFeatureBitMask = BeforeFeatureBitMask;\r
+  CpuFeature->AfterFeatureBitMask  = AfterFeatureBitMask;\r
+  CpuFeature->BeforeAll            = BeforeAll;\r
+  CpuFeature->AfterAll             = AfterAll;\r
+  CpuFeature->GetConfigDataFunc    = GetConfigDataFunc;\r
+  CpuFeature->SupportFunc          = SupportFunc;\r
+  CpuFeature->InitializeFunc       = InitializeFunc;\r
+  if (FeatureName != NULL) {\r
+    CpuFeature->FeatureName          = AllocatePool (CPU_FEATURE_NAME_SIZE);\r
+    ASSERT (CpuFeature->FeatureName != NULL);\r
+    Status = AsciiStrCpyS (CpuFeature->FeatureName, CPU_FEATURE_NAME_SIZE, FeatureName);\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  Status = RegisterCpuFeatureWorker (CpuFeature);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Add an entry in specified register table.\r
+\r
+  This function adds an entry in specified register table, with given register type,\r
+  register index, bit section and value.\r
+\r
+  @param[in]  PreSmmFlag       If TRUE, entry will be added into PreSmm register table\r
+                               If FALSE, entry will be added into register table\r
+  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry\r
+  @param[in]  RegisterType     Type of the register to program\r
+  @param[in]  Index            Index of the register to program\r
+  @param[in]  ValidBitStart    Start of the bit section\r
+  @param[in]  ValidBitLength   Length of the bit section\r
+  @param[in]  Value            Value to write\r
+**/\r
+VOID\r
+CpuRegisterTableWriteWorker (\r
+  IN BOOLEAN                 PreSmmFlag,\r
+  IN UINTN                   ProcessorNumber,\r
+  IN REGISTER_TYPE           RegisterType,\r
+  IN UINT64                  Index,\r
+  IN UINT8                   ValidBitStart,\r
+  IN UINT8                   ValidBitLength,\r
+  IN UINT64                  Value\r
+  )\r
+{\r
+  EFI_STATUS               Status;\r
+  CPU_FEATURES_DATA        *CpuFeaturesData;\r
+  ACPI_CPU_DATA            *AcpiCpuData;\r
+  CPU_REGISTER_TABLE       *RegisterTable;\r
+  CPU_REGISTER_TABLE_ENTRY *RegisterTableEntry;\r
+\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+  if (CpuFeaturesData->RegisterTable == NULL) {\r
+    AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) PcdGet64 (PcdCpuS3DataAddress);\r
+    if (AcpiCpuData == NULL) {\r
+      AcpiCpuData = AllocateAcpiCpuData ();\r
+      ASSERT (AcpiCpuData != NULL);\r
+      //\r
+      // Set PcdCpuS3DataAddress to the base address of the ACPI_CPU_DATA structure\r
+      //\r
+      Status = PcdSet64S (PcdCpuS3DataAddress, (UINT64)(UINTN)AcpiCpuData);\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+    ASSERT (AcpiCpuData->RegisterTable != 0);\r
+    CpuFeaturesData->RegisterTable = (CPU_REGISTER_TABLE *) (UINTN) AcpiCpuData->RegisterTable;\r
+    CpuFeaturesData->PreSmmRegisterTable = (CPU_REGISTER_TABLE *) (UINTN) AcpiCpuData->PreSmmInitRegisterTable;\r
+  }\r
+\r
+  if (PreSmmFlag) {\r
+    RegisterTable = &CpuFeaturesData->PreSmmRegisterTable[ProcessorNumber];\r
+  } else {\r
+    RegisterTable = &CpuFeaturesData->RegisterTable[ProcessorNumber];\r
+  }\r
+\r
+  if (RegisterTable->TableLength == RegisterTable->AllocatedSize / sizeof (CPU_REGISTER_TABLE_ENTRY)) {\r
+    EnlargeRegisterTable (RegisterTable);\r
+  }\r
+\r
+  //\r
+  // Append entry in the register table.\r
+  //\r
+  RegisterTableEntry = (CPU_REGISTER_TABLE_ENTRY *) (UINTN) RegisterTable->RegisterTableEntry;\r
+  RegisterTableEntry[RegisterTable->TableLength].RegisterType   = RegisterType;\r
+  RegisterTableEntry[RegisterTable->TableLength].Index          = (UINT32) Index;\r
+  RegisterTableEntry[RegisterTable->TableLength].HighIndex      = (UINT32) RShiftU64 (Index, 32);\r
+  RegisterTableEntry[RegisterTable->TableLength].ValidBitStart  = ValidBitStart;\r
+  RegisterTableEntry[RegisterTable->TableLength].ValidBitLength = ValidBitLength;\r
+  RegisterTableEntry[RegisterTable->TableLength].Value          = Value;\r
+\r
+  RegisterTable->TableLength++;\r
+}\r
+\r
+/**\r
+  Adds an entry in specified register table.\r
+\r
+  This function adds an entry in specified register table, with given register type,\r
+  register index, bit section and value.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry\r
+  @param[in]  RegisterType     Type of the register to program\r
+  @param[in]  Index            Index of the register to program\r
+  @param[in]  ValueMask        Mask of bits in register to write\r
+  @param[in]  Value            Value to write\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuRegisterTableWrite (\r
+  IN UINTN               ProcessorNumber,\r
+  IN REGISTER_TYPE       RegisterType,\r
+  IN UINT64              Index,\r
+  IN UINT64              ValueMask,\r
+  IN UINT64              Value\r
+  )\r
+{\r
+  UINT8                   Start;\r
+  UINT8                   End;\r
+  UINT8                   Length;\r
+\r
+  Start  = (UINT8)LowBitSet64  (ValueMask);\r
+  End    = (UINT8)HighBitSet64 (ValueMask);\r
+  Length = End - Start + 1;\r
+  CpuRegisterTableWriteWorker (FALSE, ProcessorNumber, RegisterType, Index, Start, Length, Value);\r
+}\r
+\r
+/**\r
+  Adds an entry in specified Pre-SMM register table.\r
+\r
+  This function adds an entry in specified register table, with given register type,\r
+  register index, bit section and value.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU to add a register table entry.\r
+  @param[in]  RegisterType     Type of the register to program\r
+  @param[in]  Index            Index of the register to program\r
+  @param[in]  ValueMask        Mask of bits in register to write\r
+  @param[in]  Value            Value to write\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID\r
+EFIAPI\r
+PreSmmCpuRegisterTableWrite (\r
+  IN UINTN               ProcessorNumber,\r
+  IN REGISTER_TYPE       RegisterType,\r
+  IN UINT64              Index,\r
+  IN UINT64              ValueMask,\r
+  IN UINT64              Value\r
+  )\r
+{\r
+  UINT8  Start;\r
+  UINT8  End;\r
+  UINT8  Length;\r
+\r
+  Start  = (UINT8)LowBitSet64  (ValueMask);\r
+  End    = (UINT8)HighBitSet64 (ValueMask);\r
+  Length = End - Start + 1;\r
+  CpuRegisterTableWriteWorker (TRUE, ProcessorNumber, RegisterType, Index, Start, Length, Value);\r
+}\r
+\r
+/**\r
+  Worker function to determine if a CPU feature is set in input CPU feature bit mask buffer.\r
+\r
+  @param[in]  CpuBitMask      CPU feature bit mask buffer\r
+  @param[in]  CpuBitMaskSize  The size of CPU feature bit mask buffer\r
+  @param[in]  Feature         The bit number of the CPU feature\r
+\r
+  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesSupport.\r
+  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesSupport.\r
+\r
+**/\r
+BOOLEAN\r
+IsCpuFeatureSetInCpuPcd (\r
+  IN UINT8               *CpuBitMask,\r
+  IN UINTN               CpuBitMaskSize,\r
+  IN UINT32              Feature\r
+  )\r
+{\r
+  if ((Feature >> 3) >= CpuBitMaskSize) {\r
+    return FALSE;\r
+  }\r
+  return ((*(CpuBitMask + (Feature >> 3)) & (1 << (Feature & 0x07))) != 0);\r
+}\r
+\r
+/**\r
+  Determines if a CPU feature is enabled in PcdCpuFeaturesSupport bit mask.\r
+  If a CPU feature is disabled in PcdCpuFeaturesSupport then all the code/data\r
+  associated with that feature should be optimized away if compiler\r
+  optimizations are enabled.\r
+\r
+  @param[in]  Feature  The bit number of the CPU feature to check in the PCD\r
+                       PcdCpuFeaturesSupport\r
+\r
+  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesSupport.\r
+  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesSupport.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsCpuFeatureSupported (\r
+  IN UINT32              Feature\r
+  )\r
+{\r
+  return IsCpuFeatureSetInCpuPcd (\r
+           (UINT8 *)PcdGetPtr (PcdCpuFeaturesSupport),\r
+           PcdGetSize (PcdCpuFeaturesSupport),\r
+           Feature\r
+           );\r
+}\r
+\r
+/**\r
+  Determines if a CPU feature is set in PcdCpuFeaturesSetting bit mask.\r
+\r
+  @param[in]  Feature  The bit number of the CPU feature to check in the PCD\r
+                       PcdCpuFeaturesSetting\r
+\r
+  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesSetting.\r
+  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesSetting.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsCpuFeatureInSetting (\r
+  IN UINT32              Feature\r
+  )\r
+{\r
+  return IsCpuFeatureSetInCpuPcd (\r
+           (UINT8 *)PcdGetPtr (PcdCpuFeaturesSetting),\r
+           PcdGetSize (PcdCpuFeaturesSetting),\r
+           Feature\r
+           );\r
+}\r
+\r
+/**\r
+  Determines if a CPU feature is set in PcdCpuFeaturesCapability bit mask.\r
+\r
+  @param[in]  Feature  The bit number of the CPU feature to check in the PCD\r
+                       PcdCpuFeaturesCapability\r
+\r
+  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesCapability.\r
+  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesCapability.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsCpuFeatureCapability (\r
+  IN UINT32              Feature\r
+  )\r
+{\r
+  return IsCpuFeatureSetInCpuPcd (\r
+           (UINT8 *)PcdGetPtr (PcdCpuFeaturesCapability),\r
+           PcdGetSize (PcdCpuFeaturesCapability),\r
+           Feature\r
+           );\r
+\r
+}\r
+\r
+/**\r
+  Determines if a CPU feature is set in PcdCpuFeaturesUserConfiguration bit mask.\r
+\r
+  @param[in]  Feature  The bit number of the CPU feature to check in the PCD\r
+                       PcdCpuFeaturesUserConfiguration\r
+\r
+  @retval  TRUE   The CPU feature is set in PcdCpuFeaturesUserConfiguration.\r
+  @retval  FALSE  The CPU feature is not set in PcdCpuFeaturesUserConfiguration.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsCpuFeatureUserConfiguration (\r
+  IN UINT32              Feature\r
+  )\r
+{\r
+  return IsCpuFeatureSetInCpuPcd (\r
+           (UINT8 *)PcdGetPtr (PcdCpuFeaturesUserConfiguration),\r
+           PcdGetSize (PcdCpuFeaturesUserConfiguration),\r
+           Feature\r
+           );\r
+\r
+}\r
+\r
+/**\r
+  Switches to assigned BSP after CPU features initialization.\r
+\r
+  @param[in]  ProcessorNumber  The index of the CPU executing this function.\r
+\r
+  @note This service could be called by BSP only.\r
+**/\r
+VOID\r
+EFIAPI\r
+SwitchBspAfterFeaturesInitialize (\r
+  IN UINTN               ProcessorNumber\r
+  )\r
+{\r
+  CPU_FEATURES_DATA      *CpuFeaturesData;\r
+\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+  CpuFeaturesData->BspNumber = ProcessorNumber;\r
+}\r
+\r