From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XH3bn-0006h5-Md for qemu-devel@nongnu.org; Tue, 12 Aug 2014 00:22:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XH3bh-0001A6-JP for qemu-devel@nongnu.org; Tue, 12 Aug 2014 00:22:51 -0400 From: Max Filippov Date: Tue, 12 Aug 2014 08:22:21 +0400 Message-Id: <1407817342-1373-3-git-send-email-jcmvbkbc@gmail.com> In-Reply-To: <1407817342-1373-1-git-send-email-jcmvbkbc@gmail.com> References: <1407817342-1373-1-git-send-email-jcmvbkbc@gmail.com> Subject: [Qemu-devel] [PATCH 2/3] hw/core/loader: implement load_uimage_at List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Max Filippov , Waldemar Brodkorb , qemu-stable@nongnu.org load_uimage_at loads kernel image at the specified address instead of the address recorded in the uImage header. Cc: qemu-stable@nongnu.org Signed-off-by: Max Filippov --- hw/core/loader.c | 25 +++++++++++++++++++------ include/hw/loader.h | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/hw/core/loader.c b/hw/core/loader.c index 5bf7f9b..beb7c2b 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -470,7 +470,7 @@ static int load_uboot_image_header_fd(int fd, uboot_image_header_t *hdr) /* Load a U-Boot image. */ static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr, - int *is_linux, uint8_t image_type) + bool force_addr, int *is_linux, uint8_t image_type) { int fd; hwaddr address; @@ -497,9 +497,13 @@ static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr, /* TODO: Implement other image types. */ switch (hdr->ih_type) { case IH_TYPE_KERNEL: - address = hdr->ih_load; - if (loadaddr) { - *loadaddr = hdr->ih_load; + if (force_addr) { + address = *loadaddr; + } else { + address = hdr->ih_load; + if (loadaddr) { + *loadaddr = hdr->ih_load; + } } switch (hdr->ih_comp) { @@ -589,13 +593,22 @@ int load_uboot_image_header(const char *filename, uboot_image_header_t *hdr) int load_uimage(const char *filename, hwaddr *ep, hwaddr *loadaddr, int *is_linux) { - return load_uboot_image(filename, ep, loadaddr, is_linux, IH_TYPE_KERNEL); + return load_uboot_image(filename, ep, loadaddr, false, is_linux, + IH_TYPE_KERNEL); +} + +int load_uimage_at(const char *filename, hwaddr *ep, hwaddr loadaddr, + int *is_linux) +{ + return load_uboot_image(filename, ep, &loadaddr, true, is_linux, + IH_TYPE_KERNEL); } /* Load a ramdisk. */ int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz) { - return load_uboot_image(filename, NULL, &addr, NULL, IH_TYPE_RAMDISK); + return load_uboot_image(filename, NULL, &addr, false, NULL, + IH_TYPE_RAMDISK); } /* diff --git a/include/hw/loader.h b/include/hw/loader.h index a8cd0cf..76f068d 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -31,6 +31,8 @@ int load_aout(const char *filename, hwaddr addr, int max_sz, int load_uboot_image_header(const char *filename, uboot_image_header_t *hdr); int load_uimage(const char *filename, hwaddr *ep, hwaddr *loadaddr, int *is_linux); +int load_uimage_at(const char *filename, hwaddr *ep, + hwaddr loadaddr, int *is_linux); /** * load_ramdisk: -- 1.8.1.4