Fix reserve map output for asm format.
PATCH 1/1 Fix reserve map output for asm format.
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).
---
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(-)
dtc.h +2 -2
@@ -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; }
flattree.c +11 -3
@@ -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))
Signature · 1 line
1.4.4.4
Quoted 28 lines · Jerry Van Baren
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 <[email protected]>---
Hi Jon:
Some simple fixes for handling extra reserve slots and extra space in the blob.
Best regards,
gvbdtc.h | 4 ++-- flattree.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-)dtc.h +0
-0@@ -55,10 +55,10 @@ static inline void die(char * str, ...)static inline void *xmalloc (size_t len)
dtc.h static inline void die(char * str, ...) · line 64
Quoted 10 lines
dtc.h +2
-2{ -void *new =malloc (len); +void *new =calloc (len,1 );if (! new) -die ("malloc() failed\n" ); +die ("calloc() failed\n" );return new; }
I'm less that thrilled about this change. There's a semi-standard definition of "xmalloc()" and using callc() isn't it. I'd prefer the clearing was done in the caller.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson