svn commit: r204433 - in vendor/dtc/dist: . Documentation libfdt tests

Rafal Jaworowski raj at FreeBSD.org
Sat Feb 27 20:38:42 UTC 2010


Author: raj
Date: Sat Feb 27 20:38:41 2010
New Revision: 204433
URL: http://svn.freebsd.org/changeset/base/204433

Log:
  Update DTC to git d75b33af676d0beac8398651a7f09037555a550b.
  
  Obtained from:	git://git.jdl.com/software/dtc.git

Added:
  vendor/dtc/dist/Makefile.convert-dtsv0   (contents, props changed)
  vendor/dtc/dist/Makefile.ftdump   (contents, props changed)
  vendor/dtc/dist/libfdt/version.lds   (contents, props changed)
  vendor/dtc/dist/tests/aliases.dts
  vendor/dtc/dist/tests/asm_tree_dump.c   (contents, props changed)
  vendor/dtc/dist/tests/data.S   (contents, props changed)
  vendor/dtc/dist/tests/extra-terminating-null.c   (contents, props changed)
  vendor/dtc/dist/tests/extra-terminating-null.dts
  vendor/dtc/dist/tests/get_alias.c   (contents, props changed)
  vendor/dtc/dist/tests/path_offset_aliases.c   (contents, props changed)
  vendor/dtc/dist/tests/phandle_format.c   (contents, props changed)
  vendor/dtc/dist/tests/value-labels.c   (contents, props changed)
  vendor/dtc/dist/tests/value-labels.dts
  vendor/dtc/dist/util.c   (contents, props changed)
  vendor/dtc/dist/util.h   (contents, props changed)
Modified:
  vendor/dtc/dist/Documentation/manual.txt
  vendor/dtc/dist/Makefile
  vendor/dtc/dist/Makefile.dtc
  vendor/dtc/dist/checks.c
  vendor/dtc/dist/convert-dtsv0-lexer.l
  vendor/dtc/dist/data.c
  vendor/dtc/dist/dtc-lexer.l
  vendor/dtc/dist/dtc-parser.y
  vendor/dtc/dist/dtc.c
  vendor/dtc/dist/dtc.h
  vendor/dtc/dist/flattree.c
  vendor/dtc/dist/fstree.c
  vendor/dtc/dist/ftdump.c
  vendor/dtc/dist/libfdt/Makefile.libfdt
  vendor/dtc/dist/libfdt/fdt.c
  vendor/dtc/dist/libfdt/fdt_ro.c
  vendor/dtc/dist/libfdt/fdt_rw.c
  vendor/dtc/dist/libfdt/fdt_sw.c
  vendor/dtc/dist/libfdt/fdt_wip.c
  vendor/dtc/dist/libfdt/libfdt.h
  vendor/dtc/dist/libfdt/libfdt_internal.h
  vendor/dtc/dist/livetree.c
  vendor/dtc/dist/srcpos.c
  vendor/dtc/dist/srcpos.h
  vendor/dtc/dist/tests/Makefile.tests
  vendor/dtc/dist/tests/base01.dts
  vendor/dtc/dist/tests/dtbs_equal_ordered.c
  vendor/dtc/dist/tests/empty.dts
  vendor/dtc/dist/tests/escapes.dts
  vendor/dtc/dist/tests/get_name.c
  vendor/dtc/dist/tests/get_path.c
  vendor/dtc/dist/tests/get_phandle.c
  vendor/dtc/dist/tests/incbin.c
  vendor/dtc/dist/tests/include1.dts
  vendor/dtc/dist/tests/include7.dts
  vendor/dtc/dist/tests/label01.dts
  vendor/dtc/dist/tests/mangle-layout.c
  vendor/dtc/dist/tests/node_check_compatible.c
  vendor/dtc/dist/tests/node_offset_by_compatible.c
  vendor/dtc/dist/tests/node_offset_by_phandle.c
  vendor/dtc/dist/tests/node_offset_by_prop_value.c
  vendor/dtc/dist/tests/nopulate.c
  vendor/dtc/dist/tests/notfound.c
  vendor/dtc/dist/tests/parent_offset.c
  vendor/dtc/dist/tests/path-references.c
  vendor/dtc/dist/tests/path_offset.c
  vendor/dtc/dist/tests/references.c
  vendor/dtc/dist/tests/references.dts
  vendor/dtc/dist/tests/references_dts0.dts
  vendor/dtc/dist/tests/run_tests.sh
  vendor/dtc/dist/tests/rw_tree1.c
  vendor/dtc/dist/tests/set_name.c
  vendor/dtc/dist/tests/subnode_offset.c
  vendor/dtc/dist/tests/supernode_atdepth_offset.c
  vendor/dtc/dist/tests/sw_tree1.c
  vendor/dtc/dist/tests/test01.dts
  vendor/dtc/dist/tests/test_tree1.dts
  vendor/dtc/dist/tests/test_tree1_dts0.dts
  vendor/dtc/dist/tests/tests.h
  vendor/dtc/dist/tests/trees.S
  vendor/dtc/dist/treesource.c

Modified: vendor/dtc/dist/Documentation/manual.txt
==============================================================================
--- vendor/dtc/dist/Documentation/manual.txt	Sat Feb 27 20:22:44 2010	(r204432)
+++ vendor/dtc/dist/Documentation/manual.txt	Sat Feb 27 20:38:41 2010	(r204433)
@@ -19,6 +19,10 @@ II - The DT block format
 
 III - libfdt
 
+IV - Utility Tools
+    1) convert-dtsv0 -- Conversion to Version 1
+    1) ftdump
+
 
 I - "dtc", the device tree compiler
 ===================================
@@ -28,7 +32,7 @@ I - "dtc", the device tree compiler
 Source code for the Device Tree Compiler can be found at jdl.com.
 The gitweb interface is:
 
-    http://www.jdl.com/git_repos/
+    http://git.jdl.com/gitweb/
 
 The repository is here:
 
@@ -37,7 +41,7 @@ The repository is here:
 
 Tarballs of the 1.0.0 and latest releases are here:
 
-    http://www.jdl.com/software/dtc-1.0.0.tgz
+    http://www.jdl.com/software/dtc-v1.2.0.tgz
     http://www.jdl.com/software/dtc-latest.tgz
 
 
@@ -613,6 +617,36 @@ strings block.
 
 
 III - libfdt
+============
 
 This library should be merged into dtc proper.
 This library should likely be worked into U-Boot and the kernel.
+
+
+IV - Utility Tools
+==================
+
+1) convert-dtsv0 -- Conversion to Version 1
+
+convert-dtsv0 is a small utility program which converts (DTS)
+Device Tree Source from the obsolete version 0 to version 1.
+
+Version 1 DTS files are marked by line "/dts-v1/;" at the top of the file.
+
+The syntax of the convert-dtsv0 command line is:
+
+    convert-dtsv0 [<input_filename ... >]
+
+Each file passed will be converted to the new /dts-v1/ version by creating
+a new file with a "v1" appended the filename.
+
+Comments, empty lines, etc. are preserved.
+
+
+2) ftdump -- Flat Tree dumping utility
+
+The ftdump program prints a readable version of a flat device tree file.
+
+The syntax of the ftdump command line is:
+
+    ftdump <DTB-file-name>

Modified: vendor/dtc/dist/Makefile
==============================================================================
--- vendor/dtc/dist/Makefile	Sat Feb 27 20:22:44 2010	(r204432)
+++ vendor/dtc/dist/Makefile	Sat Feb 27 20:38:41 2010	(r204433)
@@ -16,7 +16,7 @@ LOCAL_VERSION =
 CONFIG_LOCALVERSION =
 
 CPPFLAGS = -I libfdt
-CFLAGS = -Wall -g -Os -Wpointer-arith -Wcast-qual
+CFLAGS = -Wall -g -Os -fPIC -Wpointer-arith -Wcast-qual
 
 BISON = bison
 LEX = flex
@@ -28,6 +28,17 @@ BINDIR = $(PREFIX)/bin
 LIBDIR = $(PREFIX)/lib
 INCLUDEDIR = $(PREFIX)/include
 
+HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
+	    sed -e 's/\(cygwin\).*/cygwin/')
+
+ifeq ($(HOSTOS),darwin)
+SHAREDLIB_EXT=dylib
+SHAREDLIB_LINK_OPTIONS=-dynamiclib -Wl,-install_name -Wl,
+else
+SHAREDLIB_EXT=so
+SHAREDLIB_LINK_OPTIONS=-shared -Wl,--version-script=$(LIBFDT_version) -Wl,-soname,
+endif
+
 #
 # Overall rules
 #
@@ -46,17 +57,6 @@ else
 DEPTARGETS = $(filter-out $(NODEPTARGETS),$(MAKECMDGOALS))
 endif
 
-all: dtc ftdump convert-dtsv0 libfdt
-
-install: all
-	@$(VECHO) INSTALL
-	$(INSTALL) -d $(DESTDIR)$(BINDIR)
-	$(INSTALL) -m 755 dtc $(DESTDIR)$(BINDIR)
-	$(INSTALL) -d $(DESTDIR)$(LIBDIR)
-	$(INSTALL) -m 644 $(LIBFDT_lib) $(DESTDIR)$(LIBDIR)
-	$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)
-	$(INSTALL) -m 644 $(LIBFDT_include) $(DESTDIR)$(INCLUDEDIR)
-
 #
 # Rules for versioning
 #
@@ -100,63 +100,82 @@ define filechk
 	fi;
 endef
 
-$(VERSION_FILE): Makefile FORCE
-	$(call filechk,version)
 
-#
-# Rules for dtc proper
-#
+include Makefile.convert-dtsv0
 include Makefile.dtc
+include Makefile.ftdump
 
+BIN += convert-dtsv0
 BIN += dtc
+BIN += ftdump
 
-# This stops make from generating the lex and bison output during
-# auto-dependency computation, but throwing them away as an
-# intermediate target and building them again "for real"
-.SECONDARY: $(DTC_GEN_SRCS)
 
-dtc: $(DTC_OBJS)
+all: $(BIN) libfdt
+
 
 ifneq ($(DEPTARGETS),)
 -include $(DTC_OBJS:%.o=%.d)
+-include $(CONVERT_OBJS:%.o=%.d)
+-include $(FTDUMP_OBJS:%.o=%.d)
 endif
-#
-# Rules for ftdump & convert-dtsv0
-#
-BIN += ftdump convert-dtsv0
 
-ftdump:	ftdump.o
 
-convert-dtsv0: convert-dtsv0-lexer.lex.o srcpos.o
-	@$(VECHO) LD $@
-	$(LINK.c) -o $@ $^
 
-ifneq ($(DEPTARGETS),)
--include ftdump.d
-endif
 #
 # Rules for libfdt
 #
 LIBFDT_objdir = libfdt
 LIBFDT_srcdir = libfdt
-LIBFDT_lib = $(LIBFDT_objdir)/libfdt.a
+LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a
+LIBFDT_lib = $(LIBFDT_objdir)/libfdt.$(SHAREDLIB_EXT)
 LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES))
+LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION))
 
 include $(LIBFDT_srcdir)/Makefile.libfdt
 
 .PHONY: libfdt
-libfdt: $(LIBFDT_lib)
+libfdt: $(LIBFDT_archive) $(LIBFDT_lib)
 
+$(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
 $(LIBFDT_lib): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
 
 libfdt_clean:
 	@$(VECHO) CLEAN "(libfdt)"
 	rm -f $(addprefix $(LIBFDT_objdir)/,$(STD_CLEANFILES))
+	rm -f $(LIBFDT_objdir)/*.so
 
 ifneq ($(DEPTARGETS),)
 -include $(LIBFDT_OBJS:%.o=$(LIBFDT_objdir)/%.d)
 endif
 
+# This stops make from generating the lex and bison output during
+# auto-dependency computation, but throwing them away as an
+# intermediate target and building them again "for real"
+.SECONDARY: $(DTC_GEN_SRCS) $(CONVERT_GEN_SRCS)
+
+install: all
+	@$(VECHO) INSTALL
+	$(INSTALL) -d $(DESTDIR)$(BINDIR)
+	$(INSTALL) $(BIN) $(DESTDIR)$(BINDIR)
+	$(INSTALL) -d $(DESTDIR)$(LIBDIR)
+	$(INSTALL) $(LIBFDT_lib) $(DESTDIR)$(LIBDIR)
+	$(INSTALL) -m 644 $(LIBFDT_archive) $(DESTDIR)$(LIBDIR)
+	$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)
+	$(INSTALL) -m 644 $(LIBFDT_include) $(DESTDIR)$(INCLUDEDIR)
+
+$(VERSION_FILE): Makefile FORCE
+	$(call filechk,version)
+
+
+dtc: $(DTC_OBJS)
+
+convert-dtsv0: $(CONVERT_OBJS)
+	@$(VECHO) LD $@
+	$(LINK.c) -o $@ $^
+
+ftdump:	$(FTDUMP_OBJS)
+
+
 #
 # Testsuite rules
 #
@@ -166,7 +185,7 @@ include tests/Makefile.tests
 #
 # Clean rules
 #
-STD_CLEANFILES = *~ *.o *.d *.a *.i *.s core a.out vgcore.* \
+STD_CLEANFILES = *~ *.o *.so *.d *.a *.i *.s core a.out vgcore.* \
 	*.tab.[ch] *.lex.c *.output
 
 clean: libfdt_clean tests_clean
@@ -210,6 +229,11 @@ clean: libfdt_clean tests_clean
 	@$(VECHO) AR $@
 	$(AR) $(ARFLAGS) $@ $^
 
+$(LIBFDT_lib):
+	@$(VECHO) LD $@
+	$(CC) $(LDFLAGS) -fPIC $(SHAREDLIB_LINK_OPTIONS)$(notdir $@) -o $(LIBFDT_objdir)/libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT) $^
+	ln -sf libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT) $(LIBFDT_objdir)/libfdt.$(SHAREDLIB_EXT)
+
 %.lex.c: %.l
 	@$(VECHO) LEX $@
 	$(LEX) -o$@ $<

Added: vendor/dtc/dist/Makefile.convert-dtsv0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/dtc/dist/Makefile.convert-dtsv0	Sat Feb 27 20:38:41 2010	(r204433)
@@ -0,0 +1,13 @@
+#
+# This is not a complete Makefile of itself.
+# Instead, it is designed to be easily embeddable
+# into other systems of Makefiles.
+#
+
+CONVERT_SRCS = \
+	srcpos.c \
+	util.c
+
+CONVERT_GEN_SRCS = convert-dtsv0-lexer.lex.c
+
+CONVERT_OBJS = $(CONVERT_SRCS:%.c=%.o) $(CONVERT_GEN_SRCS:%.c=%.o)

Modified: vendor/dtc/dist/Makefile.dtc
==============================================================================
--- vendor/dtc/dist/Makefile.dtc	Sat Feb 27 20:22:44 2010	(r204432)
+++ vendor/dtc/dist/Makefile.dtc	Sat Feb 27 20:38:41 2010	(r204433)
@@ -3,7 +3,16 @@
 # This is not a complete Makefile of itself.  Instead, it is designed to
 # be easily embeddable into other systems of Makefiles.
 #
-DTC_SRCS = dtc.c flattree.c fstree.c data.c livetree.c treesource.c srcpos.c \
-	checks.c
+DTC_SRCS = \
+	checks.c \
+	data.c \
+	dtc.c \
+	flattree.c \
+	fstree.c \
+	livetree.c \
+	srcpos.c \
+	treesource.c \
+	util.c
+
 DTC_GEN_SRCS = dtc-lexer.lex.c dtc-parser.tab.c
 DTC_OBJS = $(DTC_SRCS:%.c=%.o) $(DTC_GEN_SRCS:%.c=%.o)

Added: vendor/dtc/dist/Makefile.ftdump
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/dtc/dist/Makefile.ftdump	Sat Feb 27 20:38:41 2010	(r204433)
@@ -0,0 +1,12 @@
+#
+# This is not a complete Makefile of itself.
+# Instead, it is designed to be easily embeddable
+# into other systems of Makefiles.
+#
+
+FTDUMP_SRCS = \
+	ftdump.c
+
+FTDUMP_GEN_SRCS =
+
+FTDUMP_OBJS = $(FTDUMP_SRCS:%.c=%.o) $(FTDUMP_GEN_SRCS:%.c=%.o)

Modified: vendor/dtc/dist/checks.c
==============================================================================
--- vendor/dtc/dist/checks.c	Sat Feb 27 20:22:44 2010	(r204432)
+++ vendor/dtc/dist/checks.c	Sat Feb 27 20:38:41 2010	(r204433)
@@ -279,31 +279,55 @@ static void check_property_name_chars(st
 PROP_CHECK(property_name_chars, PROPNODECHARS, ERROR);
 
 static void check_explicit_phandles(struct check *c, struct node *root,
-					  struct node *node)
+				    struct node *node, struct property *prop)
 {
-	struct property *prop;
+	struct marker *m;
 	struct node *other;
 	cell_t phandle;
 
-	prop = get_property(node, "linux,phandle");
-	if (! prop)
-		return; /* No phandle, that's fine */
+	if (!streq(prop->name, "phandle")
+	    && !streq(prop->name, "linux,phandle"))
+		return;
 
 	if (prop->val.len != sizeof(cell_t)) {
-		FAIL(c, "%s has bad length (%d) linux,phandle property",
-		     node->fullpath, prop->val.len);
+		FAIL(c, "%s has bad length (%d) %s property",
+		     node->fullpath, prop->val.len, prop->name);
+		return;
+	}
+
+	m = prop->val.markers;
+	for_each_marker_of_type(m, REF_PHANDLE) {
+		assert(m->offset == 0);
+		if (node != get_node_by_ref(root, m->ref))
+			/* "Set this node's phandle equal to some
+			 * other node's phandle".  That's nonsensical
+			 * by construction. */ {
+			FAIL(c, "%s in %s is a reference to another node",
+			     prop->name, node->fullpath);
+			return;
+		}
+		/* But setting this node's phandle equal to its own
+		 * phandle is allowed - that means allocate a unique
+		 * phandle for this node, even if it's not otherwise
+		 * referenced.  The value will be filled in later, so
+		 * no further checking for now. */
 		return;
 	}
 
 	phandle = propval_cell(prop);
+
 	if ((phandle == 0) || (phandle == -1)) {
-		FAIL(c, "%s has invalid linux,phandle value 0x%x",
-		     node->fullpath, phandle);
+		FAIL(c, "%s has bad value (0x%x) in %s property",
+		     node->fullpath, phandle, prop->name);
 		return;
 	}
 
+	if (node->phandle && (node->phandle != phandle))
+		FAIL(c, "%s has %s property which replaces existing phandle information",
+		     node->fullpath, prop->name);
+
 	other = get_node_by_phandle(root, phandle);
-	if (other) {
+	if (other && (other != node)) {
 		FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)",
 		     node->fullpath, phandle, other->fullpath);
 		return;
@@ -311,7 +335,7 @@ static void check_explicit_phandles(stru
 
 	node->phandle = phandle;
 }
-NODE_CHECK(explicit_phandles, NULL, ERROR);
+PROP_CHECK(explicit_phandles, NULL, ERROR);
 
 static void check_name_properties(struct check *c, struct node *root,
 				  struct node *node)

Modified: vendor/dtc/dist/convert-dtsv0-lexer.l
==============================================================================
--- vendor/dtc/dist/convert-dtsv0-lexer.l	Sat Feb 27 20:22:44 2010	(r204432)
+++ vendor/dtc/dist/convert-dtsv0-lexer.l	Sat Feb 27 20:38:41 2010	(r204433)
@@ -17,7 +17,7 @@
  *                                                                   USA
  */
 
-%option noyywrap nounput
+%option noyywrap nounput noinput
 
 %x INCLUDE
 %x BYTESTRING
@@ -42,6 +42,7 @@ GAP		({WS}|{COMMENT}|{LINECOMMENT})*
 #include <fnmatch.h>
 
 #include "srcpos.h"
+#include "util.h"
 
 static int v1_tagged; /* = 0 */
 static int cbase = 16;
@@ -51,26 +52,6 @@ static char *last_name; /* = NULL */
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
-static inline void __attribute__((noreturn)) die(char * str, ...)
-{
-	va_list ap;
-
-	va_start(ap, str);
-	fprintf(stderr, "FATAL ERROR: ");
-	vfprintf(stderr, str, ap);
-	exit(1);
-}
-
-static inline void *xmalloc(size_t len)
-{
-	void *new = malloc(len);
-
-	if (! new)
-		die("malloc() failed\n");
-
-	return new;
-}
-
 const struct {
 	const char *pattern;
 	int obase, width;
@@ -185,7 +166,7 @@ const struct {
 
 <PROPNODENAME>{PROPNODECHAR}+ {
 			ECHO;
-			last_name = strdup(yytext);
+			last_name = xstrdup(yytext);
 			BEGIN(INITIAL);
 		}
 

Modified: vendor/dtc/dist/data.c
==============================================================================
--- vendor/dtc/dist/data.c	Sat Feb 27 20:22:44 2010	(r204432)
+++ vendor/dtc/dist/data.c	Sat Feb 27 20:38:41 2010	(r204433)
@@ -217,7 +217,7 @@ struct data data_insert_at_marker(struct
 	return d;
 }
 
-struct data data_append_markers(struct data d, struct marker *m)
+static struct data data_append_markers(struct data d, struct marker *m)
 {
 	struct marker **mp = &d.markers;
 

Modified: vendor/dtc/dist/dtc-lexer.l
==============================================================================
--- vendor/dtc/dist/dtc-lexer.l	Sat Feb 27 20:22:44 2010	(r204432)
+++ vendor/dtc/dist/dtc-lexer.l	Sat Feb 27 20:38:41 2010	(r204433)
@@ -18,7 +18,7 @@
  *                                                                   USA
  */
 
-%option noyywrap nounput yylineno
+%option noyywrap nounput noinput yylineno
 
 %x INCLUDE
 %x BYTESTRING
@@ -38,6 +38,11 @@ LINECOMMENT	"//".*\n
 #include "srcpos.h"
 #include "dtc-parser.tab.h"
 
+#define	YY_USER_ACTION \
+	{ \
+		yylloc.file = srcpos_file; \
+		yylloc.first_line = yylineno; \
+	}
 
 /*#define LEXDEBUG	1*/
 
@@ -47,15 +52,10 @@ LINECOMMENT	"//".*\n
 #define DPRINT(fmt, ...)	do { } while (0)
 #endif
 
-static int dts_version; /* = 0 */
+static int dts_version = 1;
 
-#define BEGIN_DEFAULT()	if (dts_version == 0) { \
-				DPRINT("<INITIAL>\n"); \
-				BEGIN(INITIAL); \
-			} else { \
-				DPRINT("<V1>\n"); \
+#define BEGIN_DEFAULT()		DPRINT("<V1>\n"); \
 				BEGIN(V1); \
-			}
 
 static void push_input_file(const char *filename);
 static int pop_input_file(void);
@@ -75,18 +75,13 @@ static int pop_input_file(void);
 		}
 
 <*>{STRING}	{
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
 			DPRINT("String: %s\n", yytext);
 			yylval.data = data_copy_escape_string(yytext+1,
 					yyleng-2);
-			yylloc.first_line = yylineno;
 			return DT_STRING;
 		}
 
 <*>"/dts-v1/"	{
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
 			DPRINT("Keyword: /dts-v1/\n");
 			dts_version = 1;
 			BEGIN_DEFAULT();
@@ -94,106 +89,57 @@ static int pop_input_file(void);
 		}
 
 <*>"/memreserve/"	{
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
 			DPRINT("Keyword: /memreserve/\n");
 			BEGIN_DEFAULT();
 			return DT_MEMRESERVE;
 		}
 
 <*>{LABEL}:	{
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
 			DPRINT("Label: %s\n", yytext);
-			yylval.labelref = strdup(yytext);
+			yylval.labelref = xstrdup(yytext);
 			yylval.labelref[yyleng-1] = '\0';
 			return DT_LABEL;
 		}
 
-<INITIAL>[bodh]# {
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
-			if (*yytext == 'b')
-				yylval.cbase = 2;
-			else if (*yytext == 'o')
-				yylval.cbase = 8;
-			else if (*yytext == 'd')
-				yylval.cbase = 10;
-			else
-				yylval.cbase = 16;
-			DPRINT("Base: %d\n", yylval.cbase);
-			return DT_BASE;
-		}
-
-<INITIAL>[0-9a-fA-F]+	{
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
-			yylval.literal = strdup(yytext);
-			DPRINT("Literal: '%s'\n", yylval.literal);
-			return DT_LEGACYLITERAL;
-		}
-
 <V1>[0-9]+|0[xX][0-9a-fA-F]+      {
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
-			yylval.literal = strdup(yytext);
+			yylval.literal = xstrdup(yytext);
 			DPRINT("Literal: '%s'\n", yylval.literal);
 			return DT_LITERAL;
 		}
 
 \&{LABEL}	{	/* label reference */
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
 			DPRINT("Ref: %s\n", yytext+1);
-			yylval.labelref = strdup(yytext+1);
+			yylval.labelref = xstrdup(yytext+1);
 			return DT_REF;
 		}
 
 "&{/"{PATHCHAR}+\}	{	/* new-style path reference */
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
 			yytext[yyleng-1] = '\0';
 			DPRINT("Ref: %s\n", yytext+2);
-			yylval.labelref = strdup(yytext+2);
-			return DT_REF;
-		}
-
-<INITIAL>"&/"{PATHCHAR}+ {	/* old-style path reference */
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
-			DPRINT("Ref: %s\n", yytext+1);
-			yylval.labelref = strdup(yytext+1);
+			yylval.labelref = xstrdup(yytext+2);
 			return DT_REF;
 		}
 
 <BYTESTRING>[0-9a-fA-F]{2} {
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
 			yylval.byte = strtol(yytext, NULL, 16);
 			DPRINT("Byte: %02x\n", (int)yylval.byte);
 			return DT_BYTE;
 		}
 
 <BYTESTRING>"]"	{
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
 			DPRINT("/BYTESTRING\n");
 			BEGIN_DEFAULT();
 			return ']';
 		}
 
 <PROPNODENAME>{PROPNODECHAR}+ {
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
 			DPRINT("PropNodeName: %s\n", yytext);
-			yylval.propnodename = strdup(yytext);
+			yylval.propnodename = xstrdup(yytext);
 			BEGIN_DEFAULT();
 			return DT_PROPNODENAME;
 		}
 
 "/incbin/"	{
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
 			DPRINT("Binary Include\n");
 			return DT_INCBIN;
 		}
@@ -203,8 +149,6 @@ static int pop_input_file(void);
 <*>{LINECOMMENT}+ /* eat C++-style comments */
 
 <*>.		{
-			yylloc.file = srcpos_file;
-			yylloc.first_line = yylineno;
 			DPRINT("Char: %c (\\x%02x)\n", yytext[0],
 				(unsigned)yytext[0]);
 			if (yytext[0] == '[') {

Modified: vendor/dtc/dist/dtc-parser.y
==============================================================================
--- vendor/dtc/dist/dtc-parser.y	Sat Feb 27 20:22:44 2010	(r204432)
+++ vendor/dtc/dist/dtc-parser.y	Sat Feb 27 20:38:41 2010	(r204433)
@@ -27,6 +27,7 @@
 #include "srcpos.h"
 
 extern int yylex(void);
+extern void yyerror(char const *s);
 
 extern struct boot_info *the_boot_info;
 extern int treesource_error;
@@ -55,7 +56,6 @@ static unsigned long long eval_literal(c
 %token DT_MEMRESERVE
 %token <propnodename> DT_PROPNODENAME
 %token <literal> DT_LITERAL
-%token <literal> DT_LEGACYLITERAL
 %token <cbase> DT_BASE
 %token <byte> DT_BYTE
 %token <data> DT_STRING
@@ -67,11 +67,8 @@ static unsigned long long eval_literal(c
 %type <data> propdataprefix
 %type <re> memreserve
 %type <re> memreserves
-%type <re> v0_memreserve
-%type <re> v0_memreserves
 %type <addr> addr
 %type <data> celllist
-%type <cbase> cellbase
 %type <cell> cellval
 %type <data> bytestring
 %type <prop> propdef
@@ -90,10 +87,6 @@ sourcefile:
 		{
 			the_boot_info = build_boot_info($3, $4, 0);
 		}
-	| v0_memreserves devicetree
-		{
-			the_boot_info = build_boot_info($1, $2, 0);
-		}
 	;
 
 memreserves:
@@ -114,37 +107,11 @@ memreserve:
 		}
 	;
 
-v0_memreserves:
-	  /* empty */
-		{
-			$$ = NULL;
-		}
-	| v0_memreserve v0_memreserves
-		{
-			$$ = chain_reserve_entry($1, $2);
-		};
-	;
-
-v0_memreserve:
-	  memreserve
-		{
-			$$ = $1;
-		}
-	| label DT_MEMRESERVE addr '-' addr ';'
-		{
-			$$ = build_reserve_entry($3, $5 - $3 + 1, $1);
-		}
-	;
-
 addr:
 	  DT_LITERAL
 		{
 			$$ = eval_literal($1, 0, 64);
 		}
-	| DT_LEGACYLITERAL
-		{
-			$$ = eval_literal($1, 16, 64);
-		}
 	  ;
 
 devicetree:
@@ -208,9 +175,11 @@ propdata:
 
 			if ($6 != 0)
 				if (fseek(file->file, $6, SEEK_SET) != 0)
-					yyerrorf("Couldn't seek to offset %llu in \"%s\": %s",
-						 (unsigned long long)$6,
-						 $4.val, strerror(errno));
+					srcpos_error(&yylloc,
+						     "Couldn't seek to offset %llu in \"%s\": %s",
+						     (unsigned long long)$6,
+						     $4.val,
+						     strerror(errno));
 
 			d = data_copy_file(file->file, $8);
 
@@ -269,23 +238,11 @@ celllist:
 		}
 	;
 
-cellbase:
-	  /* empty */
-		{
-			$$ = 16;
-		}
-	| DT_BASE
-	;
-
 cellval:
 	  DT_LITERAL
 		{
 			$$ = eval_literal($1, 0, 32);
 		}
-	| cellbase DT_LEGACYLITERAL
-		{
-			$$ = eval_literal($2, $1, 32);
-		}
 	;
 
 bytestring:
@@ -339,26 +296,10 @@ label:
 
 %%
 
-void yyerrorf(char const *s, ...)
+void yyerror(char const *s)
 {
-	const char *fname = srcpos_file ? srcpos_file->name : "<no-file>";
-	va_list va;
-	va_start(va, s);
-
-	if (strcmp(fname, "-") == 0)
-		fname = "stdin";
-
-	fprintf(stderr, "%s:%d ", fname, yylloc.first_line);
-	vfprintf(stderr, s, va);
-	fprintf(stderr, "\n");
-
+	srcpos_error(&yylloc, "%s", s);
 	treesource_error = 1;
-	va_end(va);
-}
-
-void yyerror (char const *s)
-{
-	yyerrorf("%s", s);
 }
 
 static unsigned long long eval_literal(const char *s, int base, int bits)

Modified: vendor/dtc/dist/dtc.c
==============================================================================
--- vendor/dtc/dist/dtc.c	Sat Feb 27 20:22:44 2010	(r204432)
+++ vendor/dtc/dist/dtc.c	Sat Feb 27 20:38:41 2010	(r204433)
@@ -30,6 +30,7 @@ int quiet;		/* Level of quietness */
 int reservenum;		/* Number of memory reservation slots */
 int minsize;		/* Minimum blob size */
 int padsize;		/* Additional padding to blob */
+int phandle_format = PHANDLE_BOTH;	/* Use linux,phandle or phandle properties */
 
 char *join_path(const char *path, const char *name)
 {
@@ -106,6 +107,11 @@ static void  __attribute__ ((noreturn)) 
 	fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n");
 	fprintf(stderr, "\t-v\n");
 	fprintf(stderr, "\t\tPrint DTC version and exit\n");
+	fprintf(stderr, "\t-H <phandle format>\n");
+	fprintf(stderr, "\t\tphandle formats are:\n");
+	fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n");
+	fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n");
+	fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n");
 	exit(3);
 }
 
@@ -127,7 +133,7 @@ int main(int argc, char *argv[])
 	minsize    = 0;
 	padsize    = 0;
 
-	while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:v")) != EOF) {
+	while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:")) != EOF) {
 		switch (opt) {
 		case 'I':
 			inform = optarg;
@@ -165,6 +171,18 @@ int main(int argc, char *argv[])
 		case 'v':
 			printf("Version: %s\n", DTC_VERSION);
 			exit(0);
+		case 'H':
+			if (streq(optarg, "legacy"))
+				phandle_format = PHANDLE_LEGACY;
+			else if (streq(optarg, "epapr"))
+				phandle_format = PHANDLE_EPAPR;
+			else if (streq(optarg, "both"))
+				phandle_format = PHANDLE_BOTH;
+			else
+				die("Invalid argument \"%s\" to -H option\n",
+				    optarg);
+			break;
+
 		case 'h':
 		default:
 			usage();
@@ -182,6 +200,9 @@ int main(int argc, char *argv[])
 	if (minsize && padsize)
 		die("Can't set both -p and -S\n");
 
+	if (minsize)
+		fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n");
+
 	fprintf(stderr, "DTC: %s->%s  on file \"%s\"\n",
 		inform, outform, arg);
 

Modified: vendor/dtc/dist/dtc.h
==============================================================================
--- vendor/dtc/dist/dtc.h	Sat Feb 27 20:22:44 2010	(r204432)
+++ vendor/dtc/dist/dtc.h	Sat Feb 27 20:38:41 2010	(r204433)
@@ -34,7 +34,17 @@
 #include <libfdt_env.h>
 #include <fdt.h>
 
+#include "util.h"
+
+#ifdef DEBUG
+#define debug(fmt,args...)	printf(fmt, ##args)
+#else
+#define debug(fmt,args...)
+#endif
+
+
 #define DEFAULT_FDT_VERSION	17
+
 /*
  * Command line options
  */
@@ -42,36 +52,11 @@ extern int quiet;		/* Level of quietness
 extern int reservenum;		/* Number of memory reservation slots */
 extern int minsize;		/* Minimum blob size */
 extern int padsize;		/* Additional padding to blob */
+extern int phandle_format;	/* Use linux,phandle or phandle properties */
 
-static inline void __attribute__((noreturn)) die(char * str, ...)
-{
-	va_list ap;
-
-	va_start(ap, str);
-	fprintf(stderr, "FATAL ERROR: ");
-	vfprintf(stderr, str, ap);
-	exit(1);
-}
-
-static inline void *xmalloc(size_t len)
-{
-	void *new = malloc(len);
-
-	if (! new)
-		die("malloc() failed\n");
-
-	return new;
-}
-
-static inline void *xrealloc(void *p, size_t len)
-{
-	void *new = realloc(p, len);
-
-	if (! new)
-		die("realloc() failed (len=%d)\n", len);
-
-	return new;
-}
+#define PHANDLE_LEGACY	0x1
+#define PHANDLE_EPAPR	0x2
+#define PHANDLE_BOTH	0x3
 
 typedef uint32_t cell_t;
 

Modified: vendor/dtc/dist/flattree.c
==============================================================================
--- vendor/dtc/dist/flattree.c	Sat Feb 27 20:22:44 2010	(r204432)
+++ vendor/dtc/dist/flattree.c	Sat Feb 27 20:38:41 2010	(r204433)
@@ -127,11 +127,21 @@ static void emit_offset_label(FILE *f, c
 	fprintf(f, "%s\t= . + %d\n", label, offset);
 }
 
+#define ASM_EMIT_BELONG(f, fmt, ...) \
+	{ \
+		fprintf((f), "\t.byte\t((" fmt ") >> 24) & 0xff\n", __VA_ARGS__); \
+		fprintf((f), "\t.byte\t((" fmt ") >> 16) & 0xff\n", __VA_ARGS__); \
+		fprintf((f), "\t.byte\t((" fmt ") >> 8) & 0xff\n", __VA_ARGS__); \
+		fprintf((f), "\t.byte\t(" fmt ") & 0xff\n", __VA_ARGS__); \
+	}
+
 static void asm_emit_cell(void *e, cell_t val)
 {
 	FILE *f = e;
 
-	fprintf(f, "\t.long\t0x%x\n", val);
+	fprintf(f, "\t.byte 0x%02x; .byte 0x%02x; .byte 0x%02x; .byte 0x%02x\n",
+		(val >> 24) & 0xff, (val >> 16) & 0xff,
+		(val >> 8) & 0xff, val & 0xff);
 }
 
 static void asm_emit_string(void *e, char *str, int len)
@@ -156,7 +166,7 @@ static void asm_emit_align(void *e, int 
 {
 	FILE *f = e;
 
-	fprintf(f, "\t.balign\t%d\n", a);
+	fprintf(f, "\t.balign\t%d, 0\n", a);
 }
 
 static void asm_emit_data(void *e, struct data d)
@@ -169,8 +179,7 @@ static void asm_emit_data(void *e, struc
 		emit_offset_label(f, m->ref, m->offset);
 
 	while ((d.len - off) >= sizeof(uint32_t)) {
-		fprintf(f, "\t.long\t0x%x\n",
-			fdt32_to_cpu(*((uint32_t *)(d.val+off))));
+		asm_emit_cell(e, fdt32_to_cpu(*((uint32_t *)(d.val+off))));
 		off += sizeof(uint32_t);
 	}
 
@@ -190,14 +199,16 @@ static void asm_emit_beginnode(void *e, 
 		fprintf(f, "\t.globl\t%s\n", label);
 		fprintf(f, "%s:\n", label);
 	}
-	fprintf(f, "\t.long\tFDT_BEGIN_NODE\n");
+	fprintf(f, "\t/* FDT_BEGIN_NODE */\n");
+	asm_emit_cell(e, FDT_BEGIN_NODE);
 }
 
 static void asm_emit_endnode(void *e, const char *label)
 {
 	FILE *f = e;
 
-	fprintf(f, "\t.long\tFDT_END_NODE\n");
+	fprintf(f, "\t/* FDT_END_NODE */\n");
+	asm_emit_cell(e, FDT_END_NODE);
 	if (label) {
 		fprintf(f, "\t.globl\t%s_end\n", label);
 		fprintf(f, "%s_end:\n", label);
@@ -212,7 +223,8 @@ static void asm_emit_property(void *e, c
 		fprintf(f, "\t.globl\t%s\n", label);
 		fprintf(f, "%s:\n", label);
 	}
-	fprintf(f, "\t.long\tFDT_PROP\n");
+	fprintf(f, "\t/* FDT_PROP */\n");
+	asm_emit_cell(e, FDT_PROP);
 }
 
 static struct emitter asm_emitter = {
@@ -413,10 +425,13 @@ void dt_to_blob(FILE *f, struct boot_inf
 	if (padlen > 0)
 		blob = data_append_zeroes(blob, padlen);
 
-	fwrite(blob.val, blob.len, 1, f);
-
-	if (ferror(f))
-		die("Error writing device tree blob: %s\n", strerror(errno));
+	if (fwrite(blob.val, blob.len, 1, f) != 1) {
+		if (ferror(f))
+			die("Error writing device tree blob: %s\n",
+			    strerror(errno));
+		else
+			die("Short write on device tree blob\n");
+	}
 
 	/*
 	 * data_merge() frees the right-hand element so only the blob
@@ -455,39 +470,44 @@ void dt_to_asm(FILE *f, struct boot_info
 		die("Unknown device tree blob version %d\n", version);
 
 	fprintf(f, "/* autogenerated by dtc, do not edit */\n\n");
-	fprintf(f, "#define FDT_MAGIC 0x%x\n", FDT_MAGIC);
-	fprintf(f, "#define FDT_BEGIN_NODE 0x%x\n", FDT_BEGIN_NODE);
-	fprintf(f, "#define FDT_END_NODE 0x%x\n", FDT_END_NODE);
-	fprintf(f, "#define FDT_PROP 0x%x\n", FDT_PROP);
-	fprintf(f, "#define FDT_END 0x%x\n", FDT_END);
-	fprintf(f, "\n");
 
 	emit_label(f, symprefix, "blob_start");
 	emit_label(f, symprefix, "header");
-	fprintf(f, "\t.long\tFDT_MAGIC\t\t\t\t/* magic */\n");
-	fprintf(f, "\t.long\t_%s_blob_abs_end - _%s_blob_start\t/* totalsize */\n",
-		symprefix, symprefix);
-	fprintf(f, "\t.long\t_%s_struct_start - _%s_blob_start\t/* off_dt_struct */\n",
+	fprintf(f, "\t/* magic */\n");
+	asm_emit_cell(f, FDT_MAGIC);
+	fprintf(f, "\t/* totalsize */\n");
+	ASM_EMIT_BELONG(f, "_%s_blob_abs_end - _%s_blob_start",
+			symprefix, symprefix);
+	fprintf(f, "\t/* off_dt_struct */\n");

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-vendor mailing list