[Crosstoolchain-logs] [device-tree-compiler] 21/357: Fix endian problems with handling of memreserve entries (bug pointed out by Pantelis Antoniou). The rule is that the memreserve data in struct boot_info is always stored big-endian.

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:05:44 UTC 2016


This is an automated email from the git hooks/post-receive script.

zumbi pushed a commit to branch upstream/1.3.x
in repository device-tree-compiler.

commit 6c0f36769af7e015030d033edf6b10f7ec50318c
Author: David Gibson <dgibson at sneetch.(none)>
Date:   Mon Aug 29 13:36:15 2005 +1000

    Fix endian problems with handling of memreserve entries (bug pointed out
    by Pantelis Antoniou).  The rule is that the memreserve data in struct
    boot_info is always stored big-endian.
---
 flattree.c   | 35 ++++++++++++-----------------------
 treesource.c |  5 +++--
 2 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/flattree.c b/flattree.c
index 62b8903..92d99a5 100644
--- a/flattree.c
+++ b/flattree.c
@@ -437,8 +437,8 @@ void write_dt_asm(FILE *f, struct boot_info *bi, int version)
 	 */
 	asm_emit_align(f, 8);
 	emit_label(f, symprefix, "reserve_map");
-	fprintf(f, "\t.long\t0, _%s_blob_start\n", symprefix);
-	fprintf(f, "\t.long\t0, _%s_blob_end - _%s_blob_start\n",
+	fprintf(f, "\t.quad\t0, _%s_blob_start\n", symprefix);
+	fprintf(f, "\t.quad\t0, _%s_blob_end - _%s_blob_start\n",
 		symprefix, symprefix);
 
 	if (bi->mem_reserve_data.len > 0) {
@@ -446,8 +446,8 @@ void write_dt_asm(FILE *f, struct boot_info *bi, int version)
 		asm_emit_data(f, bi->mem_reserve_data);
 	}
 
-	fprintf(f, "\t.llong\t0\n");
-	fprintf(f, "\t.llong\t0\n");
+	fprintf(f, "\t.quad\t0\n");
+	fprintf(f, "\t.quad\t0\n");
 
 	emit_label(f, symprefix, "struct_start");
 	flatten_tree(bi->dt, &asm_emitter, f, &strbuf, vi);
@@ -585,12 +585,8 @@ static struct property *flat_read_property(struct inbuf *dtbuf,
 static struct data flat_read_mem_reserve(struct inbuf *inb)
 {
 	char *p;
-	int len = 0;
-	int done = 0;
-	cell_t cells[4];
-	struct data d;
-
-	d = empty_data;
+	struct reserve_entry re;
+	struct data d = empty_data;
 
 	/*
 	 * Each entry is a pair of u64 (addr, size) values for 4 cell_t's.
@@ -599,20 +595,13 @@ static struct data flat_read_mem_reserve(struct inbuf *inb)
 	 * First pass, count entries.
 	 */
 	p = inb->ptr;
-	do {
-		flat_read_chunk(inb, &cells[0], 4 * sizeof(cell_t));
-		if (cells[2] == 0 && cells[3] == 0) {
-			done = 1;
-		} else {
-			++len;
-		}
-	} while (!done);
+	while (1) {
+		flat_read_chunk(inb, &re, sizeof(re));
+		if (re.size == 0)
+			break;
 
-	/*
-	 * Back up for pass two, reading the whole data value.
-	 */
-	inb->ptr = p;
-	d = flat_read_data(inb, len * 4 * sizeof(cell_t));
+		d = data_append_data(d, &re, sizeof(re));
+	}
 
 	return d;
 }
diff --git a/treesource.c b/treesource.c
index 14e9e27..a568bf7 100644
--- a/treesource.c
+++ b/treesource.c
@@ -168,8 +168,9 @@ void write_tree_source(FILE *f, struct boot_info *bi)
 					    bi->mem_reserve_data.val) + i;
 
 		fprintf(f, "/memreserve/\t%016llx-%016llx;\n",
-			(unsigned long long)re->address,
-			(unsigned long long)re->address + re->size - 1);
+			(unsigned long long)be64_to_cpu(re->address),
+			(unsigned long long)(be64_to_cpu(re->address)
+					     + be64_to_cpu(re->size) - 1));
 	}
 
 	write_tree_source_node(f, bi->dt, 0);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git



More information about the Crosstoolchain-logs mailing list