aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dtc/dtc.c
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2017-01-04 11:45:20 -0500
committerRob Herring <robh@kernel.org>2017-01-04 11:47:53 -0500
commit6f05afcbb031722ec1eff77dde188ff2edf8940e (patch)
tree495052132dcba998f88e38d128d9781adfdc9272 /scripts/dtc/dtc.c
parent0c744ea4f77d72b3dcebb7a8f2684633ec79be88 (diff)
scripts/dtc: Update to upstream version 0931cea3ba20
Sync to upstream dtc commit 0931cea3ba20 ("dtc: fdtdump: check fdt if not in scanning mode"). In particular, this pulls in dtc overlay support. This adds the following commits from upstream: f88865469b65 dtc: Fix memory leak in character literal parsing 00fbb8696b66 Rename boot_info 1ef86ad2c24f dtc: Clean up /dts-v1/ and /plugin/ handling in grammar e3c769aa9c16 dtc: Don't always generate __symbols__ for plugins c96cb3c0169e tests: Don't use -@ on plugin de/recompile tests 66381538ce24 tests: Remove "suppression of fixups" tests ba765b273f0f tests: Clarify dtc overlay tests 6ea8cd944fcd tests: More thorough tests of libfdt overlay application without dtc 7d8ef6e1db97 tests: Correct fdt handling of overlays without fixups and base trees without symbols b4dc0ed8b127 tests: Fix double expansion bugs in test code 3ea879dc0c8f tests: Split overlay tests into those with do/don't exercise dtc plugin generation 47b4d66a2f11 tests: Test auto-alias generation on base tree, not overlay 72e1ad811523 tests: Make overlay/plugin tests unconditional e7b3c3b5951b tests: Add overlay tests 9637e3f772a9 tests: Add check_path test 20f29d8d41f6 dtc: Plugin and fixup support a2c92cac53f8 dtc: Document the dynamic plugin internals 8f70ac39801d checks: Pass boot_info instead of root node ea10f953878f libfdt: add missing errors to fdt_strerror() daa75e8fa594 libfdt: fix fdt_stringlist_search() e28eff5b787a libfdt: fix fdt_stringlist_count() ae97c7722840 tests: overlay: Rename the device tree blobs to be more explicit 96162d2bd9cb tests: overlay: Add test suffix to the compiled blobs 5ce8634733b7 libfdt: Add fdt_overlay_apply to the exported symbols 804a9db90ad2 fdt: strerr: Remove spurious BADOVERLAY e8c3a1a493fa tests: overlay: Move back the bad fixup tests 7a72d89d3f81 libfdt: overlay: Fix symbols and fixups nodes condition cabbaa972cdd libfdt: overlay: Report a bad overlay for mismatching local fixups deb0a5c1aeaa libfdt: Add BADPHANDLE error string 7b7a6be9ba15 libfdt: Don't use 'index' as a local variable name aea8860d831e tests: Add tests cases for the overlay code 0cdd06c5135b libfdt: Add overlay application function 39240cc865cf libfdt: Extend the reach of FDT_ERR_BADPHANDLE 4aa3a6f5e6d9 libfdt: Add new errors for the overlay code 6d1832c9e64b dtc: Remove "home page" link 45fd440a9561 Fix some typing errors in libfdt.h and livetree.c a59be4939c13 Merge tag 'v1.4.2' a34bb721caca dtc: Fix assorted problems in the testcases for the -a option 874f40588d3e Implement the -a option to pad dtb aligned ec02b34c05be dtc: Makefile improvements for release uploading 1ed45d40a137 dtc: Bump version to 1.4.2 36fd7331fb11 libfdt: simplify fdt_del_mem_rsv() d877364e4a0f libfdt: Add fdt_setprop_inplace_namelen_partial 3e9037aaad44 libfdt: Add fdt_getprop_namelen_w 84e0e1346c68 libfdt: Add max phandle retrieval function d29126c90acb libfdt: Add iterator over properties 902d0f0953d0 libfdt: Add a subnodes iterator macro c539075ba8ba fdtput.c: Fix memory leak. f79ddb83e185 fdtget.c: Fix memory leak 1074ee54b63f convert-dtsv0-lexer.l: fix memory leak e24d39a024e6 fdtdump.c: make sure size_t argument to memchr is always unsigned. 44a59713cf05 Remove unused srcpos_dump() function cb9241ae3453 DTC: Fix memory leak on flatname. 1ee0ae24ea09 Simplify check field and macro names 9d97527a8621 Remove property check functions 2e709d158e11 Remove tree check functions c4cb12e193e3 Alter grammar to allow multiple /dts-v1/ tags d71d25d76012 Use xasprintf() in srcpos 9dc404958e9c util: Add xasprintf portable asprintf variant beef80b8b55f Correct a missing space in a fdt_header cast 68d43cec1253 Correct line lengths in libfdt.h b0dbceafd49a Correct space-after-tab in libfdt.h Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'scripts/dtc/dtc.c')
-rw-r--r--scripts/dtc/dtc.c69
1 files changed, 57 insertions, 12 deletions
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c
index 5fa23c406266..a4edf4c7aebf 100644
--- a/scripts/dtc/dtc.c
+++ b/scripts/dtc/dtc.c
@@ -30,7 +30,16 @@ int quiet; /* Level of quietness */
30int reservenum; /* Number of memory reservation slots */ 30int reservenum; /* Number of memory reservation slots */
31int minsize; /* Minimum blob size */ 31int minsize; /* Minimum blob size */
32int padsize; /* Additional padding to blob */ 32int padsize; /* Additional padding to blob */
33int alignsize; /* Additional padding to blob accroding to the alignsize */
33int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */ 34int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */
35int generate_symbols; /* enable symbols & fixup support */
36int generate_fixups; /* suppress generation of fixups on symbol support */
37int auto_label_aliases; /* auto generate labels -> aliases */
38
39static int is_power_of_2(int x)
40{
41 return (x > 0) && ((x & (x - 1)) == 0);
42}
34 43
35static void fill_fullpaths(struct node *tree, const char *prefix) 44static void fill_fullpaths(struct node *tree, const char *prefix)
36{ 45{
@@ -53,7 +62,7 @@ static void fill_fullpaths(struct node *tree, const char *prefix)
53#define FDT_VERSION(version) _FDT_VERSION(version) 62#define FDT_VERSION(version) _FDT_VERSION(version)
54#define _FDT_VERSION(version) #version 63#define _FDT_VERSION(version) #version
55static const char usage_synopsis[] = "dtc [options] <input file>"; 64static const char usage_synopsis[] = "dtc [options] <input file>";
56static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv"; 65static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@Ahv";
57static struct option const usage_long_opts[] = { 66static struct option const usage_long_opts[] = {
58 {"quiet", no_argument, NULL, 'q'}, 67 {"quiet", no_argument, NULL, 'q'},
59 {"in-format", a_argument, NULL, 'I'}, 68 {"in-format", a_argument, NULL, 'I'},
@@ -64,6 +73,7 @@ static struct option const usage_long_opts[] = {
64 {"reserve", a_argument, NULL, 'R'}, 73 {"reserve", a_argument, NULL, 'R'},
65 {"space", a_argument, NULL, 'S'}, 74 {"space", a_argument, NULL, 'S'},
66 {"pad", a_argument, NULL, 'p'}, 75 {"pad", a_argument, NULL, 'p'},
76 {"align", a_argument, NULL, 'a'},
67 {"boot-cpu", a_argument, NULL, 'b'}, 77 {"boot-cpu", a_argument, NULL, 'b'},
68 {"force", no_argument, NULL, 'f'}, 78 {"force", no_argument, NULL, 'f'},
69 {"include", a_argument, NULL, 'i'}, 79 {"include", a_argument, NULL, 'i'},
@@ -71,6 +81,8 @@ static struct option const usage_long_opts[] = {
71 {"phandle", a_argument, NULL, 'H'}, 81 {"phandle", a_argument, NULL, 'H'},
72 {"warning", a_argument, NULL, 'W'}, 82 {"warning", a_argument, NULL, 'W'},
73 {"error", a_argument, NULL, 'E'}, 83 {"error", a_argument, NULL, 'E'},
84 {"symbols", no_argument, NULL, '@'},
85 {"auto-alias", no_argument, NULL, 'A'},
74 {"help", no_argument, NULL, 'h'}, 86 {"help", no_argument, NULL, 'h'},
75 {"version", no_argument, NULL, 'v'}, 87 {"version", no_argument, NULL, 'v'},
76 {NULL, no_argument, NULL, 0x0}, 88 {NULL, no_argument, NULL, 0x0},
@@ -91,6 +103,7 @@ static const char * const usage_opts_help[] = {
91 "\n\tMake space for <number> reserve map entries (for dtb and asm output)", 103 "\n\tMake space for <number> reserve map entries (for dtb and asm output)",
92 "\n\tMake the blob at least <bytes> long (extra space)", 104 "\n\tMake the blob at least <bytes> long (extra space)",
93 "\n\tAdd padding to the blob of <bytes> long (extra space)", 105 "\n\tAdd padding to the blob of <bytes> long (extra space)",
106 "\n\tMake the blob align to the <bytes> (extra space)",
94 "\n\tSet the physical boot cpu", 107 "\n\tSet the physical boot cpu",
95 "\n\tTry to produce output even if the input tree has errors", 108 "\n\tTry to produce output even if the input tree has errors",
96 "\n\tAdd a path to search for include files", 109 "\n\tAdd a path to search for include files",
@@ -101,6 +114,8 @@ static const char * const usage_opts_help[] = {
101 "\t\tboth - Both \"linux,phandle\" and \"phandle\" properties", 114 "\t\tboth - Both \"linux,phandle\" and \"phandle\" properties",
102 "\n\tEnable/disable warnings (prefix with \"no-\")", 115 "\n\tEnable/disable warnings (prefix with \"no-\")",
103 "\n\tEnable/disable errors (prefix with \"no-\")", 116 "\n\tEnable/disable errors (prefix with \"no-\")",
117 "\n\tEnable generation of symbols",
118 "\n\tEnable auto-alias of labels",
104 "\n\tPrint this help and exit", 119 "\n\tPrint this help and exit",
105 "\n\tPrint version and exit", 120 "\n\tPrint version and exit",
106 NULL, 121 NULL,
@@ -153,7 +168,7 @@ static const char *guess_input_format(const char *fname, const char *fallback)
153 168
154int main(int argc, char *argv[]) 169int main(int argc, char *argv[])
155{ 170{
156 struct boot_info *bi; 171 struct dt_info *dti;
157 const char *inform = NULL; 172 const char *inform = NULL;
158 const char *outform = NULL; 173 const char *outform = NULL;
159 const char *outname = "-"; 174 const char *outname = "-";
@@ -169,6 +184,7 @@ int main(int argc, char *argv[])
169 reservenum = 0; 184 reservenum = 0;
170 minsize = 0; 185 minsize = 0;
171 padsize = 0; 186 padsize = 0;
187 alignsize = 0;
172 188
173 while ((opt = util_getopt_long()) != EOF) { 189 while ((opt = util_getopt_long()) != EOF) {
174 switch (opt) { 190 switch (opt) {
@@ -196,6 +212,12 @@ int main(int argc, char *argv[])
196 case 'p': 212 case 'p':
197 padsize = strtol(optarg, NULL, 0); 213 padsize = strtol(optarg, NULL, 0);
198 break; 214 break;
215 case 'a':
216 alignsize = strtol(optarg, NULL, 0);
217 if (!is_power_of_2(alignsize))
218 die("Invalid argument \"%d\" to -a option\n",
219 optarg);
220 break;
199 case 'f': 221 case 'f':
200 force = true; 222 force = true;
201 break; 223 break;
@@ -234,6 +256,13 @@ int main(int argc, char *argv[])
234 parse_checks_option(false, true, optarg); 256 parse_checks_option(false, true, optarg);
235 break; 257 break;
236 258
259 case '@':
260 generate_symbols = 1;
261 break;
262 case 'A':
263 auto_label_aliases = 1;
264 break;
265
237 case 'h': 266 case 'h':
238 usage(NULL); 267 usage(NULL);
239 default: 268 default:
@@ -272,11 +301,11 @@ int main(int argc, char *argv[])
272 } 301 }
273 } 302 }
274 if (streq(inform, "dts")) 303 if (streq(inform, "dts"))
275 bi = dt_from_source(arg); 304 dti = dt_from_source(arg);
276 else if (streq(inform, "fs")) 305 else if (streq(inform, "fs"))
277 bi = dt_from_fs(arg); 306 dti = dt_from_fs(arg);
278 else if(streq(inform, "dtb")) 307 else if(streq(inform, "dtb"))
279 bi = dt_from_blob(arg); 308 dti = dt_from_blob(arg);
280 else 309 else
281 die("Unknown input format \"%s\"\n", inform); 310 die("Unknown input format \"%s\"\n", inform);
282 311
@@ -286,13 +315,29 @@ int main(int argc, char *argv[])
286 } 315 }
287 316
288 if (cmdline_boot_cpuid != -1) 317 if (cmdline_boot_cpuid != -1)
289 bi->boot_cpuid_phys = cmdline_boot_cpuid; 318 dti->boot_cpuid_phys = cmdline_boot_cpuid;
319
320 fill_fullpaths(dti->dt, "");
321 process_checks(force, dti);
322
323 /* on a plugin, generate by default */
324 if (dti->dtsflags & DTSF_PLUGIN) {
325 generate_fixups = 1;
326 }
290 327
291 fill_fullpaths(bi->dt, ""); 328 if (auto_label_aliases)
292 process_checks(force, bi); 329 generate_label_tree(dti, "aliases", false);
330
331 if (generate_symbols)
332 generate_label_tree(dti, "__symbols__", true);
333
334 if (generate_fixups) {
335 generate_fixups_tree(dti, "__fixups__");
336 generate_local_fixups_tree(dti, "__local_fixups__");
337 }
293 338
294 if (sort) 339 if (sort)
295 sort_tree(bi); 340 sort_tree(dti);
296 341
297 if (streq(outname, "-")) { 342 if (streq(outname, "-")) {
298 outf = stdout; 343 outf = stdout;
@@ -304,11 +349,11 @@ int main(int argc, char *argv[])
304 } 349 }
305 350
306 if (streq(outform, "dts")) { 351 if (streq(outform, "dts")) {
307 dt_to_source(outf, bi); 352 dt_to_source(outf, dti);
308 } else if (streq(outform, "dtb")) { 353 } else if (streq(outform, "dtb")) {
309 dt_to_blob(outf, bi, outversion); 354 dt_to_blob(outf, dti, outversion);
310 } else if (streq(outform, "asm")) { 355 } else if (streq(outform, "asm")) {
311 dt_to_asm(outf, bi, outversion); 356 dt_to_asm(outf, dti, outversion);
312 } else if (streq(outform, "null")) { 357 } else if (streq(outform, "null")) {
313 /* do nothing */ 358 /* do nothing */
314 } else { 359 } else {