[PATCH 01/12] ARM zImage: do memmap if possible

Peter Korsgaard jacmet at sunsite.dk
Mon Mar 29 14:47:57 EDT 2010


>>>>> "Sascha" == Sascha Hauer <s.hauer at pengutronix.de> writes:

Hi,

 Sascha>  	zimage = xmalloc(header.end);
 Sascha>  	memcpy(zimage, &header, sizeof(header));
 Sascha> -
 Sascha> -	ret = read(fd, zimage + sizeof(header), header.end - sizeof(header));
 Sascha> -	if (ret < header.end - sizeof(header)) {
 Sascha> -		printf("could not read %s\n", argv[1]);
 Sascha> -		goto err_out1;
 Sascha> +	m = memmap(fd, PROT_READ);
 Sascha> +	if (m != (void *)-1) {
 Sascha> +		memcpy(zimage, m, header.end);

Here you're rereading the header as well, instead of everything past it
like the normal case.

Does this give a significant boost? read() from something memmap'able
(like NOR) boils down to a memcpy as well, right?

 Sascha> +	} else {
 Sascha> +		ret = read(fd, zimage + sizeof(header), header.end - sizeof(header));

-- 
Bye, Peter Korsgaard



More information about the barebox mailing list