Message ID | 1407817342-1373-3-git-send-email-jcmvbkbc@gmail.com |
---|---|
State | New |
Headers | show |
On 12.08.14 06:22, Max Filippov wrote: > 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 <jcmvbkbc@gmail.com> Please check out load_elf() and friends. The way we usually handle these things is by providing a special translate_fn function callback that adds the offset. Alex
Hi Alex, On Thu, Aug 21, 2014 at 1:16 PM, Alexander Graf <agraf@suse.de> wrote: > On 12.08.14 06:22, Max Filippov wrote: >> 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 <jcmvbkbc@gmail.com> > > Please check out load_elf() and friends. The way we usually handle these > things is by providing a special translate_fn function callback that > adds the offset. Thanks for your comment. Nobody seems to need this functionality except xtensa, so I tried to solve it the least intrusive way. But sure, I can add generic translation support to uimage loader.
> Am 21.08.2014 um 22:56 schrieb Max Filippov <jcmvbkbc@gmail.com>: > > Hi Alex, > >> On Thu, Aug 21, 2014 at 1:16 PM, Alexander Graf <agraf@suse.de> wrote: >>> On 12.08.14 06:22, Max Filippov wrote: >>> 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 <jcmvbkbc@gmail.com> >> >> Please check out load_elf() and friends. The way we usually handle these >> things is by providing a special translate_fn function callback that >> adds the offset. > > Thanks for your comment. Nobody seems to need this functionality except > xtensa, so I tried to solve it the least intrusive way. But sure, I can add > generic translation support to uimage loader. I think I personally would prefer to have the interfaces be as consistent as possible, yeah :). Alex > > -- > Thanks. > -- Max
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:
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 <jcmvbkbc@gmail.com> --- hw/core/loader.c | 25 +++++++++++++++++++------ include/hw/loader.h | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-)