Ticket #3541: haiku_ticket4427_3541_try2_r33411.diff
File haiku_ticket4427_3541_try2_r33411.diff, 3.2 KB (added by , 15 years ago) |
---|
-
headers/os/kernel/OS.h
482 482 B_CPU_INTEL_PENTIUM_M_MODEL_13 = 0x106d, /* Dothan */ 483 483 B_CPU_INTEL_PENTIUM_CORE, 484 484 B_CPU_INTEL_PENTIUM_CORE_2, 485 B_CPU_INTEL_PENTIUM_CORE_2_EXTREME = 0x11067, /* Core 2 Extreme or Xeon 486 model 23 on 45 nm */ 485 B_CPU_INTEL_PENTIUM_CORE_2_45_NM = 0x11067, /* Core 2 on 45 nm 486 (Core 2 Extreme, 487 Xeon model 23 or 488 Core 2 Duo/Quad) */ 487 489 B_CPU_INTEL_PENTIUM_CORE_I7 = 0x1106a, /* Core i7 920 @ 2.6(6) */ 488 490 B_CPU_INTEL_PENTIUM_IV = 0x10f0, 489 491 B_CPU_INTEL_PENTIUM_IV_MODEL_1, -
headers/private/shared/cpu_type.h
60 60 } 61 61 62 62 63 #ifdef __INTEL__ 64 char * 65 get_cpuid_model_string() 66 { 67 /* references: 68 * 69 * http://grafi.ii.pw.edu.pl/gbm/x86/cpuid.html 70 * http://www.sandpile.org/ia32/cpuid.htm 71 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/TN13.pdf (Duron erratum) 72 */ 73 74 cpuid_info baseInfo; 75 cpuid_info cpuInfo; 76 int32 maxStandardFunction, maxExtendedFunction = 0; 77 78 if (get_cpuid(&baseInfo, 0, 0) != B_OK) { 79 // this CPU doesn't support cpuid 80 return NULL; 81 } 82 83 maxStandardFunction = baseInfo.eax_0.max_eax; 84 if (maxStandardFunction >= 500) 85 maxStandardFunction = 0; /* old Pentium sample chips has cpu signature here */ 86 87 /* Extended cpuid */ 88 89 get_cpuid(&cpuInfo, 0x80000000, 0); /* hardcoded to CPU 0 */ 90 91 // extended cpuid is only supported if max_eax is greater than the service id 92 if (cpuInfo.eax_0.max_eax > 0x80000000) 93 maxExtendedFunction = cpuInfo.eax_0.max_eax & 0xff; 94 95 if (maxExtendedFunction >=4 ) { 96 int32 i; 97 char *name = (char *)calloc(49, sizeof(char)); 98 99 for (i = 0; i < 3; i++) { 100 cpuid_info nameInfo; 101 get_cpuid(&nameInfo, 0x80000002 + i, 0); 102 103 memcpy(name, &nameInfo.regs.eax, 4); 104 memcpy(name + 4, &nameInfo.regs.ebx, 4); 105 memcpy(name + 8, &nameInfo.regs.ecx, 4); 106 memcpy(name + 12, &nameInfo.regs.edx, 4); 107 name += 16; 108 } 109 110 // cut off leading spaces (names are right aligned) 111 name -= 48; 112 return name; 113 } 114 115 return NULL; 116 } 117 #endif 118 119 63 120 const char * 64 121 get_cpu_model_string(system_info *info) 65 122 { 123 char *cpu; 124 66 125 // Determine CPU type 67 126 switch (info->cpu_type) { 68 127 #if __POWERPC__ … … 113 172 return "Core"; 114 173 case B_CPU_INTEL_PENTIUM_CORE_2: 115 174 return "Core 2"; 116 case B_CPU_INTEL_PENTIUM_CORE_2_EXTREME: 175 case B_CPU_INTEL_PENTIUM_CORE_2_45_NM: 176 cpu = get_cpuid_model_string(); 177 if (cpu != NULL) 178 { 179 if (strcasestr(cpu, "Duo") != NULL || 180 strcasestr(cpu, "Quad") != NULL) 181 { 182 free(cpu); 183 return "Core 2"; 184 } 185 if (strcasestr(cpu, "Xeon") != NULL) 186 { 187 free(cpu); 188 return "Core 2 Xeon"; 189 } 190 free(cpu); 191 } 117 192 return "Core 2 Extreme"; 118 193 case B_CPU_INTEL_PENTIUM_CORE_I7: 119 194 return "Core i7";