Re: [edk2-devel] [PATCH v6 3/4] UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib
Reviewed-by: Eric Dong > -Original Message- > From: Garrett Kirkendall > Sent: Monday, June 22, 2020 9:18 PM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Ni, Ray ; Laszlo > Ersek > Subject: [PATCH v6 3/4] UefiCpuPkg: Move > StandardSignatureIsAuthenticAMD to BaseUefiCpuLib > > Refactor StandardSignatureIsAuthenticAMD into BaseUefiCpuLib from > separate copies in BaseXApicLib, BaseXApicX2ApicLib, and MpInitLib. > This allows for future use of StandarSignatureIsAuthinticAMD without > creating more instances in other modules. > > This function allows IA32/X64 code to determine if it is running on an AMD > brand processor. > > UefiCpuLib is already included directly or indirectly in all modified modules. > Complete move is made in this change. > > Cc: Eric Dong > Cc: Ray Ni > Cc: Laszlo Ersek > Signed-off-by: Garrett Kirkendall > Reviewed-by: Laszlo Ersek > Reviewed-by: Eric Dong > --- > UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf | 7 > UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf | 2 ++ > UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf | 2 ++ > UefiCpuPkg/Include/Library/UefiCpuLib.h | 14 > UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c | 38 > > UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c | 25 > ++--- > UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 25 ++-- > - > UefiCpuPkg/Library/MpInitLib/MpLib.c | 23 > > 8 files changed, 67 insertions(+), 69 deletions(-) > > diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf > b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf > index 006b7acbf14e..34d3a7bb4303 100644 > --- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf > +++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf > @@ -4,6 +4,7 @@ > # The library routines are UEFI specification compliant. > # > # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. > +# Copyright (c) 2020, AMD Inc. All rights reserved. > # SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -29,6 +30,12 @@ > [Sources.IA32] [Sources.X64] >X64/InitializeFpu.nasm > > +[Sources] > + BaseUefiCpuLib.c > + > [Packages] >MdePkg/MdePkg.dec >UefiCpuPkg/UefiCpuPkg.dec > + > +[LibraryClasses] > + BaseLib > diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf > b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf > index bdb2ff372677..561baa44b0e6 100644 > --- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf > +++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf > @@ -5,6 +5,7 @@ > # where local APIC is disabled. > # > # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. > +# Copyright (c) 2020, AMD Inc. All rights reserved. > # SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -37,6 +38,7 @@ > [LibraryClasses] >TimerLib >IoLib >PcdLib > + UefiCpuLib > > [Pcd] >gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## > SOMETIMES_CONSUMES diff --git > a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf > b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf > index ac1e0a1c9896..1e2a4f8b790f 100644 > --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf > +++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf > @@ -5,6 +5,7 @@ > # where local APIC is disabled. > # > # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. > +# Copyright (c) 2020, AMD Inc. All rights reserved. > # SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -37,6 +38,7 @@ > [LibraryClasses] >TimerLib >IoLib >PcdLib > + UefiCpuLib > > [Pcd] >gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## > SOMETIMES_CONSUMES diff --git > a/UefiCpuPkg/Include/Library/UefiCpuLib.h > b/UefiCpuPkg/Include/Library/UefiCpuLib.h > index 82e53bab3a0f..5326e7246301 100644 > --- a/UefiCpuPkg/Include/Library/UefiCpuLib.h > +++ b/UefiCpuPkg/Include/Library/UefiCpuLib.h > @@ -5,6 +5,7 @@ >to be UEFI specification compliant. > >Copyright (c) 2009, Intel Corporation. All rights reserved. > + Copyright (c) 2020, AMD Inc. All rights reserved. >SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -29,4 +30,17 @@ 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 > + ); > + > #endif > diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c > b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c > new file mode 100644 > index ..c2cc3ff9a709 > --- /dev/null > +++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c > @@ -0,0 +1,38 @@ > +/** @file > + This
[edk2-devel] [PATCH v6 3/4] UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib
Refactor StandardSignatureIsAuthenticAMD into BaseUefiCpuLib from separate copies in BaseXApicLib, BaseXApicX2ApicLib, and MpInitLib. This allows for future use of StandarSignatureIsAuthinticAMD without creating more instances in other modules. This function allows IA32/X64 code to determine if it is running on an AMD brand processor. UefiCpuLib is already included directly or indirectly in all modified modules. Complete move is made in this change. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Signed-off-by: Garrett Kirkendall Reviewed-by: Laszlo Ersek Reviewed-by: Eric Dong --- UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf | 7 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf | 2 ++ UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf | 2 ++ UefiCpuPkg/Include/Library/UefiCpuLib.h | 14 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c | 38 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c | 25 ++--- UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 25 ++--- UefiCpuPkg/Library/MpInitLib/MpLib.c | 23 8 files changed, 67 insertions(+), 69 deletions(-) diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf index 006b7acbf14e..34d3a7bb4303 100644 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf +++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf @@ -4,6 +4,7 @@ # The library routines are UEFI specification compliant. # # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. +# Copyright (c) 2020, AMD Inc. All rights reserved. # SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -29,6 +30,12 @@ [Sources.IA32] [Sources.X64] X64/InitializeFpu.nasm +[Sources] + BaseUefiCpuLib.c + [Packages] MdePkg/MdePkg.dec UefiCpuPkg/UefiCpuPkg.dec + +[LibraryClasses] + BaseLib diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf index bdb2ff372677..561baa44b0e6 100644 --- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf +++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf @@ -5,6 +5,7 @@ # where local APIC is disabled. # # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. +# Copyright (c) 2020, AMD Inc. All rights reserved. # SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -37,6 +38,7 @@ [LibraryClasses] TimerLib IoLib PcdLib + UefiCpuLib [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES_CONSUMES diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf index ac1e0a1c9896..1e2a4f8b790f 100644 --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf +++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf @@ -5,6 +5,7 @@ # where local APIC is disabled. # # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. +# Copyright (c) 2020, AMD Inc. All rights reserved. # SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -37,6 +38,7 @@ [LibraryClasses] TimerLib IoLib PcdLib + UefiCpuLib [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds ## SOMETIMES_CONSUMES diff --git a/UefiCpuPkg/Include/Library/UefiCpuLib.h b/UefiCpuPkg/Include/Library/UefiCpuLib.h index 82e53bab3a0f..5326e7246301 100644 --- a/UefiCpuPkg/Include/Library/UefiCpuLib.h +++ b/UefiCpuPkg/Include/Library/UefiCpuLib.h @@ -5,6 +5,7 @@ to be UEFI specification compliant. Copyright (c) 2009, Intel Corporation. All rights reserved. + Copyright (c) 2020, AMD Inc. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -29,4 +30,17 @@ 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 + ); + #endif diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c new file mode 100644 index ..c2cc3ff9a709 --- /dev/null +++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c @@ -0,0 +1,38 @@ +/** @file + This library defines some routines that are generic for IA32 family CPU. + + The library routines are UEFI specification compliant. + + Copyright (c) 2020, AMD Inc. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +#include +#include + +/** + 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 + ) +{ + UINT32 RegEbx; +