From 224d499e7ee090ab0a3803970e3c27c05ec6f544 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 4 Aug 2009 14:25:18 +0200 Subject: bootz: Speed up bootz command We used to read the whole file with zImage booting. When the file is really a device which is much bigger than the zImage it's quite slow. Read the image size from the image instead. Signed-off-by: Sascha Hauer --- arch/arm/lib/armlinux.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'arch/arm/lib/armlinux.c') diff --git a/arch/arm/lib/armlinux.c b/arch/arm/lib/armlinux.c index 6dc54905b5..ff2b8820af 100644 --- a/arch/arm/lib/armlinux.c +++ b/arch/arm/lib/armlinux.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include #include @@ -347,24 +349,51 @@ __setup_end_tag (void) params->hdr.size = 0; } +struct zimage_header { + u32 unsused[9]; + u32 magic; + u32 start; + u32 end; +}; + static int do_bootz(cmd_tbl_t *cmdtp, int argc, char *argv[]) { void (*theKernel)(int zero, int arch, void *params); const char *commandline = getenv("bootargs"); - size_t size; + int fd, ret; + struct zimage_header header; + void *zimage; if (argc != 2) { u_boot_cmd_usage(cmdtp); return 1; } - theKernel = read_file(argv[1], &size); - if (!theKernel) { + fd = open(argv[1], O_RDONLY); + + ret = read(fd, &header, sizeof(header)); + if (ret < sizeof(header)) { printf("could not read %s\n", argv[1]); - return 1; + goto err_out; } - printf("loaded zImage from %s with size %d\n", argv[1], size); + if (header.magic != 0x016f2818) { + printf("invalid magic 0x%08x\n", header.magic); + goto err_out; + } + + zimage = xmalloc(header.end); + memcpy(zimage, &header, sizeof(header)); + + ret = read(fd, zimage + sizeof(header), header.end - sizeof(header)); + if (ret < header.end - sizeof(header)) { + printf("could not read %s\n", argv[1]); + goto err_out1; + } + + theKernel = zimage; + + printf("loaded zImage from %s with size %d\n", argv[1], header.end); setup_start_tag(); setup_serial_tag(¶ms); @@ -382,6 +411,13 @@ static int do_bootz(cmd_tbl_t *cmdtp, int argc, char *argv[]) theKernel (0, armlinux_architecture, armlinux_bootparams); return 0; + +err_out1: + free(zimage); +err_out: + close(fd); + + return 1; } static const __maybe_unused char cmd_ls_help[] = -- cgit v1.2.3