summaryrefslogtreecommitdiff
path: root/flattree.c
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2007-11-28 10:21:12 -0600
committerJon Loeliger <jdl@freescale.com>2007-12-04 07:26:47 -0600
commit2b7dc8dce549ad72ad437b254bf756d7ba4c2a5a (patch)
tree283f79de68c8ce5d2ee125780372eea046e7bcd2 /flattree.c
parent7c44c2f9cb1cc2df7aacd13decfc4e64b73d1730 (diff)
downloaddtc-2b7dc8dce549ad72ad437b254bf756d7ba4c2a5a.tar.gz
Add an option to pad the blob that is generated
There are times when we need extra space in the blob and just want to have it added on w/o know the exact size to make it. The padding and min size options are mutually exclusive. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'flattree.c')
-rw-r--r--flattree.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/flattree.c b/flattree.c
index c1032d1..c860b63 100644
--- a/flattree.c
+++ b/flattree.c
@@ -367,7 +367,7 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version,
struct data dtbuf = empty_data;
struct data strbuf = empty_data;
struct fdt_header fdt;
- int padlen;
+ int padlen = 0;
for (i = 0; i < ARRAY_SIZE(version_table); i++) {
if (version_table[i].version == version)
@@ -388,16 +388,17 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version,
/*
* If the user asked for more space than is used, adjust the totalsize.
*/
- padlen = minsize - be32_to_cpu(fdt.totalsize);
- if (padlen > 0) {
- fdt.totalsize = cpu_to_be32(minsize);
- } else {
- if ((minsize > 0) && (quiet < 1))
+ if (minsize > 0) {
+ padlen = minsize - be32_to_cpu(fdt.totalsize);
+ if ((padlen < 0) && (quiet < 1))
fprintf(stderr,
"Warning: blob size %d >= minimum size %d\n",
be32_to_cpu(fdt.totalsize), minsize);
}
+ if (padsize > 0)
+ padlen = padsize;
+
/*
* Assemble the blob: start with the header, add with alignment
* the reserve buffer, add the reserve map terminating zeroes,
@@ -414,8 +415,10 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version,
* If the user asked for more space than is used, pad out the blob.
*/
if (padlen > 0) {
+ int tsize = be32_to_cpu(fdt.totalsize);
+ tsize += padlen;
blob = data_append_zeroes(blob, padlen);
- fdt.totalsize = cpu_to_be32(minsize);
+ fdt.totalsize = cpu_to_be32(tsize);
}
fwrite(blob.val, blob.len, 1, f);
@@ -545,6 +548,9 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version, int boot_cpuid_phys)
fprintf(f, "\t.space\t%d - (_%s_blob_end - _%s_blob_start), 0\n",
minsize, symprefix, symprefix);
}
+ if (padsize > 0) {
+ fprintf(f, "\t.space\t%d, 0\n", padsize);
+ }
emit_label(f, symprefix, "blob_abs_end");
data_free(strbuf);