diff options
Diffstat (limited to 'scripts/dtc/treesource.c')
-rw-r--r-- | scripts/dtc/treesource.c | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/scripts/dtc/treesource.c b/scripts/dtc/treesource.c index 1521ff11bb97..c09aafade313 100644 --- a/scripts/dtc/treesource.c +++ b/scripts/dtc/treesource.c | |||
@@ -32,8 +32,8 @@ struct boot_info *dt_from_source(const char *fname) | |||
32 | the_boot_info = NULL; | 32 | the_boot_info = NULL; |
33 | treesource_error = 0; | 33 | treesource_error = 0; |
34 | 34 | ||
35 | srcpos_file = dtc_open_file(fname, NULL); | 35 | srcfile_push(fname); |
36 | yyin = srcpos_file->file; | 36 | yyin = current_srcfile->f; |
37 | 37 | ||
38 | if (yyparse() != 0) | 38 | if (yyparse() != 0) |
39 | die("Unable to parse input tree\n"); | 39 | die("Unable to parse input tree\n"); |
@@ -63,26 +63,20 @@ static void write_propval_string(FILE *f, struct data val) | |||
63 | { | 63 | { |
64 | const char *str = val.val; | 64 | const char *str = val.val; |
65 | int i; | 65 | int i; |
66 | int newchunk = 1; | ||
67 | struct marker *m = val.markers; | 66 | struct marker *m = val.markers; |
68 | 67 | ||
69 | assert(str[val.len-1] == '\0'); | 68 | assert(str[val.len-1] == '\0'); |
70 | 69 | ||
70 | while (m && (m->offset == 0)) { | ||
71 | if (m->type == LABEL) | ||
72 | fprintf(f, "%s: ", m->ref); | ||
73 | m = m->next; | ||
74 | } | ||
75 | fprintf(f, "\""); | ||
76 | |||
71 | for (i = 0; i < (val.len-1); i++) { | 77 | for (i = 0; i < (val.len-1); i++) { |
72 | char c = str[i]; | 78 | char c = str[i]; |
73 | 79 | ||
74 | if (newchunk) { | ||
75 | while (m && (m->offset <= i)) { | ||
76 | if (m->type == LABEL) { | ||
77 | assert(m->offset == i); | ||
78 | fprintf(f, "%s: ", m->ref); | ||
79 | } | ||
80 | m = m->next; | ||
81 | } | ||
82 | fprintf(f, "\""); | ||
83 | newchunk = 0; | ||
84 | } | ||
85 | |||
86 | switch (c) { | 80 | switch (c) { |
87 | case '\a': | 81 | case '\a': |
88 | fprintf(f, "\\a"); | 82 | fprintf(f, "\\a"); |
@@ -113,7 +107,14 @@ static void write_propval_string(FILE *f, struct data val) | |||
113 | break; | 107 | break; |
114 | case '\0': | 108 | case '\0': |
115 | fprintf(f, "\", "); | 109 | fprintf(f, "\", "); |
116 | newchunk = 1; | 110 | while (m && (m->offset < i)) { |
111 | if (m->type == LABEL) { | ||
112 | assert(m->offset == (i+1)); | ||
113 | fprintf(f, "%s: ", m->ref); | ||
114 | } | ||
115 | m = m->next; | ||
116 | } | ||
117 | fprintf(f, "\""); | ||
117 | break; | 118 | break; |
118 | default: | 119 | default: |
119 | if (isprint(c)) | 120 | if (isprint(c)) |
@@ -234,10 +235,11 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level) | |||
234 | { | 235 | { |
235 | struct property *prop; | 236 | struct property *prop; |
236 | struct node *child; | 237 | struct node *child; |
238 | struct label *l; | ||
237 | 239 | ||
238 | write_prefix(f, level); | 240 | write_prefix(f, level); |
239 | if (tree->label) | 241 | for_each_label(tree->labels, l) |
240 | fprintf(f, "%s: ", tree->label); | 242 | fprintf(f, "%s: ", l->label); |
241 | if (tree->name && (*tree->name)) | 243 | if (tree->name && (*tree->name)) |
242 | fprintf(f, "%s {\n", tree->name); | 244 | fprintf(f, "%s {\n", tree->name); |
243 | else | 245 | else |
@@ -245,8 +247,8 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level) | |||
245 | 247 | ||
246 | for_each_property(tree, prop) { | 248 | for_each_property(tree, prop) { |
247 | write_prefix(f, level+1); | 249 | write_prefix(f, level+1); |
248 | if (prop->label) | 250 | for_each_label(prop->labels, l) |
249 | fprintf(f, "%s: ", prop->label); | 251 | fprintf(f, "%s: ", l->label); |
250 | fprintf(f, "%s", prop->name); | 252 | fprintf(f, "%s", prop->name); |
251 | write_propval(f, prop); | 253 | write_propval(f, prop); |
252 | } | 254 | } |
@@ -266,8 +268,10 @@ void dt_to_source(FILE *f, struct boot_info *bi) | |||
266 | fprintf(f, "/dts-v1/;\n\n"); | 268 | fprintf(f, "/dts-v1/;\n\n"); |
267 | 269 | ||
268 | for (re = bi->reservelist; re; re = re->next) { | 270 | for (re = bi->reservelist; re; re = re->next) { |
269 | if (re->label) | 271 | struct label *l; |
270 | fprintf(f, "%s: ", re->label); | 272 | |
273 | for_each_label(re->labels, l) | ||
274 | fprintf(f, "%s: ", l->label); | ||
271 | fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n", | 275 | fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n", |
272 | (unsigned long long)re->re.address, | 276 | (unsigned long long)re->re.address, |
273 | (unsigned long long)re->re.size); | 277 | (unsigned long long)re->re.size); |