[PATCH] mips fenv support

2020-06-11 Thread Eshan dhawan
This Patch adds fenv support for mips

The implementation files are taken from FreeBSD

Signed-off-by: Eshan dhawan 
---
 newlib/configure.host |   1 +
 newlib/libc/machine/mips/machine/fenv-fp.h| 207 ++
 .../machine/mips/machine/fenv-softfloat.h | 182 +++
 newlib/libc/machine/mips/sys/fenv.h   |  88 
 newlib/libm/machine/configure.in  |   1 +
 newlib/libm/machine/mips/Makefile.am  |  21 ++
 newlib/libm/machine/mips/configure.in |  11 +
 newlib/libm/machine/mips/feclearexcept.c  |   7 +
 newlib/libm/machine/mips/fegetenv.c   |   7 +
 newlib/libm/machine/mips/fegetexceptflag.c|   7 +
 newlib/libm/machine/mips/fegetround.c |   7 +
 newlib/libm/machine/mips/feholdexcept.c   |   7 +
 newlib/libm/machine/mips/fenv.c   |  74 +++
 newlib/libm/machine/mips/feraiseexcept.c  |   7 +
 newlib/libm/machine/mips/fesetenv.c   |   7 +
 newlib/libm/machine/mips/fesetexceptflag.c|   7 +
 newlib/libm/machine/mips/fesetround.c |   7 +
 newlib/libm/machine/mips/fetestexcept.c   |   7 +
 newlib/libm/machine/mips/feupdateenv.c|   7 +
 19 files changed, 662 insertions(+)
 create mode 100644 newlib/libc/machine/mips/machine/fenv-fp.h
 create mode 100644 newlib/libc/machine/mips/machine/fenv-softfloat.h
 create mode 100644 newlib/libc/machine/mips/sys/fenv.h
 create mode 100644 newlib/libm/machine/mips/Makefile.am
 create mode 100644 newlib/libm/machine/mips/configure.in
 create mode 100644 newlib/libm/machine/mips/feclearexcept.c
 create mode 100644 newlib/libm/machine/mips/fegetenv.c
 create mode 100644 newlib/libm/machine/mips/fegetexceptflag.c
 create mode 100644 newlib/libm/machine/mips/fegetround.c
 create mode 100644 newlib/libm/machine/mips/feholdexcept.c
 create mode 100644 newlib/libm/machine/mips/fenv.c
 create mode 100644 newlib/libm/machine/mips/feraiseexcept.c
 create mode 100644 newlib/libm/machine/mips/fesetenv.c
 create mode 100644 newlib/libm/machine/mips/fesetexceptflag.c
 create mode 100644 newlib/libm/machine/mips/fesetround.c
 create mode 100644 newlib/libm/machine/mips/fetestexcept.c
 create mode 100644 newlib/libm/machine/mips/feupdateenv.c

diff --git a/newlib/configure.host b/newlib/configure.host
index a84c0c80a..dc6cff1aa 100644
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -246,6 +246,7 @@ case "${host_cpu}" in
machine_dir=mep
;;
   mips*)
+   libm_machine_dir=mips
machine_dir=mips
;;
   mmix)
diff --git a/newlib/libc/machine/mips/machine/fenv-fp.h 
b/newlib/libc/machine/mips/machine/fenv-fp.h
new file mode 100644
index 0..5f446e395
--- /dev/null
+++ b/newlib/libc/machine/mips/machine/fenv-fp.h
@@ -0,0 +1,207 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2004-2005 David Schultz 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+__fenv_static inline int
+feclearexcept(int excepts)
+{
+   fexcept_t fcsr;
+
+   excepts &= FE_ALL_EXCEPT;
+   __cfc1(fcsr);
+   fcsr &= ~(excepts | (excepts << _FCSR_CAUSE_SHIFT));
+   __ctc1(fcsr);
+
+   return (0);
+}
+
+__fenv_static inline int
+fegetexceptflag(fexcept_t *flagp, int excepts)
+{
+   fexcept_t fcsr;
+
+   excepts &= FE_ALL_EXCEPT;
+   __cfc1(fcsr);
+   *flagp = fcsr & excepts;
+
+   return (0);
+}
+
+__fenv_static inline int
+fesetexceptflag(const fexcept_t *flagp, int excepts)
+{
+   fexcept_t fcsr;
+
+   excepts &= FE_ALL_EXCEPT;
+   __cfc1(fcsr);
+   fcsr &= ~excepts;
+   fcsr |= *flagp & excepts;
+   __ctc1(fcsr);
+
+   return (0);

[PATCH] Corrected spelling-mistakes

2020-06-11 Thread Richi Dubey
---
 c-user/chains.rst | 46 +++---
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/c-user/chains.rst b/c-user/chains.rst
index 0dce1d9..8350fc4 100644
--- a/c-user/chains.rst
+++ b/c-user/chains.rst
@@ -28,11 +28,11 @@ includes wait queues and task queues. The Chains API 
provided by RTEMS is:
 
 - rtems_chain_is_empty_ - Is the chain empty ?
 
-- rtems_chain_is_first_ - Is the Node the first in the chain ?
+- rtems_chain_is_first_ - Is the node the first in the chain ?
 
-- rtems_chain_is_last_ - Is the Node the last in the chain ?
+- rtems_chain_is_last_ - Is the node the last in the chain ?
 
-- rtems_chain_has_only_one_node_ - Does the node have one node ?
+- rtems_chain_has_only_one_node_ - Does the chain have only one node ?
 
 - rtems_chain_node_count_unprotected_ - Returns the node count of the chain 
(unprotected)
 
@@ -52,22 +52,22 @@ includes wait queues and task queues. The Chains API 
provided by RTEMS is:
 
 - rtems_chain_insert_unprotected_ - Insert the node into the chain 
(unprotected)
 
-- rtems_chain_append_ - Append the node to chain
+- rtems_chain_append_ - Append the node to the chain
 
-- rtems_chain_append_unprotected_ - Append the node to chain (unprotected)
+- rtems_chain_append_unprotected_ - Append the node to the chain (unprotected)
 
 - rtems_chain_prepend_ - Prepend the node to the end of the chain
 
-- rtems_chain_prepend_unprotected_ - Prepend the node to chain (unprotected)
+- rtems_chain_prepend_unprotected_ - Prepend the node to the chain 
(unprotected)
 
 Background
 ==
 
 The Chains API maps to the Super Core Chains API. Chains are implemented as a
-double linked list of nodes anchored to a control node. The list starts at the
+doubly linked list of nodes anchored to a control node. The list starts at the
 control node and is terminated at the control node. A node has previous and
-next pointers. Being a double linked list nodes can be inserted and removed
-without the need to travse the chain.
+next pointers. Being a doubly linked list nodes can be inserted and removed
+without the need to traverse the chain.
 
 Chains have a small memory footprint and can be used in interrupt service
 routines and are thread safe in a multi-threaded environment. The directives
@@ -78,7 +78,7 @@ Chains are very useful in Board Support packages and 
applications.
 Nodes
 -
 
-A chain is made up from nodes that orginate from a chain control object. A node
+A chain is made up from nodes that originate from a chain control object. A 
node
 is of type ``rtems_chain_node``. The node is designed to be part of a user data
 structure and a cast is used to move from the node address to the user data
 structure address. For example:
@@ -102,7 +102,7 @@ from the list you perform the following:
 }
 
 The node is placed at the start of the user's structure to allow the node
-address on the chain to be easly cast to the user's structure address.
+address on the chain to be easily cast to the user's structure address.
 
 Controls
 
@@ -132,8 +132,8 @@ Multi-threading
 
 Chains are designed to be used in a multi-threading environment. The directives
 list which operations mask interrupts. Chains supports tasks and interrupt
-service routines appending and extracting nodes with out the need for extra
-locks. Chains how-ever cannot insure the integrity of a chain for all
+service routines appending and extracting nodes without the need for extra
+locks. Chains how-ever cannot ensure the integrity of a chain for all
 operations. This is the responsibility of the user. For example an interrupt
 service routine extracting nodes while a task is iterating over the chain can
 have unpredictable results.
@@ -178,7 +178,7 @@ Iterating a Chain
 
 Iterating a chain is a common function. The example shows how to iterate the
 buffer pool chain created in the last section to find buffers starting with a
-specific string. If the buffer is located it is extracted from the chain and
+specific string. If the buffer is located, it is extracted from the chain and
 placed on another chain:
 
 .. code-block:: c
@@ -209,9 +209,9 @@ placed on another chain:
 Directives
 ==
 
-The section details the Chains directives.
+The section details the chains directives.
 
-.. COMMENT: Initialize this Chain With Nodes
+.. COMMENT: Initialize this Chain with Nodes
 
 .. raw:: latex
 
@@ -239,15 +239,15 @@ RETURNS:
 Returns nothing.
 
 DESCRIPTION:
-This function take in a pointer to a chain control and initializes it to
+This function takes in a pointer to a chain control and initializes it to
 contain a set of chain nodes.  The chain will contain ``number_nodes``
-chain nodes from the memory pointed to by ``start_address``.  Each node is
+chain nodes from memory pointed to by ``start_address``.  Each node is
 assumed to be ``node_size`` bytes.
 
 NOTES:
 This call will discard any nodes on the chain.
 
-This 

[PATCH RTEMS v2 1/6] libfreebsd: Import OFW files from FreeBSD.

2020-06-11 Thread G S Niteesh Babu
freebsd head: b8c57b4

The following files have been imported from FreeBSD to implement
OF_* functions into RTEMS.
1) openfirm.h
2) openfirm.c
3) ofw_fdt.c
---
 cpukit/libfreebsd/dev/ofw/ofw_fdt.c  | 479 +++
 cpukit/libfreebsd/dev/ofw/openfirm.c | 848 +++
 cpukit/libfreebsd/dev/ofw/openfirm.h | 187 ++
 3 files changed, 1514 insertions(+)
 create mode 100644 cpukit/libfreebsd/dev/ofw/ofw_fdt.c
 create mode 100644 cpukit/libfreebsd/dev/ofw/openfirm.c
 create mode 100644 cpukit/libfreebsd/dev/ofw/openfirm.h

diff --git a/cpukit/libfreebsd/dev/ofw/ofw_fdt.c 
b/cpukit/libfreebsd/dev/ofw/ofw_fdt.c
new file mode 100644
index 00..e4f72e8142
--- /dev/null
+++ b/cpukit/libfreebsd/dev/ofw/ofw_fdt.c
@@ -0,0 +1,479 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2009-2010 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under sponsorship from
+ * the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "ofw_if.h"
+
+#ifdef DEBUG
+#define debugf(fmt, args...) do { printf("%s(): ", __func__);  \
+printf(fmt,##args); } while (0)
+#else
+#define debugf(fmt, args...)
+#endif
+
+#if defined(__arm__)
+#if defined(SOC_MV_ARMADAXP) || defined(SOC_MV_ARMADA38X) || \
+defined(SOC_MV_DISCOVERY) || defined(SOC_MV_DOVE) || \
+defined(SOC_MV_FREY) || defined(SOC_MV_KIRKWOOD) || \
+defined(SOC_MV_LOKIPLUS) || defined(SOC_MV_ORION)
+#define FDT_MARVELL
+#endif
+#endif
+
+static int ofw_fdt_init(ofw_t, void *);
+static phandle_t ofw_fdt_peer(ofw_t, phandle_t);
+static phandle_t ofw_fdt_child(ofw_t, phandle_t);
+static phandle_t ofw_fdt_parent(ofw_t, phandle_t);
+static phandle_t ofw_fdt_instance_to_package(ofw_t, ihandle_t);
+static ssize_t ofw_fdt_getproplen(ofw_t, phandle_t, const char *);
+static ssize_t ofw_fdt_getprop(ofw_t, phandle_t, const char *, void *, size_t);
+static int ofw_fdt_nextprop(ofw_t, phandle_t, const char *, char *, size_t);
+static int ofw_fdt_setprop(ofw_t, phandle_t, const char *, const void *,
+size_t);
+static ssize_t ofw_fdt_canon(ofw_t, const char *, char *, size_t);
+static phandle_t ofw_fdt_finddevice(ofw_t, const char *);
+static ssize_t ofw_fdt_instance_to_path(ofw_t, ihandle_t, char *, size_t);
+static ssize_t ofw_fdt_package_to_path(ofw_t, phandle_t, char *, size_t);
+static int ofw_fdt_interpret(ofw_t, const char *, int, cell_t *);
+
+static ofw_method_t ofw_fdt_methods[] = {
+   OFWMETHOD(ofw_init, ofw_fdt_init),
+   OFWMETHOD(ofw_peer, ofw_fdt_peer),
+   OFWMETHOD(ofw_child,ofw_fdt_child),
+   OFWMETHOD(ofw_parent,   ofw_fdt_parent),
+   OFWMETHOD(ofw_instance_to_package,  ofw_fdt_instance_to_package),
+   OFWMETHOD(ofw_getproplen,   ofw_fdt_getproplen),
+   OFWMETHOD(ofw_getprop,  ofw_fdt_getprop),
+   OFWMETHOD(ofw_nextprop, ofw_fdt_nextprop),
+   OFWMETHOD(ofw_setprop,  ofw_fdt_setprop),
+   OFWMETHOD(ofw_canon,ofw_fdt_canon),
+   OFWMETHOD(ofw_finddevice,   ofw_fdt_finddevice),
+   OFWMETHOD(ofw_instance_to_path, ofw_fdt_instance_to_path),
+   OFWMETHOD(ofw_package_to_path,  ofw_fdt_package_to_path),
+   OFWMETHOD(ofw_interpret,ofw_fdt_interpret),
+   { 0, 0 }
+};
+
+static ofw_def_t ofw_fdt = {
+   OFW_FDT,
+   ofw_fdt_methods,
+   0
+};
+OFW_DEF(ofw_fdt);
+

[PATCH RTEMS v2 6/6] cpukit/Makefile: Add libfreebsd source files.

2020-06-11 Thread G S Niteesh Babu
---
 cpukit/Makefile.am | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index 51f38c84c7..1335d41038 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -342,6 +342,8 @@ librtemscpu_a_SOURCES += libmisc/uuid/uuid_time.c
 librtemscpu_a_SOURCES += libmisc/xz/xz_crc32.c
 librtemscpu_a_SOURCES += libmisc/xz/xz_dec_lzma2.c
 librtemscpu_a_SOURCES += libmisc/xz/xz_dec_stream.c
+librtemscpu_a_SOURCES += libfreebsd/dev/ofw/ofw_fdt.c
+librtemscpu_a_SOURCES += libfreebsd/dev/ofw/openfirm.c
 librtemscpu_a_SOURCES += libfs/src/defaults/default_are_nodes_equal.c
 librtemscpu_a_SOURCES += libfs/src/defaults/default_chown.c
 librtemscpu_a_SOURCES += libfs/src/defaults/default_clone.c
-- 
2.17.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH RTEMS v2 5/6] libfreebsd: Port OFW to RTEMS

2020-06-11 Thread G S Niteesh Babu
The following files have been ported to RTEMS
1) openfirm.h
2) openfirm.c
3) ofw_fdt.c
---
 cpukit/libfreebsd/dev/ofw/ofw_fdt.c  | 146 ++-
 cpukit/libfreebsd/dev/ofw/openfirm.c |  58 ++-
 cpukit/libfreebsd/dev/ofw/openfirm.h |  17 
 3 files changed, 219 insertions(+), 2 deletions(-)

diff --git a/cpukit/libfreebsd/dev/ofw/ofw_fdt.c 
b/cpukit/libfreebsd/dev/ofw/ofw_fdt.c
index e4f72e8142..aba170d67a 100644
--- a/cpukit/libfreebsd/dev/ofw/ofw_fdt.c
+++ b/cpukit/libfreebsd/dev/ofw/ofw_fdt.c
@@ -30,9 +30,12 @@
  */
 
 #include 
+#ifndef __rtems__
 __FBSDID("$FreeBSD$");
+#endif /* __rtems__ */
 
 #include 
+#ifndef __rtems__
 #include 
 #include 
 #include 
@@ -45,9 +48,20 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#endif /* __rtems__ */
 
 #include "ofw_if.h"
 
+#ifdef __rtems__
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "openfirm.h"
+#endif /* __rtems__ */
+
+#ifndef __rtems__
 #ifdef DEBUG
 #define debugf(fmt, args...) do { printf("%s(): ", __func__);  \
 printf(fmt,##args); } while (0)
@@ -63,6 +77,7 @@ __FBSDID("$FreeBSD$");
 #define FDT_MARVELL
 #endif
 #endif
+#endif /* __rtems__ */
 
 static int ofw_fdt_init(ofw_t, void *);
 static phandle_t ofw_fdt_peer(ofw_t, phandle_t);
@@ -78,6 +93,7 @@ static ssize_t ofw_fdt_canon(ofw_t, const char *, char *, 
size_t);
 static phandle_t ofw_fdt_finddevice(ofw_t, const char *);
 static ssize_t ofw_fdt_instance_to_path(ofw_t, ihandle_t, char *, size_t);
 static ssize_t ofw_fdt_package_to_path(ofw_t, phandle_t, char *, size_t);
+#ifndef __rtems__
 static int ofw_fdt_interpret(ofw_t, const char *, int, cell_t *);
 
 static ofw_method_t ofw_fdt_methods[] = {
@@ -104,9 +120,11 @@ static ofw_def_t ofw_fdt = {
0
 };
 OFW_DEF(ofw_fdt);
+#endif /* __rtems__ */
 
 static void *fdtp = NULL;
 
+#ifndef __rtems__
 static int
 sysctl_handle_dtb(SYSCTL_HANDLER_ARGS)
 {
@@ -127,6 +145,27 @@ sysctl_register_fdt_oid(void *arg)
sysctl_handle_dtb, "", "Device Tree Blob");
 }
 SYSINIT(dtb_oid, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_fdt_oid, NULL);
+#else /* __rtems__ */
+const void* bsp_fdt_get(void);
+static void
+ofw_init(void)
+{
+   int rv;
+   const void *fdt;
+
+   fdt = bsp_fdt_get();
+   rv = ofw_fdt_init(NULL, fdt);
+
+   /* Fatal if invalid FDT is provided */
+   if (rv != 0)
+   bsp_fatal(LIBFREEBSD_FATAL_INVALID_FDT);
+}
+RTEMS_SYSINIT_ITEM(
+   ofw_init,
+   RTEMS_SYSINIT_BSP_START,
+   RTEMS_SYSINIT_ORDER_FIRST
+);
+#endif /* __rtems__ */
 
 static int
 ofw_fdt_init(ofw_t ofw, void *data)
@@ -297,7 +336,11 @@ ofw_fdt_getprop(ofw_t ofw, phandle_t package, const char 
*propname, void *buf,
if (prop == NULL)
return (-1);
 
+#ifndef __rtems__
bcopy(prop, buf, min(len, buflen));
+#else /* __rtems__ */
+   memcpy(buf, prop, MIN(len, buflen));
+#endif /* __rtems__ */
 
return (len);
 }
@@ -407,6 +450,7 @@ ofw_fdt_package_to_path(ofw_t ofw, phandle_t package, char 
*buf, size_t len)
return (-1);
 }
 
+#ifndef __rtems__
 #if defined(FDT_MARVELL)
 static int
 ofw_fdt_fixup(ofw_t ofw)
@@ -476,4 +520,104 @@ ofw_fdt_interpret(ofw_t ofw, const char *cmd, int nret, 
cell_t *retvals)
 #else
return (0);
 #endif
-}
\ No newline at end of file
+}
+#endif /* __rtems__ */
+
+#ifdef __rtems__
+int
+OFW_INIT(ofw_t ofw_obj, void *cookie)
+{
+
+   return (ofw_fdt_init(ofw_obj, cookie));
+}
+
+phandle_t
+OFW_PEER(ofw_t ofw_obj, phandle_t node)
+{
+
+   return (ofw_fdt_peer(ofw_obj, node));
+}
+
+phandle_t
+OFW_CHILD(ofw_t ofw_obj, phandle_t node)
+{
+
+   return (ofw_fdt_child(ofw_obj, node));
+}
+
+phandle_t
+OFW_PARENT(ofw_t ofw_obj, phandle_t node)
+{
+
+   return (ofw_fdt_parent(ofw_obj, node));
+}
+
+phandle_t
+OFW_INSTANCE_TO_PACKAGE(ofw_t ofw_obj, ihandle_t instance)
+{
+
+   return (ofw_fdt_instance_to_package(ofw_obj, instance));
+}
+
+ssize_t
+OFW_GETPROPLEN(ofw_t ofw_obj, phandle_t package, const char *propname)
+{
+
+   return (ofw_fdt_getproplen(ofw_obj, package, propname));
+}
+
+ssize_t
+OFW_GETPROP(ofw_t ofw_obj, phandle_t package, const char *propname,
+void *buf, size_t buflen
+)
+{
+
+   return (ofw_fdt_getprop(ofw_obj, package, propname, buf, buflen));
+}
+
+int
+OFW_NEXTPROP(ofw_t ofw_obj, phandle_t package, const char *prev, char *buf,
+size_t size)
+{
+
+   return (ofw_fdt_nextprop(ofw_obj, package, prev, buf, size));
+}
+
+int
+OFW_SETPROP(ofw_t ofw_obj, phandle_t package, const char *propname,
+const void *buf, size_t len)
+{
+
+   return (ofw_fdt_setprop(ofw_obj, package, propname, buf, len));
+}
+
+ssize_t
+OFW_CANON(ofw_t ofw_obj, const char *device, char *buf, size_t len)
+{
+
+   return (ofw_fdt_canon(ofw_obj, device, buf, len));
+}
+
+phandle_t
+OFW_FINDDEVICE(ofw_t ofw_obj, const char *device)
+{
+
+   return (ofw_fdt_finddevice(ofw_obj, device));
+}
+
+ssize_t
+OFW_INSTANCE_TO_PATH(ofw_t ofw_obj, 

[PATCH RTEMS v2 3/6] libfreebsd: FreeBSD porting helper header

2020-06-11 Thread G S Niteesh Babu
This file serve the purpose as rtems-bsd-kernel-space.h in the
rtems-libbsd.
This file is intended to be included in every source file that
is to imported from FreeBSD. This is to reduce the number of
redefinitions for commonly used functions like malloc, free
and KASSERT.
---
 cpukit/libfreebsd/rtems-freebsd-helper.h | 47 
 1 file changed, 47 insertions(+)
 create mode 100644 cpukit/libfreebsd/rtems-freebsd-helper.h

diff --git a/cpukit/libfreebsd/rtems-freebsd-helper.h 
b/cpukit/libfreebsd/rtems-freebsd-helper.h
new file mode 100644
index 00..d6edd6a01e
--- /dev/null
+++ b/cpukit/libfreebsd/rtems-freebsd-helper.h
@@ -0,0 +1,47 @@
+
+/* SPDX-License-Identifier: BSD-2-Clause
+
+ *
+ * @file
+ *
+ * @ingroup LIBFREEBSD
+ *
+ * @brief
+ */
+
+/*
+ * Copyright (C) <2020> Niteesh Babu 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIBFREEBSD_RTEMS_FREEBSD_HELPER_H
+#define _LIBFREEBSD_RTEMS_FREEBSD_HELPER_H
+#include 
+#include 
+
+#define_KERNEL 1
+#defineKASSERT(cnd, msg)   assert(cnd)
+#definemalloc(size, type, flags)   malloc(size)
+#definefree(addr, type)free(addr)
+
+#endif /* _LIBFREEBSD_RTEMS_FREEBSD_HELPER_H */
\ No newline at end of file
-- 
2.17.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH RTEMS v2 2/6] libfreebsd: Added ofw_if.h

2020-06-11 Thread G S Niteesh Babu
This file is the RTEMS implementation of ofw_if.h in FreeBSD. The
ofw_if.h in FreeBSD is an autogenerated header file that maps the
OF_function calls to their respective implementation. But in RTEMS
this file maps the OF_functions directly to their FDT implementation.
---
 cpukit/libfreebsd/dev/ofw/ofw_if.h | 62 ++
 1 file changed, 62 insertions(+)
 create mode 100644 cpukit/libfreebsd/dev/ofw/ofw_if.h

diff --git a/cpukit/libfreebsd/dev/ofw/ofw_if.h 
b/cpukit/libfreebsd/dev/ofw/ofw_if.h
new file mode 100644
index 00..b27864a032
--- /dev/null
+++ b/cpukit/libfreebsd/dev/ofw/ofw_if.h
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: BSD-2-Clause
+
+ *
+ * @file
+ *
+ * @ingroup LIBFREEBSD
+ *
+ * @brief Declaration of OFW functions.
+ */
+
+/*
+ * Copyright (C) <2020> Niteesh Babu 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIBFREEBSD_OFW_IF_H
+#define _LIBFREEBSD_OFW_IF_H
+
+#include "openfirm.h"
+
+typedef void*  ofw_t;
+
+int OFW_INIT(ofw_t ofw_obj, void *cookie);
+phandle_t OFW_PEER(ofw_t ofw_obj, phandle_t node);
+phandle_t OFW_CHILD(ofw_t ofw_obj, phandle_t node);
+phandle_t OFW_PARENT(ofw_t ofw_obj, phandle_t node);
+phandle_t OFW_INSTANCE_TO_PACKAGE(ofw_t ofw_obj, ihandle_t instance);
+ssize_t OFW_GETPROPLEN(ofw_t ofw_obj, phandle_t package, const char *propname);
+ssize_t OFW_GETPROP(ofw_t ofw_obj, phandle_t package, const char *propname,
+   void *buf, size_t buflen);
+int OFW_NEXTPROP(ofw_t ofw_obj, phandle_t package, const char *prev, char *buf,
+   size_t size);
+int OFW_SETPROP(ofw_t ofw_obj, phandle_t package, const char *propname,
+   const void *buf, size_t len);
+ssize_t OFW_CANON(ofw_t ofw_obj, const char *device, char *buf, size_t len);
+phandle_t OFW_FINDDEVICE(ofw_t ofw_obj, const char *device);
+ssize_t OFW_INSTANCE_TO_PATH(ofw_t ofw_obj, ihandle_t instance, char *buf,
+   size_t len);
+ssize_t OFW_PACKAGE_TO_PATH(ofw_t ofw_obj, phandle_t package, char *buf,
+   size_t len);
+
+#endif /* _LIBFREEBSD_OFW_IF_H */
-- 
2.17.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH RTEMS v2 4/6] bsp/fatal.h: Add FATAL codes for libfreebsd

2020-06-11 Thread G S Niteesh Babu
---
 bsps/include/bsp/fatal.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/bsps/include/bsp/fatal.h b/bsps/include/bsp/fatal.h
index 3f8e1eb591..c22f8a2f52 100644
--- a/bsps/include/bsp/fatal.h
+++ b/bsps/include/bsp/fatal.h
@@ -156,6 +156,10 @@ typedef enum {
   RISCV_FATAL_NO_TLCLOCK_FREQUENCY_IN_DEVICE_TREE
 } bsp_fatal_code;
 
+typedef enum {
+  LIBFREEBSD_FATAL_INVALID_FDT = BSP_FATAL_CODE_BLOCK(14)
+} libfreebsd_fatal_code;
+
 RTEMS_NO_RETURN static inline void
 bsp_fatal( bsp_fatal_code code )
 {
-- 
2.17.1

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


RE: GSoC 2020: [rtems/rsb]: Error while adding ptp support. This time building for xilinx_zynq_a9_qemu

2020-06-11 Thread Jan.Sommer


> -Original Message-
> From: Chris Johns [mailto:chr...@rtems.org]
> Sent: Thursday, June 11, 2020 2:26 AM
> To: Sommer, Jan; mritunjaysharma...@gmail.com
> Cc: rtems-de...@rtems.org
> Subject: Re: GSoC 2020: [rtems/rsb]: Error while adding ptp support. This
> time building for xilinx_zynq_a9_qemu
> 
> On 5/6/20 6:03 pm, jan.som...@dlr.de wrote:
> > We came across the PPSi library for PTP support some time ago:
> https://ohwr.org/project/ppsi
> > In their documentation its says they started with ptpd and then made an
> overhaul of the source code.
> 
> Interesting. Did you check the licenses and authors?
> 
> A search for "ptp v2.1.0" lists PTP v2.1.0 in SF and github. The github repo
> seems a more recent version of the SF repo but they seem similar. 

In the PPSi manual they write: 

"The algorithm and computation routines regarding the basic ieee 1588 are 
derived from the
PTPd project, v.2.1.0 (see AUTHORS for details about copyright); but as of 
March 2013 very
little remains of the original code base."

In their AUTHORS file they seem to have copied the information from here: 
https://sourceforge.net/p/ptpd/code/HEAD/tree/branches/ptpd-2.1.1/COPYRIGHT

>The PPSi code is GPLv2 and the SF and github code is 2C-BSD and the list of 
>copyright
> holders is different.
> 

Most of it seems to be LGPL with 2 exceptions according to the manual:

"The code is licensed according to the GNU LGPL, version 2.1 or later. Some 
files are individually
released to the public domain, when we think they are especially simple or 
generic.
Both the full and the partial printf code is distributed according to the 
GPL-2, as it comes from
the Linux kernel. This means that any code using our diagnostics fall under the 
GPL requirements; you may compile and use the diagnostic code internally with 
your own proprietary code
but you can’t distribute binaries with diagnostics without the complete source 
code and associated rights. You may avoid the GPL requirements by using 
different printf implementations; if
so we’d love to have them contributed back in the package.
The same issue about the GPL license applies to the div64_32 function. We need 
this implementation in our wrpc code base because the default libgcc division 
is very big, and we are always
tight with our in-FPGA memory space."

It would have been nice if this information would be more prominent in their 
repository and not hidden in the manual.

Cheers,

   Jan

> > They also claim portability as one of their goals. We haven't had time to
> look at it closer yet, but the projects looks a bit more active and seems to
> have the CERN behind it.
> 
> Then I hope the copyright is in order.
> 
> > Maybe it is worth checking out, if ptpd keeps making trouble.
> 
> It is GPL when the other code I have looked at it BSD.
> 
> Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel