From: Daniel Lezcano <daniel.lezcano@free.fr>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [rfc 3/3] arm : make initrd load address dynamic
Date: Mon, 6 Sep 2010 16:12:53 +0200 [thread overview]
Message-ID: <1283782373-4797-4-git-send-email-daniel.lezcano@free.fr> (raw)
In-Reply-To: <1283782373-4797-1-git-send-email-daniel.lezcano@free.fr>
Instead of hardcoding a default value for initrd, let's compute
dynamically from the kernel load address and its size.
We go one page after the end of the kernel.
Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
---
hw/arm-misc.h | 1 +
hw/arm_boot.c | 19 ++++++++-----------
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/hw/arm-misc.h b/hw/arm-misc.h
index 010acb4..e72f87e 100644
--- a/hw/arm-misc.h
+++ b/hw/arm-misc.h
@@ -34,6 +34,7 @@ struct arm_boot_info {
int (*atag_board)(struct arm_boot_info *info, void *p);
/* Used internally by arm_boot.c */
int is_linux;
+ target_phys_addr_t initrd_load_addr;
target_phys_addr_t initrd_size;
target_phys_addr_t entry;
};
diff --git a/hw/arm_boot.c b/hw/arm_boot.c
index 16a33af..638ef62 100644
--- a/hw/arm_boot.c
+++ b/hw/arm_boot.c
@@ -15,7 +15,6 @@
#define KERNEL_ARGS_ADDR 0x100
#define KERNEL_LOAD_ADDR 0x00010000
-#define INITRD_LOAD_ADDR 0x00800000
/* The worlds second smallest bootloader. Set r0-r2, then jump to kernel. */
static uint32_t bootloader[] = {
@@ -71,7 +70,7 @@ static void set_kernel_args(struct arm_boot_info *info)
/* ATAG_INITRD2 */
WRITE_WORD(p, 4);
WRITE_WORD(p, 0x54420005);
- WRITE_WORD(p, info->loader_start + INITRD_LOAD_ADDR);
+ WRITE_WORD(p, info->loader_start + info->initrd_load_addr);
WRITE_WORD(p, initrd_size);
}
if (info->kernel_cmdline && *info->kernel_cmdline) {
@@ -147,7 +146,7 @@ static void set_kernel_args_old(struct arm_boot_info *info)
WRITE_WORD(p, 0);
/* initrd_start */
if (initrd_size)
- WRITE_WORD(p, info->loader_start + INITRD_LOAD_ADDR);
+ WRITE_WORD(p, info->loader_start + info->initrd_load_addr);
else
WRITE_WORD(p, 0);
/* initrd_size */
@@ -201,6 +200,7 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
int is_linux = 0;
uint64_t elf_entry;
target_phys_addr_t entry;
+ target_phys_addr_t initrd_load_addr = 0x0;
int big_endian;
/* Load the kernel. */
@@ -242,16 +242,13 @@ void arm_load_kernel(CPUState *env, struct arm_boot_info *info)
if (is_linux) {
if (info->initrd_filename) {
- if (KERNEL_LOAD_ADDR + kernel_size >= INITRD_LOAD_ADDR) {
- fprintf(stderr, "qemu: kernel is too big: %d Bytes\n",
- kernel_size);
- exit(1);
- }
-
+ initrd_load_addr = KERNEL_LOAD_ADDR + kernel_size +
+ TARGET_PAGE_SIZE;
+ initrd_load_addr = TARGET_PAGE_ALIGN(initrd_load_addr);
initrd_size = load_image_targphys(info->initrd_filename,
info->loader_start
- + INITRD_LOAD_ADDR,
- ram_size - INITRD_LOAD_ADDR);
+ + initrd_load_addr,
+ ram_size - initrd_load_addr);
if (initrd_size < 0) {
fprintf(stderr, "qemu: could not load initrd '%s'\n",
info->initrd_filename);
--
1.7.0.4
next prev parent reply other threads:[~2010-09-06 14:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-06 14:12 [Qemu-devel] [rfc 0/3] arm : dynamically choose initrd load address Daniel Lezcano
2010-09-06 14:12 ` [Qemu-devel] [rfc 1/3] arm : raise an error if the kernel size will overlap the initrd Daniel Lezcano
2010-09-06 14:12 ` [Qemu-devel] [rfc 2/3] arm : factor out set_kernel_args[_old] Daniel Lezcano
2010-09-06 14:12 ` Daniel Lezcano [this message]
2010-09-08 11:47 ` [Qemu-devel] [rfc 0/3] arm : dynamically choose initrd load address Daniel Lezcano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1283782373-4797-4-git-send-email-daniel.lezcano@free.fr \
--to=daniel.lezcano@free.fr \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).