[ros-diffs] [ion] 26681: - CmpInitializeMachineDependentConfiguration: Add Processor Name and Vendor ID as well (the former doesnt' work on QEMU because QEMU desn't support CPUID-EX, but on VMWare, I get: Dual Core AMD Opteron(tm) Processor 185.

ion at svn.reactos.org ion at svn.reactos.org
Thu May 10 21:06:52 CEST 2007


Author: ion
Date: Thu May 10 23:06:52 2007
New Revision: 26681

URL: http://svn.reactos.org/svn/reactos?rev=26681&view=rev
Log:
- CmpInitializeMachineDependentConfiguration: Add Processor Name and Vendor ID as well (the former doesnt' work on QEMU because QEMU desn't support CPUID-EX, but on VMWare, I get: Dual Core AMD Opteron(tm) Processor 185.

Modified:
    trunk/reactos/ntoskrnl/config/i386/cmhardwr.c

Modified: trunk/reactos/ntoskrnl/config/i386/cmhardwr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/i386/cmhardwr.c?rev=26681&r1=26680&r2=26681&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/i386/cmhardwr.c (original)
+++ trunk/reactos/ntoskrnl/config/i386/cmhardwr.c Thu May 10 23:06:52 2007
@@ -24,7 +24,7 @@
 NTAPI
 CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 {
-    UNICODE_STRING KeyName, ValueName;
+    UNICODE_STRING KeyName, ValueName, Data;
     OBJECT_ATTRIBUTES ObjectAttributes;
     ULONG HavePae;
     NTSTATUS Status;
@@ -32,9 +32,12 @@
     ULONG Disposition;
     CONFIGURATION_COMPONENT_DATA ConfigData;
     CHAR Buffer[128];
-    ULONG i;
+    ULONG i, ExtendedId, Dummy;
     PKPRCB Prcb;
     USHORT IndexTable[MaximumType + 1] = {0};
+    ANSI_STRING TempString;
+    PCHAR PartialString = NULL;
+    CHAR CpuString[48];
 
     /* Open the SMSS Memory Management key */
     RtlInitUnicodeString(&KeyName,
@@ -198,6 +201,81 @@
                 /* Close this new handle */
                 NtClose(FpuHandle);
 
+                /* Stay on this CPU only */
+                KeSetSystemAffinityThread(Prcb->SetMember);
+                if (!Prcb->CpuID)
+                {
+                    /* Uh oh, no CPUID! */
+                }
+                else
+                {
+                    /* Check if we have extended CPUID that supports name ID */
+                    Ki386Cpuid(0x80000000, &ExtendedId, &Dummy, &Dummy, &Dummy);
+                    if (ExtendedId >= 0x80000004)
+                    {
+                        /* Do all the CPUIDs requred to get the full name */
+                        PartialString = CpuString;
+                        for (ExtendedId = 2; ExtendedId <= 4; ExtendedId++)
+                        {
+                            /* Do the CPUID and save the name string */
+                            Ki386Cpuid(0x80000000 | ExtendedId,
+                                       (PULONG)PartialString,
+                                       (PULONG)PartialString + 1,
+                                       (PULONG)PartialString + 2,
+                                       (PULONG)PartialString + 3);
+
+                            /* Go to the next name string */
+                            PartialString += 16;
+                        }
+
+                        /* Null-terminate it */
+                        CpuString[48] = ANSI_NULL;
+                    }
+                }
+
+                /* Go back to user affinity */
+                KeRevertToUserAffinityThread();
+
+                /* Check if we have a CPU Name */
+                if (PartialString)
+                {
+                    /* Convert it to Unicode */
+                    RtlInitAnsiString(&TempString, CpuString);
+                    RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE);
+
+                    /* Add it to the registry */
+                    RtlInitUnicodeString(&ValueName, L"ProcessorNameString");
+                    Status = NtSetValueKey(KeyHandle,
+                                           &ValueName,
+                                           0,
+                                           REG_SZ,
+                                           Data.Buffer,
+                                           Data.Length + sizeof(UNICODE_NULL));
+
+                    /* Free the temporary buffer */
+                    RtlFreeUnicodeString(&Data);
+                }
+
+                /* Check if we had a Vendor ID */
+                if (Prcb->VendorString)
+                {
+                    /* Convert it to Unicode */
+                    RtlInitAnsiString(&TempString, Prcb->VendorString);
+                    RtlAnsiStringToUnicodeString(&Data, &TempString, TRUE);
+
+                    /* Add it to the registry */
+                    RtlInitUnicodeString(&ValueName, L"VendorIdentifier");
+                    Status = NtSetValueKey(KeyHandle,
+                                           &ValueName,
+                                           0,
+                                           REG_SZ,
+                                           Data.Buffer,
+                                           Data.Length + sizeof(UNICODE_NULL));
+
+                    /* Free the temporary buffer */
+                    RtlFreeUnicodeString(&Data);
+                }
+
                 /* Check if we have features bits */
                 if (Prcb->FeatureBits)
                 {




More information about the Ros-diffs mailing list