Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 1 | #ifndef LINUX_KEXEC_H |
| 2 | #define LINUX_KEXEC_H |
| 3 | |
| 4 | #ifdef CONFIG_KEXEC |
| 5 | #include <linux/types.h> |
| 6 | #include <linux/list.h> |
| 7 | #include <linux/linkage.h> |
| 8 | #include <linux/compat.h> |
Haren Myneni | 9c15e85 | 2006-02-10 01:51:05 -0800 | [diff] [blame] | 9 | #include <linux/ioport.h> |
Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 10 | #include <asm/kexec.h> |
| 11 | |
| 12 | /* Verify architecture specific macros are defined */ |
| 13 | |
| 14 | #ifndef KEXEC_SOURCE_MEMORY_LIMIT |
| 15 | #error KEXEC_SOURCE_MEMORY_LIMIT not defined |
| 16 | #endif |
| 17 | |
| 18 | #ifndef KEXEC_DESTINATION_MEMORY_LIMIT |
| 19 | #error KEXEC_DESTINATION_MEMORY_LIMIT not defined |
| 20 | #endif |
| 21 | |
| 22 | #ifndef KEXEC_CONTROL_MEMORY_LIMIT |
| 23 | #error KEXEC_CONTROL_MEMORY_LIMIT not defined |
| 24 | #endif |
| 25 | |
| 26 | #ifndef KEXEC_CONTROL_CODE_SIZE |
| 27 | #error KEXEC_CONTROL_CODE_SIZE not defined |
| 28 | #endif |
| 29 | |
| 30 | #ifndef KEXEC_ARCH |
| 31 | #error KEXEC_ARCH not defined |
| 32 | #endif |
| 33 | |
| 34 | /* |
| 35 | * This structure is used to hold the arguments that are used when loading |
| 36 | * kernel binaries. |
| 37 | */ |
| 38 | |
| 39 | typedef unsigned long kimage_entry_t; |
| 40 | #define IND_DESTINATION 0x1 |
| 41 | #define IND_INDIRECTION 0x2 |
| 42 | #define IND_DONE 0x4 |
| 43 | #define IND_SOURCE 0x8 |
| 44 | |
akpm@osdl.org | 720e1a9 | 2006-01-09 20:51:51 -0800 | [diff] [blame] | 45 | #define KEXEC_SEGMENT_MAX 16 |
Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 46 | struct kexec_segment { |
| 47 | void __user *buf; |
| 48 | size_t bufsz; |
| 49 | unsigned long mem; /* User space sees this as a (void *) ... */ |
| 50 | size_t memsz; |
| 51 | }; |
| 52 | |
| 53 | #ifdef CONFIG_COMPAT |
| 54 | struct compat_kexec_segment { |
| 55 | compat_uptr_t buf; |
| 56 | compat_size_t bufsz; |
| 57 | compat_ulong_t mem; /* User space sees this as a (void *) ... */ |
| 58 | compat_size_t memsz; |
| 59 | }; |
| 60 | #endif |
| 61 | |
| 62 | struct kimage { |
| 63 | kimage_entry_t head; |
| 64 | kimage_entry_t *entry; |
| 65 | kimage_entry_t *last_entry; |
| 66 | |
| 67 | unsigned long destination; |
| 68 | |
| 69 | unsigned long start; |
| 70 | struct page *control_code_page; |
| 71 | |
| 72 | unsigned long nr_segments; |
| 73 | struct kexec_segment segment[KEXEC_SEGMENT_MAX]; |
| 74 | |
| 75 | struct list_head control_pages; |
| 76 | struct list_head dest_pages; |
| 77 | struct list_head unuseable_pages; |
| 78 | |
| 79 | /* Address of next control page to allocate for crash kernels. */ |
| 80 | unsigned long control_page; |
| 81 | |
| 82 | /* Flags to indicate special processing */ |
| 83 | unsigned int type : 1; |
| 84 | #define KEXEC_TYPE_DEFAULT 0 |
| 85 | #define KEXEC_TYPE_CRASH 1 |
| 86 | }; |
| 87 | |
| 88 | |
| 89 | |
| 90 | /* kexec interface functions */ |
| 91 | extern NORET_TYPE void machine_kexec(struct kimage *image) ATTRIB_NORET; |
| 92 | extern int machine_kexec_prepare(struct kimage *image); |
| 93 | extern void machine_kexec_cleanup(struct kimage *image); |
| 94 | extern asmlinkage long sys_kexec_load(unsigned long entry, |
Maneesh Soni | 72414d3 | 2005-06-25 14:58:28 -0700 | [diff] [blame] | 95 | unsigned long nr_segments, |
| 96 | struct kexec_segment __user *segments, |
| 97 | unsigned long flags); |
Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 98 | #ifdef CONFIG_COMPAT |
| 99 | extern asmlinkage long compat_sys_kexec_load(unsigned long entry, |
Maneesh Soni | 72414d3 | 2005-06-25 14:58:28 -0700 | [diff] [blame] | 100 | unsigned long nr_segments, |
| 101 | struct compat_kexec_segment __user *segments, |
| 102 | unsigned long flags); |
Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 103 | #endif |
Maneesh Soni | 72414d3 | 2005-06-25 14:58:28 -0700 | [diff] [blame] | 104 | extern struct page *kimage_alloc_control_pages(struct kimage *image, |
| 105 | unsigned int order); |
Alexander Nyberg | 6e274d1 | 2005-06-25 14:58:26 -0700 | [diff] [blame] | 106 | extern void crash_kexec(struct pt_regs *); |
| 107 | int kexec_should_crash(struct task_struct *); |
Magnus Damm | 85916f8 | 2006-12-06 20:40:41 -0800 | [diff] [blame] | 108 | void crash_save_cpu(struct pt_regs *regs, int cpu); |
Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 109 | extern struct kimage *kexec_image; |
Jeff Moyer | c330dda | 2006-06-23 02:05:07 -0700 | [diff] [blame] | 110 | extern struct kimage *kexec_crash_image; |
Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 111 | |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 112 | #ifndef kexec_flush_icache_page |
| 113 | #define kexec_flush_icache_page(page) |
| 114 | #endif |
| 115 | |
Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 116 | #define KEXEC_ON_CRASH 0x00000001 |
| 117 | #define KEXEC_ARCH_MASK 0xffff0000 |
| 118 | |
| 119 | /* These values match the ELF architecture values. |
| 120 | * Unless there is a good reason that should continue to be the case. |
| 121 | */ |
| 122 | #define KEXEC_ARCH_DEFAULT ( 0 << 16) |
| 123 | #define KEXEC_ARCH_386 ( 3 << 16) |
| 124 | #define KEXEC_ARCH_X86_64 (62 << 16) |
| 125 | #define KEXEC_ARCH_PPC (20 << 16) |
| 126 | #define KEXEC_ARCH_PPC64 (21 << 16) |
| 127 | #define KEXEC_ARCH_IA_64 (50 << 16) |
Richard Purdie | c587e4a | 2007-02-06 21:29:00 +0100 | [diff] [blame^] | 128 | #define KEXEC_ARCH_ARM (40 << 16) |
Heiko Carstens | cf13f0e | 2005-06-25 14:58:11 -0700 | [diff] [blame] | 129 | #define KEXEC_ARCH_S390 (22 << 16) |
kogiidena | 9d44190 | 2006-01-16 22:14:10 -0800 | [diff] [blame] | 130 | #define KEXEC_ARCH_SH (42 << 16) |
Nicolas Schichan | 583bb86 | 2006-10-18 15:14:55 +0200 | [diff] [blame] | 131 | #define KEXEC_ARCH_MIPS_LE (10 << 16) |
| 132 | #define KEXEC_ARCH_MIPS ( 8 << 16) |
Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 133 | |
| 134 | #define KEXEC_FLAGS (KEXEC_ON_CRASH) /* List of defined/legal kexec flags */ |
| 135 | |
| 136 | /* Location of a reserved region to hold the crash kernel. |
| 137 | */ |
| 138 | extern struct resource crashk_res; |
Vivek Goyal | cc57165 | 2006-01-09 20:51:41 -0800 | [diff] [blame] | 139 | typedef u32 note_buf_t[MAX_NOTE_BYTES/4]; |
| 140 | extern note_buf_t *crash_notes; |
Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 141 | |
Zou Nan hai | a795611 | 2006-12-07 09:51:35 -0800 | [diff] [blame] | 142 | |
Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 143 | #else /* !CONFIG_KEXEC */ |
Alexander Nyberg | 6e274d1 | 2005-06-25 14:58:26 -0700 | [diff] [blame] | 144 | struct pt_regs; |
| 145 | struct task_struct; |
| 146 | static inline void crash_kexec(struct pt_regs *regs) { } |
| 147 | static inline int kexec_should_crash(struct task_struct *p) { return 0; } |
Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 148 | #endif /* CONFIG_KEXEC */ |
| 149 | #endif /* LINUX_KEXEC_H */ |