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