From: Hollis Blanchard <hollisb@us.ibm.com>
To: Jerone Young <jyoung5@us.ibm.com>
Cc: kvm-devel@lists.sourceforge.net, kvm-ppc-devel@lists.sourceforge.net
Subject: Re: [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device
Date: Tue, 18 Mar 2008 21:25:56 +0000 [thread overview]
Message-ID: <1205875556.11784.38.camel@basalt> (raw)
In-Reply-To: <3e87db599895937824b9.1205870798@thinkpad.austin.ibm.com>
On Tue, 2008-03-18 at 15:06 -0500, Jerone Young wrote:
> # HG changeset patch
> # User Jerone Young <jyoung5@us.ibm.com>
> # Date 1205870472 18000
> # Branch merge
> # Node ID 3e87db599895937824b9bf3369eb67ea7f5a7595
> # Parent ba2876c3e8916ba9c19b75c4464cbb8dc6858fbd
> Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model
>
> This patch adds code to dynamically manipulate the device tree when
> loaded into memory. This allows us to finally have the ability to
> manipulate the kernel command line & initrd from the qemu command
> line. This will also let us setup different settings for the board.
>
> This patch also now uses new uboot loader load_image() to load kernel
> image.
Again, the load_uimage part (which you've misspelled here) should be a
separate patch?
> Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
>
> diff --git a/qemu/Makefile.target b/qemu/Makefile.target
> --- a/qemu/Makefile.target
> +++ b/qemu/Makefile.target
> @@ -617,7 +617,7 @@ OBJS+= unin_pci.o ppc_chrp.o
> OBJS+= unin_pci.o ppc_chrp.o
> # PowerPC 4xx boards
> OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o
> -OBJS+= ppc440.o ppc440_bamboo.o
> +OBJS+= ppc440.o ppc440_bamboo.o device_tree.o
> endif
> ifeq ($(TARGET_BASE_ARCH), mips)
> OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o
> diff --git a/qemu/hw/device_tree.c b/qemu/hw/device_tree.c
> new file mode 100644
> --- /dev/null
> +++ b/qemu/hw/device_tree.c
> @@ -0,0 +1,181 @@
> +/*
> + * Functions to help device tree manipulation using libfdt.
> + * It also provides functions to read entries from device tree proc
> + * interface.
> + *
> + * Copyright 2008 IBM Corporation.
> + * Authors: Jerone Young <jyoung5@us.ibm.com>
> + *
> + * This work is licensed under the GNU GPL license version 2 or later.
> + *
> + */
> +
> +#include <stdio.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <unistd.h>
> +#include <stdlib.h>
> +
> +#include "config.h"
> +#include "ppc440.h"
> +
> +#ifdef CONFIG_LIBFDT
> + #include "libfdt.h"
> +#endif
Again, don't indent this.
> +#define DT_PROC_INTERFACE_PATH "/proc/device-tree"
> +
> +/* FUNCTIONS FOR READING FROM DEVICE TREE OF HOST IN /PROC */
> +
> +/* This function reads device-tree property files that are of
> + * a single cell size
> + */
> +uint32_t read_proc_dt_prop_cell(char *path_in_device_tree)
> +{
> + char *buf = NULL;
> + int i;
> + uint32_t num;
> + FILE *stream;
> +
> + i = snprintf(buf, 0, "%s/%s", DT_PROC_INTERFACE_PATH,
> + path_in_device_tree);
> +
> + buf = (char *)malloc(i);
> + if (buf = NULL)
> + {
> + printf("%s: Unable to malloc string buffer buf\n",
> + __func__);
> + exit(1);
> + }
Braces.
> + i = snprintf(buf, i+1, "%s/%s", DT_PROC_INTERFACE_PATH,
> + path_in_device_tree);
> +
> + stream = fopen(buf, "rb");
> +
> + if (stream = NULL)
> + {
> + printf("%s: Unable to open '%s'\n", __func__, buf);
> + exit(1);
> + }
Braces.
> + fread(&num, sizeof(num), 1, stream);
> + fclose(stream);
> +
> + return num;
> +}
> +
> +/* FUNCTIONS FOR LOADING & MANIPULATION OF DEVICE TREE IN GUEST */
> +
> +#ifdef CONFIG_LIBFDT
> +/* support functions */
> +static int get_offset_of_node(void *fdt, char *node_path)
> +{
> + int node_offset;
> + node_offset = fdt_path_offset(fdt, node_path);
> + if (node_offset < 0) {
> + printf("Unable to find node in device tree '%s'\n",
> + node_path);
> + exit(1);
> + }
> + return node_offset;
> +}
> +
> +/* public functions */
> +void *load_device_tree(char *filename_path, unsigned long load_addr)
> +{
> + int dt_file_size;
> + int dt_file_load_size;
> + int new_dt_size; int ret;
Does this look right to you?
...
> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
> --- a/qemu/hw/ppc440_bamboo.c
> +++ b/qemu/hw/ppc440_bamboo.c
> @@ -4,15 +4,16 @@
> * Copyright 2007 IBM Corporation.
> * Authors: Jerone Young <jyoung5@us.ibm.com>
> *
> - * This work is licensed under the GNU GPL licence version 2 or later.
> + * This work is licensed under the GNU GPL license version 2 or later.
> *
> */
>
> +#include "config.h"
> #include "ppc440.h"
> +#include "qemu-kvm.h"
> +#include "device_tree.h"
>
> -#define KERNEL_LOAD_ADDR 0x400000 /* uboot loader puts kernel at 4MB */
> -
> -#include "qemu-kvm.h"
> +#define BINARY_DEVICE_TREE_FILE "bamboo.dtb"
>
> /* PPC 440 refrence demo board
Could you fix this typo while you're at it?
> @@ -26,14 +27,22 @@ void bamboo_init(ram_addr_t ram_size, in
> const char *initrd_filename,
> const char *cpu_model)
> {
> + char buf[1024];
You previously said you had removed 'buf' and replaced it with dynamic
allocation, but I don't see that here.
> target_phys_addr_t ram_bases[2], ram_sizes[2];
> qemu_irq *pic;
> CPUState *env;
> - target_ulong ep;
> + target_ulong ep=0;
> + target_ulong la=0;
> int is_linux=1; /* Will assume allways is Linux for now */
> - long kernel_size=0;
> + target_long kernel_size=0;
> target_ulong initrd_base=0;
> - target_ulong initrd_size=0;
> + target_long initrd_size=0;
> + target_ulong dt_base=0;
> + void *fdt;
> + int ret;
> +
> + uint32_t cpu_freq;
> + uint32_t timebase_freq;
Why is there an extra blank line here?
--
Hollis Blanchard
IBM Linux Technology Center
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-ppc-devel mailing list
kvm-ppc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel
WARNING: multiple messages have this Message-ID (diff)
From: Hollis Blanchard <hollisb@us.ibm.com>
To: Jerone Young <jyoung5@us.ibm.com>
Cc: kvm-devel@lists.sourceforge.net, kvm-ppc-devel@lists.sourceforge.net
Subject: Re: [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model
Date: Tue, 18 Mar 2008 16:25:56 -0500 [thread overview]
Message-ID: <1205875556.11784.38.camel@basalt> (raw)
In-Reply-To: <3e87db599895937824b9.1205870798@thinkpad.austin.ibm.com>
On Tue, 2008-03-18 at 15:06 -0500, Jerone Young wrote:
> # HG changeset patch
> # User Jerone Young <jyoung5@us.ibm.com>
> # Date 1205870472 18000
> # Branch merge
> # Node ID 3e87db599895937824b9bf3369eb67ea7f5a7595
> # Parent ba2876c3e8916ba9c19b75c4464cbb8dc6858fbd
> Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model
>
> This patch adds code to dynamically manipulate the device tree when
> loaded into memory. This allows us to finally have the ability to
> manipulate the kernel command line & initrd from the qemu command
> line. This will also let us setup different settings for the board.
>
> This patch also now uses new uboot loader load_image() to load kernel
> image.
Again, the load_uimage part (which you've misspelled here) should be a
separate patch?
> Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
>
> diff --git a/qemu/Makefile.target b/qemu/Makefile.target
> --- a/qemu/Makefile.target
> +++ b/qemu/Makefile.target
> @@ -617,7 +617,7 @@ OBJS+= unin_pci.o ppc_chrp.o
> OBJS+= unin_pci.o ppc_chrp.o
> # PowerPC 4xx boards
> OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o
> -OBJS+= ppc440.o ppc440_bamboo.o
> +OBJS+= ppc440.o ppc440_bamboo.o device_tree.o
> endif
> ifeq ($(TARGET_BASE_ARCH), mips)
> OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o
> diff --git a/qemu/hw/device_tree.c b/qemu/hw/device_tree.c
> new file mode 100644
> --- /dev/null
> +++ b/qemu/hw/device_tree.c
> @@ -0,0 +1,181 @@
> +/*
> + * Functions to help device tree manipulation using libfdt.
> + * It also provides functions to read entries from device tree proc
> + * interface.
> + *
> + * Copyright 2008 IBM Corporation.
> + * Authors: Jerone Young <jyoung5@us.ibm.com>
> + *
> + * This work is licensed under the GNU GPL license version 2 or later.
> + *
> + */
> +
> +#include <stdio.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <unistd.h>
> +#include <stdlib.h>
> +
> +#include "config.h"
> +#include "ppc440.h"
> +
> +#ifdef CONFIG_LIBFDT
> + #include "libfdt.h"
> +#endif
Again, don't indent this.
> +#define DT_PROC_INTERFACE_PATH "/proc/device-tree"
> +
> +/* FUNCTIONS FOR READING FROM DEVICE TREE OF HOST IN /PROC */
> +
> +/* This function reads device-tree property files that are of
> + * a single cell size
> + */
> +uint32_t read_proc_dt_prop_cell(char *path_in_device_tree)
> +{
> + char *buf = NULL;
> + int i;
> + uint32_t num;
> + FILE *stream;
> +
> + i = snprintf(buf, 0, "%s/%s", DT_PROC_INTERFACE_PATH,
> + path_in_device_tree);
> +
> + buf = (char *)malloc(i);
> + if (buf == NULL)
> + {
> + printf("%s: Unable to malloc string buffer buf\n",
> + __func__);
> + exit(1);
> + }
Braces.
> + i = snprintf(buf, i+1, "%s/%s", DT_PROC_INTERFACE_PATH,
> + path_in_device_tree);
> +
> + stream = fopen(buf, "rb");
> +
> + if (stream == NULL)
> + {
> + printf("%s: Unable to open '%s'\n", __func__, buf);
> + exit(1);
> + }
Braces.
> + fread(&num, sizeof(num), 1, stream);
> + fclose(stream);
> +
> + return num;
> +}
> +
> +/* FUNCTIONS FOR LOADING & MANIPULATION OF DEVICE TREE IN GUEST */
> +
> +#ifdef CONFIG_LIBFDT
> +/* support functions */
> +static int get_offset_of_node(void *fdt, char *node_path)
> +{
> + int node_offset;
> + node_offset = fdt_path_offset(fdt, node_path);
> + if (node_offset < 0) {
> + printf("Unable to find node in device tree '%s'\n",
> + node_path);
> + exit(1);
> + }
> + return node_offset;
> +}
> +
> +/* public functions */
> +void *load_device_tree(char *filename_path, unsigned long load_addr)
> +{
> + int dt_file_size;
> + int dt_file_load_size;
> + int new_dt_size; int ret;
Does this look right to you?
...
> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
> --- a/qemu/hw/ppc440_bamboo.c
> +++ b/qemu/hw/ppc440_bamboo.c
> @@ -4,15 +4,16 @@
> * Copyright 2007 IBM Corporation.
> * Authors: Jerone Young <jyoung5@us.ibm.com>
> *
> - * This work is licensed under the GNU GPL licence version 2 or later.
> + * This work is licensed under the GNU GPL license version 2 or later.
> *
> */
>
> +#include "config.h"
> #include "ppc440.h"
> +#include "qemu-kvm.h"
> +#include "device_tree.h"
>
> -#define KERNEL_LOAD_ADDR 0x400000 /* uboot loader puts kernel at 4MB */
> -
> -#include "qemu-kvm.h"
> +#define BINARY_DEVICE_TREE_FILE "bamboo.dtb"
>
> /* PPC 440 refrence demo board
Could you fix this typo while you're at it?
> @@ -26,14 +27,22 @@ void bamboo_init(ram_addr_t ram_size, in
> const char *initrd_filename,
> const char *cpu_model)
> {
> + char buf[1024];
You previously said you had removed 'buf' and replaced it with dynamic
allocation, but I don't see that here.
> target_phys_addr_t ram_bases[2], ram_sizes[2];
> qemu_irq *pic;
> CPUState *env;
> - target_ulong ep;
> + target_ulong ep=0;
> + target_ulong la=0;
> int is_linux=1; /* Will assume allways is Linux for now */
> - long kernel_size=0;
> + target_long kernel_size=0;
> target_ulong initrd_base=0;
> - target_ulong initrd_size=0;
> + target_long initrd_size=0;
> + target_ulong dt_base=0;
> + void *fdt;
> + int ret;
> +
> + uint32_t cpu_freq;
> + uint32_t timebase_freq;
Why is there an extra blank line here?
--
Hollis Blanchard
IBM Linux Technology Center
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
next prev parent reply other threads:[~2008-03-18 21:25 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-18 20:06 [kvm-ppc-devel] [PATCH 0 of 7] [v3] PowerPC kvm-userspace patches Jerone Young
2008-03-18 20:06 ` Jerone Young
2008-03-18 20:06 ` [kvm-ppc-devel] [PATCH 1 of 7] Add libfdt to KVM userspace Jerone Young
2008-03-18 20:06 ` Jerone Young
2008-03-18 20:06 ` [kvm-ppc-devel] [PATCH 2 of 7] Add libfdt support to qemu Jerone Young
2008-03-18 20:06 ` Jerone Young
2008-03-18 21:16 ` [kvm-ppc-devel] " Hollis Blanchard
2008-03-18 21:16 ` Hollis Blanchard
2008-03-18 21:22 ` Jerone Young
2008-03-18 21:22 ` Jerone Young
2008-03-18 21:28 ` Hollis Blanchard
2008-03-18 21:28 ` Hollis Blanchard
2008-03-18 21:57 ` [kvm-ppc-devel] [kvm-devel] [PATCH 2 of 7] Add libfdt Jerone Young
2008-03-18 21:57 ` [kvm-ppc-devel] [PATCH 2 of 7] Add libfdt support to qemu Jerone Young
2008-03-18 20:06 ` [kvm-ppc-devel] [PATCH 3 of 7] Create new load_uimage() & gunzip Jerone Young
2008-03-18 20:06 ` [PATCH 3 of 7] Create new load_uimage() & gunzip support to uboot loader in Qemu Jerone Young
2008-03-18 21:14 ` [kvm-ppc-devel] [PATCH 3 of 7] Create new load_uimage() Hollis Blanchard
2008-03-18 21:14 ` [kvm-ppc-devel] [PATCH 3 of 7] Create new load_uimage() & gunzip support to uboot loader in Qemu Hollis Blanchard
2008-03-18 21:46 ` [kvm-ppc-devel] [PATCH 3 of 7] Create new load_uimage() Jerone Young
2008-03-18 21:46 ` [kvm-ppc-devel] [PATCH 3 of 7] Create new load_uimage() & gunzip support to uboot loader in Qemu Jerone Young
2008-03-18 22:14 ` [kvm-ppc-devel] [PATCH 3 of 7] Create new Hollis Blanchard
2008-03-18 22:14 ` [kvm-ppc-devel] [PATCH 3 of 7] Create new load_uimage() & gunzip support to uboot loader in Qemu Hollis Blanchard
2008-03-18 20:06 ` [kvm-ppc-devel] [PATCH 4 of 7] Add PPC 440EP bamboo board device Jerone Young
2008-03-18 20:06 ` [PATCH 4 of 7] Add PPC 440EP bamboo board device tree source & binary into qemu Jerone Young
2008-03-18 20:06 ` [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device tree manipulation Jerone Young
2008-03-18 20:06 ` [PATCH 5 of 7] Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model Jerone Young
2008-03-18 21:25 ` Hollis Blanchard [this message]
2008-03-18 21:25 ` [kvm-ppc-devel] " Hollis Blanchard
2008-03-18 21:35 ` [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device Jerone Young
2008-03-18 21:35 ` [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model Jerone Young
2008-03-18 22:08 ` [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic Hollis Blanchard
2008-03-18 22:08 ` [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model Hollis Blanchard
2008-03-18 20:06 ` [kvm-ppc-devel] [PATCH 6 of 7] Modify PPC bamboo & ppc440 board Jerone Young
2008-03-18 20:06 ` [PATCH 6 of 7] Modify PPC bamboo & ppc440 board models Jerone Young
2008-03-18 20:06 ` [kvm-ppc-devel] [PATCH 7 of 7] Add ability to specify ram on Jerone Young
2008-03-18 20:06 ` [PATCH 7 of 7] Add ability to specify ram on command line for bamboo board model Jerone Young
2008-03-18 21:03 ` [kvm-ppc-devel] [PATCH 7 of 7] Add ability to specify ram Hollis Blanchard
2008-03-18 21:03 ` [kvm-ppc-devel] [PATCH 7 of 7] Add ability to specify ram on command line for bamboo board model Hollis Blanchard
2008-03-18 21:17 ` [kvm-ppc-devel] [PATCH 7 of 7] Add ability to specify ram Jerone Young
2008-03-18 21:17 ` [kvm-ppc-devel] [PATCH 7 of 7] Add ability to specify ram on command line for bamboo board model Jerone Young
-- strict thread matches above, loose matches on Subject: below --
2008-03-19 14:45 [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device tree manipulation Jerone Young
2008-03-19 18:02 ` [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device Hollis Blanchard
2008-03-12 4:50 [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device tree manipulation Jerone Young
2008-03-13 2:53 ` [kvm-ppc-devel] [PATCH 5 of 7] Add dynamic device Hollis Blanchard
2008-03-13 22:27 ` Jerone Young
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=1205875556.11784.38.camel@basalt \
--to=hollisb@us.ibm.com \
--cc=jyoung5@us.ibm.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=kvm-ppc-devel@lists.sourceforge.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.