summaryrefslogtreecommitdiffstats
path: root/arch/arm/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-08-04 14:25:18 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2009-08-13 10:43:20 +0200
commit224d499e7ee090ab0a3803970e3c27c05ec6f544 (patch)
treee3eb37854eaa011ce837e324a061b94f36987d6c /arch/arm/lib
parent0bf2410e8559fa64489876c67dbba32ccf16e415 (diff)
downloadbarebox-224d499e7ee090ab0a3803970e3c27c05ec6f544.tar.gz
barebox-224d499e7ee090ab0a3803970e3c27c05ec6f544.tar.xz
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 <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/lib')
-rw-r--r--arch/arm/lib/armlinux.c46
1 files changed, 41 insertions, 5 deletions
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 <fs.h>
#include <list.h>
#include <xfuncs.h>
+#include <malloc.h>
+#include <fcntl.h>
#include <asm/byteorder.h>
#include <asm/global_data.h>
@@ -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(&params);
@@ -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[] =