<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hello,<br></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 21, 2020 at 10:58 PM Niteesh G. S. <<a href="mailto:niteesh.gs@gmail.com">niteesh.gs@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
diff --git a/bsps/shared/ofw/ofw.c b/bsps/shared/ofw/ofw.c<br>
new file mode 100644<br>
index 0000000000..481b29553b<br>
--- /dev/null<br>
+++ b/bsps/shared/ofw/ofw.c<br>
@@ -0,0 +1,670 @@<br>
+/* SPDX-License-Identifier: BSD-2-Clause */<br>
+<br>
+/**<br>
+ * @file<br>
+ *<br>
+ * @ingroup ofw<br>
+ */<br>
+<br>
+/*<br>
+ * Copyright (C) 2020 Niteesh Babu G S <<a href="mailto:niteesh.gs@gmail.com" target="_blank">niteesh.gs@gmail.com</a>><br>
+ *<br>
+ * Redistribution and use in source and binary forms, with or without<br>
+ * modification, are permitted provided that the following conditions<br>
+ * are met:<br>
+ * 1. Redistributions of source code must retain the above copyright<br>
+ * notice, this list of conditions and the following disclaimer.<br>
+ * 2. Redistributions in binary form must reproduce the above copyright<br>
+ * notice, this list of conditions and the following disclaimer in the<br>
+ * documentation and/or other materials provided with the distribution.<br>
+ *<br>
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"<br>
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE<br>
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br>
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br>
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br>
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br>
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br>
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br>
+ * POSSIBILITY OF SUCH DAMAGE.<br>
+ */<br>
+<br>
+#ifdef HAVE_CONFIG_H<br>
+#include "config.h"<br>
+#endif<br>
+<br>
+#include <bsp/fdt.h><br>
+#include <sys/param.h><br>
+#include <ofw/ofw.h><br>
+#include <libfdt.h><br>
+#include <assert.h><br>
+#include <rtems/sysinit.h><br>
+<br>
+const void *fdtp = NULL;<br>
+<br>
+static phandle_t rtems_fdt_offset_to_phandle( int offset )<br>
+{<br>
+ if (offset < 0) {<br>
+ return 0;<br>
+ }<br>
+<br>
+ return (phandle_t)offset + fdt_off_dt_struct(fdtp);<br>
+}<br>
+<br>
+static int rtems_fdt_phandle_to_offset( phandle_t handle )<br>
+{<br>
+ int off;<br>
+ int fdt_off;<br>
+<br>
+ off = (int) handle;<br>
+ fdt_off = fdt_off_dt_struct(fdtp);<br>
+<br>
+ if (off < fdt_off) {<br>
+ return -1;<br>
+<br>
+ }<br>
+<br>
+ return off - fdt_off;<br>
+}<br>
+<br>
+static void rtems_ofw_init( void ) {<br>
+ int rv;<br>
+ const void *fdt;<br>
+ <br>
+ fdt = bsp_fdt_get();<br>
+<br>
+ rv = fdt_check_header(fdt);<br>
+<br>
+ /*<br>
+ * If the FDT is invalid exit through fatal.<br>
+ */<br>
+ if (rv != 0) {<br>
+ rtems_fatal_error_occurred(RTEMS_NOT_CONFIGURED);<br>
+ }<br>
+<br>
+ fdtp = fdt;<br>
+}<br>
+<br>
+RTEMS_SYSINIT_ITEM(<br>
+ rtems_ofw_init,<br>
+ RTEMS_SYSINIT_BSP_PRE_DRIVERS,<br>
+ RTEMS_SYSINIT_ORDER_FIRST<br>
+);<br>
+<br>
+phandle_t rtems_ofw_peer( phandle_t node )<br>
+{<br>
+ int offset;<br>
+<br>
+ if (node == 0) {<br>
+ int root = fdt_path_offset(fdtp, "/");<br>
+ return rtems_fdt_offset_to_phandle(root);<br>
+ }<br>
+<br>
+ offset = rtems_fdt_phandle_to_offset(node);<br>
+ if (offset < 0) {<br>
+ return 0;<br>
+ }<br>
+<br>
+ offset = fdt_next_subnode(fdtp, offset);<br>
+ return rtems_fdt_offset_to_phandle(offset);<br>
+}<br>
+<br>
+phandle_t rtems_ofw_child( phandle_t node )<br>
+{<br>
+ int offset;<br>
+<br>
+ offset = rtems_fdt_phandle_to_offset(node);<br>
+<br>
+ if (offset < 0) {<br>
+ return 0;<br>
+ }<br>
+<br>
+ offset = fdt_first_subnode(fdtp, offset);<br>
+ return rtems_fdt_offset_to_phandle(offset);<br>
+}<br>
+<br>
+phandle_t rtems_ofw_parent( phandle_t node )<br>
+{<br>
+ int offset;<br>
+<br>
+ offset = rtems_fdt_phandle_to_offset(node);<br>
+<br>
+ if (offset < 0) {<br>
+ return 0;<br>
+ }<br>
+<br>
+ offset = fdt_parent_offset(fdtp, offset);<br>
+ return rtems_fdt_offset_to_phandle(offset);<br>
+}<br>
+<br>
+size_t rtems_ofw_get_prop_len(<br>
+ phandle_t node,<br>
+ const char *propname<br>
+)<br>
+{<br>
+ int offset;<br>
+ int len;<br>
+ const void *prop;<br>
+<br>
+ offset = rtems_fdt_phandle_to_offset(node);<br>
+<br>
+ if (offset < 0) {<br>
+ return -1;<br>
+ }<br>
+<br>
+ prop = fdt_getprop(fdtp, offset, propname, &len);<br>
+<br>
+ if (prop == NULL && strcmp(propname, "name") == 0) {<br>
+ fdt_get_name(fdtp, offset, &len);<br>
+ return len + 1;<br>
+ }<br>
+<br>
+ if (prop == NULL && strcmp(propname, "/chosen") == 0) {<br>
+ if (strcmp(propname, "fdtbootcpu") == 0)<br>
+ return sizeof(pcell_t);<br>
+ if (strcmp(propname, "fdtmemreserv") == 0)<br>
+ return 2 * sizeof(uint64_t) * fdt_num_mem_rsv(fdtp);<br>
+ }<br>
+<br>
+ if (prop == NULL) {<br>
+ return -1;<br>
+ }<br>
+<br>
+ return len;<br>
+}<br>
+<br>
+size_t rtems_ofw_get_prop(<br>
+ phandle_t node,<br>
+ const char *propname,<br>
+ void *buf,<br>
+ size_t bufsize<br>
+)<br>
+{<br>
+ const void *prop;<br>
+ int offset;<br>
+ int len;<br>
+ uint32_t cpuid;<br>
+<br>
+ offset = rtems_fdt_phandle_to_offset(node);<br>
+<br>
+ if (offset < 0) {<br>
+ return -1;<br>
+ }<br>
+<br>
+ prop = fdt_getprop(fdtp, offset, propname, &len);<br>
+<br>
+ if (prop == NULL && strcmp(propname, "name") == 0) {<br>
+ prop = fdt_get_name(fdtp, offset, &len);<br>
+ strncpy(buf, prop, bufsize);<br>
+ return len + 1;<br>
+ }<br>
+<br>
+ if (prop == NULL && strcmp(propname, "/chosen") == 0) {<br>
+ if (strcmp(propname, "fdtbootcpu") == 0) {<br>
+ cpuid = cpu_to_fdt32(fdt_boot_cpuid_phys(fdtp));<br>
+ len = sizeof(cpuid);<br>
+ prop = &cpuid;<br>
+ }<br>
+ if (strcmp(propname, "fdtmemreserv") == 0) {<br>
+ prop = (char *)fdtp + fdt_off_mem_rsvmap(fdtp);<br>
+ len = sizeof(uint64_t)*2*fdt_num_mem_rsv(fdtp);<br>
+ }<br>
+ }<br>
+<br>
+ if (prop == NULL) {<br>
+ return -1;<br>
+ }<br>
+<br>
+ bcopy(prop, buf, MIN(len, bufsize));<br>
+<br>
+ return len;<br>
+}<br>
+<br>
+size_t rtems_ofw_get_enc_prop(<br>
+ phandle_t node,<br>
+ const char *prop,<br>
+ pcell_t *buf,<br>
+ size_t len<br>
+)<br>
+{<br>
+ size_t rv;<br>
+<br>
+ assert(len % 4 == 0);<br>
+ rv = rtems_ofw_get_prop(node, prop, buf, len);<br>
+<br>
+ if (rv < 0) {<br>
+ return rv;<br>
+ }<br>
+<br>
+ for (int i = 0; i < (len / 4); i++) {<br>
+ buf[i] = fdt32_to_cpu(buf[i]);<br>
+ }<br>
+<br>
+ return rv;<br>
+}<br>
+<br>
+int rtems_ofw_has_prop(<br>
+ phandle_t node,<br>
+ const char *propname<br>
+)<br>
+{<br>
+ size_t rv;<br>
+<br>
+ rv = rtems_ofw_get_prop_len(node, propname);<br>
+ return rv >= 0 ? 1 : 0;<br>
+}<br>
+<br>
+size_t rtems_ofw_search_prop(<br>
+ phandle_t node,<br>
+ const char *propname,<br>
+ void *buf,<br>
+ size_t len<br>
+)<br>
+{<br>
+ size_t rv;<br>
+<br>
+ for (; node != 0; node = rtems_ofw_parent(node)) {<br>
+ if ((rv = rtems_ofw_get_prop(node, propname, buf, len) != -1)) {<br>
+ return rv;<br>
+ }<br>
+ }<br>
+<br>
+ return -1;<br>
+}<br>
+<br>
+size_t rtems_ofw_search_enc_prop(<br>
+ phandle_t node,<br>
+ const char *propname,<br>
+ pcell_t *buf,<br>
+ size_t len<br>
+)<br>
+{<br>
+ size_t rv;<br>
+<br>
+ for (; node != 0; node = rtems_ofw_parent(node)) {<br>
+ if ((rv = rtems_ofw_get_enc_prop(node, propname, buf, len) != -1)) {<br>
+ return rv;<br>
+ }<br>
+ }<br>
+<br>
+ return -1;<br>
+}<br>
+<br>
+size_t rtems_ofw_get_prop_alloc(<br>
+ phandle_t node,<br>
+ const char *propname,<br>
+ void **buf<br>
+)<br>
+{<br>
+ size_t len;<br>
+<br>
+ *buf = NULL;<br>
+ if ((len = rtems_ofw_get_prop_len(node, propname)) == -1) {<br>
+ return -1;<br>
+ }<br>
+<br>
+ if (len > 0) {<br>
+ *buf = malloc(len);<br>
+<br>
+ if (rtems_ofw_get_prop(node, propname, *buf, len) == -1) {<br>
+ rtems_ofw_free(buf);<br>
+ *buf = NULL;<br>
+ return -1;<br>
+ }<br>
+ }<br>
+<br>
+ return len;<br>
+}<br>
+<br>
+size_t rtems_ofw_get_prop_alloc_multi(<br>
+ phandle_t node,<br>
+ const char *propname,<br>
+ int elsz,<br>
+ void **buf<br>
+)<br>
+{<br>
+ size_t len;<br>
+<br>
+ *buf = NULL;<br>
+ if ((len = rtems_ofw_get_prop_len(node, propname)) == -1 ||<br>
+ (len % elsz != 0)) {<br>
+ return -1;<br>
+ }<br></blockquote><div><br></div><div style="font-size:small">While going through the code again, a question raised inside me,</div><div style="font-size:small">In the above code, the function rtems_ofw_get_prop_len returns</div><div style="font-size:small">a size_t which is an unsigned value, I compare that to -1 is that</div><div style="font-size:small">OK from a code review point of view or should I change the type</div><div style="font-size:small">of len to -1?</div></div></div></blockquote><div><br></div><div class="gmail_default" style="font-size:small">UPDATE: I should have been using ssize_t, I always thought ssize_t and</div><div class="gmail_default" style="font-size:small">size_t were both the same type. But after googling I realized that ssize_t</div><div class="gmail_default" style="font-size:small">is signed, unlike size_t which is unsigned.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I have updated the local commit to use ssize_t instead of size_t as return</div><div class="gmail_default" style="font-size:small">type and as variable types in some places. So please ignore this issue</div><div class="gmail_default" style="font-size:small">during code review. Sorry for the mistake.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+ if (len > 0) {<br>
+ *buf = malloc(len);<br>
+<br>
+ if (rtems_ofw_get_prop(node, propname, *buf, len) == -1) {<br>
+ rtems_ofw_free(buf);<br>
+ *buf = NULL;<br>
+ return -1;<br>
+ }<br>
+ }<br>
+<br>
+ return (len / elsz);<br>
+}<br>
+<br>
+size_t rtems_ofw_get_enc_prop_alloc(<br>
+ phandle_t node,<br>
+ const char *propname,<br>
+ void **buf<br>
+)<br>
+{<br>
+ size_t len;<br>
+<br>
+ *buf = NULL;<br>
+ if ((len = rtems_ofw_get_prop_len(node, propname)) == -1) {<br>
+ return -1;<br>
+ }<br>
+<br>
+ if (len > 0) {<br>
+ *buf = malloc(len);<br>
+<br>
+ if (rtems_ofw_get_enc_prop(node, propname, *buf, len) == -1) {<br>
+ rtems_ofw_free(buf);<br>
+ *buf = NULL;<br>
+ return -1;<br>
+ }<br>
+ }<br>
+<br>
+ return len;<br>
+}<br>
+<br>
+size_t rtems_ofw_get_enc_prop_alloc_multi(<br>
+ phandle_t node,<br>
+ const char *propname,<br>
+ int elsz,<br>
+ void **buf<br>
+)<br>
+{<br>
+ size_t len;<br>
+<br>
+ *buf = NULL;<br>
+ if ((len = rtems_ofw_get_prop_len(node, propname)) == -1 ||<br>
+ (len % elsz != 0)) {<br>
+ return -1;<br>
+ }<br>
+<br>
+ if (len > 0) {<br>
+ *buf = malloc(len);<br>
+<br>
+ if (rtems_ofw_get_enc_prop(node, propname, *buf, len) == -1) {<br>
+ rtems_ofw_free(buf);<br>
+ *buf = NULL;<br>
+ return -1;<br>
+ }<br>
+ }<br>
+<br>
+ return (len / elsz);<br>
+}<br>
+<br>
+void rtems_ofw_free( void *buf )<br>
+{<br>
+ free(buf);<br>
+}<br>
+<br>
+int rtems_ofw_next_prop(<br>
+ phandle_t node,<br>
+ const char *previous,<br>
+ char *buf,<br>
+ size_t len<br>
+)<br>
+{<br>
+ const void *name;<br>
+ const void *prop;<br>
+ int offset;<br>
+<br>
+ offset = rtems_fdt_phandle_to_offset(node);<br>
+<br>
+ if (offset < 0) {<br>
+ return -1;<br>
+ }<br>
+<br>
+ if (previous == NULL) {<br>
+ offset = fdt_first_property_offset(fdtp, offset);<br>
+ } else {<br>
+ fdt_for_each_property_offset(offset, fdtp, offset) {<br>
+ prop = fdt_getprop_by_offset(fdtp, offset, (const char **)&name, NULL);<br>
+ if (prop == NULL)<br>
+ return -1;<br>
+<br>
+ if (strcmp(previous, name) != 0)<br>
+ continue;<br>
+<br>
+ offset = fdt_next_property_offset(fdtp, offset);<br>
+ break;<br>
+ }<br>
+ }<br>
+<br>
+ if (offset < 0)<br>
+ return 0;<br>
+<br>
+ prop = fdt_getprop_by_offset(fdtp, offset, (const char **)&name, &offset);<br>
+ if (prop == NULL)<br>
+ return -1;<br>
+<br>
+ strncpy(buf, name, len);<br>
+<br>
+ return 1;<br>
+}<br>
+<br>
+int rtems_ofw_set_prop(<br>
+ phandle_t node,<br>
+ const char *name,<br>
+ const void *buf,<br>
+ size_t len<br>
+)<br>
+{<br>
+ int offset;<br>
+<br>
+ offset = rtems_fdt_phandle_to_offset(node);<br>
+<br>
+ if (offset < 0)<br>
+ return -1;<br>
+<br>
+ if (fdt_setprop_inplace(fdtp, offset, name, buf, len) != 0)<br>
+ return (fdt_setprop(fdtp, offset, name, buf, len));<br>
+<br>
+ return 0;<br>
+}<br>
+<br>
+phandle_t rtems_ofw_find_device( const char *path )<br>
+{<br>
+ int offset;<br>
+<br>
+ offset = fdt_path_offset(fdtp, path);<br>
+ if (offset < 0)<br>
+ return -1;<br>
+<br>
+ return rtems_fdt_offset_to_phandle(offset);<br>
+}<br>
+<br>
+static phandle_t rtems_ofw_get_effective_phandle(<br>
+ phandle_t node,<br>
+ phandle_t xref<br>
+)<br>
+{<br>
+ phandle_t child;<br>
+ phandle_t ref;<br>
+<br>
+ for (child = rtems_ofw_child(node); child != 0; child = rtems_ofw_peer(child)) {<br>
+ ref = rtems_ofw_get_effective_phandle(child, xref);<br>
+ if (ref != -1)<br>
+ return ref;<br>
+<br>
+ if (rtems_ofw_get_enc_prop(child, "phandle", &ref, sizeof(ref)) == -1 &&<br>
+ rtems_ofw_get_enc_prop(child, "ibm,phandle", &ref, sizeof(ref)) == -1 &&<br>
+ rtems_ofw_get_enc_prop(child, "linux,phandle", &ref, sizeof(ref)) == -1<br>
+ ) {<br>
+ continue;<br>
+ }<br>
+<br>
+ if (ref == xref)<br>
+ return child;<br>
+ }<br>
+<br>
+ return -1;<br>
+}<br>
+<br>
+phandle_t rtems_ofw_node_from_xref( phandle_t xref )<br>
+{<br>
+ phandle_t node;<br>
+<br>
+ if ((node = rtems_ofw_get_effective_phandle(rtems_ofw_peer(0), xref)) == -1)<br>
+ return xref;<br>
+<br>
+ return node;<br>
+}<br>
+<br>
+phandle_t rtems_ofw_xref_from_node( phandle_t node )<br>
+{<br>
+ phandle_t ref;<br>
+<br>
+ if (rtems_ofw_get_enc_prop(node, "phandle", &ref, sizeof(ref)) == -1 &&<br>
+ rtems_ofw_get_enc_prop(node, "ibm,phandle", &ref, sizeof(ref)) == -1 &&<br>
+ rtems_ofw_get_enc_prop(node, "linux,phandle", &ref, sizeof(ref)) == -1)<br>
+ {<br>
+ return node;<br>
+ }<br>
+<br>
+ return ref;<br>
+}<br>
+<br>
+phandle_t rtems_ofw_instance_to_package( ihandle_t instance )<br>
+{<br>
+ return rtems_ofw_node_from_xref(instance);<br>
+}<br>
+<br>
+size_t rtems_ofw_package_to_path(<br>
+ phandle_t node,<br>
+ char *buf,<br>
+ size_t len<br>
+)<br>
+{<br>
+ int offset;<br>
+ int rv;<br>
+<br>
+ offset = rtems_fdt_phandle_to_offset(node);<br>
+<br>
+ rv = fdt_get_path(fdtp, offset, buf, len);<br>
+ if (rv != 0)<br>
+ return -1;<br>
+<br>
+ return rv;<br>
+}<br>
+<br>
+size_t rtems_ofw_instance_to_path(<br>
+ ihandle_t instance,<br>
+ char *buf,<br>
+ size_t len<br>
+)<br>
+{<br>
+ int offset;<br>
+ int rv;<br>
+<br>
+ offset = rtems_ofw_instance_to_package(instance);<br>
+ offset = rtems_fdt_phandle_to_offset(offset);<br>
+<br>
+ rv = fdt_get_path(fdtp, offset, buf, len);<br>
+ if (rv != 0)<br>
+ return -1;<br>
+<br>
+ return rv;<br>
+}<br>
+<br>
+int rtems_ofw_get_reg(<br>
+ phandle_t node,<br>
+ rtems_ofw_memory_area *buf,<br>
+ size_t size<br>
+)<br>
+{<br>
+ int len;<br>
+ int offset;<br>
+ int nranges;<br>
+ int nregs;<br>
+ phandle_t parent;<br>
+ rtems_ofw_ranges range;<br>
+ const rtems_ofw_ranges *ptr;<br>
+<br>
+ len = rtems_ofw_get_enc_prop(node, "reg", (pcell_t *)buf, size);<br>
+ if (len <= 0) {<br>
+ return len;<br>
+ }<br>
+<br>
+ nregs = MIN(len, size) / sizeof(rtems_ofw_memory_area);<br>
+<br>
+ for (parent = rtems_ofw_parent(node); parent > 0;<br>
+ parent = rtems_ofw_parent(parent)) {<br>
+<br>
+ offset = rtems_fdt_phandle_to_offset(parent);<br>
+ ptr = fdt_getprop(fdtp, offset, "ranges", &len);<br>
+<br>
+ if (len < 0) {<br>
+ break;<br>
+ }<br>
+<br>
+ nranges = len / sizeof(rtems_ofw_ranges);<br>
+<br>
+ offset = 0;<br>
+ for (int i=0; i < nregs; i++) {<br>
+ for (int j=0; j < nranges; j++) {<br>
+ <br>
+ range.parent_bus = fdt32_to_cpu(ptr[j].parent_bus);<br>
+ range.child_bus = fdt32_to_cpu(ptr[j].child_bus);<br>
+ range.size = fdt32_to_cpu(ptr[j].size);<br>
+<br>
+ if (buf[i].start >= range.child_bus &&<br>
+ buf[i].start < range.child_bus + range.size) {<br>
+ offset = range.parent_bus - range.child_bus;<br>
+ break;<br>
+ }<br>
+<br>
+ }<br>
+ buf[i].start += offset;<br>
+ }<br>
+ }<br>
+<br>
+ return nregs;<br>
+}<br>
+<br>
+int rtems_ofw_get_interrupts(<br>
+ phandle_t node,<br>
+ rtems_vector_number *buf,<br>
+ size_t size<br>
+)<br>
+{<br>
+ int rv;<br>
+<br>
+ rv = rtems_ofw_get_enc_prop(node, "interrupts", buf, size);<br>
+<br>
+ if (rv <= 0) {<br>
+ return rv;<br>
+ }<br>
+<br>
+ return MIN(size, rv) / sizeof(rtems_vector_number);<br>
+}<br>
+<br>
+bool rtems_ofw_node_status( phandle_t node )<br>
+{<br>
+ int len;<br>
+ const char buf[10];<br>
+<br>
+ len = rtems_ofw_get_prop(node, "status", &buf[0], sizeof(buf));<br>
+ if ((len == -1) ||<br>
+ (strncmp(buf, "okay", MIN(5, len)) == 0) ||<br>
+ (strncmp(buf, "ok", MIN(3, len)) == 0)) {<br>
+ return true;<br>
+ }<br>
+<br>
+ return false;<br>
+}<br>
+<br>
+phandle_t rtems_ofw_find_device_by_compat( const char *compat )<br>
+{<br>
+ int offset;<br>
+<br>
+ offset = fdt_node_offset_by_compatible(fdtp, -1, compat);<br>
+ return rtems_fdt_offset_to_phandle(offset);<br>
+}<br>
diff --git a/spec/build/bsps/obj.yml b/spec/build/bsps/obj.yml<br>
index 8809238057..141ba25f5e 100644<br>
--- a/spec/build/bsps/obj.yml<br>
+++ b/spec/build/bsps/obj.yml<br>
@@ -24,6 +24,9 @@ install:<br>
- bsps/include/bsp/u-boot.h<br>
- bsps/include/bsp/uart-output-char.h<br>
- bsps/include/bsp/utility.h<br>
+- destination: ${BSP_INCLUDEDIR}/ofw<br>
+ source:<br>
+ - bsps/include/ofw/ofw.h<br>
- destination: ${BSP_INCLUDEDIR}/libchip<br>
source:<br>
- bsps/include/libchip/am29lv160.h<br>
@@ -104,4 +107,5 @@ source:<br>
- bsps/shared/dev/serial/z85c30_reg.c<br>
- bsps/shared/start/bootcard.c<br>
- bsps/shared/rtems-version.c<br>
+- bsps/shared/ofw/ofw.c<br>
type: build<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div></div>
</blockquote></div></div>