Skip to contentSkip to conversation

libfdt: Add some utilities to manipulate the reserved memory map.

PATCH New Jerry Van Baren 1 participant 2 messages Apr 15, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libfdt: Add some utilities to manipulate the reserved memory map.

---
 include/libfdt.h |    5 +++
 libfdt/fdt_ro.c  |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 libfdt/fdt_wip.c |   26 +++++++++++++++++++
 3 files changed, 103 insertions(+), 0 deletions(-)
include/libfdt.h +5 -0
index 61f56ec..f8bac73 100644
@@ -86,6 +86,8 @@ void *fdt_getprop(const void *fdt, int nodeoffset,
 
 uint32_t fdt_next_tag(const void *fdt, int offset,
 		      int *nextoffset, char **namep);
+int fdt_num_reservemap(void *fdt, int *used, int *total);
+int fdt_get_reservemap(void *fdt, int n, struct fdt_reserve_entry *re);
 
 /* Write-in-place functions */
 int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
@@ -99,6 +101,8 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 
 int fdt_nop_property(void *fdt, int nodeoffset, const char *name);
 int fdt_nop_node(void *fdt, int nodeoffset);
+int fdt_insert_reservemap_entry(void *fdt, int n, uint64_t addr, uint64_t size);
+
 
 /* Sequential-write functions */
 int fdt_create(void *buf, int bufsize);
@@ -115,6 +119,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len);
 	fdt_property(fdt, name, str, strlen(str)+1)
 int fdt_end_node(void *fdt);
 int fdt_finish(void *fdt);
+int fdt_replace_reservemap_entry(void *fdt, int n, uint64_t addr, uint64_t size);
 
 /* Read-write functions */
 int fdt_open_into(void *fdt, void *buf, int bufsize);
libfdt/fdt_ro.c +72 -0

75 lines not on this page · raw message

libfdt/fdt_wip.c +26 -0
index 261b9b0..cf81183 100644
@@ -110,3 +110,29 @@ int fdt_nop_node(void *fdt, int nodeoffset)
 	nop_region(fdt_offset_ptr(fdt, nodeoffset, 0), endoffset - nodeoffset);
 	return 0;
 }
+
+/*
+ * Replace a reserve map entry in the nth slot.
+ */
+int fdt_replace_reservemap_entry(void *fdt, int n, uint64_t addr, uint64_t size)
+{
+	struct fdt_reserve_entry *re;
+	int  used;
+	int  total;
+	int  err;
+
+	err = fdt_num_reservemap(fdt, &used, &total);
+	if (err != 0)
+		return err;
+
+	if (n >= total)
+		return -FDT_ERR_NOSPACE;
+	re = (struct fdt_reserve_entry *)
+		(fdt + fdt_off_mem_rsvmap(fdt) +
+		 (n * sizeof(struct fdt_reserve_entry)));
+	re->address = cpu_to_fdt64(addr);
+	re->size    = cpu_to_fdt64(size);
+
+	return 0;
+}
+
Signature · 1 line
1.4.4.4
#1 lore raw

PATCH 1/2 libfdt: Add some utilities to manipulate the reserved memory map.

Hello All,

I've published two more patches for fdt handling and pushed them to the u-boot-fdt repository. This now handles ramdisks well, including modifying the reserved map entries in the blob (required some new libfdt routines).

I have not tried a multi-image (blob embedded), but have the same handling code as passing in the blob as the 2nd parameter so it should work OK. If someone could test this or send me a RTFM pointer on how to create a multi-image, I would appreciate it.

The only remaining issue is my poorly executed changes for setting the MAC addresses.

Wolfgang: This should be good to pull, but it wouldn't hurt to wait for a little for code review. Also, I'll try to get the mac address fix in in the next day or two.

Best regards,
gvb