blob: d02425cdd801c28d94cef85666bdc564ae6c867e [file] [log] [blame]
Eric W. Biedermandc009d92005-06-25 14:57:52 -07001#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 Myneni9c15e852006-02-10 01:51:05 -08009#include <linux/ioport.h>
Eric W. Biedermandc009d92005-06-25 14:57:52 -070010#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
39typedef 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.org720e1a92006-01-09 20:51:51 -080045#define KEXEC_SEGMENT_MAX 16
Eric W. Biedermandc009d92005-06-25 14:57:52 -070046struct 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
54struct 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
62struct 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 */
91extern NORET_TYPE void machine_kexec(struct kimage *image) ATTRIB_NORET;
92extern int machine_kexec_prepare(struct kimage *image);
93extern void machine_kexec_cleanup(struct kimage *image);
94extern asmlinkage long sys_kexec_load(unsigned long entry,
Maneesh Soni72414d32005-06-25 14:58:28 -070095 unsigned long nr_segments,
96 struct kexec_segment __user *segments,
97 unsigned long flags);
Eric W. Biedermandc009d92005-06-25 14:57:52 -070098#ifdef CONFIG_COMPAT
99extern asmlinkage long compat_sys_kexec_load(unsigned long entry,
Maneesh Soni72414d32005-06-25 14:58:28 -0700100 unsigned long nr_segments,
101 struct compat_kexec_segment __user *segments,
102 unsigned long flags);
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700103#endif
Maneesh Soni72414d32005-06-25 14:58:28 -0700104extern struct page *kimage_alloc_control_pages(struct kimage *image,
105 unsigned int order);
Alexander Nyberg6e274d12005-06-25 14:58:26 -0700106extern void crash_kexec(struct pt_regs *);
107int kexec_should_crash(struct task_struct *);
Magnus Damm85916f82006-12-06 20:40:41 -0800108void crash_save_cpu(struct pt_regs *regs, int cpu);
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700109extern struct kimage *kexec_image;
Jeff Moyerc330dda2006-06-23 02:05:07 -0700110extern struct kimage *kexec_crash_image;
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700111
Zou Nan haia7956112006-12-07 09:51:35 -0800112#ifndef kexec_flush_icache_page
113#define kexec_flush_icache_page(page)
114#endif
115
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700116#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)
Heiko Carstenscf13f0e2005-06-25 14:58:11 -0700128#define KEXEC_ARCH_S390 (22 << 16)
kogiidena9d441902006-01-16 22:14:10 -0800129#define KEXEC_ARCH_SH (42 << 16)
Nicolas Schichan583bb862006-10-18 15:14:55 +0200130#define KEXEC_ARCH_MIPS_LE (10 << 16)
131#define KEXEC_ARCH_MIPS ( 8 << 16)
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700132
133#define KEXEC_FLAGS (KEXEC_ON_CRASH) /* List of defined/legal kexec flags */
134
135/* Location of a reserved region to hold the crash kernel.
136 */
137extern struct resource crashk_res;
Vivek Goyalcc571652006-01-09 20:51:41 -0800138typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
139extern note_buf_t *crash_notes;
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700140
Zou Nan haia7956112006-12-07 09:51:35 -0800141
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700142#else /* !CONFIG_KEXEC */
Alexander Nyberg6e274d12005-06-25 14:58:26 -0700143struct pt_regs;
144struct task_struct;
145static inline void crash_kexec(struct pt_regs *regs) { }
146static inline int kexec_should_crash(struct task_struct *p) { return 0; }
Eric W. Biedermandc009d92005-06-25 14:57:52 -0700147#endif /* CONFIG_KEXEC */
148#endif /* LINUX_KEXEC_H */