1 /* 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> 16 #include <linux/numa.h> 17 #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 23 typedef NORET_TYPE void (*relocate_new_kernel_t)( 24 unsigned long indirection_page, 25 unsigned long reboot_code_buffer, 26 unsigned long start_address, 27 unsigned long vbr_reg) ATTRIB_NORET; 28 29 extern const unsigned char relocate_new_kernel[]; 30 extern const unsigned int relocate_new_kernel_size; 31 extern void *gdb_vbr_vector; 32 33 void machine_shutdown(void) 34 { 35 } 36 37 void machine_crash_shutdown(struct pt_regs *regs) 38 { 39 } 40 41 /* 42 * Do what every setup is needed on image and the 43 * reboot code buffer to allow us to avoid allocations 44 * later. 45 */ 46 int machine_kexec_prepare(struct kimage *image) 47 { 48 return 0; 49 } 50 51 void machine_kexec_cleanup(struct kimage *image) 52 { 53 } 54 55 static void kexec_info(struct kimage *image) 56 { 57 int i; 58 printk("kexec information\n"); 59 for (i = 0; i < image->nr_segments; i++) { 60 printk(" segment[%d]: 0x%08x - 0x%08x (0x%08x)\n", 61 i, 62 (unsigned int)image->segment[i].mem, 63 (unsigned int)image->segment[i].mem + 64 image->segment[i].memsz, 65 (unsigned int)image->segment[i].memsz); 66 } 67 printk(" start : 0x%08x\n\n", (unsigned int)image->start); 68 } 69 70 /* 71 * Do not allocate memory (or fail in any way) in machine_kexec(). 72 * We are past the point of no return, committed to rebooting now. 73 */ 74 void machine_kexec(struct kimage *image) 75 { 76 77 unsigned long page_list; 78 unsigned long reboot_code_buffer; 79 unsigned long vbr_reg; 80 relocate_new_kernel_t rnk; 81 82 #if defined(CONFIG_SH_STANDARD_BIOS) 83 vbr_reg = ((unsigned long )gdb_vbr_vector) - 0x100; 84 #else 85 vbr_reg = 0x80000000; // dummy 86 #endif 87 /* Interrupts aren't acceptable while we reboot */ 88 local_irq_disable(); 89 90 page_list = image->head; 91 92 /* we need both effective and real address here */ 93 reboot_code_buffer = 94 (unsigned long)page_address(image->control_code_page); 95 96 /* copy our kernel relocation code to the control code page */ 97 memcpy((void *)reboot_code_buffer, relocate_new_kernel, 98 relocate_new_kernel_size); 99 100 kexec_info(image); 101 flush_cache_all(); 102 103 /* now call it */ 104 rnk = (relocate_new_kernel_t) reboot_code_buffer; 105 (*rnk)(page_list, reboot_code_buffer, P2SEGADDR(image->start), vbr_reg); 106 } 107 108 void arch_crash_save_vmcoreinfo(void) 109 { 110 #ifdef CONFIG_NUMA 111 VMCOREINFO_SYMBOL(node_data); 112 VMCOREINFO_LENGTH(node_data, MAX_NUMNODES); 113 #endif 114 } 115