]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / UefiCpuPkg / Library / BaseUefiCpuLib / BaseUefiCpuLib.c
CommitLineData
df667535
KG
1/** @file\r
2 This library defines some routines that are generic for IA32 family CPU.\r
3\r
4 The library routines are UEFI specification compliant.\r
5\r
6 Copyright (c) 2020, AMD Inc. All rights reserved.<BR>\r
f826b208 7 Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
df667535
KG
8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
9\r
10**/\r
11\r
12#include <Register/Intel/Cpuid.h>\r
13#include <Register/Amd/Cpuid.h>\r
14\r
15#include <Library/BaseLib.h>\r
16#include <Library/UefiCpuLib.h>\r
17\r
18/**\r
19 Determine if the standard CPU signature is "AuthenticAMD".\r
20\r
21 @retval TRUE The CPU signature matches.\r
22 @retval FALSE The CPU signature does not match.\r
23\r
24**/\r
25BOOLEAN\r
26EFIAPI\r
27StandardSignatureIsAuthenticAMD (\r
28 VOID\r
29 )\r
30{\r
31 UINT32 RegEbx;\r
32 UINT32 RegEcx;\r
33 UINT32 RegEdx;\r
34\r
35 AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);\r
36 return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&\r
37 RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&\r
38 RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);\r
39}\r
f826b208
RN
40\r
41/**\r
42 Return the 32bit CPU family and model value.\r
43\r
44 @return CPUID[01h].EAX with Processor Type and Stepping ID cleared.\r
45**/\r
46UINT32\r
47EFIAPI\r
48GetCpuFamilyModel (\r
49 VOID\r
50 )\r
51{\r
52 CPUID_VERSION_INFO_EAX Eax;\r
53\r
54 AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL);\r
55\r
56 //\r
57 // Mask other fields than Family and Model.\r
58 //\r
59 Eax.Bits.SteppingId = 0;\r
60 Eax.Bits.ProcessorType = 0;\r
61 Eax.Bits.Reserved1 = 0;\r
62 Eax.Bits.Reserved2 = 0;\r
63 return Eax.Uint32;\r
64}\r
65\r
66/**\r
67 Return the CPU stepping ID.\r
68 @return CPU stepping ID value in CPUID[01h].EAX.\r
69**/\r
70UINT8\r
71EFIAPI\r
72GetCpuSteppingId (\r
73 VOID\r
74 )\r
75{\r
76 CPUID_VERSION_INFO_EAX Eax;\r
77\r
78 AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, NULL, NULL, NULL);\r
79\r
053e878b 80 return (UINT8)Eax.Bits.SteppingId;\r
f826b208 81}\r