From owner-svn-src-all@freebsd.org Sun Apr 8 15:21:13 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 48416F89B4C; Sun, 8 Apr 2018 15:21:13 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F1321849C7; Sun, 8 Apr 2018 15:21:12 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EC37811999; Sun, 8 Apr 2018 15:21:12 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w38FLCHF058044; Sun, 8 Apr 2018 15:21:12 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w38FLCJ2058043; Sun, 8 Apr 2018 15:21:12 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201804081521.w38FLCJ2058043@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sun, 8 Apr 2018 15:21:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332278 - head/sys/dev/fdt X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/sys/dev/fdt X-SVN-Commit-Revision: 332278 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Apr 2018 15:21:13 -0000 Author: andrew Date: Sun Apr 8 15:21:12 2018 New Revision: 332278 URL: https://svnweb.freebsd.org/changeset/base/332278 Log: Revert r332277, it contained an unintended extra change Modified: head/sys/dev/fdt/fdt_common.c Modified: head/sys/dev/fdt/fdt_common.c ============================================================================== --- head/sys/dev/fdt/fdt_common.c Sun Apr 8 15:12:36 2018 (r332277) +++ head/sys/dev/fdt/fdt_common.c Sun Apr 8 15:21:12 2018 (r332278) @@ -71,6 +71,8 @@ vm_offset_t fdt_immr_size; struct fdt_ic_list fdt_ic_list_head = SLIST_HEAD_INITIALIZER(fdt_ic_list_head); +static int fdt_is_compatible(phandle_t, const char *); + static int fdt_get_range_by_busaddr(phandle_t node, u_long addr, u_long *base, u_long *size) @@ -203,6 +205,77 @@ fdt_get_range(phandle_t node, int range_id, u_long *ba } int +fdt_immr_addr(vm_offset_t immr_va) +{ + phandle_t node; + u_long base, size; + int r; + + /* + * Try to access the SOC node directly i.e. through /aliases/. + */ + if ((node = OF_finddevice("soc")) != -1) + if (fdt_is_compatible(node, "simple-bus")) + goto moveon; + /* + * Find the node the long way. + */ + if ((node = OF_finddevice("/")) == -1) + return (ENXIO); + + if ((node = fdt_find_compatible(node, "simple-bus", 0)) == 0) + return (ENXIO); + +moveon: + if ((r = fdt_get_range(node, 0, &base, &size)) == 0) { + fdt_immr_pa = base; + fdt_immr_va = immr_va; + fdt_immr_size = size; + } + + return (r); +} + +/* + * This routine is an early-usage version of the ofw_bus_is_compatible() when + * the ofw_bus I/F is not available (like early console routines and similar). + * Note the buffer has to be on the stack since malloc() is usually not + * available in such cases either. + */ +static int +fdt_is_compatible(phandle_t node, const char *compatstr) +{ + char buf[FDT_COMPAT_LEN]; + char *compat; + int len, onelen, l, rv; + + if ((len = OF_getproplen(node, "compatible")) <= 0) + return (0); + + compat = (char *)&buf; + bzero(compat, FDT_COMPAT_LEN); + + if (OF_getprop(node, "compatible", compat, FDT_COMPAT_LEN) < 0) + return (0); + + onelen = strlen(compatstr); + rv = 0; + while (len > 0) { + if (strncasecmp(compat, compatstr, onelen) == 0) { + /* Found it. */ + rv = 1; + break; + } + /* Slide to the next sub-string. */ + l = strlen(compat) + 1; + compat += l; + len -= l; + } + + return (rv); +} + +int fdt_is_compatible_strict(phandle_t node, const char *compatible) { char compat[FDT_COMPAT_LEN]; @@ -230,7 +303,7 @@ fdt_find_compatible(phandle_t start, const char *compa * matching 'compatible' property. */ for (child = OF_child(start); child != 0; child = OF_peer(child)) - if (ofw_bus_node_is_compatible(child, compat)) { + if (fdt_is_compatible(child, compat)) { if (strict) if (!fdt_is_compatible_strict(child, compat)) continue; @@ -249,7 +322,7 @@ fdt_depth_search_compatible(phandle_t start, const cha * matching 'compatible' property. */ for (node = OF_child(start); node != 0; node = OF_peer(node)) { - if (ofw_bus_node_is_compatible(node, compat) && + if (fdt_is_compatible(node, compat) && (strict == 0 || fdt_is_compatible_strict(node, compat))) { return (node); }