[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] fread_targphys(): Do not cut off the tail.
From: |
takasi-y |
Subject: |
[Qemu-devel] [PATCH] fread_targphys(): Do not cut off the tail. |
Date: |
Sun, 8 Mar 2009 02:23:17 +0900 (JST) |
loader.c:fread_targphys() read file by 4096 byte chunks and store them to
memory. But did not store the last chunk if its size was not 4096.
Signed-off-by: Takashi YOSHII <address@hidden>
---
On Tue, 3 Mar 2009 07:20:29 +0100
Aurelien Jarno <address@hidden> wrote:
> > + kernel_size = load_image(kernel_filename, phys_ram_base +
> > 0x80000);
> > + env->pc = (SDRAM_BASE + 0x80000) | 0xa0000000;
> > + pstrcpy(phys_ram_base + 0x10100, 256, kernel_cmdline);
>
> You should use pstrcpy_targphys() instead and remove phys_ram_base.
I think load_image also should be load_image_targphys.
But the program did not work. The result was the issue fixed by this patch.
No error/eof handling is here. Even without it, this function behave like
fread() about terminate condition.
/yoshii
---
loader.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/loader.c b/loader.c
index 71b9ba7..55625cf 100644
--- a/loader.c
+++ b/loader.c
@@ -90,11 +90,12 @@ int fread_targphys(target_phys_addr_t dst_addr, size_t
nbytes, FILE *f)
while (nbytes) {
want = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;
did = fread(buf, 1, want, f);
- if (did != want) break;
cpu_physical_memory_write_rom(dst_addr, buf, did);
dst_addr += did;
nbytes -= did;
+ if (did != want)
+ break;
}
return dst_addr - dst_begin;
}
--
1.5.6.3