libata-link: separate out link initialization functions
[pv_ops_mirror.git] / include / linux / kexec.h
blob8c2c7fcd58ceab1937e8d20f4ac0da0c0940b404
1 #ifndef LINUX_KEXEC_H
2 #define LINUX_KEXEC_H
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 <linux/ioport.h>
10 #include <linux/elfcore.h>
11 #include <linux/elf.h>
12 #include <asm/kexec.h>
14 /* Verify architecture specific macros are defined */
16 #ifndef KEXEC_SOURCE_MEMORY_LIMIT
17 #error KEXEC_SOURCE_MEMORY_LIMIT not defined
18 #endif
20 #ifndef KEXEC_DESTINATION_MEMORY_LIMIT
21 #error KEXEC_DESTINATION_MEMORY_LIMIT not defined
22 #endif
24 #ifndef KEXEC_CONTROL_MEMORY_LIMIT
25 #error KEXEC_CONTROL_MEMORY_LIMIT not defined
26 #endif
28 #ifndef KEXEC_CONTROL_CODE_SIZE
29 #error KEXEC_CONTROL_CODE_SIZE not defined
30 #endif
32 #ifndef KEXEC_ARCH
33 #error KEXEC_ARCH not defined
34 #endif
36 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
37 #define KEXEC_CORE_NOTE_NAME "CORE"
38 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
39 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
41 * The per-cpu notes area is a list of notes terminated by a "NULL"
42 * note header. For kdump, the code in vmcore.c runs in the context
43 * of the second kernel to combine them into one note.
45 #define KEXEC_NOTE_BYTES ( (KEXEC_NOTE_HEAD_BYTES * 2) + \
46 KEXEC_CORE_NOTE_NAME_BYTES + \
47 KEXEC_CORE_NOTE_DESC_BYTES )
50 * This structure is used to hold the arguments that are used when loading
51 * kernel binaries.
54 typedef unsigned long kimage_entry_t;
55 #define IND_DESTINATION 0x1
56 #define IND_INDIRECTION 0x2
57 #define IND_DONE 0x4
58 #define IND_SOURCE 0x8
60 #define KEXEC_SEGMENT_MAX 16
61 struct kexec_segment {
62 void __user *buf;
63 size_t bufsz;
64 unsigned long mem; /* User space sees this as a (void *) ... */
65 size_t memsz;
68 #ifdef CONFIG_COMPAT
69 struct compat_kexec_segment {
70 compat_uptr_t buf;
71 compat_size_t bufsz;
72 compat_ulong_t mem; /* User space sees this as a (void *) ... */
73 compat_size_t memsz;
75 #endif
77 struct kimage {
78 kimage_entry_t head;
79 kimage_entry_t *entry;
80 kimage_entry_t *last_entry;
82 unsigned long destination;
84 unsigned long start;
85 struct page *control_code_page;
87 unsigned long nr_segments;
88 struct kexec_segment segment[KEXEC_SEGMENT_MAX];
90 struct list_head control_pages;
91 struct list_head dest_pages;
92 struct list_head unuseable_pages;
94 /* Address of next control page to allocate for crash kernels. */
95 unsigned long control_page;
97 /* Flags to indicate special processing */
98 unsigned int type : 1;
99 #define KEXEC_TYPE_DEFAULT 0
100 #define KEXEC_TYPE_CRASH 1
105 /* kexec interface functions */
106 extern NORET_TYPE void machine_kexec(struct kimage *image) ATTRIB_NORET;
107 extern int machine_kexec_prepare(struct kimage *image);
108 extern void machine_kexec_cleanup(struct kimage *image);
109 extern asmlinkage long sys_kexec_load(unsigned long entry,
110 unsigned long nr_segments,
111 struct kexec_segment __user *segments,
112 unsigned long flags);
113 #ifdef CONFIG_COMPAT
114 extern asmlinkage long compat_sys_kexec_load(unsigned long entry,
115 unsigned long nr_segments,
116 struct compat_kexec_segment __user *segments,
117 unsigned long flags);
118 #endif
119 extern struct page *kimage_alloc_control_pages(struct kimage *image,
120 unsigned int order);
121 extern void crash_kexec(struct pt_regs *);
122 int kexec_should_crash(struct task_struct *);
123 void crash_save_cpu(struct pt_regs *regs, int cpu);
124 extern struct kimage *kexec_image;
125 extern struct kimage *kexec_crash_image;
127 #ifndef kexec_flush_icache_page
128 #define kexec_flush_icache_page(page)
129 #endif
131 #define KEXEC_ON_CRASH 0x00000001
132 #define KEXEC_ARCH_MASK 0xffff0000
134 /* These values match the ELF architecture values.
135 * Unless there is a good reason that should continue to be the case.
137 #define KEXEC_ARCH_DEFAULT ( 0 << 16)
138 #define KEXEC_ARCH_386 ( 3 << 16)
139 #define KEXEC_ARCH_X86_64 (62 << 16)
140 #define KEXEC_ARCH_PPC (20 << 16)
141 #define KEXEC_ARCH_PPC64 (21 << 16)
142 #define KEXEC_ARCH_IA_64 (50 << 16)
143 #define KEXEC_ARCH_ARM (40 << 16)
144 #define KEXEC_ARCH_S390 (22 << 16)
145 #define KEXEC_ARCH_SH (42 << 16)
146 #define KEXEC_ARCH_MIPS_LE (10 << 16)
147 #define KEXEC_ARCH_MIPS ( 8 << 16)
149 #define KEXEC_FLAGS (KEXEC_ON_CRASH) /* List of defined/legal kexec flags */
151 /* Location of a reserved region to hold the crash kernel.
153 extern struct resource crashk_res;
154 typedef u32 note_buf_t[KEXEC_NOTE_BYTES/4];
155 extern note_buf_t *crash_notes;
158 #else /* !CONFIG_KEXEC */
159 struct pt_regs;
160 struct task_struct;
161 static inline void crash_kexec(struct pt_regs *regs) { }
162 static inline int kexec_should_crash(struct task_struct *p) { return 0; }
163 #endif /* CONFIG_KEXEC */
164 #endif /* LINUX_KEXEC_H */