Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds
[pandora-kernel.git] / include / linux / kexec.h
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 <linux/ioport.h>
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
45 #define KEXEC_SEGMENT_MAX 16
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,
95                                         unsigned long nr_segments,
96                                         struct kexec_segment __user *segments,
97                                         unsigned long flags);
98 #ifdef CONFIG_COMPAT
99 extern asmlinkage long compat_sys_kexec_load(unsigned long entry,
100                                 unsigned long nr_segments,
101                                 struct compat_kexec_segment __user *segments,
102                                 unsigned long flags);
103 #endif
104 extern struct page *kimage_alloc_control_pages(struct kimage *image,
105                                                 unsigned int order);
106 extern void crash_kexec(struct pt_regs *);
107 int kexec_should_crash(struct task_struct *);
108 void crash_save_cpu(struct pt_regs *regs, int cpu);
109 extern struct kimage *kexec_image;
110 extern struct kimage *kexec_crash_image;
111
112 #ifndef kexec_flush_icache_page
113 #define kexec_flush_icache_page(page)
114 #endif
115
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)
128 #define KEXEC_ARCH_ARM     (40 << 16)
129 #define KEXEC_ARCH_S390    (22 << 16)
130 #define KEXEC_ARCH_SH      (42 << 16)
131 #define KEXEC_ARCH_MIPS_LE (10 << 16)
132 #define KEXEC_ARCH_MIPS    ( 8 << 16)
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;
139 typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
140 extern note_buf_t *crash_notes;
141
142
143 #else /* !CONFIG_KEXEC */
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; }
148 #endif /* CONFIG_KEXEC */
149 #endif /* LINUX_KEXEC_H */