David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | #include <linux/types.h> |
| 3 | #include <linux/export.h> |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 4 | #include <asm/cpu.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 5 | |
| 6 | unsigned int x86_family(unsigned int sig) |
| 7 | { |
| 8 | unsigned int x86; |
| 9 | |
| 10 | x86 = (sig >> 8) & 0xf; |
| 11 | |
| 12 | if (x86 == 0xf) |
| 13 | x86 += (sig >> 20) & 0xff; |
| 14 | |
| 15 | return x86; |
| 16 | } |
| 17 | EXPORT_SYMBOL_GPL(x86_family); |
| 18 | |
| 19 | unsigned int x86_model(unsigned int sig) |
| 20 | { |
| 21 | unsigned int fam, model; |
| 22 | |
| 23 | fam = x86_family(sig); |
| 24 | |
| 25 | model = (sig >> 4) & 0xf; |
| 26 | |
| 27 | if (fam >= 0x6) |
| 28 | model += ((sig >> 16) & 0xf) << 4; |
| 29 | |
| 30 | return model; |
| 31 | } |
| 32 | EXPORT_SYMBOL_GPL(x86_model); |
| 33 | |
| 34 | unsigned int x86_stepping(unsigned int sig) |
| 35 | { |
| 36 | return sig & 0xf; |
| 37 | } |
| 38 | EXPORT_SYMBOL_GPL(x86_stepping); |