ReactOS 0.4.17-dev-683-g0dafdc5
cpuinfo.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Routines for x86 / x64 CPU information gathering
5 * COPYRIGHT: Copyright 2026 Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8/* INCLUDES *****************************************************************/
9
10#include <ntoskrnl.h>
11#include <x86x64/Cpuid.h>
12#define NDEBUG
13#include <debug.h>
14
15/* FUNCTIONS *****************************************************************/
16
22VOID
26{
28
29 /* Get the Vendor string */
30 __cpuid(&Signature.AsInt32[0], CPUID_SIGNATURE);
31
32 /* Copy and null-terminate it */
33 *(ULONG*)&VendorString[0] = *(ULONG*)&Signature.SignatureScrambled[0];
34 *(ULONG*)&VendorString[4] = *(ULONG*)&Signature.SignatureScrambled[8];
35 *(ULONG*)&VendorString[8] = *(ULONG*)&Signature.SignatureScrambled[4];
36 VendorString[12] = 0;
37}
38
57{
58 /* Identify the CPU vendor */
59 if (!strcmp(VendorString, "GenuineIntel") ||
60 !strcmp(VendorString, "GenuineIotel")) // Intel Xeon E3-1231 v3
61 {
62 return CPU_INTEL;
63 }
64 else if (!strcmp(VendorString, "AuthenticAMD") ||
65 !strcmp(VendorString, "HygonGenuine"))
66 {
67 return CPU_AMD;
68 }
69 else if (!strcmp(VendorString, "CentaurHauls") ||
70 !strcmp(VendorString, " Shanghai "))
71 {
72 return CPU_VIA; // == CPU_CENTAUR
73 }
74#ifdef _M_I386
75 else if (!strcmp(VendorString, "CyrixInstead"))
76 {
77 return CPU_CYRIX;
78 }
79 else if (!strcmp(VendorString, "GenuineTMx86"))
80 {
81 return CPU_TRANSMETA;
82 }
83 else if (!strcmp(VendorString, "RiseRiseRise"))
84 {
85 return CPU_RISE;
86 }
87#endif // _M_I386
88
89 return CPU_UNKNOWN;
90}
91
116VOID
117NTAPI
120 _Out_ PUSHORT Model,
121 _Out_ PUSHORT Stepping)
122{
124
125 /* Get the CPUID */
126 __cpuid(VersionInfo.AsInt32, 1);
127
128 /* Get the family */
129 *Family = VersionInfo.Eax.Bits.FamilyId;
130 if (VersionInfo.Eax.Bits.FamilyId == 15)
131 {
132 *Family += VersionInfo.Eax.Bits.ExtendedFamilyId;
133 }
134
135 /* Get the model */
136 *Model = VersionInfo.Eax.Bits.Model;
137 if ((VersionInfo.Eax.Bits.FamilyId == 6) ||
138 (VersionInfo.Eax.Bits.FamilyId == 15))
139 {
140 /* For Family < 15, AMD documents extended model as RAZ (reads as zero) */
141 *Model |= VersionInfo.Eax.Bits.ExtendedModelId << 4;
142 }
143
144 /* Get the stepping */
145 *Stepping = VersionInfo.Eax.Bits.SteppingId;
146}
#define CPUID_SIGNATURE
Definition: Cpuid.h:45
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
VOID NTAPI KiGetCpuSignature(_Out_ PUSHORT Family, _Out_ PUSHORT Model, _Out_ PUSHORT Stepping)
Get the CPU signature.
Definition: cpuinfo.c:118
VOID NTAPI KiGetCpuVendorString(_Out_writes_z_(CPU_VENDOR_STR_LEN) CHAR VendorString[CPU_VENDOR_STR_LEN])
Get the CPUID information for a given CPU.
Definition: cpuinfo.c:24
CPU_VENDORS NTAPI KiIdentifyCpuVendor(_In_reads_z_(CPU_VENDOR_STR_LEN) const CHAR VendorString[CPU_VENDOR_STR_LEN])
Identify the CPU vendor by the vendor string.
Definition: cpuinfo.c:55
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
static const WCHAR Signature[]
Definition: parser.c:141
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
Definition: intrin_ppc.h:682
CPU_VENDORS
Definition: ketypes.h:97
@ CPU_VIA
Definition: ketypes.h:101
@ CPU_INTEL
Definition: ketypes.h:100
@ CPU_UNKNOWN
Definition: ketypes.h:98
@ CPU_AMD
Definition: ketypes.h:99
@ CPU_RISE
Definition: ketypes.h:96
@ CPU_CYRIX
Definition: ketypes.h:92
@ CPU_TRANSMETA
Definition: ketypes.h:93
#define _Out_writes_z_(s)
Definition: no_sal2.h:180
#define _Out_
Definition: no_sal2.h:160
#define _In_reads_z_(s)
Definition: no_sal2.h:172
#define CPU_VENDOR_STR_LEN
Definition: ke.h:10
char CHAR
Definition: pedump.c:57
static int Family
Definition: ping.c:62
#define NTAPI
Definition: typedefs.h:36
uint16_t * PUSHORT
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59