mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
Support for specifying memreserve ranges in the source format, based on
a patch by Jon Loeliger <jdl AT freescale.com>, although tweaked substantially.
This commit is contained in:
parent
586606e35d
commit
f0517db250
11 changed files with 257 additions and 53 deletions
51
treesource.c
51
treesource.c
|
@ -20,20 +20,35 @@
|
|||
|
||||
#include "dtc.h"
|
||||
|
||||
struct node *device_tree;
|
||||
|
||||
extern FILE *yyin;
|
||||
extern int yyparse(void);
|
||||
extern void yyerror(char const *);
|
||||
|
||||
struct node *dt_from_source(FILE *f)
|
||||
struct boot_info *the_boot_info;
|
||||
|
||||
struct data build_mem_reserve(struct data d)
|
||||
{
|
||||
/*
|
||||
* FIXME: Should reconcile the -R parameter here now?
|
||||
*/
|
||||
if (d.len % 16 != 0) {
|
||||
yyerror("Memory Reserve entries are <u64 addr, u64 size>\n");
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
struct boot_info *dt_from_source(FILE *f)
|
||||
{
|
||||
the_boot_info = NULL;
|
||||
|
||||
yyin = f;
|
||||
if (yyparse() != 0)
|
||||
return NULL;
|
||||
|
||||
fill_fullpaths(device_tree, "");
|
||||
fill_fullpaths(the_boot_info->dt, "");
|
||||
|
||||
return device_tree;
|
||||
return the_boot_info;
|
||||
}
|
||||
|
||||
static void write_prefix(FILE *f, int level)
|
||||
|
@ -75,7 +90,8 @@ static enum proptype guess_type(struct property *prop)
|
|||
|
||||
}
|
||||
|
||||
void write_tree_source(FILE *f, struct node *tree, int level)
|
||||
|
||||
void write_tree_source_node(FILE *f, struct node *tree, int level)
|
||||
{
|
||||
struct property *prop;
|
||||
struct node *child;
|
||||
|
@ -133,8 +149,29 @@ void write_tree_source(FILE *f, struct node *tree, int level)
|
|||
}
|
||||
for_each_child(tree, child) {
|
||||
fprintf(f, "\n");
|
||||
write_tree_source(f, child, level+1);
|
||||
write_tree_source_node(f, child, level+1);
|
||||
}
|
||||
write_prefix(f, level);
|
||||
fprintf(f, "};\n");
|
||||
}
|
||||
|
||||
|
||||
void write_tree_source(FILE *f, struct boot_info *bi)
|
||||
{
|
||||
int i;
|
||||
|
||||
assert((bi->mem_reserve_data.len % sizeof(struct reserve_entry)) == 0);
|
||||
for (i = 0;
|
||||
i < (bi->mem_reserve_data.len / sizeof(struct reserve_entry));
|
||||
i++) {
|
||||
struct reserve_entry *re = ((struct reserve_entry *)
|
||||
bi->mem_reserve_data.val) + i;
|
||||
|
||||
fprintf(f, "/memreserve/\t%016llx-%016llx;\n",
|
||||
(unsigned long long)re->address,
|
||||
(unsigned long long)re->address + re->size - 1);
|
||||
}
|
||||
|
||||
write_tree_source_node(f, bi->dt, 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue