Re: Instructions to send a Patch

2019-06-01 Thread Vaibhav Gupta
On Thu, 30 May, 2019, 2:48 PM Aditya Upadhyay,  wrote:

> On Thu, May 30, 2019 at 12:52 AM Gedare Bloom  wrote:
> >
> > On Tue, May 28, 2019 at 8:23 PM Vaibhav Gupta 
> wrote:
> > >
> > >
> > >
> > > On Tue, May 28, 2019 at 11:47 AM Aditya Upadhyay 
> wrote:
> > >>
> > >> On Mon, May 27, 2019 at 10:42 PM Vaibhav Gupta <
> vaibhavgupt...@gmail.com> wrote:
> > >> >
> > >> > Hello, okay I will keep that in mind.
> > >> > .
> > >> > .
> > >> > .
> > >> > .
> > >> > But there is one problem with this patch then.
> > >> > .
> > >> > .
> > >> > If i just copy-paste ndbm.h, db.h(needed by ndbm.h) and ndbm.c and
> make the entry of ndbm.c  in Makefile.am.
> > >> > Then run 'autoreconf' to add the entry for ndbm.c in Makefile.in.
> And then run `make` command. There will be compilation error.
> > >> > .
> > >>
> > >> See Instructions here about regenerating the configuration files in
> newlib.
> > >> https://sourceware.org/newlib/README
> > >> Newlib uses a specific version of autoconf. You can use `autoreconf
> > >> -fvi` command to regenerate that
> > >> Makefile.in file.
> > >
> > > Okay
> > >>
> > >>
> > >> > Header files needed by libc/posic/*.c files are present in
> libc/include directory. It is default path.
> > >> > .
> > >> > But ndbm.c also requires "hash.h" which is present inside
> "libc/search".
> > >> > .
> > >> > To over come it, i had to modify the entry of ndbm.c in Makefile.in
> and add "-I (topr_srcdir)/search" to specify the compiler for alternative
> source path.
> > >>
> > >> If you specify any header file inclusion in Makefile.am, then you will
> > >> need to add the things manually
> > >> and when you will run autoreconf command, this .in file will get
> updated.
> > >>
> > > I guess I will need to modify configure.in file. If I am not wrong
> that is responsible for what autoreconf is doing.
> >
> > You shouldn't be manually modifying any *.in files.
>
> Basically, After adding any files, We just need to make some entries
> in these two files: configure.ac and Makefile.am files.
> autoheader, autoconf and automake are the tools used when you execute
> autoreconf command. It generate config.h.in, Makefile. in and that
> configure script and When you execute configure script, you get
> config.h and Makefile.
> Take a look at page no 26 of this file.
> https://elinux.org/images/4/43/Petazzoni.pdf

I am still not able to find where exactly in Makefile.am and configure.ac ,
i have to mention for "search/hash.h".

The approach i used was, if posix files are compiled using headers in
"include" folder, it must be mentioned about it somewhere inside
Makefile.am or configure.in. I thought i will mention for "search/hash.h"
at the same place.

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

Re: [PATCH] Add Test suite for inttypes.h (psxinttypes.exe) in testsuites/psxtests

2019-06-01 Thread Aditya Upadhyay
On Sat, Jun 1, 2019 at 5:03 AM Gedare Bloom  wrote:
>
> On Fri, May 31, 2019 at 10:17 AM Aditya Upadhyay  wrote:
> >
> > Hi VARoDeK,
> >
> > This looks fine to me. I would love to see other's responses.
> >
>
> This test is not right, it needs to be rethought. Let me know if you
> need further guidance.
>
Yeah, Gedare !! I need some further guidance. I had written this test
1 year ago, but could not send it on devel.
I was writing this testsuite for the very first time.

Could you please point me an example? Although I have gone through
open group POSIX
Page and looked into some previously made testsuites in the psxtests directory.

While configuring, I had used --enable-tests=yes option, but I do not
see any generated .exe file.
or Can we generate the .exe file manually?


> > On Thu, May 30, 2019 at 8:47 PM VARoDeK  wrote:
> > >
> > > ---
> > >  testsuites/psxtests/Makefile.am   |   7 +
> > >  testsuites/psxtests/configure.ac  |   1 +
> > >  testsuites/psxtests/psxinttypes01/init.c  | 154 ++
> > >  .../psxtests/psxinttypes01/psxinttypes01.doc  |  57 +++
> > >  .../psxtests/psxinttypes01/psxinttypes01.scn  |  28 
> > >  5 files changed, 247 insertions(+)
> > >  create mode 100644 testsuites/psxtests/psxinttypes01/init.c
> > >  create mode 100644 testsuites/psxtests/psxinttypes01/psxinttypes01.doc
> > >  create mode 100644 testsuites/psxtests/psxinttypes01/psxinttypes01.scn
> > >
> > > diff --git a/testsuites/psxtests/Makefile.am 
> > > b/testsuites/psxtests/Makefile.am
> > > index 749258cc0c..f619dd9ae9 100644
> > > --- a/testsuites/psxtests/Makefile.am
> > > +++ b/testsuites/psxtests/Makefile.am
> > > @@ -22,6 +22,13 @@ psx01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psx01) \
> > > $(support_includes) -I$(top_srcdir)/include
> > >  endif
> > >
> > > +if TEST_psxinttypes01
> > > +psx_tests += psxinttypes01
> > > +psxinttypes01_SOURCES = psxinttypes01/init.c
> > > +psxinttypes01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxinttypes01) \
> > > +   $(support_includes)
> > > +endif
> > > +
> > >  if HAS_POSIX
> > >  if TEST_psx02
> > >  psx_tests += psx02
> > > diff --git a/testsuites/psxtests/configure.ac 
> > > b/testsuites/psxtests/configure.ac
> > > index cdd6ee7e4e..e032a6f5ec 100644
> > > --- a/testsuites/psxtests/configure.ac
> > > +++ b/testsuites/psxtests/configure.ac
> > > @@ -140,6 +140,7 @@ RTEMS_TEST_CHECK([psxtimes01])
> > >  RTEMS_TEST_CHECK([psxualarm])
> > >  RTEMS_TEST_CHECK([psxusleep])
> > >  RTEMS_TEST_CHECK([lib_a])
> > > +RTEMS_TEST_CHECK([psxinttypes01])
> > >
> > >  AC_CONFIG_FILES([Makefile])
> > >  AC_OUTPUT
> > > diff --git a/testsuites/psxtests/psxinttypes01/init.c 
> > > b/testsuites/psxtests/psxinttypes01/init.c
> > > new file mode 100644
> > > index 00..1c6340afe2
> > > --- /dev/null
> > > +++ b/testsuites/psxtests/psxinttypes01/init.c
> > > @@ -0,0 +1,154 @@
> > > +/**
> > > + *  @file
> > > + *  @brief Test suite for inttypes.h methods
> > > + */
> > > +
> > > +/*
> > > + * SPDX-License-Identifier: BSD-2-Clause
> > > + *
> > > + * Copyright (C) 2019, Vaibhav Gupta
> > > + *
> > > + * 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.
> > > + */
> > > +
> > > +#ifdef HAVE_CONFIG_H
> > > +#include "config.h"
> > > +#endif
> > > +
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +#include 
> > > +
> > > +const char rtems_test_name[] = "PSXINTTYPE 01";
> > > +
> > > +/* forward declarations to avoid warnings */
> > > +rtems_task Init(rtems_ta

Re: [PATCH] Add Test suite for inttypes.h (psxinttypes.exe) in testsuites/psxtests

2019-06-01 Thread Gedare Bloom
On Sat, Jun 1, 2019, 8:29 AM Aditya Upadhyay  wrote:

> On Sat, Jun 1, 2019 at 5:03 AM Gedare Bloom  wrote:
> >
> > On Fri, May 31, 2019 at 10:17 AM Aditya Upadhyay 
> wrote:
> > >
> > > Hi VARoDeK,
> > >
> > > This looks fine to me. I would love to see other's responses.
> > >
> >
> > This test is not right, it needs to be rethought. Let me know if you
> > need further guidance.
> >
> Yeah, Gedare !! I need some further guidance. I had written this test
> 1 year ago, but could not send it on devel.
> I was writing this testsuite for the very first time.
>

If you wrote the test, your name should belong in the copyright info.

Could you please point me an example?


Which psxtest was this derived from? Is there a psxtest that considers
string conversions? That would be a good start. Do some digging.

The logic of the test needs to be thought out. What is the expected
behavior being tested? How do you isolate correct/incorrect behavior?

Gedare

Although I have gone through
> open group POSIX
> Page and looked into some previously made testsuites in the psxtests
> directory.
>
> While configuring, I had used --enable-tests=yes option, but I do not
> see any generated .exe file.
> or Can we generate the .exe file manually?
>
>
> > > On Thu, May 30, 2019 at 8:47 PM VARoDeK 
> wrote:
> > > >
> > > > ---
> > > >  testsuites/psxtests/Makefile.am   |   7 +
> > > >  testsuites/psxtests/configure.ac  |   1 +
> > > >  testsuites/psxtests/psxinttypes01/init.c  | 154
> ++
> > > >  .../psxtests/psxinttypes01/psxinttypes01.doc  |  57 +++
> > > >  .../psxtests/psxinttypes01/psxinttypes01.scn  |  28 
> > > >  5 files changed, 247 insertions(+)
> > > >  create mode 100644 testsuites/psxtests/psxinttypes01/init.c
> > > >  create mode 100644
> testsuites/psxtests/psxinttypes01/psxinttypes01.doc
> > > >  create mode 100644
> testsuites/psxtests/psxinttypes01/psxinttypes01.scn
> > > >
> > > > diff --git a/testsuites/psxtests/Makefile.am
> b/testsuites/psxtests/Makefile.am
> > > > index 749258cc0c..f619dd9ae9 100644
> > > > --- a/testsuites/psxtests/Makefile.am
> > > > +++ b/testsuites/psxtests/Makefile.am
> > > > @@ -22,6 +22,13 @@ psx01_CPPFLAGS = $(AM_CPPFLAGS)
> $(TEST_FLAGS_psx01) \
> > > > $(support_includes) -I$(top_srcdir)/include
> > > >  endif
> > > >
> > > > +if TEST_psxinttypes01
> > > > +psx_tests += psxinttypes01
> > > > +psxinttypes01_SOURCES = psxinttypes01/init.c
> > > > +psxinttypes01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxinttypes01)
> \
> > > > +   $(support_includes)
> > > > +endif
> > > > +
> > > >  if HAS_POSIX
> > > >  if TEST_psx02
> > > >  psx_tests += psx02
> > > > diff --git a/testsuites/psxtests/configure.ac b/testsuites/psxtests/
> configure.ac
> > > > index cdd6ee7e4e..e032a6f5ec 100644
> > > > --- a/testsuites/psxtests/configure.ac
> > > > +++ b/testsuites/psxtests/configure.ac
> > > > @@ -140,6 +140,7 @@ RTEMS_TEST_CHECK([psxtimes01])
> > > >  RTEMS_TEST_CHECK([psxualarm])
> > > >  RTEMS_TEST_CHECK([psxusleep])
> > > >  RTEMS_TEST_CHECK([lib_a])
> > > > +RTEMS_TEST_CHECK([psxinttypes01])
> > > >
> > > >  AC_CONFIG_FILES([Makefile])
> > > >  AC_OUTPUT
> > > > diff --git a/testsuites/psxtests/psxinttypes01/init.c
> b/testsuites/psxtests/psxinttypes01/init.c
> > > > new file mode 100644
> > > > index 00..1c6340afe2
> > > > --- /dev/null
> > > > +++ b/testsuites/psxtests/psxinttypes01/init.c
> > > > @@ -0,0 +1,154 @@
> > > > +/**
> > > > + *  @file
> > > > + *  @brief Test suite for inttypes.h methods
> > > > + */
> > > > +
> > > > +/*
> > > > + * SPDX-License-Identifier: BSD-2-Clause
> > > > + *
> > > > + * Copyright (C) 2019, Vaibhav Gupta
> > > > + *
> > > > + * 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
>

[PATCH] Add iicbus drivers to RTEMS-libbsd

2019-06-01 Thread Vijay Kumar Banerjee
Hello everyone,

The patch set adds the iicbus drivers to the libbsd.

- The first two patches add the iicbus drivers to libbsd.

- The third path adds a generic rtems i2c adaptation driver to the libbsd. This
  will enable the libbsd applications to use the rtems-i2c drivers. This
  adaptation layer has been tested on Beaglebone Black RevC. 

  The adaptation layer has been tested using a sample application that reads 
the 
  eeprom and prints the data to the screen. 

- The last two patches add the i2c tool to the libbsd. This tool can be used to
  read/write through the i2c bus. This is currently not working because the tool
  lacks the transfer method used in the dirver. However, this has been fixed in
  FreeBSD upstream with the following commit :
  https://svnweb.freebsd.org/base?view=revision&revision=348120

  I have tested the tool to be working with the i2c drivers using the above 
patch.
  So, after the updates to libbsd this will work.
  
  Here's a link the the sample application that I wrote outside of libbsd, this 
  uses the adaptation layer to read from eeprom:
  https://github.com/thelunatic/rtems-bbb/tree/master/apps/i2c-adaptation-sample


Thank You,
Vijay


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


[PATCH 1/5] iicbus: Import from FreeBSD

2019-06-01 Thread Vijay Kumar Banerjee
---
 freebsd/sys/dev/iicbus/iic.c| 506 ++
 freebsd/sys/dev/iicbus/iic.h|  72 
 freebsd/sys/dev/iicbus/iicbus.c | 378 
 freebsd/sys/dev/iicbus/iicbus.h |  83 +
 freebsd/sys/dev/iicbus/iiconf.c | 527 
 freebsd/sys/dev/iicbus/iiconf.h | 162 +
 freebsd/sys/dev/iicbus/ofw_iicbus.c | 242 +
 7 files changed, 1970 insertions(+)
 create mode 100644 freebsd/sys/dev/iicbus/iic.c
 create mode 100644 freebsd/sys/dev/iicbus/iic.h
 create mode 100644 freebsd/sys/dev/iicbus/iicbus.c
 create mode 100644 freebsd/sys/dev/iicbus/iicbus.h
 create mode 100644 freebsd/sys/dev/iicbus/iiconf.c
 create mode 100644 freebsd/sys/dev/iicbus/iiconf.h
 create mode 100644 freebsd/sys/dev/iicbus/ofw_iicbus.c

diff --git a/freebsd/sys/dev/iicbus/iic.c b/freebsd/sys/dev/iicbus/iic.c
new file mode 100644
index ..dc9c06f9
--- /dev/null
+++ b/freebsd/sys/dev/iicbus/iic.c
@@ -0,0 +1,506 @@
+#include 
+
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 1998, 2001 Nicolas Souchu
+ * 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$
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+struct iic_softc {
+   device_t sc_dev;
+   struct cdev *sc_devnode;
+};
+
+struct iic_cdevpriv {
+   struct sx lock;
+   struct iic_softc *sc;
+   bool started;
+   uint8_t addr;
+};
+
+
+#defineIIC_LOCK(cdp)   sx_xlock(&(cdp)->lock)
+#defineIIC_UNLOCK(cdp) sx_xunlock(&(cdp)->lock)
+
+static MALLOC_DEFINE(M_IIC, "iic", "I2C device data");
+
+static int iic_probe(device_t);
+static int iic_attach(device_t);
+static int iic_detach(device_t);
+static void iic_identify(driver_t *driver, device_t parent);
+static void iicdtor(void *data);
+static int iicuio_move(struct iic_cdevpriv *priv, struct uio *uio, int last);
+static int iicuio(struct cdev *dev, struct uio *uio, int ioflag);
+static int iicrdwr(struct iic_cdevpriv *priv, struct iic_rdwr_data *d, int 
flags);
+
+static devclass_t iic_devclass;
+
+static device_method_t iic_methods[] = {
+   /* device interface */
+   DEVMETHOD(device_identify,  iic_identify),
+   DEVMETHOD(device_probe, iic_probe),
+   DEVMETHOD(device_attach,iic_attach),
+   DEVMETHOD(device_detach,iic_detach),
+
+   /* iicbus interface */
+   DEVMETHOD(iicbus_intr,  iicbus_generic_intr),
+
+   { 0, 0 }
+};
+
+static driver_t iic_driver = {
+   "iic",
+   iic_methods,
+   sizeof(struct iic_softc),
+};
+
+static d_open_tiicopen;
+static d_ioctl_t   iicioctl;
+
+static struct cdevsw iic_cdevsw = {
+   .d_version =D_VERSION,
+   .d_open =   iicopen,
+   .d_read =   iicuio,
+   .d_write =  iicuio,
+   .d_ioctl =  iicioctl,
+   .d_name =   "iic",
+};
+
+static void
+iic_identify(driver_t *driver, device_t parent)
+{
+
+   if (device_find_child(parent, "iic", -1) == NULL)
+   BUS_ADD_CHILD(parent, 0, "iic", -1);
+}
+
+static int
+iic_probe(device_t dev)
+{
+   if (iicbus_get_addr(dev) > 0)
+   return (ENXIO);
+
+   device_set_desc(dev, "I2C generic I/O");
+
+   return (0);
+}
+   
+static int
+iic_attach(device_t dev)
+{
+   struct iic_softc *sc;
+
+   sc = device_get_softc(dev);
+   sc->sc_dev = dev;
+   sc->sc_devnode = make_dev(&iic_cdevsw, device_get_unit(dev),
+   UID_ROOT, GID_WHEEL,
+ 

[PATCH 3/5] Add rtems i2c adaptation layer

2019-06-01 Thread Vijay Kumar Banerjee
---
 libbsd.py|   1 +
 rtemsbsd/i2c/rtems-i2c.c | 218 +++
 2 files changed, 219 insertions(+)
 create mode 100644 rtemsbsd/i2c/rtems-i2c.c

diff --git a/libbsd.py b/libbsd.py
index a25d3a8a..6e8ff987 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -771,6 +771,7 @@ class iic(builder.Module):
 self.addRTEMSSourceFiles(
 [
 'local/iicbus_if.c',
+'i2c/rtems-i2c.c',
 ],
 mm.generator['source']()
 )
diff --git a/rtemsbsd/i2c/rtems-i2c.c b/rtemsbsd/i2c/rtems-i2c.c
new file mode 100644
index ..5189e5fe
--- /dev/null
+++ b/rtemsbsd/i2c/rtems-i2c.c
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2019 Vijay Kumar Banerjee .
+ * 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.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+typedef struct i2c_msg i2c_msg;
+
+struct i2c_softc {
+   device_t dev;
+   device_t sc_iicbus;
+   char *path;
+   int fd;
+   int mem_rid;
+   int irq_rid;
+};
+
+static int
+rtems_i2c_probe(device_t dev)
+{
+   if (!ofw_bus_status_okay(dev)) {
+   return (ENXIO);
+   }
+   if (!ofw_bus_is_compatible(dev, "rtems,bsp-i2c")){
+   return (ENXIO);
+   }
+
+   device_set_desc(dev, "RTEMS libbsd I2C");
+   return (BUS_PROBE_SPECIFIC);
+}
+
+static int
+rtems_i2c_attach(device_t dev)
+{
+   phandle_t node;
+   ssize_t compatlen;
+   char *compat;
+   char *curstr;
+   struct i2c_softc *sc;
+   int len;
+
+   sc = device_get_softc(dev);
+   sc->dev = dev;
+   node = ofw_bus_get_node(sc->dev);
+
+   len = OF_getprop_alloc(node, "rtems,i2c-path", &sc->path);
+   if (len == -1){
+   device_printf(sc->dev, "Path not found in Device Tree");
+   OF_prop_free(sc->path);
+   return (ENXIO);
+   }
+   else{
+   if ((sc->sc_iicbus = device_add_child(sc->dev, "iicbus", -1)) 
== NULL) {
+   device_printf(sc->dev, "could not allocate iicbus 
instance\n");
+   OF_prop_free(sc->path);
+   return (ENXIO);
+   }
+   config_intrhook_oneshot((ich_func_t)bus_generic_attach, 
sc->dev);
+   }
+   return (0);
+}
+
+static int
+rtems_i2c_detach(device_t dev)
+{
+   struct i2c_softc *sc;
+   int error;
+
+   sc = device_get_softc(dev);
+
+   OF_prop_free(sc->path);
+
+   if (sc->sc_iicbus && (error = device_delete_child(dev, sc->sc_iicbus)) 
!= 0)
+   return (error);
+
+   if ((error = bus_generic_detach(sc->dev)) != 0) {
+   device_printf(sc->dev, "cannot detach child devices\n");
+   return (error);
+   }
+
+
+   return (0);
+}
+
+static int
+rtems_i2c_transfer(device_t dev, struct iic_msg *msgs, u_int num)
+{
+   i2c_msg *messages;
+   int err;
+   char *addr;
+   struct i2c_softc *sc;
+   struct i2c_rdwr_ioctl_data ioctl_data;
+
+   sc = device_get_softc(dev);
+
+   /* Open /dev/iic0 */
+   sc->fd = open(sc->path, O_RDWR);
+   if (sc->fd < 0) {
+   device_printf(sc->dev, "%s\n", strerror(errno));
+   return errno;
+   }
+
+   /* cast iic_msg to i2c_msg */
+   messages = (i2c_msg *) msgs;
+   ioctl_data.msgs = messages;
+   ioctl_data.nmsgs = num;
+
+   /* IOCTL call to write */
+   err = ioctl(sc->fd, I2C_RDWR, &ioctl_data);
+   if (err < 0){
+  

[PATCH 5/5] i2c tool : port to RTEMS

2019-06-01 Thread Vijay Kumar Banerjee
---
 freebsd/usr.sbin/i2c/i2c.c| 35 +++
 libbsd.py |  2 ++
 rtemsbsd/include/machine/rtems-bsd-commands.h |  2 ++
 rtemsbsd/include/rtems/netcmds-config.h   |  2 ++
 rtemsbsd/rtems/rtems-bsd-shell-i2c.c  | 35 +++
 5 files changed, 76 insertions(+)
 create mode 100644 rtemsbsd/rtems/rtems-bsd-shell-i2c.c

diff --git a/freebsd/usr.sbin/i2c/i2c.c b/freebsd/usr.sbin/i2c/i2c.c
index 084682a1..840f78f6 100644
--- a/freebsd/usr.sbin/i2c/i2c.c
+++ b/freebsd/usr.sbin/i2c/i2c.c
@@ -28,6 +28,13 @@
  * SUCH DAMAGE.
  */
 
+#ifdef __rtems__
+#define __need_getopt_newlib
+#include 
+#include 
+#include 
+#endif /* __rtems__ */
+
 #include 
 __FBSDID("$FreeBSD$");
 
@@ -560,6 +567,24 @@ err2:
return (1);
 }
 
+#ifdef __rtems__
+static int main(int argc, char *argv[]);
+
+int
+rtems_bsd_command_i2c(int argc, char *argv[])
+{
+int exit_code;
+void *data_begin;
+size_t data_size;
+
+rtems_bsd_program_lock();
+exit_code = rtems_bsd_program_call_main("i2c", main, argc, argv);
+rtems_bsd_program_unlock();
+
+return exit_code;
+}
+#endif /* __rtems__ */
+
 int
 main(int argc, char** argv)
 {
@@ -568,6 +593,16 @@ main(int argc, char** argv)
char *dev, *skip_addr, *i2c_buf;
int error, chunk_size, i, j, ch;
 
+#ifdef __rtems__
+struct getopt_data getopt_data;
+memset(&getopt_data, 0, sizeof(getopt_data));
+#define optind getopt_data.optind
+#define optarg getopt_data.optarg
+#define opterr getopt_data.opterr
+#define optopt getopt_data.optopt
+#define getopt(argc, argv, opt) getopt_r(argc, argv, "+" opt, &getopt_data)
+#endif /* __rtems__ */
+
errno = 0;
error = 0;
 
diff --git a/libbsd.py b/libbsd.py
index 6e8ff987..c4b6f5eb 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -176,6 +176,7 @@ class rtems(builder.Module):
 'rtems/rtems-bsd-rc-conf.c',
 'rtems/rtems-bsd-set-if-input.c',
 'rtems/rtems-bsd-shell-arp.c',
+'rtems/rtems-bsd-shell-i2c.c',
 'rtems/rtems-bsd-shell-ifconfig.c',
 'rtems/rtems-bsd-shell-netstat.c',
 'rtems/rtems-bsd-shell-pfctl.c',
@@ -2990,6 +2991,7 @@ class user_space(builder.Module):
 'usr.bin/netstat/unix.c',
 'usr.bin/vmstat/vmstat.c',
 'usr.sbin/arp/arp.c',
+'usr.sbin/i2c/i2c.c',
 ],
 mm.generator['source'](['-DINET'])
 )
diff --git a/rtemsbsd/include/machine/rtems-bsd-commands.h 
b/rtemsbsd/include/machine/rtems-bsd-commands.h
index 1b022902..f5f2955a 100644
--- a/rtemsbsd/include/machine/rtems-bsd-commands.h
+++ b/rtemsbsd/include/machine/rtems-bsd-commands.h
@@ -54,6 +54,8 @@ int rtems_bsd_command_netstat(int argc, char **argv);
 
 int rtems_bsd_command_pfctl(int argc, char **argv);
 
+int rtems_bsd_command_i2c(int argc, char **argv);
+
 int rtems_bsd_command_ping(int argc, char **argv);
 
 int rtems_bsd_command_ping6(int argc, char **argv);
diff --git a/rtemsbsd/include/rtems/netcmds-config.h 
b/rtemsbsd/include/rtems/netcmds-config.h
index f8dcdcdc..4d72a4fa 100644
--- a/rtemsbsd/include/rtems/netcmds-config.h
+++ b/rtemsbsd/include/rtems/netcmds-config.h
@@ -26,6 +26,8 @@ extern rtems_shell_cmd_t rtems_shell_ARP_Command;
 
 extern rtems_shell_cmd_t rtems_shell_PFCTL_Command;
 
+extern rtems_shell_cmd_t rtems_shell_I2C_Command;
+
 extern rtems_shell_cmd_t rtems_shell_PING_Command;
 extern rtems_shell_cmd_t rtems_shell_PING6_Command;
 
diff --git a/rtemsbsd/rtems/rtems-bsd-shell-i2c.c 
b/rtemsbsd/rtems/rtems-bsd-shell-i2c.c
new file mode 100644
index ..2e1da406
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-bsd-shell-i2c.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2019 Vijay Kumar Banerjee 
+#include 
+
+rtems_shell_cmd_t rtems_shell_I2C_Command = {
+  .name = "i2c",
+  .usage = "i2c [args]",
+  .topic = "i2c",
+  .command = rtems_bsd_command_i2c
+};
-- 
2.20.1

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


[PATCH 4/5] i2c tool : Import from FreeBSD

2019-06-01 Thread Vijay Kumar Banerjee
---
 freebsd/usr.sbin/i2c/i2c.c | 733 +
 1 file changed, 733 insertions(+)
 create mode 100644 freebsd/usr.sbin/i2c/i2c.c

diff --git a/freebsd/usr.sbin/i2c/i2c.c b/freebsd/usr.sbin/i2c/i2c.c
new file mode 100644
index ..084682a1
--- /dev/null
+++ b/freebsd/usr.sbin/i2c/i2c.c
@@ -0,0 +1,733 @@
+#include 
+
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (C) 2008-2009 Semihalf, Michal Hajduk and Bartlomiej Sieka
+ * 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 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 
+
+#defineI2C_DEV "/dev/iic0"
+#defineI2C_MODE_NOTSET 0
+#defineI2C_MODE_NONE   1
+#defineI2C_MODE_STOP_START 2
+#defineI2C_MODE_REPEATED_START 3
+
+struct options {
+   int width;
+   int count;
+   int verbose;
+   int addr_set;
+   int binary;
+   int scan;
+   int skip;
+   int reset;
+   int mode;
+   chardir;
+   uint32_taddr;
+   uint32_toff;
+};
+
+struct skip_range {
+   int start;
+   int end;
+};
+
+__dead2 static void
+usage(void)
+{
+
+   fprintf(stderr, "usage: %s -a addr [-f device] [-d [r|w]] [-o offset] "
+   "[-w [0|8|16]] [-c count] [-m [ss|rs|no]] [-b] [-v]\n",
+   getprogname());
+   fprintf(stderr, "   %s -s [-f device] [-n skip_addr] -v\n",
+   getprogname());
+   fprintf(stderr, "   %s -r [-f device] -v\n", getprogname());
+   exit(EX_USAGE);
+}
+
+static struct skip_range
+skip_get_range(char *skip_addr)
+{
+   struct skip_range addr_range;
+   char *token;
+
+   addr_range.start = 0;
+   addr_range.end = 0;
+
+   token = strsep(&skip_addr, "..");
+   if (token) {
+   addr_range.start = strtoul(token, 0, 16);
+   token = strsep(&skip_addr, "..");
+   if ((token != NULL) && !atoi(token)) {
+   token = strsep(&skip_addr, "..");
+   if (token)
+   addr_range.end = strtoul(token, 0, 16);
+   }
+   }
+
+   return (addr_range);
+}
+
+/* Parse the string to get hex 7 bits addresses */
+static int
+skip_get_tokens(char *skip_addr, int *sk_addr, int max_index)
+{
+   char *token;
+   int i;
+
+   for (i = 0; i < max_index; i++) {
+   token = strsep(&skip_addr, ":");
+   if (token == NULL)
+   break;
+   sk_addr[i] = strtoul(token, 0, 16);
+   }
+   return (i);
+}
+
+static int
+scan_bus(struct iiccmd cmd, char *dev, int skip, char *skip_addr)
+{
+   struct iic_msg rdmsg;
+   struct iic_rdwr_data rdwrdata;
+   struct skip_range addr_range = { 0, 0 };
+   int *tokens, fd, error, i, index, j;
+   int len = 0, do_skip = 0, no_range = 1, num_found = 0, use_read_xfer = 
0;
+   uint8_t rdbyte;
+
+   fd = open(dev, O_RDWR);
+   if (fd == -1) {
+   fprintf(stderr, "Error opening I2C controller (%s) for "
+   "scanning: %s\n", dev, strerror(errno));
+   return (EX_NOINPUT);
+   }
+
+   if (skip) {
+   len = strlen(skip_addr);
+   if (strstr(skip_addr, "..") != NULL) {
+   addr_range = skip_get_range(skip_addr);
+   no_range = 0;
+   } else {
+   tokens = (int *)malloc((len / 2 + 1) * sizeof(int));
+   if (to

[PATCH 2/5] iicbus: port to RTEMS

2019-06-01 Thread Vijay Kumar Banerjee
---
 Makefile.todo |  11 ++
 buildset/default.ini  |   1 +
 libbsd.py |  35 
 rtemsbsd/include/bsp/nexus-devices.h  |   4 +
 .../machine/rtems-bsd-kernel-namespace.h  |  33 
 rtemsbsd/include/rtems/bsd/local/iicbus_if.h  | 166 ++
 rtemsbsd/local/iicbus_if.c|  76 
 7 files changed, 326 insertions(+)
 create mode 100644 rtemsbsd/include/rtems/bsd/local/iicbus_if.h
 create mode 100644 rtemsbsd/local/iicbus_if.c

diff --git a/Makefile.todo b/Makefile.todo
index 9754ddb6..74188531 100644
--- a/Makefile.todo
+++ b/Makefile.todo
@@ -215,6 +215,17 @@ $(LOCAL_SRC)/gpiobus_if.c: 
$(FREEBSD_SRC)/sys/dev/gpio/gpiobus_if.m
-e 's|#include "gpiobus_if.h"|#include 
|'
mv gpiobus_if.c $@
 
+$(LOCAL_INC)/iicbus_if.h: $(FREEBSD_SRC)/sys/dev/iicbus/iicbus_if.m
+   awk -f $(TOOLS)/makeobjops.awk $< -h
+   mv iicbus_if.h $@
+
+$(LOCAL_SRC)/iicbus_if.c: $(FREEBSD_SRC)/sys/dev/iicbus/iicbus_if.m
+   awk -f $(TOOLS)/makeobjops.awk $< -c
+   sed -i iicbus_if.c \
+   -e '1 i\#include \n' \
+   -e 's|#include "iicbus_if.h"|#include 
|'
+   mv iicbus_if.c $@
+
 $(LOCAL_INC)/sdhci_if.h: $(FREEBSD_SRC)/sys/dev/sdhci/sdhci_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv sdhci_if.h $@
diff --git a/buildset/default.ini b/buildset/default.ini
index f25fe9a3..4acb2368 100644
--- a/buildset/default.ini
+++ b/buildset/default.ini
@@ -36,6 +36,7 @@ dev_usb_serial = on
 dev_usb_storage = on
 dev_usb_wlan = off
 dev_wlan_rtwn = off
+iic = on
 dhcpcd = on
 dpaa = on
 evdev = on
diff --git a/libbsd.py b/libbsd.py
index d99e3ad8..a25d3a8a 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -125,6 +125,7 @@ _defaults = {
  ('freebsd/sys/sys','**/*.h',  
'sys'),
  ('freebsd/sys/vm', '**/*.h',  
'vm'),
  ('freebsd/sys/dev/mii','**/*.h',  
'dev/mii'),
+ ('freebsd/sys/dev/iicbus', '**/*.h',  
'dev/iicbus'),
  ('linux/include',  '**/*.h',  
''),
  ('mDNSResponder/mDNSCore', 'mDNSDebug.h', 
''),
  ('mDNSResponder/mDNSCore', 'mDNSEmbeddedAPI.h',   
''),
@@ -741,6 +742,39 @@ class evdev(builder.Module):
 mm.generator['source']()
 )
 
+#
+# IIC
+#
+class iic(builder.Module):
+
+def __init__(self, manager):
+super(iic, self).__init__(manager, type(self).__name__)
+
+def generate(self):
+mm = self.manager
+self.addKernelSpaceHeaderFiles(
+[
+'sys/dev/iicbus/iicbus.h',
+'sys/dev/iicbus/iic.h',
+'sys/dev/iicbus/iiconf.h',
+]
+)
+self.addKernelSpaceSourceFiles(
+[
+'sys/dev/iicbus/iic.c',
+'sys/dev/iicbus/iicbus.c',
+'sys/dev/iicbus/iiconf.c',
+'sys/dev/iicbus/ofw_iicbus.c',
+],
+mm.generator['source']()
+)
+self.addRTEMSSourceFiles(
+[
+'local/iicbus_if.c',
+],
+mm.generator['source']()
+)
+
 #
 # USB
 #
@@ -5096,6 +5130,7 @@ def load(mm):
 mm.addModule(mmc_ti(mm))
 mm.addModule(dev_input(mm))
 mm.addModule(evdev(mm))
+mm.addModule(iic(mm))
 
 mm.addModule(dev_usb(mm))
 mm.addModule(dev_usb_controller(mm))
diff --git a/rtemsbsd/include/bsp/nexus-devices.h 
b/rtemsbsd/include/bsp/nexus-devices.h
index a916c664..97f6d2b2 100644
--- a/rtemsbsd/include/bsp/nexus-devices.h
+++ b/rtemsbsd/include/bsp/nexus-devices.h
@@ -61,6 +61,10 @@ SYSINIT_DRIVER_REFERENCE(sdhci_ti, simplebus);
 SYSINIT_DRIVER_REFERENCE(mmcsd, mmc);
 SYSINIT_DRIVER_REFERENCE(cpsw, cpswss);
 SYSINIT_DRIVER_REFERENCE(ukphy, miibus);
+SYSINIT_DRIVER_REFERENCE(rtems_i2c, simplebus);
+SYSINIT_DRIVER_REFERENCE(ofw_iicbus, rtems_i2c);
+SYSINIT_DRIVER_REFERENCE(iic, iicbus);
+SYSINIT_DRIVER_REFERENCE(iicbus, rtems_i2c);
 #ifdef RTEMS_BSD_MODULE_NET80211
 SYSINIT_DRIVER_REFERENCE(rtwn_usb, uhub);
 SYSINIT_MODULE_REFERENCE(wlan_ratectl_none);
diff --git a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h 
b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
index d7967c65..626c2ccc 100644
--- a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
+++ b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
@@ -1304,6 +1304,8 @@
 #definegif_hashinit _bsd_gif_hashinit
 #definegif_input _bsd_gif_input
 #definegif_output _bsd_gif_output
+#defineglobal_epoch _bsd_global_epoch
+#defineglobal_epoch_preempt _bsd_global_epoch_preempt
 #definegpio_alloc_intr_resource _bsd_gpio_alloc_intr_resource
 #define  

Re: GSoC Project | Basic Support for Trace Compass

2019-06-01 Thread Chris Johns
On 31/5/19 2:32 pm, Sebastian Huber wrote:
> On 31/05/2019 01:38, Chris Johns wrote:
>> On 30/5/19 7:48 pm, Sebastian Huber wrote:
>>> Since this program runs on the host, you can also use GPL or LGPL software.
>> Hmm the rtems-tools package is aiming for no GPL or LGPL. There are a few GPL
>> files in it at the moment which could be replaced if we need too but this has
>> not happened yet. I would prefer we find other alternatives and avoid GPL 
>> rather
>> than encourage it.
> 
> I don't encourage the use of these licenses, but using lttng-ust for example
> should be fine on the host, but not on RTEMS (see begin of this thread):

Sorry, I should have been more explicit and maybe did not understand the full
context. I am concerned about GPL or LGPL code being add to rtems-tools as I
feel mixed licenses is confusing. The use of GPL or LGPL as packages built on a
host is fine.

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