Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/external/bsd/libfdt/dist Pull up following revision(s...
details: https://anonhg.NetBSD.org/src/rev/8bd1d1cc1104
branches: netbsd-8
changeset: 434108:8bd1d1cc1104
user: snj <snj%NetBSD.org@localhost>
date: Tue Jul 18 17:08:08 2017 +0000
description:
Pull up following revision(s) (requested by jmcneill in ticket #114):
sys/external/bsd/libfdt/dist/Makefile.libfdt: up to 1.1.1.2
sys/external/bsd/libfdt/dist/fdt.c: up to 1.1.1.2
sys/external/bsd/libfdt/dist/fdt.h: up to 1.1.1.2
sys/external/bsd/libfdt/dist/fdt_addresses.c: up to 1.1.1.2
sys/external/bsd/libfdt/dist/fdt_empty_tree.c: up to 1.1.1.2
sys/external/bsd/libfdt/dist/fdt_overlay.c: up to 1.1.1.1
sys/external/bsd/libfdt/dist/fdt_ro.c: up to 1.1.1.2
sys/external/bsd/libfdt/dist/fdt_rw.c: up to 1.1.1.2
sys/external/bsd/libfdt/dist/fdt_strerror.c: up to 1.1.1.2
sys/external/bsd/libfdt/dist/fdt_sw.c: up to 1.1.1.2
sys/external/bsd/libfdt/dist/fdt_wip.c: up to 1.1.1.2
sys/external/bsd/libfdt/dist/libfdt.h: up to 1.1.1.2
sys/external/bsd/libfdt/dist/libfdt_env.h: up to 1.3
sys/external/bsd/libfdt/dist/libfdt_internal.h: up to 1.1.1.2
sys/external/bsd/libfdt/dist/version.lds: up to 1.1.1.2
Import of libfdt from DTC version 1.4.4
diffstat:
sys/external/bsd/libfdt/dist/Makefile.libfdt | 2 +-
sys/external/bsd/libfdt/dist/fdt.c | 15 +-
sys/external/bsd/libfdt/dist/fdt.h | 2 +
sys/external/bsd/libfdt/dist/fdt_addresses.c | 2 +
sys/external/bsd/libfdt/dist/fdt_empty_tree.c | 2 +
sys/external/bsd/libfdt/dist/fdt_overlay.c | 679 +++++++++++++++++++++++++
sys/external/bsd/libfdt/dist/fdt_ro.c | 38 +-
sys/external/bsd/libfdt/dist/fdt_rw.c | 11 +-
sys/external/bsd/libfdt/dist/fdt_strerror.c | 8 +
sys/external/bsd/libfdt/dist/fdt_sw.c | 2 +
sys/external/bsd/libfdt/dist/fdt_wip.c | 33 +-
sys/external/bsd/libfdt/dist/libfdt.h | 242 +++++++-
sys/external/bsd/libfdt/dist/libfdt_env.h | 29 +-
sys/external/bsd/libfdt/dist/libfdt_internal.h | 2 +
sys/external/bsd/libfdt/dist/version.lds | 1 +
15 files changed, 1001 insertions(+), 67 deletions(-)
diffs (truncated from 1507 to 300 lines):
diff -r f1797d2182f8 -r 8bd1d1cc1104 sys/external/bsd/libfdt/dist/Makefile.libfdt
--- a/sys/external/bsd/libfdt/dist/Makefile.libfdt Tue Jul 18 16:08:36 2017 +0000
+++ b/sys/external/bsd/libfdt/dist/Makefile.libfdt Tue Jul 18 17:08:08 2017 +0000
@@ -7,5 +7,5 @@
LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h
LIBFDT_VERSION = version.lds
LIBFDT_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_addresses.c fdt_overlay.c
LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
diff -r f1797d2182f8 -r 8bd1d1cc1104 sys/external/bsd/libfdt/dist/fdt.c
--- a/sys/external/bsd/libfdt/dist/fdt.c Tue Jul 18 16:08:36 2017 +0000
+++ b/sys/external/bsd/libfdt/dist/fdt.c Tue Jul 18 17:08:08 2017 +0000
@@ -1,3 +1,5 @@
+/* $NetBSD: fdt.c,v 1.1.1.1.12.1 2017/07/18 17:08:08 snj Exp $ */
+
/*
* libfdt - Flat Device Tree manipulation
* Copyright (C) 2006 David Gibson, IBM Corporation.
@@ -76,18 +78,19 @@
const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
{
- const char *p;
+ unsigned absoffset = offset + fdt_off_dt_struct(fdt);
+
+ if ((absoffset < offset)
+ || ((absoffset + len) < absoffset)
+ || (absoffset + len) > fdt_totalsize(fdt))
+ return NULL;
if (fdt_version(fdt) >= 0x11)
if (((offset + len) < offset)
|| ((offset + len) > fdt_size_dt_struct(fdt)))
return NULL;
- p = _fdt_offset_ptr(fdt, offset);
-
- if (p + len < p)
- return NULL;
- return p;
+ return _fdt_offset_ptr(fdt, offset);
}
uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
diff -r f1797d2182f8 -r 8bd1d1cc1104 sys/external/bsd/libfdt/dist/fdt.h
--- a/sys/external/bsd/libfdt/dist/fdt.h Tue Jul 18 16:08:36 2017 +0000
+++ b/sys/external/bsd/libfdt/dist/fdt.h Tue Jul 18 17:08:08 2017 +0000
@@ -1,3 +1,5 @@
+/* $NetBSD: fdt.h,v 1.1.1.1.12.1 2017/07/18 17:08:08 snj Exp $ */
+
#ifndef _FDT_H
#define _FDT_H
/*
diff -r f1797d2182f8 -r 8bd1d1cc1104 sys/external/bsd/libfdt/dist/fdt_addresses.c
--- a/sys/external/bsd/libfdt/dist/fdt_addresses.c Tue Jul 18 16:08:36 2017 +0000
+++ b/sys/external/bsd/libfdt/dist/fdt_addresses.c Tue Jul 18 17:08:08 2017 +0000
@@ -1,3 +1,5 @@
+/* $NetBSD: fdt_addresses.c,v 1.1.1.1.12.1 2017/07/18 17:08:08 snj Exp $ */
+
/*
* libfdt - Flat Device Tree manipulation
* Copyright (C) 2014 David Gibson <david%gibson.dropbear.id.au@localhost>
diff -r f1797d2182f8 -r 8bd1d1cc1104 sys/external/bsd/libfdt/dist/fdt_empty_tree.c
--- a/sys/external/bsd/libfdt/dist/fdt_empty_tree.c Tue Jul 18 16:08:36 2017 +0000
+++ b/sys/external/bsd/libfdt/dist/fdt_empty_tree.c Tue Jul 18 17:08:08 2017 +0000
@@ -1,3 +1,5 @@
+/* $NetBSD: fdt_empty_tree.c,v 1.1.1.1.12.1 2017/07/18 17:08:08 snj Exp $ */
+
/*
* libfdt - Flat Device Tree manipulation
* Copyright (C) 2012 David Gibson, IBM Corporation.
diff -r f1797d2182f8 -r 8bd1d1cc1104 sys/external/bsd/libfdt/dist/fdt_overlay.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/external/bsd/libfdt/dist/fdt_overlay.c Tue Jul 18 17:08:08 2017 +0000
@@ -0,0 +1,679 @@
+/* $NetBSD: fdt_overlay.c,v 1.1.1.1.4.2 2017/07/18 17:08:08 snj Exp $ */
+
+#include "libfdt_env.h"
+
+#include <fdt.h>
+#include <libfdt.h>
+
+#include "libfdt_internal.h"
+
+/**
+ * overlay_get_target_phandle - retrieves the target phandle of a fragment
+ * @fdto: pointer to the device tree overlay blob
+ * @fragment: node offset of the fragment in the overlay
+ *
+ * overlay_get_target_phandle() retrieves the target phandle of an
+ * overlay fragment when that fragment uses a phandle (target
+ * property) instead of a path (target-path property).
+ *
+ * returns:
+ * the phandle pointed by the target property
+ * 0, if the phandle was not found
+ * -1, if the phandle was malformed
+ */
+static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
+{
+ const fdt32_t *val;
+ int len;
+
+ val = fdt_getprop(fdto, fragment, "target", &len);
+ if (!val)
+ return 0;
+
+ if ((len != sizeof(*val)) || (fdt32_to_cpu(*val) == (uint32_t)-1))
+ return (uint32_t)-1;
+
+ return fdt32_to_cpu(*val);
+}
+
+/**
+ * overlay_get_target - retrieves the offset of a fragment's target
+ * @fdt: Base device tree blob
+ * @fdto: Device tree overlay blob
+ * @fragment: node offset of the fragment in the overlay
+ *
+ * overlay_get_target() retrieves the target offset in the base
+ * device tree of a fragment, no matter how the actual targetting is
+ * done (through a phandle or a path)
+ *
+ * returns:
+ * the targetted node offset in the base device tree
+ * Negative error code on error
+ */
+static int overlay_get_target(const void *fdt, const void *fdto,
+ int fragment)
+{
+ uint32_t phandle;
+ const char *path;
+ int path_len;
+
+ /* Try first to do a phandle based lookup */
+ phandle = overlay_get_target_phandle(fdto, fragment);
+ if (phandle == (uint32_t)-1)
+ return -FDT_ERR_BADPHANDLE;
+
+ if (phandle)
+ return fdt_node_offset_by_phandle(fdt, phandle);
+
+ /* And then a path based lookup */
+ path = fdt_getprop(fdto, fragment, "target-path", &path_len);
+ if (!path) {
+ /*
+ * If we haven't found either a target or a
+ * target-path property in a node that contains a
+ * __overlay__ subnode (we wouldn't be called
+ * otherwise), consider it a improperly written
+ * overlay
+ */
+ if (path_len == -FDT_ERR_NOTFOUND)
+ return -FDT_ERR_BADOVERLAY;
+
+ return path_len;
+ }
+
+ return fdt_path_offset(fdt, path);
+}
+
+/**
+ * overlay_phandle_add_offset - Increases a phandle by an offset
+ * @fdt: Base device tree blob
+ * @node: Device tree overlay blob
+ * @name: Name of the property to modify (phandle or linux,phandle)
+ * @delta: offset to apply
+ *
+ * overlay_phandle_add_offset() increments a node phandle by a given
+ * offset.
+ *
+ * returns:
+ * 0 on success.
+ * Negative error code on error
+ */
+static int overlay_phandle_add_offset(void *fdt, int node,
+ const char *name, uint32_t delta)
+{
+ const fdt32_t *val;
+ uint32_t adj_val;
+ int len;
+
+ val = fdt_getprop(fdt, node, name, &len);
+ if (!val)
+ return len;
+
+ if (len != sizeof(*val))
+ return -FDT_ERR_BADPHANDLE;
+
+ adj_val = fdt32_to_cpu(*val);
+ if ((adj_val + delta) < adj_val)
+ return -FDT_ERR_NOPHANDLES;
+
+ adj_val += delta;
+ if (adj_val == (uint32_t)-1)
+ return -FDT_ERR_NOPHANDLES;
+
+ return fdt_setprop_inplace_u32(fdt, node, name, adj_val);
+}
+
+/**
+ * overlay_adjust_node_phandles - Offsets the phandles of a node
+ * @fdto: Device tree overlay blob
+ * @node: Offset of the node we want to adjust
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_adjust_node_phandles() adds a constant to all the phandles
+ * of a given node. This is mainly use as part of the overlay
+ * application process, when we want to update all the overlay
+ * phandles to not conflict with the overlays of the base device tree.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int overlay_adjust_node_phandles(void *fdto, int node,
+ uint32_t delta)
+{
+ int child;
+ int ret;
+
+ ret = overlay_phandle_add_offset(fdto, node, "phandle", delta);
+ if (ret && ret != -FDT_ERR_NOTFOUND)
+ return ret;
+
+ ret = overlay_phandle_add_offset(fdto, node, "linux,phandle", delta);
+ if (ret && ret != -FDT_ERR_NOTFOUND)
+ return ret;
+
+ fdt_for_each_subnode(child, fdto, node) {
+ ret = overlay_adjust_node_phandles(fdto, child, delta);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+/**
+ * overlay_adjust_local_phandles - Adjust the phandles of a whole overlay
+ * @fdto: Device tree overlay blob
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_adjust_local_phandles() adds a constant to all the
+ * phandles of an overlay. This is mainly use as part of the overlay
+ * application process, when we want to update all the overlay
+ * phandles to not conflict with the overlays of the base device tree.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int overlay_adjust_local_phandles(void *fdto, uint32_t delta)
+{
+ /*
+ * Start adjusting the phandles from the overlay root
+ */
+ return overlay_adjust_node_phandles(fdto, 0, delta);
+}
+
+/**
+ * overlay_update_local_node_references - Adjust the overlay references
+ * @fdto: Device tree overlay blob
+ * @tree_node: Node offset of the node to operate on
+ * @fixup_node: Node offset of the matching local fixups node
+ * @delta: Offset to shift the phandles of
+ *
+ * overlay_update_local_nodes_references() update the phandles
+ * pointing to a node within the device tree overlay by adding a
+ * constant delta.
+ *
+ * This is mainly used as part of a device tree application process,
+ * where you want the device tree overlays phandles to not conflict
+ * with the ones from the base device tree before merging them.
+ *
+ * returns:
+ * 0 on success
+ * Negative error code on failure
+ */
+static int overlay_update_local_node_references(void *fdto,
+ int tree_node,
+ int fixup_node,
+ uint32_t delta)
+{
+ int fixup_prop;
+ int fixup_child;
+ int ret;
+
+ fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) {
+ const fdt32_t *fixup_val;
+ const char *tree_val;
+ const char *name;
+ int fixup_len;
+ int tree_len;
+ int i;
+
+ fixup_val = fdt_getprop_by_offset(fdto, fixup_prop,
+ &name, &fixup_len);
+ if (!fixup_val)
Home |
Main Index |
Thread Index |
Old Index