Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHERRY-PICK] Merge UefiCpuPkg/UefiCpuLib to MdePkg/CpuLib [Rebase & FF] #544

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions MdePkg/Include/Library/CpuLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,52 @@ CpuFlushTlb (
VOID
);

#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)

/**
Initializes floating point units for requirement of UEFI specification.
This function initializes floating-point control word to 0x027F (all exceptions
masked,double-precision, round-to-nearest) and multimedia-extensions control word
(if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero
for masked underflow).
**/
VOID
EFIAPI
InitializeFloatingPointUnits (
VOID
);

/**
Determine if the standard CPU signature is "AuthenticAMD".
@retval TRUE The CPU signature matches.
@retval FALSE The CPU signature does not match.
**/
BOOLEAN
EFIAPI
StandardSignatureIsAuthenticAMD (
VOID
);

/**
Return the 32bit CPU family and model value.
@return CPUID[01h].EAX with Processor Type and Stepping ID cleared.
**/
UINT32
EFIAPI
GetCpuFamilyModel (
VOID
);

/**
Return the CPU stepping ID.
@return CPU stepping ID value in CPUID[01h].EAX.
**/
UINT8
EFIAPI
GetCpuSteppingId (
VOID
);

#endif

#endif
6 changes: 6 additions & 0 deletions MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@
# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64 RISCV64 LOONGARCH64
#

[Sources.IA32, Sources.X64]
X86BaseCpuLib.c

[Sources.IA32]
Ia32/CpuSleep.c | MSFT
Ia32/CpuSleep.nasm| INTEL
Ia32/CpuSleepGcc.c | GCC
X86CpuFlushTlb.c

Ia32/InitializeFpu.nasm

[Sources.X64]
X86CpuFlushTlb.c
X64/CpuSleep.nasm

X64/InitializeFpu.nasm

[Sources.EBC]
Ebc/CpuSleepFlushTlb.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <Register/Amd/Cpuid.h>

#include <Library/BaseLib.h>
#include <Library/UefiCpuLib.h>
#include <Library/CpuLib.h>

/**
Determine if the standard CPU signature is "AuthenticAMD".
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/CpuDxe/CpuDxe.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <Library/DebugLib.h>
#include <Library/MtrrLib.h>
#include <Library/LocalApicLib.h>
#include <Library/UefiCpuLib.h>
#include <Library/UefiLib.h>
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/HobLib.h>
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/CpuDxe/CpuDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
UefiBootServicesTableLib
UefiDriverEntryPoint
LocalApicLib
UefiCpuLib
UefiLib
CpuExceptionHandlerLib
HobLib
Expand Down
49 changes: 0 additions & 49 deletions UefiCpuPkg/Include/Library/UefiCpuLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,4 @@
#ifndef __UEFI_CPU_LIB_H__
#define __UEFI_CPU_LIB_H__

/**
Initializes floating point units for requirement of UEFI specification.

This function initializes floating-point control word to 0x027F (all exceptions
masked,double-precision, round-to-nearest) and multimedia-extensions control word
(if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to zero
for masked underflow).

**/
VOID
EFIAPI
InitializeFloatingPointUnits (
VOID
);

/**
Determine if the standard CPU signature is "AuthenticAMD".

@retval TRUE The CPU signature matches.
@retval FALSE The CPU signature does not match.

**/
BOOLEAN
EFIAPI
StandardSignatureIsAuthenticAMD (
VOID
);

/**
Return the 32bit CPU family and model value.

@return CPUID[01h].EAX with Processor Type and Stepping ID cleared.
**/
UINT32
EFIAPI
GetCpuFamilyModel (
VOID
);

/**
Return the CPU stepping ID.
@return CPU stepping ID value in CPUID[01h].EAX.
**/
UINT8
EFIAPI
GetCpuSteppingId (
VOID
);

#endif
8 changes: 1 addition & 7 deletions UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@
# VALID_ARCHITECTURES = IA32 X64
#

[Sources.IA32]
Ia32/InitializeFpu.nasm

[Sources.X64]
X64/InitializeFpu.nasm

[Sources]
BaseUefiCpuLib.c
BaseUefiCpuLibNull.c

[Packages]
MdePkg/MdePkg.dec
Expand Down
18 changes: 18 additions & 0 deletions UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @file
This library contains a dummy function to pass build.

Copyright (c) 2022, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Base.h>

/**
Dummy function.
**/
VOID
Dummy (
VOID
)
{
}
1 change: 0 additions & 1 deletion UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <Library/TimerLib.h>
#include <Library/PcdLib.h>
#include <Library/CpuLib.h>
#include <Library/UefiCpuLib.h>

//
// Library internal functions
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
IoLib
PcdLib
CpuLib
UefiCpuLib

[Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES_CONSUMES
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <Library/TimerLib.h>
#include <Library/PcdLib.h>
#include <Library/CpuLib.h>
#include <Library/UefiCpuLib.h>
#include <IndustryStandard/Tdx.h>

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
IoLib
PcdLib
CpuLib
UefiCpuLib

[Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES_CONSUMES
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
HobLib
MtrrLib
CpuLib
UefiCpuLib
UefiBootServicesTableLib
DebugAgentLib
SynchronizationLib
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/Library/MpInitLib/MpLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <Library/DebugLib.h>
#include <Library/LocalApicLib.h>
#include <Library/CpuLib.h>
#include <Library/UefiCpuLib.h>
#include <Library/TimerLib.h>
#include <Library/SynchronizationLib.h>
#include <Library/MtrrLib.h>
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
HobLib
MtrrLib
CpuLib
UefiCpuLib
SynchronizationLib
PeiServicesLib
PcdLib
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/HobLib.h>
#include <Library/LocalApicLib.h>
#include <Library/CpuLib.h>
#include <Library/UefiCpuLib.h>
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/SmmCpuFeaturesLib.h>
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
HobLib
PciLib
LocalApicLib
UefiCpuLib
SmmCpuPlatformHookLib
CpuExceptionHandlerLib
UefiLib
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/CpuLib.h>
#include <Library/UefiCpuLib.h>
#include <IndustryStandard/Acpi.h>
#include <Library/MmMemoryProtectionHobLib.h> // MU_CHANGE

Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/SecCore/SecCore.inf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
PcdLib
DebugAgentLib
CpuLib
UefiCpuLib
PeCoffGetEntryPointLib
PeCoffExtraActionLib
CpuExceptionHandlerLib
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/SecCore/SecCoreNative.inf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
PcdLib
DebugAgentLib
CpuLib
UefiCpuLib
PeCoffGetEntryPointLib
PeCoffExtraActionLib
CpuExceptionHandlerLib
Expand Down
1 change: 0 additions & 1 deletion UefiCpuPkg/SecCore/SecMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <Library/BaseMemoryLib.h>
#include <Library/PlatformSecLib.h>
#include <Library/CpuLib.h>
#include <Library/UefiCpuLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
#include <Library/PeCoffExtraActionLib.h>
#include <Library/DebugAgentLib.h>
Expand Down