ReactOS 0.4.17-dev-683-g0dafdc5
cpuinfo.c File Reference
#include <ntoskrnl.h>
#include <x86x64/Cpuid.h>
#include <debug.h>
Include dependency graph for cpuinfo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI KiGetCpuVendorString (_Out_writes_z_(CPU_VENDOR_STR_LEN) CHAR VendorString[CPU_VENDOR_STR_LEN])
 Get the CPUID information for a given CPU.
 
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.
 
VOID NTAPI KiGetCpuSignature (_Out_ PUSHORT Family, _Out_ PUSHORT Model, _Out_ PUSHORT Stepping)
 Get the CPU signature.
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file cpuinfo.c.

Function Documentation

◆ KiGetCpuSignature()

VOID NTAPI KiGetCpuSignature ( _Out_ PUSHORT  Family,
_Out_ PUSHORT  Model,
_Out_ PUSHORT  Stepping 
)

Get the CPU signature.

Parameters
[out]Family- Pointer to a USHORT to receive the family
[out]Model- Pointer to a USHORT to receive the model
[out]Stepping- Pointer to a USHORT to receive the stepping

\See

Definition at line 118 of file cpuinfo.c.

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}
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
Definition: intrin_ppc.h:682
static int Family
Definition: ping.c:62

Referenced by KiSetProcessorType().

◆ KiGetCpuVendorString()

VOID NTAPI KiGetCpuVendorString ( _Out_writes_z_(CPU_VENDOR_STR_LEN) CHAR  VendorString[CPU_VENDOR_STR_LEN])

Get the CPUID information for a given CPU.

Parameters
[out]VendorString- Pointer to a buffer to receive the vendor string

Definition at line 24 of file cpuinfo.c.

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}
#define CPUID_SIGNATURE
Definition: Cpuid.h:45
static const WCHAR Signature[]
Definition: parser.c:141
uint32_t ULONG
Definition: typedefs.h:59

Referenced by KiSetProcessorType().

◆ KiIdentifyCpuVendor()

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.

Parameters
[in]VendorString- Pointer to a buffer containing the vendor string
Returns
The CPU_VENDOR enum value that corresponds to the vendor string
See also
Remarks
This function is called very early during the boot process, before the kernel debugger is initialized, so it must not do any debug prints.

Definition at line 55 of file cpuinfo.c.

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}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
@ 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

Referenced by KiGetCpuVendor(), and KiSetProcessorType().