]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib
authorKirkendall, Garrett <garrett.kirkendall@amd.com>
Mon, 22 Jun 2020 13:18:24 +0000 (08:18 -0500)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 7 Jul 2020 23:25:16 +0000 (23:25 +0000)
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 <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Garrett Kirkendall <garrett.kirkendall@amd.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Message-Id: <20200622131825.1352-4-Garrett.Kirkendall@amd.com>

UefiCpuPkg/Include/Library/UefiCpuLib.h
UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c [new file with mode: 0644]
UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
UefiCpuPkg/Library/MpInitLib/MpLib.c

index 82e53bab3a0fc6c237e2e079064ac69f3a4c84c7..5326e7246301c2da4914b03647e5b353d734da8f 100644 (file)
@@ -5,6 +5,7 @@
   to be UEFI specification compliant.\r
 \r
   Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2020, AMD Inc. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -29,4 +30,17 @@ InitializeFloatingPointUnits (
   VOID\r
   );\r
 \r
+/**\r
+  Determine if the standard CPU signature is "AuthenticAMD".\r
+\r
+  @retval TRUE  The CPU signature matches.\r
+  @retval FALSE The CPU signature does not match.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+StandardSignatureIsAuthenticAMD (\r
+  VOID\r
+  );\r
+\r
 #endif\r
diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
new file mode 100644 (file)
index 0000000..c2cc3ff
--- /dev/null
@@ -0,0 +1,38 @@
+/** @file\r
+  This library defines some routines that are generic for IA32 family CPU.\r
+\r
+  The library routines are UEFI specification compliant.\r
+\r
+  Copyright (c) 2020, AMD Inc. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Register/Intel/Cpuid.h>\r
+#include <Register/Amd/Cpuid.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiCpuLib.h>\r
+\r
+/**\r
+  Determine if the standard CPU signature is "AuthenticAMD".\r
+\r
+  @retval TRUE  The CPU signature matches.\r
+  @retval FALSE The CPU signature does not match.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+StandardSignatureIsAuthenticAMD (\r
+  VOID\r
+  )\r
+{\r
+  UINT32  RegEbx;\r
+  UINT32  RegEcx;\r
+  UINT32  RegEdx;\r
+\r
+  AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);\r
+  return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&\r
+          RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&\r
+          RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);\r
+}\r
index 006b7acbf14e69795f5ff682562d216b7ba34ebe..34d3a7bb43038456ca174ea21568f842a8fb0e1c 100644 (file)
@@ -4,6 +4,7 @@
 #  The library routines are UEFI specification compliant.\r
 #\r
 #  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2020, AMD Inc. All rights reserved.<BR>\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
 [Sources.X64]\r
   X64/InitializeFpu.nasm\r
 \r
+[Sources]\r
+  BaseUefiCpuLib.c\r
+\r
 [Packages]\r
   MdePkg/MdePkg.dec\r
   UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
index 33ea15ca2916db835912f075f0b6d428c417c709..52bd90d33428e9776524660e40facb9ae5cb2cef 100644 (file)
@@ -4,7 +4,7 @@
   This local APIC library instance supports xAPIC mode only.\r
 \r
   Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>\r
-  Copyright (c) 2017, AMD Inc. All rights reserved.<BR>\r
+  Copyright (c) 2017 - 2020, AMD Inc. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 #include <Library/IoLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/UefiCpuLib.h>\r
 \r
 //\r
 // Library internal functions\r
 //\r
 \r
-/**\r
-  Determine if the standard CPU signature is "AuthenticAMD".\r
-\r
-  @retval TRUE  The CPU signature matches.\r
-  @retval FALSE The CPU signature does not match.\r
-\r
-**/\r
-BOOLEAN\r
-StandardSignatureIsAuthenticAMD (\r
-  VOID\r
-  )\r
-{\r
-  UINT32  RegEbx;\r
-  UINT32  RegEcx;\r
-  UINT32  RegEdx;\r
-\r
-  AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);\r
-  return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&\r
-          RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&\r
-          RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);\r
-}\r
-\r
 /**\r
   Determine if the CPU supports the Local APIC Base Address MSR.\r
 \r
index bdb2ff3726773836669b369516b675db707c9309..561baa44b0e6486f15fb8206b55e1a1edc4b6160 100644 (file)
@@ -5,6 +5,7 @@
 #  where local APIC is disabled.\r
 #\r
 #  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2020, AMD Inc. All rights reserved.<BR>\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -37,6 +38,7 @@
   TimerLib\r
   IoLib\r
   PcdLib\r
+  UefiCpuLib\r
 \r
 [Pcd]\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds  ## SOMETIMES_CONSUMES\r
index d0f92b33dc8ceb306ea504e54694d39895148f32..cdcbca04619119a2b0012e347647acd1ec65f6cd 100644 (file)
@@ -5,7 +5,7 @@
   which have xAPIC and x2APIC modes.\r
 \r
   Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>\r
-  Copyright (c) 2017, AMD Inc. All rights reserved.<BR>\r
+  Copyright (c) 2017 - 2020, AMD Inc. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 #include <Library/IoLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/UefiCpuLib.h>\r
 \r
 //\r
 // Library internal functions\r
 //\r
 \r
-/**\r
-  Determine if the standard CPU signature is "AuthenticAMD".\r
-\r
-  @retval TRUE  The CPU signature matches.\r
-  @retval FALSE The CPU signature does not match.\r
-\r
-**/\r
-BOOLEAN\r
-StandardSignatureIsAuthenticAMD (\r
-  VOID\r
-  )\r
-{\r
-  UINT32  RegEbx;\r
-  UINT32  RegEcx;\r
-  UINT32  RegEdx;\r
-\r
-  AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);\r
-  return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&\r
-          RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&\r
-          RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);\r
-}\r
-\r
 /**\r
   Determine if the CPU supports the Local APIC Base Address MSR.\r
 \r
index ac1e0a1c9896e082814ff7362604ca51ab95ce65..1e2a4f8b790f9b1c6b95eda9e80c889eac147e55 100644 (file)
@@ -5,6 +5,7 @@
 #  where local APIC is disabled.\r
 #\r
 #  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2020, AMD Inc. All rights reserved.<BR>\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -37,6 +38,7 @@
   TimerLib\r
   IoLib\r
   PcdLib\r
+  UefiCpuLib\r
 \r
 [Pcd]\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds  ## SOMETIMES_CONSUMES\r
index ab7a8ed6633a52b0c7d4cb3b5d0646a5800916dd..9b0660a5d4ea9d0710c4dbfdb314919230c80266 100644 (file)
 EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID;\r
 \r
 \r
-/**\r
-  Determine if the standard CPU signature is "AuthenticAMD".\r
-\r
-  @retval TRUE  The CPU signature matches.\r
-  @retval FALSE The CPU signature does not match.\r
-\r
-**/\r
-STATIC\r
-BOOLEAN\r
-StandardSignatureIsAuthenticAMD (\r
-  VOID\r
-  )\r
-{\r
-  UINT32  RegEbx;\r
-  UINT32  RegEcx;\r
-  UINT32  RegEdx;\r
-\r
-  AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);\r
-  return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&\r
-          RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&\r
-          RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);\r
-}\r
-\r
 /**\r
   The function will check if BSP Execute Disable is enabled.\r
 \r