| 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 *); | 
| Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 108 | extern struct kimage *kexec_image; | 
 | 109 |  | 
 | 110 | #define KEXEC_ON_CRASH  0x00000001 | 
 | 111 | #define KEXEC_ARCH_MASK 0xffff0000 | 
 | 112 |  | 
 | 113 | /* These values match the ELF architecture values. | 
 | 114 |  * Unless there is a good reason that should continue to be the case. | 
 | 115 |  */ | 
 | 116 | #define KEXEC_ARCH_DEFAULT ( 0 << 16) | 
 | 117 | #define KEXEC_ARCH_386     ( 3 << 16) | 
 | 118 | #define KEXEC_ARCH_X86_64  (62 << 16) | 
 | 119 | #define KEXEC_ARCH_PPC     (20 << 16) | 
 | 120 | #define KEXEC_ARCH_PPC64   (21 << 16) | 
 | 121 | #define KEXEC_ARCH_IA_64   (50 << 16) | 
| Heiko Carstens | cf13f0e | 2005-06-25 14:58:11 -0700 | [diff] [blame] | 122 | #define KEXEC_ARCH_S390    (22 << 16) | 
| kogiidena | 9d44190 | 2006-01-16 22:14:10 -0800 | [diff] [blame] | 123 | #define KEXEC_ARCH_SH      (42 << 16) | 
| Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 124 |  | 
 | 125 | #define KEXEC_FLAGS    (KEXEC_ON_CRASH)  /* List of defined/legal kexec flags */ | 
 | 126 |  | 
 | 127 | /* Location of a reserved region to hold the crash kernel. | 
 | 128 |  */ | 
 | 129 | extern struct resource crashk_res; | 
| Vivek Goyal | cc57165 | 2006-01-09 20:51:41 -0800 | [diff] [blame] | 130 | typedef u32 note_buf_t[MAX_NOTE_BYTES/4]; | 
 | 131 | extern note_buf_t *crash_notes; | 
| Eric W. Biederman | dc009d9 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 132 |  | 
 | 133 | #else /* !CONFIG_KEXEC */ | 
| Alexander Nyberg | 6e274d1 | 2005-06-25 14:58:26 -0700 | [diff] [blame] | 134 | struct pt_regs; | 
 | 135 | struct task_struct; | 
 | 136 | static inline void crash_kexec(struct pt_regs *regs) { } | 
 | 137 | 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] | 138 | #endif /* CONFIG_KEXEC */ | 
 | 139 | #endif /* LINUX_KEXEC_H */ |