<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><div dir="ltr"><div dir="ltr"><div style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 14, 2020 at 5:48 PM Christian Mauderer <<a href="mailto:oss@c-mauderer.de" target="_blank">oss@c-mauderer.de</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"><br>
<br>
On 14/06/2020 13:37, Vijay Kumar Banerjee wrote:<br>
> On Sat, Jun 13, 2020 at 11:44 PM Niteesh G. S. <<a href="mailto:niteesh.gs@gmail.com" target="_blank">niteesh.gs@gmail.com</a>> wrote:<br>
>><br>
>><br>
>><br>
>> On Sat, Jun 13, 2020 at 6:30 PM Vijay Kumar Banerjee <<a href="mailto:vijay@rtems.org" target="_blank">vijay@rtems.org</a>> wrote:<br>
>>><br>
>>> On Thu, Jun 11, 2020 at 5:53 PM G S Niteesh Babu <<a href="mailto:niteesh.gs@gmail.com" target="_blank">niteesh.gs@gmail.com</a>> wrote:<br>
>>>><br>
>>>> The following files have been ported to RTEMS<br>
>>>> 1) openfirm.h<br>
>>>> 2) openfirm.c<br>
>>>> 3) ofw_fdt.c<br>
>>>> ---<br>
>>>> cpukit/libfreebsd/dev/ofw/ofw_fdt.c | 146 ++++++++++++++++++++++++++-<br>
>>>> cpukit/libfreebsd/dev/ofw/openfirm.c | 58 ++++++++++-<br>
>>>> cpukit/libfreebsd/dev/ofw/openfirm.h | 17 ++++<br>
>>>> 3 files changed, 219 insertions(+), 2 deletions(-)<br>
>>>><br>
>>>> diff --git a/cpukit/libfreebsd/dev/ofw/ofw_fdt.c b/cpukit/libfreebsd/dev/ofw/ofw_fdt.c<br>
>>>> index e4f72e8142..aba170d67a 100644<br>
>>>> --- a/cpukit/libfreebsd/dev/ofw/ofw_fdt.c<br>
>>>> +++ b/cpukit/libfreebsd/dev/ofw/ofw_fdt.c<br>
>>>> @@ -30,9 +30,12 @@<br>
>>>> */<br>
>>>><br>
>>>> #include <sys/cdefs.h><br>
>>>> +#ifndef __rtems__<br>
>>>> __FBSDID("$FreeBSD$");<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> #include <sys/param.h><br>
>>>> +#ifndef __rtems__<br>
>>>> #include <sys/kernel.h><br>
>>>> #include <sys/malloc.h><br>
>>>> #include <sys/systm.h><br>
>>>> @@ -45,9 +48,20 @@ __FBSDID("$FreeBSD$");<br>
>>>> #include <dev/ofw/ofwvar.h><br>
>>>> #include <dev/ofw/openfirm.h><br>
>>>> #include <dev/ofw/ofw_bus_subr.h><br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> #include "ofw_if.h"<br>
>>>><br>
>>>> +#ifdef __rtems__<br>
>>>> +#include <rtems.h><br>
>>>> +#include <rtems/sysinit.h><br>
>>>> +#include <bsp/fatal.h><br>
>>>> +#include <libfdt.h><br>
>>>> +#include <assert.h><br>
>>>> +#include "openfirm.h"<br>
>>>> +#endif /* __rtems__ */<br>
>>>> +<br>
>>>> +#ifndef __rtems__<br>
>>>> #ifdef DEBUG<br>
>>>> #define debugf(fmt, args...) do { printf("%s(): ", __func__); \<br>
>>>> printf(fmt,##args); } while (0)<br>
>>>> @@ -63,6 +77,7 @@ __FBSDID("$FreeBSD$");<br>
>>>> #define FDT_MARVELL<br>
>>>> #endif<br>
>>>> #endif<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> static int ofw_fdt_init(ofw_t, void *);<br>
>>>> static phandle_t ofw_fdt_peer(ofw_t, phandle_t);<br>
>>>> @@ -78,6 +93,7 @@ static ssize_t ofw_fdt_canon(ofw_t, const char *, char *, size_t);<br>
>>>> static phandle_t ofw_fdt_finddevice(ofw_t, const char *);<br>
>>>> static ssize_t ofw_fdt_instance_to_path(ofw_t, ihandle_t, char *, size_t);<br>
>>>> static ssize_t ofw_fdt_package_to_path(ofw_t, phandle_t, char *, size_t);<br>
>>>> +#ifndef __rtems__<br>
>>>> static int ofw_fdt_interpret(ofw_t, const char *, int, cell_t *);<br>
>>>><br>
>>>> static ofw_method_t ofw_fdt_methods[] = {<br>
>>>> @@ -104,9 +120,11 @@ static ofw_def_t ofw_fdt = {<br>
>>>> 0<br>
>>>> };<br>
>>>> OFW_DEF(ofw_fdt);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> static void *fdtp = NULL;<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> static int<br>
>>>> sysctl_handle_dtb(SYSCTL_HANDLER_ARGS)<br>
>>>> {<br>
>>>> @@ -127,6 +145,27 @@ sysctl_register_fdt_oid(void *arg)<br>
>>>> sysctl_handle_dtb, "", "Device Tree Blob");<br>
>>>> }<br>
>>>> SYSINIT(dtb_oid, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_fdt_oid, NULL);<br>
>>>> +#else /* __rtems__ */<br>
>>>> +const void* bsp_fdt_get(void);<br>
>>><br>
>>> Why is it declared here? The function declaration is in fdt.h which is<br>
>>> included in the libfdt.h<br>
>><br>
>><br>
>> We cannot include a BSP headers from cpukit.<br>
>><br>
> The definition of the function is in bsps/shared/start so we're<br>
> already using code from the bsps/ here. I wonder if this raises the<br>
> question of whether cpukit is the right location for this driver or if<br>
> we should use the bsps codes in this driver as a special case?<br>
<br>
I wondered about that too. That's why Niteesh moved it in an earlier<br>
patch set. I think Sebastian said that it would be better in cpukit.<br>
<br>
But I'm not that happy with the current solution either. That code<br>
wouldn't even link without the bsp_fdt_get function. Is there an<br>
alternative that we could use that would link?<br></blockquote><div> </div><div><div class="gmail_default" style="font-size:small">Hello Christian,</div><br></div><div><br></div><div><div class="gmail_default" style="font-size:small">Sebastian already suggested creating an API to register a device</div></div><div class="gmail_default" style="font-size:small">tree. The main goal of this was to allow unit testing. But then he</div><div class="gmail_default" style="font-size:small">mentioned about using wrapper functions to test.</div><div class="gmail_default" style="font-size:small"><a href="https://lists.rtems.org/pipermail/devel/2020-June/060025.html" target="_blank">https://lists.rtems.org/pipermail/devel/2020-June/060025.html</a><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I would like to get this patch to a state where this can be pushed</div><div class="gmail_default" style="font-size:small">without any changes. The upcoming patches are also libfreebsd</div><div class="gmail_default" style="font-size:small">related. If we could finalize this patch we can avoid some</div><div class="gmail_default" style="font-size:small">repetitive discussions and will also make it easier for me to create</div><div class="gmail_default" style="font-size:small">the next patches.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">These are the following points that need to be finalized</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">1) Where to place the header files? Should they be placed under</div><div class="gmail_default" style="font-size:small">cpukit/include/libfreebsd or can we add libfreebsd to the include path?</div><div class="gmail_default" style="font-size:small">The latter one will allow us to have same header structure as FreeBSD.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">2) How to handle BSP dependencies?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Thanks,</div><div class="gmail_default" style="font-size:small">Niteesh.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
>>><br>
>>>> +static void<br>
>>>> +ofw_init(void)<br>
>>>> +{<br>
>>>> + int rv;<br>
>>>> + const void *fdt;<br>
>>>> +<br>
>>>> + fdt = bsp_fdt_get();<br>
>>>> + rv = ofw_fdt_init(NULL, fdt);<br>
>>>> +<br>
>>>> + /* Fatal if invalid FDT is provided */<br>
>>>> + if (rv != 0)<br>
>>>> + bsp_fatal(LIBFREEBSD_FATAL_INVALID_FDT);<br>
>>>> +}<br>
>>>> +RTEMS_SYSINIT_ITEM(<br>
>>>> + ofw_init,<br>
>>>> + RTEMS_SYSINIT_BSP_START,<br>
>>>> + RTEMS_SYSINIT_ORDER_FIRST<br>
>>>> +);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> static int<br>
>>>> ofw_fdt_init(ofw_t ofw, void *data)<br>
>>>> @@ -297,7 +336,11 @@ ofw_fdt_getprop(ofw_t ofw, phandle_t package, const char *propname, void *buf,<br>
>>>> if (prop == NULL)<br>
>>>> return (-1);<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> bcopy(prop, buf, min(len, buflen));<br>
>>>> +#else /* __rtems__ */<br>
>>>> + memcpy(buf, prop, MIN(len, buflen));<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (len);<br>
>>>> }<br>
>>>> @@ -407,6 +450,7 @@ ofw_fdt_package_to_path(ofw_t ofw, phandle_t package, char *buf, size_t len)<br>
>>>> return (-1);<br>
>>>> }<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> #if defined(FDT_MARVELL)<br>
>>>> static int<br>
>>>> ofw_fdt_fixup(ofw_t ofw)<br>
>>>> @@ -476,4 +520,104 @@ ofw_fdt_interpret(ofw_t ofw, const char *cmd, int nret, cell_t *retvals)<br>
>>>> #else<br>
>>>> return (0);<br>
>>>> #endif<br>
>>>> -}<br>
>>>> \ No newline at end of file<br>
>>>> +}<br>
>>>> +#endif /* __rtems__ */<br>
>>>> +<br>
>>>> +#ifdef __rtems__<br>
>>>> +int<br>
>>>> +OFW_INIT(ofw_t ofw_obj, void *cookie)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_init(ofw_obj, cookie));<br>
>>>> +}<br>
>>>> +<br>
>>>> +phandle_t<br>
>>>> +OFW_PEER(ofw_t ofw_obj, phandle_t node)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_peer(ofw_obj, node));<br>
>>>> +}<br>
>>>> +<br>
>>>> +phandle_t<br>
>>>> +OFW_CHILD(ofw_t ofw_obj, phandle_t node)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_child(ofw_obj, node));<br>
>>>> +}<br>
>>>> +<br>
>>>> +phandle_t<br>
>>>> +OFW_PARENT(ofw_t ofw_obj, phandle_t node)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_parent(ofw_obj, node));<br>
>>>> +}<br>
>>>> +<br>
>>>> +phandle_t<br>
>>>> +OFW_INSTANCE_TO_PACKAGE(ofw_t ofw_obj, ihandle_t instance)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_instance_to_package(ofw_obj, instance));<br>
>>>> +}<br>
>>>> +<br>
>>>> +ssize_t<br>
>>>> +OFW_GETPROPLEN(ofw_t ofw_obj, phandle_t package, const char *propname)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_getproplen(ofw_obj, package, propname));<br>
>>>> +}<br>
>>>> +<br>
>>>> +ssize_t<br>
>>>> +OFW_GETPROP(ofw_t ofw_obj, phandle_t package, const char *propname,<br>
>>>> + void *buf, size_t buflen<br>
>>>> +)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_getprop(ofw_obj, package, propname, buf, buflen));<br>
>>>> +}<br>
>>>> +<br>
>>>> +int<br>
>>>> +OFW_NEXTPROP(ofw_t ofw_obj, phandle_t package, const char *prev, char *buf,<br>
>>>> + size_t size)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_nextprop(ofw_obj, package, prev, buf, size));<br>
>>>> +}<br>
>>>> +<br>
>>>> +int<br>
>>>> +OFW_SETPROP(ofw_t ofw_obj, phandle_t package, const char *propname,<br>
>>>> + const void *buf, size_t len)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_setprop(ofw_obj, package, propname, buf, len));<br>
>>>> +}<br>
>>>> +<br>
>>>> +ssize_t<br>
>>>> +OFW_CANON(ofw_t ofw_obj, const char *device, char *buf, size_t len)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_canon(ofw_obj, device, buf, len));<br>
>>>> +}<br>
>>>> +<br>
>>>> +phandle_t<br>
>>>> +OFW_FINDDEVICE(ofw_t ofw_obj, const char *device)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_finddevice(ofw_obj, device));<br>
>>>> +}<br>
>>>> +<br>
>>>> +ssize_t<br>
>>>> +OFW_INSTANCE_TO_PATH(ofw_t ofw_obj, ihandle_t instance, char *buf,<br>
>>>> + size_t len)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_instance_to_path(ofw_obj, instance, buf, len));<br>
>>>> +}<br>
>>>> +<br>
>>>> +ssize_t<br>
>>>> +OFW_PACKAGE_TO_PATH(ofw_t ofw_obj, phandle_t package, char *buf,<br>
>>>> + size_t len)<br>
>>>> +{<br>
>>>> +<br>
>>>> + return (ofw_fdt_package_to_path(ofw_obj, package, buf, len));<br>
>>>> +}<br>
>>>> +#endif /* __rtems__ */<br>
>>>> \ No newline at end of file<br>
>>>> diff --git a/cpukit/libfreebsd/dev/ofw/openfirm.c b/cpukit/libfreebsd/dev/ofw/openfirm.c<br>
>>>> index 50ebf2cf16..e7a67cfd34 100644<br>
>>>> --- a/cpukit/libfreebsd/dev/ofw/openfirm.c<br>
>>>> +++ b/cpukit/libfreebsd/dev/ofw/openfirm.c<br>
>>>> @@ -58,26 +58,37 @@<br>
>>>> */<br>
>>>><br>
>>>> #include <sys/cdefs.h><br>
>>>> +#ifndef __rtems__<br>
>>>> __FBSDID("$FreeBSD$");<br>
>>>><br>
>>>> #include "opt_platform.h"<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> #include <sys/param.h><br>
>>>> +#ifndef __rtems__<br>
>>>> #include <sys/kernel.h><br>
>>>> #include <sys/lock.h><br>
>>>> #include <sys/malloc.h><br>
>>>> #include <sys/mutex.h><br>
>>>> #include <sys/queue.h><br>
>>>> #include <sys/systm.h><br>
>>>> +#endif /* __rtems__ */<br>
>>>> #include <sys/endian.h><br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> #include <machine/stdarg.h><br>
>>>><br>
>>>> #include <dev/ofw/ofwvar.h><br>
>>>> #include <dev/ofw/openfirm.h><br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> #include "ofw_if.h"<br>
>>>> +#ifdef __rtems__<br>
>>>> +#include "openfirm.h"<br>
>>>> +#include "../../rtems-freebsd-helper.h"<br>
>>><br>
>>> Can we add the file rtems-freebsd-helper.h in somewhere like<br>
>>> libfreebsd/include and install this header file? This will avoid<br>
>>> future confusions with the number of dots required and we can have<br>
>>> something like <libfreebsd/rtems-freebsd-helper.h><br>
>><br>
>><br>
>> We still haven't decided where to place the FreeBSD header files.<br>
>> Once we decide upon this I'll move it and change all references.<br>
>> Since we have also planned to move all FreeBSD sources under<br>
>> libfreebsd/freebsd this patch is not valid anymore.<br>
>> But the code will remain the same so we can use this to discuss<br>
>> changes but it is not valid for pushing.<br>
>><br>
> Ok. Thanks for the note. libfreebsd/freebsd sounds like an approach<br>
> similar to libbsd so it should be OK.<br>
> We can write a post to the devel regarding the plan so that we can get<br>
> ideas from the devel as well. This will make it easier to merge it<br>
> later as the plan will be understood by everyone beforehand.<br>
> <br>
> <br>
> Best regards,<br>
> Vijay<br>
>><br>
>>><br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> static void OF_putchar(int c, void *arg);<br>
>>>><br>
>>>> MALLOC_DEFINE(M_OFWPROP, "openfirm", "Open Firmware properties");<br>
>>>> @@ -85,7 +96,9 @@ MALLOC_DEFINE(M_OFWPROP, "openfirm", "Open Firmware properties");<br>
>>>> static ihandle_t stdout;<br>
>>>><br>
>>>> static ofw_def_t *ofw_def_impl = NULL;<br>
>>>> +#endif /* __rtems__ */<br>
>>>> static ofw_t ofw_obj;<br>
>>>> +#ifndef __rtems__<br>
>>>> static struct ofw_kobj ofw_kernel_obj;<br>
>>>> static struct kobj_ops ofw_kernel_kops;<br>
>>>><br>
>>>> @@ -224,14 +237,18 @@ OF_install(char *name, int prio)<br>
>>>><br>
>>>> return (FALSE);<br>
>>>> }<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> /* Initializer */<br>
>>>> int<br>
>>>> OF_init(void *cookie)<br>
>>>> {<br>
>>>> +#ifndef __rtems__<br>
>>>> phandle_t chosen;<br>
>>>> +#endif /* __rtems__ */<br>
>>>> int rv;<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (-1);<br>
>>>><br>
>>>> @@ -242,17 +259,21 @@ OF_init(void *cookie)<br>
>>>> */<br>
>>>> kobj_class_compile_static(ofw_def_impl, &ofw_kernel_kops);<br>
>>>> kobj_init_static((kobj_t)ofw_obj, ofw_def_impl);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> rv = OFW_INIT(ofw_obj, cookie);<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if ((chosen = OF_finddevice("/chosen")) != -1)<br>
>>>> if (OF_getencprop(chosen, "stdout", &stdout,<br>
>>>> sizeof(stdout)) == -1)<br>
>>>> stdout = -1;<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (rv);<br>
>>>> }<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> static void<br>
>>>> OF_putchar(int c, void *arg __unused)<br>
>>>> {<br>
>>>> @@ -314,6 +335,7 @@ OF_interpret(const char *cmd, int nreturns, ...)<br>
>>>><br>
>>>> return (status);<br>
>>>> }<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> /*<br>
>>>> * Device tree functions<br>
>>>> @@ -324,8 +346,10 @@ phandle_t<br>
>>>> OF_peer(phandle_t node)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (0);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_PEER(ofw_obj, node));<br>
>>>> }<br>
>>>> @@ -335,8 +359,10 @@ phandle_t<br>
>>>> OF_child(phandle_t node)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (0);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_CHILD(ofw_obj, node));<br>
>>>> }<br>
>>>> @@ -346,8 +372,10 @@ phandle_t<br>
>>>> OF_parent(phandle_t node)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (0);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_PARENT(ofw_obj, node));<br>
>>>> }<br>
>>>> @@ -357,8 +385,10 @@ phandle_t<br>
>>>> OF_instance_to_package(ihandle_t instance)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (-1);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_INSTANCE_TO_PACKAGE(ofw_obj, instance));<br>
>>>> }<br>
>>>> @@ -368,8 +398,10 @@ ssize_t<br>
>>>> OF_getproplen(phandle_t package, const char *propname)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (-1);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_GETPROPLEN(ofw_obj, package, propname));<br>
>>>> }<br>
>>>> @@ -387,8 +419,10 @@ ssize_t<br>
>>>> OF_getprop(phandle_t package, const char *propname, void *buf, size_t buflen)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (-1);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_GETPROP(ofw_obj, package, propname, buf, buflen));<br>
>>>> }<br>
>>>> @@ -532,8 +566,10 @@ int<br>
>>>> OF_nextprop(phandle_t package, const char *previous, char *buf, size_t size)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (-1);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_NEXTPROP(ofw_obj, package, previous, buf, size));<br>
>>>> }<br>
>>>> @@ -543,8 +579,10 @@ int<br>
>>>> OF_setprop(phandle_t package, const char *propname, const void *buf, size_t len)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (-1);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_SETPROP(ofw_obj, package, propname, buf,len));<br>
>>>> }<br>
>>>> @@ -554,8 +592,10 @@ ssize_t<br>
>>>> OF_canon(const char *device, char *buf, size_t len)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (-1);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_CANON(ofw_obj, device, buf, len));<br>
>>>> }<br>
>>>> @@ -565,8 +605,10 @@ phandle_t<br>
>>>> OF_finddevice(const char *device)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (-1);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_FINDDEVICE(ofw_obj, device));<br>
>>>> }<br>
>>>> @@ -576,8 +618,10 @@ ssize_t<br>
>>>> OF_instance_to_path(ihandle_t instance, char *buf, size_t len)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (-1);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_INSTANCE_TO_PATH(ofw_obj, instance, buf, len));<br>
>>>> }<br>
>>>> @@ -587,8 +631,10 @@ ssize_t<br>
>>>> OF_package_to_path(phandle_t package, char *buf, size_t len)<br>
>>>> {<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (ofw_def_impl == NULL)<br>
>>>> return (-1);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> return (OFW_PACKAGE_TO_PATH(ofw_obj, package, buf, len));<br>
>>>> }<br>
>>>> @@ -626,14 +672,18 @@ OF_child_xref_phandle(phandle_t parent, phandle_t xref)<br>
>>>> phandle_t<br>
>>>> OF_node_from_xref(phandle_t xref)<br>
>>>> {<br>
>>>> +#ifndef __rtems__<br>
>>>> struct xrefinfo *xi;<br>
>>>> +#endif /* __rtems__ */<br>
>>>> phandle_t node;<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (xref_init_done) {<br>
>>>> if ((xi = xrefinfo_find(xref, FIND_BY_XREF)) == NULL)<br>
>>>> return (xref);<br>
>>>> return (xi->node);<br>
>>>> }<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> if ((node = OF_child_xref_phandle(OF_peer(0), xref)) == -1)<br>
>>>> return (xref);<br>
>>>> @@ -643,14 +693,18 @@ OF_node_from_xref(phandle_t xref)<br>
>>>> phandle_t<br>
>>>> OF_xref_from_node(phandle_t node)<br>
>>>> {<br>
>>>> +#ifndef __rtems__<br>
>>>> struct xrefinfo *xi;<br>
>>>> +#endif /* __rtems__ */<br>
>>>> phandle_t xref;<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> if (xref_init_done) {<br>
>>>> if ((xi = xrefinfo_find(node, FIND_BY_NODE)) == NULL)<br>
>>>> return (node);<br>
>>>> return (xi->xref);<br>
>>>> }<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> if (OF_getencprop(node, "phandle", &xref, sizeof(xref)) == -1 &&<br>
>>>> OF_getencprop(node, "ibm,phandle", &xref, sizeof(xref)) == -1 &&<br>
>>>> @@ -659,6 +713,7 @@ OF_xref_from_node(phandle_t node)<br>
>>>> return (xref);<br>
>>>> }<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> device_t<br>
>>>> OF_device_from_xref(phandle_t xref)<br>
>>>> {<br>
>>>> @@ -845,4 +900,5 @@ OF_exit()<br>
>>>><br>
>>>> for (;;) /* just in case */<br>
>>>> ;<br>
>>>> -}<br>
>>>> \ No newline at end of file<br>
>>>> +}<br>
>>>> +#endif /* __rtems__ */<br>
>>>> \ No newline at end of file<br>
>>>> diff --git a/cpukit/libfreebsd/dev/ofw/openfirm.h b/cpukit/libfreebsd/dev/ofw/openfirm.h<br>
>>>> index 74a7075367..b4f6bf292a 100644<br>
>>>> --- a/cpukit/libfreebsd/dev/ofw/openfirm.h<br>
>>>> +++ b/cpukit/libfreebsd/dev/ofw/openfirm.h<br>
>>>> @@ -63,7 +63,12 @@<br>
>>>> #define _DEV_OPENFIRM_H_<br>
>>>><br>
>>>> #include <sys/types.h><br>
>>>> +#ifndef __rtems__<br>
>>>> #include <machine/_bus.h><br>
>>>> +#else /* __rtems__ */<br>
>>>> +#include <rtems.h><br>
>>>> +#include "../../rtems-freebsd-helper.h"<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> /*<br>
>>>> * Prototypes for Open Firmware Interface Routines<br>
>>>> @@ -73,7 +78,12 @@ typedef uint32_t ihandle_t;<br>
>>>> typedef uint32_t phandle_t;<br>
>>>> typedef uint32_t pcell_t;<br>
>>>><br>
>>>> +#ifdef __rtems__<br>
>>>> +typedef uint32_t cell_t;<br>
>>>> +#endif /* __rtems__ */<br>
>>>> +<br>
>>>> #ifdef _KERNEL<br>
>>>> +#ifndef __rtems__<br>
>>>> #include <sys/malloc.h><br>
>>>><br>
>>>> #include <machine/ofw_machdep.h><br>
>>>> @@ -86,8 +96,10 @@ MALLOC_DECLARE(M_OFWPROP);<br>
>>>> */<br>
>>>><br>
>>>> boolean_t OF_install(char *name, int prio);<br>
>>>> +#endif /* __rtems__*/<br>
>>>> int OF_init(void *cookie);<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> /*<br>
>>>> * Known Open Firmware interface names<br>
>>>> */<br>
>>>> @@ -100,6 +112,7 @@ int OF_init(void *cookie);<br>
>>>> /* Generic functions */<br>
>>>> int OF_test(const char *name);<br>
>>>> void OF_printf(const char *fmt, ...);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> /* Device tree functions */<br>
>>>> phandle_t OF_peer(phandle_t node);<br>
>>>> @@ -141,6 +154,7 @@ ssize_t OF_package_to_path(phandle_t node, char *buf, size_t len);<br>
>>>> phandle_t OF_node_from_xref(phandle_t xref);<br>
>>>> phandle_t OF_xref_from_node(phandle_t node);<br>
>>>><br>
>>>> +#ifndef __rtems__<br>
>>>> /*<br>
>>>> * When properties contain references to other nodes using xref handles it is<br>
>>>> * often necessary to use interfaces provided by the driver for the referenced<br>
>>>> @@ -158,9 +172,11 @@ void OF_close(ihandle_t instance);<br>
>>>> ssize_t OF_read(ihandle_t instance, void *buf, size_t len);<br>
>>>> ssize_t OF_write(ihandle_t instance, const void *buf, size_t len);<br>
>>>> int OF_seek(ihandle_t instance, uint64_t where);<br>
>>>> +#endif /* __rtems__ */<br>
>>>><br>
>>>> phandle_t OF_instance_to_package(ihandle_t instance);<br>
>>>> ssize_t OF_instance_to_path(ihandle_t instance, char *buf, size_t len);<br>
>>>> +#ifndef __rtems__<br>
>>>> int OF_call_method(const char *method, ihandle_t instance,<br>
>>>> int nargs, int nreturns, ...);<br>
>>>><br>
>>>> @@ -183,5 +199,6 @@ int OF_interpret(const char *cmd, int nreturns, ...);<br>
>>>> int OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *ptag,<br>
>>>> bus_space_handle_t *phandle, bus_size_t *sz);<br>
>>>><br>
>>>> +#endif /* __rtems__ */<br>
>>>> #endif /* _KERNEL */<br>
>>>> #endif /* _DEV_OPENFIRM_H_ */<br>
>>>> \ No newline at end of file<br>
>>>> --<br>
>>>> 2.17.1<br>
>>>><br>
> <br>
</blockquote></div></div>
</div>