~ubuntu-branches/debian/stretch/device-tree-compiler/stretch

« back to all changes in this revision

Viewing changes to debian/patches/16_fdtdump-rename-from-ftdump.patch

  • Committer: Package Import Robot
  • Author(s): Hector Oron
  • Date: 2012-01-28 01:16:09 UTC
  • Revision ID: package-import@ubuntu.com-20120128011609-vs6417ofg0ytw1e4
Tags: 1.3.0-2
* Add libfdt package (Closes: #477565)
  - Thanks Dmitry Eremin-Solenikov and Aurelien Jarno for patch.
* Backport upstream fixes as patches until 2012-1-21.
* Reword package description to generalize architecture support.
  - Removes OpenFirmware and PowerPC references.
* Update dtc manpage and include fdtget, fdtput, fdtdump, convert-dtsv0,
  dtdiff manpages.
* d/rules: Add build-arch and build-indep targets.
* d/README.source: refer to quilt patching system.
* Remove Apps top-level section from doc-base.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
Acked-by: David Gibson <david@gibson.dropbear.id.au>
16
16
---
17
17
 
18
 
diff --git a/.gitignore b/.gitignore
19
 
index ae7a46a..74714cd 100644
20
 
--- a/.gitignore
21
 
+++ b/.gitignore
 
18
Index: device-tree-compiler-1.3.0/.gitignore
 
19
===================================================================
 
20
--- device-tree-compiler-1.3.0.orig/.gitignore  2012-01-30 15:03:30.095993353 +0100
 
21
+++ device-tree-compiler-1.3.0/.gitignore       2012-01-30 15:03:34.487993309 +0100
22
22
@@ -7,6 +7,6 @@
23
23
 lex.yy.c
24
24
 *.lex.c
27
27
+/fdtdump
28
28
 /convert-dtsv0
29
29
 /version_gen.h
30
 
diff --git a/Documentation/manual.txt b/Documentation/manual.txt
31
 
index f8a8a7b..14508f3 100644
32
 
--- a/Documentation/manual.txt
33
 
+++ b/Documentation/manual.txt
34
 
@@ -21,7 +21,7 @@ III - libfdt
 
30
Index: device-tree-compiler-1.3.0/Documentation/manual.txt
 
31
===================================================================
 
32
--- device-tree-compiler-1.3.0.orig/Documentation/manual.txt    2012-01-30 15:03:30.075993336 +0100
 
33
+++ device-tree-compiler-1.3.0/Documentation/manual.txt 2012-01-30 15:03:34.487993309 +0100
 
34
@@ -21,7 +21,7 @@
35
35
 
36
36
 IV - Utility Tools
37
37
     1) convert-dtsv0 -- Conversion to Version 1
40
40
 
41
41
 
42
42
 I - "dtc", the device tree compiler
43
 
@@ -643,10 +643,10 @@ a new file with a "v1" appended the filename.
 
43
@@ -643,10 +643,10 @@
44
44
 Comments, empty lines, etc. are preserved.
45
45
 
46
46
 
55
55
 
56
56
-    ftdump <DTB-file-name>
57
57
+    fdtdump <DTB-file-name>
58
 
diff --git a/Makefile b/Makefile
59
 
index b32409b..4582f5d 100644
60
 
--- a/Makefile
61
 
+++ b/Makefile
62
 
@@ -109,7 +109,7 @@ include Makefile.utils
 
58
Index: device-tree-compiler-1.3.0/Makefile
 
59
===================================================================
 
60
--- device-tree-compiler-1.3.0.orig/Makefile    2012-01-30 15:03:30.023993406 +0100
 
61
+++ device-tree-compiler-1.3.0/Makefile 2012-01-30 15:03:34.487993309 +0100
 
62
@@ -109,7 +109,7 @@
63
63
 
64
64
 BIN += convert-dtsv0
65
65
 BIN += dtc
68
68
 
69
69
 SCRIPTS = dtdiff
70
70
 
71
 
@@ -119,7 +119,7 @@ all: $(BIN) libfdt
 
71
@@ -119,7 +119,7 @@
72
72
 ifneq ($(DEPTARGETS),)
73
73
 -include $(DTC_OBJS:%.o=%.d)
74
74
 -include $(CONVERT_OBJS:%.o=%.d)
77
77
 endif
78
78
 
79
79
 
80
 
@@ -178,7 +178,7 @@ convert-dtsv0: $(CONVERT_OBJS)
 
80
@@ -178,7 +178,7 @@
81
81
        @$(VECHO) LD $@
82
82
        $(LINK.c) -o $@ $^
83
83
 
86
86
 
87
87
 
88
88
 #
89
 
diff --git a/Makefile.utils b/Makefile.utils
90
 
index 0ed9297..fae5b00 100644
91
 
--- a/Makefile.utils
92
 
+++ b/Makefile.utils
 
89
Index: device-tree-compiler-1.3.0/Makefile.utils
 
90
===================================================================
 
91
--- device-tree-compiler-1.3.0.orig/Makefile.utils      2012-01-30 15:03:30.043993314 +0100
 
92
+++ device-tree-compiler-1.3.0/Makefile.utils   2012-01-30 15:03:34.491993307 +0100
93
93
@@ -3,8 +3,8 @@
94
94
 # be easily embeddable into other systems of Makefiles.
95
95
 #
102
102
 
103
103
-FTDUMP_OBJS = $(FTDUMP_SRCS:%.c=%.o)
104
104
+FDTDUMP_OBJS = $(FDTDUMP_SRCS:%.c=%.o)
105
 
diff --git a/ftdump.c b/fdtdump.c
106
 
similarity index 97%
107
 
rename from ftdump.c
108
 
rename to fdtdump.c
109
 
index cc55fe2..207a46d 100644
110
 
--- a/ftdump.c
111
 
+++ b/fdtdump.c
112
 
@@ -1,5 +1,5 @@
113
 
 /*
 
105
Index: device-tree-compiler-1.3.0/ftdump.c
 
106
===================================================================
 
107
--- device-tree-compiler-1.3.0.orig/ftdump.c    2012-01-30 15:03:30.059993370 +0100
 
108
+++ /dev/null   1970-01-01 00:00:00.000000000 +0000
 
109
@@ -1,162 +0,0 @@
 
110
-/*
114
111
- * ftdump.c - Contributed by Pantelis Antoniou <pantelis.antoniou AT gmail.com>
 
112
- */
 
113
-
 
114
-#include <stdint.h>
 
115
-#include <stdio.h>
 
116
-#include <stdlib.h>
 
117
-#include <string.h>
 
118
-#include <ctype.h>
 
119
-
 
120
-#include <fdt.h>
 
121
-#include <libfdt_env.h>
 
122
-
 
123
-#include "util.h"
 
124
-
 
125
-#define ALIGN(x, a)    (((x) + ((a) - 1)) & ~((a) - 1))
 
126
-#define PALIGN(p, a)   ((void *)(ALIGN((unsigned long)(p), (a))))
 
127
-#define GET_CELL(p)    (p += 4, *((const uint32_t *)(p-4)))
 
128
-
 
129
-static void print_data(const char *data, int len)
 
130
-{
 
131
-       int i;
 
132
-       const char *p = data;
 
133
-
 
134
-       /* no data, don't print */
 
135
-       if (len == 0)
 
136
-               return;
 
137
-
 
138
-       if (util_is_printable_string(data, len)) {
 
139
-               printf(" = \"%s\"", (const char *)data);
 
140
-       } else if ((len % 4) == 0) {
 
141
-               printf(" = <");
 
142
-               for (i = 0; i < len; i += 4)
 
143
-                       printf("0x%08x%s", fdt32_to_cpu(GET_CELL(p)),
 
144
-                              i < (len - 4) ? " " : "");
 
145
-               printf(">");
 
146
-       } else {
 
147
-               printf(" = [");
 
148
-               for (i = 0; i < len; i++)
 
149
-                       printf("%02x%s", *p++, i < len - 1 ? " " : "");
 
150
-               printf("]");
 
151
-       }
 
152
-}
 
153
-
 
154
-static void dump_blob(void *blob)
 
155
-{
 
156
-       struct fdt_header *bph = blob;
 
157
-       uint32_t off_mem_rsvmap = fdt32_to_cpu(bph->off_mem_rsvmap);
 
158
-       uint32_t off_dt = fdt32_to_cpu(bph->off_dt_struct);
 
159
-       uint32_t off_str = fdt32_to_cpu(bph->off_dt_strings);
 
160
-       struct fdt_reserve_entry *p_rsvmap =
 
161
-               (struct fdt_reserve_entry *)((char *)blob + off_mem_rsvmap);
 
162
-       const char *p_struct = (const char *)blob + off_dt;
 
163
-       const char *p_strings = (const char *)blob + off_str;
 
164
-       uint32_t version = fdt32_to_cpu(bph->version);
 
165
-       uint32_t totalsize = fdt32_to_cpu(bph->totalsize);
 
166
-       uint32_t tag;
 
167
-       const char *p, *s, *t;
 
168
-       int depth, sz, shift;
 
169
-       int i;
 
170
-       uint64_t addr, size;
 
171
-
 
172
-       depth = 0;
 
173
-       shift = 4;
 
174
-
 
175
-       printf("/dts-v1/;\n");
 
176
-       printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic));
 
177
-       printf("// totalsize:\t\t0x%x (%d)\n", totalsize, totalsize);
 
178
-       printf("// off_dt_struct:\t0x%x\n", off_dt);
 
179
-       printf("// off_dt_strings:\t0x%x\n", off_str);
 
180
-       printf("// off_mem_rsvmap:\t0x%x\n", off_mem_rsvmap);
 
181
-       printf("// version:\t\t%d\n", version);
 
182
-       printf("// last_comp_version:\t%d\n",
 
183
-              fdt32_to_cpu(bph->last_comp_version));
 
184
-       if (version >= 2)
 
185
-               printf("// boot_cpuid_phys:\t0x%x\n",
 
186
-                      fdt32_to_cpu(bph->boot_cpuid_phys));
 
187
-
 
188
-       if (version >= 3)
 
189
-               printf("// size_dt_strings:\t0x%x\n",
 
190
-                      fdt32_to_cpu(bph->size_dt_strings));
 
191
-       if (version >= 17)
 
192
-               printf("// size_dt_struct:\t0x%x\n",
 
193
-                      fdt32_to_cpu(bph->size_dt_struct));
 
194
-       printf("\n");
 
195
-
 
196
-       for (i = 0; ; i++) {
 
197
-               addr = fdt64_to_cpu(p_rsvmap[i].address);
 
198
-               size = fdt64_to_cpu(p_rsvmap[i].size);
 
199
-               if (addr == 0 && size == 0)
 
200
-                       break;
 
201
-
 
202
-               printf("/memreserve/ %llx %llx;\n",
 
203
-                      (unsigned long long)addr, (unsigned long long)size);
 
204
-       }
 
205
-
 
206
-       p = p_struct;
 
207
-       while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) {
 
208
-
 
209
-               /* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */
 
210
-
 
211
-               if (tag == FDT_BEGIN_NODE) {
 
212
-                       s = p;
 
213
-                       p = PALIGN(p + strlen(s) + 1, 4);
 
214
-
 
215
-                       if (*s == '\0')
 
216
-                               s = "/";
 
217
-
 
218
-                       printf("%*s%s {\n", depth * shift, "", s);
 
219
-
 
220
-                       depth++;
 
221
-                       continue;
 
222
-               }
 
223
-
 
224
-               if (tag == FDT_END_NODE) {
 
225
-                       depth--;
 
226
-
 
227
-                       printf("%*s};\n", depth * shift, "");
 
228
-                       continue;
 
229
-               }
 
230
-
 
231
-               if (tag == FDT_NOP) {
 
232
-                       printf("%*s// [NOP]\n", depth * shift, "");
 
233
-                       continue;
 
234
-               }
 
235
-
 
236
-               if (tag != FDT_PROP) {
 
237
-                       fprintf(stderr, "%*s ** Unknown tag 0x%08x\n", depth * shift, "", tag);
 
238
-                       break;
 
239
-               }
 
240
-               sz = fdt32_to_cpu(GET_CELL(p));
 
241
-               s = p_strings + fdt32_to_cpu(GET_CELL(p));
 
242
-               if (version < 16 && sz >= 8)
 
243
-                       p = PALIGN(p, 8);
 
244
-               t = p;
 
245
-
 
246
-               p = PALIGN(p + sz, 4);
 
247
-
 
248
-               printf("%*s%s", depth * shift, "", s);
 
249
-               print_data(t, sz);
 
250
-               printf(";\n");
 
251
-       }
 
252
-}
 
253
-
 
254
-
 
255
-int main(int argc, char *argv[])
 
256
-{
 
257
-       char *buf;
 
258
-
 
259
-       if (argc < 2) {
 
260
-               fprintf(stderr, "supply input filename\n");
 
261
-               return 5;
 
262
-       }
 
263
-
 
264
-       buf = utilfdt_read(argv[1]);
 
265
-       if (buf)
 
266
-               dump_blob(buf);
 
267
-       else
 
268
-               return 10;
 
269
-
 
270
-       return 0;
 
271
-}
 
272
Index: device-tree-compiler-1.3.0/fdtdump.c
 
273
===================================================================
 
274
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
275
+++ device-tree-compiler-1.3.0/fdtdump.c        2012-01-30 15:04:46.255989457 +0100
 
276
@@ -0,0 +1,162 @@
 
277
+/*
115
278
+ * fdtdump.c - Contributed by Pantelis Antoniou <pantelis.antoniou AT gmail.com>
116
 
  */
117
 
 
118
 
 #include <stdint.h>
 
279
+ */
 
280
+
 
281
+#include <stdint.h>
 
282
+#include <stdio.h>
 
283
+#include <stdlib.h>
 
284
+#include <string.h>
 
285
+#include <ctype.h>
 
286
+
 
287
+#include <fdt.h>
 
288
+#include <libfdt_env.h>
 
289
+
 
290
+#include "util.h"
 
291
+
 
292
+#define ALIGN(x, a)    (((x) + ((a) - 1)) & ~((a) - 1))
 
293
+#define PALIGN(p, a)   ((void *)(ALIGN((unsigned long)(p), (a))))
 
294
+#define GET_CELL(p)    (p += 4, *((const uint32_t *)(p-4)))
 
295
+
 
296
+static void print_data(const char *data, int len)
 
297
+{
 
298
+       int i;
 
299
+       const char *p = data;
 
300
+
 
301
+       /* no data, don't print */
 
302
+       if (len == 0)
 
303
+               return;
 
304
+
 
305
+       if (util_is_printable_string(data, len)) {
 
306
+               printf(" = \"%s\"", (const char *)data);
 
307
+       } else if ((len % 4) == 0) {
 
308
+               printf(" = <");
 
309
+               for (i = 0; i < len; i += 4)
 
310
+                       printf("0x%08x%s", fdt32_to_cpu(GET_CELL(p)),
 
311
+                              i < (len - 4) ? " " : "");
 
312
+               printf(">");
 
313
+       } else {
 
314
+               printf(" = [");
 
315
+               for (i = 0; i < len; i++)
 
316
+                       printf("%02x%s", *p++, i < len - 1 ? " " : "");
 
317
+               printf("]");
 
318
+       }
 
319
+}
 
320
+
 
321
+static void dump_blob(void *blob)
 
322
+{
 
323
+       struct fdt_header *bph = blob;
 
324
+       uint32_t off_mem_rsvmap = fdt32_to_cpu(bph->off_mem_rsvmap);
 
325
+       uint32_t off_dt = fdt32_to_cpu(bph->off_dt_struct);
 
326
+       uint32_t off_str = fdt32_to_cpu(bph->off_dt_strings);
 
327
+       struct fdt_reserve_entry *p_rsvmap =
 
328
+               (struct fdt_reserve_entry *)((char *)blob + off_mem_rsvmap);
 
329
+       const char *p_struct = (const char *)blob + off_dt;
 
330
+       const char *p_strings = (const char *)blob + off_str;
 
331
+       uint32_t version = fdt32_to_cpu(bph->version);
 
332
+       uint32_t totalsize = fdt32_to_cpu(bph->totalsize);
 
333
+       uint32_t tag;
 
334
+       const char *p, *s, *t;
 
335
+       int depth, sz, shift;
 
336
+       int i;
 
337
+       uint64_t addr, size;
 
338
+
 
339
+       depth = 0;
 
340
+       shift = 4;
 
341
+
 
342
+       printf("/dts-v1/;\n");
 
343
+       printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic));
 
344
+       printf("// totalsize:\t\t0x%x (%d)\n", totalsize, totalsize);
 
345
+       printf("// off_dt_struct:\t0x%x\n", off_dt);
 
346
+       printf("// off_dt_strings:\t0x%x\n", off_str);
 
347
+       printf("// off_mem_rsvmap:\t0x%x\n", off_mem_rsvmap);
 
348
+       printf("// version:\t\t%d\n", version);
 
349
+       printf("// last_comp_version:\t%d\n",
 
350
+              fdt32_to_cpu(bph->last_comp_version));
 
351
+       if (version >= 2)
 
352
+               printf("// boot_cpuid_phys:\t0x%x\n",
 
353
+                      fdt32_to_cpu(bph->boot_cpuid_phys));
 
354
+
 
355
+       if (version >= 3)
 
356
+               printf("// size_dt_strings:\t0x%x\n",
 
357
+                      fdt32_to_cpu(bph->size_dt_strings));
 
358
+       if (version >= 17)
 
359
+               printf("// size_dt_struct:\t0x%x\n",
 
360
+                      fdt32_to_cpu(bph->size_dt_struct));
 
361
+       printf("\n");
 
362
+
 
363
+       for (i = 0; ; i++) {
 
364
+               addr = fdt64_to_cpu(p_rsvmap[i].address);
 
365
+               size = fdt64_to_cpu(p_rsvmap[i].size);
 
366
+               if (addr == 0 && size == 0)
 
367
+                       break;
 
368
+
 
369
+               printf("/memreserve/ %llx %llx;\n",
 
370
+                      (unsigned long long)addr, (unsigned long long)size);
 
371
+       }
 
372
+
 
373
+       p = p_struct;
 
374
+       while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) {
 
375
+
 
376
+               /* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */
 
377
+
 
378
+               if (tag == FDT_BEGIN_NODE) {
 
379
+                       s = p;
 
380
+                       p = PALIGN(p + strlen(s) + 1, 4);
 
381
+
 
382
+                       if (*s == '\0')
 
383
+                               s = "/";
 
384
+
 
385
+                       printf("%*s%s {\n", depth * shift, "", s);
 
386
+
 
387
+                       depth++;
 
388
+                       continue;
 
389
+               }
 
390
+
 
391
+               if (tag == FDT_END_NODE) {
 
392
+                       depth--;
 
393
+
 
394
+                       printf("%*s};\n", depth * shift, "");
 
395
+                       continue;
 
396
+               }
 
397
+
 
398
+               if (tag == FDT_NOP) {
 
399
+                       printf("%*s// [NOP]\n", depth * shift, "");
 
400
+                       continue;
 
401
+               }
 
402
+
 
403
+               if (tag != FDT_PROP) {
 
404
+                       fprintf(stderr, "%*s ** Unknown tag 0x%08x\n", depth * shift, "", tag);
 
405
+                       break;
 
406
+               }
 
407
+               sz = fdt32_to_cpu(GET_CELL(p));
 
408
+               s = p_strings + fdt32_to_cpu(GET_CELL(p));
 
409
+               if (version < 16 && sz >= 8)
 
410
+                       p = PALIGN(p, 8);
 
411
+               t = p;
 
412
+
 
413
+               p = PALIGN(p + sz, 4);
 
414
+
 
415
+               printf("%*s%s", depth * shift, "", s);
 
416
+               print_data(t, sz);
 
417
+               printf(";\n");
 
418
+       }
 
419
+}
 
420
+
 
421
+
 
422
+int main(int argc, char *argv[])
 
423
+{
 
424
+       char *buf;
 
425
+
 
426
+       if (argc < 2) {
 
427
+               fprintf(stderr, "supply input filename\n");
 
428
+               return 5;
 
429
+       }
 
430
+
 
431
+       buf = utilfdt_read(argv[1]);
 
432
+       if (buf)
 
433
+               dump_blob(buf);
 
434
+       else
 
435
+               return 10;
 
436
+
 
437
+       return 0;
 
438
+}