Merge Linux 2.6.23
[sfrench/cifs-2.6.git] / arch / i386 / kernel / cpu / addon_cpuid_features.c
1
2 /*
3  *      Routines to indentify additional cpu features that are scattered in
4  *      cpuid space.
5  */
6
7 #include <linux/cpu.h>
8
9 #include <asm/processor.h>
10
11 struct cpuid_bit {
12         u16 feature;
13         u8 reg;
14         u8 bit;
15         u32 level;
16 };
17
18 enum cpuid_regs {
19         CR_EAX = 0,
20         CR_ECX,
21         CR_EDX,
22         CR_EBX
23 };
24
25 void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
26 {
27         u32 max_level;
28         u32 regs[4];
29         const struct cpuid_bit *cb;
30
31         static const struct cpuid_bit cpuid_bits[] = {
32                 { X86_FEATURE_IDA, CR_EAX, 1, 0x00000006 },
33                 { 0, 0, 0, 0 }
34         };
35
36         for (cb = cpuid_bits; cb->feature; cb++) {
37
38                 /* Verify that the level is valid */
39                 max_level = cpuid_eax(cb->level & 0xffff0000);
40                 if (max_level < cb->level ||
41                     max_level > (cb->level | 0xffff))
42                         continue;
43
44                 cpuid(cb->level, &regs[CR_EAX], &regs[CR_EBX],
45                         &regs[CR_ECX], &regs[CR_EDX]);
46
47                 if (regs[cb->reg] & (1 << cb->bit))
48                         set_bit(cb->feature, c->x86_capability);
49         }
50 }