Browse Source

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>
main
David Gibson 9 years ago
parent
commit
00fbb8696b
  1. 86
      checks.c
  2. 6
      dtc-parser.y
  3. 32
      dtc.c
  4. 32
      dtc.h
  5. 20
      flattree.c
  6. 5
      fstree.c
  7. 100
      livetree.c
  8. 14
      treesource.c

86
checks.c

@ -40,7 +40,7 @@ enum checkstatus { @@ -40,7 +40,7 @@ enum checkstatus {

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 {
const char *name;
@ -97,21 +97,21 @@ static inline void check_msg(struct check *c, const char *fmt, ...) @@ -97,21 +97,21 @@ static inline void check_msg(struct check *c, const char *fmt, ...)
check_msg((c), __VA_ARGS__); \
} 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;

TRACE(c, "%s", node->fullpath);
if (c->fn)
c->fn(c, bi, node);
c->fn(c, dti, node);

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;
int i;

@ -124,7 +124,7 @@ static bool run_check(struct check *c, struct boot_info *bi) @@ -124,7 +124,7 @@ static bool run_check(struct check *c, struct boot_info *bi)

for (i = 0; i < c->num_prereqs; i++) {
struct check *prq = c->prereq[i];
error = error || run_check(prq, bi);
error = error || run_check(prq, dti);
if (prq->status != PASSED) {
c->status = PREREQ;
check_msg(c, "Failed prerequisite '%s'",
@ -135,7 +135,7 @@ static bool run_check(struct check *c, struct boot_info *bi) @@ -135,7 +135,7 @@ static bool run_check(struct check *c, struct boot_info *bi)
if (c->status != UNCHECKED)
goto out;

check_nodes_props(c, bi, dt);
check_nodes_props(c, dti, dt);

if (c->status == UNCHECKED)
c->status = PASSED;
@ -154,14 +154,14 @@ out: @@ -154,14 +154,14 @@ out:
*/

/* 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)
{
FAIL(c, "always_fail check");
}
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 property *prop;
@ -180,7 +180,7 @@ static void check_is_string(struct check *c, struct boot_info *bi, @@ -180,7 +180,7 @@ static void check_is_string(struct check *c, struct boot_info *bi,
#define ERROR_IF_NOT_STRING(nm, 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 property *prop;
@ -203,7 +203,7 @@ static void check_is_cell(struct check *c, struct boot_info *bi, @@ -203,7 +203,7 @@ static void check_is_cell(struct check *c, struct boot_info *bi,
* 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 *child, *child2;
@ -218,7 +218,7 @@ static void check_duplicate_node_names(struct check *c, struct boot_info *bi, @@ -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);

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 property *prop, *prop2;
@ -240,7 +240,7 @@ ERROR(duplicate_property_names, check_duplicate_property_names, NULL); @@ -240,7 +240,7 @@ ERROR(duplicate_property_names, check_duplicate_property_names, NULL);
#define DIGITS "0123456789"
#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)
{
int n = strspn(node->name, c->data);
@ -251,7 +251,7 @@ static void check_node_name_chars(struct check *c, struct boot_info *bi, @@ -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 "@");

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)
{
if (strchr(get_unitname(node), '@'))
@ -260,7 +260,7 @@ static void check_node_name_format(struct check *c, struct boot_info *bi, @@ -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);

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)
{
const char *unitname = get_unitname(node);
@ -284,7 +284,7 @@ static void check_unit_address_vs_reg(struct check *c, struct boot_info *bi, @@ -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);

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 property *prop;
@ -306,11 +306,11 @@ ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS); @@ -306,11 +306,11 @@ ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS);
((prop) ? (prop)->name : ""), \
((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,
struct property *prop, struct marker *mark)
{
struct node *dt = bi->dt;
struct node *dt = dti->dt;
struct node *othernode = NULL;
struct property *otherprop = NULL;
struct marker *othermark = NULL;
@ -333,31 +333,31 @@ static void check_duplicate_label(struct check *c, struct boot_info *bi, @@ -333,31 +333,31 @@ static void check_duplicate_label(struct check *c, struct boot_info *bi,
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 label *l;
struct property *prop;

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) {
struct marker *m = prop->val.markers;

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)
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);

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 *root = bi->dt;
struct node *root = dti->dt;
struct property *prop;
struct marker *m;
cell_t phandle;
@ -401,19 +401,19 @@ static cell_t check_phandle_prop(struct check *c, struct boot_info *bi, @@ -401,19 +401,19 @@ static cell_t check_phandle_prop(struct check *c, struct boot_info *bi,
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 *root = bi->dt;
struct node *root = dti->dt;
struct node *other;
cell_t phandle, linux_phandle;

/* Nothing should have assigned phandles yet */
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)
/* No valid phandles; nothing further to check */
@ -437,7 +437,7 @@ static void check_explicit_phandles(struct check *c, struct boot_info *bi, @@ -437,7 +437,7 @@ static void check_explicit_phandles(struct check *c, struct boot_info *bi,
}
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 property **pp, *prop = NULL;
@ -471,10 +471,10 @@ ERROR(name_properties, check_name_properties, NULL, &name_is_string); @@ -471,10 +471,10 @@ ERROR(name_properties, check_name_properties, NULL, &name_is_string);
* 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 *dt = bi->dt;
struct node *dt = dti->dt;
struct property *prop;

for_each_property(node, prop) {
@ -487,7 +487,7 @@ static void fixup_phandle_references(struct check *c, struct boot_info *bi, @@ -487,7 +487,7 @@ static void fixup_phandle_references(struct check *c, struct boot_info *bi,

refnode = get_node_by_ref(dt, m->ref);
if (! refnode) {
if (!(bi->dtsflags & DTSF_PLUGIN))
if (!(dti->dtsflags & DTSF_PLUGIN))
FAIL(c, "Reference to non-existent node or "
"label \"%s\"\n", m->ref);
else /* mark the entry as unresolved */
@ -504,10 +504,10 @@ static void fixup_phandle_references(struct check *c, struct boot_info *bi, @@ -504,10 +504,10 @@ static void fixup_phandle_references(struct check *c, struct boot_info *bi,
ERROR(phandle_references, fixup_phandle_references, NULL,
&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 *dt = bi->dt;
struct node *dt = dti->dt;
struct property *prop;

for_each_property(node, prop) {
@ -544,7 +544,7 @@ WARNING_IF_NOT_STRING(device_type_is_string, "device_type"); @@ -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(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 property *prop;
@ -568,7 +568,7 @@ WARNING(addr_size_cells, fixup_addr_size_cells, NULL, @@ -568,7 +568,7 @@ WARNING(addr_size_cells, fixup_addr_size_cells, NULL,
#define node_size_cells(n) \
(((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 property *prop;
@ -597,7 +597,7 @@ static void check_reg_format(struct check *c, struct boot_info *bi, @@ -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);

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 property *prop;
@ -641,7 +641,7 @@ WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells); @@ -641,7 +641,7 @@ WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells);
/*
* 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 property *reg, *ranges;
@ -667,10 +667,10 @@ WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL, @@ -667,10 +667,10 @@ WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL,
&addr_size_cells);

static void check_obsolete_chosen_interrupt_controller(struct check *c,
struct boot_info *bi,
struct dt_info *dti,
struct node *node)
{
struct node *dt = bi->dt;
struct node *dt = dti->dt;
struct node *chosen;
struct property *prop;

@ -774,7 +774,7 @@ void parse_checks_option(bool warn, bool error, const char *arg) @@ -774,7 +774,7 @@ void parse_checks_option(bool warn, bool error, const char *arg)
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 error = 0;
@ -783,7 +783,7 @@ void process_checks(bool force, struct boot_info *bi) @@ -783,7 +783,7 @@ void process_checks(bool force, struct boot_info *bi)
struct check *c = check_table[i];

if (c->warn || c->error)
error = error || run_check(c, bi);
error = error || run_check(c, dti);
}

if (error) {

6
dtc-parser.y

@ -32,7 +32,7 @@ extern void yyerror(char const *s); @@ -32,7 +32,7 @@ extern void yyerror(char const *s);
treesource_error = true; \
} while (0)

extern struct boot_info *the_boot_info;
extern struct dt_info *parser_output;
extern bool treesource_error;
%}

@ -108,8 +108,8 @@ extern bool treesource_error; @@ -108,8 +108,8 @@ extern bool treesource_error;
sourcefile:
headers memreserves devicetree
{
the_boot_info = build_boot_info($1, $2, $3,
guess_boot_cpuid($3));
parser_output = build_dt_info($1, $2, $3,
guess_boot_cpuid($3));
}
;


32
dtc.c

@ -168,7 +168,7 @@ static const char *guess_input_format(const char *fname, const char *fallback) @@ -168,7 +168,7 @@ static const char *guess_input_format(const char *fname, const char *fallback)

int main(int argc, char *argv[])
{
struct boot_info *bi;
struct dt_info *dti;
const char *inform = NULL;
const char *outform = NULL;
const char *outname = "-";
@ -301,11 +301,11 @@ int main(int argc, char *argv[]) @@ -301,11 +301,11 @@ int main(int argc, char *argv[])
}
}
if (streq(inform, "dts"))
bi = dt_from_source(arg);
dti = dt_from_source(arg);
else if (streq(inform, "fs"))
bi = dt_from_fs(arg);
dti = dt_from_fs(arg);
else if(streq(inform, "dtb"))
bi = dt_from_blob(arg);
dti = dt_from_blob(arg);
else
die("Unknown input format \"%s\"\n", inform);

@ -315,29 +315,29 @@ int main(int argc, char *argv[]) @@ -315,29 +315,29 @@ int main(int argc, char *argv[])
}

if (cmdline_boot_cpuid != -1)
bi->boot_cpuid_phys = cmdline_boot_cpuid;
dti->boot_cpuid_phys = cmdline_boot_cpuid;

fill_fullpaths(bi->dt, "");
process_checks(force, bi);
fill_fullpaths(dti->dt, "");
process_checks(force, dti);

/* on a plugin, generate by default */
if (bi->dtsflags & DTSF_PLUGIN) {
if (dti->dtsflags & DTSF_PLUGIN) {
generate_fixups = 1;
}

if (auto_label_aliases)
generate_label_tree(bi, "aliases", false);
generate_label_tree(dti, "aliases", false);

if (generate_symbols)
generate_label_tree(bi, "__symbols__", true);
generate_label_tree(dti, "__symbols__", true);

if (generate_fixups) {
generate_fixups_tree(bi, "__fixups__");
generate_local_fixups_tree(bi, "__local_fixups__");
generate_fixups_tree(dti, "__fixups__");
generate_local_fixups_tree(dti, "__local_fixups__");
}

if (sort)
sort_tree(bi);
sort_tree(dti);

if (streq(outname, "-")) {
outf = stdout;
@ -349,11 +349,11 @@ int main(int argc, char *argv[]) @@ -349,11 +349,11 @@ int main(int argc, char *argv[])
}

if (streq(outform, "dts")) {
dt_to_source(outf, bi);
dt_to_source(outf, dti);
} else if (streq(outform, "dtb")) {
dt_to_blob(outf, bi, outversion);
dt_to_blob(outf, dti, outversion);
} else if (streq(outform, "asm")) {
dt_to_asm(outf, bi, outversion);
dt_to_asm(outf, dti, outversion);
} else if (streq(outform, "null")) {
/* do nothing */
} else {

32
dtc.h

@ -241,44 +241,44 @@ struct reserve_info *add_reserve_entry(struct reserve_info *list, @@ -241,44 +241,44 @@ struct reserve_info *add_reserve_entry(struct reserve_info *list,
struct reserve_info *new);


struct boot_info {
struct dt_info {
unsigned int dtsflags;
struct reserve_info *reservelist;
struct node *dt; /* the device tree */
uint32_t boot_cpuid_phys;
struct node *dt; /* the device tree */
};

/* DTS version flags definitions */
#define DTSF_V1 0x0001 /* /dts-v1/ */
#define DTSF_PLUGIN 0x0002 /* /plugin/ */

struct boot_info *build_boot_info(unsigned int dtsflags,
struct reserve_info *reservelist,
struct node *tree, uint32_t boot_cpuid_phys);
void sort_tree(struct boot_info *bi);
void generate_label_tree(struct boot_info *bi, char *name, bool allocph);
void generate_fixups_tree(struct boot_info *bi, char *name);
void generate_local_fixups_tree(struct boot_info *bi, char *name);
struct dt_info *build_dt_info(unsigned int dtsflags,
struct reserve_info *reservelist,
struct node *tree, uint32_t boot_cpuid_phys);
void sort_tree(struct dt_info *dti);
void generate_label_tree(struct dt_info *dti, char *name, bool allocph);
void generate_fixups_tree(struct dt_info *dti, char *name);
void generate_local_fixups_tree(struct dt_info *dti, char *name);

/* Checks */

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 */

void dt_to_blob(FILE *f, struct boot_info *bi, int version);
void dt_to_asm(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 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 */

void dt_to_source(FILE *f, struct boot_info *bi);
struct boot_info *dt_from_source(const char *f);
void dt_to_source(FILE *f, struct dt_info *dti);
struct dt_info *dt_from_source(const char *f);

/* FS trees */

struct boot_info *dt_from_fs(const char *dirname);
struct dt_info *dt_from_fs(const char *dirname);

#endif /* _DTC_H */

20
flattree.c

@ -366,7 +366,7 @@ static void make_fdt_header(struct fdt_header *fdt, @@ -366,7 +366,7 @@ static void make_fdt_header(struct fdt_header *fdt,
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;
int i;
@ -384,14 +384,14 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version) @@ -384,14 +384,14 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
if (!vi)
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);

reservebuf = flatten_reserve_list(bi->reservelist, vi);
reservebuf = flatten_reserve_list(dti->reservelist, vi);

/* Make header */
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.
@ -467,7 +467,7 @@ static void dump_stringtable_asm(FILE *f, struct data strbuf) @@ -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;
int i;
@ -507,7 +507,7 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) @@ -507,7 +507,7 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version)

if (vi->flags & FTF_BOOTCPUID) {
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) {
@ -537,7 +537,7 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) @@ -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
* 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;

for_each_label(re->labels, l) {
@ -557,7 +557,7 @@ void dt_to_asm(FILE *f, struct boot_info *bi, int version) @@ -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");

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");
asm_emit_cell(f, FDT_END);
@ -814,7 +814,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf, @@ -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;
uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys;
@ -942,5 +942,5 @@ struct boot_info *dt_from_blob(const char *fname) @@ -942,5 +942,5 @@ struct boot_info *dt_from_blob(const char *fname)

fclose(f);

return build_boot_info(DTSF_V1, reservelist, tree, boot_cpuid_phys);
return build_dt_info(DTSF_V1, reservelist, tree, boot_cpuid_phys);
}

5
fstree.c

@ -79,13 +79,12 @@ static struct node *read_fstree(const char *dirname) @@ -79,13 +79,12 @@ static struct node *read_fstree(const char *dirname)
return tree;
}

struct boot_info *dt_from_fs(const char *dirname)
struct dt_info *dt_from_fs(const char *dirname)
{
struct node *tree;

tree = read_fstree(dirname);
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));
}


100
livetree.c

@ -352,19 +352,19 @@ struct reserve_info *add_reserve_entry(struct reserve_info *list, @@ -352,19 +352,19 @@ struct reserve_info *add_reserve_entry(struct reserve_info *list,
return list;
}

struct boot_info *build_boot_info(unsigned int dtsflags,
struct reserve_info *reservelist,
struct node *tree, uint32_t boot_cpuid_phys)
struct dt_info *build_dt_info(unsigned int dtsflags,
struct reserve_info *reservelist,
struct node *tree, uint32_t boot_cpuid_phys)
{
struct boot_info *bi;
struct dt_info *dti;

bi = xmalloc(sizeof(*bi));
bi->dtsflags = dtsflags;
bi->reservelist = reservelist;
bi->dt = tree;
bi->boot_cpuid_phys = boot_cpuid_phys;
dti = xmalloc(sizeof(*dti));
dti->dtsflags = dtsflags;
dti->reservelist = reservelist;
dti->dt = tree;
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) @@ -611,12 +611,12 @@ static int cmp_reserve_info(const void *ax, const void *bx)
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;
int n = 0, i = 0;

for (ri = bi->reservelist;
for (ri = dti->reservelist;
ri;
ri = ri->next)
n++;
@ -626,14 +626,14 @@ static void sort_reserve_entries(struct boot_info *bi) @@ -626,14 +626,14 @@ static void sort_reserve_entries(struct boot_info *bi)

tbl = xmalloc(n * sizeof(*tbl));

for (ri = bi->reservelist;
for (ri = dti->reservelist;
ri;
ri = ri->next)
tbl[i++] = ri;

qsort(tbl, n, sizeof(*tbl), cmp_reserve_info);

bi->reservelist = tbl[0];
dti->reservelist = tbl[0];
for (i = 0; i < (n-1); i++)
tbl[i]->next = tbl[i+1];
tbl[n-1]->next = NULL;
@ -723,10 +723,10 @@ static void sort_node(struct node *node) @@ -723,10 +723,10 @@ static void sort_node(struct node *node)
sort_node(c);
}

void sort_tree(struct boot_info *bi)
void sort_tree(struct dt_info *dti)
{
sort_reserve_entries(bi);
sort_node(bi->dt);
sort_reserve_entries(dti);
sort_node(dti->dt);
}

/* utility helper to avoid code duplication */
@ -755,7 +755,7 @@ static struct node *build_root_node(struct node *dt, char *name) @@ -755,7 +755,7 @@ static struct node *build_root_node(struct node *dt, char *name)
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;

@ -763,17 +763,17 @@ static bool any_label_tree(struct boot_info *bi, struct node *node) @@ -763,17 +763,17 @@ static bool any_label_tree(struct boot_info *bi, struct node *node)
return true;

for_each_child(node, c)
if (any_label_tree(bi, c))
if (any_label_tree(dti, c))
return true;

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,
bool allocph)
{
struct node *dt = bi->dt;
struct node *dt = dti->dt;
struct node *c;
struct property *p;
struct label *l;
@ -806,10 +806,10 @@ static void generate_label_tree_internal(struct boot_info *bi, @@ -806,10 +806,10 @@ static void generate_label_tree_internal(struct boot_info *bi,
}

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 property *prop;
@ -818,20 +818,20 @@ static bool any_fixup_tree(struct boot_info *bi, struct node *node) @@ -818,20 +818,20 @@ static bool any_fixup_tree(struct boot_info *bi, struct node *node)
for_each_property(node, prop) {
m = prop->val.markers;
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;
}
}

for_each_child(node, c) {
if (any_fixup_tree(bi, c))
if (any_fixup_tree(dti, c))
return true;
}

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 marker *m)
{
@ -849,11 +849,11 @@ static void add_fixup_entry(struct boot_info *bi, struct node *fn, @@ -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);
}

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 *node)
{
struct node *dt = bi->dt;
struct node *dt = dti->dt;
struct node *c;
struct property *prop;
struct marker *m;
@ -864,15 +864,15 @@ static void generate_fixups_tree_internal(struct boot_info *bi, @@ -864,15 +864,15 @@ static void generate_fixups_tree_internal(struct boot_info *bi,
for_each_marker_of_type(m, REF_PHANDLE) {
refnode = get_node_by_ref(dt, m->ref);
if (!refnode)
add_fixup_entry(bi, fn, node, prop, m);
add_fixup_entry(dti, fn, node, prop, m);
}
}

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 property *prop;
@ -881,20 +881,20 @@ static bool any_local_fixup_tree(struct boot_info *bi, struct node *node) @@ -881,20 +881,20 @@ static bool any_local_fixup_tree(struct boot_info *bi, struct node *node)
for_each_property(node, prop) {
m = prop->val.markers;
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;
}
}

for_each_child(node, c) {
if (any_local_fixup_tree(bi, c))
if (any_local_fixup_tree(dti, c))
return true;
}

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 property *prop, struct marker *m,
struct node *refnode)
@ -930,11 +930,11 @@ static void add_local_fixup_entry(struct boot_info *bi, @@ -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));
}

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 *node)
{
struct node *dt = bi->dt;
struct node *dt = dti->dt;
struct node *c;
struct property *prop;
struct marker *m;
@ -945,34 +945,34 @@ static void generate_local_fixups_tree_internal(struct boot_info *bi, @@ -945,34 +945,34 @@ static void generate_local_fixups_tree_internal(struct boot_info *bi,
for_each_marker_of_type(m, REF_PHANDLE) {
refnode = get_node_by_ref(dt, m->ref);
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)
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;
generate_label_tree_internal(bi, build_root_node(bi->dt, name),
bi->dt, allocph);
generate_label_tree_internal(dti, build_root_node(dti->dt, name),
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;
generate_fixups_tree_internal(bi, build_root_node(bi->dt, name),
bi->dt);
generate_fixups_tree_internal(dti, build_root_node(dti->dt, name),
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;
generate_local_fixups_tree_internal(bi, build_root_node(bi->dt, name),
bi->dt);
generate_local_fixups_tree_internal(dti, build_root_node(dti->dt, name),
dti->dt);
}

14
treesource.c

@ -25,12 +25,12 @@ extern FILE *yyin; @@ -25,12 +25,12 @@ extern FILE *yyin;
extern int yyparse(void);
extern YYLTYPE yylloc;

struct boot_info *the_boot_info;
struct dt_info *parser_output;
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;

srcfile_push(fname);
@ -43,7 +43,7 @@ struct boot_info *dt_from_source(const char *fname) @@ -43,7 +43,7 @@ struct boot_info *dt_from_source(const char *fname)
if (treesource_error)
die("Syntax error parsing input tree\n");

return the_boot_info;
return parser_output;
}

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) @@ -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;

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;

for_each_label(re->labels, l)
@ -279,6 +279,6 @@ void dt_to_source(FILE *f, struct boot_info *bi) @@ -279,6 +279,6 @@ void dt_to_source(FILE *f, struct boot_info *bi)
(unsigned long long)re->re.size);
}

write_tree_source_node(f, bi->dt, 0);
write_tree_source_node(f, dti->dt, 0);
}


Loading…
Cancel
Save