H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 1 | #ifndef _ASM_X86_MICROCODE_H |
| 2 | #define _ASM_X86_MICROCODE_H |
Dmitry Adamushko | d45de40 | 2008-08-20 00:22:26 +0200 | [diff] [blame] | 3 | |
Dmitry Adamushko | 18dbc91 | 2008-09-23 12:08:44 +0200 | [diff] [blame] | 4 | struct cpu_signature { |
| 5 | unsigned int sig; |
| 6 | unsigned int pf; |
| 7 | unsigned int rev; |
| 8 | }; |
Peter Oruba | 8d86f39 | 2008-07-28 18:44:21 +0200 | [diff] [blame] | 9 | |
Dmitry Adamushko | a0a29b6 | 2008-09-11 23:27:52 +0200 | [diff] [blame] | 10 | struct device; |
Dmitry Adamushko | d45de40 | 2008-08-20 00:22:26 +0200 | [diff] [blame] | 11 | |
Dmitry Adamushko | 871b72d | 2009-05-11 23:48:27 +0200 | [diff] [blame] | 12 | enum ucode_state { UCODE_ERROR, UCODE_OK, UCODE_NFOUND }; |
| 13 | |
Peter Oruba | 26bf7a4 | 2008-07-28 18:44:20 +0200 | [diff] [blame] | 14 | struct microcode_ops { |
Dmitry Adamushko | 871b72d | 2009-05-11 23:48:27 +0200 | [diff] [blame] | 15 | enum ucode_state (*request_microcode_user) (int cpu, |
| 16 | const void __user *buf, size_t size); |
Dmitry Adamushko | a0a29b6 | 2008-09-11 23:27:52 +0200 | [diff] [blame] | 17 | |
Borislav Petkov | 48e3068 | 2012-07-26 15:51:00 +0200 | [diff] [blame] | 18 | enum ucode_state (*request_microcode_fw) (int cpu, struct device *, |
| 19 | bool refresh_fw); |
Dmitry Adamushko | a0a29b6 | 2008-09-11 23:27:52 +0200 | [diff] [blame] | 20 | |
Dmitry Adamushko | a0a29b6 | 2008-09-11 23:27:52 +0200 | [diff] [blame] | 21 | void (*microcode_fini_cpu) (int cpu); |
Dmitry Adamushko | 871b72d | 2009-05-11 23:48:27 +0200 | [diff] [blame] | 22 | |
| 23 | /* |
| 24 | * The generic 'microcode_core' part guarantees that |
| 25 | * the callbacks below run on a target cpu when they |
| 26 | * are being called. |
| 27 | * See also the "Synchronization" section in microcode_core.c. |
| 28 | */ |
| 29 | int (*apply_microcode) (int cpu); |
| 30 | int (*collect_cpu_info) (int cpu, struct cpu_signature *csig); |
Peter Oruba | 26bf7a4 | 2008-07-28 18:44:20 +0200 | [diff] [blame] | 31 | }; |
| 32 | |
Dmitry Adamushko | d45de40 | 2008-08-20 00:22:26 +0200 | [diff] [blame] | 33 | struct ucode_cpu_info { |
Dmitry Adamushko | 871b72d | 2009-05-11 23:48:27 +0200 | [diff] [blame] | 34 | struct cpu_signature cpu_sig; |
| 35 | int valid; |
| 36 | void *mc; |
Peter Oruba | c3b71bc | 2008-07-28 18:44:15 +0200 | [diff] [blame] | 37 | }; |
Dmitry Adamushko | d45de40 | 2008-08-20 00:22:26 +0200 | [diff] [blame] | 38 | extern struct ucode_cpu_info ucode_cpu_info[]; |
| 39 | |
Dmitry Adamushko | 18dbc91 | 2008-09-23 12:08:44 +0200 | [diff] [blame] | 40 | #ifdef CONFIG_MICROCODE_INTEL |
| 41 | extern struct microcode_ops * __init init_intel_microcode(void); |
| 42 | #else |
| 43 | static inline struct microcode_ops * __init init_intel_microcode(void) |
| 44 | { |
| 45 | return NULL; |
| 46 | } |
| 47 | #endif /* CONFIG_MICROCODE_INTEL */ |
| 48 | |
| 49 | #ifdef CONFIG_MICROCODE_AMD |
| 50 | extern struct microcode_ops * __init init_amd_microcode(void); |
Borislav Petkov | f72c1a5 | 2011-12-02 16:50:04 +0100 | [diff] [blame] | 51 | extern void __exit exit_amd_microcode(void); |
Dmitry Adamushko | 18dbc91 | 2008-09-23 12:08:44 +0200 | [diff] [blame] | 52 | #else |
| 53 | static inline struct microcode_ops * __init init_amd_microcode(void) |
| 54 | { |
| 55 | return NULL; |
| 56 | } |
Borislav Petkov | f72c1a5 | 2011-12-02 16:50:04 +0100 | [diff] [blame] | 57 | static inline void __exit exit_amd_microcode(void) {} |
Dmitry Adamushko | 18dbc91 | 2008-09-23 12:08:44 +0200 | [diff] [blame] | 58 | #endif |
| 59 | |
Fenghua Yu | a8ebf6d | 2012-12-20 23:44:25 -0800 | [diff] [blame] | 60 | #ifdef CONFIG_MICROCODE_EARLY |
| 61 | #define MAX_UCODE_COUNT 128 |
| 62 | extern void __init load_ucode_bsp(void); |
Paul Gortmaker | 148f9bb | 2013-06-18 18:23:59 -0400 | [diff] [blame] | 63 | extern void load_ucode_ap(void); |
Fenghua Yu | a8ebf6d | 2012-12-20 23:44:25 -0800 | [diff] [blame] | 64 | extern int __init save_microcode_in_initrd(void); |
| 65 | #else |
| 66 | static inline void __init load_ucode_bsp(void) {} |
Paul Gortmaker | 148f9bb | 2013-06-18 18:23:59 -0400 | [diff] [blame] | 67 | static inline void load_ucode_ap(void) {} |
Fenghua Yu | a8ebf6d | 2012-12-20 23:44:25 -0800 | [diff] [blame] | 68 | static inline int __init save_microcode_in_initrd(void) |
| 69 | { |
| 70 | return 0; |
| 71 | } |
| 72 | #endif |
| 73 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 74 | #endif /* _ASM_X86_MICROCODE_H */ |