* [Qemu-devel] [PATCH 1/2] powerpc/booke: move fdt loading to rom infrastructure
@ 2010-02-02 8:49 Liu Yu
2010-02-02 8:49 ` [Qemu-devel] [PATCH 2/2] powerpc/e500: adjust fdt and ramdisk loading addr Liu Yu
2010-02-27 15:33 ` [Qemu-devel] [PATCH 1/2] powerpc/booke: move fdt loading to rom infrastructure Aurelien Jarno
0 siblings, 2 replies; 4+ messages in thread
From: Liu Yu @ 2010-02-02 8:49 UTC (permalink / raw)
To: hollis; +Cc: Liu Yu, qemu-devel
It's convinent to use rom to checking overlap, to reset etc.
And uImage and ramdisk loading has already moved to it.
Also, after we add fdt to rom, free it.
Signed-off-by: Liu Yu <yu.liu@freescale.com>
---
hw/ppc440_bamboo.c | 15 ++++++++-------
hw/ppce500_mpc8544ds.c | 17 ++++++++++-------
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index 1ab9872..9d95417 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -27,7 +27,7 @@
#define BINARY_DEVICE_TREE_FILE "bamboo.dtb"
-static void *bamboo_load_device_tree(target_phys_addr_t addr,
+static int bamboo_load_device_tree(target_phys_addr_t addr,
uint32_t ramsize,
target_phys_addr_t initrd_base,
target_phys_addr_t initrd_size,
@@ -42,11 +42,13 @@ static void *bamboo_load_device_tree(target_phys_addr_t addr,
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (!filename) {
+ ret = -1;
goto out;
}
fdt = load_device_tree(filename, &fdt_size);
qemu_free(filename);
if (fdt == NULL) {
+ ret = -1;
goto out;
}
@@ -75,12 +77,13 @@ static void *bamboo_load_device_tree(target_phys_addr_t addr,
if (kvm_enabled())
kvmppc_fdt_update(fdt);
- cpu_physical_memory_write (addr, (void *)fdt, fdt_size);
+ ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
+ qemu_free(fdt);
out:
#endif
- return fdt;
+ return ret;
}
static void bamboo_init(ram_addr_t ram_size,
@@ -101,7 +104,6 @@ static void bamboo_init(ram_addr_t ram_size,
target_ulong initrd_base = 0;
target_long initrd_size = 0;
target_ulong dt_base = 0;
- void *fdt;
int i;
/* Setup CPU. */
@@ -153,9 +155,8 @@ static void bamboo_init(ram_addr_t ram_size,
else
dt_base = kernel_size + loadaddr;
- fdt = bamboo_load_device_tree(dt_base, ram_size,
- initrd_base, initrd_size, kernel_cmdline);
- if (fdt == NULL) {
+ if (bamboo_load_device_tree(dt_base, ram_size,
+ initrd_base, initrd_size, kernel_cmdline) < 0) {
fprintf(stderr, "couldn't load device tree\n");
exit(1);
}
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index ea30816..9a5654b 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -72,7 +72,7 @@ out:
}
#endif
-static void *mpc8544_load_device_tree(target_phys_addr_t addr,
+static int mpc8544_load_device_tree(target_phys_addr_t addr,
uint32_t ramsize,
target_phys_addr_t initrd_base,
target_phys_addr_t initrd_size,
@@ -87,11 +87,13 @@ static void *mpc8544_load_device_tree(target_phys_addr_t addr,
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
if (!filename) {
+ ret = -1;
goto out;
}
fdt = load_device_tree(filename, &fdt_size);
qemu_free(filename);
if (fdt == NULL) {
+ ret = -1;
goto out;
}
@@ -123,6 +125,7 @@ static void *mpc8544_load_device_tree(target_phys_addr_t addr,
if ((dp = opendir("/proc/device-tree/cpus/")) == NULL) {
printf("Can't open directory /proc/device-tree/cpus/\n");
+ ret = -1;
goto out;
}
@@ -136,6 +139,7 @@ static void *mpc8544_load_device_tree(target_phys_addr_t addr,
closedir(dp);
if (buf[0] == '\0') {
printf("Unknow host!\n");
+ ret = -1;
goto out;
}
@@ -143,12 +147,13 @@ static void *mpc8544_load_device_tree(target_phys_addr_t addr,
mpc8544_copy_soc_cell(fdt, buf, "timebase-frequency");
}
- cpu_physical_memory_write (addr, (void *)fdt, fdt_size);
+ ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
+ qemu_free(fdt);
out:
#endif
- return fdt;
+ return ret;
}
static void mpc8544ds_init(ram_addr_t ram_size,
@@ -168,7 +173,6 @@ static void mpc8544ds_init(ram_addr_t ram_size,
target_ulong dt_base=DTB_LOAD_BASE;
target_ulong initrd_base=INITRD_LOAD_BASE;
target_long initrd_size=0;
- void *fdt;
int i=0;
unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
qemu_irq *irqs, *mpic, *pci_irqs;
@@ -254,9 +258,8 @@ static void mpc8544ds_init(ram_addr_t ram_size,
/* If we're loading a kernel directly, we must load the device tree too. */
if (kernel_filename) {
- fdt = mpc8544_load_device_tree(dt_base, ram_size,
- initrd_base, initrd_size, kernel_cmdline);
- if (fdt == NULL) {
+ if (mpc8544_load_device_tree(dt_base, ram_size,
+ initrd_base, initrd_size, kernel_cmdline) < 0) {
fprintf(stderr, "couldn't load device tree\n");
exit(1);
}
--
1.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/2] powerpc/e500: adjust fdt and ramdisk loading addr
2010-02-02 8:49 [Qemu-devel] [PATCH 1/2] powerpc/booke: move fdt loading to rom infrastructure Liu Yu
@ 2010-02-02 8:49 ` Liu Yu
2010-02-27 15:33 ` [Qemu-devel] [PATCH 1/2] powerpc/booke: move fdt loading to rom infrastructure Aurelien Jarno
1 sibling, 0 replies; 4+ messages in thread
From: Liu Yu @ 2010-02-02 8:49 UTC (permalink / raw)
To: hollis; +Cc: Liu Yu, qemu-devel
Since kernel uimage is getting bigger,
old fixed loading bases will result in regions overlap.
Add pad for fdt and ramdisk, so that they won't overlap with uimage.
Signed-off-by: Liu Yu <yu.liu@freescale.com>
---
hw/ppce500_mpc8544ds.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index 9a5654b..3826156 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -34,8 +34,10 @@
#define BINARY_DEVICE_TREE_FILE "mpc8544ds.dtb"
#define UIMAGE_LOAD_BASE 0
-#define DTB_LOAD_BASE 0x600000
-#define INITRD_LOAD_BASE 0x2000000
+#define DTC_LOAD_PAD 0x500000
+#define DTC_PAD_MASK 0xFFFFF
+#define INITRD_LOAD_PAD 0x2000000
+#define INITRD_PAD_MASK 0xFFFFFF
#define RAM_SIZES_ALIGN (64UL << 20)
@@ -170,8 +172,8 @@ static void mpc8544ds_init(ram_addr_t ram_size,
target_phys_addr_t entry=0;
target_phys_addr_t loadaddr=UIMAGE_LOAD_BASE;
target_long kernel_size=0;
- target_ulong dt_base=DTB_LOAD_BASE;
- target_ulong initrd_base=INITRD_LOAD_BASE;
+ target_ulong dt_base = 0;
+ target_ulong initrd_base = 0;
target_long initrd_size=0;
int i=0;
unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
@@ -246,6 +248,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
/* Load initrd. */
if (initrd_filename) {
+ initrd_base = (kernel_size + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK;
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
@@ -258,6 +261,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
/* If we're loading a kernel directly, we must load the device tree too. */
if (kernel_filename) {
+ dt_base = (kernel_size + DTC_LOAD_PAD) & ~DTC_PAD_MASK;
if (mpc8544_load_device_tree(dt_base, ram_size,
initrd_base, initrd_size, kernel_cmdline) < 0) {
fprintf(stderr, "couldn't load device tree\n");
--
1.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] powerpc/booke: move fdt loading to rom infrastructure
2010-02-02 8:49 [Qemu-devel] [PATCH 1/2] powerpc/booke: move fdt loading to rom infrastructure Liu Yu
2010-02-02 8:49 ` [Qemu-devel] [PATCH 2/2] powerpc/e500: adjust fdt and ramdisk loading addr Liu Yu
@ 2010-02-27 15:33 ` Aurelien Jarno
2010-02-27 18:49 ` Aurelien Jarno
1 sibling, 1 reply; 4+ messages in thread
From: Aurelien Jarno @ 2010-02-27 15:33 UTC (permalink / raw)
To: Liu Yu; +Cc: qemu-devel, hollis
On Tue, Feb 02, 2010 at 04:49:02PM +0800, Liu Yu wrote:
> It's convinent to use rom to checking overlap, to reset etc.
> And uImage and ramdisk loading has already moved to it.
>
> Also, after we add fdt to rom, free it.
This does not build if CONFIG_FDT is not set:
| CC ppc-softmmu/ppc440_bamboo.o
| /home/aurel32/git/qemu/hw/ppc440_bamboo.c: In function 'bamboo_load_device_tree':
| /home/aurel32/git/qemu/hw/ppc440_bamboo.c:86: error: 'ret' undeclared (first use in this function)
| /home/aurel32/git/qemu/hw/ppc440_bamboo.c:86: error: (Each undeclared identifier is reported only once
| /home/aurel32/git/qemu/hw/ppc440_bamboo.c:86: error: for each function it appears in.)
| cc1: warnings being treated as errors
| /home/aurel32/git/qemu/hw/ppc440_bamboo.c:36: error: unused variable 'fdt'
| make[1]: *** [ppc440_bamboo.o] Error 1
| make: *** [subdir-ppc-softmmu] Error 2
> Signed-off-by: Liu Yu <yu.liu@freescale.com>
> ---
> hw/ppc440_bamboo.c | 15 ++++++++-------
> hw/ppce500_mpc8544ds.c | 17 ++++++++++-------
> 2 files changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
> index 1ab9872..9d95417 100644
> --- a/hw/ppc440_bamboo.c
> +++ b/hw/ppc440_bamboo.c
> @@ -27,7 +27,7 @@
>
> #define BINARY_DEVICE_TREE_FILE "bamboo.dtb"
>
> -static void *bamboo_load_device_tree(target_phys_addr_t addr,
> +static int bamboo_load_device_tree(target_phys_addr_t addr,
> uint32_t ramsize,
> target_phys_addr_t initrd_base,
> target_phys_addr_t initrd_size,
> @@ -42,11 +42,13 @@ static void *bamboo_load_device_tree(target_phys_addr_t addr,
>
> filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
> if (!filename) {
> + ret = -1;
> goto out;
> }
> fdt = load_device_tree(filename, &fdt_size);
> qemu_free(filename);
> if (fdt == NULL) {
> + ret = -1;
> goto out;
> }
>
> @@ -75,12 +77,13 @@ static void *bamboo_load_device_tree(target_phys_addr_t addr,
> if (kvm_enabled())
> kvmppc_fdt_update(fdt);
>
> - cpu_physical_memory_write (addr, (void *)fdt, fdt_size);
> + ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
> + qemu_free(fdt);
>
> out:
> #endif
>
> - return fdt;
> + return ret;
> }
>
> static void bamboo_init(ram_addr_t ram_size,
> @@ -101,7 +104,6 @@ static void bamboo_init(ram_addr_t ram_size,
> target_ulong initrd_base = 0;
> target_long initrd_size = 0;
> target_ulong dt_base = 0;
> - void *fdt;
> int i;
>
> /* Setup CPU. */
> @@ -153,9 +155,8 @@ static void bamboo_init(ram_addr_t ram_size,
> else
> dt_base = kernel_size + loadaddr;
>
> - fdt = bamboo_load_device_tree(dt_base, ram_size,
> - initrd_base, initrd_size, kernel_cmdline);
> - if (fdt == NULL) {
> + if (bamboo_load_device_tree(dt_base, ram_size,
> + initrd_base, initrd_size, kernel_cmdline) < 0) {
> fprintf(stderr, "couldn't load device tree\n");
> exit(1);
> }
> diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
> index ea30816..9a5654b 100644
> --- a/hw/ppce500_mpc8544ds.c
> +++ b/hw/ppce500_mpc8544ds.c
> @@ -72,7 +72,7 @@ out:
> }
> #endif
>
> -static void *mpc8544_load_device_tree(target_phys_addr_t addr,
> +static int mpc8544_load_device_tree(target_phys_addr_t addr,
> uint32_t ramsize,
> target_phys_addr_t initrd_base,
> target_phys_addr_t initrd_size,
> @@ -87,11 +87,13 @@ static void *mpc8544_load_device_tree(target_phys_addr_t addr,
>
> filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
> if (!filename) {
> + ret = -1;
> goto out;
> }
> fdt = load_device_tree(filename, &fdt_size);
> qemu_free(filename);
> if (fdt == NULL) {
> + ret = -1;
> goto out;
> }
>
> @@ -123,6 +125,7 @@ static void *mpc8544_load_device_tree(target_phys_addr_t addr,
>
> if ((dp = opendir("/proc/device-tree/cpus/")) == NULL) {
> printf("Can't open directory /proc/device-tree/cpus/\n");
> + ret = -1;
> goto out;
> }
>
> @@ -136,6 +139,7 @@ static void *mpc8544_load_device_tree(target_phys_addr_t addr,
> closedir(dp);
> if (buf[0] == '\0') {
> printf("Unknow host!\n");
> + ret = -1;
> goto out;
> }
>
> @@ -143,12 +147,13 @@ static void *mpc8544_load_device_tree(target_phys_addr_t addr,
> mpc8544_copy_soc_cell(fdt, buf, "timebase-frequency");
> }
>
> - cpu_physical_memory_write (addr, (void *)fdt, fdt_size);
> + ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr);
> + qemu_free(fdt);
>
> out:
> #endif
>
> - return fdt;
> + return ret;
> }
>
> static void mpc8544ds_init(ram_addr_t ram_size,
> @@ -168,7 +173,6 @@ static void mpc8544ds_init(ram_addr_t ram_size,
> target_ulong dt_base=DTB_LOAD_BASE;
> target_ulong initrd_base=INITRD_LOAD_BASE;
> target_long initrd_size=0;
> - void *fdt;
> int i=0;
> unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
> qemu_irq *irqs, *mpic, *pci_irqs;
> @@ -254,9 +258,8 @@ static void mpc8544ds_init(ram_addr_t ram_size,
>
> /* If we're loading a kernel directly, we must load the device tree too. */
> if (kernel_filename) {
> - fdt = mpc8544_load_device_tree(dt_base, ram_size,
> - initrd_base, initrd_size, kernel_cmdline);
> - if (fdt == NULL) {
> + if (mpc8544_load_device_tree(dt_base, ram_size,
> + initrd_base, initrd_size, kernel_cmdline) < 0) {
> fprintf(stderr, "couldn't load device tree\n");
> exit(1);
> }
> --
> 1.6.4
>
>
>
>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] powerpc/booke: move fdt loading to rom infrastructure
2010-02-27 15:33 ` [Qemu-devel] [PATCH 1/2] powerpc/booke: move fdt loading to rom infrastructure Aurelien Jarno
@ 2010-02-27 18:49 ` Aurelien Jarno
0 siblings, 0 replies; 4+ messages in thread
From: Aurelien Jarno @ 2010-02-27 18:49 UTC (permalink / raw)
To: Liu Yu; +Cc: qemu-devel, hollis
On Sat, Feb 27, 2010 at 04:33:02PM +0100, Aurelien Jarno wrote:
> On Tue, Feb 02, 2010 at 04:49:02PM +0800, Liu Yu wrote:
> > It's convinent to use rom to checking overlap, to reset etc.
> > And uImage and ramdisk loading has already moved to it.
> >
> > Also, after we add fdt to rom, free it.
>
> This does not build if CONFIG_FDT is not set:
>
> | CC ppc-softmmu/ppc440_bamboo.o
> | /home/aurel32/git/qemu/hw/ppc440_bamboo.c: In function 'bamboo_load_device_tree':
> | /home/aurel32/git/qemu/hw/ppc440_bamboo.c:86: error: 'ret' undeclared (first use in this function)
> | /home/aurel32/git/qemu/hw/ppc440_bamboo.c:86: error: (Each undeclared identifier is reported only once
> | /home/aurel32/git/qemu/hw/ppc440_bamboo.c:86: error: for each function it appears in.)
> | cc1: warnings being treated as errors
> | /home/aurel32/git/qemu/hw/ppc440_bamboo.c:36: error: unused variable 'fdt'
> | make[1]: *** [ppc440_bamboo.o] Error 1
> | make: *** [subdir-ppc-softmmu] Error 2
>
As I have pushed the patch by mistake to the git tree, and it is mostly
ok, I have committed a patch to fix the above issue.
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-27 18:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-02 8:49 [Qemu-devel] [PATCH 1/2] powerpc/booke: move fdt loading to rom infrastructure Liu Yu
2010-02-02 8:49 ` [Qemu-devel] [PATCH 2/2] powerpc/e500: adjust fdt and ramdisk loading addr Liu Yu
2010-02-27 15:33 ` [Qemu-devel] [PATCH 1/2] powerpc/booke: move fdt loading to rom infrastructure Aurelien Jarno
2010-02-27 18:49 ` Aurelien Jarno
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).