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>
12 /* Verify architecture specific macros are defined */
14 #ifndef KEXEC_SOURCE_MEMORY_LIMIT
15 #error KEXEC_SOURCE_MEMORY_LIMIT not defined
18 #ifndef KEXEC_DESTINATION_MEMORY_LIMIT
19 #error KEXEC_DESTINATION_MEMORY_LIMIT not defined
22 #ifndef KEXEC_CONTROL_MEMORY_LIMIT
23 #error KEXEC_CONTROL_MEMORY_LIMIT not defined
26 #ifndef KEXEC_CONTROL_CODE_SIZE
27 #error KEXEC_CONTROL_CODE_SIZE not defined
31 #error KEXEC_ARCH not defined
35 * This structure is used to hold the arguments that are used when loading
39 typedef unsigned long kimage_entry_t
;
40 #define IND_DESTINATION 0x1
41 #define IND_INDIRECTION 0x2
43 #define IND_SOURCE 0x8
45 #define KEXEC_SEGMENT_MAX 16
46 struct kexec_segment
{
49 unsigned long mem
; /* User space sees this as a (void *) ... */
54 struct compat_kexec_segment
{
57 compat_ulong_t mem
; /* User space sees this as a (void *) ... */
64 kimage_entry_t
*entry
;
65 kimage_entry_t
*last_entry
;
67 unsigned long destination
;
70 struct page
*control_code_page
;
72 unsigned long nr_segments
;
73 struct kexec_segment segment
[KEXEC_SEGMENT_MAX
];
75 struct list_head control_pages
;
76 struct list_head dest_pages
;
77 struct list_head unuseable_pages
;
79 /* Address of next control page to allocate for crash kernels. */
80 unsigned long control_page
;
82 /* Flags to indicate special processing */
83 unsigned int type
: 1;
84 #define KEXEC_TYPE_DEFAULT 0
85 #define KEXEC_TYPE_CRASH 1
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
,
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
);
104 extern struct page
*kimage_alloc_control_pages(struct kimage
*image
,
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
;
112 #ifndef kexec_flush_icache_page
113 #define kexec_flush_icache_page(page)
116 #define KEXEC_ON_CRASH 0x00000001
117 #define KEXEC_ARCH_MASK 0xffff0000
119 /* These values match the ELF architecture values.
120 * Unless there is a good reason that should continue to be the case.
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_S390 (22 << 16)
129 #define KEXEC_ARCH_SH (42 << 16)
130 #define KEXEC_ARCH_MIPS_LE (10 << 16)
131 #define KEXEC_ARCH_MIPS ( 8 << 16)
133 #define KEXEC_FLAGS (KEXEC_ON_CRASH) /* List of defined/legal kexec flags */
135 /* Location of a reserved region to hold the crash kernel.
137 extern struct resource crashk_res
;
138 typedef u32 note_buf_t
[MAX_NOTE_BYTES
/4];
139 extern note_buf_t
*crash_notes
;
142 #else /* !CONFIG_KEXEC */
145 static inline void crash_kexec(struct pt_regs
*regs
) { }
146 static inline int kexec_should_crash(struct task_struct
*p
) { return 0; }
147 #endif /* CONFIG_KEXEC */
148 #endif /* LINUX_KEXEC_H */