Path: blob/master/arch/mips/kernel/machine_kexec.c
10817 views
/*1* machine_kexec.c for kexec2* Created by <[email protected]> on Thu Oct 12 15:15:06 20063*4* This source code is licensed under the GNU General Public License,5* Version 2. See the file COPYING for more details.6*/78#include <linux/kexec.h>9#include <linux/mm.h>10#include <linux/delay.h>1112#include <asm/cacheflush.h>13#include <asm/page.h>1415extern const unsigned char relocate_new_kernel[];16extern const size_t relocate_new_kernel_size;1718extern unsigned long kexec_start_address;19extern unsigned long kexec_indirection_page;2021int22machine_kexec_prepare(struct kimage *kimage)23{24return 0;25}2627void28machine_kexec_cleanup(struct kimage *kimage)29{30}3132void33machine_shutdown(void)34{35}3637void38machine_crash_shutdown(struct pt_regs *regs)39{40}4142typedef void (*noretfun_t)(void) __attribute__((noreturn));4344void45machine_kexec(struct kimage *image)46{47unsigned long reboot_code_buffer;48unsigned long entry;49unsigned long *ptr;5051reboot_code_buffer =52(unsigned long)page_address(image->control_code_page);5354kexec_start_address = image->start;55kexec_indirection_page =56(unsigned long) phys_to_virt(image->head & PAGE_MASK);5758memcpy((void*)reboot_code_buffer, relocate_new_kernel,59relocate_new_kernel_size);6061/*62* The generic kexec code builds a page list with physical63* addresses. they are directly accessible through KSEG0 (or64* CKSEG0 or XPHYS if on 64bit system), hence the65* pys_to_virt() call.66*/67for (ptr = &image->head; (entry = *ptr) && !(entry &IND_DONE);68ptr = (entry & IND_INDIRECTION) ?69phys_to_virt(entry & PAGE_MASK) : ptr + 1) {70if (*ptr & IND_SOURCE || *ptr & IND_INDIRECTION ||71*ptr & IND_DESTINATION)72*ptr = (unsigned long) phys_to_virt(*ptr);73}7475/*76* we do not want to be bothered.77*/78local_irq_disable();7980printk("Will call new kernel at %08lx\n", image->start);81printk("Bye ...\n");82__flush_cache_all();83((noretfun_t) reboot_code_buffer)();84}858687