Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Aug 2016 18:48:47 +0000 (UTC)
From:      "Stephen J. Kiernan" <stevek@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r303803 - in head/sys/dev: fdt ofw
Message-ID:  <201608061848.u76ImlqK030395@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: stevek
Date: Sat Aug  6 18:48:47 2016
New Revision: 303803
URL: https://svnweb.freebsd.org/changeset/base/303803

Log:
  Add hw.fdt sysctl node.
  Make FDT blob available via opaque hw.fdt.dtb sysctl, if a DTB has been
  installed by the time sysctls are registered.
  
  Reviewed by:	andrew
  Approved by:	sjg (mentor)
  Sponsored by:	Juniper Networks, Inc.
  Differential Revision:	https://reviews.freebsd.org/D7411

Modified:
  head/sys/dev/fdt/fdt_common.c
  head/sys/dev/fdt/fdt_common.h
  head/sys/dev/ofw/ofw_fdt.c

Modified: head/sys/dev/fdt/fdt_common.c
==============================================================================
--- head/sys/dev/fdt/fdt_common.c	Sat Aug  6 17:53:53 2016	(r303802)
+++ head/sys/dev/fdt/fdt_common.c	Sat Aug  6 18:48:47 2016	(r303803)
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/module.h>
 #include <sys/bus.h>
 #include <sys/limits.h>
+#include <sys/sysctl.h>
 
 #include <machine/resource.h>
 
@@ -60,6 +61,8 @@ __FBSDID("$FreeBSD$");
 
 #define FDT_REG_CELLS	4
 
+SYSCTL_NODE(_hw, OID_AUTO, fdt, CTLFLAG_RD, 0, "Flattened Device Tree");
+
 vm_paddr_t fdt_immr_pa;
 vm_offset_t fdt_immr_va;
 vm_offset_t fdt_immr_size;

Modified: head/sys/dev/fdt/fdt_common.h
==============================================================================
--- head/sys/dev/fdt/fdt_common.h	Sat Aug  6 17:53:53 2016	(r303802)
+++ head/sys/dev/fdt/fdt_common.h	Sat Aug  6 18:48:47 2016	(r303803)
@@ -32,6 +32,7 @@
 #ifndef _FDT_COMMON_H_
 #define _FDT_COMMON_H_
 
+#include <sys/sysctl.h>
 #include <sys/slicer.h>
 #include <contrib/libfdt/libfdt_env.h>
 #include <dev/ofw/ofw_bus.h>
@@ -80,6 +81,8 @@ extern struct fdt_pm_mask_entry fdt_pm_m
 extern u_char fdt_static_dtb;
 #endif
 
+SYSCTL_DECL(_hw_fdt);
+
 int fdt_addrsize_cells(phandle_t, int *, int *);
 u_long fdt_data_get(void *, int);
 int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *);

Modified: head/sys/dev/ofw/ofw_fdt.c
==============================================================================
--- head/sys/dev/ofw/ofw_fdt.c	Sat Aug  6 17:53:53 2016	(r303802)
+++ head/sys/dev/ofw/ofw_fdt.c	Sat Aug  6 18:48:47 2016	(r303803)
@@ -96,6 +96,27 @@ OFW_DEF(ofw_fdt);
 static void *fdtp = NULL;
 
 static int
+sysctl_handle_dtb(SYSCTL_HANDLER_ARGS)
+{
+
+        return (sysctl_handle_opaque(oidp, fdtp, fdt_totalsize(fdtp), req));
+}
+
+static void
+sysctl_register_fdt_oid(void *arg)
+{
+
+	/* If there is no FDT registered, skip adding the sysctl */
+	if (fdtp == NULL)
+		return;
+
+	SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_fdt), OID_AUTO, "dtb",
+	    CTLTYPE_OPAQUE | CTLFLAG_RD, NULL, 0, sysctl_handle_dtb, "",
+	    "Device Tree Blob");
+}
+SYSINIT(dtb_oid, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_fdt_oid, 0);
+
+static int
 ofw_fdt_init(ofw_t ofw, void *data)
 {
 	int err;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608061848.u76ImlqK030395>