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