[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 2/3] hw/core/loader: implement load_uimage_at
From: |
Max Filippov |
Subject: |
[Qemu-stable] [PATCH 2/3] hw/core/loader: implement load_uimage_at |
Date: |
Tue, 12 Aug 2014 08:22:21 +0400 |
load_uimage_at loads kernel image at the specified address instead of
the address recorded in the uImage header.
Cc: address@hidden
Signed-off-by: Max Filippov <address@hidden>
---
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
- [Qemu-stable] [PATCH 2/3] hw/core/loader: implement load_uimage_at,
Max Filippov <=