@ -47,55 +47,60 @@ static void fill_fullpaths(struct node *tree, const char *prefix)
fill_fullpaths(child, tree->fullpath);
fill_fullpaths(child, tree->fullpath);
}
}
static void __attribute__ ((noreturn)) usage(void)
/* Usage related data. */
{
static const char usage_synopsis[] = "dtc [options] <input file>";
fprintf(stderr, "Usage:\n");
static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv";
fprintf(stderr, "\tdtc [options] <input file>\n");
static struct option const usage_long_opts[] = {
fprintf(stderr, "\nOptions:\n");
{"quiet", no_argument, NULL, 'q'},
fprintf(stderr, "\t-h\n");
{"in-format", a_argument, NULL, 'I'},
fprintf(stderr, "\t\tThis help text\n");
{"out", a_argument, NULL, 'o'},
fprintf(stderr, "\t-q\n");
{"out-format", a_argument, NULL, 'O'},
fprintf(stderr, "\t\tQuiet: -q suppress warnings, -qq errors, -qqq all\n");
{"out-version", a_argument, NULL, 'V'},
fprintf(stderr, "\t-I <input format>\n");
{"out-dependency", a_argument, NULL, 'd'},
fprintf(stderr, "\t\tInput formats are:\n");
{"reserve", a_argument, NULL, 'R'},
fprintf(stderr, "\t\t\tdts - device tree source text\n");
{"space", a_argument, NULL, 'S'},
fprintf(stderr, "\t\t\tdtb - device tree blob\n");
{"pad", a_argument, NULL, 'p'},
fprintf(stderr, "\t\t\tfs - /proc/device-tree style directory\n");
{"boot-cpu", a_argument, NULL, 'b'},
fprintf(stderr, "\t-o <output file>\n");
{"force", no_argument, NULL, 'f'},
fprintf(stderr, "\t-O <output format>\n");
{"include", a_argument, NULL, 'i'},
fprintf(stderr, "\t\tOutput formats are:\n");
{"sort", no_argument, NULL, 's'},
fprintf(stderr, "\t\t\tdts - device tree source text\n");
{"phandle", a_argument, NULL, 'H'},
fprintf(stderr, "\t\t\tdtb - device tree blob\n");
{"warning", a_argument, NULL, 'W'},
fprintf(stderr, "\t\t\tasm - assembler source\n");
{"error", a_argument, NULL, 'E'},
fprintf(stderr, "\t-V <output version>\n");
{"help", no_argument, NULL, 'h'},
fprintf(stderr, "\t\tBlob version to produce, defaults to %d (relevant for dtb\n\t\tand asm output only)\n", DEFAULT_FDT_VERSION);
{"version", no_argument, NULL, 'v'},
fprintf(stderr, "\t-d <output dependency file>\n");
{NULL, no_argument, NULL, 0x0},
fprintf(stderr, "\t-R <number>\n");
};
fprintf(stderr, "\t\tMake space for <number> reserve map entries (relevant for \n\t\tdtb and asm output only)\n");
static const char * const usage_opts_help[] = {
fprintf(stderr, "\t-S <bytes>\n");
"\n\tQuiet: -q suppress warnings, -qq errors, -qqq all",
fprintf(stderr, "\t\tMake the blob at least <bytes> long (extra space)\n");
"\n\tInput formats are:\n"
fprintf(stderr, "\t-p <bytes>\n");
"\t\tdts - device tree source text\n"
fprintf(stderr, "\t\tAdd padding to the blob of <bytes> long (extra space)\n");
"\t\tdtb - device tree blob\n"
fprintf(stderr, "\t-b <number>\n");
"\t\tfs - /proc/device-tree style directory",
fprintf(stderr, "\t\tSet the physical boot cpu\n");
"\n\tOutput file",
fprintf(stderr, "\t-f\n");
"\n\tOutput formats are:\n"
fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n");
"\t\tdts - device tree source text\n"
fprintf(stderr, "\t-i\n");
"\t\tdtb - device tree blob\n"
fprintf(stderr, "\t\tAdd a path to search for include files\n");
"\t\tasm - assembler source",
fprintf(stderr, "\t-s\n");
"\n\tBlob version to produce, defaults to %d (for dtb and asm output)", //, DEFAULT_FDT_VERSION);
fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n");
"\n\tOutput dependency file",
fprintf(stderr, "\t-v\n");
"\n\ttMake space for <number> reserve map entries (for dtb and asm output)",
fprintf(stderr, "\t\tPrint DTC version and exit\n");
"\n\tMake the blob at least <bytes> long (extra space)",
fprintf(stderr, "\t-H <phandle format>\n");
"\n\tAdd padding to the blob of <bytes> long (extra space)",
fprintf(stderr, "\t\tphandle formats are:\n");
"\n\tSet the physical boot cpu",
fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n");
"\n\tTry to produce output even if the input tree has errors",
fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n");
"\n\tAdd a path to search for include files",
fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n");
"\n\tSort nodes and properties before outputting (useful for comparing trees)",
fprintf(stderr, "\t-W [no-]<checkname>\n");
"\n\tValid phandle formats are:\n"
fprintf(stderr, "\t-E [no-]<checkname>\n");
"\t\tlegacy - \"linux,phandle\" properties only\n"
fprintf(stderr, "\t\t\tenable or disable warnings and errors\n");
"\t\tepapr - \"phandle\" properties only\n"
exit(3);
"\t\tboth - Both \"linux,phandle\" and \"phandle\" properties",
}
"\n\tEnable/disable warnings (prefix with \"no-\")",
"\n\tEnable/disable errors (prefix with \"no-\")",
"\n\tPrint this help and exit",
"\n\tPrint version and exit",
NULL,
};
int main(int argc, char *argv[])
int main(int argc, char *argv[])
{
{
@ -116,8 +121,7 @@ int main(int argc, char *argv[])
minsize = 0;
minsize = 0;
padsize = 0;
padsize = 0;
while ((opt = getopt(argc, argv, "hI:O:o:V:d:R:S:p:fqb:i:vH:sW:E:"))
while ((opt = util_getopt_long()) != EOF) {
!= EOF) {
switch (opt) {
switch (opt) {
case 'I':
case 'I':
inform = optarg;
inform = optarg;
@ -182,13 +186,14 @@ int main(int argc, char *argv[])
break;
break;
case 'h':
case 'h':
long_usage(NULL);
default:
default:
usage();
long_usage("unknown option");
}
}
}
}
if (argc > (optind+1))
if (argc > (optind+1))
usage();
long_usage("missing files");
else if (argc < (optind+1))
else if (argc < (optind+1))
arg = "-";
arg = "-";
else
else