Update dtc to the version of 20170713 of upstream
For pylibfdt, merge dtc to upstream 0016f8c2aa32423f680ec6e94a00f1095b81b5fc
and merge history
Bug: 64424046
Test: Build dtc, use output dtc to build dts, can output correct dtb.
Change-Id: I4304259e1245bc4a45d0b8f8e3ae8119e509042c
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..618466f
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,3 @@
+subdirs = [
+ "libfdt"
+]
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..4aafda0
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,33 @@
+# Copyright 2016 The Android Open Source Project
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS := \
+ -Wall \
+ -Werror \
+ -Wno-sign-compare \
+ -Wno-missing-field-initializers \
+ -Wno-unused-parameter
+LOCAL_SRC_FILES := \
+ checks.c \
+ data.c \
+ dtc.c \
+ dtc-lexer.l \
+ dtc-parser.y \
+ flattree.c \
+ fstree.c \
+ livetree.c \
+ srcpos.c \
+ treesource.c \
+ util.c
+
+LOCAL_STATIC_LIBRARIES := \
+ libfdt
+LOCAL_CXX_STL := none
+
+LOCAL_MODULE := dtc
+
+include $(BUILD_HOST_EXECUTABLE)
+
+$(call dist-for-goals, dist_files, $(ALL_MODULES.dtc.BUILT):dtc/dtc)
diff --git a/Documentation/dt-object-internal.txt b/Documentation/dt-object-internal.txt
index 51d68ab..624aa43 100644
--- a/Documentation/dt-object-internal.txt
+++ b/Documentation/dt-object-internal.txt
@@ -308,3 +308,20 @@
DT object loaded. The __local_fixups__ node records the offset relative to the
start of every local reference within that property so that the loader can apply
the offset.
+
+There is an alternative syntax to the expanded form for overlays with phandle
+targets which makes the format similar to the one using in .dtsi include files.
+
+So for the &ocp target example above one can simply write:
+
+/dts-v1/;
+/plugin/;
+&ocp {
+ /* bar peripheral */
+ bar {
+ compatible = "corp,bar";
+ ... /* various properties and child nodes */
+ }
+};
+
+The resulting dtb object is identical.
diff --git a/README.version b/README.version
new file mode 100644
index 0000000..50213c0
--- /dev/null
+++ b/README.version
@@ -0,0 +1,3 @@
+URL: https://git.kernel.org/cgit/utils/dtc/dtc.git/commit/?id=120775eb1cf39f8dcecd695c3ff1cfef8aeb669d
+Version: 1.4.2 plus bugfixes
+Owners: cphoenix
diff --git a/dtc-lexer.l b/dtc-lexer.l
index fd825eb..13f4b06 100644
--- a/dtc-lexer.l
+++ b/dtc-lexer.l
@@ -36,7 +36,7 @@
%{
#include "dtc.h"
#include "srcpos.h"
-#include "dtc-parser.tab.h"
+#include "dtc-parser.h"
YYLTYPE yylloc;
extern bool treesource_error;
diff --git a/dtc-parser.y b/dtc-parser.y
index ca3f500..affc81a 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -182,10 +182,19 @@
{
struct node *target = get_node_by_ref($1, $2);
- if (target)
+ if (target) {
merge_nodes(target, $3);
- else
- ERROR(&@2, "Label or path %s not found", $2);
+ } else {
+ /*
+ * We rely on the rule being always:
+ * versioninfo plugindecl memreserves devicetree
+ * so $-1 is what we want (plugindecl)
+ */
+ if ($<flags>-1 & DTSF_PLUGIN)
+ add_orphan_node($1, $3, $2);
+ else
+ ERROR(&@2, "Label or path %s not found", $2);
+ }
$$ = $1;
}
| devicetree DT_DEL_NODE DT_REF ';'
@@ -200,6 +209,11 @@
$$ = $1;
}
+ | /* empty */
+ {
+ /* build empty node */
+ $$ = name_node(build_node(NULL, NULL), "");
+ }
;
nodedef:
diff --git a/dtc.h b/dtc.h
index 409db76..07e3ddb 100644
--- a/dtc.h
+++ b/dtc.h
@@ -203,6 +203,7 @@
struct node *name_node(struct node *node, char *name);
struct node *chain_node(struct node *first, struct node *list);
struct node *merge_nodes(struct node *old_node, struct node *new_node);
+void add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
void add_property(struct node *node, struct property *prop);
void delete_property_by_name(struct node *node, char *name);
diff --git a/libfdt/Android.bp b/libfdt/Android.bp
new file mode 100644
index 0000000..e92497b
--- /dev/null
+++ b/libfdt/Android.bp
@@ -0,0 +1,22 @@
+cc_library_static {
+ name: "libfdt",
+ host_supported: true,
+
+ cflags: [
+ "-Werror",
+ "-Wno-macro-redefined",
+ "-Wno-sign-compare",
+ ],
+ srcs: [
+ "fdt.c",
+ "fdt_ro.c",
+ "fdt_wip.c",
+ "fdt_sw.c",
+ "fdt_rw.c",
+ "fdt_strerror.c",
+ "fdt_empty_tree.c",
+ "fdt_addresses.c",
+ "fdt_overlay.c",
+ ],
+ export_include_dirs: ["."],
+}
diff --git a/livetree.c b/livetree.c
index aecd278..a5d5676 100644
--- a/livetree.c
+++ b/livetree.c
@@ -216,6 +216,28 @@
return old_node;
}
+void add_orphan_node(struct node *dt, struct node *new_node, char *ref)
+{
+ static unsigned int next_orphan_fragment = 0;
+ struct node *node;
+ struct property *p;
+ struct data d = empty_data;
+ char *name;
+
+ d = data_add_marker(d, REF_PHANDLE, ref);
+ d = data_append_integer(d, 0xffffffff, 32);
+
+ p = build_property("target", d);
+
+ xasprintf(&name, "fragment@%u",
+ next_orphan_fragment++);
+ name_node(new_node, "__overlay__");
+ node = build_node(p, new_node);
+ name_node(node, name);
+
+ add_child(dt, node);
+}
+
struct node *chain_node(struct node *first, struct node *list)
{
assert(first->next_sibling == NULL);
diff --git a/util.c b/util.c
index 9953c32..6ae5976 100644
--- a/util.c
+++ b/util.c
@@ -34,7 +34,7 @@
#include "libfdt.h"
#include "util.h"
-#include "version_gen.h"
+#include "version_non_gen.h"
char *xstrdup(const char *s)
{
diff --git a/version_non_gen.h b/version_non_gen.h
new file mode 100644
index 0000000..71d542d
--- /dev/null
+++ b/version_non_gen.h
@@ -0,0 +1 @@
+#define DTC_VERSION "DTC 1.4.4-Android-build"