machine_kexec.c 1.6 KB
Newer Older
H
Heiko Carstens 已提交
1 2 3
/*
 * arch/s390/kernel/machine_kexec.c
 *
H
Heiko Carstens 已提交
4
 * Copyright IBM Corp. 2005,2006
H
Heiko Carstens 已提交
5
 *
H
Heiko Carstens 已提交
6 7
 * Author(s): Rolf Adelsberger,
 *	      Heiko Carstens <heiko.carstens@de.ibm.com>
H
Heiko Carstens 已提交
8 9 10 11 12 13
 */

#include <linux/device.h>
#include <linux/mm.h>
#include <linux/kexec.h>
#include <linux/delay.h>
14
#include <linux/reboot.h>
15 16
#include <asm/cio.h>
#include <asm/setup.h>
H
Heiko Carstens 已提交
17 18 19
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
#include <asm/system.h>
20
#include <asm/smp.h>
21
#include <asm/reset.h>
H
Heiko Carstens 已提交
22
#include <asm/ipl.h>
H
Heiko Carstens 已提交
23

H
Heiko Carstens 已提交
24
typedef void (*relocate_kernel_t)(kimage_entry_t *, unsigned long);
H
Heiko Carstens 已提交
25

T
Tobias Klauser 已提交
26 27
extern const unsigned char relocate_kernel[];
extern const unsigned long long relocate_kernel_len;
H
Heiko Carstens 已提交
28

H
Heiko Carstens 已提交
29
int machine_kexec_prepare(struct kimage *image)
H
Heiko Carstens 已提交
30
{
H
Heiko Carstens 已提交
31
	void *reboot_code_buffer;
H
Heiko Carstens 已提交
32

H
Heiko Carstens 已提交
33 34 35 36
	/* Can't replace kernel image since it is read-only. */
	if (ipl_flags & IPL_NSS_VALID)
		return -ENOSYS;

H
Heiko Carstens 已提交
37 38 39 40 41
	/* We don't support anything but the default image type for now. */
	if (image->type != KEXEC_TYPE_DEFAULT)
		return -EINVAL;

	/* Get the destination where the assembler code should be copied to.*/
H
Heiko Carstens 已提交
42
	reboot_code_buffer = (void *) page_to_phys(image->control_code_page);
H
Heiko Carstens 已提交
43 44

	/* Then copy it */
H
Heiko Carstens 已提交
45
	memcpy(reboot_code_buffer, relocate_kernel, relocate_kernel_len);
H
Heiko Carstens 已提交
46 47 48
	return 0;
}

H
Heiko Carstens 已提交
49
void machine_kexec_cleanup(struct kimage *image)
H
Heiko Carstens 已提交
50 51 52
{
}

H
Heiko Carstens 已提交
53
void machine_shutdown(void)
H
Heiko Carstens 已提交
54 55 56 57
{
	printk(KERN_INFO "kexec: machine_shutdown called\n");
}

H
Heiko Carstens 已提交
58
void machine_kexec(struct kimage *image)
H
Heiko Carstens 已提交
59 60 61
{
	relocate_kernel_t data_mover;

H
Heiko Carstens 已提交
62
	smp_send_stop();
H
Heiko Carstens 已提交
63
	pfault_fini();
64 65
	s390_reset_system();

H
Heiko Carstens 已提交
66
	data_mover = (relocate_kernel_t) page_to_phys(image->control_code_page);
H
Heiko Carstens 已提交
67 68

	/* Call the moving routine */
H
Heiko Carstens 已提交
69 70
	(*data_mover)(&image->head, image->start);
	for (;;);
H
Heiko Carstens 已提交
71
}