Improve options, #define default version.
Add -h option for help Add -q quiet option to reduce or suppress the whining Create #define for the default version value. Signed-off-by: vanbaren@cideas.com <vanbaren@cideas.com>main
parent
b299ac76a7
commit
cd1da87116
23
dtc.c
23
dtc.c
|
@ -81,6 +81,10 @@ static void usage(void)
|
||||||
fprintf(stderr, "Usage:\n");
|
fprintf(stderr, "Usage:\n");
|
||||||
fprintf(stderr, "\tdtc [options] <input file>\n");
|
fprintf(stderr, "\tdtc [options] <input file>\n");
|
||||||
fprintf(stderr, "\nOptions:\n");
|
fprintf(stderr, "\nOptions:\n");
|
||||||
|
fprintf(stderr, "\t-h\n");
|
||||||
|
fprintf(stderr, "\t\tThis help text\n");
|
||||||
|
fprintf(stderr, "\t-q\n");
|
||||||
|
fprintf(stderr, "\t\tQuiet: -q suppress warnings, -qq errors, -qqq all\n");
|
||||||
fprintf(stderr, "\t-I <input format>\n");
|
fprintf(stderr, "\t-I <input format>\n");
|
||||||
fprintf(stderr, "\t\tInput formats are:\n");
|
fprintf(stderr, "\t\tInput formats are:\n");
|
||||||
fprintf(stderr, "\t\t\tdts - device tree source text\n");
|
fprintf(stderr, "\t\t\tdts - device tree source text\n");
|
||||||
|
@ -92,7 +96,7 @@ static void usage(void)
|
||||||
fprintf(stderr, "\t\t\tdtb - device tree blob\n");
|
fprintf(stderr, "\t\t\tdtb - device tree blob\n");
|
||||||
fprintf(stderr, "\t\t\tasm - assembler source\n");
|
fprintf(stderr, "\t\t\tasm - assembler source\n");
|
||||||
fprintf(stderr, "\t-V <output version>\n");
|
fprintf(stderr, "\t-V <output version>\n");
|
||||||
fprintf(stderr, "\t\tBlob version to produce, defaults to 16 (relevant for dtb\n\t\tand asm output only)\n");
|
fprintf(stderr, "\t\tBlob version to produce, defaults to %d (relevant for dtb\n\t\tand asm output only)\n", OF_DEFAULT_VERSION);
|
||||||
fprintf(stderr, "\t-R <number>\n");
|
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");
|
fprintf(stderr, "\t\tMake space for <number> reserve map entries (relevant for \n\t\tdtb and asm output only)\n");
|
||||||
fprintf(stderr, "\t-b <number>\n");
|
fprintf(stderr, "\t-b <number>\n");
|
||||||
|
@ -113,11 +117,13 @@ int main(int argc, char *argv[])
|
||||||
int opt;
|
int opt;
|
||||||
FILE *inf = NULL;
|
FILE *inf = NULL;
|
||||||
FILE *outf = NULL;
|
FILE *outf = NULL;
|
||||||
int outversion = 17;
|
int outversion = OF_DEFAULT_VERSION;
|
||||||
int reservenum = 1;
|
int reservenum = 1;
|
||||||
int boot_cpuid_phys = 0xfeedbeef;
|
int boot_cpuid_phys = 0xfeedbeef;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "I:O:o:V:R:fb:")) != EOF) {
|
quiet = 0;
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "hI:O:o:V:R:fqb:")) != EOF) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'I':
|
case 'I':
|
||||||
inform = optarg;
|
inform = optarg;
|
||||||
|
@ -137,9 +143,13 @@ int main(int argc, char *argv[])
|
||||||
case 'f':
|
case 'f':
|
||||||
force = 1;
|
force = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'q':
|
||||||
|
quiet++;
|
||||||
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
boot_cpuid_phys = strtol(optarg, NULL, 0);
|
boot_cpuid_phys = strtol(optarg, NULL, 0);
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
@ -174,9 +184,12 @@ int main(int argc, char *argv[])
|
||||||
die("Couldn't read input tree\n");
|
die("Couldn't read input tree\n");
|
||||||
|
|
||||||
if (! check_device_tree(bi->dt, outversion, boot_cpuid_phys)) {
|
if (! check_device_tree(bi->dt, outversion, boot_cpuid_phys)) {
|
||||||
fprintf(stderr, "Input tree has errors\n");
|
if ((force) && (quiet < 3))
|
||||||
if (! force)
|
fprintf(stderr, "Input tree has errors, output forced\n");
|
||||||
|
if (! force) {
|
||||||
|
fprintf(stderr, "Input tree has errors, not writing output (use -f to force output)\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streq(outname, "-")) {
|
if (streq(outname, "-")) {
|
||||||
|
|
5
dtc.h
5
dtc.h
|
@ -36,6 +36,11 @@
|
||||||
|
|
||||||
#include "flat_dt.h"
|
#include "flat_dt.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Level of quietness
|
||||||
|
*/
|
||||||
|
int quiet;
|
||||||
|
|
||||||
static inline void die(char * str, ...)
|
static inline void die(char * str, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#define _FLAT_DT_H_
|
#define _FLAT_DT_H_
|
||||||
|
|
||||||
|
|
||||||
|
#define OF_DEFAULT_VERSION 17
|
||||||
|
|
||||||
#define OF_DT_HEADER 0xd00dfeed /* 4: version, 4: total size */
|
#define OF_DT_HEADER 0xd00dfeed /* 4: version, 4: total size */
|
||||||
|
|
||||||
#define OF_DT_BEGIN_NODE 0x1 /* Start node: full name */
|
#define OF_DT_BEGIN_NODE 0x1 /* Start node: full name */
|
||||||
|
|
|
@ -252,8 +252,8 @@ static struct node *get_node_by_phandle(struct node *tree, cell_t phandle)
|
||||||
* Tree checking functions
|
* Tree checking functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ERRMSG(...) fprintf(stderr, "ERROR: " __VA_ARGS__)
|
#define ERRMSG(...) if (quiet < 2) fprintf(stderr, "ERROR: " __VA_ARGS__)
|
||||||
#define WARNMSG(...) fprintf(stderr, "Warning: " __VA_ARGS__)
|
#define WARNMSG(...) if (quiet < 1) fprintf(stderr, "Warning: " __VA_ARGS__)
|
||||||
|
|
||||||
static int must_be_one_cell(struct property *prop, struct node *node)
|
static int must_be_one_cell(struct property *prop, struct node *node)
|
||||||
{
|
{
|
||||||
|
@ -512,13 +512,14 @@ static int check_cpus(struct node *root, int outversion, int boot_cpuid_phys)
|
||||||
char *eptr;
|
char *eptr;
|
||||||
|
|
||||||
unitnum = strtol(get_unitname(cpu), &eptr, 16);
|
unitnum = strtol(get_unitname(cpu), &eptr, 16);
|
||||||
if (*eptr)
|
if (*eptr) {
|
||||||
WARNMSG("%s has bad format unit name %s (should be CPU number\n",
|
WARNMSG("%s has bad format unit name %s (should be CPU number\n",
|
||||||
cpu->fullpath, get_unitname(cpu));
|
cpu->fullpath, get_unitname(cpu));
|
||||||
else if (unitnum != propval_cell(prop))
|
} else if (unitnum != propval_cell(prop)) {
|
||||||
WARNMSG("%s unit name \"%s\" does not match \"reg\" property <%x>\n",
|
WARNMSG("%s unit name \"%s\" does not match \"reg\" property <%x>\n",
|
||||||
cpu->fullpath, get_unitname(cpu),
|
cpu->fullpath, get_unitname(cpu),
|
||||||
propval_cell(prop));
|
propval_cell(prop));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CHECK_HAVE_ONECELL(cpu, "d-cache-line-size"); */
|
/* CHECK_HAVE_ONECELL(cpu, "d-cache-line-size"); */
|
||||||
|
|
Loading…
Reference in New Issue