* [Qemu-devel] [PATCH 2/5] uImage: implement gzip support
2008-11-20 19:34 ` [Qemu-devel] [PATCH 1/5] uImage: don't leak file data or file descriptor Hollis Blanchard
@ 2008-11-20 19:34 ` Hollis Blanchard
2008-11-20 19:34 ` [Qemu-devel] [PATCH 3/5] uImage: return base load address Hollis Blanchard
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Hollis Blanchard @ 2008-11-20 19:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Hollis Blanchard
Based on gzip uImage loading code from u-boot.
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
---
Changes from v1:
- Include u-boot copyright notice and GPL license.
- Use a fixed size buffer for uncompressed data.
- Invert ih_comp test to properly handle LZMA compressed images.
---
loader.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 136 insertions(+), 4 deletions(-)
diff --git a/loader.c b/loader.c
index e7e6abc..6805692 100644
--- a/loader.c
+++ b/loader.c
@@ -20,12 +20,37 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
+ *
+ * Gunzip functionality in this file is derived from u-boot:
+ *
+ * (C) Copyright 2008 Semihalf
+ *
+ * (C) Copyright 2000-2005
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
*/
+
#include "qemu-common.h"
#include "disas.h"
#include "sysemu.h"
#include "uboot_image.h"
+#include <zlib.h>
+
/* return the size or -1 if error */
int get_image_size(const char *filename)
{
@@ -345,10 +370,94 @@ static void bswap_uboot_header(uboot_image_header_t *hdr)
#endif
}
+
+#define ZALLOC_ALIGNMENT 16
+
+static void *zalloc(void *x, unsigned items, unsigned size)
+{
+ void *p;
+
+ size *= items;
+ size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1);
+
+ p = qemu_malloc(size);
+
+ return (p);
+}
+
+static void zfree(void *x, void *addr, unsigned nb)
+{
+ qemu_free(addr);
+}
+
+
+#define HEAD_CRC 2
+#define EXTRA_FIELD 4
+#define ORIG_NAME 8
+#define COMMENT 0x10
+#define RESERVED 0xe0
+
+#define DEFLATED 8
+
+/* This is the maximum in uboot, so if a uImage overflows this, it would
+ * overflow on real hardware too. */
+#define UBOOT_MAX_GUNZIP_BYTES 0x800000
+
+static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
+ size_t srclen)
+{
+ z_stream s;
+ ssize_t dstbytes;
+ int r, i, flags;
+
+ /* skip header */
+ i = 10;
+ flags = src[3];
+ if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
+ puts ("Error: Bad gzipped data\n");
+ return -1;
+ }
+ if ((flags & EXTRA_FIELD) != 0)
+ i = 12 + src[10] + (src[11] << 8);
+ if ((flags & ORIG_NAME) != 0)
+ while (src[i++] != 0)
+ ;
+ if ((flags & COMMENT) != 0)
+ while (src[i++] != 0)
+ ;
+ if ((flags & HEAD_CRC) != 0)
+ i += 2;
+ if (i >= srclen) {
+ puts ("Error: gunzip out of data in header\n");
+ return -1;
+ }
+
+ s.zalloc = zalloc;
+ s.zfree = (free_func)zfree;
+
+ r = inflateInit2(&s, -MAX_WBITS);
+ if (r != Z_OK) {
+ printf ("Error: inflateInit2() returned %d\n", r);
+ return (-1);
+ }
+ s.next_in = src + i;
+ s.avail_in = srclen - i;
+ s.next_out = dst;
+ s.avail_out = dstlen;
+ r = inflate(&s, Z_FINISH);
+ if (r != Z_OK && r != Z_STREAM_END) {
+ printf ("Error: inflate() returned %d\n", r);
+ return -1;
+ }
+ dstbytes = s.next_out - (unsigned char *) dst;
+ inflateEnd(&s);
+
+ return dstbytes;
+}
+
/* Load a U-Boot image. */
int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
{
-
int fd;
int size;
uboot_image_header_t h;
@@ -375,9 +484,14 @@ int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
goto out;
}
- /* TODO: Implement compressed images. */
- if (hdr->ih_comp != IH_COMP_NONE) {
- fprintf(stderr, "Unable to load compressed u-boot images\n");
+ switch (hdr->ih_comp) {
+ case IH_COMP_NONE:
+ case IH_COMP_GZIP:
+ break;
+ default:
+ fprintf(stderr,
+ "Unable to load u-boot images with compression type %d\n",
+ hdr->ih_comp);
goto out;
}
@@ -399,6 +513,24 @@ int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
goto out;
}
+ if (hdr->ih_comp == IH_COMP_GZIP) {
+ uint8_t *compressed_data;
+ size_t max_bytes;
+ ssize_t bytes;
+
+ compressed_data = data;
+ max_bytes = UBOOT_MAX_GUNZIP_BYTES;
+ data = qemu_malloc(max_bytes);
+
+ bytes = gunzip(data, max_bytes, compressed_data, hdr->ih_size);
+ qemu_free(compressed_data);
+ if (bytes < 0) {
+ fprintf(stderr, "Unable to decompress gzipped image!\n");
+ goto out;
+ }
+ hdr->ih_size = bytes;
+ }
+
cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);
ret = hdr->ih_size;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread* [Qemu-devel] [PATCH 3/5] uImage: return base load address
2008-11-20 19:34 ` [Qemu-devel] [PATCH 1/5] uImage: don't leak file data or file descriptor Hollis Blanchard
2008-11-20 19:34 ` [Qemu-devel] [PATCH 2/5] uImage: implement gzip support Hollis Blanchard
@ 2008-11-20 19:34 ` Hollis Blanchard
2008-11-20 22:05 ` Anthony Liguori
2008-11-20 19:34 ` [Qemu-devel] [PATCH 4/5] uImage: rename load_uboot() to load_uimage() Hollis Blanchard
2008-11-20 19:34 ` [Qemu-devel] [PATCH 5/5] uImage: only try to load 'kernel' images Hollis Blanchard
3 siblings, 1 reply; 10+ messages in thread
From: Hollis Blanchard @ 2008-11-20 19:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Hollis Blanchard
Return the base address at which the image was loaded so that callers may keep
track of currently occupied guest memory.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
---
hw/an5206.c | 2 +-
hw/arm_boot.c | 3 ++-
hw/dummy_m68k.c | 2 +-
hw/mcf5208.c | 2 +-
loader.c | 6 +++++-
sysemu.h | 3 ++-
6 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/hw/an5206.c b/hw/an5206.c
index 9d315f3..bb9cde1 100644
--- a/hw/an5206.c
+++ b/hw/an5206.c
@@ -68,7 +68,7 @@ static void an5206_init(ram_addr_t ram_size, int vga_ram_size,
kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL);
entry = elf_entry;
if (kernel_size < 0) {
- kernel_size = load_uboot(kernel_filename, &entry, NULL);
+ kernel_size = load_uboot(kernel_filename, &entry, NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image(kernel_filename,
diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index 5990961..765075d 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -205,7 +205,8 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
kernel_size = load_elf(info->kernel_filename, 0, &elf_entry, NULL, NULL);
entry = elf_entry;
if (kernel_size < 0) {
- kernel_size = load_uboot(info->kernel_filename, &entry, &is_linux);
+ kernel_size = load_uboot(info->kernel_filename, &entry, NULL,
+ &is_linux);
}
if (kernel_size < 0) {
kernel_size = load_image(info->kernel_filename,
diff --git a/hw/dummy_m68k.c b/hw/dummy_m68k.c
index fc06e9c..5cd5358 100644
--- a/hw/dummy_m68k.c
+++ b/hw/dummy_m68k.c
@@ -44,7 +44,7 @@ static void dummy_m68k_init(ram_addr_t ram_size, int vga_ram_size,
kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL);
entry = elf_entry;
if (kernel_size < 0) {
- kernel_size = load_uboot(kernel_filename, &entry, NULL);
+ kernel_size = load_uboot(kernel_filename, &entry, NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image(kernel_filename,
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index 3e0a811..82db38d 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -290,7 +290,7 @@ static void mcf5208evb_init(ram_addr_t ram_size, int vga_ram_size,
kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL);
entry = elf_entry;
if (kernel_size < 0) {
- kernel_size = load_uboot(kernel_filename, &entry, NULL);
+ kernel_size = load_uboot(kernel_filename, &entry, NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image(kernel_filename, phys_ram_base);
diff --git a/loader.c b/loader.c
index 6805692..575a23a 100644
--- a/loader.c
+++ b/loader.c
@@ -456,7 +456,8 @@ static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
}
/* Load a U-Boot image. */
-int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
+int load_uboot(const char *filename, target_ulong *ep, target_ulong *loadaddr,
+ int *is_linux)
{
int fd;
int size;
@@ -533,6 +534,9 @@ int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);
+ if (loadaddr)
+ *loadaddr = hdr->ih_load;
+
ret = hdr->ih_size;
out:
diff --git a/sysemu.h b/sysemu.h
index ef0fe50..d3d3203 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -165,7 +165,8 @@ int load_image_targphys(const char *filename, target_phys_addr_t, int max_sz);
int load_elf(const char *filename, int64_t address_offset,
uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr);
int load_aout(const char *filename, target_phys_addr_t addr, int max_sz);
-int load_uboot(const char *filename, target_ulong *ep, int *is_linux);
+int load_uboot(const char *filename, target_ulong *ep, target_ulong *loadaddr,
+ int *is_linux);
int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f);
int fread_targphys_ok(target_phys_addr_t dst_addr, size_t nbytes, FILE *f);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [Qemu-devel] [PATCH 3/5] uImage: return base load address
2008-11-20 19:34 ` [Qemu-devel] [PATCH 3/5] uImage: return base load address Hollis Blanchard
@ 2008-11-20 22:05 ` Anthony Liguori
2008-11-20 22:13 ` Hollis Blanchard
0 siblings, 1 reply; 10+ messages in thread
From: Anthony Liguori @ 2008-11-20 22:05 UTC (permalink / raw)
To: qemu-devel; +Cc: Hollis Blanchard
Hollis Blanchard wrote:
> Return the base address at which the image was loaded so that callers may keep
> track of currently occupied guest memory.
>
Why is it that you need this information if no other callers have needed
it before?
I'm not suggesting this patch isn't correct, it's just not obvious from
the description why this is now needed.
Regards,
Anthony Liguori
> Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
> ---
> hw/an5206.c | 2 +-
> hw/arm_boot.c | 3 ++-
> hw/dummy_m68k.c | 2 +-
> hw/mcf5208.c | 2 +-
> loader.c | 6 +++++-
> sysemu.h | 3 ++-
> 6 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/hw/an5206.c b/hw/an5206.c
> index 9d315f3..bb9cde1 100644
> --- a/hw/an5206.c
> +++ b/hw/an5206.c
> @@ -68,7 +68,7 @@ static void an5206_init(ram_addr_t ram_size, int vga_ram_size,
> kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL);
> entry = elf_entry;
> if (kernel_size < 0) {
> - kernel_size = load_uboot(kernel_filename, &entry, NULL);
> + kernel_size = load_uboot(kernel_filename, &entry, NULL, NULL);
> }
> if (kernel_size < 0) {
> kernel_size = load_image(kernel_filename,
> diff --git a/hw/arm_boot.c b/hw/arm_boot.c
> index 5990961..765075d 100644
> --- a/hw/arm_boot.c
> +++ b/hw/arm_boot.c
> @@ -205,7 +205,8 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
> kernel_size = load_elf(info->kernel_filename, 0, &elf_entry, NULL, NULL);
> entry = elf_entry;
> if (kernel_size < 0) {
> - kernel_size = load_uboot(info->kernel_filename, &entry, &is_linux);
> + kernel_size = load_uboot(info->kernel_filename, &entry, NULL,
> + &is_linux);
> }
> if (kernel_size < 0) {
> kernel_size = load_image(info->kernel_filename,
> diff --git a/hw/dummy_m68k.c b/hw/dummy_m68k.c
> index fc06e9c..5cd5358 100644
> --- a/hw/dummy_m68k.c
> +++ b/hw/dummy_m68k.c
> @@ -44,7 +44,7 @@ static void dummy_m68k_init(ram_addr_t ram_size, int vga_ram_size,
> kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL);
> entry = elf_entry;
> if (kernel_size < 0) {
> - kernel_size = load_uboot(kernel_filename, &entry, NULL);
> + kernel_size = load_uboot(kernel_filename, &entry, NULL, NULL);
> }
> if (kernel_size < 0) {
> kernel_size = load_image(kernel_filename,
> diff --git a/hw/mcf5208.c b/hw/mcf5208.c
> index 3e0a811..82db38d 100644
> --- a/hw/mcf5208.c
> +++ b/hw/mcf5208.c
> @@ -290,7 +290,7 @@ static void mcf5208evb_init(ram_addr_t ram_size, int vga_ram_size,
> kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL);
> entry = elf_entry;
> if (kernel_size < 0) {
> - kernel_size = load_uboot(kernel_filename, &entry, NULL);
> + kernel_size = load_uboot(kernel_filename, &entry, NULL, NULL);
> }
> if (kernel_size < 0) {
> kernel_size = load_image(kernel_filename, phys_ram_base);
> diff --git a/loader.c b/loader.c
> index 6805692..575a23a 100644
> --- a/loader.c
> +++ b/loader.c
> @@ -456,7 +456,8 @@ static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
> }
>
> /* Load a U-Boot image. */
> -int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
> +int load_uboot(const char *filename, target_ulong *ep, target_ulong *loadaddr,
> + int *is_linux)
> {
> int fd;
> int size;
> @@ -533,6 +534,9 @@ int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
>
> cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);
>
> + if (loadaddr)
> + *loadaddr = hdr->ih_load;
> +
> ret = hdr->ih_size;
>
> out:
> diff --git a/sysemu.h b/sysemu.h
> index ef0fe50..d3d3203 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -165,7 +165,8 @@ int load_image_targphys(const char *filename, target_phys_addr_t, int max_sz);
> int load_elf(const char *filename, int64_t address_offset,
> uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr);
> int load_aout(const char *filename, target_phys_addr_t addr, int max_sz);
> -int load_uboot(const char *filename, target_ulong *ep, int *is_linux);
> +int load_uboot(const char *filename, target_ulong *ep, target_ulong *loadaddr,
> + int *is_linux);
>
> int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f);
> int fread_targphys_ok(target_phys_addr_t dst_addr, size_t nbytes, FILE *f);
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [Qemu-devel] [PATCH 3/5] uImage: return base load address
2008-11-20 22:05 ` Anthony Liguori
@ 2008-11-20 22:13 ` Hollis Blanchard
0 siblings, 0 replies; 10+ messages in thread
From: Hollis Blanchard @ 2008-11-20 22:13 UTC (permalink / raw)
To: qemu-devel
On Thu, 2008-11-20 at 16:05 -0600, Anthony Liguori wrote:
> Hollis Blanchard wrote:
> > Return the base address at which the image was loaded so that
> callers may keep
> > track of currently occupied guest memory.
> >
>
> Why is it that you need this information if no other callers have needed
> it before?
As far as I can see, other users are making assumptions about maximum
kernel size and simply hardcoding some addresses.
For example arm_load_kernel() seems to always load the initrd at 8MB,
regardless of where the ELF or uImage kernel was loaded. (In the case of
a "flat" kernel, that's loaded at 0x1000, and probably isn't bigger than
8MB...)
--
Hollis Blanchard
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 4/5] uImage: rename load_uboot() to load_uimage()
2008-11-20 19:34 ` [Qemu-devel] [PATCH 1/5] uImage: don't leak file data or file descriptor Hollis Blanchard
2008-11-20 19:34 ` [Qemu-devel] [PATCH 2/5] uImage: implement gzip support Hollis Blanchard
2008-11-20 19:34 ` [Qemu-devel] [PATCH 3/5] uImage: return base load address Hollis Blanchard
@ 2008-11-20 19:34 ` Hollis Blanchard
2008-11-20 19:34 ` [Qemu-devel] [PATCH 5/5] uImage: only try to load 'kernel' images Hollis Blanchard
3 siblings, 0 replies; 10+ messages in thread
From: Hollis Blanchard @ 2008-11-20 19:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Hollis Blanchard
u-boot is a firmware. uImage is an executable file format.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
---
hw/an5206.c | 2 +-
hw/arm_boot.c | 4 ++--
hw/dummy_m68k.c | 2 +-
hw/mcf5208.c | 2 +-
loader.c | 4 ++--
patches | 1 +
sysemu.h | 4 ++--
7 files changed, 10 insertions(+), 9 deletions(-)
create mode 120000 patches
diff --git a/hw/an5206.c b/hw/an5206.c
index bb9cde1..98f35e3 100644
--- a/hw/an5206.c
+++ b/hw/an5206.c
@@ -68,7 +68,7 @@ static void an5206_init(ram_addr_t ram_size, int vga_ram_size,
kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL);
entry = elf_entry;
if (kernel_size < 0) {
- kernel_size = load_uboot(kernel_filename, &entry, NULL, NULL);
+ kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image(kernel_filename,
diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index 765075d..cf9616a 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -205,8 +205,8 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
kernel_size = load_elf(info->kernel_filename, 0, &elf_entry, NULL, NULL);
entry = elf_entry;
if (kernel_size < 0) {
- kernel_size = load_uboot(info->kernel_filename, &entry, NULL,
- &is_linux);
+ kernel_size = load_uimage(info->kernel_filename, &entry, NULL,
+ &is_linux);
}
if (kernel_size < 0) {
kernel_size = load_image(info->kernel_filename,
diff --git a/hw/dummy_m68k.c b/hw/dummy_m68k.c
index 5cd5358..7931b6d 100644
--- a/hw/dummy_m68k.c
+++ b/hw/dummy_m68k.c
@@ -44,7 +44,7 @@ static void dummy_m68k_init(ram_addr_t ram_size, int vga_ram_size,
kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL);
entry = elf_entry;
if (kernel_size < 0) {
- kernel_size = load_uboot(kernel_filename, &entry, NULL, NULL);
+ kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image(kernel_filename,
diff --git a/hw/mcf5208.c b/hw/mcf5208.c
index 82db38d..f9ae588 100644
--- a/hw/mcf5208.c
+++ b/hw/mcf5208.c
@@ -290,7 +290,7 @@ static void mcf5208evb_init(ram_addr_t ram_size, int vga_ram_size,
kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL);
entry = elf_entry;
if (kernel_size < 0) {
- kernel_size = load_uboot(kernel_filename, &entry, NULL, NULL);
+ kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL);
}
if (kernel_size < 0) {
kernel_size = load_image(kernel_filename, phys_ram_base);
diff --git a/loader.c b/loader.c
index 575a23a..f9f37b2 100644
--- a/loader.c
+++ b/loader.c
@@ -456,8 +456,8 @@ static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
}
/* Load a U-Boot image. */
-int load_uboot(const char *filename, target_ulong *ep, target_ulong *loadaddr,
- int *is_linux)
+int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr,
+ int *is_linux)
{
int fd;
int size;
diff --git a/patches b/patches
new file mode 120000
index 0000000..848fc19
--- /dev/null
+++ b/patches
@@ -0,0 +1 @@
+.git/patches/master
\ No newline at end of file
diff --git a/sysemu.h b/sysemu.h
index d3d3203..f72ec96 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -165,8 +165,8 @@ int load_image_targphys(const char *filename, target_phys_addr_t, int max_sz);
int load_elf(const char *filename, int64_t address_offset,
uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr);
int load_aout(const char *filename, target_phys_addr_t addr, int max_sz);
-int load_uboot(const char *filename, target_ulong *ep, target_ulong *loadaddr,
- int *is_linux);
+int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr,
+ int *is_linux);
int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f);
int fread_targphys_ok(target_phys_addr_t dst_addr, size_t nbytes, FILE *f);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread* [Qemu-devel] [PATCH 5/5] uImage: only try to load 'kernel' images
2008-11-20 19:34 ` [Qemu-devel] [PATCH 1/5] uImage: don't leak file data or file descriptor Hollis Blanchard
` (2 preceding siblings ...)
2008-11-20 19:34 ` [Qemu-devel] [PATCH 4/5] uImage: rename load_uboot() to load_uimage() Hollis Blanchard
@ 2008-11-20 19:34 ` Hollis Blanchard
3 siblings, 0 replies; 10+ messages in thread
From: Hollis Blanchard @ 2008-11-20 19:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Hollis Blanchard
Loading other image types (e.g. IH_TYPE_MULTI, IH_TYPE_FLATDT) is not
implemented.
IH_TYPE_STANDALONE images could be loaded, but would unexpectedly fail if they
tried to use any uboot services.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
---
loader.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/loader.c b/loader.c
index f9f37b2..cca9d3b 100644
--- a/loader.c
+++ b/loader.c
@@ -479,9 +479,9 @@ int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr,
if (hdr->ih_magic != IH_MAGIC)
goto out;
- /* TODO: Implement Multi-File images. */
- if (hdr->ih_type == IH_TYPE_MULTI) {
- fprintf(stderr, "Unable to load multi-file u-boot images\n");
+ /* TODO: Implement other image types. */
+ if (hdr->ih_type != IH_TYPE_KERNEL) {
+ fprintf(stderr, "Can only load u-boot image type \"kernel\"\n");
goto out;
}
@@ -498,7 +498,7 @@ int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr,
/* TODO: Check CPU type. */
if (is_linux) {
- if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX)
+ if (hdr->ih_os == IH_OS_LINUX)
*is_linux = 1;
else
*is_linux = 0;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread