https://git.reactos.org/?p=reactos.git;a=commitdiff;h=84cc81ee298b9030a0c39dfd60487bc8c2ed1703

commit 84cc81ee298b9030a0c39dfd60487bc8c2ed1703
Author:     Stanislav Motylkov <[email protected]>
AuthorDate: Wed Jan 5 00:50:51 2022 +0300
Commit:     Stanislav Motylkov <[email protected]>
CommitDate: Wed Jan 5 18:28:40 2022 +0300

    [NTOS:KE/x64] Detect CPU vendor properly and store value in PRCB
    
    Also generate processor identifier properly based on this value
    on the Configuration Manager machine-dependent initialization.
    
    Update processor driver INF file accordingly.
    
    CORE-17970 CORE-14922
---
 drivers/processor/processr/cpu.inf | 10 ++++++++++
 ntoskrnl/config/i386/cmhardwr.c    | 36 ++++++++++++++++++++++++++++++++++++
 ntoskrnl/ke/amd64/cpu.c            | 19 ++++++++-----------
 3 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/drivers/processor/processr/cpu.inf 
b/drivers/processor/processr/cpu.inf
index ca3dd062b96..268ec540e8a 100644
--- a/drivers/processor/processr/cpu.inf
+++ b/drivers/processor/processr/cpu.inf
@@ -62,6 +62,9 @@ HKR, , Icon,           0, "-28"
 %IntelP4Processor.DeviceDesc%     = 
Processr_Inst,ACPI\GenuineIntel_-_x86_Family_15
 %IntelProcessor.DeviceDesc%       = Processr_Inst,ACPI\GenuineIntel_-_x86
 
+[Intel.NTAMD64]
+%IntelProcessor.DeviceDesc%       = Processr_Inst,ACPI\GenuineIntel_-_EM64T
+
 [AMD]
 %AMDK6Processor.DeviceDesc%   = 
Processr_Inst,ACPI\AuthenticAMD_-_x86_Family_5_Model_7
 %AMDK62Processor.DeviceDesc%  = 
Processr_Inst,ACPI\AuthenticAMD_-_x86_Family_5_Model_8
@@ -74,6 +77,10 @@ HKR, , Icon,           0, "-28"
 %AMDQProcessor.DeviceDesc%    = Processr_Inst,ACPI\AuthenticAMD_-_x86_Family_17
 %AMDProcessor.DeviceDesc%     = Processr_Inst,ACPI\AuthenticAMD_-_x86
 
+[AMD.NTAMD64]
+%AMDK8Processor.DeviceDesc%   = 
Processr_Inst,ACPI\AuthenticAMD_-_AMD64_Family_15
+%AMDProcessor.DeviceDesc%     = Processr_Inst,ACPI\AuthenticAMD_-_AMD64
+
 [Transmeta]
 %TransmetaProcessor.DeviceDesc% = Processr_Inst,ACPI\GenuineTMx86_-_x86
 
@@ -84,6 +91,9 @@ HKR, , Icon,           0, "-28"
 %ViaNANOProcessor.DeviceDesc% = 
Processr_Inst,ACPI\CentaurHauls_-_x86_Family_6_Model_15
 %ViaProcessor.DeviceDesc%     = Processr_Inst,ACPI\CentaurHauls_-_x86
 
+[VIA.NTAMD64]
+%ViaProcessor.DeviceDesc%     = Processr_Inst,ACPI\CentaurHauls_-_VIA64
+
 ;---------------------------- Processr Driver ---------------------------
 
 [Processr_Inst.NT]
diff --git a/ntoskrnl/config/i386/cmhardwr.c b/ntoskrnl/config/i386/cmhardwr.c
index 7bdd139ecbd..1810da6a53b 100644
--- a/ntoskrnl/config/i386/cmhardwr.c
+++ b/ntoskrnl/config/i386/cmhardwr.c
@@ -14,8 +14,14 @@
 
 /* GLOBALS *******************************************************************/
 
+#ifdef _M_IX86
 PCHAR CmpID1 = "80%u86-%c%x";
 PCHAR CmpID2 = "x86 Family %u Model %u Stepping %u";
+#else
+PCHAR CmpID1 = "EM64T Family %u Model %u Stepping %u";
+PCHAR CmpID2 = "AMD64 Family %u Model %u Stepping %u";
+PCHAR CmpID3 = "VIA64 Family %u Model %u Stepping %u";
+#endif
 PCHAR CmpBiosStrings[] =
 {
     "Ver",
@@ -346,6 +352,9 @@ CmpInitializeMachineDependentConfiguration(IN 
PLOADER_PARAMETER_BLOCK LoaderBloc
         /* Loop all CPUs */
         for (i = 0; i < KeNumberProcessors; i++)
         {
+#ifdef _M_AMD64
+            PCHAR CmpID;
+#endif
             /* Get the PRCB */
             Prcb = KiProcessorBlock[i];
 
@@ -357,6 +366,7 @@ CmpInitializeMachineDependentConfiguration(IN 
PLOADER_PARAMETER_BLOCK LoaderBloc
             ConfigData.ComponentEntry.AffinityMask = AFFINITY_MASK(i);
             ConfigData.ComponentEntry.Identifier = Buffer;
 
+#if defined(_M_IX86)
             /* Check if the CPU doesn't support CPUID */
             if (!Prcb->CpuID)
             {
@@ -376,6 +386,32 @@ CmpInitializeMachineDependentConfiguration(IN 
PLOADER_PARAMETER_BLOCK LoaderBloc
                         (Prcb->CpuStep >> 8),
                         Prcb->CpuStep & 0xff);
             }
+#elif defined(_M_AMD64)
+            if (Prcb->CpuVendor == CPU_VIA)
+            {
+                /* This is VIA64 family */
+                CmpID = CmpID3;
+            }
+            else if (Prcb->CpuVendor == CPU_AMD)
+            {
+                /* This is AMD64 family */
+                CmpID = CmpID2;
+            }
+            else
+            {
+                /* This is generic EM64T family */
+                CmpID = CmpID1;
+            }
+
+            /* ID string has the same style for all 64-bit CPUs */
+            sprintf(Buffer,
+                    CmpID,
+                    Prcb->CpuType,
+                    (Prcb->CpuStep >> 8),
+                    Prcb->CpuStep & 0xff);
+#else
+#error Unknown architecture
+#endif
 
             /* Save the ID string length now that we've created it */
             ConfigData.ComponentEntry.IdentifierLength = (ULONG)strlen(Buffer) 
+ 1;
diff --git a/ntoskrnl/ke/amd64/cpu.c b/ntoskrnl/ke/amd64/cpu.c
index 320e48bdd3b..659264cde30 100644
--- a/ntoskrnl/ke/amd64/cpu.c
+++ b/ntoskrnl/ke/amd64/cpu.c
@@ -33,10 +33,7 @@ volatile LONG KiTbFlushTimeStamp;
 /* CPU Signatures */
 static const CHAR CmpIntelID[]       = "GenuineIntel";
 static const CHAR CmpAmdID[]         = "AuthenticAMD";
-static const CHAR CmpCyrixID[]       = "CyrixInstead";
-static const CHAR CmpTransmetaID[]   = "GenuineTMx86";
 static const CHAR CmpCentaurID[]     = "CentaurHauls";
-static const CHAR CmpRiseID[]        = "RiseRiseRise";
 
 /* FUNCTIONS *****************************************************************/
 
@@ -89,25 +86,25 @@ KiGetCpuVendor(VOID)
     /* Now check the CPU Type */
     if (!strcmp((PCHAR)Prcb->VendorString, CmpIntelID))
     {
-        return CPU_INTEL;
+        Prcb->CpuVendor = CPU_INTEL;
     }
     else if (!strcmp((PCHAR)Prcb->VendorString, CmpAmdID))
     {
-        return CPU_AMD;
+        Prcb->CpuVendor = CPU_AMD;
     }
     else if (!strcmp((PCHAR)Prcb->VendorString, CmpCentaurID))
     {
         DPRINT1("VIA CPUs not fully supported\n");
-        return CPU_VIA;
+        Prcb->CpuVendor = CPU_VIA;
     }
-    else if (!strcmp((PCHAR)Prcb->VendorString, CmpRiseID))
+    else
     {
-        DPRINT1("Rise CPUs not fully supported\n");
-        return 0;
+        /* Invalid CPU */
+        DPRINT1("%s CPU support not fully tested!\n", Prcb->VendorString);
+        Prcb->CpuVendor = CPU_UNKNOWN;
     }
 
-    /* Invalid CPU */
-    return CPU_UNKNOWN;
+    return Prcb->CpuVendor;
 }
 
 ULONG

Reply via email to