MIPS: use kexec to load ELF linux images
Subsystems (3)
cover MIPS: use kexec to load ELF linux images
This patchseries introduces a suitable way for loading ELF linux kernel images on MIPS. You can load normal vmlinux images or compressed self-extractable vmlinuz images.
The patchseries and additional patch with pre-compiled demo vmlinuz image for MIPS Malta can be obtained here:
https://github.com/frantony/barebox/tree/next.mips-malta-elf-linux.20140415
Linux kernel ELF images use KSEG1 ("cached") addresses, so this series adds elementary code for MIPS cache support.
The code for actual ELF loading and relocation is imported
from
kexec-tools (git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools)
and
linux kernel (http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git).
There is no common standard on passing cmdline to the linux kernel on MIPS machines. We have to realize it's own cmdline passing routine for every MIPS machine supported by barebox. The 'MIPS: mach-malta: add kexec-capable reboot()' patch demonstrates how to do it for MIPS Malta.
To separate common ELF handling routines and machine-specific cmdline handling the 'reboot()' call is introduced.
The common code checks and loads ELF-file, the MIPS-specific code arrange ELF segments in the appropriate memory places and tunes relocator; next reboot() is called and machine-specific code works on cmdline passing.
Antony Pavlov (10):
MIPS: add initial cache support for R4000-class CPUs
MIPS: introduce arch_shutdown()
MIPS: use arch_shutdown() for flushing caches
MIPS: add virt_to_phys() and phys_to_virt()
resource: add create_resource() helper function import initial kexec stuff
filetype: add ELF type
bootm: add kexec ELF support
MIPS: add ELF support
MIPS: mach-malta: add kexec-capable reboot()
arch/mips/Kconfig | 1 + arch/mips/include/asm/cache.h | 8 + arch/mips/include/asm/cacheops.h | 27 ++ arch/mips/include/asm/common.h | 2 +- arch/mips/include/asm/elf.h | 8 +- arch/mips/include/asm/io.h | 42 +++ arch/mips/lib/Makefile | 5 + arch/mips/lib/c-r4k.c | 89 ++++++ arch/mips/lib/dma.c | 27 ++ arch/mips/lib/kexec-mips.c | 170 +++++++++++ arch/mips/lib/relocate_kernel.S | 80 +++++ arch/mips/lib/shutdown.c | 12 + arch/mips/mach-malta/Makefile | 1 + arch/mips/mach-malta/reboot.c | 104 +++++++ commands/Kconfig | 7 + common/Kconfig | 3 + common/filetype.c | 5 + common/resource.c | 15 + include/filetype.h | 1 + include/linux/ioport.h | 2 + include/linux/reboot.h | 14 + lib/Makefile | 1 + lib/kexec/Makefile | 4 + lib/kexec/kexec-bootm-elf.c | 36 +++ lib/kexec/kexec-elf-exec.c | 82 +++++ lib/kexec/kexec-elf.c | 639 +++++++++++++++++++++++++++++++++++++++ lib/kexec/kexec-elf.h | 86 ++++++ lib/kexec/kexec.c | 149 +++++++++ lib/kexec/kexec.h | 89 ++++++ 29 files changed, 1707 insertions(+), 2 deletions(-) create mode 100644 arch/mips/include/asm/cache.h create mode 100644 arch/mips/include/asm/cacheops.h create mode 100644 arch/mips/lib/dma.c create mode 100644 arch/mips/lib/kexec-mips.c create mode 100644 arch/mips/lib/relocate_kernel.S create mode 100644 arch/mips/lib/shutdown.c create mode 100644 arch/mips/mach-malta/reboot.c create mode 100644 include/linux/reboot.h create mode 100644 lib/kexec/Makefile create mode 100644 lib/kexec/kexec-bootm-elf.c create mode 100644 lib/kexec/kexec-elf-exec.c create mode 100644 lib/kexec/kexec-elf.c create mode 100644 lib/kexec/kexec-elf.h create mode 100644 lib/kexec/kexec.c create mode 100644 lib/kexec/kexec.h
Signature · 7 lines
1.9.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 1/10 MIPS: add initial cache support for R4000-class CPUs
This commit adds very elementary U-Boot style flush/clean cache generic routines for R4000-class CPUs.
This patch lacks of initial cache initialization code as it's may be CPU-dependent.
Here is Linux-Barebox cache routines correspondance:
Linux Barebox
_dma_cache_wback_inv => dma_flush_range
_dma_cache_wback => dma_clean_range
_dma_cache_inv => dma_inv_range--- arch/mips/include/asm/cache.h | 8 ++++ arch/mips/include/asm/cacheops.h | 27 ++++++++++++ arch/mips/include/asm/io.h | 7 ++++ arch/mips/lib/Makefile | 1 + arch/mips/lib/c-r4k.c | 89 ++++++++++++++++++++++++++++++++++++++++ arch/mips/lib/dma.c | 27 ++++++++++++ 6 files changed, 159 insertions(+) create mode 100644 arch/mips/include/asm/cache.h create mode 100644 arch/mips/include/asm/cacheops.h create mode 100644 arch/mips/lib/dma.c
arch/mips/include/asm/cache.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _ASM_MIPS_CACHE_H +#define _ASM_MIPS_CACHE_H + +void flush_cache_all (void ); +void flush_dcache_all (void ); +void flush_icache_all (void ); + +#endif /* _ASM_MIPS_CACHE_H */
arch/mips/include/asm/cacheops.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Cache operations for the cache instruction. +* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file "COPYING" in the main directory of this archive +* for more details. +* +* (C) Copyright 1996, 97, 99, 2002, 03 Ralf Baechle +* (C) Copyright 1999 Silicon Graphics, Inc. +*/ +#ifndef __ASM_CACHEOPS_H +#define __ASM_CACHEOPS_H + +/* +* Cache Operations available on all MIPS processors with R4000-style caches +*/ +#define Index_Invalidate_I 0x00 +#define Index_Writeback_Inv_D 0x01 +#define Index_Load_Tag_I 0x04 +#define Index_Load_Tag_D 0x05 +#define Index_Store_Tag_I 0x08 +#define Index_Store_Tag_D 0x09 +#define Hit_Invalidate_I 0x10 +#define Hit_Invalidate_D 0x11 +#define Hit_Writeback_Inv_D 0x15 + +#endif /* __ASM_CACHEOPS_H */
arch/mips/include/asm/io.h +7 -0
@@ -14,6 +14,13 @@#include <asm/types.h> #include <asm/byteorder.h> +void *dma_alloc_coherent (size_t size); +void dma_free_coherent (void *mem,size_t size); + +void dma_clean_range (unsigned long ,unsigned long ); +void dma_flush_range (unsigned long ,unsigned long ); +void dma_inv_range (unsigned long ,unsigned long ); +#define IO_SPACE_LIMIT 0/*****************************************************************************/
arch/mips/lib/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-y += ashrdi3.o obj-y += cpu-probe.o obj-y += traps.o obj-y += genex.o +obj-y += dma.o obj-$(CONFIG_CPU_MIPS32) += c-r4k.o obj-$(CONFIG_CPU_MIPS64) += c-r4k.o
arch/mips/lib/c-r4k.c +89 -0
99 lines not on this page · raw message
arch/mips/lib/dma.c new file +27 -0
@@ -0,0 +1,27 @@ +#include <common.h> +#include <asm/io.h> +#include <asm/mipsregs.h> +#include <malloc.h> + +static inline void __iomem *ioremap_nocache (phys_t offset,unsigned long size) +{ +return (void __iomem *) (unsigned long )CKSEG1ADDR (offset); +} + +void *dma_alloc_coherent (size_t size) +{ +void *ret; + + ret =xmemalign (PAGE_SIZE , size); + +dma_inv_range ((unsigned long )ret, (unsigned long )ret + size); + + ret =ioremap_nocache ((phys_t )ret, size); + +return ret; +} + +void dma_free_coherent (void *mem,size_t size) +{ +free (mem); +}
Signature · 7 lines
1.9.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 3/10 MIPS: use arch_shutdown() for flushing caches
In reply to Antony Pavlov--- arch/mips/lib/shutdown.c | 2 ++ 1 file changed, 2 insertions(+)
arch/mips/lib/shutdown.c +2 -0
@@ -3,8 +3,10 @@* memory/cache state. */ #include <common.h> +#include <asm/cache.h> void arch_shutdown (void ) { +flush_cache_all (); }EXPORT_SYMBOL (arch_shutdown);
Signature · 7 lines
1.9.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 2/10 MIPS: introduce arch_shutdown()
In reply to Antony Pavlov--- arch/mips/include/asm/common.h | 2 +- arch/mips/lib/Makefile | 1 + arch/mips/lib/shutdown.c | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 arch/mips/lib/shutdown.c
arch/mips/include/asm/common.h +1 -1
@@ -20,6 +20,6 @@#ifndef _ASM_MIPS_COMMON_H_#define _ASM_MIPS_COMMON_H_ -/* nothing special yet */ +#define ARCH_SHUTDOWN #endif /* _ASM_MIPS_COMMON_H_ */
arch/mips/lib/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-y += cpu-probe.o obj-y += traps.o obj-y += genex.o obj-y += dma.o +obj-y += shutdown.o obj-$(CONFIG_CPU_MIPS32) += c-r4k.o obj-$(CONFIG_CPU_MIPS64) += c-r4k.o
arch/mips/lib/shutdown.c new file +10 -0
@@ -0,0 +1,10 @@ +/** +* This function is called by shutdown_barebox to get a clean +* memory/cache state. +*/ +#include <common.h> + +void arch_shutdown (void ) +{ +} +EXPORT_SYMBOL (arch_shutdown);
Signature · 7 lines
1.9.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 4/10 MIPS: add virt_to_phys() and phys_to_virt()
In reply to Antony Pavlov--- arch/mips/include/asm/io.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
arch/mips/include/asm/io.h +35 -0
@@ -12,6 +12,7 @@#include <linux/compiler.h> #include <asm/types.h> +#include <asm/addrspace.h> #include <asm/byteorder.h> void *dma_alloc_coherent (size_t size);
@@ -21,6 +22,40 @@ void dma_clean_range(unsigned long, unsigned long);void dma_flush_range (unsigned long ,unsigned long );void dma_inv_range (unsigned long ,unsigned long ); +/* +* virt_to_phys - map virtual addresses to physical +* @address: address to remap +* +* The returned physical address is the physical (CPU) mapping for +* the memory address given. It is only valid to use this function on +* addresses directly mapped or allocated via kmalloc. +* +* This function does not give bus mappings for DMA transfers. In +* almost all conceivable cases a device driver should not be using +* this function +*/ +static inline unsigned long virt_to_phys (const void *address) +{ +return (unsigned long )address &0x3fffffff ; +} + +/* +* phys_to_virt - map physical address to virtual +* @address: address to remap +* +* The returned virtual address is a current CPU mapping for +* the memory address given. It is only valid to use this function on +* addresses that have a kernel mapping +* +* This function does not handle bus mappings for DMA transfers. In +* almost all conceivable cases a device driver should not be using +* this function +*/ +static inline void *phys_to_virt (unsigned long address) +{ +return (void *)(KSEG0 | (address &0x3fffffff )); +} +#define IO_SPACE_LIMIT 0/*****************************************************************************/
Signature · 7 lines
1.9.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 6/10 import initial kexec stuff
In reply to Antony Pavlov--- commands/Kconfig | 7 + common/Kconfig | 3 + lib/Makefile | 1 + lib/kexec/Makefile | 3 + lib/kexec/kexec-elf-exec.c | 82 ++++++ lib/kexec/kexec-elf.c | 639 +++++++++++++++++++++++++++++++++++++++++++++ lib/kexec/kexec-elf.h | 86 ++++++ lib/kexec/kexec.c | 149 +++++++++++ lib/kexec/kexec.h | 89 +++++++ 9 files changed, 1059 insertions(+) create mode 100644 lib/kexec/Makefile create mode 100644 lib/kexec/kexec-elf-exec.c create mode 100644 lib/kexec/kexec-elf.c create mode 100644 lib/kexec/kexec-elf.h create mode 100644 lib/kexec/kexec.c create mode 100644 lib/kexec/kexec.h
commands/Kconfig +7 -0
@@ -484,6 +484,13 @@ config CMD_BOOTM_AIMAGE help Support using Android Images. +config KEXEC + bool + prompt "bootm ELF image support" + depends on CMD_BOOTM && HAS_KEXEC + help + Support using ELF Images. + config CMD_UIMAGE select UIMAGE tristate
common/Kconfig +3 -0
@@ -847,3 +847,6 @@ endmenu config HAS_DEBUG_LL bool + +config HAS_KEXEC + bool
lib/Makefile +1 -0
@@ -44,3 +44,4 @@ obj-y += gui/ obj-$(CONFIG_XYMODEM) += xymodem.o obj-y += unlink-recursive.o obj-$(CONFIG_STMP_DEVICE) += stmp-device.o +obj-$(CONFIG_KEXEC) += kexec/
lib/kexec/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-y += kexec.o +obj-y += kexec-elf.o +obj-y += kexec-elf-exec.o
lib/kexec/kexec-elf-exec.c new file +82 -0
82 lines not on this page · raw message
lib/kexec/kexec-elf.c new file +639 -0
639 lines not on this page · raw message
lib/kexec/kexec-elf.h new file +86 -0
86 lines not on this page · raw message
lib/kexec/kexec.c new file +149 -0
149 lines not on this page · raw message
lib/kexec/kexec.h new file +89 -0
89 lines not on this page · raw message
Signature · 7 lines
1.9.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 8/10 bootm: add kexec ELF support
In reply to Antony PavlovAlso introduce reboot() for starting already loaded via kexec ELF segments.
--- include/linux/reboot.h | 14 ++++++++++++++ lib/kexec/Makefile | 1 + lib/kexec/kexec-bootm-elf.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 include/linux/reboot.h create mode 100644 lib/kexec/kexec-bootm-elf.c
include/linux/reboot.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _LINUX_REBOOT_H +#define _LINUX_REBOOT_H + +/* +* Commands accepted by the _reboot() system call. +* +* KEXEC Restart system using a previously loaded Linux kernel +*/ + +#define LINUX_REBOOT_CMD_KEXEC 0x45584543 + +extern int reboot (int cmd); + +#endif /* _LINUX_REBOOT_H */
lib/kexec/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-y += kexec.o obj-y += kexec-elf.o obj-y += kexec-elf-exec.o +obj-y += kexec-bootm-elf.o
lib/kexec/kexec-bootm-elf.c new file +36 -0
@@ -0,0 +1,36 @@ +#include <boot.h> +#include <init.h> +#include <binfmt.h> +#include <errno.h> +#include <linux/reboot.h> + +#include "kexec.h" + +static int do_bootm_elf (struct image_data *data) +{ +kexec_load_file (data->os_file,0 ); +setenv ("global.bootm.image" , data->os_file); +reboot (LINUX_REBOOT_CMD_KEXEC ); + +return -ERESTARTSYS ; +} + +static struct image_handler elf_handler = { + .name ="ELF" , + .bootm = do_bootm_elf, + .filetype = filetype_elf, +}; + +static struct binfmt_hook binfmt_elf_hook = { + .type = filetype_elf, + .exec ="bootm" , +}; + +static int elf_register_image_handler (void ) +{ +register_image_handler (&elf_handler); +binfmt_register (&binfmt_elf_hook); + +return 0 ; +} +late_initcall (elf_register_image_handler);
Signature · 7 lines
1.9.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 9/10 MIPS: add ELF support
In reply to Antony Pavlov--- arch/mips/include/asm/elf.h | 8 +- arch/mips/lib/Makefile | 3 + arch/mips/lib/kexec-mips.c | 170 ++++++++++++++++++++++++++++++++++++++++ arch/mips/lib/relocate_kernel.S | 80 +++++++++++++++++++ 4 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 arch/mips/lib/kexec-mips.c create mode 100644 arch/mips/lib/relocate_kernel.S
arch/mips/include/asm/elf.h +7 -1
@@ -17,12 +17,18 @@#ifndef ELF_ARCH +/* Legal values for e_machine (architecture). */ + +#define EM_MIPS 8/* MIPS R3000 big-endian */ +#define EM_MIPS_RS4_BE 10/* MIPS R4000 big-endian */ +#ifdef CONFIG_32BIT /* * This is used to ensure we don't load something for the wrong architecture. */ -#define elf_check_arch (hdr) \ +#define elf_check_arch (x) ((x)->e_machine == EM_MIPS) +/* * These are used to set parameters in the core dumps. */
arch/mips/lib/Makefile +3 -0
@@ -14,3 +14,6 @@ obj-$(CONFIG_CPU_MIPS64) += c-r4k.o obj-$(CONFIG_CMD_MIPS_CPUINFO) += cpuinfo.o obj-$(CONFIG_CMD_BOOTM) += bootm.o + +obj-$(CONFIG_KEXEC) += kexec-mips.o +obj-$(CONFIG_KEXEC) += relocate_kernel.o
arch/mips/lib/kexec-mips.c new file +170 -0
170 lines not on this page · raw message
arch/mips/lib/relocate_kernel.S new file +80 -0
80 lines not on this page · raw message
Signature · 7 lines
1.9.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 5/10 resource: add create_resource() helper function
In reply to Antony Pavlov--- common/resource.c | 15 +++++++++++++++ include/linux/ioport.h | 2 ++ 2 files changed, 17 insertions(+)
common/resource.c +15 -0
@@ -143,3 +143,18 @@ struct resource *request_ioport_region(const char *name, {return __request_region (&ioport_resource, name, start, end); } + +struct resource *create_resource (const char *name, +resource_size_t start,resource_size_t end) +{ +struct resource *t; + + t =xzalloc (sizeof *t); +INIT_LIST_HEAD (&t->children); + t->parent =NULL ; + t->name =xstrdup (name); + t->start = start; + t->end = end; + +return t; +}
include/linux/ioport.h +2 -0
@@ -145,6 +145,8 @@ struct resource *__request_region(struct resource *parent, resource_size_t size);int release_region (struct resource *res); +struct resource *create_resource (const char *name, +resource_size_t start,resource_size_t end);extern struct resource iomem_resource;extern struct resource ioport_resource;
Signature · 7 lines
1.9.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 7/10 filetype: add ELF type
In reply to Antony Pavlov--- common/filetype.c | 5 +++++ include/filetype.h | 1 + 2 files changed, 6 insertions(+)
common/filetype.c +5 -0
@@ -24,6 +24,7 @@#include <malloc.h> #include <errno.h> #include <envfs.h> +#include <elf.h> struct filetype_str {const char *name;/* human readable filetype */
@@ -53,6 +54,7 @@ static const struct filetype_str filetype_str[] = { [filetype_gpt] = { "GUID Partition Table", "gpt" }, [filetype_bpk] = { "Binary PacKage", "bpk" }, [filetype_barebox_env] = { "barebox environment file", "bbenv" }, + [filetype_elf] = { "ELF", "elf" }, };const char *file_type_to_string (enum filetype f)
@@ -246,6 +248,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)if (bufsize >=1536 && buf16[512 +28 ] ==le16_to_cpu (0xef53 ))return filetype_ext; +if (strncmp (buf8,ELFMAG ,4 ) ==0 ) +return filetype_elf; +return filetype_unknown; }
include/filetype.h +1 -0
@@ -30,6 +30,7 @@ enum filetype { filetype_ubifs, filetype_bpk, filetype_barebox_env, + filetype_elf, filetype_max, };
Signature · 7 lines
1.9.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC 10/10 MIPS: mach-malta: add kexec-capable reboot()
In reply to Antony PavlovThis patch is based on qemu.git/hw/mips/mips_malta.c code.
--- arch/mips/Kconfig | 1 + arch/mips/mach-malta/Makefile | 1 + arch/mips/mach-malta/reboot.c | 104 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 arch/mips/mach-malta/reboot.c
arch/mips/Kconfig +1 -0
@@ -44,6 +44,7 @@ config MACH_MIPS_MALTA select SYS_SUPPORTS_32BIT_KERNEL select SYS_SUPPORTS_BIG_ENDIAN select HAS_DEBUG_LL + select HAS_KEXEC config MACH_MIPS_AR231X bool "Atheros ar231x-based boards"
arch/mips/mach-malta/Makefile +1 -0
@@ -1 +1,2 @@ obj-y += reset.o +obj-y += reboot.o
arch/mips/mach-malta/reboot.c new file +104 -0
104 lines not on this page · raw message
Signature · 7 lines
1.9.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 03/10] MIPS: use arch_shutdown() for flushing caches
In reply to Antony PavlovQuoted 10 lines · Antony Pavlov
Signed-off-by Antony Pavlov <[email protected]>--- arch/mips/lib/shutdown.c | 2 ++ 1 file changed, 2 insertions(+)arch/mips/lib/shutdown.c +0
-0
arch/mips/lib/shutdown.c line 12
Quoted 10 lines
arch/mips/lib/shutdown.c +2
-0@@ -3,8 +3,10 @@* memory/cache state. */ #include <common.h> +#include <asm/cache.h> void arch_shutdown (void ) { +flush_cache_all (); }EXPORT_SYMBOL (arch_shutdown);
You could combine this with 2/10. Otherwise 2/10 leaves the question:
why is this needed?
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 05/10] resource: add create_resource() helper function
In reply to Antony PavlovQuoted 16 lines · Antony Pavlov
Signed-off-by Antony Pavlov <[email protected]>--- common/resource.c | 15 +++++++++++++++ include/linux/ioport.h | 2 ++ 2 files changed, 17 insertions(+)common/resource.c +2
-0@@ -143,3 +143,18 @@ struct resource *request_ioport_region(const char *name, {return __request_region (&ioport_resource, name, start, end); } + +struct resource *create_resource(const char *name,
common/resource.c struct resource *request_ioport_region(const char *name, · line 157
Quoted 10 lines
common/resource.c +10
-0+ resource_size_t start, resource_size_t end) +{ +struct resource *t; + + t =xzalloc (sizeof *t); +INIT_LIST_HEAD (&t->children); + t->parent =NULL ; + t->name =xstrdup (name); + t->start = start; + t->end = end;
How about calling init_resource() and skip the fields already initialized there from this function? This makes sure new fields in struct resource can be initialized in a single place.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [RFC 08/10] bootm: add kexec ELF support
In reply to Antony PavlovQuoted 73 lines · Antony Pavlov
Also introduce
reboot()for starting already loaded via kexec ELF segments.Signed-off-by Antony Pavlov <[email protected]>--- include/linux/reboot.h | 14 ++++++++++++++ lib/kexec/Makefile | 1 + lib/kexec/kexec-bootm-elf.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 include/linux/reboot.h create mode 100644 lib/kexec/kexec-bootm-elf.cinclude/linux/reboot.h new file +14
-0@@ -0,0 +1,14 @@ +#ifndef _LINUX_REBOOT_H +#define _LINUX_REBOOT_H + +/* +* Commands accepted by the _reboot() system call. +* +* KEXEC Restart system using a previously loaded Linux kernel +*/ + +#define LINUX_REBOOT_CMD_KEXEC 0x45584543 + +extern int reboot (int cmd); + +#endif /* _LINUX_REBOOT_H */ lib/kexec/Makefile +1
-0@@ -1,3 +1,4 @@ obj-y += kexec.o obj-y += kexec-elf.o obj-y += kexec-elf-exec.o +obj-y += kexec-bootm-elf.olib/kexec/kexec-bootm-elf.c new file +26
-0@@ -0,0 +1,36 @@ +#include <boot.h> +#include <init.h> +#include <binfmt.h> +#include <errno.h> +#include <linux/reboot.h> + +#include "kexec.h" + +static int do_bootm_elf (struct image_data *data) +{ +kexec_load_file (data->os_file,0 ); +setenv ("global.bootm.image" , data->os_file); +reboot (LINUX_REBOOT_CMD_KEXEC ); + +return -ERESTARTSYS ; +} + +static struct image_handler elf_handler = { + .name ="ELF" , + .bootm = do_bootm_elf, + .filetype = filetype_elf, +}; + +static struct binfmt_hook binfmt_elf_hook = { + .type = filetype_elf, + .exec ="bootm" ,
lib/kexec/kexec-bootm-elf.c line 36
Quoted 10 lines
lib/kexec/kexec-bootm-elf.c new file +10
-0+}; + +static int elf_register_image_handler (void ) +{ +register_image_handler (&elf_handler); +binfmt_register (&binfmt_elf_hook); + +return 0 ; +} +late_initcall (elf_register_image_handler);
Instead of making this an initcall I suggest that you call this function from Malta specific code along with a pointer to a kexec_execute_file function. This makes sure the generic code does not have to call into global architecture specific functions. Also the dataflow can be done clearer. kexec_load_file() currently loads the image *somewhere* and reboot() is expected to know where it is loaded. I imagine kexec_load_file should return information about the loaded image which is then passed to reboot().
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox