代码拉取完成,页面将自动刷新
From c5906a1813f0a370e76d0e4910f1959edd552af4 Mon Sep 17 00:00:00 2001
From: jiangxin <jiangxin@hygon.cn>
Date: Thu, 21 Apr 2022 16:03:08 +0800
Subject: [PATCH 29/46] anolis: UefiCpuPkg: Add
StandardSignatureIsHygonGenuine() in BaseUefiCpuLib
This function allows IA32/X64 code to determine if it is running on an
Hygon brand processor.
Signed-off-by: Xin Jiang <jiangxin@hygon.cn>
Change-Id: I72594196f0ce6003fce43856120e3ca4609b8bb2
---
UefiCpuPkg/Include/Library/UefiCpuLib.h | 13 +++++
UefiCpuPkg/Include/Register/Hygon/Cpuid.h | 47 +++++++++++++++++++
.../Library/BaseUefiCpuLib/BaseUefiCpuLib.c | 24 ++++++++++
3 files changed, 84 insertions(+)
create mode 100644 UefiCpuPkg/Include/Register/Hygon/Cpuid.h
diff --git a/UefiCpuPkg/Include/Library/UefiCpuLib.h b/UefiCpuPkg/Include/Library/UefiCpuLib.h
index 092c1d2..c64fe26 100644
--- a/UefiCpuPkg/Include/Library/UefiCpuLib.h
+++ b/UefiCpuPkg/Include/Library/UefiCpuLib.h
@@ -43,6 +43,19 @@ StandardSignatureIsAuthenticAMD (
VOID
);
+/**
+ Determine if the standard CPU signature is "HygonGenuine".
+
+ @retval TRUE The CPU signature matches.
+ @retval FALSE The CPU signature does not match.
+
+**/
+BOOLEAN
+EFIAPI
+StandardSignatureIsHygonGenuine (
+ VOID
+ );
+
/**
Return the 32bit CPU family and model value.
diff --git a/UefiCpuPkg/Include/Register/Hygon/Cpuid.h b/UefiCpuPkg/Include/Register/Hygon/Cpuid.h
new file mode 100644
index 0000000..e8a2c76
--- /dev/null
+++ b/UefiCpuPkg/Include/Register/Hygon/Cpuid.h
@@ -0,0 +1,47 @@
+/** @file
+ CPUID leaf definitions.
+
+ Provides defines for CPUID leaf indexes. Data structures are provided for
+ registers returned by a CPUID leaf that contain one or more bit fields.
+ If a register returned is a single 32-bit value, then a data structure is
+ not provided for that register.
+
+ Copyright (c) 2022, HYGON. All rights reserved.<BR>
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+
+#ifndef __HYGON_CPUID_H__
+#define __HYGON_CPUID_H__
+
+/**
+CPUID Signature Information
+
+@param EAX CPUID_SIGNATURE (0x00)
+
+@retval EAX Returns the highest value the CPUID instruction recognizes for
+ returning basic processor information. The value is returned is
+ processor specific.
+@retval EBX First 4 characters of a vendor identification string.
+@retval ECX Last 4 characters of a vendor identification string.
+@retval EDX Middle 4 characters of a vendor identification string.
+
+**/
+
+///
+/// @{ CPUID signature values returned by HYGON processors
+///
+#define CPUID_SIGNATURE_AUTHENTIC_HYGON_EBX SIGNATURE_32 ('H', 'y', 'g', 'o')
+#define CPUID_SIGNATURE_AUTHENTIC_HYGON_EDX SIGNATURE_32 ('n', 'G', 'e', 'n')
+#define CPUID_SIGNATURE_AUTHENTIC_HYGON_ECX SIGNATURE_32 ('u', 'i', 'n', 'e')
+///
+/// @}
+///
+
+#endif
diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
index 5089161..700d633 100644
--- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
+++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
@@ -11,6 +11,7 @@
#include <Register/Intel/Cpuid.h>
#include <Register/Amd/Cpuid.h>
+#include <Register/Hygon/Cpuid.h>
#include <Library/BaseLib.h>
#include <Library/UefiCpuLib.h>
@@ -38,6 +39,29 @@ StandardSignatureIsAuthenticAMD (
RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);
}
+/**
+ Determine if the standard CPU signature is "HygonGenuine".
+
+ @retval TRUE The CPU signature matches.
+ @retval FALSE The CPU signature does not match.
+
+**/
+BOOLEAN
+EFIAPI
+StandardSignatureIsHygonGenuine (
+ VOID
+ )
+{
+ UINT32 RegEbx;
+ UINT32 RegEcx;
+ UINT32 RegEdx;
+
+ AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);
+ return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_HYGON_EBX &&
+ RegEcx == CPUID_SIGNATURE_AUTHENTIC_HYGON_ECX &&
+ RegEdx == CPUID_SIGNATURE_AUTHENTIC_HYGON_EDX);
+}
+
/**
Return the 32bit CPU family and model value.
--
2.17.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。