summaryrefslogtreecommitdiffstats
path: root/meta-ti-extras/recipes/dtc/dtc
diff options
context:
space:
mode:
Diffstat (limited to 'meta-ti-extras/recipes/dtc/dtc')
-rw-r--r--meta-ti-extras/recipes/dtc/dtc/0001-fdtdump-Add-live-tree-dump-capability.patch212
-rw-r--r--meta-ti-extras/recipes/dtc/dtc/0002-DTBO-magic-and-dtbo-format-options.patch253
-rw-r--r--meta-ti-extras/recipes/dtc/dtc/0003-dtc-Plugin-and-fixup-support.patch635
-rw-r--r--meta-ti-extras/recipes/dtc/dtc/0004-plugin-Transparently-support-old-style-syntax.patch61
4 files changed, 0 insertions, 1161 deletions
diff --git a/meta-ti-extras/recipes/dtc/dtc/0001-fdtdump-Add-live-tree-dump-capability.patch b/meta-ti-extras/recipes/dtc/dtc/0001-fdtdump-Add-live-tree-dump-capability.patch
deleted file mode 100644
index 372a430..0000000
--- a/meta-ti-extras/recipes/dtc/dtc/0001-fdtdump-Add-live-tree-dump-capability.patch
+++ /dev/null
@@ -1,212 +0,0 @@
1From da5c33dd94949fa27243faf15cd87e98c53ccb29 Mon Sep 17 00:00:00 2001
2From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
3Date: Tue, 5 Nov 2013 10:16:14 +0200
4Subject: [PATCH] fdtdump: Add live tree dump capability
5
6Adds the capability to dump any point of the kernel's live tree
7which resides usually in /proc/device-tree.
8
9For example you can do this:
10
11 # fdtdump /proc/device-tree/ocp/ethernet\@4a100000/
12 /* dump of live tree at /proc/device-tree/ocp/ethernet@4a100000 */
13 / {
14 name = "ethernet";
15 pinctrl-1 = <0x0000000b>;
16 pinctrl-0 = <0x0000000a>;
17 pinctrl-names = "default", "sleep";
18 ranges;
19 interrupts = <0x00000028 0x00000000 0x00000000 0x00000000>;
20 interrupt-parent = <0x00000001>;
21 #size-cells = <0x00000001>;
22 #address-cells = <0x00000001>;
23 reg = <0x4a100000 0x00000000 0x00000000 0x00000000>;
24 cpts_clock_shift = <0x0000001d>;
25 cpts_clock_mult = <0x80000000>;
26 active_slave = <0x00000000>;
27 slaves = <0x00000002>;
28 mac_control = <0x00000020>;
29 rx_descs = <0x00000040>;
30 no_bd_ram = <0x00000000>;
31 bd_ram_size = <0x00002000>;
32 ale_entries = <0x00000400>;
33 cpdma_channels = <0x00000008>;
34 ti,hwmods = "cpgmac0";
35 compatible = "ti,cpsw";
36 slave@4a100300 {
37 name = "slave";
38 phy-mode = "mii";
39 phy_id = <0x0000000e 0x00000000>;
40 mac-address = [00 00 00 00 00 00];
41 };
42 slave@4a100200 {
43 name = "slave";
44 phy-mode = "mii";
45 phy_id = <0x0000000e 0x00000000>;
46 mac-address = [00 00 00 00 00 00];
47 };
48 mdio@4a101000 {
49 name = "mdio";
50 phandle = <0x0000000e>;
51 linux,phandle = <0x0000000e>;
52 pinctrl-1 = <0x0000000d>;
53 pinctrl-0 = <0x0000000c>;
54 pinctrl-names = "default", "sleep";
55 reg = <0x4a101000 0x00000000>;
56 bus_freq = <0x000f4240>;
57 ti,hwmods = "davinci_mdio";
58 #size-cells = <0x00000000>;
59 #address-cells = <0x00000001>;
60 compatible = "ti,davinci_mdio";
61 };
62 };
63
64This makes it much easier to see the state of the kernel's live tree.
65
66Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
67---
68 fdtdump.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
69 1 file changed, 107 insertions(+)
70
71diff --git a/fdtdump.c b/fdtdump.c
72index 95a6a20..9183555 100644
73--- a/fdtdump.c
74+++ b/fdtdump.c
75@@ -8,6 +8,14 @@
76 #include <stdlib.h>
77 #include <string.h>
78 #include <ctype.h>
79+#include <sys/types.h>
80+#include <sys/stat.h>
81+#include <alloca.h>
82+#include <dirent.h>
83+#include <limits.h>
84+#include <unistd.h>
85+#include <fcntl.h>
86+#include <errno.h>
87
88 #include <libfdt.h>
89 #include <libfdt_env.h>
90@@ -143,6 +151,95 @@ static void dump_blob(void *blob, bool debug)
91 }
92 }
93
94+static void dump_live_internal(const char *path, bool debug, int depth)
95+{
96+ int maxsz = strlen(path) + 1 + PATH_MAX;
97+ char *new_path = alloca(maxsz + 1);
98+ struct stat sb;
99+ struct dirent *de;
100+ char *buf, *p;
101+ int buf_alloc, shift, chunk, left, fd, ret;
102+ DIR *d;
103+
104+ shift = 4;
105+ buf_alloc = 4 * 1024; /* 4K (maximum chunk) */
106+ buf = alloca(buf_alloc + sizeof(uint32_t));
107+ buf[buf_alloc] = '\0'; /* always terminate (just in case) */
108+
109+ d = opendir(path);
110+ if (d == NULL)
111+ die("Could not open %s directory\n", path);
112+
113+ /* first dump the properties (files) */
114+ while ((de = readdir(d)) != NULL) {
115+ /* properties are files */
116+ if (de->d_type != DT_REG)
117+ continue;
118+ snprintf(new_path, maxsz, "%s/%s", path, de->d_name);
119+ new_path[maxsz] = '\0';
120+ printf("%*s%s", depth * shift, "", de->d_name);
121+
122+ if (stat(new_path, &sb) != 0)
123+ die("could not open: %s\n", new_path);
124+
125+ fd = open(new_path, O_RDONLY);
126+ if (fd == -1)
127+ die("Could not open: %s\n", new_path);
128+
129+ chunk = sb.st_size > buf_alloc ? buf_alloc : sb.st_size;
130+ p = buf;
131+ left = chunk;
132+ while (left > 0) {
133+ do {
134+ ret = read(fd, p, left);
135+ } while (ret == -1 && (errno == EAGAIN || errno == EINTR));
136+ if (ret == -1)
137+ die("Read failed on: %s\n", new_path);
138+ left -= ret;
139+ p += ret;
140+ }
141+ close(fd);
142+
143+ if (chunk < sb.st_size)
144+ printf(" (trunc)");
145+ utilfdt_print_data(buf, chunk);
146+ printf(";\n");
147+ }
148+
149+ /* now recurse to the directories */
150+ rewinddir(d);
151+ while ((de = readdir(d)) != NULL) {
152+ /* properties are files */
153+ if (de->d_type != DT_DIR)
154+ continue;
155+ /* skip current and parent directories */
156+ if (strcmp(de->d_name, ".") == 0 ||
157+ strcmp(de->d_name, "..") == 0)
158+ continue;
159+ snprintf(new_path, maxsz, "%s/%s", path, de->d_name);
160+ new_path[maxsz] = '\0';
161+ printf("%*s%s {\n", depth * shift, "", de->d_name);
162+ dump_live_internal(new_path, debug, depth + 1);
163+ printf("%*s};\n", depth * shift, "");
164+ }
165+}
166+
167+static void dump_live(const char *path, bool debug)
168+{
169+ char *fixed_path = alloca(strlen(path) + 1);
170+ char *p;
171+
172+ /* strip trailing / */
173+ strcpy(fixed_path, path);
174+ p = fixed_path + strlen(fixed_path) - 1;
175+ while (*p == '/' && p > fixed_path)
176+ *p-- = '\0';
177+ printf("/* dump of live tree at %s */\n", fixed_path);
178+ printf("/ {\n");
179+ dump_live_internal(fixed_path, debug, 1);
180+ printf("};\n");
181+}
182+
183 /* Usage related data. */
184 static const char usage_synopsis[] = "fdtdump [options] <file>";
185 static const char usage_short_opts[] = "ds" USAGE_COMMON_SHORT_OPTS;
186@@ -165,6 +262,7 @@ int main(int argc, char *argv[])
187 bool debug = false;
188 bool scan = false;
189 off_t len;
190+ struct stat sb;
191
192 while ((opt = util_getopt_long()) != EOF) {
193 switch (opt) {
194@@ -182,6 +280,15 @@ int main(int argc, char *argv[])
195 usage("missing input filename");
196 file = argv[optind];
197
198+ if (stat(file, &sb) != 0)
199+ die("could not open: %s\n", file);
200+
201+ /* dump live tree if it's a directory */
202+ if (S_ISDIR(sb.st_mode)) {
203+ dump_live(file, debug);
204+ return 0;
205+ }
206+
207 buf = utilfdt_read_len(file, &len);
208 if (!buf)
209 die("could not read: %s\n", file);
210--
2111.9.1
212
diff --git a/meta-ti-extras/recipes/dtc/dtc/0002-DTBO-magic-and-dtbo-format-options.patch b/meta-ti-extras/recipes/dtc/dtc/0002-DTBO-magic-and-dtbo-format-options.patch
deleted file mode 100644
index 73e0a09..0000000
--- a/meta-ti-extras/recipes/dtc/dtc/0002-DTBO-magic-and-dtbo-format-options.patch
+++ /dev/null
@@ -1,253 +0,0 @@
1From d69b3ebbf86c45cbe717ee35359e15af3cf02014 Mon Sep 17 00:00:00 2001
2From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
3Date: Thu, 5 May 2016 14:07:48 +0300
4Subject: [PATCH] DTBO magic and dtbo format options
5
6Introduce a new magic number for dynamic plugin objects,
7which is enabled by selecting dtbo/input output options.
8
9Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
10---
11 Documentation/manual.txt | 7 +++++++
12 dtc.c | 14 +++++++++++---
13 dtc.h | 4 ++--
14 fdtdump.c | 2 +-
15 flattree.c | 11 ++++++-----
16 libfdt/fdt.c | 2 +-
17 libfdt/fdt.h | 3 ++-
18 tests/mangle-layout.c | 7 ++++---
19 8 files changed, 34 insertions(+), 16 deletions(-)
20
21diff --git a/Documentation/manual.txt b/Documentation/manual.txt
22index 398de32..f64c4f4 100644
23--- a/Documentation/manual.txt
24+++ b/Documentation/manual.txt
25@@ -60,6 +60,9 @@ The currently supported Input Formats are:
26 - "dtb": "blob" format. A flattened device-tree block with
27 header in one binary blob.
28
29+ - "dtbo" : "blob" format. Identical with "dtb" but meant
30+ for use with dynamic-device tree objects.
31+
32 - "dts": "source" format. A text file containing a "source"
33 for a device-tree.
34
35@@ -71,6 +74,8 @@ The currently supported Output Formats are:
36
37 - "dtb": "blob" format
38
39+ - "dtbo": "blob" format - for objects
40+
41 - "dts": "source" format
42
43 - "asm": assembly language file. A file that can be sourced
44@@ -78,6 +83,8 @@ The currently supported Output Formats are:
45 then simply be added to your Makefile. Additionally, the
46 assembly file exports some symbols that can be used.
47
48+ - "asmo": assembly language file for objects. Identical to "asm"
49+
50
51 3) Command Line
52
53diff --git a/dtc.c b/dtc.c
54index 5fa23c4..63c2c9c 100644
55--- a/dtc.c
56+++ b/dtc.c
57@@ -117,6 +117,8 @@ static const char *guess_type_by_name(const char *fname, const char *fallback)
58 return "dts";
59 if (!strcasecmp(s, ".dtb"))
60 return "dtb";
61+ if (!strcasecmp(s, ".dtbo"))
62+ return "dtbo";
63 return fallback;
64 }
65
66@@ -147,6 +149,8 @@ static const char *guess_input_format(const char *fname, const char *fallback)
67 magic = fdt32_to_cpu(magic);
68 if (magic == FDT_MAGIC)
69 return "dtb";
70+ if (magic == FDT_MAGIC_DTBO)
71+ return "dtbo";
72
73 return guess_type_by_name(fname, fallback);
74 }
75@@ -275,7 +279,7 @@ int main(int argc, char *argv[])
76 bi = dt_from_source(arg);
77 else if (streq(inform, "fs"))
78 bi = dt_from_fs(arg);
79- else if(streq(inform, "dtb"))
80+ else if(streq(inform, "dtb") || streq(inform, "dtbo"))
81 bi = dt_from_blob(arg);
82 else
83 die("Unknown input format \"%s\"\n", inform);
84@@ -306,9 +310,13 @@ int main(int argc, char *argv[])
85 if (streq(outform, "dts")) {
86 dt_to_source(outf, bi);
87 } else if (streq(outform, "dtb")) {
88- dt_to_blob(outf, bi, outversion);
89+ dt_to_blob(outf, bi, FDT_MAGIC, outversion);
90+ } else if (streq(outform, "dtbo")) {
91+ dt_to_blob(outf, bi, FDT_MAGIC_DTBO, outversion);
92 } else if (streq(outform, "asm")) {
93- dt_to_asm(outf, bi, outversion);
94+ dt_to_asm(outf, bi, FDT_MAGIC, outversion);
95+ } else if (streq(outform, "asmo")) {
96+ dt_to_asm(outf, bi, FDT_MAGIC_DTBO, outversion);
97 } else if (streq(outform, "null")) {
98 /* do nothing */
99 } else {
100diff --git a/dtc.h b/dtc.h
101index 56212c8..9d7f2d6 100644
102--- a/dtc.h
103+++ b/dtc.h
104@@ -252,8 +252,8 @@ void process_checks(bool force, struct boot_info *bi);
105
106 /* Flattened trees */
107
108-void dt_to_blob(FILE *f, struct boot_info *bi, int version);
109-void dt_to_asm(FILE *f, struct boot_info *bi, int version);
110+void dt_to_blob(FILE *f, struct boot_info *bi, fdt32_t magic, int version);
111+void dt_to_asm(FILE *f, struct boot_info *bi, fdt32_t magic, int version);
112
113 struct boot_info *dt_from_blob(const char *fname);
114
115diff --git a/fdtdump.c b/fdtdump.c
116index 9183555..11c2b8d 100644
117--- a/fdtdump.c
118+++ b/fdtdump.c
119@@ -306,7 +306,7 @@ int main(int argc, char *argv[])
120 p = memchr(p, smagic[0], endp - p - 4);
121 if (!p)
122 break;
123- if (fdt_magic(p) == FDT_MAGIC) {
124+ if (fdt_magic(p) == FDT_MAGIC || fdt_magic(p) == FDT_MAGIC_DTBO) {
125 /* try and validate the main struct */
126 off_t this_len = endp - p;
127 fdt32_t max_version = 17;
128diff --git a/flattree.c b/flattree.c
129index ec14954..64ed375 100644
130--- a/flattree.c
131+++ b/flattree.c
132@@ -335,6 +335,7 @@ static struct data flatten_reserve_list(struct reserve_info *reservelist,
133 }
134
135 static void make_fdt_header(struct fdt_header *fdt,
136+ fdt32_t magic,
137 struct version_info *vi,
138 int reservesize, int dtsize, int strsize,
139 int boot_cpuid_phys)
140@@ -345,7 +346,7 @@ static void make_fdt_header(struct fdt_header *fdt,
141
142 memset(fdt, 0xff, sizeof(*fdt));
143
144- fdt->magic = cpu_to_fdt32(FDT_MAGIC);
145+ fdt->magic = cpu_to_fdt32(magic);
146 fdt->version = cpu_to_fdt32(vi->version);
147 fdt->last_comp_version = cpu_to_fdt32(vi->last_comp_version);
148
149@@ -366,7 +367,7 @@ static void make_fdt_header(struct fdt_header *fdt,
150 fdt->size_dt_struct = cpu_to_fdt32(dtsize);
151 }
152
153-void dt_to_blob(FILE *f, struct boot_info *bi, int version)
154+void dt_to_blob(FILE *f, struct boot_info *bi, fdt32_t magic, int version)
155 {
156 struct version_info *vi = NULL;
157 int i;
158@@ -390,7 +391,7 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
159 reservebuf = flatten_reserve_list(bi->reservelist, vi);
160
161 /* Make header */
162- make_fdt_header(&fdt, vi, reservebuf.len, dtbuf.len, strbuf.len,
163+ make_fdt_header(&fdt, magic, vi, reservebuf.len, dtbuf.len, strbuf.len,
164 bi->boot_cpuid_phys);
165
166 /*
167@@ -460,7 +461,7 @@ static void dump_stringtable_asm(FILE *f, struct data strbuf)
168 }
169 }
170
171-void dt_to_asm(FILE *f, struct boot_info *bi, int version)
172+void dt_to_asm(FILE *f, struct boot_info *bi, fdt32_t magic, int version)
173 {
174 struct version_info *vi = NULL;
175 int i;
176@@ -832,7 +833,7 @@ struct boot_info *dt_from_blob(const char *fname)
177 }
178
179 magic = fdt32_to_cpu(magic);
180- if (magic != FDT_MAGIC)
181+ if (magic != FDT_MAGIC && magic != FDT_MAGIC_DTBO)
182 die("Blob has incorrect magic number\n");
183
184 rc = fread(&totalsize, sizeof(totalsize), 1, f);
185diff --git a/libfdt/fdt.c b/libfdt/fdt.c
186index 22286a1..28d422c 100644
187--- a/libfdt/fdt.c
188+++ b/libfdt/fdt.c
189@@ -57,7 +57,7 @@
190
191 int fdt_check_header(const void *fdt)
192 {
193- if (fdt_magic(fdt) == FDT_MAGIC) {
194+ if (fdt_magic(fdt) == FDT_MAGIC || fdt_magic(fdt) == FDT_MAGIC_DTBO) {
195 /* Complete tree */
196 if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)
197 return -FDT_ERR_BADVERSION;
198diff --git a/libfdt/fdt.h b/libfdt/fdt.h
199index 526aedb..493cd55 100644
200--- a/libfdt/fdt.h
201+++ b/libfdt/fdt.h
202@@ -55,7 +55,7 @@
203 #ifndef __ASSEMBLY__
204
205 struct fdt_header {
206- fdt32_t magic; /* magic word FDT_MAGIC */
207+ fdt32_t magic; /* magic word FDT_MAGIC[|_DTBO] */
208 fdt32_t totalsize; /* total size of DT block */
209 fdt32_t off_dt_struct; /* offset to structure */
210 fdt32_t off_dt_strings; /* offset to strings */
211@@ -93,6 +93,7 @@ struct fdt_property {
212 #endif /* !__ASSEMBLY */
213
214 #define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */
215+#define FDT_MAGIC_DTBO 0xd00dfdb0 /* DTBO magic */
216 #define FDT_TAGSIZE sizeof(fdt32_t)
217
218 #define FDT_BEGIN_NODE 0x1 /* Start node: full name */
219diff --git a/tests/mangle-layout.c b/tests/mangle-layout.c
220index a76e51e..d29ebc6 100644
221--- a/tests/mangle-layout.c
222+++ b/tests/mangle-layout.c
223@@ -42,7 +42,8 @@ static void expand_buf(struct bufstate *buf, int newsize)
224 buf->size = newsize;
225 }
226
227-static void new_header(struct bufstate *buf, int version, const void *fdt)
228+static void new_header(struct bufstate *buf, fdt32_t magic, int version,
229+ const void *fdt)
230 {
231 int hdrsize;
232
233@@ -56,7 +57,7 @@ static void new_header(struct bufstate *buf, int version, const void *fdt)
234 expand_buf(buf, hdrsize);
235 memset(buf->buf, 0, hdrsize);
236
237- fdt_set_magic(buf->buf, FDT_MAGIC);
238+ fdt_set_magic(buf->buf, magic);
239 fdt_set_version(buf->buf, version);
240 fdt_set_last_comp_version(buf->buf, 16);
241 fdt_set_boot_cpuid_phys(buf->buf, fdt_boot_cpuid_phys(fdt));
242@@ -145,7 +146,7 @@ int main(int argc, char *argv[])
243 if (fdt_version(fdt) < 17)
244 CONFIG("Input tree must be v17");
245
246- new_header(&buf, version, fdt);
247+ new_header(&buf, FDT_MAGIC, version, fdt);
248
249 while (*blockorder) {
250 add_block(&buf, version, *blockorder, fdt);
251--
2521.9.1
253
diff --git a/meta-ti-extras/recipes/dtc/dtc/0003-dtc-Plugin-and-fixup-support.patch b/meta-ti-extras/recipes/dtc/dtc/0003-dtc-Plugin-and-fixup-support.patch
deleted file mode 100644
index 69451b8..0000000
--- a/meta-ti-extras/recipes/dtc/dtc/0003-dtc-Plugin-and-fixup-support.patch
+++ /dev/null
@@ -1,635 +0,0 @@
1From 10e5b09069bb7d5b9c4b1aced82b7b20cd06dd65 Mon Sep 17 00:00:00 2001
2From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
3Date: Tue, 21 Oct 2014 22:07:16 +0300
4Subject: [PATCH] dtc: Plugin and fixup support
5
6This patch enable the generation of symbols & local fixup information
7for trees compiled with the -@ (--symbols) option.
8
9Using this patch labels in the tree and their users emit information
10in __symbols__ and __local_fixups__ nodes.
11
12The __fixups__ node make possible the dynamic resolution of phandle
13references which are present in the plugin tree but lie in the
14tree that are applying the overlay against.
15
16Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
17Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
18Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
19---
20 Documentation/manual.txt | 16 ++++
21 checks.c | 8 +-
22 dtc-lexer.l | 5 ++
23 dtc-parser.y | 45 ++++++++--
24 dtc.c | 23 +++++-
25 dtc.h | 29 ++++++-
26 flattree.c | 2 +-
27 fstree.c | 2 +-
28 livetree.c | 209 ++++++++++++++++++++++++++++++++++++++++++++++-
29 treesource.c | 1 +
30 10 files changed, 327 insertions(+), 13 deletions(-)
31
32diff --git a/Documentation/manual.txt b/Documentation/manual.txt
33index f64c4f4..63066ec 100644
34--- a/Documentation/manual.txt
35+++ b/Documentation/manual.txt
36@@ -126,6 +126,20 @@ Options:
37 Make space for <number> reserve map entries
38 Relevant for dtb and asm output only.
39
40+ -@
41+ Generates a __symbols__ node at the root node of the resulting blob
42+ for any node labels used, and for any local references using phandles
43+ it also generates a __local_fixups__ node that tracks them.
44+
45+ When using the /plugin/ tag all unresolved label references to
46+ be tracked in the __fixups__ node, making dynamic resolution possible.
47+
48+ -A
49+ Generate automatically aliases for all node labels. This is similar to
50+ the -@ option (the __symbols__ node contain identical information) but
51+ the semantics are slightly different since no phandles are automatically
52+ generated for labeled nodes.
53+
54 -S <bytes>
55 Ensure the blob at least <bytes> long, adding additional
56 space if needed.
57@@ -160,6 +174,8 @@ Here is a very rough overview of the layout of a DTS source file:
58
59 devicetree: '/' nodedef
60
61+ plugindecl: '/' 'plugin' '/' ';'
62+
63 nodedef: '{' list_of_property list_of_subnode '}' ';'
64
65 property: label PROPNAME '=' propdata ';'
66diff --git a/checks.c b/checks.c
67index 386f956..3d4c3c6 100644
68--- a/checks.c
69+++ b/checks.c
70@@ -490,8 +490,12 @@ static void fixup_phandle_references(struct check *c, struct node *dt,
71
72 refnode = get_node_by_ref(dt, m->ref);
73 if (! refnode) {
74- FAIL(c, "Reference to non-existent node or label \"%s\"\n",
75- m->ref);
76+ if (!(tree_get_versionflags(dt) & VF_PLUGIN))
77+ FAIL(c, "Reference to non-existent node or "
78+ "label \"%s\"\n", m->ref);
79+ else /* mark the entry as unresolved */
80+ *((cell_t *)(prop->val.val + m->offset)) =
81+ cpu_to_fdt32(0xffffffff);
82 continue;
83 }
84
85diff --git a/dtc-lexer.l b/dtc-lexer.l
86index 790fbf6..40bbc87 100644
87--- a/dtc-lexer.l
88+++ b/dtc-lexer.l
89@@ -121,6 +121,11 @@ static void lexical_error(const char *fmt, ...);
90 return DT_V1;
91 }
92
93+<*>"/plugin/" {
94+ DPRINT("Keyword: /plugin/\n");
95+ return DT_PLUGIN;
96+ }
97+
98 <*>"/memreserve/" {
99 DPRINT("Keyword: /memreserve/\n");
100 BEGIN_DEFAULT();
101diff --git a/dtc-parser.y b/dtc-parser.y
102index 000873f..2890c1c 100644
103--- a/dtc-parser.y
104+++ b/dtc-parser.y
105@@ -19,6 +19,7 @@
106 */
107 %{
108 #include <stdio.h>
109+#include <inttypes.h>
110
111 #include "dtc.h"
112 #include "srcpos.h"
113@@ -33,6 +34,7 @@ extern void yyerror(char const *s);
114
115 extern struct boot_info *the_boot_info;
116 extern bool treesource_error;
117+extern unsigned int the_versionflags;
118 %}
119
120 %union {
121@@ -52,9 +54,11 @@ extern bool treesource_error;
122 struct node *nodelist;
123 struct reserve_info *re;
124 uint64_t integer;
125+ unsigned int flags;
126 }
127
128 %token DT_V1
129+%token DT_PLUGIN
130 %token DT_MEMRESERVE
131 %token DT_LSHIFT DT_RSHIFT DT_LE DT_GE DT_EQ DT_NE DT_AND DT_OR
132 %token DT_BITS
133@@ -71,6 +75,8 @@ extern bool treesource_error;
134
135 %type <data> propdata
136 %type <data> propdataprefix
137+%type <flags> versioninfo
138+%type <flags> plugindecl
139 %type <re> memreserve
140 %type <re> memreserves
141 %type <array> arrayprefix
142@@ -101,13 +107,33 @@ extern bool treesource_error;
143 %%
144
145 sourcefile:
146- DT_V1 ';' memreserves devicetree
147+ versioninfo ';' memreserves devicetree
148 {
149- the_boot_info = build_boot_info($3, $4,
150+ the_boot_info = build_boot_info($1, $3, $4,
151 guess_boot_cpuid($4));
152 }
153 ;
154
155+versioninfo:
156+ DT_V1 plugindecl
157+ {
158+ the_versionflags |= VF_DT_V1 | $2;
159+ $$ = the_versionflags;
160+ }
161+ ;
162+
163+plugindecl:
164+ DT_PLUGIN
165+ {
166+ the_versionflags |= VF_PLUGIN;
167+ $$ = VF_PLUGIN;
168+ }
169+ | /* empty */
170+ {
171+ $$ = 0;
172+ }
173+ ;
174+
175 memreserves:
176 /* empty */
177 {
178@@ -156,10 +182,14 @@ devicetree:
179 {
180 struct node *target = get_node_by_ref($1, $2);
181
182- if (target)
183+ if (target) {
184 merge_nodes(target, $3);
185- else
186- ERROR(&@2, "Label or path %s not found", $2);
187+ } else {
188+ if (the_versionflags & VF_PLUGIN)
189+ add_orphan_node($1, $3, $2);
190+ else
191+ ERROR(&@2, "Label or path %s not found", $2);
192+ }
193 $$ = $1;
194 }
195 | devicetree DT_DEL_NODE DT_REF ';'
196@@ -174,6 +204,11 @@ devicetree:
197
198 $$ = $1;
199 }
200+ | /* empty */
201+ {
202+ /* build empty node */
203+ $$ = name_node(build_node(NULL, NULL), "");
204+ }
205 ;
206
207 nodedef:
208diff --git a/dtc.c b/dtc.c
209index 63c2c9c..a25f852 100644
210--- a/dtc.c
211+++ b/dtc.c
212@@ -31,6 +31,8 @@ int reservenum; /* Number of memory reservation slots */
213 int minsize; /* Minimum blob size */
214 int padsize; /* Additional padding to blob */
215 int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */
216+int symbol_fixup_support;
217+int auto_label_aliases;
218
219 static void fill_fullpaths(struct node *tree, const char *prefix)
220 {
221@@ -53,7 +55,7 @@ static void fill_fullpaths(struct node *tree, const char *prefix)
222 #define FDT_VERSION(version) _FDT_VERSION(version)
223 #define _FDT_VERSION(version) #version
224 static const char usage_synopsis[] = "dtc [options] <input file>";
225-static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv";
226+static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:fb:i:H:sW:E:@Ahv";
227 static struct option const usage_long_opts[] = {
228 {"quiet", no_argument, NULL, 'q'},
229 {"in-format", a_argument, NULL, 'I'},
230@@ -71,6 +73,8 @@ static struct option const usage_long_opts[] = {
231 {"phandle", a_argument, NULL, 'H'},
232 {"warning", a_argument, NULL, 'W'},
233 {"error", a_argument, NULL, 'E'},
234+ {"symbols", no_argument, NULL, '@'},
235+ {"auto-alias", no_argument, NULL, 'A'},
236 {"help", no_argument, NULL, 'h'},
237 {"version", no_argument, NULL, 'v'},
238 {NULL, no_argument, NULL, 0x0},
239@@ -101,6 +105,8 @@ static const char * const usage_opts_help[] = {
240 "\t\tboth - Both \"linux,phandle\" and \"phandle\" properties",
241 "\n\tEnable/disable warnings (prefix with \"no-\")",
242 "\n\tEnable/disable errors (prefix with \"no-\")",
243+ "\n\tEnable symbols/fixup support",
244+ "\n\tEnable auto-alias of labels",
245 "\n\tPrint this help and exit",
246 "\n\tPrint version and exit",
247 NULL,
248@@ -237,7 +243,12 @@ int main(int argc, char *argv[])
249 case 'E':
250 parse_checks_option(false, true, optarg);
251 break;
252-
253+ case '@':
254+ symbol_fixup_support = 1;
255+ break;
256+ case 'A':
257+ auto_label_aliases = 1;
258+ break;
259 case 'h':
260 usage(NULL);
261 default:
262@@ -295,6 +306,14 @@ int main(int argc, char *argv[])
263 fill_fullpaths(bi->dt, "");
264 process_checks(force, bi);
265
266+ if (auto_label_aliases)
267+ generate_label_tree(bi->dt, "aliases", false);
268+
269+ if (symbol_fixup_support) {
270+ generate_label_tree(bi->dt, "__symbols__", true);
271+ generate_fixups_tree(bi->dt);
272+ }
273+
274 if (sort)
275 sort_tree(bi);
276
277diff --git a/dtc.h b/dtc.h
278index 9d7f2d6..392cde7 100644
279--- a/dtc.h
280+++ b/dtc.h
281@@ -54,6 +54,12 @@ extern int reservenum; /* Number of memory reservation slots */
282 extern int minsize; /* Minimum blob size */
283 extern int padsize; /* Additional padding to blob */
284 extern int phandle_format; /* Use linux,phandle or phandle properties */
285+extern int symbol_fixup_support;/* enable symbols & fixup support */
286+extern int auto_label_aliases; /* auto generate labels -> aliases */
287+
288+/*
289+ * Tree source globals
290+ */
291
292 #define PHANDLE_LEGACY 0x1
293 #define PHANDLE_EPAPR 0x2
294@@ -158,6 +164,9 @@ struct node {
295 int addr_cells, size_cells;
296
297 struct label *labels;
298+
299+ /* only for the root (parent == NULL) */
300+ struct boot_info *bi;
301 };
302
303 #define for_each_label_withdel(l0, l) \
304@@ -194,6 +203,7 @@ struct node *build_node_delete(void);
305 struct node *name_node(struct node *node, char *name);
306 struct node *chain_node(struct node *first, struct node *list);
307 struct node *merge_nodes(struct node *old_node, struct node *new_node);
308+void add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
309
310 void add_property(struct node *node, struct property *prop);
311 void delete_property_by_name(struct node *node, char *name);
312@@ -201,6 +211,8 @@ void delete_property(struct property *prop);
313 void add_child(struct node *parent, struct node *child);
314 void delete_node_by_name(struct node *parent, char *name);
315 void delete_node(struct node *node);
316+struct property *append_to_property(struct node *node,
317+ char *name, const void *data, int len);
318
319 const char *get_unitname(struct node *node);
320 struct property *get_property(struct node *node, const char *propname);
321@@ -236,14 +248,29 @@ struct reserve_info *add_reserve_entry(struct reserve_info *list,
322
323
324 struct boot_info {
325+ unsigned int versionflags;
326 struct reserve_info *reservelist;
327 struct node *dt; /* the device tree */
328 uint32_t boot_cpuid_phys;
329 };
330
331-struct boot_info *build_boot_info(struct reserve_info *reservelist,
332+/* version flags definitions */
333+#define VF_DT_V1 0x0001 /* /dts-v1/ */
334+#define VF_PLUGIN 0x0002 /* /plugin/ */
335+
336+static inline unsigned int tree_get_versionflags(struct node *dt)
337+{
338+ if (!dt || !dt->bi)
339+ return 0;
340+ return dt->bi->versionflags;
341+}
342+
343+struct boot_info *build_boot_info(unsigned int versionflags,
344+ struct reserve_info *reservelist,
345 struct node *tree, uint32_t boot_cpuid_phys);
346 void sort_tree(struct boot_info *bi);
347+void generate_label_tree(struct node *dt, char *gen_node_name, bool allocph);
348+void generate_fixups_tree(struct node *dt);
349
350 /* Checks */
351
352diff --git a/flattree.c b/flattree.c
353index 64ed375..4fe64d4 100644
354--- a/flattree.c
355+++ b/flattree.c
356@@ -930,5 +930,5 @@ struct boot_info *dt_from_blob(const char *fname)
357
358 fclose(f);
359
360- return build_boot_info(reservelist, tree, boot_cpuid_phys);
361+ return build_boot_info(VF_DT_V1, reservelist, tree, boot_cpuid_phys);
362 }
363diff --git a/fstree.c b/fstree.c
364index 6d1beec..54f520b 100644
365--- a/fstree.c
366+++ b/fstree.c
367@@ -86,6 +86,6 @@ struct boot_info *dt_from_fs(const char *dirname)
368 tree = read_fstree(dirname);
369 tree = name_node(tree, "");
370
371- return build_boot_info(NULL, tree, guess_boot_cpuid(tree));
372+ return build_boot_info(VF_DT_V1, NULL, tree, guess_boot_cpuid(tree));
373 }
374
375diff --git a/livetree.c b/livetree.c
376index e229b84..3eab9e2 100644
377--- a/livetree.c
378+++ b/livetree.c
379@@ -216,6 +216,31 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node)
380 return old_node;
381 }
382
383+void add_orphan_node(struct node *dt, struct node *new_node, char *ref)
384+{
385+ static unsigned int next_orphan_fragment = 0;
386+ struct node *node = xmalloc(sizeof(*node));
387+ struct property *p;
388+ struct data d = empty_data;
389+ char *name;
390+
391+ memset(node, 0, sizeof(*node));
392+
393+ d = data_add_marker(d, REF_PHANDLE, ref);
394+ d = data_append_integer(d, 0xffffffff, 32);
395+
396+ p = build_property("target", d);
397+ add_property(node, p);
398+
399+ xasprintf(&name, "fragment@%u",
400+ next_orphan_fragment++);
401+ name_node(node, name);
402+ name_node(new_node, "__overlay__");
403+
404+ add_child(dt, node);
405+ add_child(node, new_node);
406+}
407+
408 struct node *chain_node(struct node *first, struct node *list)
409 {
410 assert(first->next_sibling == NULL);
411@@ -296,6 +321,24 @@ void delete_node(struct node *node)
412 delete_labels(&node->labels);
413 }
414
415+struct property *append_to_property(struct node *node,
416+ char *name, const void *data, int len)
417+{
418+ struct data d;
419+ struct property *p;
420+
421+ p = get_property(node, name);
422+ if (p) {
423+ d = data_append_data(p->val, data, len);
424+ p->val = d;
425+ } else {
426+ d = data_append_data(empty_data, data, len);
427+ p = build_property(name, d);
428+ add_property(node, p);
429+ }
430+ return p;
431+}
432+
433 struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size)
434 {
435 struct reserve_info *new = xmalloc(sizeof(*new));
436@@ -335,15 +378,19 @@ struct reserve_info *add_reserve_entry(struct reserve_info *list,
437 return list;
438 }
439
440-struct boot_info *build_boot_info(struct reserve_info *reservelist,
441+struct boot_info *build_boot_info(unsigned int versionflags,
442+ struct reserve_info *reservelist,
443 struct node *tree, uint32_t boot_cpuid_phys)
444 {
445 struct boot_info *bi;
446
447 bi = xmalloc(sizeof(*bi));
448+ bi->versionflags = versionflags;
449 bi->reservelist = reservelist;
450 bi->dt = tree;
451 bi->boot_cpuid_phys = boot_cpuid_phys;
452+ /* link back */
453+ tree->bi = bi;
454
455 return bi;
456 }
457@@ -709,3 +756,163 @@ void sort_tree(struct boot_info *bi)
458 sort_reserve_entries(bi);
459 sort_node(bi->dt);
460 }
461+
462+/* utility helper to avoid code duplication */
463+static struct node *build_and_name_child_node(struct node *parent, char *name)
464+{
465+ struct node *node;
466+
467+ node = build_node(NULL, NULL);
468+ name_node(node, xstrdup(name));
469+ add_child(parent, node);
470+
471+ return node;
472+}
473+
474+static void generate_label_tree_internal(struct node *dt, struct node *node,
475+ struct node *an, bool allocph)
476+{
477+ struct node *c;
478+ struct property *p;
479+ struct label *l;
480+
481+ /* if if there are labels */
482+ if (node->labels) {
483+ /* now add the label in the node */
484+ for_each_label(node->labels, l) {
485+ /* check whether the label already exists */
486+ p = get_property(an, l->label);
487+ if (p) {
488+ fprintf(stderr, "WARNING: label %s already"
489+ " exists in /%s", l->label,
490+ an->name);
491+ continue;
492+ }
493+
494+ /* insert it */
495+ p = build_property(l->label,
496+ data_copy_escape_string(node->fullpath,
497+ strlen(node->fullpath)));
498+ add_property(an, p);
499+ }
500+
501+ /* force allocation of a phandle for this node */
502+ if (allocph)
503+ (void)get_node_phandle(dt, node);
504+ }
505+
506+ for_each_child(node, c)
507+ generate_label_tree_internal(dt, c, an, allocph);
508+}
509+
510+void generate_label_tree(struct node *dt, char *gen_node_name, bool allocph)
511+{
512+ struct node *an;
513+
514+ an = build_and_name_child_node(dt, gen_node_name);
515+ if (!an)
516+ die("Could not build label node /%s\n", gen_node_name);
517+
518+ generate_label_tree_internal(dt, dt, an, allocph);
519+}
520+
521+static char *fixups_name = "__fixups__";
522+static char *local_fixups_name = "__local_fixups__";
523+
524+static void add_fixup_entry(struct node *dt, struct node *node,
525+ struct property *prop, struct marker *m)
526+{
527+ struct node *fn; /* fixup node */
528+ char *entry;
529+
530+ /* m->ref can only be a REF_PHANDLE, but check anyway */
531+ assert(m->type == REF_PHANDLE);
532+
533+ /* fn is the node we're putting entries in */
534+ fn = get_subnode(dt, fixups_name);
535+ assert(fn != NULL);
536+
537+ /* there shouldn't be any ':' in the arguments */
538+ if (strchr(node->fullpath, ':') || strchr(prop->name, ':'))
539+ die("arguments should not contain ':'\n");
540+
541+ xasprintf(&entry, "%s:%s:%u",
542+ node->fullpath, prop->name, m->offset);
543+ append_to_property(fn, m->ref, entry, strlen(entry) + 1);
544+}
545+
546+static void add_local_fixup_entry(struct node *dt, struct node *node,
547+ struct property *prop, struct marker *m,
548+ struct node *refnode)
549+{
550+ struct node *lfn, *wn, *nwn; /* local fixup node, walk node, new */
551+ uint32_t value_32;
552+ char *s, *e, *comp;
553+ int len;
554+
555+ /* fn is the node we're putting entries in */
556+ lfn = get_subnode(dt, local_fixups_name);
557+ assert(lfn != NULL);
558+
559+ /* walk the path components creating nodes if they don't exist */
560+ comp = xmalloc(strlen(node->fullpath) + 1);
561+ /* start skipping the first / */
562+ s = node->fullpath + 1;
563+ wn = lfn;
564+ while (*s) {
565+ /* retrieve path component */
566+ e = strchr(s, '/');
567+ if (e == NULL)
568+ e = s + strlen(s);
569+ len = e - s;
570+ memcpy(comp, s, len);
571+ comp[len] = '\0';
572+
573+ /* if no node exists, create it */
574+ nwn = get_subnode(wn, comp);
575+ if (!nwn)
576+ nwn = build_and_name_child_node(wn, comp);
577+ wn = nwn;
578+
579+ /* last path component */
580+ if (!*e)
581+ break;
582+
583+ /* next path component */
584+ s = e + 1;
585+ }
586+ free(comp);
587+
588+ value_32 = cpu_to_fdt32(m->offset);
589+ append_to_property(wn, prop->name, &value_32, sizeof(value_32));
590+}
591+
592+static void generate_fixups_tree_internal(struct node *dt, struct node *node)
593+{
594+ struct node *c;
595+ struct property *prop;
596+ struct marker *m;
597+ struct node *refnode;
598+
599+ for_each_property(node, prop) {
600+ m = prop->val.markers;
601+ for_each_marker_of_type(m, REF_PHANDLE) {
602+ refnode = get_node_by_ref(dt, m->ref);
603+ if (!refnode)
604+ add_fixup_entry(dt, node, prop, m);
605+ else
606+ add_local_fixup_entry(dt, node, prop, m,
607+ refnode);
608+ }
609+ }
610+
611+ for_each_child(node, c)
612+ generate_fixups_tree_internal(dt, c);
613+}
614+
615+void generate_fixups_tree(struct node *dt)
616+{
617+ build_and_name_child_node(dt, fixups_name);
618+ build_and_name_child_node(dt, local_fixups_name);
619+ generate_fixups_tree_internal(dt, dt);
620+}
621diff --git a/treesource.c b/treesource.c
622index a55d1d1..2539a57 100644
623--- a/treesource.c
624+++ b/treesource.c
625@@ -27,6 +27,7 @@ extern YYLTYPE yylloc;
626
627 struct boot_info *the_boot_info;
628 bool treesource_error;
629+unsigned int the_versionflags;
630
631 struct boot_info *dt_from_source(const char *fname)
632 {
633--
6341.9.1
635
diff --git a/meta-ti-extras/recipes/dtc/dtc/0004-plugin-Transparently-support-old-style-syntax.patch b/meta-ti-extras/recipes/dtc/dtc/0004-plugin-Transparently-support-old-style-syntax.patch
deleted file mode 100644
index ad4eb5b..0000000
--- a/meta-ti-extras/recipes/dtc/dtc/0004-plugin-Transparently-support-old-style-syntax.patch
+++ /dev/null
@@ -1,61 +0,0 @@
1From f7da040f2bed614fd55a4901d71fafb916863e8a Mon Sep 17 00:00:00 2001
2From: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
3Date: Wed, 20 Apr 2016 20:36:35 +0300
4Subject: [PATCH] plugin: Transparently support old style syntax
5
6The old style syntax for plugins is still out in the wild.
7This patch transparently support it.
8
9Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
10---
11 dtc-parser.y | 19 ++++++++++++++++---
12 1 file changed, 16 insertions(+), 3 deletions(-)
13
14diff --git a/dtc-parser.y b/dtc-parser.y
15index 2890c1c..4a67baf 100644
16--- a/dtc-parser.y
17+++ b/dtc-parser.y
18@@ -77,6 +77,7 @@ extern unsigned int the_versionflags;
19 %type <data> propdataprefix
20 %type <flags> versioninfo
21 %type <flags> plugindecl
22+%type <flags> oldplugindecl
23 %type <re> memreserve
24 %type <re> memreserves
25 %type <array> arrayprefix
26@@ -107,10 +108,10 @@ extern unsigned int the_versionflags;
27 %%
28
29 sourcefile:
30- versioninfo ';' memreserves devicetree
31+ versioninfo ';' oldplugindecl memreserves devicetree
32 {
33- the_boot_info = build_boot_info($1, $3, $4,
34- guess_boot_cpuid($4));
35+ the_boot_info = build_boot_info($1 | $3, $4, $5,
36+ guess_boot_cpuid($5));
37 }
38 ;
39
40@@ -134,6 +135,18 @@ plugindecl:
41 }
42 ;
43
44+oldplugindecl:
45+ DT_PLUGIN ';'
46+ {
47+ the_versionflags |= VF_PLUGIN;
48+ $$ = VF_PLUGIN;
49+ }
50+ | /* empty */
51+ {
52+ $$ = 0;
53+ }
54+ ;
55+
56 memreserves:
57 /* empty */
58 {
59--
601.9.1
61