UefiCpuPkg/CpuFeatures: Change files format to DOS

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Jeff Fan 2017-04-05 16:33:16 +08:00
parent 028db58d1f
commit 80c4b23638
35 changed files with 6076 additions and 6076 deletions

View File

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

View File

@ -1,53 +1,53 @@
## @file ## @file
# CPU Features DXE driver. # CPU Features DXE driver.
# #
# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # 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 # which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php # http://opensource.org/licenses/bsd-license.php
# #
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# #
## ##
[Defines] [Defines]
INF_VERSION = 0x00010005 INF_VERSION = 0x00010005
BASE_NAME = CpuFeaturesDxe BASE_NAME = CpuFeaturesDxe
MODULE_UNI_FILE = CpuFeaturesDxe.uni MODULE_UNI_FILE = CpuFeaturesDxe.uni
FILE_GUID = 63EB1B62-10C9-4693-88AC-AE0999EA87F8 FILE_GUID = 63EB1B62-10C9-4693-88AC-AE0999EA87F8
MODULE_TYPE = DXE_DRIVER MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0 VERSION_STRING = 1.0
ENTRY_POINT = CpuFeaturesDxeInitialize ENTRY_POINT = CpuFeaturesDxeInitialize
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
UefiCpuPkg/UefiCpuPkg.dec UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses] [LibraryClasses]
BaseLib BaseLib
DebugLib DebugLib
UefiLib UefiLib
UefiDriverEntryPoint UefiDriverEntryPoint
UefiBootServicesTableLib UefiBootServicesTableLib
RegisterCpuFeaturesLib RegisterCpuFeaturesLib
[Sources] [Sources]
CpuFeaturesDxe.c CpuFeaturesDxe.c
[Guids] [Guids]
gEdkiiCpuFeaturesInitDoneGuid ## PRODUCES ## UNDEFINED # protocol GUID installed gEdkiiCpuFeaturesInitDoneGuid ## PRODUCES ## UNDEFINED # protocol GUID installed
[Protocols] [Protocols]
gEfiSmmConfigurationProtocolGuid ## NOTIFY gEfiSmmConfigurationProtocolGuid ## NOTIFY
[Pcd] [Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitAfterSmmRelocation ## CONSUMES
[Depex] [Depex]
TRUE TRUE
[UserExtensions.TianoCore."ExtraFiles"] [UserExtensions.TianoCore."ExtraFiles"]
CpuFeaturesDxeExtra.uni CpuFeaturesDxeExtra.uni

View File

@ -1,22 +1,22 @@
// /** @file // /** @file
// CPU Features DXE driver. // CPU Features DXE driver.
// //
// CPU Features DXE driver. // CPU Features DXE driver.
// //
// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> // Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
// //
// This program and the accompanying materials // This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License // 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 // which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php // http://opensource.org/licenses/bsd-license.php
// //
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // 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_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." #string STR_MODULE_DESCRIPTION #language en-US "CPU Features DXE driver to initialize CPU features."

View File

@ -1,20 +1,20 @@
// /** @file // /** @file
// CpuFeaturesDxe Localized Strings and Content // CpuFeaturesDxe Localized Strings and Content
// //
// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> // Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
// //
// This program and the accompanying materials // This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License // 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 // which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php // http://opensource.org/licenses/bsd-license.php
// //
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// //
// **/ // **/
#string STR_PROPERTIES_MODULE_NAME #string STR_PROPERTIES_MODULE_NAME
#language en-US #language en-US
"CPU Features DXE Driver" "CPU Features DXE Driver"

View File

@ -1,75 +1,75 @@
/** @file /** @file
CPU Features PEIM driver to initialize CPU features. CPU Features PEIM driver to initialize CPU features.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include <PiPei.h> #include <PiPei.h>
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/PeiServicesLib.h> #include <Library/PeiServicesLib.h>
#include <Library/RegisterCpuFeaturesLib.h> #include <Library/RegisterCpuFeaturesLib.h>
#include <Guid/CpuFeaturesInitDone.h> #include <Guid/CpuFeaturesInitDone.h>
EFI_PEI_PPI_DESCRIPTOR mPeiCpuFeaturesInitDonePpiDesc = { EFI_PEI_PPI_DESCRIPTOR mPeiCpuFeaturesInitDonePpiDesc = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEdkiiCpuFeaturesInitDoneGuid, &gEdkiiCpuFeaturesInitDoneGuid,
NULL NULL
}; };
/** /**
CPU Features driver entry point function. CPU Features driver entry point function.
It will perform CPU features initialization, except for It will perform CPU features initialization, except for
PcdCpuFeaturesInitOnS3Resume is FALSE on S3 resume. PcdCpuFeaturesInitOnS3Resume is FALSE on S3 resume.
@param FileHandle Handle of the file being invoked. @param FileHandle Handle of the file being invoked.
@param PeiServices Describes the list of possible PEI Services. @param PeiServices Describes the list of possible PEI Services.
@retval EFI_SUCCESS CPU Features is initialized successfully. @retval EFI_SUCCESS CPU Features is initialized successfully.
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
CpuFeaturesPeimInitialize ( CpuFeaturesPeimInitialize (
IN EFI_PEI_FILE_HANDLE FileHandle, IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices IN CONST EFI_PEI_SERVICES **PeiServices
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_BOOT_MODE BootMode; EFI_BOOT_MODE BootMode;
Status = PeiServicesGetBootMode (&BootMode); Status = PeiServicesGetBootMode (&BootMode);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (BootMode == BOOT_ON_S3_RESUME && if (BootMode == BOOT_ON_S3_RESUME &&
!PcdGetBool (PcdCpuFeaturesInitOnS3Resume)) { !PcdGetBool (PcdCpuFeaturesInitOnS3Resume)) {
// //
// Does nothing when if PcdCpuFeaturesInitOnS3Resume is FLASE // Does nothing when if PcdCpuFeaturesInitOnS3Resume is FLASE
// on S3 boot mode // on S3 boot mode
// //
return EFI_SUCCESS; return EFI_SUCCESS;
} }
CpuFeaturesDetect (); CpuFeaturesDetect ();
CpuFeaturesInitialize (); CpuFeaturesInitialize ();
// //
// Install CPU Features Init Done PPI // Install CPU Features Init Done PPI
// //
Status = PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc); Status = PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -1,49 +1,49 @@
## @file ## @file
# CPU Features PEIM driver. # CPU Features PEIM driver.
# #
# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # 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 # which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php # http://opensource.org/licenses/bsd-license.php
# #
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# #
## ##
[Defines] [Defines]
INF_VERSION = 0x00010005 INF_VERSION = 0x00010005
BASE_NAME = CpuFeaturesPei BASE_NAME = CpuFeaturesPei
MODULE_UNI_FILE = CpuFeaturesPei.uni MODULE_UNI_FILE = CpuFeaturesPei.uni
FILE_GUID = 183BB3E1-A1E5-4445-8AC9-0E83B6547E0E FILE_GUID = 183BB3E1-A1E5-4445-8AC9-0E83B6547E0E
MODULE_TYPE = PEIM MODULE_TYPE = PEIM
VERSION_STRING = 1.0 VERSION_STRING = 1.0
ENTRY_POINT = CpuFeaturesPeimInitialize ENTRY_POINT = CpuFeaturesPeimInitialize
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
UefiCpuPkg/UefiCpuPkg.dec UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses] [LibraryClasses]
BaseLib BaseLib
DebugLib DebugLib
PeimEntryPoint PeimEntryPoint
PeiServicesLib PeiServicesLib
RegisterCpuFeaturesLib RegisterCpuFeaturesLib
[Sources] [Sources]
CpuFeaturesPei.c CpuFeaturesPei.c
[Guids] [Guids]
gEdkiiCpuFeaturesInitDoneGuid ## PRODUCES ## UNDEFINED # PPI GUID installed gEdkiiCpuFeaturesInitDoneGuid ## PRODUCES ## UNDEFINED # PPI GUID installed
[Pcd] [Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesInitOnS3Resume ## CONSUMES
[Depex] [Depex]
TRUE TRUE
[UserExtensions.TianoCore."ExtraFiles"] [UserExtensions.TianoCore."ExtraFiles"]
CpuFeaturesPeiExtra.uni CpuFeaturesPeiExtra.uni

View File

@ -1,22 +1,22 @@
// /** @file // /** @file
// CPU Features PEIM driver. // CPU Features PEIM driver.
// //
// CPU Features PEIM driver. // CPU Features PEIM driver.
// //
// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> // Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
// //
// This program and the accompanying materials // This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License // 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 // which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php // http://opensource.org/licenses/bsd-license.php
// //
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // 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_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." #string STR_MODULE_DESCRIPTION #language en-US "CPU Features PEIM driver to initialize CPU features."

View File

@ -1,20 +1,20 @@
// /** @file // /** @file
// CpuFeaturesPei Localized Strings and Content // CpuFeaturesPei Localized Strings and Content
// //
// Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> // Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
// //
// This program and the accompanying materials // This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License // 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 // which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php // http://opensource.org/licenses/bsd-license.php
// //
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// //
// **/ // **/
#string STR_PROPERTIES_MODULE_NAME #string STR_PROPERTIES_MODULE_NAME
#language en-US #language en-US
"CPU Features PEIM Driver" "CPU Features PEIM Driver"

View File

@ -1,26 +1,26 @@
/** @file /** @file
CPU Features Init Done PPI/Protocol should be installed after CPU features CPU Features Init Done PPI/Protocol should be installed after CPU features
are initialized. are initialized.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#ifndef _CPU_FEATURES_INIT_DONE_H_ #ifndef _CPU_FEATURES_INIT_DONE_H_
#define _CPU_FEATURES_INIT_DONE_H_ #define _CPU_FEATURES_INIT_DONE_H_
#define EDKII_CPU_FEATURES_INIT_DONE_GUID \ #define EDKII_CPU_FEATURES_INIT_DONE_GUID \
{ \ { \
{ 0xc77c3a41, 0x61ab, 0x4143, { 0x98, 0x3e, 0x33, 0x39, 0x28, 0x6, 0x28, 0xe5 } \ { 0xc77c3a41, 0x61ab, 0x4143, { 0x98, 0x3e, 0x33, 0x39, 0x28, 0x6, 0x28, 0xe5 } \
} }
extern EFI_GUID gEdkiiCpuFeaturesInitDoneGuid; extern EFI_GUID gEdkiiCpuFeaturesInitDoneGuid;
#endif #endif

View File

@ -1,26 +1,26 @@
/** @file /** @file
CPU Features Set Done PPI/Protocol should be installed after CPU features CPU Features Set Done PPI/Protocol should be installed after CPU features
configuration are set. configuration are set.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#ifndef _CPU_FEATURES_INIT_DONE_H_ #ifndef _CPU_FEATURES_INIT_DONE_H_
#define _CPU_FEATURES_INIT_DONE_H_ #define _CPU_FEATURES_INIT_DONE_H_
#define EDKII_CPU_FEATURES_SET_DONE_GUID \ #define EDKII_CPU_FEATURES_SET_DONE_GUID \
{ \ { \
{ 0xa82485ce, 0xad6b, 0x4101, { 0x99, 0xd3, 0xe1, 0x35, 0x8c, 0x9e, 0x7e, 0x37 } \ { 0xa82485ce, 0xad6b, 0x4101, { 0x99, 0xd3, 0xe1, 0x35, 0x8c, 0x9e, 0x7e, 0x37 } \
} }
extern EFI_GUID gEdkiiCpuFeaturesSetDoneGuid; extern EFI_GUID gEdkiiCpuFeaturesSetDoneGuid;
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,127 +1,127 @@
/** @file /** @file
AESNI feature. AESNI feature.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Prepares for the data used by CPU feature detection and initialization. Prepares for the data used by CPU feature detection and initialization.
@param[in] NumberOfProcessors The number of CPUs in the platform. @param[in] NumberOfProcessors The number of CPUs in the platform.
@return Pointer to a buffer of CPU related configuration data. @return Pointer to a buffer of CPU related configuration data.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
VOID * VOID *
EFIAPI EFIAPI
AesniGetConfigData ( AesniGetConfigData (
IN UINTN NumberOfProcessors IN UINTN NumberOfProcessors
) )
{ {
UINT64 *ConfigData; UINT64 *ConfigData;
ConfigData = AllocateZeroPool (sizeof (UINT64) * NumberOfProcessors); ConfigData = AllocateZeroPool (sizeof (UINT64) * NumberOfProcessors);
ASSERT (ConfigData != NULL); ASSERT (ConfigData != NULL);
return ConfigData; return ConfigData;
} }
/** /**
Detects if AESNI feature supported on current processor. Detects if AESNI feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE AESNI feature is supported. @retval TRUE AESNI feature is supported.
@retval FALSE AESNI feature is not supported. @retval FALSE AESNI feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
AesniSupport ( AesniSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *MsrFeatureConfig; MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *MsrFeatureConfig;
if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
IS_XEON_5600_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || IS_XEON_5600_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
IS_XEON_E7_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || IS_XEON_E7_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) { IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData; MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData;
MsrFeatureConfig[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG); MsrFeatureConfig[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG);
return (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI == 1); return (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI == 1);
} }
return FALSE; return FALSE;
} }
/** /**
Initializes AESNI feature to specific state. Initializes AESNI feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the AESNI feature must be enabled. @param[in] State If TRUE, then the AESNI feature must be enabled.
If FALSE, then the AESNI feature must be disabled. If FALSE, then the AESNI feature must be disabled.
@retval RETURN_SUCCESS AESNI feature is initialized. @retval RETURN_SUCCESS AESNI feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
AesniInitialize ( AesniInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *MsrFeatureConfig; MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *MsrFeatureConfig;
// //
// SANDY_BRIDGE, SILVERMONT, XEON_5600, XEON_7, and XEON_PHI have the same MSR index, // SANDY_BRIDGE, SILVERMONT, XEON_5600, XEON_7, and XEON_PHI have the same MSR index,
// Simply use MSR_SANDY_BRIDGE_FEATURE_CONFIG here // 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 // 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 // of each core. Otherwise, once a thread in the core disabled AES, the other thread will cause GP when
// programming it. // programming it.
// //
if (CpuInfo->ProcessorInfo.Location.Thread == 0) { if (CpuInfo->ProcessorInfo.Location.Thread == 0) {
MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData; MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData;
if ((MsrFeatureConfig[ProcessorNumber].Bits.AESConfiguration & BIT0) == 0) { if ((MsrFeatureConfig[ProcessorNumber].Bits.AESConfiguration & BIT0) == 0) {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_SANDY_BRIDGE_FEATURE_CONFIG, MSR_SANDY_BRIDGE_FEATURE_CONFIG,
MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER, MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER,
Bits.AESConfiguration, Bits.AESConfiguration,
BIT1 | ((State) ? 0 : BIT0) BIT1 | ((State) ? 0 : BIT0)
); );
} }
} }
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,79 +1,79 @@
/** @file /** @file
C1E feature. C1E feature.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Detects if C1E feature supported on current processor. Detects if C1E feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE C1E feature is supported. @retval TRUE C1E feature is supported.
@retval FALSE C1E feature is not supported. @retval FALSE C1E feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
C1eSupport ( C1eSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
return IS_NEHALEM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel); return IS_NEHALEM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel);
} }
/** /**
Initializes C1E feature to specific state. Initializes C1E feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the C1E feature must be enabled. @param[in] State If TRUE, then the C1E feature must be enabled.
If FALSE, then the C1E feature must be disabled. If FALSE, then the C1E feature must be disabled.
@retval RETURN_SUCCESS C1E feature is initialized. @retval RETURN_SUCCESS C1E feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
C1eInitialize ( C1eInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_NEHALEM_POWER_CTL, MSR_NEHALEM_POWER_CTL,
MSR_NEHALEM_POWER_CTL_REGISTER, MSR_NEHALEM_POWER_CTL_REGISTER,
Bits.C1EEnable, Bits.C1EEnable,
(State) ? 1 : 0 (State) ? 1 : 0
); );
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,106 +1,106 @@
/** @file /** @file
Clock Modulation feature. Clock Modulation feature.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Detects if Clock Modulation feature supported on current processor. Detects if Clock Modulation feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE Clock Modulation feature is supported. @retval TRUE Clock Modulation feature is supported.
@retval FALSE Clock Modulation feature is not supported. @retval FALSE Clock Modulation feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
ClockModulationSupport ( ClockModulationSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
return (CpuInfo->CpuIdVersionInfoEdx.Bits.ACPI == 1); return (CpuInfo->CpuIdVersionInfoEdx.Bits.ACPI == 1);
} }
/** /**
Initializes Clock Modulation feature to specific state. Initializes Clock Modulation feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the Clock Modulation feature must be enabled. @param[in] State If TRUE, then the Clock Modulation feature must be enabled.
If FALSE, then the Clock Modulation feature must be disabled. If FALSE, then the Clock Modulation feature must be disabled.
@retval RETURN_SUCCESS Clock Modulation feature is initialized. @retval RETURN_SUCCESS Clock Modulation feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
ClockModulationInitialize ( ClockModulationInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) { if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION, MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION,
MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER, MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER,
Bits.OnDemandClockModulationDutyCycle, Bits.OnDemandClockModulationDutyCycle,
PcdGet8 (PcdCpuClockModulationDutyCycle) PcdGet8 (PcdCpuClockModulationDutyCycle)
); );
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION, MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION,
MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER, MSR_SANDY_BRIDGE_IA32_CLOCK_MODULATION_REGISTER,
Bits.OnDemandClockModulationEnable, Bits.OnDemandClockModulationEnable,
(State) ? 1 : 0 (State) ? 1 : 0
); );
} else { } else {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_CLOCK_MODULATION, MSR_IA32_CLOCK_MODULATION,
MSR_IA32_CLOCK_MODULATION_REGISTER, MSR_IA32_CLOCK_MODULATION_REGISTER,
Bits.OnDemandClockModulationDutyCycle, Bits.OnDemandClockModulationDutyCycle,
PcdGet8 (PcdCpuClockModulationDutyCycle) PcdGet8 (PcdCpuClockModulationDutyCycle)
); );
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_CLOCK_MODULATION, MSR_IA32_CLOCK_MODULATION,
MSR_IA32_CLOCK_MODULATION_REGISTER, MSR_IA32_CLOCK_MODULATION_REGISTER,
Bits.OnDemandClockModulationEnable, Bits.OnDemandClockModulationEnable,
(State) ? 1 : 0 (State) ? 1 : 0
); );
} }
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,227 +1,227 @@
/** @file /** @file
This library registers CPU features defined in Intel(R) 64 and IA-32 This library registers CPU features defined in Intel(R) 64 and IA-32
Architectures Software Developer's Manual. Architectures Software Developer's Manual.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Register CPU features. Register CPU features.
@retval RETURN_SUCCESS Register successfully @retval RETURN_SUCCESS Register successfully
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
CpuCommonFeaturesLibConstructor ( CpuCommonFeaturesLibConstructor (
VOID VOID
) )
{ {
RETURN_STATUS Status; RETURN_STATUS Status;
if (IsCpuFeatureSupported (CPU_FEATURE_AESNI)) { if (IsCpuFeatureSupported (CPU_FEATURE_AESNI)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"AESNI", "AESNI",
AesniGetConfigData, AesniGetConfigData,
AesniSupport, AesniSupport,
AesniInitialize, AesniInitialize,
CPU_FEATURE_AESNI, CPU_FEATURE_AESNI,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_MWAIT)) { if (IsCpuFeatureSupported (CPU_FEATURE_MWAIT)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"MWAIT", "MWAIT",
NULL, NULL,
MonitorMwaitSupport, MonitorMwaitSupport,
MonitorMwaitInitialize, MonitorMwaitInitialize,
CPU_FEATURE_MWAIT, CPU_FEATURE_MWAIT,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_ACPI)) { if (IsCpuFeatureSupported (CPU_FEATURE_ACPI)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"ACPI", "ACPI",
NULL, NULL,
ClockModulationSupport, ClockModulationSupport,
ClockModulationInitialize, ClockModulationInitialize,
CPU_FEATURE_ACPI, CPU_FEATURE_ACPI,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_EIST)) { if (IsCpuFeatureSupported (CPU_FEATURE_EIST)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"EIST", "EIST",
NULL, NULL,
EistSupport, EistSupport,
EistInitialize, EistInitialize,
CPU_FEATURE_EIST, CPU_FEATURE_EIST,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_XD)) { if (IsCpuFeatureSupported (CPU_FEATURE_XD)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"Execute Disable", "Execute Disable",
NULL, NULL,
ExecuteDisableSupport, ExecuteDisableSupport,
ExecuteDisableInitialize, ExecuteDisableInitialize,
CPU_FEATURE_XD, CPU_FEATURE_XD,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_FASTSTRINGS)) { if (IsCpuFeatureSupported (CPU_FEATURE_FASTSTRINGS)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"FastStrings", "FastStrings",
NULL, NULL,
NULL, NULL,
FastStringsInitialize, FastStringsInitialize,
CPU_FEATURE_FASTSTRINGS, CPU_FEATURE_FASTSTRINGS,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER)) { if (IsCpuFeatureSupported (CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"Lock Feature Control Register", "Lock Feature Control Register",
FeatureControlGetConfigData, FeatureControlGetConfigData,
LockFeatureControlRegisterSupport, LockFeatureControlRegisterSupport,
LockFeatureControlRegisterInitialize, LockFeatureControlRegisterInitialize,
CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER, CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_SENTER)) { if (IsCpuFeatureSupported (CPU_FEATURE_SENTER)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"SENTER", "SENTER",
FeatureControlGetConfigData, FeatureControlGetConfigData,
VmxSupport, VmxSupport,
SenterInitialize, SenterInitialize,
CPU_FEATURE_SENTER, CPU_FEATURE_SENTER,
CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE, CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,
CPU_FEATURE_SMX | CPU_FEATURE_AFTER, CPU_FEATURE_SMX | CPU_FEATURE_AFTER,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_SMX)) { if (IsCpuFeatureSupported (CPU_FEATURE_SMX)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"SMX", "SMX",
FeatureControlGetConfigData, FeatureControlGetConfigData,
SmxSupport, SmxSupport,
VmxInsideSmxInitialize, VmxInsideSmxInitialize,
CPU_FEATURE_SMX, CPU_FEATURE_SMX,
CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE, CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_VMX)) { if (IsCpuFeatureSupported (CPU_FEATURE_VMX)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"VMX", "VMX",
FeatureControlGetConfigData, FeatureControlGetConfigData,
SmxSupport, SmxSupport,
VmxOutsideSmxInitialize, VmxOutsideSmxInitialize,
CPU_FEATURE_VMX, CPU_FEATURE_VMX,
CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE, CPU_FEATURE_LOCK_FEATURE_CONTROL_REGISTER | CPU_FEATURE_BEFORE,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_LIMIT_CPUID_MAX_VAL)) { if (IsCpuFeatureSupported (CPU_FEATURE_LIMIT_CPUID_MAX_VAL)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"Limit CpuId Maximum Value", "Limit CpuId Maximum Value",
NULL, NULL,
LimitCpuidMaxvalSupport, LimitCpuidMaxvalSupport,
LimitCpuidMaxvalInitialize, LimitCpuidMaxvalInitialize,
CPU_FEATURE_LIMIT_CPUID_MAX_VAL, CPU_FEATURE_LIMIT_CPUID_MAX_VAL,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_MCE)) { if (IsCpuFeatureSupported (CPU_FEATURE_MCE)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"Machine Check Enable", "Machine Check Enable",
NULL, NULL,
MceSupport, MceSupport,
MceInitialize, MceInitialize,
CPU_FEATURE_MCE, CPU_FEATURE_MCE,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_MCA)) { if (IsCpuFeatureSupported (CPU_FEATURE_MCA)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"Machine Check Architect", "Machine Check Architect",
NULL, NULL,
McaSupport, McaSupport,
McaInitialize, McaInitialize,
CPU_FEATURE_MCA, CPU_FEATURE_MCA,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_MCG_CTL)) { if (IsCpuFeatureSupported (CPU_FEATURE_MCG_CTL)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"MCG_CTL", "MCG_CTL",
NULL, NULL,
McgCtlSupport, McgCtlSupport,
McgCtlInitialize, McgCtlInitialize,
CPU_FEATURE_MCG_CTL, CPU_FEATURE_MCG_CTL,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_PENDING_BREAK)) { if (IsCpuFeatureSupported (CPU_FEATURE_PENDING_BREAK)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"Pending Break", "Pending Break",
NULL, NULL,
PendingBreakSupport, PendingBreakSupport,
PendingBreakInitialize, PendingBreakInitialize,
CPU_FEATURE_PENDING_BREAK, CPU_FEATURE_PENDING_BREAK,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_C1E)) { if (IsCpuFeatureSupported (CPU_FEATURE_C1E)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"C1E", "C1E",
NULL, NULL,
C1eSupport, C1eSupport,
C1eInitialize, C1eInitialize,
CPU_FEATURE_C1E, CPU_FEATURE_C1E,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
if (IsCpuFeatureSupported (CPU_FEATURE_X2APIC)) { if (IsCpuFeatureSupported (CPU_FEATURE_X2APIC)) {
Status = RegisterCpuFeature ( Status = RegisterCpuFeature (
"X2Apic", "X2Apic",
NULL, NULL,
X2ApicSupport, X2ApicSupport,
X2ApicInitialize, X2ApicInitialize,
CPU_FEATURE_X2APIC, CPU_FEATURE_X2APIC,
CPU_FEATURE_END CPU_FEATURE_END
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,68 +1,68 @@
## @file ## @file
# NULL instance to register CPU features. # NULL instance to register CPU features.
# #
# This library registers CPU features defined in Intel(R) 64 and IA-32 # This library registers CPU features defined in Intel(R) 64 and IA-32
# Architectures Software Developer's Manual. # Architectures Software Developer's Manual.
# #
# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # 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 # which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php # http://opensource.org/licenses/bsd-license.php
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# #
## ##
[Defines] [Defines]
INF_VERSION = 0x00010005 INF_VERSION = 0x00010005
BASE_NAME = CpuCommonFeaturesLib BASE_NAME = CpuCommonFeaturesLib
MODULE_UNI_FILE = CpuCommonFeaturesLib.uni MODULE_UNI_FILE = CpuCommonFeaturesLib.uni
FILE_GUID = 6D69F79F-9535-4893-9DD7-93929898252C FILE_GUID = 6D69F79F-9535-4893-9DD7-93929898252C
MODULE_TYPE = BASE MODULE_TYPE = BASE
VERSION_STRING = 1.0 VERSION_STRING = 1.0
LIBRARY_CLASS = NULL LIBRARY_CLASS = NULL
CONSTRUCTOR = CpuCommonFeaturesLibConstructor CONSTRUCTOR = CpuCommonFeaturesLibConstructor
# #
# The following information is for reference only and not required by the build tools. # The following information is for reference only and not required by the build tools.
# #
# VALID_ARCHITECTURES = IA32 X64 # VALID_ARCHITECTURES = IA32 X64
# #
[Sources] [Sources]
CpuCommonFeaturesLib.c CpuCommonFeaturesLib.c
CpuCommonFeatures.h CpuCommonFeatures.h
Aesni.c Aesni.c
C1e.c C1e.c
ClockModulation.c ClockModulation.c
Eist.c Eist.c
ExecuteDisable.c ExecuteDisable.c
FastStrings.c FastStrings.c
FeatureControl.c FeatureControl.c
LimitCpuIdMaxval.c LimitCpuIdMaxval.c
MachineCheck.c MachineCheck.c
MonitorMwait.c MonitorMwait.c
PendingBreak.c PendingBreak.c
X2Apic.c X2Apic.c
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
UefiCpuPkg/UefiCpuPkg.dec UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses] [LibraryClasses]
BaseLib BaseLib
PcdLib PcdLib
DebugLib DebugLib
RegisterCpuFeaturesLib RegisterCpuFeaturesLib
BaseMemoryLib BaseMemoryLib
MemoryAllocationLib MemoryAllocationLib
LocalApicLib LocalApicLib
[Pcd] [Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle ## SOMETIMES_CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuClockModulationDutyCycle ## SOMETIMES_CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset ## SOMETIMES_CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset ## SOMETIMES_CONSUMES

View File

@ -1,25 +1,25 @@
// /** @file // /** @file
// Dxe Crc32 Guided Section Extract library. // Dxe Crc32 Guided Section Extract library.
// //
// This library doesn't produce any library class. The constructor function uses // This library doesn't produce any library class. The constructor function uses
// ExtractGuidedSectionLib service to register CRC32 guided section handler // ExtractGuidedSectionLib service to register CRC32 guided section handler
// that parses CRC32 encapsulation section and extracts raw data. // that parses CRC32 encapsulation section and extracts raw data.
// //
// It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value. // It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value.
// //
// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR> // Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
// //
// This program and the accompanying materials // This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License // 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 // which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php // http://opensource.org/licenses/bsd-license.php
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // 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_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." #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."

View File

@ -1,81 +1,81 @@
/** @file /** @file
Enhanced Intel SpeedStep feature. Enhanced Intel SpeedStep feature.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Detects if Enhanced Intel SpeedStep feature supported on current processor. Detects if Enhanced Intel SpeedStep feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE Enhanced Intel SpeedStep feature is supported. @retval TRUE Enhanced Intel SpeedStep feature is supported.
@retval FALSE Enhanced Intel SpeedStep feature is not supported. @retval FALSE Enhanced Intel SpeedStep feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
EistSupport ( EistSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
return (CpuInfo->CpuIdVersionInfoEcx.Bits.EIST == 1); return (CpuInfo->CpuIdVersionInfoEcx.Bits.EIST == 1);
} }
/** /**
Initializes Enhanced Intel SpeedStep feature to specific state. Initializes Enhanced Intel SpeedStep feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the Enhanced Intel SpeedStep feature @param[in] State If TRUE, then the Enhanced Intel SpeedStep feature
must be enabled. must be enabled.
If FALSE, then the Enhanced Intel SpeedStep feature If FALSE, then the Enhanced Intel SpeedStep feature
must be disabled. must be disabled.
@retval RETURN_SUCCESS Enhanced Intel SpeedStep feature is initialized. @retval RETURN_SUCCESS Enhanced Intel SpeedStep feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
EistInitialize ( EistInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_MISC_ENABLE, MSR_IA32_MISC_ENABLE,
MSR_IA32_MISC_ENABLE_REGISTER, MSR_IA32_MISC_ENABLE_REGISTER,
Bits.EIST, Bits.EIST,
(State) ? 1 : 0 (State) ? 1 : 0
); );
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,91 +1,91 @@
/** @file /** @file
Execute Disable feature. Execute Disable feature.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Detects if Execute Disable feature supported on current processor. Detects if Execute Disable feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE Execute Disable feature is supported. @retval TRUE Execute Disable feature is supported.
@retval FALSE Execute Disable feature is not supported. @retval FALSE Execute Disable feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
ExecuteDisableSupport ( ExecuteDisableSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
UINT32 Eax; UINT32 Eax;
CPUID_EXTENDED_CPU_SIG_EDX Edx; CPUID_EXTENDED_CPU_SIG_EDX Edx;
AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL); AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL);
if (Eax <= CPUID_EXTENDED_FUNCTION) { if (Eax <= CPUID_EXTENDED_FUNCTION) {
// //
// Extended CPUID functions are not supported on this processor. // Extended CPUID functions are not supported on this processor.
// //
return FALSE; return FALSE;
} }
AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32); AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32);
return (Edx.Bits.NX != 0); return (Edx.Bits.NX != 0);
} }
/** /**
Initializes Execute Disable feature to specific state. Initializes Execute Disable feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the Execute Disable feature must be enabled. @param[in] State If TRUE, then the Execute Disable feature must be enabled.
If FALSE, then the Execute Disable feature must be disabled. If FALSE, then the Execute Disable feature must be disabled.
@retval RETURN_SUCCESS Execute Disable feature is initialized. @retval RETURN_SUCCESS Execute Disable feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
ExecuteDisableInitialize ( ExecuteDisableInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_EFER, MSR_IA32_EFER,
MSR_IA32_EFER_REGISTER, MSR_IA32_EFER_REGISTER,
Bits.NXE, Bits.NXE,
(State) ? 1 : 0 (State) ? 1 : 0
); );
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,52 +1,52 @@
/** @file /** @file
Fast-Strings feature. Fast-Strings feature.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Initializes Fast-Strings feature to specific state. Initializes Fast-Strings feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the Fast-Strings feature must be enabled. @param[in] State If TRUE, then the Fast-Strings feature must be enabled.
If FALSE, then the Fast-Strings feature must be disabled. If FALSE, then the Fast-Strings feature must be disabled.
@retval RETURN_SUCCESS Fast-Strings feature is initialized. @retval RETURN_SUCCESS Fast-Strings feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
FastStringsInitialize ( FastStringsInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_MISC_ENABLE, MSR_IA32_MISC_ENABLE,
MSR_IA32_MISC_ENABLE_REGISTER, MSR_IA32_MISC_ENABLE_REGISTER,
Bits.FastStrings, Bits.FastStrings,
(State) ? 1 : 0 (State) ? 1 : 0
); );
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,314 +1,314 @@
/** @file /** @file
Features in MSR_IA32_FEATURE_CONTROL register. Features in MSR_IA32_FEATURE_CONTROL register.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Prepares for the data used by CPU feature detection and initialization. Prepares for the data used by CPU feature detection and initialization.
@param[in] NumberOfProcessors The number of CPUs in the platform. @param[in] NumberOfProcessors The number of CPUs in the platform.
@return Pointer to a buffer of CPU related configuration data. @return Pointer to a buffer of CPU related configuration data.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
VOID * VOID *
EFIAPI EFIAPI
FeatureControlGetConfigData ( FeatureControlGetConfigData (
IN UINTN NumberOfProcessors IN UINTN NumberOfProcessors
) )
{ {
VOID *ConfigData; VOID *ConfigData;
ConfigData = AllocateZeroPool (sizeof (MSR_IA32_FEATURE_CONTROL_REGISTER) * NumberOfProcessors); ConfigData = AllocateZeroPool (sizeof (MSR_IA32_FEATURE_CONTROL_REGISTER) * NumberOfProcessors);
ASSERT (ConfigData != NULL); ASSERT (ConfigData != NULL);
return ConfigData; return ConfigData;
} }
/** /**
Detects if VMX feature supported on current processor. Detects if VMX feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE VMX feature is supported. @retval TRUE VMX feature is supported.
@retval FALSE VMX feature is not supported. @retval FALSE VMX feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
VmxSupport ( VmxSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister;
ASSERT (ConfigData != NULL); ASSERT (ConfigData != NULL);
MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL); MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);
return (CpuInfo->CpuIdVersionInfoEcx.Bits.VMX == 1); return (CpuInfo->CpuIdVersionInfoEcx.Bits.VMX == 1);
} }
/** /**
Initializes VMX inside SMX feature to specific state. Initializes VMX inside SMX feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the VMX inside SMX feature must be enabled. @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. If FALSE, then the VMX inside SMX feature must be disabled.
@retval RETURN_SUCCESS VMX inside SMX feature is initialized. @retval RETURN_SUCCESS VMX inside SMX feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
VmxInsideSmxInitialize ( VmxInsideSmxInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister;
ASSERT (ConfigData != NULL); ASSERT (ConfigData != NULL);
MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_FEATURE_CONTROL, MSR_IA32_FEATURE_CONTROL,
MSR_IA32_FEATURE_CONTROL_REGISTER, MSR_IA32_FEATURE_CONTROL_REGISTER,
Bits.EnableVmxInsideSmx, Bits.EnableVmxInsideSmx,
(State) ? 1 : 0 (State) ? 1 : 0
); );
} }
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
Initializes SENTER feature to specific state. Initializes SENTER feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the SENTER feature must be enabled. @param[in] State If TRUE, then the SENTER feature must be enabled.
If FALSE, then the SENTER feature must be disabled. If FALSE, then the SENTER feature must be disabled.
@retval RETURN_SUCCESS SENTER feature is initialized. @retval RETURN_SUCCESS SENTER feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
SenterInitialize ( SenterInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister;
ASSERT (ConfigData != NULL); ASSERT (ConfigData != NULL);
MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_FEATURE_CONTROL, MSR_IA32_FEATURE_CONTROL,
MSR_IA32_FEATURE_CONTROL_REGISTER, MSR_IA32_FEATURE_CONTROL_REGISTER,
Bits.SenterLocalFunctionEnables, Bits.SenterLocalFunctionEnables,
(State) ? 0x7F : 0 (State) ? 0x7F : 0
); );
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_FEATURE_CONTROL, MSR_IA32_FEATURE_CONTROL,
MSR_IA32_FEATURE_CONTROL_REGISTER, MSR_IA32_FEATURE_CONTROL_REGISTER,
Bits.SenterGlobalEnable, Bits.SenterGlobalEnable,
(State) ? 1 : 0 (State) ? 1 : 0
); );
} }
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
Detects if Lock Feature Control Register feature supported on current processor. Detects if Lock Feature Control Register feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE Lock Feature Control Register feature is supported. @retval TRUE Lock Feature Control Register feature is supported.
@retval FALSE Lock Feature Control Register feature is not supported. @retval FALSE Lock Feature Control Register feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
LockFeatureControlRegisterSupport ( LockFeatureControlRegisterSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister;
ASSERT (ConfigData != NULL); ASSERT (ConfigData != NULL);
MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL); MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);
return TRUE; return TRUE;
} }
/** /**
Initializes Lock Feature Control Register feature to specific state. Initializes Lock Feature Control Register feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the Lock Feature Control Register feature must be enabled. @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. If FALSE, then the Lock Feature Control Register feature must be disabled.
@retval RETURN_SUCCESS Lock Feature Control Register feature is initialized. @retval RETURN_SUCCESS Lock Feature Control Register feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
LockFeatureControlRegisterInitialize ( LockFeatureControlRegisterInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister;
ASSERT (ConfigData != NULL); ASSERT (ConfigData != NULL);
MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_FEATURE_CONTROL, MSR_IA32_FEATURE_CONTROL,
MSR_IA32_FEATURE_CONTROL_REGISTER, MSR_IA32_FEATURE_CONTROL_REGISTER,
Bits.Lock, Bits.Lock,
1 1
); );
} }
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
Detects if SMX feature supported on current processor. Detects if SMX feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE SMX feature is supported. @retval TRUE SMX feature is supported.
@retval FALSE SMX feature is not supported. @retval FALSE SMX feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
SmxSupport ( SmxSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister;
ASSERT (ConfigData != NULL); ASSERT (ConfigData != NULL);
MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL); MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);
return (CpuInfo->CpuIdVersionInfoEcx.Bits.SMX == 1); return (CpuInfo->CpuIdVersionInfoEcx.Bits.SMX == 1);
} }
/** /**
Initializes VMX outside SMX feature to specific state. Initializes VMX outside SMX feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the VMX outside SMX feature must be enabled. @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. If FALSE, then the VMX outside SMX feature must be disabled.
@retval RETURN_SUCCESS VMX outside SMX feature is initialized. @retval RETURN_SUCCESS VMX outside SMX feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
VmxOutsideSmxInitialize ( VmxOutsideSmxInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister; MSR_IA32_FEATURE_CONTROL_REGISTER *MsrRegister;
ASSERT (ConfigData != NULL); ASSERT (ConfigData != NULL);
MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData; MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
if (MsrRegister[ProcessorNumber].Bits.Lock == 0) { if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_FEATURE_CONTROL, MSR_IA32_FEATURE_CONTROL,
MSR_IA32_FEATURE_CONTROL_REGISTER, MSR_IA32_FEATURE_CONTROL_REGISTER,
Bits.EnableVmxOutsideSmx, Bits.EnableVmxOutsideSmx,
(State) ? 1 : 0 (State) ? 1 : 0
); );
} }
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,82 +1,82 @@
/** @file /** @file
LimitCpuidMaxval Feature. LimitCpuidMaxval Feature.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Detects if LimitCpuidMaxval feature supported on current processor. Detects if LimitCpuidMaxval feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE LimitCpuidMaxval feature is supported. @retval TRUE LimitCpuidMaxval feature is supported.
@retval FALSE LimitCpuidMaxval feature is not supported. @retval FALSE LimitCpuidMaxval feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
LimitCpuidMaxvalSupport ( LimitCpuidMaxvalSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
UINT32 Eax; UINT32 Eax;
AsmCpuid (CPUID_SIGNATURE, &Eax, NULL, NULL, NULL); AsmCpuid (CPUID_SIGNATURE, &Eax, NULL, NULL, NULL);
return (Eax > 3); return (Eax > 3);
} }
/** /**
Initializes LimitCpuidMaxval feature to specific state. Initializes LimitCpuidMaxval feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the LimitCpuidMaxval feature must be enabled. @param[in] State If TRUE, then the LimitCpuidMaxval feature must be enabled.
If FALSE, then the LimitCpuidMaxval feature must be disabled. If FALSE, then the LimitCpuidMaxval feature must be disabled.
@retval RETURN_SUCCESS LimitCpuidMaxval feature is initialized. @retval RETURN_SUCCESS LimitCpuidMaxval feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
LimitCpuidMaxvalInitialize ( LimitCpuidMaxvalInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_MISC_ENABLE, MSR_IA32_MISC_ENABLE,
MSR_IA32_MISC_ENABLE_REGISTER, MSR_IA32_MISC_ENABLE_REGISTER,
Bits.LimitCpuidMaxval, Bits.LimitCpuidMaxval,
(State) ? 1 : 0 (State) ? 1 : 0
); );
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,231 +1,231 @@
/** @file /** @file
Machine Check features. Machine Check features.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Detects if Machine Check Exception feature supported on current processor. Detects if Machine Check Exception feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE Machine Check Exception feature is supported. @retval TRUE Machine Check Exception feature is supported.
@retval FALSE Machine Check Exception feature is not supported. @retval FALSE Machine Check Exception feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
MceSupport ( MceSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCE == 1); return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCE == 1);
} }
/** /**
Initializes Machine Check Exception feature to specific state. Initializes Machine Check Exception feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the Machine Check Exception feature must be enabled. @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. If FALSE, then the Machine Check Exception feature must be disabled.
@retval RETURN_SUCCESS Machine Check Exception feature is initialized. @retval RETURN_SUCCESS Machine Check Exception feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
MceInitialize ( MceInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
// //
// Set MCE bit in CR4 // Set MCE bit in CR4
// //
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
ControlRegister, ControlRegister,
4, 4,
IA32_CR4, IA32_CR4,
Bits.MCE, Bits.MCE,
(State) ? 1 : 0 (State) ? 1 : 0
); );
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
Detects if Machine Check Architecture feature supported on current processor. Detects if Machine Check Architecture feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE Machine Check Architecture feature is supported. @retval TRUE Machine Check Architecture feature is supported.
@retval FALSE Machine Check Architecture feature is not supported. @retval FALSE Machine Check Architecture feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
McaSupport ( McaSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCA == 1); return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCA == 1);
} }
/** /**
Initializes Machine Check Architecture feature to specific state. Initializes Machine Check Architecture feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the Machine Check Architecture feature must be enabled. @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. If FALSE, then the Machine Check Architecture feature must be disabled.
@retval RETURN_SUCCESS Machine Check Architecture feature is initialized. @retval RETURN_SUCCESS Machine Check Architecture feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
McaInitialize ( McaInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
MSR_IA32_MCG_CAP_REGISTER McgCap; MSR_IA32_MCG_CAP_REGISTER McgCap;
UINT32 BankIndex; UINT32 BankIndex;
McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP); McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);
for (BankIndex = 0; BankIndex < (UINT32) McgCap.Bits.Count; BankIndex++) { for (BankIndex = 0; BankIndex < (UINT32) McgCap.Bits.Count; BankIndex++) {
CPU_REGISTER_TABLE_WRITE64 ( CPU_REGISTER_TABLE_WRITE64 (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_MC0_CTL + BankIndex * 4, MSR_IA32_MC0_CTL + BankIndex * 4,
MAX_UINT64 MAX_UINT64
); );
} }
if (PcdGetBool (PcdIsPowerOnReset)) { if (PcdGetBool (PcdIsPowerOnReset)) {
for (BankIndex = 0; BankIndex < (UINTN) McgCap.Bits.Count; BankIndex++) { for (BankIndex = 0; BankIndex < (UINTN) McgCap.Bits.Count; BankIndex++) {
CPU_REGISTER_TABLE_WRITE64 ( CPU_REGISTER_TABLE_WRITE64 (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_MC0_STATUS + BankIndex * 4, MSR_IA32_MC0_STATUS + BankIndex * 4,
0 0
); );
} }
} }
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
Detects if IA32_MCG_CTL feature supported on current processor. Detects if IA32_MCG_CTL feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE IA32_MCG_CTL feature is supported. @retval TRUE IA32_MCG_CTL feature is supported.
@retval FALSE IA32_MCG_CTL feature is not supported. @retval FALSE IA32_MCG_CTL feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
McgCtlSupport ( McgCtlSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
MSR_IA32_MCG_CAP_REGISTER McgCap; MSR_IA32_MCG_CAP_REGISTER McgCap;
if (!McaSupport (ProcessorNumber, CpuInfo, ConfigData)) { if (!McaSupport (ProcessorNumber, CpuInfo, ConfigData)) {
return FALSE; return FALSE;
} }
McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP); McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);
return (McgCap.Bits.MCG_CTL_P == 1); return (McgCap.Bits.MCG_CTL_P == 1);
} }
/** /**
Initializes IA32_MCG_CTL feature to specific state. Initializes IA32_MCG_CTL feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the IA32_MCG_CTL feature must be enabled. @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. If FALSE, then the IA32_MCG_CTL feature must be disabled.
@retval RETURN_SUCCESS IA32_MCG_CTL feature is initialized. @retval RETURN_SUCCESS IA32_MCG_CTL feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
McgCtlInitialize ( McgCtlInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
CPU_REGISTER_TABLE_WRITE64 ( CPU_REGISTER_TABLE_WRITE64 (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_MCG_CTL, MSR_IA32_MCG_CTL,
(State)? MAX_UINT64 : 0 (State)? MAX_UINT64 : 0
); );
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,79 +1,79 @@
/** @file /** @file
MonitorMwait feature. MonitorMwait feature.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Detects if MONITOR/MWAIT feature supported on current processor. Detects if MONITOR/MWAIT feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE MONITOR/MWAIT feature is supported. @retval TRUE MONITOR/MWAIT feature is supported.
@retval FALSE MONITOR/MWAIT feature is not supported. @retval FALSE MONITOR/MWAIT feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
MonitorMwaitSupport ( MonitorMwaitSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
return (CpuInfo->CpuIdVersionInfoEcx.Bits.MONITOR == 1); return (CpuInfo->CpuIdVersionInfoEcx.Bits.MONITOR == 1);
} }
/** /**
Initializes MONITOR/MWAIT feature to specific state. Initializes MONITOR/MWAIT feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the MONITOR/MWAIT feature must be enabled. @param[in] State If TRUE, then the MONITOR/MWAIT feature must be enabled.
If FALSE, then the MONITOR/MWAIT feature must be disabled. If FALSE, then the MONITOR/MWAIT feature must be disabled.
@retval RETURN_SUCCESS MONITOR/MWAIT feature is initialized. @retval RETURN_SUCCESS MONITOR/MWAIT feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
MonitorMwaitInitialize ( MonitorMwaitInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_MISC_ENABLE, MSR_IA32_MISC_ENABLE,
MSR_IA32_MISC_ENABLE_REGISTER, MSR_IA32_MISC_ENABLE_REGISTER,
Bits.MONITOR, Bits.MONITOR,
(State) ? 1 : 0 (State) ? 1 : 0
); );
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,90 +1,90 @@
/** @file /** @file
Pending Break feature. Pending Break feature.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Detects if Pending Break feature supported on current processor. Detects if Pending Break feature supported on current processor.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE Pending Break feature is supported. @retval TRUE Pending Break feature is supported.
@retval FALSE Pending Break feature is not supported. @retval FALSE Pending Break feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
PendingBreakSupport ( PendingBreakSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
if (IS_ATOM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || if (IS_ATOM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
IS_CORE2_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || IS_CORE2_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
IS_CORE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || IS_CORE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) || IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
IS_PENTIUM_M_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) { IS_PENTIUM_M_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
return (CpuInfo->CpuIdVersionInfoEdx.Bits.PBE == 1); return (CpuInfo->CpuIdVersionInfoEdx.Bits.PBE == 1);
} }
return FALSE; return FALSE;
} }
/** /**
Initializes Pending Break feature to specific state. Initializes Pending Break feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the Pending Break feature must be enabled. @param[in] State If TRUE, then the Pending Break feature must be enabled.
If FALSE, then the Pending Break feature must be disabled. If FALSE, then the Pending Break feature must be disabled.
@retval RETURN_SUCCESS Pending Break feature is initialized. @retval RETURN_SUCCESS Pending Break feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
PendingBreakInitialize ( PendingBreakInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
// //
// ATOM, CORE2, CORE, PENTIUM_4 and IS_PENTIUM_M_PROCESSOR have the same MSR index, // ATOM, CORE2, CORE, PENTIUM_4 and IS_PENTIUM_M_PROCESSOR have the same MSR index,
// Simply use MSR_ATOM_IA32_MISC_ENABLE here // Simply use MSR_ATOM_IA32_MISC_ENABLE here
// //
CPU_REGISTER_TABLE_WRITE_FIELD ( CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_ATOM_IA32_MISC_ENABLE, MSR_ATOM_IA32_MISC_ENABLE,
MSR_ATOM_IA32_MISC_ENABLE_REGISTER, MSR_ATOM_IA32_MISC_ENABLE_REGISTER,
Bits.FERR, Bits.FERR,
(State) ? 1 : 0 (State) ? 1 : 0
); );
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,81 +1,81 @@
/** @file /** @file
X2Apic feature. X2Apic feature.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include "CpuCommonFeatures.h" #include "CpuCommonFeatures.h"
/** /**
Detects if X2Apci feature supported on current processor. Detects if X2Apci feature supported on current processor.
Detect if X2Apci has been already enabled. Detect if X2Apci has been already enabled.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@retval TRUE X2Apci feature is supported. @retval TRUE X2Apci feature is supported.
@retval FALSE X2Apci feature is not supported. @retval FALSE X2Apci feature is not supported.
@note This service could be called by BSP/APs. @note This service could be called by BSP/APs.
**/ **/
BOOLEAN BOOLEAN
EFIAPI EFIAPI
X2ApicSupport ( X2ApicSupport (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData OPTIONAL IN VOID *ConfigData OPTIONAL
) )
{ {
return (GetApicMode () == LOCAL_APIC_MODE_X2APIC); return (GetApicMode () == LOCAL_APIC_MODE_X2APIC);
} }
/** /**
Initializes X2Apci feature to specific state. Initializes X2Apci feature to specific state.
@param[in] ProcessorNumber The index of the CPU executing this function. @param[in] ProcessorNumber The index of the CPU executing this function.
@param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
structure for the CPU executing this function. structure for the CPU executing this function.
@param[in] ConfigData A pointer to the configuration buffer returned @param[in] ConfigData A pointer to the configuration buffer returned
by CPU_FEATURE_GET_CONFIG_DATA. NULL if by CPU_FEATURE_GET_CONFIG_DATA. NULL if
CPU_FEATURE_GET_CONFIG_DATA was not provided in CPU_FEATURE_GET_CONFIG_DATA was not provided in
RegisterCpuFeature(). RegisterCpuFeature().
@param[in] State If TRUE, then the X2Apci feature must be enabled. @param[in] State If TRUE, then the X2Apci feature must be enabled.
If FALSE, then the X2Apci feature must be disabled. If FALSE, then the X2Apci feature must be disabled.
@retval RETURN_SUCCESS X2Apci feature is initialized. @retval RETURN_SUCCESS X2Apci feature is initialized.
@note This service could be called by BSP only. @note This service could be called by BSP only.
**/ **/
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
X2ApicInitialize ( X2ApicInitialize (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
IN VOID *ConfigData, OPTIONAL IN VOID *ConfigData, OPTIONAL
IN BOOLEAN State IN BOOLEAN State
) )
{ {
PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD ( PRE_SMM_CPU_REGISTER_TABLE_WRITE_FIELD (
ProcessorNumber, ProcessorNumber,
Msr, Msr,
MSR_IA32_APIC_BASE, MSR_IA32_APIC_BASE,
MSR_IA32_APIC_BASE_REGISTER, MSR_IA32_APIC_BASE_REGISTER,
Bits.EXTD, Bits.EXTD,
(State) ? 1 : 0 (State) ? 1 : 0
); );
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -1,266 +1,266 @@
/** @file /** @file
CPU Register Table Library functions. CPU Register Table Library functions.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include <PiDxe.h> #include <PiDxe.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include "RegisterCpuFeatures.h" #include "RegisterCpuFeatures.h"
CPU_FEATURES_DATA mCpuFeaturesData = {0}; CPU_FEATURES_DATA mCpuFeaturesData = {0};
EFI_MP_SERVICES_PROTOCOL *mCpuFeaturesMpServices = NULL; EFI_MP_SERVICES_PROTOCOL *mCpuFeaturesMpServices = NULL;
/** /**
Worker function to get CPU_FEATURES_DATA pointer. Worker function to get CPU_FEATURES_DATA pointer.
@return Pointer to CPU_FEATURES_DATA. @return Pointer to CPU_FEATURES_DATA.
**/ **/
CPU_FEATURES_DATA * CPU_FEATURES_DATA *
GetCpuFeaturesData ( GetCpuFeaturesData (
VOID VOID
) )
{ {
return &mCpuFeaturesData; return &mCpuFeaturesData;
} }
/** /**
Worker function to get EFI_MP_SERVICES_PROTOCOL pointer. Worker function to get EFI_MP_SERVICES_PROTOCOL pointer.
@return Pointer to EFI_MP_SERVICES_PROTOCOL. @return Pointer to EFI_MP_SERVICES_PROTOCOL.
**/ **/
EFI_MP_SERVICES_PROTOCOL * EFI_MP_SERVICES_PROTOCOL *
GetMpProtocol ( GetMpProtocol (
VOID VOID
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
if (mCpuFeaturesMpServices == NULL) { if (mCpuFeaturesMpServices == NULL) {
// //
// Get MP Services Protocol // Get MP Services Protocol
// //
Status = gBS->LocateProtocol ( Status = gBS->LocateProtocol (
&gEfiMpServiceProtocolGuid, &gEfiMpServiceProtocolGuid,
NULL, NULL,
(VOID **)&mCpuFeaturesMpServices (VOID **)&mCpuFeaturesMpServices
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
ASSERT (mCpuFeaturesMpServices != NULL); ASSERT (mCpuFeaturesMpServices != NULL);
return mCpuFeaturesMpServices; return mCpuFeaturesMpServices;
} }
/** /**
Worker function to return processor index. Worker function to return processor index.
@return The processor index. @return The processor index.
**/ **/
UINTN UINTN
GetProcessorIndex ( GetProcessorIndex (
VOID VOID
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN ProcessorIndex; UINTN ProcessorIndex;
EFI_MP_SERVICES_PROTOCOL *MpServices; EFI_MP_SERVICES_PROTOCOL *MpServices;
MpServices = GetMpProtocol (); MpServices = GetMpProtocol ();
Status = MpServices->WhoAmI(MpServices, &ProcessorIndex); Status = MpServices->WhoAmI(MpServices, &ProcessorIndex);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return ProcessorIndex; return ProcessorIndex;
} }
/** /**
Gets detailed MP-related information on the requested processor at the Gets detailed MP-related information on the requested processor at the
instant this call is made. instant this call is made.
@param[in] ProcessorNumber The handle number of processor. @param[in] ProcessorNumber The handle number of processor.
@param[out] ProcessorInfoBuffer A pointer to the buffer where information for @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
the requested processor is deposited. the requested processor is deposited.
@return Status of MpServices->GetProcessorInfo(). @return Status of MpServices->GetProcessorInfo().
**/ **/
EFI_STATUS EFI_STATUS
GetProcessorInformation ( GetProcessorInformation (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_MP_SERVICES_PROTOCOL *MpServices; EFI_MP_SERVICES_PROTOCOL *MpServices;
MpServices = GetMpProtocol (); MpServices = GetMpProtocol ();
Status = MpServices->GetProcessorInfo ( Status = MpServices->GetProcessorInfo (
MpServices, MpServices,
ProcessorNumber, ProcessorNumber,
ProcessorInfoBuffer ProcessorInfoBuffer
); );
return Status; return Status;
} }
/** /**
Worker function to execute a caller provided function on all enabled APs. Worker function to execute a caller provided function on all enabled APs.
@param[in] Procedure A pointer to the function to be run on @param[in] Procedure A pointer to the function to be run on
enabled APs of the system. enabled APs of the system.
**/ **/
VOID VOID
StartupAPsWorker ( StartupAPsWorker (
IN EFI_AP_PROCEDURE Procedure IN EFI_AP_PROCEDURE Procedure
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_MP_SERVICES_PROTOCOL *MpServices; EFI_MP_SERVICES_PROTOCOL *MpServices;
MpServices = GetMpProtocol (); MpServices = GetMpProtocol ();
// //
// Wakeup all APs // Wakeup all APs
// //
Status = MpServices->StartupAllAPs ( Status = MpServices->StartupAllAPs (
MpServices, MpServices,
Procedure, Procedure,
FALSE, FALSE,
NULL, NULL,
0, 0,
NULL, NULL,
NULL NULL
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
/** /**
Worker function to switch the requested AP to be the BSP from that point onward. 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. @param[in] ProcessorNumber The handle number of AP that is to become the new BSP.
**/ **/
VOID VOID
SwitchNewBsp ( SwitchNewBsp (
IN UINTN ProcessorNumber IN UINTN ProcessorNumber
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_MP_SERVICES_PROTOCOL *MpServices; EFI_MP_SERVICES_PROTOCOL *MpServices;
MpServices = GetMpProtocol (); MpServices = GetMpProtocol ();
// //
// Wakeup all APs // Wakeup all APs
// //
Status = MpServices->SwitchBSP ( Status = MpServices->SwitchBSP (
MpServices, MpServices,
ProcessorNumber, ProcessorNumber,
TRUE TRUE
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
/** /**
Worker function to retrieve the number of logical processor in the platform. Worker function to retrieve the number of logical processor in the platform.
@param[out] NumberOfCpus Pointer to the total number of logical @param[out] NumberOfCpus Pointer to the total number of logical
processors in the system, including the BSP processors in the system, including the BSP
and disabled APs. and disabled APs.
@param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
processors that exist in system, including processors that exist in system, including
the BSP. the BSP.
**/ **/
VOID VOID
GetNumberOfProcessor ( GetNumberOfProcessor (
OUT UINTN *NumberOfCpus, OUT UINTN *NumberOfCpus,
OUT UINTN *NumberOfEnabledProcessors OUT UINTN *NumberOfEnabledProcessors
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_MP_SERVICES_PROTOCOL *MpServices; EFI_MP_SERVICES_PROTOCOL *MpServices;
MpServices = GetMpProtocol (); MpServices = GetMpProtocol ();
// //
// Get the number of CPUs // Get the number of CPUs
// //
Status = MpServices->GetNumberOfProcessors ( Status = MpServices->GetNumberOfProcessors (
MpServices, MpServices,
NumberOfCpus, NumberOfCpus,
NumberOfEnabledProcessors NumberOfEnabledProcessors
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
/** /**
Allocates ACPI NVS memory to save ACPI_CPU_DATA. Allocates ACPI NVS memory to save ACPI_CPU_DATA.
@return Pointer to allocated ACPI_CPU_DATA. @return Pointer to allocated ACPI_CPU_DATA.
**/ **/
ACPI_CPU_DATA * ACPI_CPU_DATA *
AllocateAcpiCpuData ( AllocateAcpiCpuData (
VOID VOID
) )
{ {
// //
// CpuS3DataDxe will do it. // CpuS3DataDxe will do it.
// //
ASSERT (FALSE); ASSERT (FALSE);
return NULL; return NULL;
} }
/** /**
Enlarges CPU register table for each processor. Enlarges CPU register table for each processor.
@param[in, out] RegisterTable Pointer processor's CPU register table @param[in, out] RegisterTable Pointer processor's CPU register table
**/ **/
VOID VOID
EnlargeRegisterTable ( EnlargeRegisterTable (
IN OUT CPU_REGISTER_TABLE *RegisterTable IN OUT CPU_REGISTER_TABLE *RegisterTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS Address; EFI_PHYSICAL_ADDRESS Address;
UINTN AllocatePages; UINTN AllocatePages;
Address = BASE_4GB - 1; Address = BASE_4GB - 1;
AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE; AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE;
Status = gBS->AllocatePages ( Status = gBS->AllocatePages (
AllocateMaxAddress, AllocateMaxAddress,
EfiACPIMemoryNVS, EfiACPIMemoryNVS,
AllocatePages + 1, AllocatePages + 1,
&Address &Address
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// If there are records existing in the register table, then copy its contents // If there are records existing in the register table, then copy its contents
// to new region and free the old one. // to new region and free the old one.
// //
if (RegisterTable->AllocatedSize > 0) { if (RegisterTable->AllocatedSize > 0) {
CopyMem ( CopyMem (
(VOID *) (UINTN) Address, (VOID *) (UINTN) Address,
(VOID *) (UINTN) RegisterTable->RegisterTableEntry, (VOID *) (UINTN) RegisterTable->RegisterTableEntry,
RegisterTable->AllocatedSize RegisterTable->AllocatedSize
); );
// //
// RegisterTableEntry is allocated by gBS->AllocatePages() service. // RegisterTableEntry is allocated by gBS->AllocatePages() service.
// So, gBS->FreePages() service is used to free it. // So, gBS->FreePages() service is used to free it.
// //
gBS->FreePages ( gBS->FreePages (
RegisterTable->RegisterTableEntry, RegisterTable->RegisterTableEntry,
AllocatePages AllocatePages
); );
} }
// //
// Adjust the allocated size and register table base address. // Adjust the allocated size and register table base address.
// //
RegisterTable->AllocatedSize += EFI_PAGE_SIZE; RegisterTable->AllocatedSize += EFI_PAGE_SIZE;
RegisterTable->RegisterTableEntry = Address; RegisterTable->RegisterTableEntry = Address;
} }

View File

@ -1,62 +1,62 @@
## @file ## @file
# Register CPU Features Library DXE instance. # Register CPU Features Library DXE instance.
# #
# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # 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 # which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php # http://opensource.org/licenses/bsd-license.php
# #
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# #
## ##
[Defines] [Defines]
INF_VERSION = 0x00010005 INF_VERSION = 0x00010005
BASE_NAME = DxeRegisterCpuFeaturesLib BASE_NAME = DxeRegisterCpuFeaturesLib
MODULE_UNI_FILE = DxeRegisterCpuFeaturesLib.uni MODULE_UNI_FILE = DxeRegisterCpuFeaturesLib.uni
FILE_GUID = ADE8F745-AA2E-49f6-8ED4-746B34867E52 FILE_GUID = ADE8F745-AA2E-49f6-8ED4-746B34867E52
MODULE_TYPE = DXE_DRIVER MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0 VERSION_STRING = 1.0
LIBRARY_CLASS = RegisterCpuFeaturesLib|DXE_DRIVER LIBRARY_CLASS = RegisterCpuFeaturesLib|DXE_DRIVER
# #
# The following information is for reference only and not required by the build tools. # The following information is for reference only and not required by the build tools.
# #
# VALID_ARCHITECTURES = IA32 X64 # VALID_ARCHITECTURES = IA32 X64
# #
[Sources.common] [Sources.common]
DxeRegisterCpuFeaturesLib.c DxeRegisterCpuFeaturesLib.c
RegisterCpuFeaturesLib.c RegisterCpuFeaturesLib.c
RegisterCpuFeatures.h RegisterCpuFeatures.h
CpuFeaturesInitialize.c CpuFeaturesInitialize.c
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
UefiCpuPkg/UefiCpuPkg.dec UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses] [LibraryClasses]
BaseLib BaseLib
DebugLib DebugLib
PcdLib PcdLib
LocalApicLib LocalApicLib
BaseMemoryLib BaseMemoryLib
MemoryAllocationLib MemoryAllocationLib
SynchronizationLib SynchronizationLib
UefiBootServicesTableLib UefiBootServicesTableLib
IoLib IoLib
[Protocols] [Protocols]
gEfiMpServiceProtocolGuid ## CONSUMES gEfiMpServiceProtocolGuid ## CONSUMES
[Pcd] [Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability ## PRODUCES gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability ## PRODUCES
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting ## PRODUCES gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting ## PRODUCES
[Depex] [Depex]
gEfiMpServiceProtocolGuid AND gEdkiiCpuFeaturesSetDoneGuid gEfiMpServiceProtocolGuid AND gEdkiiCpuFeaturesSetDoneGuid

View File

@ -1,390 +1,390 @@
/** @file /** @file
CPU Register Table Library functions. CPU Register Table Library functions.
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#include <PiPei.h> #include <PiPei.h>
#include <Library/HobLib.h> #include <Library/HobLib.h>
#include <Library/PeiServicesLib.h> #include <Library/PeiServicesLib.h>
#include <Library/PeiServicesTablePointerLib.h> #include <Library/PeiServicesTablePointerLib.h>
#include <Ppi/MpServices.h> #include <Ppi/MpServices.h>
#include "RegisterCpuFeatures.h" #include "RegisterCpuFeatures.h"
#define REGISTER_CPU_FEATURES_GUID \ #define REGISTER_CPU_FEATURES_GUID \
{ \ { \
0xa694c467, 0x697a, 0x446b, { 0xb9, 0x29, 0x5b, 0x14, 0xa0, 0xcf, 0x39, 0xf } \ 0xa694c467, 0x697a, 0x446b, { 0xb9, 0x29, 0x5b, 0x14, 0xa0, 0xcf, 0x39, 0xf } \
} }
EFI_GUID mRegisterCpuFeaturesHobGuid = REGISTER_CPU_FEATURES_GUID; EFI_GUID mRegisterCpuFeaturesHobGuid = REGISTER_CPU_FEATURES_GUID;
/** /**
Worker function to get CPU_FEATURES_DATA pointer. Worker function to get CPU_FEATURES_DATA pointer.
@return Pointer to CPU_FEATURES_DATA. @return Pointer to CPU_FEATURES_DATA.
**/ **/
CPU_FEATURES_DATA * CPU_FEATURES_DATA *
GetCpuFeaturesData ( GetCpuFeaturesData (
VOID VOID
) )
{ {
CPU_FEATURES_DATA *CpuInitData; CPU_FEATURES_DATA *CpuInitData;
EFI_HOB_GUID_TYPE *GuidHob; EFI_HOB_GUID_TYPE *GuidHob;
VOID *DataInHob; VOID *DataInHob;
UINT64 Data64; UINT64 Data64;
CpuInitData = NULL; CpuInitData = NULL;
GuidHob = GetFirstGuidHob (&mRegisterCpuFeaturesHobGuid); GuidHob = GetFirstGuidHob (&mRegisterCpuFeaturesHobGuid);
if (GuidHob != NULL) { if (GuidHob != NULL) {
DataInHob = GET_GUID_HOB_DATA (GuidHob); DataInHob = GET_GUID_HOB_DATA (GuidHob);
CpuInitData = (CPU_FEATURES_DATA *) (*(UINTN *) DataInHob); CpuInitData = (CPU_FEATURES_DATA *) (*(UINTN *) DataInHob);
ASSERT (CpuInitData != NULL); ASSERT (CpuInitData != NULL);
} else { } else {
CpuInitData = AllocateZeroPool (sizeof (CPU_FEATURES_DATA)); CpuInitData = AllocateZeroPool (sizeof (CPU_FEATURES_DATA));
ASSERT (CpuInitData != NULL); ASSERT (CpuInitData != NULL);
// //
// Build location of CPU MP DATA buffer in HOB // Build location of CPU MP DATA buffer in HOB
// //
Data64 = (UINT64) (UINTN) CpuInitData; Data64 = (UINT64) (UINTN) CpuInitData;
BuildGuidDataHob ( BuildGuidDataHob (
&mRegisterCpuFeaturesHobGuid, &mRegisterCpuFeaturesHobGuid,
(VOID *) &Data64, (VOID *) &Data64,
sizeof (UINT64) sizeof (UINT64)
); );
} }
return CpuInitData; return CpuInitData;
} }
/** /**
Worker function to get MP PPI service pointer. Worker function to get MP PPI service pointer.
@return PEI PPI service pointer. @return PEI PPI service pointer.
**/ **/
EFI_PEI_MP_SERVICES_PPI * EFI_PEI_MP_SERVICES_PPI *
GetMpPpi ( GetMpPpi (
VOID VOID
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; EFI_PEI_MP_SERVICES_PPI *CpuMpPpi;
// //
// Get MP Services Protocol // Get MP Services Protocol
// //
Status = PeiServicesLocatePpi ( Status = PeiServicesLocatePpi (
&gEfiPeiMpServicesPpiGuid, &gEfiPeiMpServicesPpiGuid,
0, 0,
NULL, NULL,
(VOID **)&CpuMpPpi (VOID **)&CpuMpPpi
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return CpuMpPpi; return CpuMpPpi;
} }
/** /**
Worker function to return processor index. Worker function to return processor index.
@return The processor index. @return The processor index.
**/ **/
UINTN UINTN
GetProcessorIndex ( GetProcessorIndex (
VOID VOID
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; EFI_PEI_MP_SERVICES_PPI *CpuMpPpi;
UINTN ProcessorIndex; UINTN ProcessorIndex;
CpuMpPpi = GetMpPpi (); CpuMpPpi = GetMpPpi ();
Status = CpuMpPpi->WhoAmI(GetPeiServicesTablePointer (), CpuMpPpi, &ProcessorIndex); Status = CpuMpPpi->WhoAmI(GetPeiServicesTablePointer (), CpuMpPpi, &ProcessorIndex);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return ProcessorIndex; return ProcessorIndex;
} }
/** /**
Worker function to MP-related information on the requested processor at the Worker function to MP-related information on the requested processor at the
instant this call is made. instant this call is made.
@param[in] ProcessorNumber The handle number of processor. @param[in] ProcessorNumber The handle number of processor.
@param[out] ProcessorInfoBuffer A pointer to the buffer where information for @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
the requested processor is deposited. the requested processor is deposited.
@return Status of MpServices->GetProcessorInfo(). @return Status of MpServices->GetProcessorInfo().
**/ **/
EFI_STATUS EFI_STATUS
GetProcessorInformation ( GetProcessorInformation (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
) )
{ {
EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; EFI_PEI_MP_SERVICES_PPI *CpuMpPpi;
EFI_STATUS Status; EFI_STATUS Status;
CpuMpPpi = GetMpPpi (); CpuMpPpi = GetMpPpi ();
Status = CpuMpPpi->GetProcessorInfo ( Status = CpuMpPpi->GetProcessorInfo (
GetPeiServicesTablePointer(), GetPeiServicesTablePointer(),
CpuMpPpi, CpuMpPpi,
ProcessorNumber, ProcessorNumber,
ProcessorInfoBuffer ProcessorInfoBuffer
); );
return Status; return Status;
} }
/** /**
Worker function to execute a caller provided function on all enabled APs. Worker function to execute a caller provided function on all enabled APs.
@param[in] Procedure A pointer to the function to be run on @param[in] Procedure A pointer to the function to be run on
enabled APs of the system. enabled APs of the system.
**/ **/
VOID VOID
StartupAPsWorker ( StartupAPsWorker (
IN EFI_AP_PROCEDURE Procedure IN EFI_AP_PROCEDURE Procedure
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; EFI_PEI_MP_SERVICES_PPI *CpuMpPpi;
// //
// Get MP Services Protocol // Get MP Services Protocol
// //
Status = PeiServicesLocatePpi ( Status = PeiServicesLocatePpi (
&gEfiPeiMpServicesPpiGuid, &gEfiPeiMpServicesPpiGuid,
0, 0,
NULL, NULL,
(VOID **)&CpuMpPpi (VOID **)&CpuMpPpi
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// Wakeup all APs for data collection. // Wakeup all APs for data collection.
// //
Status = CpuMpPpi->StartupAllAPs ( Status = CpuMpPpi->StartupAllAPs (
GetPeiServicesTablePointer (), GetPeiServicesTablePointer (),
CpuMpPpi, CpuMpPpi,
Procedure, Procedure,
FALSE, FALSE,
0, 0,
NULL NULL
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
/** /**
Worker function to switch the requested AP to be the BSP from that point onward. 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. @param[in] ProcessorNumber The handle number of AP that is to become the new BSP.
**/ **/
VOID VOID
SwitchNewBsp ( SwitchNewBsp (
IN UINTN ProcessorNumber IN UINTN ProcessorNumber
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; EFI_PEI_MP_SERVICES_PPI *CpuMpPpi;
// //
// Get MP Services Protocol // Get MP Services Protocol
// //
Status = PeiServicesLocatePpi ( Status = PeiServicesLocatePpi (
&gEfiPeiMpServicesPpiGuid, &gEfiPeiMpServicesPpiGuid,
0, 0,
NULL, NULL,
(VOID **)&CpuMpPpi (VOID **)&CpuMpPpi
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// Wakeup all APs for data collection. // Wakeup all APs for data collection.
// //
Status = CpuMpPpi->SwitchBSP ( Status = CpuMpPpi->SwitchBSP (
GetPeiServicesTablePointer (), GetPeiServicesTablePointer (),
CpuMpPpi, CpuMpPpi,
ProcessorNumber, ProcessorNumber,
TRUE TRUE
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
/** /**
Worker function to retrieve the number of logical processor in the platform. Worker function to retrieve the number of logical processor in the platform.
@param[out] NumberOfCpus Pointer to the total number of logical @param[out] NumberOfCpus Pointer to the total number of logical
processors in the system, including the BSP processors in the system, including the BSP
and disabled APs. and disabled APs.
@param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
processors that exist in system, including processors that exist in system, including
the BSP. the BSP.
**/ **/
VOID VOID
GetNumberOfProcessor ( GetNumberOfProcessor (
OUT UINTN *NumberOfCpus, OUT UINTN *NumberOfCpus,
OUT UINTN *NumberOfEnabledProcessors OUT UINTN *NumberOfEnabledProcessors
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; EFI_PEI_MP_SERVICES_PPI *CpuMpPpi;
// //
// Get MP Services Protocol // Get MP Services Protocol
// //
Status = PeiServicesLocatePpi ( Status = PeiServicesLocatePpi (
&gEfiPeiMpServicesPpiGuid, &gEfiPeiMpServicesPpiGuid,
0, 0,
NULL, NULL,
(VOID **)&CpuMpPpi (VOID **)&CpuMpPpi
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// Get the number of CPUs // Get the number of CPUs
// //
Status = CpuMpPpi->GetNumberOfProcessors ( Status = CpuMpPpi->GetNumberOfProcessors (
GetPeiServicesTablePointer (), GetPeiServicesTablePointer (),
CpuMpPpi, CpuMpPpi,
NumberOfCpus, NumberOfCpus,
NumberOfEnabledProcessors NumberOfEnabledProcessors
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
/** /**
Allocates ACPI NVS memory to save ACPI_CPU_DATA. Allocates ACPI NVS memory to save ACPI_CPU_DATA.
@return Pointer to allocated ACPI_CPU_DATA. @return Pointer to allocated ACPI_CPU_DATA.
**/ **/
ACPI_CPU_DATA * ACPI_CPU_DATA *
AllocateAcpiCpuData ( AllocateAcpiCpuData (
VOID VOID
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; EFI_PEI_MP_SERVICES_PPI *CpuMpPpi;
UINTN NumberOfCpus; UINTN NumberOfCpus;
UINTN NumberOfEnabledProcessors; UINTN NumberOfEnabledProcessors;
ACPI_CPU_DATA *AcpiCpuData; ACPI_CPU_DATA *AcpiCpuData;
EFI_PHYSICAL_ADDRESS Address; EFI_PHYSICAL_ADDRESS Address;
UINTN TableSize; UINTN TableSize;
CPU_REGISTER_TABLE *RegisterTable; CPU_REGISTER_TABLE *RegisterTable;
UINTN Index; UINTN Index;
EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer;
Status = PeiServicesAllocatePages ( Status = PeiServicesAllocatePages (
EfiACPIMemoryNVS, EfiACPIMemoryNVS,
EFI_SIZE_TO_PAGES (sizeof (ACPI_CPU_DATA)), EFI_SIZE_TO_PAGES (sizeof (ACPI_CPU_DATA)),
&Address &Address
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) Address; AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) Address;
ASSERT (AcpiCpuData != NULL); ASSERT (AcpiCpuData != NULL);
// //
// Get MP Services Protocol // Get MP Services Protocol
// //
Status = PeiServicesLocatePpi ( Status = PeiServicesLocatePpi (
&gEfiPeiMpServicesPpiGuid, &gEfiPeiMpServicesPpiGuid,
0, 0,
NULL, NULL,
(VOID **)&CpuMpPpi (VOID **)&CpuMpPpi
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// Get the number of CPUs // Get the number of CPUs
// //
Status = CpuMpPpi->GetNumberOfProcessors ( Status = CpuMpPpi->GetNumberOfProcessors (
GetPeiServicesTablePointer (), GetPeiServicesTablePointer (),
CpuMpPpi, CpuMpPpi,
&NumberOfCpus, &NumberOfCpus,
&NumberOfEnabledProcessors &NumberOfEnabledProcessors
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus; AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus;
// //
// Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs
// //
TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE); TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE);
Status = PeiServicesAllocatePages ( Status = PeiServicesAllocatePages (
EfiACPIMemoryNVS, EfiACPIMemoryNVS,
EFI_SIZE_TO_PAGES (TableSize), EFI_SIZE_TO_PAGES (TableSize),
&Address &Address
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
RegisterTable = (CPU_REGISTER_TABLE *) (UINTN) Address; RegisterTable = (CPU_REGISTER_TABLE *) (UINTN) Address;
for (Index = 0; Index < NumberOfCpus; Index++) { for (Index = 0; Index < NumberOfCpus; Index++) {
Status = CpuMpPpi->GetProcessorInfo ( Status = CpuMpPpi->GetProcessorInfo (
GetPeiServicesTablePointer (), GetPeiServicesTablePointer (),
CpuMpPpi, CpuMpPpi,
Index, Index,
&ProcessorInfoBuffer &ProcessorInfoBuffer
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
RegisterTable[Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; RegisterTable[Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId;
RegisterTable[Index].TableLength = 0; RegisterTable[Index].TableLength = 0;
RegisterTable[Index].AllocatedSize = 0; RegisterTable[Index].AllocatedSize = 0;
RegisterTable[Index].RegisterTableEntry = 0; RegisterTable[Index].RegisterTableEntry = 0;
RegisterTable[NumberOfCpus + Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; RegisterTable[NumberOfCpus + Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId;
RegisterTable[NumberOfCpus + Index].TableLength = 0; RegisterTable[NumberOfCpus + Index].TableLength = 0;
RegisterTable[NumberOfCpus + Index].AllocatedSize = 0; RegisterTable[NumberOfCpus + Index].AllocatedSize = 0;
RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0; RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0;
} }
AcpiCpuData->RegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable; AcpiCpuData->RegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable;
AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus); AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus);
return AcpiCpuData; return AcpiCpuData;
} }
/** /**
Enlarges CPU register table for each processor. Enlarges CPU register table for each processor.
@param[in, out] RegisterTable Pointer processor's CPU register table @param[in, out] RegisterTable Pointer processor's CPU register table
**/ **/
VOID VOID
EnlargeRegisterTable ( EnlargeRegisterTable (
IN OUT CPU_REGISTER_TABLE *RegisterTable IN OUT CPU_REGISTER_TABLE *RegisterTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS Address; EFI_PHYSICAL_ADDRESS Address;
UINTN AllocatePages; UINTN AllocatePages;
AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE; AllocatePages = RegisterTable->AllocatedSize / EFI_PAGE_SIZE;
Status = PeiServicesAllocatePages ( Status = PeiServicesAllocatePages (
EfiACPIMemoryNVS, EfiACPIMemoryNVS,
AllocatePages + 1, AllocatePages + 1,
&Address &Address
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// If there are records existing in the register table, then copy its contents // If there are records existing in the register table, then copy its contents
// to new region and free the old one. // to new region and free the old one.
// //
if (RegisterTable->AllocatedSize > 0) { if (RegisterTable->AllocatedSize > 0) {
CopyMem ( CopyMem (
(VOID *) (UINTN) Address, (VOID *) (UINTN) Address,
(VOID *) (UINTN) RegisterTable->RegisterTableEntry, (VOID *) (UINTN) RegisterTable->RegisterTableEntry,
RegisterTable->AllocatedSize RegisterTable->AllocatedSize
); );
} }
// //
// Adjust the allocated size and register table base address. // Adjust the allocated size and register table base address.
// //
RegisterTable->AllocatedSize += EFI_PAGE_SIZE; RegisterTable->AllocatedSize += EFI_PAGE_SIZE;
RegisterTable->RegisterTableEntry = Address; RegisterTable->RegisterTableEntry = Address;
} }

View File

@ -1,64 +1,64 @@
## @file ## @file
# Register CPU Features Library PEI instance. # Register CPU Features Library PEI instance.
# #
# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # 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 # which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php # http://opensource.org/licenses/bsd-license.php
# #
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# #
## ##
[Defines] [Defines]
INF_VERSION = 0x00010005 INF_VERSION = 0x00010005
BASE_NAME = PeiRegisterCpuFeaturesLib BASE_NAME = PeiRegisterCpuFeaturesLib
MODULE_UNI_FILE = PeiRegisterCpuFeaturesLib.uni MODULE_UNI_FILE = PeiRegisterCpuFeaturesLib.uni
FILE_GUID = D8855DB3-8348-41B5-BDA4-385351767D41 FILE_GUID = D8855DB3-8348-41B5-BDA4-385351767D41
MODULE_TYPE = PEIM MODULE_TYPE = PEIM
VERSION_STRING = 1.0 VERSION_STRING = 1.0
LIBRARY_CLASS = RegisterCpuFeaturesLib|PEIM LIBRARY_CLASS = RegisterCpuFeaturesLib|PEIM
# #
# The following information is for reference only and not required by the build tools. # The following information is for reference only and not required by the build tools.
# #
# VALID_ARCHITECTURES = IA32 X64 # VALID_ARCHITECTURES = IA32 X64
# #
[Sources.common] [Sources.common]
PeiRegisterCpuFeaturesLib.c PeiRegisterCpuFeaturesLib.c
RegisterCpuFeaturesLib.c RegisterCpuFeaturesLib.c
RegisterCpuFeatures.h RegisterCpuFeatures.h
CpuFeaturesInitialize.c CpuFeaturesInitialize.c
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
UefiCpuPkg/UefiCpuPkg.dec UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses] [LibraryClasses]
BaseLib BaseLib
DebugLib DebugLib
PcdLib PcdLib
LocalApicLib LocalApicLib
BaseMemoryLib BaseMemoryLib
MemoryAllocationLib MemoryAllocationLib
SynchronizationLib SynchronizationLib
HobLib HobLib
PeiServicesLib PeiServicesLib
PeiServicesTablePointerLib PeiServicesTablePointerLib
IoLib IoLib
[Ppis] [Ppis]
gEfiPeiMpServicesPpiGuid ## CONSUMES gEfiPeiMpServicesPpiGuid ## CONSUMES
[Pcd] [Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration ## CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration ## CONSUMES
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability ## PRODUCES gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability ## PRODUCES
gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting ## PRODUCES gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting ## PRODUCES
[Depex] [Depex]
gEfiPeiMpServicesPpiGuid AND gEdkiiCpuFeaturesSetDoneGuid gEfiPeiMpServicesPpiGuid AND gEdkiiCpuFeaturesSetDoneGuid

View File

@ -1,193 +1,193 @@
/** @file /** @file
CPU Register Table Library definitions. CPU Register Table Library definitions.
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#ifndef _REGISTER_CPU_FEATURES_H_ #ifndef _REGISTER_CPU_FEATURES_H_
#define _REGISTER_CPU_FEATURES_H_ #define _REGISTER_CPU_FEATURES_H_
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/RegisterCpuFeaturesLib.h> #include <Library/RegisterCpuFeaturesLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/SynchronizationLib.h> #include <Library/SynchronizationLib.h>
#include <Library/IoLib.h> #include <Library/IoLib.h>
#include <AcpiCpuData.h> #include <AcpiCpuData.h>
#define CPU_FEATURE_ENTRY_SIGNATURE SIGNATURE_32 ('C', 'F', 'E', 'S') #define CPU_FEATURE_ENTRY_SIGNATURE SIGNATURE_32 ('C', 'F', 'E', 'S')
#define CPU_FEATURE_NAME_SIZE 128 #define CPU_FEATURE_NAME_SIZE 128
typedef struct { typedef struct {
REGISTER_CPU_FEATURE_INFORMATION CpuInfo; REGISTER_CPU_FEATURE_INFORMATION CpuInfo;
UINT8 *FeaturesSupportedMask; UINT8 *FeaturesSupportedMask;
LIST_ENTRY OrderList; LIST_ENTRY OrderList;
} CPU_FEATURES_INIT_ORDER; } CPU_FEATURES_INIT_ORDER;
typedef struct { typedef struct {
UINT32 Signature; UINT32 Signature;
LIST_ENTRY Link; LIST_ENTRY Link;
UINT8 *FeatureMask; UINT8 *FeatureMask;
CHAR8 *FeatureName; CHAR8 *FeatureName;
CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc; CPU_FEATURE_GET_CONFIG_DATA GetConfigDataFunc;
CPU_FEATURE_SUPPORT SupportFunc; CPU_FEATURE_SUPPORT SupportFunc;
CPU_FEATURE_INITIALIZE InitializeFunc; CPU_FEATURE_INITIALIZE InitializeFunc;
UINT8 *BeforeFeatureBitMask; UINT8 *BeforeFeatureBitMask;
UINT8 *AfterFeatureBitMask; UINT8 *AfterFeatureBitMask;
VOID *ConfigData; VOID *ConfigData;
BOOLEAN BeforeAll; BOOLEAN BeforeAll;
BOOLEAN AfterAll; BOOLEAN AfterAll;
} CPU_FEATURES_ENTRY; } CPU_FEATURES_ENTRY;
typedef struct { typedef struct {
UINTN FeaturesCount; UINTN FeaturesCount;
UINT32 BitMaskSize; UINT32 BitMaskSize;
SPIN_LOCK MsrLock; SPIN_LOCK MsrLock;
SPIN_LOCK MemoryMappedLock; SPIN_LOCK MemoryMappedLock;
LIST_ENTRY FeatureList; LIST_ENTRY FeatureList;
CPU_FEATURES_INIT_ORDER *InitOrder; CPU_FEATURES_INIT_ORDER *InitOrder;
UINT8 *SupportPcds; UINT8 *SupportPcds;
UINT8 *CapabilityPcds; UINT8 *CapabilityPcds;
UINT8 *ConfigurationPcds; UINT8 *ConfigurationPcds;
UINT8 *SettingPcds; UINT8 *SettingPcds;
CPU_REGISTER_TABLE *RegisterTable; CPU_REGISTER_TABLE *RegisterTable;
CPU_REGISTER_TABLE *PreSmmRegisterTable; CPU_REGISTER_TABLE *PreSmmRegisterTable;
UINTN BspNumber; UINTN BspNumber;
} CPU_FEATURES_DATA; } CPU_FEATURES_DATA;
#define CPU_FEATURE_ENTRY_FROM_LINK(a) \ #define CPU_FEATURE_ENTRY_FROM_LINK(a) \
CR ( \ CR ( \
(a), \ (a), \
CPU_FEATURES_ENTRY, \ CPU_FEATURES_ENTRY, \
Link, \ Link, \
CPU_FEATURE_ENTRY_SIGNATURE \ CPU_FEATURE_ENTRY_SIGNATURE \
) )
/** /**
Worker function to get CPU_FEATURES_DATA pointer. Worker function to get CPU_FEATURES_DATA pointer.
@return Pointer to CPU_FEATURES_DATA. @return Pointer to CPU_FEATURES_DATA.
**/ **/
CPU_FEATURES_DATA * CPU_FEATURES_DATA *
GetCpuFeaturesData ( GetCpuFeaturesData (
VOID VOID
); );
/** /**
Enlarges CPU register table for each processor. Enlarges CPU register table for each processor.
@param[in, out] RegisterTable Pointer processor's CPU register table @param[in, out] RegisterTable Pointer processor's CPU register table
**/ **/
VOID VOID
EnlargeRegisterTable ( EnlargeRegisterTable (
IN OUT CPU_REGISTER_TABLE *RegisterTable IN OUT CPU_REGISTER_TABLE *RegisterTable
); );
/** /**
Allocates ACPI NVS memory to save ACPI_CPU_DATA. Allocates ACPI NVS memory to save ACPI_CPU_DATA.
@return Pointer to allocated ACPI_CPU_DATA. @return Pointer to allocated ACPI_CPU_DATA.
**/ **/
ACPI_CPU_DATA * ACPI_CPU_DATA *
AllocateAcpiCpuData ( AllocateAcpiCpuData (
VOID VOID
); );
/** /**
Worker function to return processor index. Worker function to return processor index.
@return The processor index. @return The processor index.
**/ **/
UINTN UINTN
GetProcessorIndex ( GetProcessorIndex (
VOID VOID
); );
/** /**
Gets detailed MP-related information on the requested processor at the Gets detailed MP-related information on the requested processor at the
instant this call is made. instant this call is made.
@param[in] ProcessorNumber The handle number of processor. @param[in] ProcessorNumber The handle number of processor.
@param[out] ProcessorInfoBuffer A pointer to the buffer where information for @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
the requested processor is deposited. the requested processor is deposited.
@return Status of MpServices->GetProcessorInfo(). @return Status of MpServices->GetProcessorInfo().
**/ **/
EFI_STATUS EFI_STATUS
GetProcessorInformation ( GetProcessorInformation (
IN UINTN ProcessorNumber, IN UINTN ProcessorNumber,
OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
); );
/** /**
Worker function to execute a caller provided function on all enabled APs. Worker function to execute a caller provided function on all enabled APs.
@param[in] Procedure A pointer to the function to be run on @param[in] Procedure A pointer to the function to be run on
enabled APs of the system. enabled APs of the system.
**/ **/
VOID VOID
StartupAPsWorker ( StartupAPsWorker (
IN EFI_AP_PROCEDURE Procedure IN EFI_AP_PROCEDURE Procedure
); );
/** /**
Worker function to retrieve the number of logical processor in the platform. Worker function to retrieve the number of logical processor in the platform.
@param[out] NumberOfCpus Pointer to the total number of logical @param[out] NumberOfCpus Pointer to the total number of logical
processors in the system, including the BSP processors in the system, including the BSP
and disabled APs. and disabled APs.
@param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
processors that exist in system, including processors that exist in system, including
the BSP. the BSP.
**/ **/
VOID VOID
GetNumberOfProcessor ( GetNumberOfProcessor (
OUT UINTN *NumberOfCpus, OUT UINTN *NumberOfCpus,
OUT UINTN *NumberOfEnabledProcessors OUT UINTN *NumberOfEnabledProcessors
); );
/** /**
Worker function to switch the requested AP to be the BSP from that point onward. 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. @param[in] ProcessorNumber The handle number of AP that is to become the new BSP.
**/ **/
VOID VOID
SwitchNewBsp ( SwitchNewBsp (
IN UINTN ProcessorNumber IN UINTN ProcessorNumber
); );
/** /**
Function that uses DEBUG() macros to display the contents of a a CPU feature bit mask. 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. @param[in] FeatureMask A pointer to the CPU feature bit mask.
**/ **/
VOID VOID
DumpCpuFeatureMask ( DumpCpuFeatureMask (
IN UINT8 *FeatureMask IN UINT8 *FeatureMask
); );
/** /**
Dump CPU feature name or CPU feature bit mask. Dump CPU feature name or CPU feature bit mask.
@param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY @param[in] CpuFeature Pointer to CPU_FEATURES_ENTRY
**/ **/
VOID VOID
DumpCpuFeature ( DumpCpuFeature (
IN CPU_FEATURES_ENTRY *CpuFeature IN CPU_FEATURES_ENTRY *CpuFeature
); );
#endif #endif

View File

@ -1,22 +1,22 @@
// /** @file // /** @file
// CPU Register Table Library instance. // CPU Register Table Library instance.
// //
// CPU Register Table Library instance. // CPU Register Table Library instance.
// //
// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR> // Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
// //
// This program and the accompanying materials // This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License // 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 // which accompanies this distribution. The full text of the license may be found at
// http://opensource.org/licenses/bsd-license.php // http://opensource.org/licenses/bsd-license.php
// //
// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // 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_ABSTRACT #language en-US "CPU Register Table Library instance"
#string STR_MODULE_DESCRIPTION #language en-US "CPU Register Table Library instance." #string STR_MODULE_DESCRIPTION #language en-US "CPU Register Table Library instance."