blob: 195becc6f78074f23f25dc7d5d14da4bd90aac76 [file] [log] [blame]
Fenghua Yu9cd4d782012-12-20 23:44:22 -08001#ifndef _ASM_X86_MICROCODE_INTEL_H
2#define _ASM_X86_MICROCODE_INTEL_H
3
4#include <asm/microcode.h>
5
6struct 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];
17};
18
19struct microcode_intel {
20 struct microcode_header_intel hdr;
21 unsigned int bits[0];
22};
23
24/* microcode format is extended from prescott processors */
25struct extended_signature {
26 unsigned int sig;
27 unsigned int pf;
28 unsigned int cksum;
29};
30
31struct extended_sigtable {
32 unsigned int count;
33 unsigned int cksum;
34 unsigned int reserved[3];
35 struct extended_signature sigs[0];
36};
37
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))
Fenghua Yu9cd4d782012-12-20 23:44:22 -080043
44#define get_totalsize(mc) \
Henrique de Moraes Holschuhebc14dd2014-07-23 17:10:49 -030045 (((struct microcode_intel *)mc)->hdr.datasize ? \
Fenghua Yu9cd4d782012-12-20 23:44:22 -080046 ((struct microcode_intel *)mc)->hdr.totalsize : \
47 DEFAULT_UCODE_TOTALSIZE)
48
49#define get_datasize(mc) \
50 (((struct microcode_intel *)mc)->hdr.datasize ? \
51 ((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE)
52
Fenghua Yu9cd4d782012-12-20 23:44:22 -080053#define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE)
54
Borislav Petkovfe055892015-10-20 11:54:45 +020055#ifdef CONFIG_MICROCODE_INTEL
Fenghua Yu9cd4d782012-12-20 23:44:22 -080056extern void __init load_ucode_intel_bsp(void);
Paul Gortmaker148f9bb2013-06-18 18:23:59 -040057extern void load_ucode_intel_ap(void);
Fenghua Yu9cd4d782012-12-20 23:44:22 -080058extern void show_ucode_info_early(void);
Jacob Shinf2b3ee82013-05-30 14:09:17 -050059extern int __init save_microcode_in_initrd_intel(void);
Borislav Petkovfbae4ba2014-12-03 17:21:41 +010060void reload_ucode_intel(void);
Fenghua Yu9cd4d782012-12-20 23:44:22 -080061#else
62static inline __init void load_ucode_intel_bsp(void) {}
Paul Gortmaker148f9bb2013-06-18 18:23:59 -040063static inline void load_ucode_intel_ap(void) {}
Fenghua Yu9cd4d782012-12-20 23:44:22 -080064static inline void show_ucode_info_early(void) {}
Jacob Shinf2b3ee82013-05-30 14:09:17 -050065static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL; }
Borislav Petkovfbae4ba2014-12-03 17:21:41 +010066static inline void reload_ucode_intel(void) {}
Fenghua Yu9cd4d782012-12-20 23:44:22 -080067#endif
68
Fenghua Yu9cd4d782012-12-20 23:44:22 -080069#endif /* _ASM_X86_MICROCODE_INTEL_H */