| 1 | |
| 2 | #include <linux/types.h>
|
| 3 | #include <linux/export.h>
|
| 4 |
|
| 5 | #include <asm/cpu.h>
|
| 6 | #include <asm/cpuid/leaf_types.h>
|
| 7 |
|
| 8 | static unsigned int __x86_family(unsigned int base_fam, unsigned int ext_fam)
|
| 9 | {
|
| 10 | if (base_fam == 0xf)
|
| 11 | base_fam += ext_fam;
|
| 12 |
|
| 13 | return base_fam;
|
| 14 | }
|
| 15 |
|
| 16 | static unsigned int __x86_model(unsigned int family, unsigned int base_model,
|
| 17 | unsigned int ext_model)
|
| 18 | {
|
| 19 | if (family >= 0x6)
|
| 20 | base_model |= ext_model << 4;
|
| 21 |
|
| 22 | return base_model;
|
| 23 | }
|
| 24 |
|
| 25 | unsigned int x86_family(unsigned int sig)
|
| 26 | {
|
| 27 | return __x86_family((sig >> 8) & 0xf, (sig >> 20) & 0xff);
|
| 28 | }
|
| 29 | EXPORT_SYMBOL_GPL(x86_family);
|
| 30 |
|
| 31 | unsigned int x86_model(unsigned int sig)
|
| 32 | {
|
| 33 | return __x86_model(x86_family(sig), (sig >> 4) & 0xf, (sig >> 16) & 0xf);
|
| 34 | }
|
| 35 | EXPORT_SYMBOL_GPL(x86_model);
|
| 36 |
|
| 37 | unsigned int x86_stepping(unsigned int sig)
|
| 38 | {
|
| 39 | return sig & 0xf;
|
| 40 | }
|
| 41 | EXPORT_SYMBOL_GPL(x86_stepping);
|
| 42 |
|
| 43 | unsigned int cpuid_family(const struct leaf_0x1_0 *l)
|
| 44 | {
|
| 45 | return __x86_family(l->base_family_id, l->ext_family);
|
| 46 | }
|
| 47 |
|
| 48 | unsigned int cpuid_model(const struct leaf_0x1_0 *l)
|
| 49 | {
|
| 50 | return __x86_model(cpuid_family(l), l->base_model, l->ext_model);
|
| 51 | }
|