| xj | b04a402 | 2021-11-25 15:01:52 +0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2016 Imagination Technologies | 
|  | 3 | * Author: Marcin Nowakowski <marcin.nowakowski@mips.com> | 
|  | 4 | * | 
|  | 5 | * This program is free software; you can redistribute it and/or modify it | 
|  | 6 | * under the terms of the GNU General Public License as published by the | 
|  | 7 | * Free Software Foundation; either version 2 of the License, or (at your | 
|  | 8 | * option) any later version. | 
|  | 9 | */ | 
|  | 10 |  | 
|  | 11 | #include <linux/kexec.h> | 
|  | 12 | #include <linux/libfdt.h> | 
|  | 13 | #include <linux/uaccess.h> | 
|  | 14 |  | 
|  | 15 | static int generic_kexec_prepare(struct kimage *image) | 
|  | 16 | { | 
|  | 17 | int i; | 
|  | 18 |  | 
|  | 19 | for (i = 0; i < image->nr_segments; i++) { | 
|  | 20 | struct fdt_header fdt; | 
|  | 21 |  | 
|  | 22 | if (image->segment[i].memsz <= sizeof(fdt)) | 
|  | 23 | continue; | 
|  | 24 |  | 
|  | 25 | if (copy_from_user(&fdt, image->segment[i].buf, sizeof(fdt))) | 
|  | 26 | continue; | 
|  | 27 |  | 
|  | 28 | if (fdt_check_header(&fdt)) | 
|  | 29 | continue; | 
|  | 30 |  | 
|  | 31 | kexec_args[0] = -2; | 
|  | 32 | kexec_args[1] = (unsigned long) | 
|  | 33 | phys_to_virt((unsigned long)image->segment[i].mem); | 
|  | 34 | break; | 
|  | 35 | } | 
|  | 36 | return 0; | 
|  | 37 | } | 
|  | 38 |  | 
|  | 39 | static int __init register_generic_kexec(void) | 
|  | 40 | { | 
|  | 41 | _machine_kexec_prepare = generic_kexec_prepare; | 
|  | 42 | return 0; | 
|  | 43 | } | 
|  | 44 | arch_initcall(register_generic_kexec); |