Merge tag 'pm-4.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
[linux/fpc-iii.git] / arch / x86 / include / asm / microcode_intel.h
blobe793fc9a9b20c36d2e0d0e8e2a359fd1c70f2d8e
1 #ifndef _ASM_X86_MICROCODE_INTEL_H
2 #define _ASM_X86_MICROCODE_INTEL_H
4 #include <asm/microcode.h>
6 struct microcode_header_intel {
7 unsigned int hdrver;
8 unsigned int rev;
9 unsigned int date;
10 unsigned int sig;
11 unsigned int cksum;
12 unsigned int ldrver;
13 unsigned int pf;
14 unsigned int datasize;
15 unsigned int totalsize;
16 unsigned int reserved[3];
19 struct microcode_intel {
20 struct microcode_header_intel hdr;
21 unsigned int bits[0];
24 /* microcode format is extended from prescott processors */
25 struct extended_signature {
26 unsigned int sig;
27 unsigned int pf;
28 unsigned int cksum;
31 struct extended_sigtable {
32 unsigned int count;
33 unsigned int cksum;
34 unsigned int reserved[3];
35 struct extended_signature sigs[0];
38 #define DEFAULT_UCODE_DATASIZE (2000)
39 #define MC_HEADER_SIZE (sizeof(struct microcode_header_intel))
40 #define DEFAULT_UCODE_TOTALSIZE (DEFAULT_UCODE_DATASIZE + MC_HEADER_SIZE)
41 #define EXT_HEADER_SIZE (sizeof(struct extended_sigtable))
42 #define EXT_SIGNATURE_SIZE (sizeof(struct extended_signature))
44 #define get_totalsize(mc) \
45 (((struct microcode_intel *)mc)->hdr.datasize ? \
46 ((struct microcode_intel *)mc)->hdr.totalsize : \
47 DEFAULT_UCODE_TOTALSIZE)
49 #define get_datasize(mc) \
50 (((struct microcode_intel *)mc)->hdr.datasize ? \
51 ((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE)
53 #define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE)
55 static inline u32 intel_get_microcode_revision(void)
57 u32 rev, dummy;
59 native_wrmsrl(MSR_IA32_UCODE_REV, 0);
61 /* As documented in the SDM: Do a CPUID 1 here */
62 native_cpuid_eax(1);
64 /* get the current revision from MSR 0x8B */
65 native_rdmsr(MSR_IA32_UCODE_REV, dummy, rev);
67 return rev;
70 #ifdef CONFIG_MICROCODE_INTEL
71 extern void __init load_ucode_intel_bsp(void);
72 extern void load_ucode_intel_ap(void);
73 extern void show_ucode_info_early(void);
74 extern int __init save_microcode_in_initrd_intel(void);
75 void reload_ucode_intel(void);
76 #else
77 static inline __init void load_ucode_intel_bsp(void) {}
78 static inline void load_ucode_intel_ap(void) {}
79 static inline void show_ucode_info_early(void) {}
80 static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL; }
81 static inline void reload_ucode_intel(void) {}
82 #endif
84 #endif /* _ASM_X86_MICROCODE_INTEL_H */