[ntoskrnl]
[reactos.git] / reactos / ntoskrnl / config / i386 / cmhardwr.c
index ac31d33..5d967e1 100644 (file)
@@ -226,6 +226,97 @@ Match:
     return TRUE;
 }
 
+VOID
+NTAPI
+CmpGetIntelBrandString(OUT PCHAR CpuString)
+{
+    ULONG BrandId, Ebx, Signature, Dummy;
+    
+    /* Get the Brand Id */
+    CPUID(0x00000001, &Signature, &Ebx, &Dummy, &Dummy);
+    BrandId = Ebx & 0xFF;
+
+    switch (BrandId)
+    {
+        case 0x01:
+            strcpy(CpuString, "Intel(R) Celeron(R) processor");
+            break;
+        case 0x02:
+        case 0x04:
+            strcpy(CpuString, "Intel(R) Pentium(R) III processor");
+            break;
+        case 0x03:
+            if(Signature == 0x000006B1)
+                strcpy(CpuString, "Intel(R) Celeron(R) processor");
+            else
+                strcpy(CpuString, "Intel(R) Pentium(R) III Xeon(R) processor");
+            break;
+        case 0x06:
+            strcpy(CpuString, "Mobile Intel(R) Pentium(R) III Processor-M");
+            break;
+        case 0x08:
+            if(Signature >= 0x00000F13)
+                strcpy(CpuString, "Intel(R) Genuine Processor");
+            else
+                strcpy(CpuString, "Intel(R) Pentium(R) 4 processor");
+            break;
+        case 0x09:
+            strcpy(CpuString, "Intel(R) Pentium(R) 4 processor");
+            break;
+        case 0x0B:
+            if(Signature >= 0x00000F13)
+                strcpy(CpuString, "Intel(R) Xeon(R) processor");
+            else
+                strcpy(CpuString, "Intel(R) Xeon(R) processor MP");
+            break;
+        case 0x0C:
+            strcpy(CpuString, "Intel(R) Xeon(R) processor MP");
+            break;
+        case 0x0E:
+            if(Signature >= 0x00000F13)
+                strcpy(CpuString, "Mobile Intel(R) Pentium(R) 4 processor-M");
+            else
+                strcpy(CpuString, "Intel(R) Xeon(R) processor");
+            break;
+        case 0x12:
+            strcpy(CpuString, "Intel(R) Celeron(R) M processor");
+            break;
+        case 0x07:
+        case 0x0F:
+        case 0x13:
+        case 0x17:
+            strcpy(CpuString, "Mobile Intel(R) Celeron(R) processor");
+            break;
+        case 0x0A:
+        case 0x14:
+            strcpy(CpuString, "Intel(R) Celeron(R) Processor");
+            break;
+        case 0x15:
+            strcpy(CpuString, "Mobile Genuine Intel(R) Processor");
+            break;
+        case 0x16:
+            strcpy(CpuString, "Intel(R) Pentium(R) M processor");
+            break;
+        default:
+            strcpy(CpuString, "Unknown Intel processor");
+    }
+}
+
+VOID
+NTAPI
+CmpGetVendorString(IN PKPRCB Prcb, OUT PCHAR CpuString)
+{
+    /* Check if we have a Vendor String */
+    if (Prcb->VendorString[0])
+    {
+        strcpy(CpuString, Prcb->VendorString);
+    }
+    else
+    {
+        strcpy(CpuString, "Unknown x86 processor");
+    }
+}
+
 NTSTATUS
 NTAPI
 CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
@@ -238,7 +329,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
     HANDLE KeyHandle, BiosHandle, SystemHandle, FpuHandle, SectionHandle;
     CONFIGURATION_COMPONENT_DATA ConfigData;
     CHAR Buffer[128];
-    ULONG ExtendedId, Dummy;
+    ULONG VendorId, ExtendedId, Dummy;
     PKPRCB Prcb;
     USHORT IndexTable[MaximumType + 1] = {0};
     ANSI_STRING TempString;
@@ -374,7 +465,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
             }
 
             /* Save the ID string length now that we've created it */
-            ConfigData.ComponentEntry.IdentifierLength = strlen(Buffer) + 1;
+            ConfigData.ComponentEntry.IdentifierLength = (ULONG)strlen(Buffer) + 1;
 
             /* Initialize the registry configuration node for it */
             Status = CmpInitializeRegistryNode(&ConfigData,
@@ -400,7 +491,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
                 if (Prcb->CpuType == 3) strcpy(Buffer, "80387");
 
                 /* Save the ID string length now that we've created it */
-                ConfigData.ComponentEntry.IdentifierLength = strlen(Buffer) + 1;
+                ConfigData.ComponentEntry.IdentifierLength = (ULONG)strlen(Buffer) + 1;
 
                 /* Initialize the registry configuration node for it */
                 Status = CmpInitializeRegistryNode(&ConfigData,
@@ -424,6 +515,8 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
                 if (!Prcb->CpuID)
                 {
                     /* Uh oh, no CPUID! */
+                    PartialString = CpuString;
+                    CmpGetVendorString(Prcb, PartialString);
                 }
                 else
                 {
@@ -449,6 +542,23 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
                         /* Null-terminate it */
                         CpuString[47] = ANSI_NULL;
                     }
+                    else
+                    {
+                        CPUID(0x00000000, &Dummy, &VendorId, &Dummy, &Dummy);
+                        PartialString = CpuString;
+                        switch (VendorId)
+                        {
+                            case 'uneG': /* Intel */
+                                CmpGetIntelBrandString(PartialString);
+                                break;
+                            case 'htuA': /* AMD */
+                                /* FIXME */
+                                CmpGetVendorString(Prcb, PartialString);
+                                break;
+                            default:
+                                CmpGetVendorString(Prcb, PartialString);
+                        }
+                    }
                 }
 
                 /* Go back to user affinity */
@@ -478,7 +588,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
                 }
 
                 /* Check if we had a Vendor ID */
-                if (Prcb->VendorString)
+                if (Prcb->VendorString[0])
                 {
                     /* Convert it to Unicode */
                     RtlInitAnsiString(&TempString, Prcb->VendorString);
@@ -722,8 +832,7 @@ CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBloc
     /* Now prepare for Video BIOS Mapping of 32KB */
     BaseAddress = 0;
     ViewSize = 8 * PAGE_SIZE;
-    ViewBase.LowPart = VideoRomBase;
-    ViewBase.HighPart = 0;
+    ViewBase.QuadPart = VideoRomBase;
 
     /* Map it */
     Status = ZwMapViewOfSection(SectionHandle,