All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerry Van Baren <gvb.uboot@gmail.com>
To: linuxppc-dev@ozlabs.org, jdl@jdl.com
Subject: [PATCH dtc] Fix reserve map output for asm format.
Date: Sat, 14 Apr 2007 18:15:27 -0400	[thread overview]
Message-ID: <20070414221526.GA23870@dellserver.lan> (raw)

Add extra reserve map slots output for asm format (previously done for dtb
  output).
Use cmalloc to pre-zero memory (for dtb input) and handle dtb (binary)
  input being shorter than the total blob length (result of putting
  extra space in the blob).

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
---

Hi Jon:

Some simple fixes for handling extra reserve slots and extra space in
the blob.

Best regards,
gvb

 dtc.h      |    4 ++--
 flattree.c |   14 +++++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/dtc.h b/dtc.h
index 8cfe1a1..e77f9d1 100644
--- a/dtc.h
+++ b/dtc.h
@@ -55,10 +55,10 @@ static inline void die(char * str, ...)
 
 static inline void *xmalloc(size_t len)
 {
-	void *new = malloc(len);
+	void *new = calloc(len, 1);
 
 	if (! new)
-		die("malloc() failed\n");
+		die("calloc() failed\n");
 
 	return new;
 }
diff --git a/flattree.c b/flattree.c
index 151d16e..6f0c9b7 100644
--- a/flattree.c
+++ b/flattree.c
@@ -21,6 +21,9 @@
 #include "dtc.h"
 #include "flat_dt.h"
 
+#define WARNMSG(...) if (quiet < 1) fprintf(stderr, "Warning: " __VA_ARGS__)
+
+
 #define FTF_FULLPATH	0x1
 #define FTF_VARALIGN	0x2
 #define FTF_NAMEPROPS	0x4
@@ -490,6 +493,9 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version, int boot_cpuid_phys)
 			(unsigned int)(re->re.size >> 32),
 			(unsigned int)(re->re.size & 0xffffffff));
 	}
+	for (i = 0; i < reservenum; i++) {
+		fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
+	}
 
 	fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
 
@@ -818,9 +824,11 @@ struct boot_info *dt_from_blob(FILE *f)
 	p = blob + sizeof(magic)  + sizeof(totalsize);
 
 	while (sizeleft) {
-		if (feof(f))
-			die("EOF before reading %d bytes of DT blob\n",
-			    totalsize);
+		if (feof(f)) {
+			WARNMSG("EOF after reading %d of %d bytes of DT blob, assuming there is extra space in the blob.\n",
+			    totalsize - sizeleft, totalsize);
+			break;
+		}
 
 		rc = fread(p, 1, sizeleft, f);
 		if (ferror(f))
-- 
1.4.4.4

             reply	other threads:[~2007-04-14 22:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-14 22:15 Jerry Van Baren [this message]
2007-04-15  0:44 ` [PATCH dtc] Fix reserve map output for asm format David Gibson

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=20070414221526.GA23870@dellserver.lan \
    --to=gvb.uboot@gmail.com \
    --cc=jdl@jdl.com \
    --cc=linuxppc-dev@ozlabs.org \
    /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.