x86-microcode: generic interface refactoring
[pandora-kernel.git] / include / asm-x86 / microcode.h
1 #ifndef ASM_X86__MICROCODE_H
2 #define ASM_X86__MICROCODE_H
3
4 extern int microcode_init(void *opaque, struct module *module);
5 extern void microcode_exit(void);
6
7 struct cpu_signature;
8
9 struct microcode_ops {
10         long (*get_next_ucode)(void **mc, long offset);
11         long (*microcode_get_next_ucode)(void **mc, long offset);
12         int (*get_matching_microcode)(void *mc, int cpu);
13         int (*microcode_sanity_check)(void *mc);
14         int (*cpu_request_microcode)(int cpu);
15         int (*collect_cpu_info)(int cpu_num, struct cpu_signature *csig);
16         void (*apply_microcode)(int cpu);
17         void (*microcode_fini_cpu)(int cpu);
18         void (*clear_patch)(void *data);
19 };
20
21 struct microcode_header_intel {
22         unsigned int            hdrver;
23         unsigned int            rev;
24         unsigned int            date;
25         unsigned int            sig;
26         unsigned int            cksum;
27         unsigned int            ldrver;
28         unsigned int            pf;
29         unsigned int            datasize;
30         unsigned int            totalsize;
31         unsigned int            reserved[3];
32 };
33
34 struct microcode_intel {
35         struct microcode_header_intel hdr;
36         unsigned int            bits[0];
37 };
38
39 /* microcode format is extended from prescott processors */
40 struct extended_signature {
41         unsigned int            sig;
42         unsigned int            pf;
43         unsigned int            cksum;
44 };
45
46 struct extended_sigtable {
47         unsigned int            count;
48         unsigned int            cksum;
49         unsigned int            reserved[3];
50         struct extended_signature sigs[0];
51 };
52
53 struct equiv_cpu_entry {
54         unsigned int installed_cpu;
55         unsigned int fixed_errata_mask;
56         unsigned int fixed_errata_compare;
57         unsigned int equiv_cpu;
58 };
59
60 struct microcode_header_amd {
61         unsigned int  data_code;
62         unsigned int  patch_id;
63         unsigned char mc_patch_data_id[2];
64         unsigned char mc_patch_data_len;
65         unsigned char init_flag;
66         unsigned int  mc_patch_data_checksum;
67         unsigned int  nb_dev_id;
68         unsigned int  sb_dev_id;
69         unsigned char processor_rev_id[2];
70         unsigned char nb_rev_id;
71         unsigned char sb_rev_id;
72         unsigned char bios_api_rev;
73         unsigned char reserved1[3];
74         unsigned int  match_reg[8];
75 };
76
77 struct microcode_amd {
78         struct microcode_header_amd hdr;
79         unsigned int mpb[0];
80 };
81
82 struct cpu_signature {
83         unsigned int sig;
84         unsigned int pf;
85         unsigned int rev;
86 };
87
88 struct ucode_cpu_info {
89         struct cpu_signature cpu_sig;
90         int valid;
91         union {
92                 struct microcode_intel *mc_intel;
93                 struct microcode_amd *mc_amd;
94                 void *valid_mc;
95         } mc;
96 };
97 extern struct ucode_cpu_info ucode_cpu_info[];
98
99 #endif /* ASM_X86__MICROCODE_H */