|
2 | 2 | #ifndef _ASM_X86_CPU_DEVICE_ID
|
3 | 3 | #define _ASM_X86_CPU_DEVICE_ID
|
4 | 4 |
|
| 5 | +/* |
| 6 | + * Can't use <linux/bitfield.h> because it generates expressions that |
| 7 | + * cannot be used in structure initializers. Bitfield construction |
| 8 | + * here must match the union in struct cpuinfo_86: |
| 9 | + * union { |
| 10 | + * struct { |
| 11 | + * __u8 x86_model; |
| 12 | + * __u8 x86; |
| 13 | + * __u8 x86_vendor; |
| 14 | + * __u8 x86_reserved; |
| 15 | + * }; |
| 16 | + * __u32 x86_vfm; |
| 17 | + * }; |
| 18 | + */ |
| 19 | +#define VFM_MODEL_BIT 0 |
| 20 | +#define VFM_FAMILY_BIT 8 |
| 21 | +#define VFM_VENDOR_BIT 16 |
| 22 | +#define VFM_RSVD_BIT 24 |
| 23 | + |
| 24 | +#define VFM_MODEL_MASK GENMASK(VFM_FAMILY_BIT - 1, VFM_MODEL_BIT) |
| 25 | +#define VFM_FAMILY_MASK GENMASK(VFM_VENDOR_BIT - 1, VFM_FAMILY_BIT) |
| 26 | +#define VFM_VENDOR_MASK GENMASK(VFM_RSVD_BIT - 1, VFM_VENDOR_BIT) |
| 27 | + |
| 28 | +#define VFM_MODEL(vfm) (((vfm) & VFM_MODEL_MASK) >> VFM_MODEL_BIT) |
| 29 | +#define VFM_FAMILY(vfm) (((vfm) & VFM_FAMILY_MASK) >> VFM_FAMILY_BIT) |
| 30 | +#define VFM_VENDOR(vfm) (((vfm) & VFM_VENDOR_MASK) >> VFM_VENDOR_BIT) |
| 31 | + |
| 32 | +#define VFM_MAKE(_vendor, _family, _model) ( \ |
| 33 | + ((_model) << VFM_MODEL_BIT) | \ |
| 34 | + ((_family) << VFM_FAMILY_BIT) | \ |
| 35 | + ((_vendor) << VFM_VENDOR_BIT) \ |
| 36 | +) |
| 37 | + |
5 | 38 | /*
|
6 | 39 | * Declare drivers belonging to specific x86 CPUs
|
7 | 40 | * Similar in spirit to pci_device_id and related PCI functions
|
|
49 | 82 | .driver_data = (unsigned long) _data \
|
50 | 83 | }
|
51 | 84 |
|
| 85 | +#define X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE(_vendor, _family, _model, \ |
| 86 | + _steppings, _feature, _data) { \ |
| 87 | + .vendor = _vendor, \ |
| 88 | + .family = _family, \ |
| 89 | + .model = _model, \ |
| 90 | + .steppings = _steppings, \ |
| 91 | + .feature = _feature, \ |
| 92 | + .driver_data = (unsigned long) _data \ |
| 93 | +} |
| 94 | + |
52 | 95 | /**
|
53 | 96 | * X86_MATCH_VENDOR_FAM_MODEL_FEATURE - Macro for CPU matching
|
54 | 97 | * @_vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
|
|
164 | 207 | X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(INTEL, 6, INTEL_FAM6_##model, \
|
165 | 208 | steppings, X86_FEATURE_ANY, data)
|
166 | 209 |
|
| 210 | +/** |
| 211 | + * X86_MATCH_VFM - Match encoded vendor/family/model |
| 212 | + * @vfm: Encoded 8-bits each for vendor, family, model |
| 213 | + * @data: Driver specific data or NULL. The internal storage |
| 214 | + * format is unsigned long. The supplied value, pointer |
| 215 | + * etc. is cast to unsigned long internally. |
| 216 | + * |
| 217 | + * Stepping and feature are set to wildcards |
| 218 | + */ |
| 219 | +#define X86_MATCH_VFM(vfm, data) \ |
| 220 | + X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \ |
| 221 | + VFM_VENDOR(vfm), \ |
| 222 | + VFM_FAMILY(vfm), \ |
| 223 | + VFM_MODEL(vfm), \ |
| 224 | + X86_STEPPING_ANY, X86_FEATURE_ANY, data) |
| 225 | + |
| 226 | +/** |
| 227 | + * X86_MATCH_VFM_STEPPINGS - Match encoded vendor/family/model/stepping |
| 228 | + * @vfm: Encoded 8-bits each for vendor, family, model |
| 229 | + * @steppings: Bitmask of steppings to match |
| 230 | + * @data: Driver specific data or NULL. The internal storage |
| 231 | + * format is unsigned long. The supplied value, pointer |
| 232 | + * etc. is cast to unsigned long internally. |
| 233 | + * |
| 234 | + * feature is set to wildcard |
| 235 | + */ |
| 236 | +#define X86_MATCH_VFM_STEPPINGS(vfm, steppings, data) \ |
| 237 | + X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \ |
| 238 | + VFM_VENDOR(vfm), \ |
| 239 | + VFM_FAMILY(vfm), \ |
| 240 | + VFM_MODEL(vfm), \ |
| 241 | + steppings, X86_FEATURE_ANY, data) |
| 242 | + |
| 243 | +/** |
| 244 | + * X86_MATCH_VFM_FEATURE - Match encoded vendor/family/model/feature |
| 245 | + * @vfm: Encoded 8-bits each for vendor, family, model |
| 246 | + * @feature: A X86_FEATURE bit |
| 247 | + * @data: Driver specific data or NULL. The internal storage |
| 248 | + * format is unsigned long. The supplied value, pointer |
| 249 | + * etc. is cast to unsigned long internally. |
| 250 | + * |
| 251 | + * Steppings is set to wildcard |
| 252 | + */ |
| 253 | +#define X86_MATCH_VFM_FEATURE(vfm, feature, data) \ |
| 254 | + X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \ |
| 255 | + VFM_VENDOR(vfm), \ |
| 256 | + VFM_FAMILY(vfm), \ |
| 257 | + VFM_MODEL(vfm), \ |
| 258 | + X86_STEPPING_ANY, feature, data) |
| 259 | + |
167 | 260 | /*
|
168 | 261 | * Match specific microcode revisions.
|
169 | 262 | *
|
|
0 commit comments