Rename boot_info

struct boot_info is named that for historical reasons, and isn't
particularly meaningful.  Essentially it contains all the information -
in "live" form from a single dts or dtb file.  As we move towards support
for dynamic dt overlays, that name will become increasingly bad.

So, in preparation, rename it to dt_info.  At the same time rename the
'the_boot_info' global to 'parser_output' since that's its actual purpose.
Unfortunately we do need the global unless we switch to bison's re-entrant
parser extensions, which would introduce its own complications.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2016-05-31 11:58:42 +10:00
parent 1ef86ad2c2
commit 00fbb8696b
8 changed files with 147 additions and 148 deletions

View file

@ -40,7 +40,7 @@ enum checkstatus {
struct check; struct check;
typedef void (*check_fn)(struct check *c, struct boot_info *bi, struct node *node); typedef void (*check_fn)(struct check *c, struct dt_info *dti, struct node *node);
struct check { struct check {
const char *name; const char *name;
@ -97,21 +97,21 @@ static inline void check_msg(struct check *c, const char *fmt, ...)
check_msg((c), __VA_ARGS__); \ check_msg((c), __VA_ARGS__); \
} while (0) } while (0)
static void check_nodes_props(struct check *c, struct boot_info *bi, struct node *node) static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node)
{ {
struct node *child; struct node *child;
TRACE(c, "%s", node->fullpath); TRACE(c, "%s", node->fullpath);
if (c->fn) if (c->fn)
c->fn(c, bi, node); c->fn(c, dti, node);
for_each_child(node, child) for_each_child(node, child)
check_nodes_props(c, bi, child); check_nodes_props(c, dti, child);
} }
static bool run_check(struct check *c, struct boot_info *bi) static bool run_check(struct check *c, struct dt_info *dti)
{ {
struct node *dt = bi->dt; struct node *dt = dti->dt;
bool error = false; bool error = false;
int i; int i;
@ -124,7 +124,7 @@ static bool run_check(struct check *c, struct boot_info *bi)
for (i = 0; i < c->num_prereqs; i++) { for (i = 0; i < c->num_prereqs; i++) {
struct check *prq = c->prereq[i]; struct check *prq = c->prereq[i];
error = error || run_check(prq, bi); error = error || run_check(prq, dti);
if (prq->status != PASSED) { if (prq->status != PASSED) {
c->status = PREREQ; c->status = PREREQ;
check_msg(c, "Failed prerequisite '%s'", check_msg(c, "Failed prerequisite '%s'",
@ -135,7 +135,7 @@ static bool run_check(struct check *c, struct boot_info *bi)
if (c->status != UNCHECKED) if (c->status != UNCHECKED)
goto out; goto out;
check_nodes_props(c, bi, dt); check_nodes_props(c, dti, dt);
if (c->status == UNCHECKED) if (c->status == UNCHECKED)
c->status = PASSED; c->status = PASSED;
@ -154,14 +154,14 @@ out:
*/ */
/* A check which always fails, for testing purposes only */ /* A check which always fails, for testing purposes only */
static inline void check_always_fail(struct check *c, struct boot_info *bi, static inline void check_always_fail(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
FAIL(c, "always_fail check"); FAIL(c, "always_fail check");
} }
CHECK(always_fail, check_always_fail, NULL); CHECK(always_fail, check_always_fail, NULL);
static void check_is_string(struct check *c, struct boot_info *bi, static void check_is_string(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct property *prop; struct property *prop;
@ -180,7 +180,7 @@ static void check_is_string(struct check *c, struct boot_info *bi,
#define ERROR_IF_NOT_STRING(nm, propname) \ #define ERROR_IF_NOT_STRING(nm, propname) \
ERROR(nm, check_is_string, (propname)) ERROR(nm, check_is_string, (propname))
static void check_is_cell(struct check *c, struct boot_info *bi, static void check_is_cell(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct property *prop; struct property *prop;
@ -203,7 +203,7 @@ static void check_is_cell(struct check *c, struct boot_info *bi,
* Structural check functions * Structural check functions
*/ */
static void check_duplicate_node_names(struct check *c, struct boot_info *bi, static void check_duplicate_node_names(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct node *child, *child2; struct node *child, *child2;
@ -218,7 +218,7 @@ static void check_duplicate_node_names(struct check *c, struct boot_info *bi,
} }
ERROR(duplicate_node_names, check_duplicate_node_names, NULL); ERROR(duplicate_node_names, check_duplicate_node_names, NULL);
static void check_duplicate_property_names(struct check *c, struct boot_info *bi, static void check_duplicate_property_names(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct property *prop, *prop2; struct property *prop, *prop2;
@ -240,7 +240,7 @@ ERROR(duplicate_property_names, check_duplicate_property_names, NULL);
#define DIGITS "0123456789" #define DIGITS "0123456789"
#define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-" #define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-"
static void check_node_name_chars(struct check *c, struct boot_info *bi, static void check_node_name_chars(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
int n = strspn(node->name, c->data); int n = strspn(node->name, c->data);
@ -251,7 +251,7 @@ static void check_node_name_chars(struct check *c, struct boot_info *bi,
} }
ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@"); ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@");
static void check_node_name_format(struct check *c, struct boot_info *bi, static void check_node_name_format(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
if (strchr(get_unitname(node), '@')) if (strchr(get_unitname(node), '@'))
@ -260,7 +260,7 @@ static void check_node_name_format(struct check *c, struct boot_info *bi,
} }
ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars); ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars);
static void check_unit_address_vs_reg(struct check *c, struct boot_info *bi, static void check_unit_address_vs_reg(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
const char *unitname = get_unitname(node); const char *unitname = get_unitname(node);
@ -284,7 +284,7 @@ static void check_unit_address_vs_reg(struct check *c, struct boot_info *bi,
} }
WARNING(unit_address_vs_reg, check_unit_address_vs_reg, NULL); WARNING(unit_address_vs_reg, check_unit_address_vs_reg, NULL);
static void check_property_name_chars(struct check *c, struct boot_info *bi, static void check_property_name_chars(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct property *prop; struct property *prop;
@ -306,11 +306,11 @@ ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS);
((prop) ? (prop)->name : ""), \ ((prop) ? (prop)->name : ""), \
((prop) ? "' in " : ""), (node)->fullpath ((prop) ? "' in " : ""), (node)->fullpath
static void check_duplicate_label(struct check *c, struct boot_info *bi, static void check_duplicate_label(struct check *c, struct dt_info *dti,
const char *label, struct node *node, const char *label, struct node *node,
struct property *prop, struct marker *mark) struct property *prop, struct marker *mark)
{ {
struct node *dt = bi->dt; struct node *dt = dti->dt;
struct node *othernode = NULL; struct node *othernode = NULL;
struct property *otherprop = NULL; struct property *otherprop = NULL;
struct marker *othermark = NULL; struct marker *othermark = NULL;
@ -333,31 +333,31 @@ static void check_duplicate_label(struct check *c, struct boot_info *bi,
DESCLABEL_ARGS(othernode, otherprop, othermark)); DESCLABEL_ARGS(othernode, otherprop, othermark));
} }
static void check_duplicate_label_node(struct check *c, struct boot_info *bi, static void check_duplicate_label_node(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct label *l; struct label *l;
struct property *prop; struct property *prop;
for_each_label(node->labels, l) for_each_label(node->labels, l)
check_duplicate_label(c, bi, l->label, node, NULL, NULL); check_duplicate_label(c, dti, l->label, node, NULL, NULL);
for_each_property(node, prop) { for_each_property(node, prop) {
struct marker *m = prop->val.markers; struct marker *m = prop->val.markers;
for_each_label(prop->labels, l) for_each_label(prop->labels, l)
check_duplicate_label(c, bi, l->label, node, prop, NULL); check_duplicate_label(c, dti, l->label, node, prop, NULL);
for_each_marker_of_type(m, LABEL) for_each_marker_of_type(m, LABEL)
check_duplicate_label(c, bi, m->ref, node, prop, m); check_duplicate_label(c, dti, m->ref, node, prop, m);
} }
} }
ERROR(duplicate_label, check_duplicate_label_node, NULL); ERROR(duplicate_label, check_duplicate_label_node, NULL);
static cell_t check_phandle_prop(struct check *c, struct boot_info *bi, static cell_t check_phandle_prop(struct check *c, struct dt_info *dti,
struct node *node, const char *propname) struct node *node, const char *propname)
{ {
struct node *root = bi->dt; struct node *root = dti->dt;
struct property *prop; struct property *prop;
struct marker *m; struct marker *m;
cell_t phandle; cell_t phandle;
@ -401,19 +401,19 @@ static cell_t check_phandle_prop(struct check *c, struct boot_info *bi,
return phandle; return phandle;
} }
static void check_explicit_phandles(struct check *c, struct boot_info *bi, static void check_explicit_phandles(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct node *root = bi->dt; struct node *root = dti->dt;
struct node *other; struct node *other;
cell_t phandle, linux_phandle; cell_t phandle, linux_phandle;
/* Nothing should have assigned phandles yet */ /* Nothing should have assigned phandles yet */
assert(!node->phandle); assert(!node->phandle);
phandle = check_phandle_prop(c, bi, node, "phandle"); phandle = check_phandle_prop(c, dti, node, "phandle");
linux_phandle = check_phandle_prop(c, bi, node, "linux,phandle"); linux_phandle = check_phandle_prop(c, dti, node, "linux,phandle");
if (!phandle && !linux_phandle) if (!phandle && !linux_phandle)
/* No valid phandles; nothing further to check */ /* No valid phandles; nothing further to check */
@ -437,7 +437,7 @@ static void check_explicit_phandles(struct check *c, struct boot_info *bi,
} }
ERROR(explicit_phandles, check_explicit_phandles, NULL); ERROR(explicit_phandles, check_explicit_phandles, NULL);
static void check_name_properties(struct check *c, struct boot_info *bi, static void check_name_properties(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct property **pp, *prop = NULL; struct property **pp, *prop = NULL;
@ -471,10 +471,10 @@ ERROR(name_properties, check_name_properties, NULL, &name_is_string);
* Reference fixup functions * Reference fixup functions
*/ */
static void fixup_phandle_references(struct check *c, struct boot_info *bi, static void fixup_phandle_references(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct node *dt = bi->dt; struct node *dt = dti->dt;
struct property *prop; struct property *prop;
for_each_property(node, prop) { for_each_property(node, prop) {
@ -487,7 +487,7 @@ static void fixup_phandle_references(struct check *c, struct boot_info *bi,
refnode = get_node_by_ref(dt, m->ref); refnode = get_node_by_ref(dt, m->ref);
if (! refnode) { if (! refnode) {
if (!(bi->dtsflags & DTSF_PLUGIN)) if (!(dti->dtsflags & DTSF_PLUGIN))
FAIL(c, "Reference to non-existent node or " FAIL(c, "Reference to non-existent node or "
"label \"%s\"\n", m->ref); "label \"%s\"\n", m->ref);
else /* mark the entry as unresolved */ else /* mark the entry as unresolved */
@ -504,10 +504,10 @@ static void fixup_phandle_references(struct check *c, struct boot_info *bi,
ERROR(phandle_references, fixup_phandle_references, NULL, ERROR(phandle_references, fixup_phandle_references, NULL,
&duplicate_node_names, &explicit_phandles); &duplicate_node_names, &explicit_phandles);
static void fixup_path_references(struct check *c, struct boot_info *bi, static void fixup_path_references(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct node *dt = bi->dt; struct node *dt = dti->dt;
struct property *prop; struct property *prop;
for_each_property(node, prop) { for_each_property(node, prop) {
@ -544,7 +544,7 @@ WARNING_IF_NOT_STRING(device_type_is_string, "device_type");
WARNING_IF_NOT_STRING(model_is_string, "model"); WARNING_IF_NOT_STRING(model_is_string, "model");
WARNING_IF_NOT_STRING(status_is_string, "status"); WARNING_IF_NOT_STRING(status_is_string, "status");
static void fixup_addr_size_cells(struct check *c, struct boot_info *bi, static void fixup_addr_size_cells(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct property *prop; struct property *prop;
@ -568,7 +568,7 @@ WARNING(addr_size_cells, fixup_addr_size_cells, NULL,
#define node_size_cells(n) \ #define node_size_cells(n) \
(((n)->size_cells == -1) ? 1 : (n)->size_cells) (((n)->size_cells == -1) ? 1 : (n)->size_cells)
static void check_reg_format(struct check *c, struct boot_info *bi, static void check_reg_format(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct property *prop; struct property *prop;
@ -597,7 +597,7 @@ static void check_reg_format(struct check *c, struct boot_info *bi,
} }
WARNING(reg_format, check_reg_format, NULL, &addr_size_cells); WARNING(reg_format, check_reg_format, NULL, &addr_size_cells);
static void check_ranges_format(struct check *c, struct boot_info *bi, static void check_ranges_format(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct property *prop; struct property *prop;
@ -641,7 +641,7 @@ WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells);
/* /*
* Style checks * Style checks
*/ */
static void check_avoid_default_addr_size(struct check *c, struct boot_info *bi, static void check_avoid_default_addr_size(struct check *c, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct property *reg, *ranges; struct property *reg, *ranges;
@ -667,10 +667,10 @@ WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL,
&addr_size_cells); &addr_size_cells);
static void check_obsolete_chosen_interrupt_controller(struct check *c, static void check_obsolete_chosen_interrupt_controller(struct check *c,
struct boot_info *bi, struct dt_info *dti,
struct node *node) struct node *node)
{ {
struct node *dt = bi->dt; struct node *dt = dti->dt;
struct node *chosen; struct node *chosen;
struct property *prop; struct property *prop;
@ -774,7 +774,7 @@ void parse_checks_option(bool warn, bool error, const char *arg)
die("Unrecognized check name \"%s\"\n", name); die("Unrecognized check name \"%s\"\n", name);
} }
void process_checks(bool force, struct boot_info *bi) void process_checks(bool force, struct dt_info *dti)
{ {
int i; int i;
int error = 0; int error = 0;
@ -783,7 +783,7 @@ void process_checks(bool force, struct boot_info *bi)
struct check *c = check_table[i]; struct check *c = check_table[i];
if (c->warn || c->error) if (c->warn || c->error)
error = error || run_check(c, bi); error = error || run_check(c, dti);
} }
if (error) { if (error) {

View file

@ -32,7 +32,7 @@ extern void yyerror(char const *s);
treesource_error = true; \ treesource_error = true; \
} while (0) } while (0)
extern struct boot_info *the_boot_info; extern struct dt_info *parser_output;
extern bool treesource_error; extern bool treesource_error;
%} %}
@ -108,7 +108,7 @@ extern bool treesource_error;
sourcefile: sourcefile:
headers memreserves devicetree headers memreserves devicetree
{ {
the_boot_info = build_boot_info($1, $2, $3, parser_output = build_dt_info($1, $2, $3,
guess_boot_cpuid($3)); guess_boot_cpuid($3));
} }
; ;

32
dtc.c
View file

@ -168,7 +168,7 @@ static const char *guess_input_format(const char *fname, const char *fallback)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct boot_info *bi; struct dt_info *dti;
const char *inform = NULL; const char *inform = NULL;
const char *outform = NULL; const char *outform = NULL;
const char *outname = "-"; const char *outname = "-";
@ -301,11 +301,11 @@ int main(int argc, char *argv[])
} }
} }
if (streq(inform, "dts")) if (streq(inform, "dts"))
bi = dt_from_source(arg); dti = dt_from_source(arg);
else if (streq(inform, "fs")) else if (streq(inform, "fs"))
bi = dt_from_fs(arg); dti = dt_from_fs(arg);
else if(streq(inform, "dtb")) else if(streq(inform, "dtb"))
bi = dt_from_blob(arg); dti = dt_from_blob(arg);
else else
die("Unknown input format \"%s\"\n", inform); die("Unknown input format \"%s\"\n", inform);
@ -315,29 +315,29 @@ int main(int argc, char *argv[])
} }
if (cmdline_boot_cpuid != -1) if (cmdline_boot_cpuid != -1)
bi->boot_cpuid_phys = cmdline_boot_cpuid; dti->boot_cpuid_phys = cmdline_boot_cpuid;
fill_fullpaths(bi->dt, ""); fill_fullpaths(dti->dt, "");
process_checks(force, bi); process_checks(force, dti);
/* on a plugin, generate by default */ /* on a plugin, generate by default */
if (bi->dtsflags & DTSF_PLUGIN) { if (dti->dtsflags & DTSF_PLUGIN) {
generate_fixups = 1; generate_fixups = 1;
} }
if (auto_label_aliases) if (auto_label_aliases)
generate_label_tree(bi, "aliases", false); generate_label_tree(dti, "aliases", false);
if (generate_symbols) if (generate_symbols)
generate_label_tree(bi, "__symbols__", true); generate_label_tree(dti, "__symbols__", true);
if (generate_fixups) { if (generate_fixups) {
generate_fixups_tree(bi, "__fixups__"); generate_fixups_tree(dti, "__fixups__");
generate_local_fixups_tree(bi, "__local_fixups__"); generate_local_fixups_tree(dti, "__local_fixups__");
} }
if (sort) if (sort)
sort_tree(bi); sort_tree(dti);
if (streq(outname, "-")) { if (streq(outname, "-")) {
outf = stdout; outf = stdout;
@ -349,11 +349,11 @@ int main(int argc, char *argv[])
} }
if (streq(outform, "dts")) { if (streq(outform, "dts")) {
dt_to_source(outf, bi); dt_to_source(outf, dti);
} else if (streq(outform, "dtb")) { } else if (streq(outform, "dtb")) {
dt_to_blob(outf, bi, outversion); dt_to_blob(outf, dti, outversion);
} else if (streq(outform, "asm")) { } else if (streq(outform, "asm")) {
dt_to_asm(outf, bi, outversion); dt_to_asm(outf, dti, outversion);
} else if (streq(outform, "null")) { } else if (streq(outform, "null")) {
/* do nothing */ /* do nothing */
} else { } else {

28
dtc.h
View file

@ -241,44 +241,44 @@ struct reserve_info *add_reserve_entry(struct reserve_info *list,
struct reserve_info *new); struct reserve_info *new);
struct boot_info { struct dt_info {
unsigned int dtsflags; unsigned int dtsflags;
struct reserve_info *reservelist; struct reserve_info *reservelist;
struct node *dt; /* the device tree */
uint32_t boot_cpuid_phys; uint32_t boot_cpuid_phys;
struct node *dt; /* the device tree */
}; };
/* DTS version flags definitions */ /* DTS version flags definitions */
#define DTSF_V1 0x0001 /* /dts-v1/ */ #define DTSF_V1 0x0001 /* /dts-v1/ */
#define DTSF_PLUGIN 0x0002 /* /plugin/ */ #define DTSF_PLUGIN 0x0002 /* /plugin/ */
struct boot_info *build_boot_info(unsigned int dtsflags, struct dt_info *build_dt_info(unsigned int dtsflags,
struct reserve_info *reservelist, struct reserve_info *reservelist,
struct node *tree, uint32_t boot_cpuid_phys); struct node *tree, uint32_t boot_cpuid_phys);
void sort_tree(struct boot_info *bi); void sort_tree(struct dt_info *dti);
void generate_label_tree(struct boot_info *bi, char *name, bool allocph); void generate_label_tree(struct dt_info *dti, char *name, bool allocph);
void generate_fixups_tree(struct boot_info *bi, char *name); void generate_fixups_tree(struct dt_info *dti, char *name);
void generate_local_fixups_tree(struct boot_info *bi, char *name); void generate_local_fixups_tree(struct dt_info *dti, char *name);
/* Checks */ /* Checks */
void parse_checks_option(bool warn, bool error, const char *arg); void parse_checks_option(bool warn, bool error, const char *arg);
void process_checks(bool force, struct boot_info *bi); void process_checks(bool force, struct dt_info *dti);
/* Flattened trees */ /* Flattened trees */
void dt_to_blob(FILE *f, struct boot_info *bi, int version); void dt_to_blob(FILE *f, struct dt_info *dti, int version);
void dt_to_asm(FILE *f, struct boot_info *bi, int version); void dt_to_asm(FILE *f, struct dt_info *dti, int version);
struct boot_info *dt_from_blob(const char *fname); struct dt_info *dt_from_blob(const char *fname);
/* Tree source */ /* Tree source */
void dt_to_source(FILE *f, struct boot_info *bi); void dt_to_source(FILE *f, struct dt_info *dti);
struct boot_info *dt_from_source(const char *f); struct dt_info *dt_from_source(const char *f);
/* FS trees */ /* FS trees */
struct boot_info *dt_from_fs(const char *dirname); struct dt_info *dt_from_fs(const char *dirname);
#endif /* _DTC_H */ #endif /* _DTC_H */

View file

@ -366,7 +366,7 @@ static void make_fdt_header(struct fdt_header *fdt,
fdt->size_dt_struct = cpu_to_fdt32(dtsize); fdt->size_dt_struct = cpu_to_fdt32(dtsize);
} }
void dt_to_blob(FILE *f, struct boot_info *bi, int version) void dt_to_blob(FILE *f, struct dt_info *dti, int version)
{ {
struct version_info *vi = NULL; struct version_info *vi = NULL;
int i; int i;
@ -384,14 +384,14 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
if (!vi) if (!vi)
die("Unknown device tree blob version %d\n", version); die("Unknown device tree blob version %d\n", version);
flatten_tree(bi->dt, &bin_emitter, &dtbuf, &strbuf, vi); flatten_tree(dti->dt, &bin_emitter, &dtbuf, &strbuf, vi);
bin_emit_cell(&dtbuf, FDT_END); bin_emit_cell(&dtbuf, FDT_END);
reservebuf = flatten_reserve_list(bi->reservelist, vi); reservebuf = flatten_reserve_list(dti->reservelist, vi);
/* Make header */ /* Make header */
make_fdt_header(&fdt, vi, reservebuf.len, dtbuf.len, strbuf.len, make_fdt_header(&fdt, vi, reservebuf.len, dtbuf.len, strbuf.len,
bi->boot_cpuid_phys); dti->boot_cpuid_phys);
/* /*
* If the user asked for more space than is used, adjust the totalsize. * If the user asked for more space than is used, adjust the totalsize.
@ -467,7 +467,7 @@ static void dump_stringtable_asm(FILE *f, struct data strbuf)
} }
} }
void dt_to_asm(FILE *f, struct boot_info *bi, int version) void dt_to_asm(FILE *f, struct dt_info *dti, int version)
{ {
struct version_info *vi = NULL; struct version_info *vi = NULL;
int i; int i;
@ -507,7 +507,7 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
if (vi->flags & FTF_BOOTCPUID) { if (vi->flags & FTF_BOOTCPUID) {
fprintf(f, "\t/* boot_cpuid_phys */\n"); fprintf(f, "\t/* boot_cpuid_phys */\n");
asm_emit_cell(f, bi->boot_cpuid_phys); asm_emit_cell(f, dti->boot_cpuid_phys);
} }
if (vi->flags & FTF_STRTABSIZE) { if (vi->flags & FTF_STRTABSIZE) {
@ -537,7 +537,7 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
* Use .long on high and low halfs of u64s to avoid .quad * Use .long on high and low halfs of u64s to avoid .quad
* as it appears .quad isn't available in some assemblers. * as it appears .quad isn't available in some assemblers.
*/ */
for (re = bi->reservelist; re; re = re->next) { for (re = dti->reservelist; re; re = re->next) {
struct label *l; struct label *l;
for_each_label(re->labels, l) { for_each_label(re->labels, l) {
@ -557,7 +557,7 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)
fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n"); fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n");
emit_label(f, symprefix, "struct_start"); emit_label(f, symprefix, "struct_start");
flatten_tree(bi->dt, &asm_emitter, f, &strbuf, vi); flatten_tree(dti->dt, &asm_emitter, f, &strbuf, vi);
fprintf(f, "\t/* FDT_END */\n"); fprintf(f, "\t/* FDT_END */\n");
asm_emit_cell(f, FDT_END); asm_emit_cell(f, FDT_END);
@ -814,7 +814,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf,
} }
struct boot_info *dt_from_blob(const char *fname) struct dt_info *dt_from_blob(const char *fname)
{ {
FILE *f; FILE *f;
uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys; uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys;
@ -942,5 +942,5 @@ struct boot_info *dt_from_blob(const char *fname)
fclose(f); fclose(f);
return build_boot_info(DTSF_V1, reservelist, tree, boot_cpuid_phys); return build_dt_info(DTSF_V1, reservelist, tree, boot_cpuid_phys);
} }

View file

@ -79,13 +79,12 @@ static struct node *read_fstree(const char *dirname)
return tree; return tree;
} }
struct boot_info *dt_from_fs(const char *dirname) struct dt_info *dt_from_fs(const char *dirname)
{ {
struct node *tree; struct node *tree;
tree = read_fstree(dirname); tree = read_fstree(dirname);
tree = name_node(tree, ""); tree = name_node(tree, "");
return build_boot_info(DTSF_V1, NULL, tree, guess_boot_cpuid(tree)); return build_dt_info(DTSF_V1, NULL, tree, guess_boot_cpuid(tree));
} }

View file

@ -352,19 +352,19 @@ struct reserve_info *add_reserve_entry(struct reserve_info *list,
return list; return list;
} }
struct boot_info *build_boot_info(unsigned int dtsflags, struct dt_info *build_dt_info(unsigned int dtsflags,
struct reserve_info *reservelist, struct reserve_info *reservelist,
struct node *tree, uint32_t boot_cpuid_phys) struct node *tree, uint32_t boot_cpuid_phys)
{ {
struct boot_info *bi; struct dt_info *dti;
bi = xmalloc(sizeof(*bi)); dti = xmalloc(sizeof(*dti));
bi->dtsflags = dtsflags; dti->dtsflags = dtsflags;
bi->reservelist = reservelist; dti->reservelist = reservelist;
bi->dt = tree; dti->dt = tree;
bi->boot_cpuid_phys = boot_cpuid_phys; dti->boot_cpuid_phys = boot_cpuid_phys;
return bi; return dti;
} }
/* /*
@ -611,12 +611,12 @@ static int cmp_reserve_info(const void *ax, const void *bx)
return 0; return 0;
} }
static void sort_reserve_entries(struct boot_info *bi) static void sort_reserve_entries(struct dt_info *dti)
{ {
struct reserve_info *ri, **tbl; struct reserve_info *ri, **tbl;
int n = 0, i = 0; int n = 0, i = 0;
for (ri = bi->reservelist; for (ri = dti->reservelist;
ri; ri;
ri = ri->next) ri = ri->next)
n++; n++;
@ -626,14 +626,14 @@ static void sort_reserve_entries(struct boot_info *bi)
tbl = xmalloc(n * sizeof(*tbl)); tbl = xmalloc(n * sizeof(*tbl));
for (ri = bi->reservelist; for (ri = dti->reservelist;
ri; ri;
ri = ri->next) ri = ri->next)
tbl[i++] = ri; tbl[i++] = ri;
qsort(tbl, n, sizeof(*tbl), cmp_reserve_info); qsort(tbl, n, sizeof(*tbl), cmp_reserve_info);
bi->reservelist = tbl[0]; dti->reservelist = tbl[0];
for (i = 0; i < (n-1); i++) for (i = 0; i < (n-1); i++)
tbl[i]->next = tbl[i+1]; tbl[i]->next = tbl[i+1];
tbl[n-1]->next = NULL; tbl[n-1]->next = NULL;
@ -723,10 +723,10 @@ static void sort_node(struct node *node)
sort_node(c); sort_node(c);
} }
void sort_tree(struct boot_info *bi) void sort_tree(struct dt_info *dti)
{ {
sort_reserve_entries(bi); sort_reserve_entries(dti);
sort_node(bi->dt); sort_node(dti->dt);
} }
/* utility helper to avoid code duplication */ /* utility helper to avoid code duplication */
@ -755,7 +755,7 @@ static struct node *build_root_node(struct node *dt, char *name)
return an; return an;
} }
static bool any_label_tree(struct boot_info *bi, struct node *node) static bool any_label_tree(struct dt_info *dti, struct node *node)
{ {
struct node *c; struct node *c;
@ -763,17 +763,17 @@ static bool any_label_tree(struct boot_info *bi, struct node *node)
return true; return true;
for_each_child(node, c) for_each_child(node, c)
if (any_label_tree(bi, c)) if (any_label_tree(dti, c))
return true; return true;
return false; return false;
} }
static void generate_label_tree_internal(struct boot_info *bi, static void generate_label_tree_internal(struct dt_info *dti,
struct node *an, struct node *node, struct node *an, struct node *node,
bool allocph) bool allocph)
{ {
struct node *dt = bi->dt; struct node *dt = dti->dt;
struct node *c; struct node *c;
struct property *p; struct property *p;
struct label *l; struct label *l;
@ -806,10 +806,10 @@ static void generate_label_tree_internal(struct boot_info *bi,
} }
for_each_child(node, c) for_each_child(node, c)
generate_label_tree_internal(bi, an, c, allocph); generate_label_tree_internal(dti, an, c, allocph);
} }
static bool any_fixup_tree(struct boot_info *bi, struct node *node) static bool any_fixup_tree(struct dt_info *dti, struct node *node)
{ {
struct node *c; struct node *c;
struct property *prop; struct property *prop;
@ -818,20 +818,20 @@ static bool any_fixup_tree(struct boot_info *bi, struct node *node)
for_each_property(node, prop) { for_each_property(node, prop) {
m = prop->val.markers; m = prop->val.markers;
for_each_marker_of_type(m, REF_PHANDLE) { for_each_marker_of_type(m, REF_PHANDLE) {
if (!get_node_by_ref(bi->dt, m->ref)) if (!get_node_by_ref(dti->dt, m->ref))
return true; return true;
} }
} }
for_each_child(node, c) { for_each_child(node, c) {
if (any_fixup_tree(bi, c)) if (any_fixup_tree(dti, c))
return true; return true;
} }
return false; return false;
} }
static void add_fixup_entry(struct boot_info *bi, struct node *fn, static void add_fixup_entry(struct dt_info *dti, struct node *fn,
struct node *node, struct property *prop, struct node *node, struct property *prop,
struct marker *m) struct marker *m)
{ {
@ -849,11 +849,11 @@ static void add_fixup_entry(struct boot_info *bi, struct node *fn,
append_to_property(fn, m->ref, entry, strlen(entry) + 1); append_to_property(fn, m->ref, entry, strlen(entry) + 1);
} }
static void generate_fixups_tree_internal(struct boot_info *bi, static void generate_fixups_tree_internal(struct dt_info *dti,
struct node *fn, struct node *fn,
struct node *node) struct node *node)
{ {
struct node *dt = bi->dt; struct node *dt = dti->dt;
struct node *c; struct node *c;
struct property *prop; struct property *prop;
struct marker *m; struct marker *m;
@ -864,15 +864,15 @@ static void generate_fixups_tree_internal(struct boot_info *bi,
for_each_marker_of_type(m, REF_PHANDLE) { for_each_marker_of_type(m, REF_PHANDLE) {
refnode = get_node_by_ref(dt, m->ref); refnode = get_node_by_ref(dt, m->ref);
if (!refnode) if (!refnode)
add_fixup_entry(bi, fn, node, prop, m); add_fixup_entry(dti, fn, node, prop, m);
} }
} }
for_each_child(node, c) for_each_child(node, c)
generate_fixups_tree_internal(bi, fn, c); generate_fixups_tree_internal(dti, fn, c);
} }
static bool any_local_fixup_tree(struct boot_info *bi, struct node *node) static bool any_local_fixup_tree(struct dt_info *dti, struct node *node)
{ {
struct node *c; struct node *c;
struct property *prop; struct property *prop;
@ -881,20 +881,20 @@ static bool any_local_fixup_tree(struct boot_info *bi, struct node *node)
for_each_property(node, prop) { for_each_property(node, prop) {
m = prop->val.markers; m = prop->val.markers;
for_each_marker_of_type(m, REF_PHANDLE) { for_each_marker_of_type(m, REF_PHANDLE) {
if (get_node_by_ref(bi->dt, m->ref)) if (get_node_by_ref(dti->dt, m->ref))
return true; return true;
} }
} }
for_each_child(node, c) { for_each_child(node, c) {
if (any_local_fixup_tree(bi, c)) if (any_local_fixup_tree(dti, c))
return true; return true;
} }
return false; return false;
} }
static void add_local_fixup_entry(struct boot_info *bi, static void add_local_fixup_entry(struct dt_info *dti,
struct node *lfn, struct node *node, struct node *lfn, struct node *node,
struct property *prop, struct marker *m, struct property *prop, struct marker *m,
struct node *refnode) struct node *refnode)
@ -930,11 +930,11 @@ static void add_local_fixup_entry(struct boot_info *bi,
append_to_property(wn, prop->name, &value_32, sizeof(value_32)); append_to_property(wn, prop->name, &value_32, sizeof(value_32));
} }
static void generate_local_fixups_tree_internal(struct boot_info *bi, static void generate_local_fixups_tree_internal(struct dt_info *dti,
struct node *lfn, struct node *lfn,
struct node *node) struct node *node)
{ {
struct node *dt = bi->dt; struct node *dt = dti->dt;
struct node *c; struct node *c;
struct property *prop; struct property *prop;
struct marker *m; struct marker *m;
@ -945,34 +945,34 @@ static void generate_local_fixups_tree_internal(struct boot_info *bi,
for_each_marker_of_type(m, REF_PHANDLE) { for_each_marker_of_type(m, REF_PHANDLE) {
refnode = get_node_by_ref(dt, m->ref); refnode = get_node_by_ref(dt, m->ref);
if (refnode) if (refnode)
add_local_fixup_entry(bi, lfn, node, prop, m, refnode); add_local_fixup_entry(dti, lfn, node, prop, m, refnode);
} }
} }
for_each_child(node, c) for_each_child(node, c)
generate_local_fixups_tree_internal(bi, lfn, c); generate_local_fixups_tree_internal(dti, lfn, c);
} }
void generate_label_tree(struct boot_info *bi, char *name, bool allocph) void generate_label_tree(struct dt_info *dti, char *name, bool allocph)
{ {
if (!any_label_tree(bi, bi->dt)) if (!any_label_tree(dti, dti->dt))
return; return;
generate_label_tree_internal(bi, build_root_node(bi->dt, name), generate_label_tree_internal(dti, build_root_node(dti->dt, name),
bi->dt, allocph); dti->dt, allocph);
} }
void generate_fixups_tree(struct boot_info *bi, char *name) void generate_fixups_tree(struct dt_info *dti, char *name)
{ {
if (!any_fixup_tree(bi, bi->dt)) if (!any_fixup_tree(dti, dti->dt))
return; return;
generate_fixups_tree_internal(bi, build_root_node(bi->dt, name), generate_fixups_tree_internal(dti, build_root_node(dti->dt, name),
bi->dt); dti->dt);
} }
void generate_local_fixups_tree(struct boot_info *bi, char *name) void generate_local_fixups_tree(struct dt_info *dti, char *name)
{ {
if (!any_local_fixup_tree(bi, bi->dt)) if (!any_local_fixup_tree(dti, dti->dt))
return; return;
generate_local_fixups_tree_internal(bi, build_root_node(bi->dt, name), generate_local_fixups_tree_internal(dti, build_root_node(dti->dt, name),
bi->dt); dti->dt);
} }

View file

@ -25,12 +25,12 @@ extern FILE *yyin;
extern int yyparse(void); extern int yyparse(void);
extern YYLTYPE yylloc; extern YYLTYPE yylloc;
struct boot_info *the_boot_info; struct dt_info *parser_output;
bool treesource_error; bool treesource_error;
struct boot_info *dt_from_source(const char *fname) struct dt_info *dt_from_source(const char *fname)
{ {
the_boot_info = NULL; parser_output = NULL;
treesource_error = false; treesource_error = false;
srcfile_push(fname); srcfile_push(fname);
@ -43,7 +43,7 @@ struct boot_info *dt_from_source(const char *fname)
if (treesource_error) if (treesource_error)
die("Syntax error parsing input tree\n"); die("Syntax error parsing input tree\n");
return the_boot_info; return parser_output;
} }
static void write_prefix(FILE *f, int level) static void write_prefix(FILE *f, int level)
@ -263,13 +263,13 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level)
} }
void dt_to_source(FILE *f, struct boot_info *bi) void dt_to_source(FILE *f, struct dt_info *dti)
{ {
struct reserve_info *re; struct reserve_info *re;
fprintf(f, "/dts-v1/;\n\n"); fprintf(f, "/dts-v1/;\n\n");
for (re = bi->reservelist; re; re = re->next) { for (re = dti->reservelist; re; re = re->next) {
struct label *l; struct label *l;
for_each_label(re->labels, l) for_each_label(re->labels, l)
@ -279,6 +279,6 @@ void dt_to_source(FILE *f, struct boot_info *bi)
(unsigned long long)re->re.size); (unsigned long long)re->re.size);
} }
write_tree_source_node(f, bi->dt, 0); write_tree_source_node(f, dti->dt, 0);
} }