blob: 7ad68917a51e8e123eb19b0d5d3956870aee56ed [file] [log] [blame]
Thomas Gleixner457c8992019-05-19 13:08:55 +01001// SPDX-License-Identifier: GPL-2.0-only
Paul Gortmakere6830142016-07-13 20:18:57 -04002#include <linux/types.h>
3#include <linux/export.h>
Valdis Klētnieks04f5bda2019-08-07 23:27:17 -04004#include <asm/cpu.h>
Borislav Petkov99f925c2015-11-23 11:12:21 +01005
6unsigned 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}
17EXPORT_SYMBOL_GPL(x86_family);
18
19unsigned int x86_model(unsigned int sig)
20{
21 unsigned int fam, model;
22
Jia Zhangb3991512018-01-01 09:52:10 +080023 fam = x86_family(sig);
Borislav Petkov99f925c2015-11-23 11:12:21 +010024
25 model = (sig >> 4) & 0xf;
26
27 if (fam >= 0x6)
28 model += ((sig >> 16) & 0xf) << 4;
29
30 return model;
31}
32EXPORT_SYMBOL_GPL(x86_model);
33
34unsigned int x86_stepping(unsigned int sig)
35{
36 return sig & 0xf;
37}
38EXPORT_SYMBOL_GPL(x86_stepping);