blob: d3318f99256b3ae8c8ad32ca5dff773fbb7feb7b [file] [log] [blame]
kogiidena9d441902006-01-16 22:14:10 -08001/*
2 * machine_kexec.c - handle transition of Linux booting another kernel
3 * Copyright (C) 2002-2003 Eric Biederman <ebiederm@xmission.com>
4 *
5 * GameCube/ppc32 port Copyright (C) 2004 Albert Herranz
6 * LANDISK/sh4 supported by kogiidena
7 *
8 * This source code is licensed under the GNU General Public License,
9 * Version 2. See the file COPYING for more details.
10 */
11
12#include <linux/mm.h>
13#include <linux/kexec.h>
14#include <linux/delay.h>
15#include <linux/reboot.h>
Paul Mundtc3b4adf2008-08-04 13:42:49 +090016#include <linux/numa.h>
kogiidena9d441902006-01-16 22:14:10 -080017#include <asm/pgtable.h>
18#include <asm/pgalloc.h>
19#include <asm/mmu_context.h>
20#include <asm/io.h>
21#include <asm/cacheflush.h>
22
23typedef NORET_TYPE void (*relocate_new_kernel_t)(
24 unsigned long indirection_page,
25 unsigned long reboot_code_buffer,
Magnus Damm7be5c552009-03-18 08:47:31 +000026 unsigned long start_address) ATTRIB_NORET;
kogiidena9d441902006-01-16 22:14:10 -080027
Tobias Klauser2efe55a2006-06-26 18:57:34 +020028extern const unsigned char relocate_new_kernel[];
29extern const unsigned int relocate_new_kernel_size;
kogiidena9d441902006-01-16 22:14:10 -080030extern void *gdb_vbr_vector;
31
kogiidena9d441902006-01-16 22:14:10 -080032void machine_shutdown(void)
33{
34}
35
36void machine_crash_shutdown(struct pt_regs *regs)
37{
38}
39
40/*
41 * Do what every setup is needed on image and the
42 * reboot code buffer to allow us to avoid allocations
43 * later.
44 */
45int machine_kexec_prepare(struct kimage *image)
46{
47 return 0;
48}
49
50void machine_kexec_cleanup(struct kimage *image)
51{
52}
53
54static void kexec_info(struct kimage *image)
55{
56 int i;
57 printk("kexec information\n");
58 for (i = 0; i < image->nr_segments; i++) {
59 printk(" segment[%d]: 0x%08x - 0x%08x (0x%08x)\n",
60 i,
61 (unsigned int)image->segment[i].mem,
Paul Mundt4d5ade52007-04-27 11:25:57 +090062 (unsigned int)image->segment[i].mem +
63 image->segment[i].memsz,
kogiidena9d441902006-01-16 22:14:10 -080064 (unsigned int)image->segment[i].memsz);
Paul Mundt4d5ade52007-04-27 11:25:57 +090065 }
kogiidena9d441902006-01-16 22:14:10 -080066 printk(" start : 0x%08x\n\n", (unsigned int)image->start);
67}
68
kogiidena9d441902006-01-16 22:14:10 -080069/*
70 * Do not allocate memory (or fail in any way) in machine_kexec().
71 * We are past the point of no return, committed to rebooting now.
72 */
Huang Ying3ab83522008-07-25 19:45:07 -070073void machine_kexec(struct kimage *image)
kogiidena9d441902006-01-16 22:14:10 -080074{
75
76 unsigned long page_list;
77 unsigned long reboot_code_buffer;
kogiidena9d441902006-01-16 22:14:10 -080078 relocate_new_kernel_t rnk;
79
kogiidena9d441902006-01-16 22:14:10 -080080 /* Interrupts aren't acceptable while we reboot */
81 local_irq_disable();
82
83 page_list = image->head;
84
85 /* we need both effective and real address here */
86 reboot_code_buffer =
87 (unsigned long)page_address(image->control_code_page);
88
89 /* copy our kernel relocation code to the control code page */
90 memcpy((void *)reboot_code_buffer, relocate_new_kernel,
91 relocate_new_kernel_size);
92
93 kexec_info(image);
94 flush_cache_all();
95
Magnus Damm7be5c552009-03-18 08:47:31 +000096 set_bl_bit();
97#if defined(CONFIG_SH_STANDARD_BIOS)
98 asm volatile("ldc %0, vbr" :
99 : "r" (((unsigned long) gdb_vbr_vector) - 0x100)
100 : "memory");
101#endif
kogiidena9d441902006-01-16 22:14:10 -0800102 /* now call it */
103 rnk = (relocate_new_kernel_t) reboot_code_buffer;
Magnus Damm7be5c552009-03-18 08:47:31 +0000104 (*rnk)(page_list, reboot_code_buffer, P2SEGADDR(image->start));
kogiidena9d441902006-01-16 22:14:10 -0800105}
106
Paul Mundtc3b4adf2008-08-04 13:42:49 +0900107void arch_crash_save_vmcoreinfo(void)
108{
109#ifdef CONFIG_NUMA
110 VMCOREINFO_SYMBOL(node_data);
111 VMCOREINFO_LENGTH(node_data, MAX_NUMNODES);
112#endif
113}