[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 36/72] dt: add helper for empty dt creation
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PATCH 36/72] dt: add helper for empty dt creation |
Date: |
Sun, 24 Jun 2012 01:07:00 +0200 |
We want to get rid of the concept of loading an external device tree and instead
generate our own. However, to do this we need to also create a device tree
template programatically.
This patch adds a helper to create an empty device tree in memory.
Signed-off-by: Alexander Graf <address@hidden>
Reviewed-by: Peter Crosthwaite <address@hidden>
---
device_tree.c | 37 +++++++++++++++++++++++++++++++++++++
device_tree.h | 1 +
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/device_tree.c b/device_tree.c
index 2f127b7..d037896 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -25,6 +25,43 @@
#include <libfdt.h>
+#define FDT_MAX_SIZE 0x10000
+
+void *create_device_tree(int *sizep)
+{
+ void *fdt;
+ int ret;
+
+ *sizep = FDT_MAX_SIZE;
+ fdt = g_malloc0(FDT_MAX_SIZE);
+ ret = fdt_create(fdt, FDT_MAX_SIZE);
+ if (ret < 0) {
+ goto fail;
+ }
+ ret = fdt_begin_node(fdt, "");
+ if (ret < 0) {
+ goto fail;
+ }
+ ret = fdt_end_node(fdt);
+ if (ret < 0) {
+ goto fail;
+ }
+ ret = fdt_finish(fdt);
+ if (ret < 0) {
+ goto fail;
+ }
+ ret = fdt_open_into(fdt, fdt, *sizep);
+ if (ret) {
+ fprintf(stderr, "Unable to copy device tree in memory\n");
+ exit(1);
+ }
+
+ return fdt;
+fail:
+ fprintf(stderr, "%s Couldn't create dt: %s\n", __func__,
fdt_strerror(ret));
+ exit(1);
+}
+
void *load_device_tree(const char *filename_path, int *sizep)
{
int dt_size;
diff --git a/device_tree.h b/device_tree.h
index 36fc9db..5f76f40 100644
--- a/device_tree.h
+++ b/device_tree.h
@@ -14,6 +14,7 @@
#ifndef __DEVICE_TREE_H__
#define __DEVICE_TREE_H__
+void *create_device_tree(int *sizep);
void *load_device_tree(const char *filename_path, int *sizep);
int qemu_devtree_setprop(void *fdt, const char *node_path,
--
1.6.0.2
- [Qemu-ppc] [PATCH 66/72] PPC: Add support for MSR_CM, (continued)
- [Qemu-ppc] [PATCH 66/72] PPC: Add support for MSR_CM, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 70/72] PPC: Extract SPR dump generation into its own function, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 52/72] PPC: e500: dt: use 64bit cell helper, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 10/72] ppc: Split MMU etc. helpers from op_helper.c, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 33/72] dt: add helper for phandle references, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 44/72] PPC: e500: dt: create /chosen node dynamically, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 32/72] dt: add helpers for multi-cell adds, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 29/72] spapr: Add "memop" hypercall, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 61/72] PPC: e500: Refactor serial dt generation, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 45/72] PPC: e500: dt: create /soc8544 node dynamically, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 36/72] dt: add helper for empty dt creation,
Alexander Graf <=
- [Qemu-ppc] [PATCH 51/72] dt: Add -machine dumpdtb option to dump the current dtb, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 46/72] PPC: e500: dt: create serial nodes dynamically, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 48/72] PPC: e500: dt: create global-utils node dynamically, Alexander Graf, 2012/06/23
- [Qemu-ppc] [PATCH 53/72] PPC: e500: dt: use target_phys_addr_t for ramsize, Alexander Graf, 2012/06/23
- Re: [Qemu-ppc] [PULL 00/72] ppc patch queue 2012-06-24, Blue Swirl, 2012/06/24