1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
18 cpu_vendor_("unknown") {
22 void CPU::Initialize() {
23 int cpu_info
[4] = {-1};
24 char cpu_string
[0x20];
26 // __cpuid with an InfoType argument of 0 returns the number of
27 // valid Ids in CPUInfo[0] and the CPU identification string in
28 // the other three array elements. The CPU identification string is
29 // not in linear order. The code below arranges the information
30 // in a human readable form.
32 // More info can be found here:
33 // http://msdn.microsoft.com/en-us/library/hskdteyh.aspx
35 int num_ids
= cpu_info
[0];
36 memset(cpu_string
, 0, sizeof(cpu_string
));
37 *(reinterpret_cast<int*>(cpu_string
)) = cpu_info
[1];
38 *(reinterpret_cast<int*>(cpu_string
+4)) = cpu_info
[3];
39 *(reinterpret_cast<int*>(cpu_string
+8)) = cpu_info
[2];
41 // Interpret CPU feature information.
44 stepping_
= cpu_info
[0] & 0xf;
45 model_
= (cpu_info
[0] >> 4) & 0xf;
46 family_
= (cpu_info
[0] >> 8) & 0xf;
47 type_
= (cpu_info
[0] >> 12) & 0x3;
48 ext_model_
= (cpu_info
[0] >> 16) & 0xf;
49 ext_family_
= (cpu_info
[0] >> 20) & 0xff;
50 cpu_vendor_
= cpu_string
;