[Xenomai-git] Philippe Gerum : drivers/gpio: add blocking read()

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: e171922a92f7fec3dc484286b4e8ea92860a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e171922a92f7fec3dc484286b4e8ea92860a

Author: Philippe Gerum 
Date:   Tue Jul 12 09:53:37 2016 +0200

drivers/gpio: add blocking read()

---

 include/rtdm/uapi/gpio.h|2 --
 kernel/drivers/gpio/gpio-core.c |7 +++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/rtdm/uapi/gpio.h b/include/rtdm/uapi/gpio.h
index 307e190..f846f48 100644
--- a/include/rtdm/uapi/gpio.h
+++ b/include/rtdm/uapi/gpio.h
@@ -18,8 +18,6 @@
 #ifndef _RTDM_UAPI_GPIO_H
 #define _RTDM_UAPI_GPIO_H
 
-#include 
-
 #define GPIO_RTIOC_DIR_OUT _IOW(RTDM_CLASS_GPIO, 0, int)
 #define GPIO_RTIOC_DIR_IN  _IO(RTDM_CLASS_GPIO, 1)
 #define GPIO_RTIOC_IRQEN   _IOW(RTDM_CLASS_GPIO, 2, int) /* GPIO 
trigger */
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 6c1f351..f18d571 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -155,6 +155,13 @@ static ssize_t gpio_pin_read_rt(struct rtdm_fd *fd,
return -EINVAL;
 
pin = container_of(dev, struct rtdm_gpio_pin, dev);
+
+   if (!(fd->oflags & O_NONBLOCK)) {
+   ret = rtdm_event_wait(>event);
+   if (ret)
+   return ret;
+   }
+
value = gpiod_get_raw_value(pin->desc);
ret = rtdm_safe_copy_to_user(fd, buf, , sizeof(value));



___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/boilerplate: bootstrap: fix Blackfin build

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 1d46b59eda88933b2af4d255b549bf7d2e6f5f1a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1d46b59eda88933b2af4d255b549bf7d2e6f5f1a

Author: Philippe Gerum 
Date:   Thu Jan 26 15:04:37 2017 +0100

lib/boilerplate: bootstrap: fix Blackfin build

The bootstrap module object is built in two forms:

- in static object form, to be glued to the main executable, which
  should include a wrapper interposing on the main() routine for
  auto-init purpose. Such wrapper is activated when symbol wrapping is
  enabled at link time (--wrap).

- in dynamic object form, to be included in a shared library target
  which enables the auto-init feature. This form should not include
  any wrapper to a main() routine - which does not exist - but only a
  constructor routine performing the inits.

The FDPIC format is used for building static and dynamic objects on
the Blackfin architecture, for which GCC defines __PIC__ in both
cases. This prevents from testing __PIC__ as a way to differentiate
between the static and dynamic versions of the bootstrap module on
Blackfin.

To fix this, set and check for a dedicated macro (__INTERCEPT_MAIN__)
to figure out whether the main() interception code should be present
in the relocatable object.

---

 lib/boilerplate/init/Makefile.am |1 +
 lib/boilerplate/init/bootstrap.c |   21 +++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib/boilerplate/init/Makefile.am b/lib/boilerplate/init/Makefile.am
index f41f419..702c900 100644
--- a/lib/boilerplate/init/Makefile.am
+++ b/lib/boilerplate/init/Makefile.am
@@ -3,6 +3,7 @@ noinst_LIBRARIES = libbootstrap.a
 libbootstrap_a_SOURCES = bootstrap.c
 
 libbootstrap_a_CPPFLAGS =  \
+   -D__INTERCEPT_MAIN__\
@XENO_USER_CFLAGS@  \
-I$(top_srcdir)/include \
-I$(top_srcdir)/lib
diff --git a/lib/boilerplate/init/bootstrap.c b/lib/boilerplate/init/bootstrap.c
index b0d4a12..118f861 100644
--- a/lib/boilerplate/init/bootstrap.c
+++ b/lib/boilerplate/init/bootstrap.c
@@ -28,7 +28,24 @@ static char *const *early_argv;
 
 const int xenomai_auto_bootstrap = 1;
 
-#ifndef __PIC__
+/*
+ * The bootstrap module object is built in two forms:
+ *
+ * - in static object form, to be glued to the main executable, which
+ *   should include a wrapper interposing on the main() routine for
+ *   auto-init purpose. Such wrapper is activated when symbol wrapping
+ *   is enabled at link time (--wrap).
+ *
+ * - in dynamic object form, to be included in a shared library target
+ *   which enables the auto-init feature. This form should not include
+ *   any wrapper to a main() routine - which does not exist - but only
+ *   a constructor routine performing the inits.
+ *
+ * The dedicated macro __INTERCEPT_MAIN__ tells us whether the main()
+ * interception code should be present in the relocatable object.
+ */
+
+#ifdef __INTERCEPT_MAIN__
 
 int __real_main(int argc, char *const argv[]);
 
@@ -45,7 +62,7 @@ int xenomai_main(int argc, char *const argv[])
return __real_main(argc, argv);
 }
 
-#endif /* !__PIC__ */
+#endif /* !__INTERCEPT_MAIN__ */
 
 __bootstrap_ctor static void xenomai_bootstrap(void)
 {


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/spi: introduce real-time SPI support

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: b7e3bd434ff00403bfe971c531c467e42502386f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b7e3bd434ff00403bfe971c531c467e42502386f

Author: Philippe Gerum 
Date:   Fri Jun 17 16:28:25 2016 +0200

drivers/spi: introduce real-time SPI support

---

 include/rtdm/Makefile.am   |1 +
 include/rtdm/spi.h |   24 ++
 include/rtdm/uapi/Makefile.am  |1 +
 include/rtdm/uapi/rtdm.h   |9 +-
 include/rtdm/uapi/spi.h|   40 +++
 kernel/drivers/Kconfig |1 +
 kernel/drivers/Makefile|2 +-
 kernel/drivers/gpio/gpio-bcm2835.c |   18 +-
 kernel/drivers/spi/Kconfig |   20 ++
 kernel/drivers/spi/Makefile|8 +
 kernel/drivers/spi/spi-bcm2835.c   |  691 
 kernel/drivers/spi/spi-device.c|  180 ++
 kernel/drivers/spi/spi-device.h|   53 +++
 kernel/drivers/spi/spi-master.c|  423 ++
 kernel/drivers/spi/spi-master.h|   81 +
 15 files changed, 1535 insertions(+), 17 deletions(-)

diff --git a/include/rtdm/Makefile.am b/include/rtdm/Makefile.am
index c837a05..9198595 100644
--- a/include/rtdm/Makefile.am
+++ b/include/rtdm/Makefile.am
@@ -10,6 +10,7 @@ includesub_HEADERS += \
gpio.h  \
ipc.h   \
serial.h\
+   spi.h   \
testing.h   \
udd.h
 endif
diff --git a/include/rtdm/spi.h b/include/rtdm/spi.h
new file mode 100644
index 000..339a862
--- /dev/null
+++ b/include/rtdm/spi.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2016 Philippe Gerum 
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+#ifndef _RTDM_SPI_H
+#define _RTDM_SPI_H
+
+#include 
+#include 
+
+#endif /* !_RTDM_SPI_H */
diff --git a/include/rtdm/uapi/Makefile.am b/include/rtdm/uapi/Makefile.am
index c288ff9..fec15db 100644
--- a/include/rtdm/uapi/Makefile.am
+++ b/include/rtdm/uapi/Makefile.am
@@ -10,6 +10,7 @@ includesub_HEADERS += \
gpio.h  \
ipc.h   \
serial.h\
+   spi.h   \
testing.h   \
udd.h
 endif
diff --git a/include/rtdm/uapi/rtdm.h b/include/rtdm/uapi/rtdm.h
index c49378c..ee6de65 100644
--- a/include/rtdm/uapi/rtdm.h
+++ b/include/rtdm/uapi/rtdm.h
@@ -80,13 +80,8 @@ typedef int64_t nanosecs_rel_t;
 #define RTDM_CLASS_UDD 9
 #define RTDM_CLASS_MEMORY  10
 #define RTDM_CLASS_GPIO11
-/*
-#define RTDM_CLASS_USB ?
-#define RTDM_CLASS_FIREWIRE?
-#define RTDM_CLASS_INTERBUS?
-#define RTDM_CLASS_PROFIBUS?
-#define ...
-*/
+#define RTDM_CLASS_SPI 12
+
 #define RTDM_CLASS_MISC223
 #define RTDM_CLASS_EXPERIMENTAL224
 #define RTDM_CLASS_MAX 255
diff --git a/include/rtdm/uapi/spi.h b/include/rtdm/uapi/spi.h
new file mode 100644
index 000..45bc92d
--- /dev/null
+++ b/include/rtdm/uapi/spi.h
@@ -0,0 +1,40 @@
+/**
+ * @note Copyright (C) 2016 Philippe Gerum 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#ifndef _RTDM_UAPI_SPI_H
+#define _RTDM_UAPI_SPI_H
+
+#include 
+
+struct rtdm_spi_config {
+   __u32 speed_hz;
+   __u16 mode;
+   __u8 bits_per_word;
+};
+
+struct rtdm_spi_iobufs {
+   __u32 io_len;
+   __u32 i_offset;
+   __u32 o_offset;
+};
+
+#define SPI_RTIOC_SET_CONFIG   _IOW(RTDM_CLASS_SPI, 0, struct 
rtdm_spi_config)
+#define 

[Xenomai-git] Ronny Meeus : boilerplate: solve compiler warning when libgen.h is included

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 12fa18f4267cc67882d477b282eb72b2daa5c193
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=12fa18f4267cc67882d477b282eb72b2daa5c193

Author: Ronny Meeus 
Date:   Tue Nov 29 14:26:00 2016 +0100

boilerplate: solve compiler warning when libgen.h is included

In boilerplate function 'get_program_name', basename is used.

When libgen.h is included in your program, the basename gets the POSIX
version (no const char*, see 'man basename'): char *basename(char
*path);

This results in the following compiler warning:
boilerplate/setup.h: In function 'const char* get_program_name()':
boilerplate/setup.h:107: error: invalid conversion from 'const char*' to 'char*'
boilerplate/setup.h:107: error:   initializing argument 1 of 'char* 
__xpg_basename(char*)'

Test application:

int main(int argc, char * const argv[])
{
  return 0;
}

When the libgen.h is not included, the warning is not seen.

This patch solve the above issue by moving the implementation to setup.c
instead of using an inline function.

---

 include/boilerplate/setup.h |5 +
 lib/boilerplate/setup.c |5 +
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/boilerplate/setup.h b/include/boilerplate/setup.h
index 5a18f6a..374758b 100644
--- a/include/boilerplate/setup.h
+++ b/include/boilerplate/setup.h
@@ -102,10 +102,7 @@ extern int __config_done;
 
 extern struct base_setup_data __base_setup_data;
 
-static inline const char *get_program_name(void)
-{
-   return basename(__base_setup_data.arg0 ?: "program");
-}
+const char *get_program_name(void);
 
 void __trace_me(const char *fmt, ...);
 
diff --git a/lib/boilerplate/setup.c b/lib/boilerplate/setup.c
index dbeb5e1..f1760e6 100644
--- a/lib/boilerplate/setup.c
+++ b/lib/boilerplate/setup.c
@@ -644,3 +644,8 @@ void __register_setup_call(struct setup_descriptor *p, int 
id)
}
pvlist_prepend(>__reserved.next, _list);
 }
+
+const char *get_program_name(void)
+{
+   return basename(__base_setup_data.arg0 ?: "program");
+}


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Ronny Meeus : boilerplate/tlsf: limit memory usage to the specified size

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: e0e6ae76230e283e81bd0e80ea87dd6612c63a1c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e0e6ae76230e283e81bd0e80ea87dd6612c63a1c

Author: Ronny Meeus 
Date:   Thu Dec 15 12:45:00 2016 +0100

boilerplate/tlsf: limit memory usage to the specified size

Before this patch the system memory pool's (tlsf variant) behavior was
to grow in case allocations were done when depleted. This is a
contradiction with the expected behavior (see mem-pool-size tunable
documentation). When the pool is depleted, an error should be retuned
instead of growing the pool.

This patch solves this bug.

---

 lib/boilerplate/tlsf/tlsf.c |   18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/lib/boilerplate/tlsf/tlsf.c b/lib/boilerplate/tlsf/tlsf.c
index 207de21..8ee9405 100644
--- a/lib/boilerplate/tlsf/tlsf.c
+++ b/lib/boilerplate/tlsf/tlsf.c
@@ -625,6 +625,7 @@ void *tlsf_malloc(size_t size)
void *area;
 
area_size = sizeof(tlsf_t) + BHDR_OVERHEAD * 8; /* Just a safety 
constant */
+   area_size += size;
area_size = (area_size > DEFAULT_AREA_SIZE) ? area_size : 
DEFAULT_AREA_SIZE;
area = get_new_area(_size);
if (area == ((void *) ~0))
@@ -709,23 +710,6 @@ void *malloc_ex(size_t size, void *mem_pool)
 /* Searching a free block, recall that this function changes the values of 
fl and sl,
so they are not longer valid when the function fails */
 b = FIND_SUITABLE_BLOCK(tlsf, , );
-#if USE_MMAP || USE_SBRK
-if (!b && mem_pool == mp) {/* Don't grow private pools */
-   size_t area_size;
-   void *area;
-   /* Growing the pool size when needed */
-   area_size = size + BHDR_OVERHEAD * 8;   /* size plus enough room for 
the requered headers. */
-   area_size = (area_size > DEFAULT_AREA_SIZE) ? area_size : 
DEFAULT_AREA_SIZE;
-   area = get_new_area(_size);/* Call sbrk or mmap */
-   if (area == ((void *) ~0))
-   return NULL;/* Not enough system memory */
-   add_new_area(area, area_size, mem_pool);
-   /* Rounding up the requested size and calculating fl and sl */
-   MAPPING_SEARCH(, , );
-   /* Searching a free block */
-   b = FIND_SUITABLE_BLOCK(tlsf, , );
-}
-#endif
 if (!b)
return NULL;/* Not found */
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: auto-release pin upon close()

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 261d1e84678900e04db56f71e7930fea0e36970f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=261d1e84678900e04db56f71e7930fea0e36970f

Author: Philippe Gerum 
Date:   Tue Dec 27 15:37:06 2016 +0100

drivers/gpio: auto-release pin upon close()

---

 kernel/drivers/gpio/gpio-core.c |   42 +++
 1 file changed, 38 insertions(+), 4 deletions(-)

diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 5c08355..c310a96 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -33,6 +33,10 @@ struct rtdm_gpio_pin {
struct gpio_desc *desc;
 };
 
+struct rtdm_gpio_chan {
+   bool requested;
+};
+
 static int gpio_pin_interrupt(rtdm_irq_t *irqh)
 {
struct rtdm_gpio_pin *pin;
@@ -45,6 +49,7 @@ static int gpio_pin_interrupt(rtdm_irq_t *irqh)
 }
 
 static int request_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin,
+   struct rtdm_gpio_chan *chan,
int trigger)
 {
static const int trigger_flags[] = {
@@ -92,6 +97,8 @@ static int request_gpio_irq(unsigned int gpio, struct 
rtdm_gpio_pin *pin,
goto fail;
}
 
+   chan->requested = true;
+   
rtdm_irq_enable(>irqh);
 
return 0;
@@ -101,15 +108,18 @@ fail:
return ret;
 }
 
-static void release_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin)
+static void release_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin,
+struct rtdm_gpio_chan *chan)
 {
rtdm_irq_free(>irqh);
gpio_free(gpio);
+   chan->requested = false;
 }
 
 static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd,
  unsigned int request, void *arg)
 {
+   struct rtdm_gpio_chan *chan = rtdm_fd_to_private(fd);
struct rtdm_device *dev = rtdm_fd_device(fd);
unsigned int gpio = rtdm_fd_minor(fd);
int ret = 0, val, trigger;
@@ -128,14 +138,16 @@ static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd,
ret = gpio_direction_input(gpio);
break;
case GPIO_RTIOC_IRQEN:
+   if (chan->requested)
+   return -EBUSY;
ret = rtdm_safe_copy_from_user(fd, ,
   arg, sizeof(trigger));
if (ret)
return ret;
-   ret = request_gpio_irq(gpio, pin, trigger);
+   ret = request_gpio_irq(gpio, pin, chan, trigger);
break;
case GPIO_RTIOC_IRQDIS:
-   release_gpio_irq(gpio, pin);
+   release_gpio_irq(gpio, pin, chan);
break;
default:
return -EINVAL;
@@ -147,6 +159,7 @@ static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd,
 static ssize_t gpio_pin_read_rt(struct rtdm_fd *fd,
void __user *buf, size_t len)
 {
+   struct rtdm_gpio_chan *chan = rtdm_fd_to_private(fd);
struct rtdm_device *dev = rtdm_fd_device(fd);
struct rtdm_gpio_pin *pin;
int value, ret;
@@ -154,6 +167,9 @@ static ssize_t gpio_pin_read_rt(struct rtdm_fd *fd,
if (len < sizeof(value))
return -EINVAL;
 
+   if (!chan->requested)
+   return -EAGAIN;
+
pin = container_of(dev, struct rtdm_gpio_pin, dev);
 
if (!(fd->oflags & O_NONBLOCK)) {
@@ -191,14 +207,31 @@ static ssize_t gpio_pin_write_rt(struct rtdm_fd *fd,
 static int gpio_pin_select(struct rtdm_fd *fd, struct xnselector *selector,
   unsigned int type, unsigned int index)
 {
+   struct rtdm_gpio_chan *chan = rtdm_fd_to_private(fd);
struct rtdm_device *dev = rtdm_fd_device(fd);
struct rtdm_gpio_pin *pin;
 
+   if (!chan->requested)
+   return -EAGAIN;
+
pin = container_of(dev, struct rtdm_gpio_pin, dev);
 
return rtdm_event_select(>event, selector, type, index);
 }
 
+static void gpio_pin_close(struct rtdm_fd *fd)
+{
+   struct rtdm_gpio_chan *chan = rtdm_fd_to_private(fd);
+   struct rtdm_device *dev = rtdm_fd_device(fd);
+   unsigned int gpio = rtdm_fd_minor(fd);
+   struct rtdm_gpio_pin *pin;
+
+   if (chan->requested) {
+   pin = container_of(dev, struct rtdm_gpio_pin, dev);
+   release_gpio_irq(gpio, pin, chan);
+   }
+}
+
 static void delete_pin_devices(struct rtdm_gpio_chip *rgc)
 {
struct rtdm_gpio_pin *pin, *n;
@@ -304,8 +337,9 @@ int rtdm_gpiochip_add(struct rtdm_gpio_chip *rgc,
rgc->driver.device_flags = RTDM_NAMED_DEVICE|RTDM_FIXED_MINOR;
rgc->driver.base_minor = gc->base;
rgc->driver.device_count = gc->ngpio;
-   rgc->driver.context_size = 0;
+   rgc->driver.context_size = sizeof(struct rtdm_gpio_chan);
rgc->driver.ops = (struct rtdm_fd_ops){
+   .close  =

[Xenomai-git] Philippe Gerum : testsuite/spitest: add SPI test suite

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 789773177b7d124dac8c652f53a973cf71ee2b2a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=789773177b7d124dac8c652f53a973cf71ee2b2a

Author: Philippe Gerum 
Date:   Sat Jun 25 18:55:14 2016 +0200

testsuite/spitest: add SPI test suite

---

 configure.ac  |1 +
 testsuite/Makefile.am |2 +
 testsuite/gpiotest/gpiotest.c |   31 +--
 testsuite/spitest/Makefile.am |   19 ++
 testsuite/spitest/spitest.c   |  451 +
 5 files changed, 491 insertions(+), 13 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1f3c4fe..1308f8b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -885,6 +885,7 @@ AC_CONFIG_FILES([ \
testsuite/latency/Makefile \
testsuite/switchtest/Makefile \
testsuite/gpiotest/Makefile \
+   testsuite/spitest/Makefile \
testsuite/smokey/Makefile \
testsuite/smokey/arith/Makefile \
testsuite/smokey/sched-quota/Makefile \
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index c345472..76d108e 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -5,6 +5,7 @@ if XENO_COBALT
 SUBDIRS += \
clocktest   \
gpiotest\
+   spitest \
switchtest  \
xeno-test
 endif
@@ -14,5 +15,6 @@ DIST_SUBDIRS =\
gpiotest\
latency \
smokey  \
+   spitest \
switchtest  \
xeno-test
diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index 65949ee..0bdd39f 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -1,19 +1,24 @@
 /*
- * Copyright (C) 2016 Philippe Gerum .
+ * Copyright (C) 2016 Philippe Gerum 
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *  
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #include 
 #include 
diff --git a/testsuite/spitest/Makefile.am b/testsuite/spitest/Makefile.am
new file mode 100644
index 000..ccdd392
--- /dev/null
+++ b/testsuite/spitest/Makefile.am
@@ -0,0 +1,19 @@
+testdir = @XENO_TEST_DIR@
+
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
+test_PROGRAMS = spitest
+
+spitest_SOURCES = spitest.c
+
+spitest_CPPFLAGS = \
+   $(XENO_USER_CFLAGS) \
+   -I$(top_srcdir)/include
+
+spitest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS)
+
+spitest_LDADD =\
+   ../../lib/smokey/libsmokey.la   \
+   ../../lib/@XENO_CORE_LIB@   \
+@XENO_USER_LDADD@  \
+   -lpthread -lrt
diff --git a/testsuite/spitest/spitest.c b/testsuite/spitest/spitest.c
new file mode 100644
index 000..0609bad
--- /dev/null
+++ b/testsuite/spitest/spitest.c
@@ -0,0 +1,451 @@
+/*
+ * Copyright (C) 2016 Philippe Gerum 
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the 

[Xenomai-git] Philippe Gerum : drivers/gpio: rename after the SoC

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: b6e0ca8e8b43a052e78b440cce91cccf069b5943
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b6e0ca8e8b43a052e78b440cce91cccf069b5943

Author: Philippe Gerum 
Date:   Thu Jun 23 14:31:10 2016 +0200

drivers/gpio: rename after the SoC

---

 kernel/drivers/gpio/Kconfig|8 
 kernel/drivers/gpio/Makefile   |2 +-
 kernel/drivers/gpio/{gpio-bcm2708.c => gpio-bcm2835.c} |0
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/drivers/gpio/Kconfig b/kernel/drivers/gpio/Kconfig
index 618f23a..850127f 100644
--- a/kernel/drivers/gpio/Kconfig
+++ b/kernel/drivers/gpio/Kconfig
@@ -4,14 +4,14 @@ config XENO_DRIVERS_GPIO
tristate
depends on GPIOLIB
 
-config XENO_DRIVERS_GPIO_BCM2708
+config XENO_DRIVERS_GPIO_BCM2835
depends on MACH_BCM2708
select XENO_DRIVERS_GPIO
-   tristate "Support for BCM2708 GPIOs"
+   tristate "Support for BCM2835 GPIOs"
help
 
-   Suitable for the GPIO controller present on Broadcom's BCM2708
-   chip family.
+   Enables support for the GPIO controller available from
+   Broadcom's BCM2835 SoC.
 
 config XENO_DRIVERS_GPIO_MXC
depends on GPIO_MXC
diff --git a/kernel/drivers/gpio/Makefile b/kernel/drivers/gpio/Makefile
index 5d194a1..e237279 100644
--- a/kernel/drivers/gpio/Makefile
+++ b/kernel/drivers/gpio/Makefile
@@ -3,5 +3,5 @@ obj-$(CONFIG_XENO_DRIVERS_GPIO) += xeno_gpio.o
 
 xeno_gpio-y := gpio-core.o
 
-xeno_gpio-$(CONFIG_XENO_DRIVERS_GPIO_BCM2708) += gpio-bcm2708.o
+xeno_gpio-$(CONFIG_XENO_DRIVERS_GPIO_BCM2835) += gpio-bcm2835.o
 xeno_gpio-$(CONFIG_XENO_DRIVERS_GPIO_MXC) += gpio-mxc.o
diff --git a/kernel/drivers/gpio/gpio-bcm2708.c 
b/kernel/drivers/gpio/gpio-bcm2835.c
similarity index 100%
rename from kernel/drivers/gpio/gpio-bcm2708.c
rename to kernel/drivers/gpio/gpio-bcm2835.c


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: allow setting trigger type w/ GPIO_RTIOC_IRQEN

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: a847734467bde3a979bd0916c57c4375b34fbaa0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a847734467bde3a979bd0916c57c4375b34fbaa0

Author: Philippe Gerum 
Date:   Tue Jun 28 12:16:02 2016 +0200

drivers/gpio: allow setting trigger type w/ GPIO_RTIOC_IRQEN

---

 include/rtdm/uapi/gpio.h|9 -
 kernel/drivers/gpio/gpio-core.c |   31 +++
 testsuite/gpiotest/gpiotest.c   |   34 +++---
 3 files changed, 66 insertions(+), 8 deletions(-)

diff --git a/include/rtdm/uapi/gpio.h b/include/rtdm/uapi/gpio.h
index b0d4899..307e190 100644
--- a/include/rtdm/uapi/gpio.h
+++ b/include/rtdm/uapi/gpio.h
@@ -22,7 +22,14 @@
 
 #define GPIO_RTIOC_DIR_OUT _IOW(RTDM_CLASS_GPIO, 0, int)
 #define GPIO_RTIOC_DIR_IN  _IO(RTDM_CLASS_GPIO, 1)
-#define GPIO_RTIOC_IRQEN   _IO(RTDM_CLASS_GPIO, 2)
+#define GPIO_RTIOC_IRQEN   _IOW(RTDM_CLASS_GPIO, 2, int) /* GPIO 
trigger */
 #define GPIO_RTIOC_IRQDIS  _IO(RTDM_CLASS_GPIO, 3)
 
+#define GPIO_TRIGGER_NONE  0x0 /* unspecified */
+#define GPIO_TRIGGER_EDGE_RISING   0x1
+#define GPIO_TRIGGER_EDGE_FALLING  0x2
+#define GPIO_TRIGGER_LEVEL_HIGH0x4
+#define GPIO_TRIGGER_LEVEL_LOW 0x8
+#define GPIO_TRIGGER_MASK  0xf
+
 #endif /* !_RTDM_UAPI_GPIO_H */
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index e8a7ba1..6c1f351 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -44,10 +44,20 @@ static int gpio_pin_interrupt(rtdm_irq_t *irqh)
return RTDM_IRQ_HANDLED;
 }
 
-static int request_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin)
+static int request_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin,
+   int trigger)
 {
+   static const int trigger_flags[] = {
+   IRQ_TYPE_EDGE_RISING,
+   IRQ_TYPE_EDGE_FALLING,
+   IRQ_TYPE_LEVEL_HIGH,
+   IRQ_TYPE_LEVEL_LOW,
+   };
+   int irq_trigger, ret;
unsigned int irq;
-   int ret;
+
+   if (trigger & ~GPIO_TRIGGER_MASK)
+   return -EINVAL;
 
ret = gpio_request(gpio, pin->name);
if (ret) {
@@ -66,6 +76,15 @@ static int request_gpio_irq(unsigned int gpio, struct 
rtdm_gpio_pin *pin)
 
rtdm_event_clear(>event);
irq = gpio_to_irq(gpio);
+   /*
+* Assumes GPIO_TRIGGER_xx values are forming a continuous
+* sequence of bits starting at bit #0.
+*/
+   if (trigger) {
+   irq_trigger = trigger_flags[ffs(trigger) - 1];
+   irq_set_irq_type(irq, irq_trigger);
+   }
+   
ret = rtdm_irq_request(>irqh, irq, gpio_pin_interrupt,
   0, pin->name, pin);
if (ret) {
@@ -93,8 +112,8 @@ static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd,
 {
struct rtdm_device *dev = rtdm_fd_device(fd);
unsigned int gpio = rtdm_fd_minor(fd);
+   int ret = 0, val, trigger;
struct rtdm_gpio_pin *pin;
-   int ret = 0, val;

pin = container_of(dev, struct rtdm_gpio_pin, dev);
 
@@ -109,7 +128,11 @@ static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd,
ret = gpio_direction_input(gpio);
break;
case GPIO_RTIOC_IRQEN:
-   ret = request_gpio_irq(gpio, pin);
+   ret = rtdm_safe_copy_from_user(fd, ,
+  arg, sizeof(trigger));
+   if (ret)
+   return ret;
+   ret = request_gpio_irq(gpio, pin, trigger);
break;
case GPIO_RTIOC_IRQDIS:
release_gpio_irq(gpio, pin);
diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index 0bdd39f..6e9ce5b 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -55,8 +55,21 @@ smokey_test_plugin(write_value,
 
 static int run_interrupt(struct smokey_test *t, int argc, char *const argv[])
 {
-   const char *device = NULL;
-   int fd, ret;
+   static struct {
+   const char *name;
+   int flag;
+   } trigger_types[] = {
+   { .name = "edge", .flag = GPIO_TRIGGER_EDGE_RISING },
+   { .name = "edge-rising", .flag = GPIO_TRIGGER_EDGE_RISING },
+   { .name = "edge-falling", .flag = GPIO_TRIGGER_EDGE_FALLING },
+   { .name = "edge-both", .flag = 
GPIO_TRIGGER_EDGE_FALLING|GPIO_TRIGGER_EDGE_RISING },
+   { .name = "level", .flag = GPIO_TRIGGER_LEVEL_LOW },
+   { .name = "level-low", .flag = GPIO_TRIGGER_LEVEL_LOW },
+   { .name = "level-high", .flag = GPIO_TRIGGER_LEVEL_HIGH },
+   { NULL, 0 },
+   };
+   const char *device = NULL, *trigname;
+   int fd, ret, trigger, n;
fd_set 

[Xenomai-git] Philippe Gerum : drivers/gpio: add debugging option

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 657763dd956f9fecc1518f55d9c263366e46c8dc
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=657763dd956f9fecc1518f55d9c263366e46c8dc

Author: Philippe Gerum 
Date:   Thu Jun 23 11:57:50 2016 +0200

drivers/gpio: add debugging option

---

 kernel/drivers/gpio/Kconfig |6 +-
 kernel/drivers/gpio/gpio-core.c |3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/drivers/gpio/Kconfig b/kernel/drivers/gpio/Kconfig
index 8997963..618f23a 100644
--- a/kernel/drivers/gpio/Kconfig
+++ b/kernel/drivers/gpio/Kconfig
@@ -19,7 +19,11 @@ config XENO_DRIVERS_GPIO_MXC
tristate "Support for MXC GPIOs"
help
 
-   Suitable for the GPIO controller available with
+   Suitable for the GPIO controller available from
Freescale/NXP's MXC architecture.
 
+config XENO_DRIVERS_GPIO_DEBUG
+   depends on XENO_DRIVERS_GPIO
+   bool "Enable GPIO core debugging features"
+   
 endmenu
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index e8a7ba1..d9863d9 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -15,6 +15,9 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
+#ifdef CONFIG_XENO_DRIVERS_GPIO_DEBUG
+#define DEBUG
+#endif
 #include 
 #include 
 #include 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/gpio: illustrate select() + read() combination

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 322f91153bb8ce8710837722ae24d8376d7cad6c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=322f91153bb8ce8710837722ae24d8376d7cad6c

Author: Philippe Gerum 
Date:   Tue Jul 12 10:03:48 2016 +0200

testsuite/gpio: illustrate select() + read() combination

---

 testsuite/gpiotest/gpiotest.c |   24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index 6e9ce5b..aeb16af 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -32,6 +32,7 @@
 smokey_test_plugin(interrupt,
   SMOKEY_ARGLIST(
   SMOKEY_STRING(device),
+  SMOKEY_BOOL(select),
   ),
"Wait for interrupts from a GPIO pin.\n"
"\tdevice=."
@@ -68,8 +69,8 @@ static int run_interrupt(struct smokey_test *t, int argc, 
char *const argv[])
{ .name = "level-high", .flag = GPIO_TRIGGER_LEVEL_HIGH },
{ NULL, 0 },
};
+   int do_select = 0, fd, ret, trigger, n, value;
const char *device = NULL, *trigname;
-   int fd, ret, trigger, n;
fd_set set;

smokey_parse_args(t, argc, argv);
@@ -88,6 +89,9 @@ static int run_interrupt(struct smokey_test *t, int argc, 
char *const argv[])
return ret;
}
 
+   if (SMOKEY_ARG_ISSET(interrupt, select))
+   do_select = SMOKEY_ARG_BOOL(interrupt, select);
+
trigger = GPIO_TRIGGER_NONE;
if (SMOKEY_ARG_ISSET(interrupt, trigger)) {
trigname = SMOKEY_ARG_STRING(interrupt, trigger);
@@ -115,13 +119,23 @@ static int run_interrupt(struct smokey_test *t, int argc, 
char *const argv[])
FD_SET(fd, );

for (;;) {
-   ret = select(fd + 1, , NULL, NULL, NULL);
+   if (do_select) {
+   ret = select(fd + 1, , NULL, NULL, NULL);
+   if (ret < 0) {
+   ret = -errno;
+   warning("failed listening to %s [%s]",
+   device, symerror(ret));
+   return ret;
+   }
+   }
+   ret = read(fd, , sizeof(value));
if (ret < 0) {
ret = -errno;
-   warning("failed listening to %s [%s]",
+   warning("failed reading from %s [%s]",
device, symerror(ret));
+   return ret;
}
-   printf("kick %d!\n", ret);
+   printf("received irq, GPIO state=%d\n", value);
}
 
close(fd);
@@ -142,7 +156,7 @@ static int run_read_value(struct smokey_test *t, int argc, 
char *const argv[])
}
 
device = SMOKEY_ARG_STRING(read_value, device);
-   fd = open(device, O_RDONLY);
+   fd = open(device, O_RDONLY|O_NONBLOCK);
if (fd < 0) {
ret = -errno;
warning("cannot open device %s [%s]",


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Jan Kiszka : cobalt/kernel: Allow to restart clock_nanosleep and select after signal processing

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 36132cdb21cd0f8325ca9ef5a3299fecaf2ddfcc
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=36132cdb21cd0f8325ca9ef5a3299fecaf2ddfcc

Author: Jan Kiszka 
Date:   Fri May 13 20:35:26 2016 +0200

cobalt/kernel: Allow to restart clock_nanosleep and select after signal 
processing

Only if a signal was actually delivered to a thread that was blocked on
sleep, [clock_]nanosleep or select, those calls should return -EINTR.
Otherwise, they should resume with the timeout, accordingly adjusted in
case of relative timeout. So far we returned -EINTR immediately which
particularly disturbed the debugging of applications (SIGSTOP/CONT
terminated those syscalls).

This approach reuses the Linux restart mechanism to find out if those
syscalls should be restarted or actually terminated after the signal
was handled: Linux sets current->restart_block.fn in case a termination
is required, unconditionally, thus also when the syscall did not return
ERESTART_RESTARTBLOCK. We also use the restart_block.nanosleep.expires
to transfer the remaining timeout to the restarted syscall.

We can't use the original restart mechanism of Linux because it directs
all ERESTART_RESTARTBLOCK through a special, Linux-only syscall. In our
case, we would have to migrate the caller in that context to primary in
order to resume the sleep, but this is not possible under Xenomai (we
need to migration from within the syscall hooks).

Signed-off-by: Jan Kiszka 

---

 include/cobalt/uapi/kernel/thread.h|1 +
 .../cobalt/include/asm-generic/xenomai/wrappers.h  |6 +++
 kernel/cobalt/posix/clock.c|   35 --
 kernel/cobalt/posix/internal.h |2 +
 kernel/cobalt/posix/io.c   |   39 
 kernel/cobalt/posix/syscall.c  |5 +++
 6 files changed, 78 insertions(+), 10 deletions(-)

diff --git a/include/cobalt/uapi/kernel/thread.h 
b/include/cobalt/uapi/kernel/thread.h
index 100ccee..cf2dfd3 100644
--- a/include/cobalt/uapi/kernel/thread.h
+++ b/include/cobalt/uapi/kernel/thread.h
@@ -77,6 +77,7 @@
 #define XNMOVED   0x0001 /**< CPU migration in primary mode occurred */
 #define XNLBALERT 0x0002 /**< Scheduler lock break alert (SIGDEBUG sent) */
 #define XNDESCENT 0x0004 /**< Adaptive transitioning to secondary mode */
+#define XNSYSRST  0x0008 /**< Thread awaiting syscall restart after signal 
*/
 
 /** @} */
 
diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index 060ce85..0f9ab14 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -133,4 +133,10 @@ devm_hwmon_device_register_with_groups(struct device *dev, 
const char *name,
 #error "Xenomai/cobalt requires Linux kernel 3.10 or above"
 #endif /* < 3.10 */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)
+#define cobalt_get_restart_block(p)(_thread_info(p)->restart_block)
+#else
+#define cobalt_get_restart_block(p)(&(p)->restart_block)
+#endif
+
 #endif /* _COBALT_ASM_GENERIC_WRAPPERS_H */
diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
index 8dab55b..d6a315b 100644
--- a/kernel/cobalt/posix/clock.c
+++ b/kernel/cobalt/posix/clock.c
@@ -236,8 +236,9 @@ int __cobalt_clock_nanosleep(clockid_t clock_id, int flags,
 const struct timespec *rqt,
 struct timespec *rmt)
 {
+   struct restart_block *restart;
struct xnthread *cur;
-   xnsticks_t rem;
+   xnsticks_t timeout, rem;
int ret = 0;
spl_t s;
 
@@ -259,12 +260,40 @@ int __cobalt_clock_nanosleep(clockid_t clock_id, int 
flags,
 
cur = xnthread_current();
 
+   if (xnthread_test_localinfo(cur, XNSYSRST)) {
+   xnthread_clear_localinfo(cur, XNSYSRST);
+
+   restart = cobalt_get_restart_block(current);
+
+   if (restart->fn != cobalt_restart_syscall_placeholder) {
+   if (rmt)
+   ns2ts(rmt, rem > 1 ? rem : 0);
+   return -EINTR;
+   }
+
+   timeout = restart->nanosleep.expires;
+   } else
+   timeout = ts2ns(rqt);
+
xnlock_get_irqsave(, s);
 
-   xnthread_suspend(cur, XNDELAY, ts2ns(rqt) + 1,
+   xnthread_suspend(cur, XNDELAY, timeout + 1,
 clock_flag(flags, clock_id), NULL);
 
if (xnthread_test_info(cur, XNBREAK)) {
+   if (signal_pending(current)) {
+   restart = cobalt_get_restart_block(current);
+   restart->nanosleep.expires =
+   (flags & TIMER_ABSTIME) ? timeout :
+   xntimer_get_timeout_stopped(>rtimer);
+   

[Xenomai-git] Henning Schild : scripts/xeno-config: apply the assert_nrt wrappers on all skins

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: ebc039b62c40e8fe9bac2f1892f630515f2f09de
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ebc039b62c40e8fe9bac2f1892f630515f2f09de

Author: Henning Schild 
Date:   Wed Jan 25 16:08:00 2017 +0100

scripts/xeno-config: apply the assert_nrt wrappers on all skins

There are basically two classes of wrappers. Those that actually change
the implementation, and those that just assert that certain calls are
not made from a realtime context. The latter are usefull for all skins
and should always be applied.

Signed-off-by: Henning Schild 

---

 configure.ac  |   12 +++-
 debian/libxenomai-dev.install |1 +
 lib/cobalt/Makefile.am|4 +++-
 lib/cobalt/assert.wrappers|2 ++
 lib/cobalt/cobalt.wrappers|2 --
 scripts/xeno-config-cobalt.in |4 ++--
 6 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1308f8b..83bc809 100644
--- a/configure.ac
+++ b/configure.ac
@@ -796,17 +796,19 @@ dnl Build wrapping information. XENO_POSIX_WRAPPERS lists 
all wrapping
 dnl directives in a format the linker understands, for building the
 dnl in-tree executables which require POSIX symbol wrapping.
 
+   assert_wrappers="$topdir/lib/cobalt/assert.wrappers"
cobalt_wrappers="$topdir/lib/cobalt/cobalt.wrappers"
if [[ $ac_cv_ld_file_option = yes ]]; then
-   XENO_POSIX_WRAPPERS="-Wl,@$cobalt_wrappers"
+   XENO_POSIX_WRAPPERS="-Wl,@$assert_wrappers -Wl,@$cobalt_wrappers"
else
-   XENO_POSIX_WRAPPERS=`while read wrap_option symbol ; do \
-   echo -n "-Wl,$wrap_option,$symbol " ; \
-   done < $cobalt_wrappers`
+   XENO_POSIX_WRAPPERS=`cat $assert_wrappers $cobalt_wrappers | \
+   while read wrap_option symbol ; do \
+   echo -n "-Wl,$wrap_option,$symbol " ; \
+   done`
fi
 
AC_SUBST(XENO_POSIX_WRAPPERS)
-   AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ["$cobalt_wrappers"])
+   AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ["$assert_wrappers 
$cobalt_wrappers"])
 fi
 
 dnl
diff --git a/debian/libxenomai-dev.install b/debian/libxenomai-dev.install
index 7b107cb..6d7eb7b 100644
--- a/debian/libxenomai-dev.install
+++ b/debian/libxenomai-dev.install
@@ -2,5 +2,6 @@ usr/include
 usr/lib/*.la
 usr/lib/*.a
 usr/lib/*.so
+usr/lib/assert.wrappers
 usr/lib/cobalt.wrappers
 usr/lib/dynlist.ld
diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 576122d..459b207 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -46,10 +46,12 @@ libcobalt_la_CPPFLAGS = \
 install-data-local:
$(mkinstalldirs) $(DESTDIR)$(libdir)
$(INSTALL_DATA) $(srcdir)/cobalt.wrappers $(DESTDIR)$(libdir)
+   $(INSTALL_DATA) $(srcdir)/assert.wrappers $(DESTDIR)$(libdir)
 
 uninstall-local:
$(RM) $(DESTDIR)$(libdir)/cobalt.wrappers
+   $(RM) $(DESTDIR)$(libdir)/assert.wrappers
 
-EXTRA_DIST = cobalt.wrappers
+EXTRA_DIST = cobalt.wrappers assert.wrappers
 
 SUBDIRS = arch
diff --git a/lib/cobalt/assert.wrappers b/lib/cobalt/assert.wrappers
new file mode 100644
index 000..7164858
--- /dev/null
+++ b/lib/cobalt/assert.wrappers
@@ -0,0 +1,2 @@
+--wrap malloc
+--wrap free
diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers
index 9480f34..0378abf 100644
--- a/lib/cobalt/cobalt.wrappers
+++ b/lib/cobalt/cobalt.wrappers
@@ -91,8 +91,6 @@
 --wrap fclose
 --wrap syslog
 --wrap vsyslog
---wrap malloc
---wrap free
 --wrap gettimeofday
 --wrap __vfprintf_chk
 --wrap __vprintf_chk
diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index d102d04..3e1f64c 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -235,8 +235,8 @@ if test x$do_ldflags = xy; then
echo "no API specified, missing --skin before --ldflags" 1>&2
exit 1
 fi
-ldflags=
-test x$compat = xy && ldflags="-ltrank "
+ldflags="`dump_wrappers assert.wrappers`"
+test x$compat = xy && ldflags="-ltrank $ldflags"
 copperplate=
 for skin in $skin_list; do
case "$skin" in


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/gpio: fix output value set with direction

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: d0647b6468052cc491ee3324109153ed17510bc0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d0647b6468052cc491ee3324109153ed17510bc0

Author: Philippe Gerum 
Date:   Tue Jul 12 10:03:48 2016 +0200

testsuite/gpio: fix output value set with direction

---

 testsuite/gpiotest/gpiotest.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index c6620e1..a845ef5 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -202,7 +202,8 @@ static int run_write_value(struct smokey_test *t, int argc, 
char *const argv[])
return ret;
}
 
-   if (!__T(ret, ioctl(fd, GPIO_RTIOC_DIR_OUT)))
+   value = 1;
+   if (!__T(ret, ioctl(fd, GPIO_RTIOC_DIR_OUT, )))
return ret;

ret = write(fd, , sizeof(value));


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/smokey: setsched: drop invalid test of pthread_setschedprio()

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 1f8cadb9ce402aadf61133e3930afb2090b5ce90
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1f8cadb9ce402aadf61133e3930afb2090b5ce90

Author: Philippe Gerum 
Date:   Thu Jan 26 15:44:46 2017 +0100

testsuite/smokey: setsched: drop invalid test of pthread_setschedprio()

pthread_setschedprio() is not part of the libcobalt interface. The
outcome of such test can only be wrong.

---

 testsuite/smokey/setsched/setsched.c |   17 -
 1 file changed, 17 deletions(-)

diff --git a/testsuite/smokey/setsched/setsched.c 
b/testsuite/smokey/setsched/setsched.c
index 359f190..f227f65 100644
--- a/testsuite/smokey/setsched/setsched.c
+++ b/testsuite/smokey/setsched/setsched.c
@@ -94,23 +94,6 @@ static void *thread_body(void *arg)
 
check_linux_schedparams(SCHED_FIFO, 2);
 
-   cobalt_thread_harden();
-
-   if (smokey_check_status(cobalt_thread_stat(thread_pid, )))
-   pthread_exit((void *)(long)-EINVAL);
-   msw = stats.msw;
-
-   if (smokey_check_status(pthread_setschedprio(pthread_self(), 3)))
-   pthread_exit((void *)(long)-EINVAL);
-
-   check_rt_schedparams(SCHED_FIFO, 3);
-
-   if (smokey_check_status(cobalt_thread_stat(thread_pid, )) ||
-   !smokey_assert(stats.msw == msw))
-   pthread_exit((void *)(long)-EINVAL);
-
-   check_linux_schedparams(SCHED_FIFO, 3);
-
return (void *)0L;
 }
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/spitest: fix x86_32 build

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 580ac2acd8951260ca842a79504ee5d20fe04f81
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=580ac2acd8951260ca842a79504ee5d20fe04f81

Author: Philippe Gerum 
Date:   Wed Dec 28 12:59:44 2016 +0100

testsuite/spitest: fix x86_32 build

---

 testsuite/spitest/spitest.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testsuite/spitest/spitest.c b/testsuite/spitest/spitest.c
index 40ef9a9..b25dc70 100644
--- a/testsuite/spitest/spitest.c
+++ b/testsuite/spitest/spitest.c
@@ -233,7 +233,7 @@ static void *display_thread(void *arg)
dt = now - start;
printf("RTT|  %.2ld:%.2ld:%.2ld  (%Ld us period)\n",
   dt / 3600, (dt / 60) % 60, dt % 60,
-  period_ns / 1000);
+  (long long)period_ns / 1000);
printf("RTH|%11s|%11s|%11s|%8s|%8s|%11s|%11s\n",
   "lat min", "lat avg",
   "lat max", "-overrun", "-errors",


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Henning Schild : lib/cobalt: wrap CXXABI One-time Constructor functions

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: be90f09cf277083ff7021b1f0f1a856c66c42b46
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=be90f09cf277083ff7021b1f0f1a856c66c42b46

Author: Henning Schild 
Date:   Wed Jan 25 16:08:00 2017 +0100

lib/cobalt: wrap CXXABI One-time Constructor functions

The implementation of these functions uses locks and has the potential
to trigger a SIGXCPU when contended. Wrap them with assert_nrt so they
reliably cause a switch when used in the rt context.

Signed-off-by: Henning Schild 

---

 lib/cobalt/assert.wrappers  |3 +++
 lib/cobalt/assert_context.c |   19 +++
 lib/cobalt/internal.h   |   12 
 lib/cobalt/wrappers.c   |   37 +
 4 files changed, 71 insertions(+)

diff --git a/lib/cobalt/assert.wrappers b/lib/cobalt/assert.wrappers
index 7164858..65320ab 100644
--- a/lib/cobalt/assert.wrappers
+++ b/lib/cobalt/assert.wrappers
@@ -1,2 +1,5 @@
 --wrap malloc
 --wrap free
+--wrap __cxa_guard_acquire
+--wrap __cxa_guard_release
+--wrap __cxa_guard_abort
diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
index 2085953..fd18d6b 100644
--- a/lib/cobalt/assert_context.c
+++ b/lib/cobalt/assert_context.c
@@ -66,3 +66,22 @@ COBALT_IMPL(void, free, (void *ptr))
assert_nrt();
__STD(free(ptr));
 }
+
+/* CXXABI 3.3.2 One-time Construction API */
+COBALT_IMPL(int, __cxa_guard_acquire, (__guard *g))
+{
+   assert_nrt();
+   return __STD(__cxa_guard_acquire(g));
+}
+
+COBALT_IMPL(void, __cxa_guard_release, (__guard *g))
+{
+   assert_nrt();
+   __STD(__cxa_guard_release(g));
+}
+
+COBALT_IMPL(void, __cxa_guard_abort, (__guard *g))
+{
+   assert_nrt();
+   __STD(__cxa_guard_abort(g));
+}
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index fee3fe1..9f58c6a 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -73,4 +73,16 @@ void cobalt_check_features(struct cobalt_featinfo *finfo);
 
 extern struct sigaction __cobalt_orig_sigdebug;
 
+#ifdef __ARM_EABI__
+typedef uint32_t __guard;
+#else
+typedef uint64_t __guard;
+#endif
+int __real___cxa_guard_acquire(__guard*);
+void __real___cxa_guard_release(__guard*);
+void __real___cxa_guard_abort(__guard*);
+int __cxa_guard_acquire(__guard*);
+void __cxa_guard_release(__guard*);
+void __cxa_guard_abort(__guard*);
+
 #endif /* _LIB_COBALT_INTERNAL_H */
diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index 09c74e5..65dc3bd 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* sched */
 __weak
@@ -532,3 +533,39 @@ unsigned int __real_sleep(unsigned int seconds)
 {
return sleep(seconds);
 }
+
+__weak
+int __real___cxa_guard_acquire(__guard *g)
+{
+   return __cxa_guard_acquire(g);
+}
+
+__weak
+void __real___cxa_guard_release(__guard *g)
+{
+   return __cxa_guard_release(g);
+}
+
+__weak
+void __real___cxa_guard_abort(__guard *g)
+{
+   return __cxa_guard_abort(g);
+}
+
+__weak
+int __cxa_guard_acquire(__guard *g)
+{
+   return 0;
+}
+
+__weak
+void __cxa_guard_release(__guard *g)
+{
+   return;
+}
+
+__weak
+void __cxa_guard_abort(__guard *g)
+{
+   return;
+}


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : lib/smokey: fix documentation

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 559f1dc7dc80be5566452b51459d1241f434a381
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=559f1dc7dc80be5566452b51459d1241f434a381

Author: Philippe Gerum 
Date:   Thu Jan 12 10:34:52 2017 +0100

lib/smokey: fix documentation

---

 lib/smokey/init.c |   26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/lib/smokey/init.c b/lib/smokey/init.c
index b69f24c..9df9a55 100644
--- a/lib/smokey/init.c
+++ b/lib/smokey/init.c
@@ -91,13 +91,11 @@
  *
  * static int run_foo(struct smokey_test *t, int argc, char *const argv[])
  * {
+ *  int i_arg = 0, nargs;
  *  char *s_arg = NULL;
  *  bool b_arg = false;
- *  int i_arg = 0, ret;
  *
- * ret = smokey_parse_args(t, argc, argv);
- *  if (ret)
- *  return ret;
+ * nargs = smokey_parse_args(t, argc, argv);
  *
  * if (SMOKEY_ARG_ISSET(foo, some_integer))
  * i_arg = SMOKEY_ARG_INT(foo, some_integer);
@@ -124,15 +122,17 @@
  * where @a name should match one of the declarators.  Before the
  * test-specific arguments can be accessed, a call to
  * smokey_parse_args() must be issued by the test code, passing the
- * parameters received in the run handler.
- *
- * Once smokey_parse_args() has returned, each argument can be checked
- * individually for presence. If a valid argument was matched on the
- * command line, SMOKEY_ARG_ISSET(test_name, arg_name) returns
- * non-zero. In the latter case, its value can be retrieved by a
- * similar call to SMOKEY_ARG_INT(test_name, arg_name),
- * SMOKEY_ARG_STRING(test_name, arg_name) or
- * SMOKEY_ARG_BOOL(test_name, arg_name).
+ * parameters received in the run handler. This routine returns the
+ * number of arguments found on the command line matching the
+ * an entry in SMOKEY_ARGLIST().
+ *
+ * Once smokey_parse_args() has returned with a non-zero value, each
+ * argument can be checked individually for presence. If a valid
+ * argument was matched on the command line,
+ * SMOKEY_ARG_ISSET(test_name, arg_name) returns non-zero. In the
+ * latter case, its value can be retrieved by a similar call to
+ * SMOKEY_ARG_INT(test_name, arg_name), SMOKEY_ARG_STRING(test_name,
+ * arg_name) or SMOKEY_ARG_BOOL(test_name, arg_name).
  *
  * In the above example, passing "some_integer=3" on the command line of
  * any program implementing such Smokey-based test would cause the


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/spi: master: clear device class upon removal

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: cc6f7533e468f874834bb0e78b3b0765b33cd706
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cc6f7533e468f874834bb0e78b3b0765b33cd706

Author: Philippe Gerum 
Date:   Tue Nov 29 12:21:32 2016 +0100

drivers/spi: master: clear device class upon removal

Since the master driver structure may be registered back later, we
want to make sure that no dandling class pointer is left there.

---

 kernel/drivers/spi/spi-master.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/drivers/spi/spi-master.c b/kernel/drivers/spi/spi-master.c
index ac7929a..12a1ad1 100644
--- a/kernel/drivers/spi/spi-master.c
+++ b/kernel/drivers/spi/spi-master.c
@@ -426,6 +426,7 @@ void rtdm_spi_remove_master(struct rtdm_spi_master *master)

rtdm_mutex_destroy(>bus_lock);
spi_unregister_master(master->kmaster);
+   rtdm_drv_set_sysclass(>driver, NULL);
class_destroy(class);
kfree(classname);
 }


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/gpiotest: set GPIO direction

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 597e4bf3b0f95c6802489e19e6671cf0a7e0c33e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=597e4bf3b0f95c6802489e19e6671cf0a7e0c33e

Author: Philippe Gerum 
Date:   Sat Jun 25 18:53:36 2016 +0200

testsuite/gpiotest: set GPIO direction

---

 testsuite/gpiotest/gpiotest.c |6 ++
 1 file changed, 6 insertions(+)

diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index 838f498..65949ee 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -117,6 +117,9 @@ static int run_read_value(struct smokey_test *t, int argc, 
char *const argv[])
return ret;
}
 
+   if (!__T(ret, ioctl(fd, GPIO_RTIOC_DIR_IN)))
+   return ret;
+
ret = read(fd, , sizeof(value));
close(fd);
 
@@ -149,6 +152,9 @@ static int run_write_value(struct smokey_test *t, int argc, 
char *const argv[])
return ret;
}
 
+   if (!__T(ret, ioctl(fd, GPIO_RTIOC_DIR_OUT)))
+   return ret;
+   
ret = write(fd, , sizeof(value));
close(fd);
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/timer: fix spurious assertion trigger

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 0326d526edeb377948b68d86a51b25a403b67c81
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0326d526edeb377948b68d86a51b25a403b67c81

Author: Philippe Gerum 
Date:   Tue Jan  3 11:20:28 2017 +0100

cobalt/timer: fix spurious assertion trigger

Commit #ccbd3750c introduced a debug assertion which only makes sense
when the timer is running. Reduce the scope of this check in order to
eliminate triggers on false positive.

---

 kernel/cobalt/timer.c |   15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index 3a4732d..aa3bc9e 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -601,23 +601,21 @@ void xntimer_release_ipi(void)
 unsigned long long xntimer_get_overruns(struct xntimer *timer, xnticks_t now)
 {
xnticks_t period = timer->interval;
-   xnsticks_t delta;
unsigned long long overruns = 0;
+   xnsticks_t delta;
+   xntimerq_t *q;
 
-   XENO_BUG_ON(COBALT, (timer->status &
-(XNTIMER_DEQUEUED|XNTIMER_PERIODIC)) != XNTIMER_PERIODIC);
-   
delta = now - xntimer_pexpect(timer);
if (unlikely(delta >= (xnsticks_t) period)) {
-   xntimerq_t *q;
-
period = timer->interval_ns;
delta = xnclock_ticks_to_ns(xntimer_clock(timer), delta);
overruns = xnarch_div64(delta, period);
timer->pexpect_ticks += overruns;
-
if (xntimer_running_p(timer)) {
-   q = xntimer_percpu_queue(timer);
+   XENO_BUG_ON(COBALT, (timer->status &
+   (XNTIMER_DEQUEUED|XNTIMER_PERIODIC))
+   != XNTIMER_PERIODIC);
+   q = xntimer_percpu_queue(timer);
xntimer_dequeue(timer, q);
while (xntimerh_date(>aplink) < now) {
timer->periodic_ticks++;
@@ -628,6 +626,7 @@ unsigned long long xntimer_get_overruns(struct xntimer 
*timer, xnticks_t now)
}
 
timer->pexpect_ticks++;
+
return overruns;
 }
 EXPORT_SYMBOL_GPL(xntimer_get_overruns);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: sanitize DEBUG mode switch

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: a49b78bfeabb16685807155d71541b733594a61d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a49b78bfeabb16685807155d71541b733594a61d

Author: Philippe Gerum 
Date:   Tue Jun 28 10:49:17 2016 +0200

drivers/gpio: sanitize DEBUG mode switch

---

 kernel/drivers/gpio/Makefile|2 ++
 kernel/drivers/gpio/gpio-core.c |3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/drivers/gpio/Makefile b/kernel/drivers/gpio/Makefile
index e237279..c9e976f 100644
--- a/kernel/drivers/gpio/Makefile
+++ b/kernel/drivers/gpio/Makefile
@@ -1,4 +1,6 @@
 
+ccflags-$(CONFIG_XENO_DRIVERS_GPIO_DEBUG) := -DDEBUG
+
 obj-$(CONFIG_XENO_DRIVERS_GPIO) += xeno_gpio.o
 
 xeno_gpio-y := gpio-core.o
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index d9863d9..e8a7ba1 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -15,9 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
-#ifdef CONFIG_XENO_DRIVERS_GPIO_DEBUG
-#define DEBUG
-#endif
 #include 
 #include 
 #include 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/gpio: add interrupt trigger argument

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 588f1ad5e30a4c49533ea2eec4fafd9d50ec976f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=588f1ad5e30a4c49533ea2eec4fafd9d50ec976f

Author: Philippe Gerum 
Date:   Tue Jul 12 10:03:48 2016 +0200

testsuite/gpio: add interrupt trigger argument

---

 testsuite/gpiotest/gpiotest.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
index aeb16af..c6620e1 100644
--- a/testsuite/gpiotest/gpiotest.c
+++ b/testsuite/gpiotest/gpiotest.c
@@ -32,10 +32,13 @@
 smokey_test_plugin(interrupt,
   SMOKEY_ARGLIST(
   SMOKEY_STRING(device),
+  SMOKEY_STRING(trigger),
   SMOKEY_BOOL(select),
   ),
"Wait for interrupts from a GPIO pin.\n"
-   "\tdevice=."
+   "\tdevice=\n"
+   "\trigger={edge[-rising/falling/both], level[-low/high]}\n"
+   "\tselect, wait on select(2)."
 );
 
 smokey_test_plugin(read_value,


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Henning Schild : scripts/xeno-config: fix error message, dump_wrappers is not just POSIX

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 197e96eef5fe5485e625eabb493edb55cc38edd5
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=197e96eef5fe5485e625eabb493edb55cc38edd5

Author: Henning Schild 
Date:   Wed Jan 25 16:08:00 2017 +0100

scripts/xeno-config: fix error message, dump_wrappers is not just POSIX

Signed-off-by: Henning Schild 

---

 scripts/xeno-config-cobalt.in |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index 62c1f33..d102d04 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -25,7 +25,7 @@ dump_wrappers()
 {
file=$1
if test \! -r ${XENO_LIBRARY_DIR}/$file; then
-  echo "Xenomai: POSIX wrappers cannot be read from 
${XENO_LIBRARY_DIR}/${file}" >&2
+  echo "Xenomai: wrappers cannot be read from ${XENO_LIBRARY_DIR}/${file}" 
>&2
   exit 1
fi
if test "$LD_FILE_OPTION" = "yes"; then


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/spi: introduce iobufs.map_len to expose the mapping length

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 11a3a75f92cecabf2a202698ebde60287dd5ef3f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=11a3a75f92cecabf2a202698ebde60287dd5ef3f

Author: Philippe Gerum 
Date:   Tue Jun 28 10:41:33 2016 +0200

drivers/spi: introduce iobufs.map_len to expose the mapping length

Overwriting iobufs.io_len for returning the length of the user-space
mapping makes no sense, since both values have different meanings
(DMA_ALIGNED(io_len) * 2 == map_len).

---

 include/rtdm/uapi/spi.h  |1 +
 kernel/drivers/spi/spi-bcm2835.c |2 +-
 testsuite/spitest/spitest.c  |4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/rtdm/uapi/spi.h b/include/rtdm/uapi/spi.h
index 45bc92d..8f04237 100644
--- a/include/rtdm/uapi/spi.h
+++ b/include/rtdm/uapi/spi.h
@@ -30,6 +30,7 @@ struct rtdm_spi_iobufs {
__u32 io_len;
__u32 i_offset;
__u32 o_offset;
+   __u32 map_len;
 };
 
 #define SPI_RTIOC_SET_CONFIG   _IOW(RTDM_CLASS_SPI, 0, struct 
rtdm_spi_config)
diff --git a/kernel/drivers/spi/spi-bcm2835.c b/kernel/drivers/spi/spi-bcm2835.c
index 02ebecd..118cfd5 100644
--- a/kernel/drivers/spi/spi-bcm2835.c
+++ b/kernel/drivers/spi/spi-bcm2835.c
@@ -409,7 +409,7 @@ static int bcm2835_set_iobufs(struct rtdm_spi_remote_slave 
*slave,
 
p->i_offset = 0;
p->o_offset = bcm->io_len / 2;
-   p->io_len = bcm->io_len;
+   p->map_len = bcm->io_len;

return 0;
 }
diff --git a/testsuite/spitest/spitest.c b/testsuite/spitest/spitest.c
index 0609bad..40ef9a9 100644
--- a/testsuite/spitest/spitest.c
+++ b/testsuite/spitest/spitest.c
@@ -385,14 +385,14 @@ static int run_spi_transfer(struct smokey_test *t, int 
argc, char *const argv[])
if (!__T(ret, ioctl(fd, SPI_RTIOC_SET_IOBUFS, )))
return ret;
 
-   p = mmap(NULL, iobufs.io_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+   p = mmap(NULL, iobufs.map_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (!__Fassert(p == MAP_FAILED))
return -EINVAL;

smokey_trace("input_area[%u..%u], output_area[%u..%u], mapping 
length=%u",
 iobufs.i_offset, iobufs.i_offset + TRANSFER_SIZE - 1,
 iobufs.o_offset, iobufs.o_offset + TRANSFER_SIZE - 1,
-iobufs.io_len);
+iobufs.map_len);

i_area = p + iobufs.i_offset;
o_area = p + iobufs.o_offset;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: return ENODEV on failed device detection

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 609615e9e94ce68d33adc8e3802cf5f9199142ca
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=609615e9e94ce68d33adc8e3802cf5f9199142ca

Author: Philippe Gerum 
Date:   Sat Jun 18 12:20:43 2016 +0200

drivers/gpio: return ENODEV on failed device detection

---

 kernel/drivers/gpio/gpio-core.c |   11 ---
 kernel/drivers/gpio/gpio-core.h |2 ++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 319d5c7..e8a7ba1 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -22,7 +22,6 @@
 #include 
 #include 
 #include 
-#include 
 #include "gpio-core.h"
 
 struct rtdm_gpio_pin {
@@ -329,13 +328,17 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
 }
 EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
 
+#ifdef CONFIG_OF
+
+#include 
+
 int rtdm_gpiochip_scan_of(struct device_node *from, const char *compat,
  int (*match)(struct gpio_chip *gc))
 {
struct device_node *np = from;
struct platform_device *pdev;
-   int ret = -EPROBE_DEFER;
struct gpio_chip *gc;
+   int ret = -ENODEV;
 
for (;;) {
np = of_find_compatible_node(np, NULL, compat);
@@ -344,7 +347,7 @@ int rtdm_gpiochip_scan_of(struct device_node *from, const 
char *compat,
pdev = of_find_device_by_node(np);
of_node_put(np);
if (pdev == NULL)
-   return -ENODEV;
+   break;
gc = find_chip_by_name(dev_name(>dev));
if (gc) {
ret = match(gc);
@@ -356,3 +359,5 @@ int rtdm_gpiochip_scan_of(struct device_node *from, const 
char *compat,
return ret;
 }
 EXPORT_SYMBOL_GPL(rtdm_gpiochip_scan_of);
+
+#endif /* CONFIG_OF */
diff --git a/kernel/drivers/gpio/gpio-core.h b/kernel/drivers/gpio/gpio-core.h
index d4dd28a..c0eac32 100644
--- a/kernel/drivers/gpio/gpio-core.h
+++ b/kernel/drivers/gpio/gpio-core.h
@@ -43,7 +43,9 @@ void rtdm_gpiochip_remove(struct rtdm_gpio_chip *rgc);
 int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
  const char *label, int gpio_subclass);
 
+#ifdef CONFIG_OF
 int rtdm_gpiochip_scan_of(struct device_node *from, const char *compat,
  int (*match)(struct gpio_chip *gc));
+#endif
 
 #endif /* !_RTDM_GPIO_CORE_H */


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: fix enumeration/detection of controllers

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: bb9c92b86ac166f12d5661950fe53187af3247cf
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bb9c92b86ac166f12d5661950fe53187af3247cf

Author: Philippe Gerum 
Date:   Thu Sep 29 15:22:24 2016 +0200

drivers/gpio: fix enumeration/detection of controllers

---

 kernel/drivers/gpio/Kconfig|   18 +
 kernel/drivers/gpio/gpio-bcm2835.c |   12 +++---
 kernel/drivers/gpio/gpio-core.c|   71 +++-
 kernel/drivers/gpio/gpio-core.h|   10 -
 kernel/drivers/gpio/gpio-mxc.c |   39 ++--
 5 files changed, 89 insertions(+), 61 deletions(-)

diff --git a/kernel/drivers/gpio/Kconfig b/kernel/drivers/gpio/Kconfig
index 850127f..74c56d4 100644
--- a/kernel/drivers/gpio/Kconfig
+++ b/kernel/drivers/gpio/Kconfig
@@ -1,13 +1,17 @@
 menu "Real-time GPIO drivers"
 
 config XENO_DRIVERS_GPIO
-   tristate
+   tristate "GPIO controller"
depends on GPIOLIB
+   help
+
+   Real-time capable GPIO module.
+  
+if XENO_DRIVERS_GPIO
 
 config XENO_DRIVERS_GPIO_BCM2835
depends on MACH_BCM2708
-   select XENO_DRIVERS_GPIO
-   tristate "Support for BCM2835 GPIOs"
+   bool "Support for BCM2835 GPIOs"
help
 
Enables support for the GPIO controller available from
@@ -15,15 +19,15 @@ config XENO_DRIVERS_GPIO_BCM2835
 
 config XENO_DRIVERS_GPIO_MXC
depends on GPIO_MXC
-   select XENO_DRIVERS_GPIO
-   tristate "Support for MXC GPIOs"
+   bool "Support for MXC GPIOs"
help
 
Suitable for the GPIO controller available from
Freescale/NXP's MXC architecture.
 
 config XENO_DRIVERS_GPIO_DEBUG
-   depends on XENO_DRIVERS_GPIO
bool "Enable GPIO core debugging features"
-   
+
+endif
+
 endmenu
diff --git a/kernel/drivers/gpio/gpio-bcm2835.c 
b/kernel/drivers/gpio/gpio-bcm2835.c
index f277262..6328955 100644
--- a/kernel/drivers/gpio/gpio-bcm2835.c
+++ b/kernel/drivers/gpio/gpio-bcm2835.c
@@ -20,20 +20,18 @@
 
 #define RTDM_SUBCLASS_BCM2835  1
 
-static struct rtdm_gpio_chip bcm2835_gpio_chip;
-
 static int __init bcm2835_gpio_init(void)
 {
-   return rtdm_gpiochip_add_by_name(_gpio_chip, "bcm2708_gpio",
-RTDM_SUBCLASS_BCM2835);
+   return rtdm_gpiochip_scan_of(NULL, "brcm,bcm2835-gpio",
+RTDM_SUBCLASS_BCM2835);
 }
+module_init(bcm2835_gpio_init);
 
 static void __exit bcm2835_gpio_exit(void)
 {
-   rtdm_gpiochip_remove(_gpio_chip);
+   rtdm_gpiochip_remove_of(RTDM_SUBCLASS_BCM2835);
 }
-
-module_init(bcm2835_gpio_init);
 module_exit(bcm2835_gpio_exit);
 
 MODULE_LICENSE("GPL");
+
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index f18d571..5c08355 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -203,22 +203,23 @@ static void delete_pin_devices(struct rtdm_gpio_chip *rgc)
 {
struct rtdm_gpio_pin *pin, *n;
struct rtdm_device *dev;
+   rtdm_lockctx_t s;
 
-   rtdm_lock_get(>lock);
+   rtdm_lock_get_irqsave(>lock, s);

list_for_each_entry_safe(pin, n, >pins, next) {
list_del(>next);
-   rtdm_lock_put(>lock);
+   rtdm_lock_put_irqrestore(>lock, s);
dev = >dev;
rtdm_dev_unregister(dev);
rtdm_event_destroy(>event);
kfree(dev->label);
kfree(pin->name);
kfree(pin);
-   rtdm_lock_get(>lock);
+   rtdm_lock_get_irqsave(>lock, s);
}
 
-   rtdm_lock_put(>lock);
+   rtdm_lock_put_irqrestore(>lock, s);
 }
 
 static int create_pin_devices(struct rtdm_gpio_chip *rgc)
@@ -226,6 +227,7 @@ static int create_pin_devices(struct rtdm_gpio_chip *rgc)
struct gpio_chip *gc = rgc->gc;
struct rtdm_gpio_pin *pin;
struct rtdm_device *dev;
+   rtdm_lockctx_t s;
int n, ret;
 
for (n = gc->base; n < gc->base + gc->ngpio - 1; n++) {
@@ -252,9 +254,9 @@ static int create_pin_devices(struct rtdm_gpio_chip *rgc)
if (ret)
goto fail_register;
rtdm_event_init(>event, 0);
-   rtdm_lock_get(>lock);
+   rtdm_lock_get_irqsave(>lock, s);
list_add_tail(>next, >pins);
-   rtdm_lock_put(>lock);
+   rtdm_lock_put_irqrestore(>lock, s);
}
 
return 0;
@@ -362,8 +364,41 @@ EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
 
 #include 
 
+LIST_HEAD(rtdm_gpio_chips);
+
+static DEFINE_MUTEX(chip_lock);
+
+static int match_gpio_chip(struct gpio_chip *gc, void *data)
+{
+   struct device *dev = data;
+
+   return gc->dev == dev;
+}
+
+static int add_gpio_chip(struct gpio_chip *gc, int type)
+{
+   struct rtdm_gpio_chip *rgc;
+   int ret;
+
+   rgc = kzalloc(sizeof(*rgc), 

[Xenomai-git] Philippe Gerum : drivers/gpio: bcm2835: look up for the right chip label

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 8012a966ac5ed9fe5de272e4021c697c3be1857c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8012a966ac5ed9fe5de272e4021c697c3be1857c

Author: Philippe Gerum 
Date:   Sun Jul 10 12:02:04 2016 +0200

drivers/gpio: bcm2835: look up for the right chip label

---

 kernel/drivers/gpio/gpio-bcm2835.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/drivers/gpio/gpio-bcm2835.c 
b/kernel/drivers/gpio/gpio-bcm2835.c
index 772298b..f277262 100644
--- a/kernel/drivers/gpio/gpio-bcm2835.c
+++ b/kernel/drivers/gpio/gpio-bcm2835.c
@@ -24,7 +24,7 @@ static struct rtdm_gpio_chip bcm2835_gpio_chip;
 
 static int __init bcm2835_gpio_init(void)
 {
-   return rtdm_gpiochip_add_by_name(_gpio_chip, "bcm2835_gpio",
+   return rtdm_gpiochip_add_by_name(_gpio_chip, "bcm2708_gpio",
 RTDM_SUBCLASS_BCM2835);
 }
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/spi: enable GPIO-based chip select

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 0f85395e3228ea30523d21a50ee9a0e5d0dfe82c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0f85395e3228ea30523d21a50ee9a0e5d0dfe82c

Author: Philippe Gerum 
Date:   Tue Jun 28 09:58:10 2016 +0200

drivers/spi: enable GPIO-based chip select

---

 kernel/drivers/spi/spi-device.c |   38 +-
 kernel/drivers/spi/spi-device.h |1 +
 kernel/drivers/spi/spi-master.c |   18 --
 3 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/kernel/drivers/spi/spi-device.c b/kernel/drivers/spi/spi-device.c
index 62482b2..08cf9b0 100644
--- a/kernel/drivers/spi/spi-device.c
+++ b/kernel/drivers/spi/spi-device.c
@@ -43,22 +43,14 @@ int rtdm_spi_add_remote_slave(struct rtdm_spi_remote_slave 
*slave,
slave->config.speed_hz = spi->max_speed_hz;
slave->config.mode = spi->mode;
slave->master = master;
-   mutex_init(>ctl_lock);

dev = >dev;
dev->driver = >driver;
dev->label = kasprintf(GFP_KERNEL, "%s/slave%d.%%d",
   dev_name(>dev),
   kmaster->bus_num);
-   if (dev->label == NULL) {
-   ret = -ENOMEM;
-   goto fail_label;
-   }
-
-   dev->device_data = master;
-   ret = rtdm_dev_register(dev);
-   if (ret)
-   goto fail_register;
+   if (dev->label == NULL)
+   return -ENOMEM;
 
if (gpio_is_valid(spi->cs_gpio))
slave->cs_gpio = spi->cs_gpio;
@@ -68,21 +60,30 @@ int rtdm_spi_add_remote_slave(struct rtdm_spi_remote_slave 
*slave,
slave->cs_gpio = kmaster->cs_gpios[spi->chip_select];
}
 
-   if (gpio_is_valid(slave->cs_gpio))
-   dev_dbg(slave_to_kdev(slave), "using CS GPIO%d\n",
-   slave->cs_gpio);
+   if (gpio_is_valid(slave->cs_gpio)) {
+   ret = gpio_request(slave->cs_gpio, dev->label);
+   if (ret)
+   goto fail;
+   slave->cs_gpiod = gpio_to_desc(slave->cs_gpio);
+   if (slave->cs_gpiod == NULL)
+   goto fail;
+   }
+   
+   mutex_init(>ctl_lock);
+
+   dev->device_data = master;
+   ret = rtdm_dev_register(dev);
+   if (ret)
+   goto fail;
 
rtdm_lock_get_irqsave(>lock, c);
list_add_tail(>next, >slaves);
rtdm_lock_put_irqrestore(>lock, c);
 
return 0;
-
-fail_register:
+fail:
kfree(dev->label);
 
-fail_label:
-
return ret;
 }
 EXPORT_SYMBOL_GPL(rtdm_spi_add_remote_slave);
@@ -93,6 +94,9 @@ void rtdm_spi_remove_remote_slave(struct 
rtdm_spi_remote_slave *slave)
struct rtdm_device *dev;
rtdm_lockctx_t c;

+   if (gpio_is_valid(slave->cs_gpio))
+   gpio_free(slave->cs_gpio);
+
mutex_destroy(>ctl_lock);
rtdm_lock_get_irqsave(>lock, c);
list_del(>next);
diff --git a/kernel/drivers/spi/spi-device.h b/kernel/drivers/spi/spi-device.h
index fcfca90..ee43c38 100644
--- a/kernel/drivers/spi/spi-device.h
+++ b/kernel/drivers/spi/spi-device.h
@@ -30,6 +30,7 @@ struct rtdm_spi_master;
 struct rtdm_spi_remote_slave {
u8 chip_select;
int cs_gpio;
+   struct gpio_desc *cs_gpiod;
struct rtdm_device dev;
struct list_head next;
struct rtdm_spi_config config;
diff --git a/kernel/drivers/spi/spi-master.c b/kernel/drivers/spi/spi-master.c
index 132a3b9..fe2ee40 100644
--- a/kernel/drivers/spi/spi-master.c
+++ b/kernel/drivers/spi/spi-master.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "spi-master.h"
 
 static inline
@@ -105,6 +106,7 @@ static int do_chip_select(struct rtdm_spi_remote_slave 
*slave)
 {  /* master->bus_lock held */
struct rtdm_spi_master *master = slave->master;
rtdm_lockctx_t c;
+   int state;
 
if (slave->config.speed_hz == 0)
return -EINVAL; /* Setup is missing. */
@@ -113,7 +115,11 @@ static int do_chip_select(struct rtdm_spi_remote_slave 
*slave)
rtdm_lock_get_irqsave(>lock, c);

if (master->cs != slave) {
-   master->ops->chip_select(slave, true);
+   if (gpio_is_valid(slave->cs_gpio)) {
+   state = !!(slave->config.mode & SPI_CS_HIGH);
+   gpiod_set_raw_value(slave->cs_gpiod, state);
+   } else
+   master->ops->chip_select(slave, true);
master->cs = slave;
}
 
@@ -126,10 +132,18 @@ static void do_chip_deselect(struct rtdm_spi_remote_slave 
*slave)
 {  /* master->bus_lock held */
struct rtdm_spi_master *master = slave->master;
rtdm_lockctx_t c;
+   int state;
 
rtdm_lock_get_irqsave(>lock, c);
-   master->ops->chip_select(slave, false);
+
+   

[Xenomai-git] Philippe Gerum : copperplate/regd: conform to libfuse assumption regarding SIGCHLD

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 4364bdd358e893b1f4f7f644a35191b3fc7f4180
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4364bdd358e893b1f4f7f644a35191b3fc7f4180

Author: Philippe Gerum 
Date:   Tue Dec 27 09:45:35 2016 +0100

copperplate/regd: conform to libfuse assumption regarding SIGCHLD

When executing utility programs such as /bin/mount via a fork+exec
sequence, libfuse assumes that SIGCHLD won't be ignored by the forked
child, so that waitpid() may be safely used to wait for child
completion.

This means that SIGCHLD must not be ignored by the caller of
fuse_main() in the first place, since such signal disposition is
inherited.

It turned out that sysregd was actually ignoring SIGCHLD before
attempting to mount the system fs on behalf of fuse_main(), causing
libfuse's add_mount() to fail after ECHILD was received from
waitpid(), due to the following sequence of events:

registry_thread: fuse_main()
registry_thread:add_mount()
registry_thread:mount_pid = fork()
registry_thread:execl("/bin/mount", ...)
/bin/mount: ...
/bin/mount: exit(0)
registry_thread:waitpid(mount_pid, ...) => ECHILD

As a matter of fact, sysregd does not need any particular disposition
for SIGCHLD for carrying out its own duties, but has to start with
this signal set to SIG_IGN when spawned from copperplate (see
spawn_daemon()). The fix is to switch this signal disposition back to
SIG_DFL before the registry thread is started.

---

 lib/copperplate/regd/regd.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/copperplate/regd/regd.c b/lib/copperplate/regd/regd.c
index e0228fb..8752070 100644
--- a/lib/copperplate/regd/regd.c
+++ b/lib/copperplate/regd/regd.c
@@ -541,8 +541,9 @@ int main(int argc, char *const *argv)
 
memset(, 0, sizeof(sa));
sa.sa_handler = SIG_IGN;
-   sigaction(SIGCHLD, , NULL);
sigaction(SIGPIPE, , NULL);
+   sa.sa_handler = SIG_DFL;
+   sigaction(SIGCHLD, , NULL);
 
if (daemonize) {
ret = daemon(1, 1);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: serialize access to per-chip pin list

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 3b42d107c1ae11fc39a0cf11c1d8c8f78adac46b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3b42d107c1ae11fc39a0cf11c1d8c8f78adac46b

Author: Philippe Gerum 
Date:   Fri Jun 17 16:12:27 2016 +0200

drivers/gpio: serialize access to per-chip pin list

---

 kernel/drivers/gpio/gpio-core.c |9 +
 kernel/drivers/gpio/gpio-core.h |1 +
 2 files changed, 10 insertions(+)

diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 4f707b8..319d5c7 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -175,15 +175,21 @@ static void delete_pin_devices(struct rtdm_gpio_chip *rgc)
struct rtdm_gpio_pin *pin, *n;
struct rtdm_device *dev;
 
+   rtdm_lock_get(>lock);
+   
list_for_each_entry_safe(pin, n, >pins, next) {
list_del(>next);
+   rtdm_lock_put(>lock);
dev = >dev;
rtdm_dev_unregister(dev);
rtdm_event_destroy(>event);
kfree(dev->label);
kfree(pin->name);
kfree(pin);
+   rtdm_lock_get(>lock);
}
+
+   rtdm_lock_put(>lock);
 }
 
 static int create_pin_devices(struct rtdm_gpio_chip *rgc)
@@ -217,7 +223,9 @@ static int create_pin_devices(struct rtdm_gpio_chip *rgc)
if (ret)
goto fail_register;
rtdm_event_init(>event, 0);
+   rtdm_lock_get(>lock);
list_add_tail(>next, >pins);
+   rtdm_lock_put(>lock);
}
 
return 0;
@@ -277,6 +285,7 @@ int rtdm_gpiochip_add(struct rtdm_gpio_chip *rgc,
 
rgc->gc = gc;
INIT_LIST_HEAD(>pins);
+   rtdm_lock_init(>lock);
 
ret = create_pin_devices(rgc);
if (ret)
diff --git a/kernel/drivers/gpio/gpio-core.h b/kernel/drivers/gpio/gpio-core.h
index 3fa7867..d4dd28a 100644
--- a/kernel/drivers/gpio/gpio-core.h
+++ b/kernel/drivers/gpio/gpio-core.h
@@ -31,6 +31,7 @@ struct rtdm_gpio_chip {
struct class *devclass;
struct list_head pins;
struct list_head next;
+   rtdm_lock_t lock;
 };
 
 int rtdm_gpiochip_add(struct rtdm_gpio_chip *rgc,


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/spi: fix read/write transfer descriptor

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: f6d88b8d4c0d1e68673726dca5d668c29f275662
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f6d88b8d4c0d1e68673726dca5d668c29f275662

Author: Philippe Gerum 
Date:   Wed Aug 10 10:14:28 2016 +0200

drivers/spi: fix read/write transfer descriptor

---

 kernel/drivers/spi/spi-bcm2835.c |   18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/kernel/drivers/spi/spi-bcm2835.c b/kernel/drivers/spi/spi-bcm2835.c
index 117cf38..da44bf7 100644
--- a/kernel/drivers/spi/spi-bcm2835.c
+++ b/kernel/drivers/spi/spi-bcm2835.c
@@ -324,13 +324,10 @@ static ssize_t bcm2835_read(struct rtdm_spi_remote_slave 
*slave,
struct spi_master_bcm2835 *spim = to_master_bcm2835(slave);
struct spi_slave_bcm2835 *bcm = to_slave_bcm2835(slave);
 
-   if (bcm->io_len == 0)
-   return -EINVAL; /* No I/O buffers set. */
-   
-   spim->tx_len = bcm->io_len / 2;
-   spim->rx_len = spim->tx_len;
+   spim->tx_len = len;
+   spim->rx_len = len;
spim->tx_buf = NULL;
-   spim->rx_buf = bcm->io_virt;
+   spim->rx_buf = rx;
 
return do_transfer_irq(slave) ?: len;
 }
@@ -341,12 +338,9 @@ static ssize_t bcm2835_write(struct rtdm_spi_remote_slave 
*slave,
struct spi_master_bcm2835 *spim = to_master_bcm2835(slave);
struct spi_slave_bcm2835 *bcm = to_slave_bcm2835(slave);
 
-   if (bcm->io_len == 0)
-   return -EINVAL; /* No I/O buffers set. */
-   
-   spim->tx_len = bcm->io_len / 2;
-   spim->rx_len = spim->tx_len;
-   spim->tx_buf = bcm->io_virt + bcm->io_len / 2;
+   spim->tx_len = len;
+   spim->rx_len = len;
+   spim->tx_buf = tx;
spim->rx_buf = NULL;
 
return do_transfer_irq(slave) ?: len;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : boilerplate/tlsf: work around excessive meta-data overhead for main pool

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 00e3d016519efc54cb2b2b33437814ff6725cf33
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=00e3d016519efc54cb2b2b33437814ff6725cf33

Author: Philippe Gerum 
Date:   Fri Jan 27 10:16:11 2017 +0100

boilerplate/tlsf: work around excessive meta-data overhead for main pool

e0e6ae76 caused a regression with failure to initialize the main pool
with TLSF, uncovering an issue in the allocator code which fails to
account properly for the overhead induced by the meta-data.

Overhead footprints and management is a recurring problem with TLSF,
particularly on 64bit platforms; for this reason there is a plan for
dropping TLSF entirely from the Xenomai code base. Until this happens,
the current change works around the issue to keep things going.

---

 lib/boilerplate/tlsf/tlsf.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/boilerplate/tlsf/tlsf.c b/lib/boilerplate/tlsf/tlsf.c
index 8ee9405..2dddc1e 100644
--- a/lib/boilerplate/tlsf/tlsf.c
+++ b/lib/boilerplate/tlsf/tlsf.c
@@ -626,6 +626,7 @@ void *tlsf_malloc(size_t size)
 
area_size = sizeof(tlsf_t) + BHDR_OVERHEAD * 8; /* Just a safety 
constant */
area_size += size;
+   area_size += (1 << (ms_bit(area_size) - MAX_LOG2_SLI)) - 1;
area_size = (area_size > DEFAULT_AREA_SIZE) ? area_size : 
DEFAULT_AREA_SIZE;
area = get_new_area(_size);
if (area == ((void *) ~0))


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/spi: sanitize DEBUG mode switch

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 121c9feb407e259e27995f70ba63b8a64ac071b6
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=121c9feb407e259e27995f70ba63b8a64ac071b6

Author: Philippe Gerum 
Date:   Tue Jun 28 10:49:26 2016 +0200

drivers/spi: sanitize DEBUG mode switch

---

 kernel/drivers/spi/Makefile  |2 ++
 kernel/drivers/spi/spi-bcm2835.c |3 ---
 kernel/drivers/spi/spi-device.c  |3 ---
 kernel/drivers/spi/spi-master.c  |3 ---
 4 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/kernel/drivers/spi/Makefile b/kernel/drivers/spi/Makefile
index 6c78a2e..2a00284 100644
--- a/kernel/drivers/spi/Makefile
+++ b/kernel/drivers/spi/Makefile
@@ -1,4 +1,6 @@
 
+ccflags-$(CONFIG_XENO_DRIVERS_SPI_DEBUG) := -DDEBUG
+
 obj-$(CONFIG_XENO_DRIVERS_SPI) += xeno_spi.o
 
 xeno_spi-y := spi-master.o spi-device.o
diff --git a/kernel/drivers/spi/spi-bcm2835.c b/kernel/drivers/spi/spi-bcm2835.c
index 118cfd5..117cf38 100644
--- a/kernel/drivers/spi/spi-bcm2835.c
+++ b/kernel/drivers/spi/spi-bcm2835.c
@@ -21,9 +21,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
-#ifdef CONFIG_XENO_DRIVERS_SPI_DEBUG
-#define DEBUG
-#endif
 #include 
 #include 
 #include 
diff --git a/kernel/drivers/spi/spi-device.c b/kernel/drivers/spi/spi-device.c
index 08cf9b0..71f30a6 100644
--- a/kernel/drivers/spi/spi-device.c
+++ b/kernel/drivers/spi/spi-device.c
@@ -15,9 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
-#ifdef CONFIG_XENO_DRIVERS_SPI_DEBUG
-#define DEBUG
-#endif
 #include 
 #include 
 #include 
diff --git a/kernel/drivers/spi/spi-master.c b/kernel/drivers/spi/spi-master.c
index fe2ee40..ac7929a 100644
--- a/kernel/drivers/spi/spi-master.c
+++ b/kernel/drivers/spi/spi-master.c
@@ -15,9 +15,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
-#ifdef CONFIG_XENO_DRIVERS_SPI_DEBUG
-#define DEBUG
-#endif
 #include 
 #include 
 #include 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/timer: fixup CPU affinity mismatch at init

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 9b8d7c947089dfb0b3ca4b6f1e17a989ddc9a3e4
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9b8d7c947089dfb0b3ca4b6f1e17a989ddc9a3e4

Author: Philippe Gerum 
Date:   Sat Nov 12 11:56:09 2016 +0100

cobalt/timer: fixup CPU affinity mismatch at init

Since recently, POSIX timers can be backed by external clock
devices. Unlike the core clock, some of those devices may be ticking
only on a restricted set of CPUs, compared to the broader real-time
CPU set. This may lead to an affinity mismatch between a thread
creating a timer, and the CPU set that can receive timer events from
the backing device.

When this happens, warning on detecting such issue while initializing
the timer without fixing up the situation is not of a great help.

It is better to pick a CPU which is a member of the clock affinity set
and make such timer affine to it instead. In such a case, the overhead
induced by rescheduling a remote thread upon timer expiry is
acceptable compared to leaving a thread waiting indefinitely for timer
events that will never come.

---

 include/cobalt/kernel/timer.h |2 --
 kernel/cobalt/sched.c |6 +++---
 kernel/cobalt/thread.c|2 --
 kernel/cobalt/timer.c |   30 --
 4 files changed, 11 insertions(+), 29 deletions(-)

diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h
index d92c8c8..6cb2bb3 100644
--- a/include/cobalt/kernel/timer.h
+++ b/include/cobalt/kernel/timer.h
@@ -56,8 +56,6 @@ typedef enum xntmode {
 #define XNTIMER_GRAVITY_MASK   (XNTIMER_KGRAVITY|XNTIMER_UGRAVITY)
 #define XNTIMER_INIT_MASK  (XNTIMER_GRAVITY_MASK|XNTIMER_NOBLCK)
 
-#define __XNTIMER_CORE0x1000
-
 /* These flags are available to the real-time interfaces */
 #define XNTIMER_SPARE0  0x0100
 #define XNTIMER_SPARE1  0x0200
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index 7cb91a5..cbe14bd 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -194,11 +194,11 @@ void xnsched_init(struct xnsched *sched, int cpu)
 * exit code.
 */
xntimer_init(>htimer, , NULL,
-sched, XNTIMER_IGRAVITY|__XNTIMER_CORE);
+sched, XNTIMER_IGRAVITY);
xntimer_set_priority(>htimer, XNTIMER_LOPRIO);
xntimer_set_name(>htimer, htimer_name);
xntimer_init(>rrbtimer, , roundrobin_handler,
-sched, XNTIMER_IGRAVITY|__XNTIMER_CORE);
+sched, XNTIMER_IGRAVITY);
xntimer_set_name(>rrbtimer, rrbtimer_name);
xntimer_set_priority(>rrbtimer, XNTIMER_LOPRIO);
 
@@ -213,7 +213,7 @@ void xnsched_init(struct xnsched *sched, int cpu)
 
 #ifdef CONFIG_XENO_OPT_WATCHDOG
xntimer_init(>wdtimer, , watchdog_handler,
-sched, XNTIMER_NOBLCK|XNTIMER_IGRAVITY|__XNTIMER_CORE);
+sched, XNTIMER_NOBLCK|XNTIMER_IGRAVITY);
xntimer_set_name(>wdtimer, "[watchdog]");
xntimer_set_priority(>wdtimer, XNTIMER_LOPRIO);
 #endif /* CONFIG_XENO_OPT_WATCHDOG */
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index fb856a4..34eca35 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -209,8 +209,6 @@ int __xnthread_init(struct xnthread *thread,
init_completion(>exited);
 
gravity = flags & XNUSER ? XNTIMER_UGRAVITY : XNTIMER_KGRAVITY;
-   if (flags & XNROOT)
-   gravity |= __XNTIMER_CORE;
xntimer_init(>rtimer, , timeout_handler,
 sched, gravity);
xntimer_set_name(>rtimer, thread->name);
diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index 3563636..dd78c38 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -349,29 +349,15 @@ void __xntimer_init(struct xntimer *timer,
timer->handler = handler;
timer->interval_ns = 0;
/*
-* Timers are affine to a real-time CPU. If no affinity was
-* specified, assign the timer to the first possible CPU which
-* can receive interrupt events from the clock device attached
-* to the reference clock for this timer.
+* Unlike common IRQs, timer events are per-CPU by design. If
+* the CPU the caller is affine to does not receive timer
+* events, or no affinity was specified (i.e. sched == NULL),
+* assign the timer to the first possible CPU which can
+* receive interrupt events from the clock device backing this
+* timer.
 */
-   if (sched) {
-   /*
-* Complain loudly if no tick is expected from the
-* clock device on the CPU served by the specified
-* scheduler slot. This reveals a CPU affinity
-* mismatch between the clock hardware and the client
-* code initializing the timer. This check excludes
-* core timers which may have their own reason to 

[Xenomai-git] Jan Kiszka : testsuite/smokey: Add test case for setschedparam & Co,

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 3010b7ccae8fc2ebbfa915f4ed85897e29033546
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3010b7ccae8fc2ebbfa915f4ed85897e29033546

Author: Jan Kiszka 
Date:   Mon Feb 29 16:54:26 2016 +0100

testsuite/smokey: Add test case for setschedparam & Co,

This performs basic checks on the correct execution of scheduling
parameter changes from primary mode.

Signed-off-by: Jan Kiszka 

---

 configure.ac  |1 +
 testsuite/smokey/Makefile.am  |1 +
 testsuite/smokey/setsched/Makefile.am |9 +++
 testsuite/smokey/setsched/setsched.c  |  137 +
 4 files changed, 148 insertions(+)

diff --git a/configure.ac b/configure.ac
index 38a1749..789a6d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -882,6 +882,7 @@ AC_CONFIG_FILES([ \
testsuite/smokey/arith/Makefile \
testsuite/smokey/sched-quota/Makefile \
testsuite/smokey/sched-tp/Makefile \
+   testsuite/smokey/setsched/Makefile \
testsuite/smokey/rtdm/Makefile \
testsuite/smokey/vdso-access/Makefile \
testsuite/smokey/posix-cond/Makefile \
diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am
index 5ade58b..b0904d2 100644
--- a/testsuite/smokey/Makefile.am
+++ b/testsuite/smokey/Makefile.am
@@ -23,6 +23,7 @@ COBALT_SUBDIRS =  \
rtdm\
sched-quota \
sched-tp\
+   setsched\
sigdebug\
timerfd \
tsc \
diff --git a/testsuite/smokey/setsched/Makefile.am 
b/testsuite/smokey/setsched/Makefile.am
new file mode 100644
index 000..8c0a59b
--- /dev/null
+++ b/testsuite/smokey/setsched/Makefile.am
@@ -0,0 +1,9 @@
+
+noinst_LIBRARIES = libsetsched.a
+
+libsetsched_a_SOURCES = setsched.c
+
+libsetsched_a_CPPFLAGS =   \
+   @XENO_USER_CFLAGS@  \
+   -I$(top_srcdir) \
+   -I$(top_srcdir)/include
diff --git a/testsuite/smokey/setsched/setsched.c 
b/testsuite/smokey/setsched/setsched.c
new file mode 100644
index 000..359f190
--- /dev/null
+++ b/testsuite/smokey/setsched/setsched.c
@@ -0,0 +1,137 @@
+/*
+ * Scheduler live-adjustment test.
+ *
+ * Copyright (c) Siemens AG 2016
+ *
+ * Authors:
+ *  Jan Kiszka 
+ *
+ * Released under the terms of GPLv2.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+smokey_test_plugin(setsched, SMOKEY_NOARGS,
+   "Validate correct application of scheduling parameters to running threads."
+);
+
+static pid_t thread_pid;
+
+static void __check_linux_schedparams(int expected_policy, int expected_prio,
+ int line)
+{
+   struct sched_param linux_param;
+   int linux_policy;
+
+   linux_policy = syscall(SYS_sched_getscheduler, thread_pid);
+   if (smokey_check_status(syscall(SYS_sched_getparam, thread_pid,
+   _param)))
+   pthread_exit((void *)(long)-EINVAL);
+
+   if (!smokey_assert(linux_policy == expected_policy) ||
+   !smokey_assert(linux_param.sched_priority == expected_prio)) {
+   smokey_warning("called from line %d", line);
+   pthread_exit((void *)(long)-EINVAL);
+   }
+}
+
+#define check_linux_schedparams(pol, prio) \
+   __check_linux_schedparams(pol, prio, __LINE__)
+
+static void __check_rt_schedparams(int expected_policy, int expected_prio,
+  int line)
+{
+   struct sched_param cobalt_param;
+   int cobalt_policy;
+
+   if (smokey_check_status(pthread_getschedparam(pthread_self(),
+ _policy,
+ _param)))
+   pthread_exit((void *)(long)-EINVAL);
+
+   if (!smokey_assert(cobalt_policy == expected_policy) ||
+   !smokey_assert(cobalt_param.sched_priority == expected_prio)) {
+   smokey_warning("called from line %d", line);
+   pthread_exit((void *)(long)-EINVAL);
+   }
+}
+
+#define check_rt_schedparams(pol, prio)\
+   __check_rt_schedparams(pol, prio, __LINE__)
+
+static void *thread_body(void *arg)
+{
+   struct cobalt_threadstat stats;
+   struct sched_param param;
+   unsigned long long msw;
+
+   thread_pid = syscall(SYS_gettid);
+
+   check_rt_schedparams(SCHED_FIFO, 1);
+   check_linux_schedparams(SCHED_FIFO, 1);
+
+   if (smokey_check_status(cobalt_thread_stat(thread_pid, )))
+   pthread_exit((void *)(long)-EINVAL);
+   msw = stats.msw;
+
+   param.sched_priority = 2;
+   if (smokey_check_status(pthread_setschedparam(pthread_self(),
+ SCHED_FIFO, )))
+   pthread_exit((void *)(long)-EINVAL);
+
+   

[Xenomai-git] Philippe Gerum : build: allow building Mercury over any CPU architecture

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 18493575967fe969768674096f88b63d71e032e1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=18493575967fe969768674096f88b63d71e032e1

Author: Philippe Gerum 
Date:   Mon Nov 28 16:42:10 2016 +0100

build: allow building Mercury over any CPU architecture

We have no arch-dep bits for Mercury, so there is no point in
restricting the set of supported CPU architectures further than those
the target compiler can build for.

---

 configure.ac |   54 ++
 1 file changed, 30 insertions(+), 24 deletions(-)

diff --git a/configure.ac b/configure.ac
index 789a6d7..b33ff12 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,37 +123,44 @@ use_tls=no
 case "$build_for" in
  i*86*-*)
use_tls=yes
-   XENO_TARGET_ARCH=x86
+   target_cpu_arch=x86
CONFIG_XENO_DEFAULT_PERIOD=10
;;
  ppc-*|powerpc-*|powerpc64-*|ppc64-*)
use_tls=yes
-   XENO_TARGET_ARCH=powerpc
+   target_cpu_arch=powerpc
CONFIG_XENO_DEFAULT_PERIOD=10
;;
  bfin-*|bfinnommu-*|blackfin-*)
-   XENO_TARGET_ARCH=blackfin
+   target_cpu_arch=blackfin
CONFIG_XENO_DEFAULT_PERIOD=10
;;
  arm*-*)
-   XENO_TARGET_ARCH=arm
+   target_cpu_arch=arm
CONFIG_XENO_DEFAULT_PERIOD=100
;;
  x86_64-*|amd64-*)
use_tls=yes
-   XENO_TARGET_ARCH=x86
+   target_cpu_arch=x86
CONFIG_XENO_DEFAULT_PERIOD=10
;;
- *) echo ""
-   echo "***"
-   echo "Still unsupported target: $build_for -- Sorry."
-   echo "***"
-   echo ""
-   exit 1;;
+ *)
+   if test $rtcore_type = cobalt; then
+  echo ""
+  echo "**"
+  echo "Cobalt not supported over $build_for."
+  echo "**"
+  echo ""
+  exit 1
+   else
+  CONFIG_XENO_DEFAULT_PERIOD=10
+  target_cpu_arch=`echo $build_for|cut -d- -f1`
+   fi
+   ;;
 esac
 
-AC_MSG_RESULT([$XENO_TARGET_ARCH])
-AM_CONDITIONAL(XENO_TARGET_ARCH_X86,[test $XENO_TARGET_ARCH = x86])
+AC_MSG_RESULT([$target_cpu_arch])
+XENO_TARGET_ARCH=$target_cpu_arch
 AC_ENABLE_SHARED
 AC_PROG_LIBTOOL
 
@@ -211,7 +218,7 @@ fi
 
 dnl Raw monotonic clock (default: cobalt=on, mercury=off)
 
-if test x$rtcore_type = xcobalt; then
+if test $rtcore_type = cobalt; then
raw_monotonic_clock=y
 else
raw_monotonic_clock=
@@ -273,7 +280,7 @@ AC_ARG_ENABLE(condvar-workaround,
esac])
 AC_MSG_RESULT(${workaround_condvar_pi:-no})
 if test x$workaround_condvar_pi = xy; then
-   if test x$rtcore_type = xmercury; then
+   if test $rtcore_type = mercury; then
AC_DEFINE(CONFIG_XENO_WORKAROUND_CONDVAR_PI,1,[config])
else
 AC_MSG_WARN([PI workaround for condvars useless over Cobalt - 
ignoring])
@@ -319,10 +326,10 @@ if test x$use_registry = xy; then
 fi
 AM_CONDITIONAL(XENO_REGISTRY,[test x$use_registry = xy])
 
-dnl SMP support (default: off)
+dnl SMP support (default: on for cobalt/x86, off otherwise)
 
 CONFIG_SMP=
-if test $XENO_TARGET_ARCH = x86; then
+if test $target_cpu_arch = x86 -a $rtcore_type = cobalt; then
CONFIG_SMP=y
 fi
 AC_MSG_CHECKING(for SMP support)
@@ -352,11 +359,10 @@ else
   AC_DEFINE(CONFIG_XENO_SANITY,0,[config])
 fi
 
-dnl VSYSCALL (default: enabled) for x86
-
-CONFIG_XENO_X86_VSYSCALL=y
+dnl VSYSCALL (default: enabled) for Cobalt/x86
 
-if test $XENO_TARGET_ARCH = x86; then
+if test $XENO_TARGET_ARCH = x86 -a $rtcore_type = cobalt; then
+  CONFIG_XENO_X86_VSYSCALL=y
   AC_MSG_CHECKING(for x86 VSYSCALL availability)
   AC_ARG_ENABLE(x86-vsyscall,
AS_HELP_STRING([--enable-x86-vsyscall], [Assume VSYSCALL enabled for 
issuing syscalls]),
@@ -597,8 +603,8 @@ dnl Allocator for Copperplate
 dnl Note: in dual kernel mode, we don't want malloc, no matter what.
 dnl We switch to malloc only over the Mercury core in debug mode, to ease
 dnl debugging with valgrind, instrumented glibc etc.
-AM_CONDITIONAL(XENO_TLSF,[test x$rtcore_type = xcobalt -o x$debug_mode = x])
-test x$rtcore_type = xcobalt -o x$debug_mode = x && 
AC_DEFINE(CONFIG_XENO_TLSF,1,[config])
+AM_CONDITIONAL(XENO_TLSF,[test $rtcore_type = cobalt -o x$debug_mode = x])
+test $rtcore_type = cobalt -o x$debug_mode = x && 
AC_DEFINE(CONFIG_XENO_TLSF,1,[config])
 
 dnl Check for atomic builtins. For now we only check for the legacy
 dnl interface, i.e. __sync_*.
@@ -779,7 +785,7 @@ dnl Now we can close the conditional section, right after 
all
 dnl Autoconf-generated symbols have been listed.
 AH_BOTTOM([#endif /* __IN_XENO__ */])
 
-if test x$rtcore_type = xcobalt; then
+if test $rtcore_type = cobalt; then
XENO_USER_CFLAGS="-I$topdir/lib/cobalt/arch/$XENO_TARGET_ARCH/include 
-I$topdir/kernel/cobalt/arch/$XENO_TARGET_ARCH/include $XENO_USER_CFLAGS"

[Xenomai-git] Philippe Gerum : boilerplate/time: add helper to init a timespec from a scalar

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 61f6da906cda308c9f9a9de84ebf6010e988ccb8
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=61f6da906cda308c9f9a9de84ebf6010e988ccb8

Author: Philippe Gerum 
Date:   Tue Dec 13 14:56:10 2016 +0100

boilerplate/time: add helper to init a timespec from a scalar

---

 include/boilerplate/time.h |3 +++
 lib/boilerplate/time.c |   11 +++
 2 files changed, 14 insertions(+)

diff --git a/include/boilerplate/time.h b/include/boilerplate/time.h
index fff6075..8d317e7 100644
--- a/include/boilerplate/time.h
+++ b/include/boilerplate/time.h
@@ -44,6 +44,9 @@ void timespec_adds(struct timespec *__restrict r,
   const struct timespec *__restrict t1,
   sticks_t t2);
 
+void timespec_sets(struct timespec *__restrict r,
+  ticks_t ns);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/boilerplate/time.c b/lib/boilerplate/time.c
index 547f899..d112593 100644
--- a/lib/boilerplate/time.c
+++ b/lib/boilerplate/time.c
@@ -72,3 +72,14 @@ void timespec_adds(struct timespec *__restrict r,
r->tv_nsec -= 10;
}
 }
+
+void timespec_sets(struct timespec *__restrict r,
+  ticks_t ns)
+{
+   r->tv_sec = ns / 10UL;
+   r->tv_nsec = ns - r->tv_sec * 10UL;
+   if (r->tv_nsec >= 10) {
+   r->tv_sec++;
+   r->tv_nsec -= 10;
+   }
+}


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : drivers/gpio: introduce real-time GPIO support

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: d0adf70c4a58c9ccc113ec54f4e07d0cc6261d5c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d0adf70c4a58c9ccc113ec54f4e07d0cc6261d5c

Author: Philippe Gerum 
Date:   Wed May 25 10:54:22 2016 +0200

drivers/gpio: introduce real-time GPIO support

---

 configure.ac   |1 +
 include/rtdm/Makefile.am   |1 +
 include/rtdm/gpio.h|   24 +++
 include/rtdm/uapi/Makefile.am  |1 +
 include/rtdm/uapi/gpio.h   |   28 +++
 include/rtdm/uapi/rtdm.h   |1 +
 kernel/drivers/Kconfig |1 +
 kernel/drivers/Makefile|2 +-
 kernel/drivers/gpio/Kconfig|   25 +++
 kernel/drivers/gpio/Makefile   |7 +
 kernel/drivers/gpio/gpio-bcm2708.c |   39 
 kernel/drivers/gpio/gpio-core.c|  349 
 kernel/drivers/gpio/gpio-core.h|   48 +
 kernel/drivers/gpio/gpio-mxc.c |   67 +++
 14 files changed, 593 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index b33ff12..1f3c4fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -884,6 +884,7 @@ AC_CONFIG_FILES([ \
testsuite/Makefile \
testsuite/latency/Makefile \
testsuite/switchtest/Makefile \
+   testsuite/gpiotest/Makefile \
testsuite/smokey/Makefile \
testsuite/smokey/arith/Makefile \
testsuite/smokey/sched-quota/Makefile \
diff --git a/include/rtdm/Makefile.am b/include/rtdm/Makefile.am
index a8773ed..c837a05 100644
--- a/include/rtdm/Makefile.am
+++ b/include/rtdm/Makefile.am
@@ -7,6 +7,7 @@ includesub_HEADERS +=   \
analogy.h   \
autotune.h  \
can.h   \
+   gpio.h  \
ipc.h   \
serial.h\
testing.h   \
diff --git a/include/rtdm/gpio.h b/include/rtdm/gpio.h
new file mode 100644
index 000..c61f229
--- /dev/null
+++ b/include/rtdm/gpio.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2016 Philippe Gerum 
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+#ifndef _RTDM_GPIO_H
+#define _RTDM_GPIO_H
+
+#include 
+#include 
+
+#endif /* !_RTDM_GPIO_H */
diff --git a/include/rtdm/uapi/Makefile.am b/include/rtdm/uapi/Makefile.am
index 9560310..c288ff9 100644
--- a/include/rtdm/uapi/Makefile.am
+++ b/include/rtdm/uapi/Makefile.am
@@ -7,6 +7,7 @@ includesub_HEADERS +=   \
analogy.h   \
autotune.h  \
can.h   \
+   gpio.h  \
ipc.h   \
serial.h\
testing.h   \
diff --git a/include/rtdm/uapi/gpio.h b/include/rtdm/uapi/gpio.h
new file mode 100644
index 000..b0d4899
--- /dev/null
+++ b/include/rtdm/uapi/gpio.h
@@ -0,0 +1,28 @@
+/**
+ * @note Copyright (C) 2016 Philippe Gerum 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#ifndef _RTDM_UAPI_GPIO_H
+#define _RTDM_UAPI_GPIO_H
+
+#include 
+
+#define GPIO_RTIOC_DIR_OUT _IOW(RTDM_CLASS_GPIO, 0, int)
+#define GPIO_RTIOC_DIR_IN  _IO(RTDM_CLASS_GPIO, 1)
+#define GPIO_RTIOC_IRQEN   _IO(RTDM_CLASS_GPIO, 2)
+#define GPIO_RTIOC_IRQDIS  _IO(RTDM_CLASS_GPIO, 3)
+
+#endif /* !_RTDM_UAPI_GPIO_H */
diff --git a/include/rtdm/uapi/rtdm.h b/include/rtdm/uapi/rtdm.h
index eed3b36..c49378c 100644
--- a/include/rtdm/uapi/rtdm.h
+++ b/include/rtdm/uapi/rtdm.h
@@ -79,6 +79,7 @@ typedef int64_t nanosecs_rel_t;
 #define RTDM_CLASS_COBALT  8
 #define RTDM_CLASS_UDD 9
 #define RTDM_CLASS_MEMORY 

[Xenomai-git] Philippe Gerum : cobalt/posix/timer: allow usage with external clocks

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: e6cd9610215b06ee85272f57702354a7e38b5f7c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e6cd9610215b06ee85272f57702354a7e38b5f7c

Author: Philippe Gerum 
Date:   Fri Nov  4 16:25:15 2016 +0100

cobalt/posix/timer: allow usage with external clocks

There is no reason to restrict usage of POSIX timers to the standard
POSIX clocks, given that Cobalt allows registering user-defined
clocks, and nothing in the implementation assumes a specific clock
driving such timers.

---

 kernel/cobalt/posix/clock.c |   23 +++
 kernel/cobalt/posix/clock.h |   22 +-
 kernel/cobalt/posix/timer.c |   19 +++
 3 files changed, 39 insertions(+), 25 deletions(-)

diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
index b51cb4c..8dab55b 100644
--- a/kernel/cobalt/posix/clock.c
+++ b/kernel/cobalt/posix/clock.c
@@ -349,3 +349,26 @@ void cobalt_clock_deregister(struct xnclock *clock)
xnclock_deregister(clock);
 }
 EXPORT_SYMBOL_GPL(cobalt_clock_deregister);
+
+struct xnclock *cobalt_clock_find(clockid_t clock_id)
+{
+   struct xnclock *clock = ERR_PTR(-EINVAL);
+   spl_t s;
+   int nr;
+
+   if (clock_id == CLOCK_MONOTONIC ||
+   clock_id == CLOCK_MONOTONIC_RAW ||
+   clock_id == CLOCK_REALTIME)
+   return 
+   
+   if (__COBALT_CLOCK_EXT_P(clock_id)) {
+   nr = __COBALT_CLOCK_EXT_INDEX(clock_id);
+   xnlock_get_irqsave(, s);
+   if (test_bit(nr, cobalt_clock_extids))
+   clock = external_clocks[nr];
+   xnlock_put_irqrestore(, s);
+   }
+
+   return clock;
+}
+EXPORT_SYMBOL_GPL(cobalt_clock_find);
diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
index 82cb0b6..c77c3a5 100644
--- a/kernel/cobalt/posix/clock.h
+++ b/kernel/cobalt/posix/clock.h
@@ -26,6 +26,8 @@
 
 #define ONE_BILLION 10
 
+struct xnclock;
+
 static inline void ns2ts(struct timespec *ts, xnticks_t nsecs)
 {
ts->tv_sec = xnclock_divrem_billion(nsecs, >tv_nsec);
@@ -68,21 +70,13 @@ static inline xnticks_t clock_get_ticks(clockid_t clock_id)
 
 static inline int clock_flag(int flag, clockid_t clock_id)
 {
-   switch(flag & TIMER_ABSTIME) {
-   case 0:
+   if ((flag & TIMER_ABSTIME) == 0)
return XN_RELATIVE;
 
-   case TIMER_ABSTIME:
-   switch(clock_id) {
-   case CLOCK_MONOTONIC:
-   case CLOCK_MONOTONIC_RAW:
-   return XN_ABSOLUTE;
-
-   case CLOCK_REALTIME:
-   return XN_REALTIME;
-   }
-   }
-   return -EINVAL;
+   if (clock_id == CLOCK_REALTIME)
+   return XN_REALTIME;
+
+   return XN_ABSOLUTE;
 }
 
 int __cobalt_clock_getres(clockid_t clock_id,
@@ -118,6 +112,8 @@ int cobalt_clock_register(struct xnclock *clock,
 
 void cobalt_clock_deregister(struct xnclock *clock);
 
+struct xnclock *cobalt_clock_find(clockid_t clock_id);
+
 extern DECLARE_BITMAP(cobalt_clock_extids, COBALT_MAX_EXTCLOCKS);
 
 #endif /* !_COBALT_POSIX_CLOCK_H */
diff --git a/kernel/cobalt/posix/timer.c b/kernel/cobalt/posix/timer.c
index cf1c919..c6190d1 100644
--- a/kernel/cobalt/posix/timer.c
+++ b/kernel/cobalt/posix/timer.c
@@ -47,6 +47,7 @@ timer_init(struct cobalt_timer *timer,
   const struct sigevent *__restrict__ evp) /* nklocked, IRQs off. */
 {
struct cobalt_thread *owner = cobalt_current_thread(), *target = NULL;
+   struct xnclock *clock;
 
/*
 * First, try to offload this operation to the extended
@@ -59,14 +60,8 @@ timer_init(struct cobalt_timer *timer,
/*
 * Ok, we have no extension available, or we do but it does
 * not want to overload the standard behavior: handle this
-* timer the pure Cobalt way then. We only know about standard
-* clocks in this case.
+* timer the pure Cobalt way then.
 */
-   if (timer->clockid != CLOCK_MONOTONIC &&
-   timer->clockid != CLOCK_MONOTONIC_RAW &&
-   timer->clockid != CLOCK_REALTIME)
-   return ERR_PTR(-EINVAL);
-
if (evp == NULL || evp->sigev_notify == SIGEV_NONE) {
target = owner; /* Assume SIGEV_THREAD_ID. */
goto init;
@@ -83,11 +78,11 @@ timer_init(struct cobalt_timer *timer,
if (target == NULL)
return ERR_PTR(-EINVAL);
 init:
-   /*
-* All standard clocks are based on the core clock, and we
-* want to deliver a signal when a timer elapses.
-*/
-   xntimer_init(>timerbase, , cobalt_timer_handler,
+   clock = cobalt_clock_find(timer->clockid);
+   if (IS_ERR(clock))
+   return ERR_PTR(PTR_ERR(clock));
+
+   xntimer_init(>timerbase, clock, cobalt_timer_handler,
 target->threadbase.sched, 

[Xenomai-git] Philippe Gerum : demo/cross-link: fix multiple error reports

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 8fe023a422aab5cebfbd0363d6f06cbe2386eca4
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8fe023a422aab5cebfbd0363d6f06cbe2386eca4

Author: Philippe Gerum 
Date:   Tue Nov 29 09:37:48 2016 +0100

demo/cross-link: fix multiple error reports

---

 demo/alchemy/cobalt/cross-link.c |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/demo/alchemy/cobalt/cross-link.c b/demo/alchemy/cobalt/cross-link.c
index 8c0f53f..9b1fb34 100644
--- a/demo/alchemy/cobalt/cross-link.c
+++ b/demo/alchemy/cobalt/cross-link.c
@@ -89,7 +89,7 @@ static int close_file( int fd, char *name)
break;
default:
printf(MAIN_PREFIX "%s -> %s\n", name,
-  strerror(-err));
+  strerror(errno));
break;
}
} while (err == -EAGAIN && i < 10);
@@ -158,7 +158,7 @@ static void write_task_proc(void *arg)
written = write(write_fd, _time, sz);
if (written < 0 ) {
printf(WTASK_PREFIX "error on write, %s\n",
-  strerror(-err));
+  strerror(errno));
break;
} else if (written != sz) {
printf(WTASK_PREFIX "only %d / %zd byte transmitted\n",
@@ -201,7 +201,7 @@ static void read_task_proc(void *arg)
if (err) {
printf(RTASK_PREFIX
   "error on RTSER_RTIOC_WAIT_EVENT, %s\n",
-  strerror(-err));
+  strerror(errno));
if (err == -ETIMEDOUT)
continue;
break;
@@ -218,7 +218,7 @@ static void read_task_proc(void *arg)
nr++;
} else if (rd < 0 ) {
printf(RTASK_PREFIX "error on read, code %s\n",
-  strerror(-err));
+  strerror(errno));
break;
} else {
printf(RTASK_PREFIX "only %d / %zd byte received \n",
@@ -245,7 +245,7 @@ int main(int argc, char* argv[])
write_fd = open( WRITE_FILE, 0);
if (write_fd < 0) {
printf(MAIN_PREFIX "can't open %s (write), %s\n", WRITE_FILE,
-  strerror(-write_fd));
+  strerror(errno));
goto error;
}
write_state |= STATE_FILE_OPENED;
@@ -255,7 +255,7 @@ int main(int argc, char* argv[])
err = ioctl(write_fd, RTSER_RTIOC_SET_CONFIG, _config);
if (err) {
printf(MAIN_PREFIX "error while RTSER_RTIOC_SET_CONFIG, %s\n",
-  strerror(-err));
+  strerror(errno));
goto error;
}
printf(MAIN_PREFIX "write-config written\n");
@@ -264,7 +264,7 @@ int main(int argc, char* argv[])
read_fd = open( READ_FILE, 0 );
if (read_fd < 0) {
printf(MAIN_PREFIX "can't open %s (read), %s\n", READ_FILE,
-  strerror(-read_fd));
+  strerror(errno));
goto error;
}
read_state |= STATE_FILE_OPENED;
@@ -274,7 +274,7 @@ int main(int argc, char* argv[])
err = ioctl(read_fd, RTSER_RTIOC_SET_CONFIG, _config);
if (err) {
printf(MAIN_PREFIX "error while ioctl, %s\n",
-  strerror(-err));
+  strerror(errno));
goto error;
}
printf(MAIN_PREFIX "read-config written\n");


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/timer: fix build issue w/ CONFIG_SMP off

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 15620f7d298889ac6ba9da11ea1bbf70b6065e94
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=15620f7d298889ac6ba9da11ea1bbf70b6065e94

Author: Philippe Gerum 
Date:   Sat Nov 19 11:14:55 2016 +0100

cobalt/timer: fix build issue w/ CONFIG_SMP off

---

 include/cobalt/kernel/timer.h |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h
index 86ac7a7..3c75354 100644
--- a/include/cobalt/kernel/timer.h
+++ b/include/cobalt/kernel/timer.h
@@ -522,6 +522,9 @@ int xntimer_setup_ipi(void);
 
 void xntimer_release_ipi(void);
 
+bool xntimer_set_sched(struct xntimer *timer,
+  struct xnsched *sched);
+
 #else /* ! CONFIG_SMP */
 
 static inline void xntimer_migrate(struct xntimer *timer,
@@ -535,10 +538,13 @@ static inline int xntimer_setup_ipi(void)
 
 static inline void xntimer_release_ipi(void) { }
 
-#endif /* CONFIG_SMP */
+static inline bool xntimer_set_sched(struct xntimer *timer,
+struct xnsched *sched)
+{
+   return true;
+}
 
-bool xntimer_set_sched(struct xntimer *timer,
-  struct xnsched *sched);
+#endif /* CONFIG_SMP */
 
 char *xntimer_format_time(xnticks_t ns,
  char *buf, size_t bufsz);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Ronny Meeus : include/psos: remove dependency on tunables.h

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: dfec891315969f92aec781d037dd5cbb11cbdb1c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=dfec891315969f92aec781d037dd5cbb11cbdb1c

Author: Ronny Meeus 
Date:   Tue Nov 29 15:03:00 2016 +0100

include/psos: remove dependency on tunables.h

The psos.h file pollutes the application's namespace with defines
of the boilerplate code because the tunables.h is included. In our
application we already have a definition of the list_entry macro,
resulting in a redefinition. The psos.h should be kept clean.

Following small test program clearly shows the issue:

int main(int argc, char * const argv[])
{
  return 0;
}

When compiling the code above a warning is generated:

simple_test.c:3:1: warning: "list_entry" redefined
In file included from boilerplate/list.h:24,
 from boilerplate/setup.h:21,
 from boilerplate/tunables.h:22,
 from psos/psos.h:28,
 from simple_test.c:1:
boilerplate/shared-list.h:233:1: warning: this is the location of the previous 
definition

This patch resolves the issue by moving the tunable related functionality in
a seperate header file.

---

 include/psos/Makefile.am |4 +++-
 include/psos/psos.h  |   13 
 include/psos/tunables.h  |   49 ++
 3 files changed, 52 insertions(+), 14 deletions(-)

diff --git a/include/psos/Makefile.am b/include/psos/Makefile.am
index 0174271..ee7c5c8 100644
--- a/include/psos/Makefile.am
+++ b/include/psos/Makefile.am
@@ -1,3 +1,5 @@
 includesubdir = $(includedir)/psos
 
-includesub_HEADERS = psos.h
+includesub_HEADERS = \
+   psos.h \
+   tunables.h
diff --git a/include/psos/psos.h b/include/psos/psos.h
index a6f1559..1554244 100644
--- a/include/psos/psos.h
+++ b/include/psos/psos.h
@@ -25,7 +25,6 @@
 #define _XENOMAI_PSOS_PSOS_H
 
 #include 
-#include 
 
 #ifndef SUCCESS
 #define SUCCESS 0
@@ -370,18 +369,6 @@ int psos_task_normalize_priority(u_long psos_prio);
 
 u_long psos_task_denormalize_priority(int core_prio);
 
-extern int psos_long_names;
-
-static inline define_config_tunable(long_names, int, on)
-{
-   psos_long_names = on;
-}
-
-static inline read_config_tunable(long_names, int)
-{
-   return psos_long_names;
-}
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/include/psos/tunables.h b/include/psos/tunables.h
new file mode 100644
index 000..2dbd3f0
--- /dev/null
+++ b/include/psos/tunables.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2001-2010 Philippe Gerum .
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ *
+ * This file satisfies the references within the emulator code
+ * mimicking a pSOS-like API built upon the copperplate library.
+ *
+ * pSOS and pSOS+ are registered trademarks of Wind River Systems, Inc.
+ */
+
+#ifndef _XENOMAI_PSOS_TUNABLES_H
+#define _XENOMAI_PSOS_TUNABLES_H
+
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+extern int psos_long_names;
+
+static inline define_config_tunable(long_names, int, on)
+{
+   psos_long_names = on;
+}
+
+static inline read_config_tunable(long_names, int)
+{
+   return psos_long_names;
+}
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* !_XENOMAI_PSOS_TUNABLES_H */


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/clock: add support for devices without percpu semantics

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 596acc3ce2f77bab32bc36ec2666e79d4d5c00f4
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=596acc3ce2f77bab32bc36ec2666e79d4d5c00f4

Author: Philippe Gerum 
Date:   Wed Nov 16 20:49:47 2016 +0100

cobalt/clock: add support for devices without percpu semantics

Some clock devices have no percpu semantics. Passing a NULL affinity
mask to xnclock_register() (and cobalt_clock_register() as well) now
causes all timers for any such clock to be maintained into a single
queue xnclock_tick() will inspect exclusively regardless of the
current CPU.

---

 include/cobalt/kernel/timer.h |9 --
 kernel/cobalt/clock.c |   65 ++---
 kernel/cobalt/timer.c |   22 +-
 3 files changed, 63 insertions(+), 33 deletions(-)

diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h
index 700392e..86ac7a7 100644
--- a/include/cobalt/kernel/timer.h
+++ b/include/cobalt/kernel/timer.h
@@ -311,15 +311,6 @@ static inline struct xnsched *xntimer_sched(struct xntimer 
*timer)
>q;\
})
 
-static inline xntimerq_t *xntimer_this_queue(struct xntimer *timer)
-{
-   struct xntimerdata *tmd;
-
-   tmd = xnclock_this_timerdata(xntimer_clock(timer));
-
-   return >q;
-}
-
 static inline unsigned long xntimer_gravity(struct xntimer *timer)
 {
struct xnclock *clock = xntimer_clock(timer);
diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index a4d0df8..796358f 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -137,6 +137,10 @@ void xnclock_core_local_shot(struct xnsched *sched)
if (sched->status & XNINTCK)
return;
 
+   /*
+* Assume the core clock device always has percpu semantics in
+* SMP.
+*/
tmd = xnclock_this_timerdata();
h = xntimerq_head(>q);
if (h == NULL)
@@ -334,7 +338,13 @@ int xnclock_get_default_cpu(struct xnclock *clock, int cpu)
 * suggested CPU does not receive events from this device,
 * return the first one which does.  We also account for the
 * dynamic set of real-time CPUs.
+*
+* A clock device with no percpu semantics causes this routine
+* to return CPU0 unconditionally.
 */
+   if (cpumask_empty(>affinity))
+   return 0;
+   
cpumask_and(, >affinity, _cpu_affinity);
if (!cpumask_empty() && !cpumask_test_cpu(cpu, ))
cpu = cpumask_first();
@@ -620,7 +630,10 @@ static inline void cleanup_clock_proc(struct xnclock 
*clock) { }
  * @param clock The new clock to register.
  *
  * @param affinity The set of CPUs we may expect the backing clock
- * device to tick on.
+ * device to tick on. As a special case, passing a NULL affinity mask
+ * means that timer IRQs cannot be seen as percpu events, in which
+ * case all outstanding timers will be maintained into a single global
+ * queue instead of percpu timer queues.
  *
  * @coretags{secondary-only}
  */
@@ -633,14 +646,17 @@ int xnclock_register(struct xnclock *clock, const 
cpumask_t *affinity)
 
 #ifdef CONFIG_SMP
/*
-* A CPU affinity set is defined for each clock, enumerating
-* the CPUs which can receive ticks from the backing clock
-* device.  This set must be a subset of the real-time CPU
-* set.
+* A CPU affinity set may be defined for each clock,
+* enumerating the CPUs which can receive ticks from the
+* backing clock device.  When given, this set must be a
+* subset of the real-time CPU set.
 */
-   cpumask_and(>affinity, affinity, _realtime_cpus);
-   if (cpumask_empty(>affinity))
-   return -EINVAL;
+   if (affinity) {
+   cpumask_and(>affinity, affinity, _realtime_cpus);
+   if (cpumask_empty(>affinity))
+   return -EINVAL;
+   } else  /* No percpu semantics. */
+   cpumask_clear(>affinity);
 #endif
 
/* Allocate the percpu timer queue slot. */
@@ -651,7 +667,8 @@ int xnclock_register(struct xnclock *clock, const cpumask_t 
*affinity)
/*
 * POLA: init all timer slots for the new clock, although some
 * of them might remain unused depending on the CPU affinity
-* of the event source(s).
+* of the event source(s). If the clock device has no percpu
+* semantics, all timers will be queued to slot #0.
 */
for_each_online_cpu(cpu) {
tmd = xnclock_percpu_timerdata(clock, cpu);
@@ -712,18 +729,32 @@ EXPORT_SYMBOL_GPL(xnclock_deregister);
  *
  * @coretags{coreirq-only, atomic-entry}
  *
- * @note The current CPU must be part of the real-time affinity set,
- * otherwise weird things may happen.
+ * @note The current CPU must be part of the real-time affinity set
+ * unless the 

[Xenomai-git] Jan Kiszka : net/drivers/pcnet32: Replace deprecated pci_dma_supported with dma_supported

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: b0f8a6cb0260117a14d46de02a4564e3fa5498c7
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b0f8a6cb0260117a14d46de02a4564e3fa5498c7

Author: Jan Kiszka 
Date:   Thu Dec  1 17:16:16 2016 +0100

net/drivers/pcnet32: Replace deprecated pci_dma_supported with dma_supported

The old function is no longer available with latest kernels.

Signed-off-by: Jan Kiszka 

---

 kernel/drivers/net/drivers/pcnet32.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/drivers/net/drivers/pcnet32.c 
b/kernel/drivers/net/drivers/pcnet32.c
index 7dfe28f..b041397 100644
--- a/kernel/drivers/net/drivers/pcnet32.c
+++ b/kernel/drivers/net/drivers/pcnet32.c
@@ -513,7 +513,7 @@ static int pcnet32_probe_pci(struct pci_dev *pdev, const 
struct pci_device_id *e
return -ENODEV;
 }
 
-if (!pci_dma_supported(pdev, PCNET32_DMA_MASK)) {
+if (!dma_supported(>dev, PCNET32_DMA_MASK)) {
printk(KERN_ERR PFX "architecture does not support 32bit PCI busmaster 
DMA\n");
return -ENODEV;
 }


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/rtdm: allow polling events from secondary/ IRQ context

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 91010aab23e6ae8993a136b1a64c20daf0a89b4b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=91010aab23e6ae8993a136b1a64c20daf0a89b4b

Author: Philippe Gerum 
Date:   Wed Dec 14 15:06:34 2016 +0100

cobalt/rtdm: allow polling events from secondary/IRQ context

Invoking timed services for receiving events in polled mode (timeout
== RTDM_TIMEOUT_NONE) is always valid regardless of the calling
context. Do not trigger assertions when doing so.

---

 kernel/cobalt/init.c|3 ++-
 kernel/cobalt/rtdm/drvlib.c |8 
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/kernel/cobalt/init.c b/kernel/cobalt/init.c
index 5a6fdbf..1f7ce49 100644
--- a/kernel/cobalt/init.c
+++ b/kernel/cobalt/init.c
@@ -445,10 +445,11 @@ device_initcall(xenomai_init);
  * 
  * Tag Context on entry
  * primary-only   Must be called from a Cobalt task in 
primary mode
+ * primary-timed  Requires a Cobalt task in primary mode if 
timed
  * coreirq-only   Must be called from a Cobalt IRQ 
handler
  * secondary-only Must be called from a Cobalt task in 
secondary mode or regular Linux task
  * rtdm-task  Must be called from a RTDM driver 
task
- * mode-unrestricted  Must be called from a Cobalt task 
in either primary or secondary mode
+ * mode-unrestricted  May be called from a Cobalt task in 
either primary or secondary mode
  * task-unrestricted  May be called from a Cobalt or 
regular Linux task indifferently
  * unrestricted   May be called from any context previously 
described
  * atomic-entry   Caller must currently hold the big Cobalt 
kernel lock (nklock)
diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index 629c555..1a79121 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -858,7 +858,7 @@ EXPORT_SYMBOL_GPL(rtdm_event_wait);
  * - -EWOULDBLOCK is returned if a negative @a timeout (i.e., non-blocking
  * operation) has been specified.
  *
- * @coretags{primary-only, might-switch}
+ * @coretags{primary-timed, might-switch}
  */
 int rtdm_event_timedwait(rtdm_event_t *event, nanosecs_rel_t timeout,
 rtdm_toseq_t *timeout_seq)
@@ -867,7 +867,7 @@ int rtdm_event_timedwait(rtdm_event_t *event, 
nanosecs_rel_t timeout,
int err = 0, ret;
spl_t s;
 
-   if (!XENO_ASSERT(COBALT, !xnsched_unblockable_p()))
+   if (!XENO_ASSERT(COBALT, timeout < 0 || !xnsched_unblockable_p()))
return -EPERM;
 
trace_cobalt_driver_event_wait(event, xnthread_current());
@@ -1091,7 +1091,7 @@ EXPORT_SYMBOL_GPL(rtdm_sem_down);
  * - -EPERM @e may be returned if an illegal invocation environment is
  * detected.
  *
- * @coretags{primary-only, might-switch}
+ * @coretags{primary-timed, might-switch}
  */
 int rtdm_sem_timeddown(rtdm_sem_t *sem, nanosecs_rel_t timeout,
   rtdm_toseq_t *timeout_seq)
@@ -1100,7 +1100,7 @@ int rtdm_sem_timeddown(rtdm_sem_t *sem, nanosecs_rel_t 
timeout,
int err = 0, ret;
spl_t s;
 
-   if (!XENO_ASSERT(COBALT, !xnsched_unblockable_p()))
+   if (!XENO_ASSERT(COBALT, timeout < 0 || !xnsched_unblockable_p()))
return -EPERM;
 
trace_cobalt_driver_sem_wait(sem, xnthread_current());


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : boilerplate/list: add list_{prev, next}_entry() accessors

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: c35e76631e22a17b3f1387e7e95efa08b8accc96
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c35e76631e22a17b3f1387e7e95efa08b8accc96

Author: Philippe Gerum 
Date:   Wed Sep 28 18:26:38 2016 +0200

boilerplate/list: add list_{prev, next}_entry() accessors

---

 include/boilerplate/private-list.h |   18 ++
 include/boilerplate/shared-list.h  |   24 
 2 files changed, 42 insertions(+)

diff --git a/include/boilerplate/private-list.h 
b/include/boilerplate/private-list.h
index f5aafac..72f1e4c 100644
--- a/include/boilerplate/private-list.h
+++ b/include/boilerplate/private-list.h
@@ -146,6 +146,24 @@ static inline int pvlist_heading_p(const struct pvholder 
*holder,
 #define pvlist_last_entry(list, type, member)  \
pvlist_entry((list)->head.prev, type, member)
 
+#define pvlist_prev_entry(pos, list, member)   \
+   ({  \
+   typeof(*pos) *__prev = NULL;\
+   if ((list)->head.next != &(pos)->member)\
+   __prev = pvlist_entry((pos)->member.prev,   \
+ typeof(*pos), member);\
+   __prev; \
+   })
+
+#define pvlist_next_entry(pos, list, member)   \
+   ({  \
+   typeof(*pos) *__next = NULL;\
+   if ((list)->head.prev != &(pos)->member)\
+   __next = pvlist_entry((pos)->member.next,   \
+ typeof(*pos), member);\
+   __next; \
+   })
+
 #define pvlist_pop_entry(list, type, member) ({
\
struct pvholder *__holder = pvlist_pop(list);   \
pvlist_entry(__holder, type, member); })
diff --git a/include/boilerplate/shared-list.h 
b/include/boilerplate/shared-list.h
index 0f88d6f..741dfc0 100644
--- a/include/boilerplate/shared-list.h
+++ b/include/boilerplate/shared-list.h
@@ -245,6 +245,30 @@ static inline int list_heading_p(const struct holder 
*holder,
 #define list_last_entry(list, type, member)\
__list_last_entry(__main_heap, list, type, member)
 
+#define __list_prev_entry(heap, pos, list, member) \
+   ({  \
+   typeof(*pos) *__prev = NULL;\
+   if ((list)->head.next != __hoff(heap, &(pos)->member))  \
+   __prev = list_entry(__hptr((heap),  \
+  (pos)->member.prev), typeof(*pos), member);  \
+   __prev; \
+   })
+
+#define list_prev_entry(pos, list, member) \
+   __list_prev_entry(__main_heap, pos, list, member)
+
+#define __list_next_entry(heap, pos, list, member) \
+   ({  \
+   typeof(*pos) *__next = NULL;\
+   if ((list)->head.prev != __hoff(heap, &(pos)->member))  \
+   __next = list_entry(__hptr((heap),  \
+  (pos)->member.next), typeof(*pos), member);  \
+   __next; \
+   })
+
+#define list_next_entry(pos, list, member) \
+   __list_next_entry(__main_heap, pos, list, member)
+
 #define __list_pop_entry(heap, list, type, member) ({  \
struct holder *__holder = __list_pop((heap), list); \
list_entry(__holder, type, member); })


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : include/rtdm: mercury: export basic RTDM definitions

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: acde09bc494c5a13652548f0f5778842ddf8f90e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=acde09bc494c5a13652548f0f5778842ddf8f90e

Author: Philippe Gerum 
Date:   Tue Dec 13 11:35:50 2016 +0100

include/rtdm: mercury: export basic RTDM definitions

The basic RTDM definitions and data types should be exposed to
Mercury-based applications, since the native RTDM implementation
should use them over the POSIX I/O interface the same way.

---

 include/Makefile.am   |5 ++---
 include/rtdm/Makefile.am  |7 +--
 include/rtdm/uapi/Makefile.am |7 +--
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/Makefile.am b/include/Makefile.am
index f1b5738..1e9fe02 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -6,14 +6,13 @@ SUBDIRS = \
smokey  \
alchemy \
psos\
+   rtdm\
trank   \
vxworks \
xenomai
 
 if XENO_COBALT
-SUBDIRS += \
-   cobalt  \
-   rtdm
+SUBDIRS += cobalt
 else
 SUBDIRS += mercury
 endif
diff --git a/include/rtdm/Makefile.am b/include/rtdm/Makefile.am
index a4e6ff8..a8773ed 100644
--- a/include/rtdm/Makefile.am
+++ b/include/rtdm/Makefile.am
@@ -1,13 +1,16 @@
 includesubdir = $(includedir)/rtdm
 
-includesub_HEADERS =   \
+includesub_HEADERS = rtdm.h
+
+if XENO_COBALT
+includesub_HEADERS +=  \
analogy.h   \
autotune.h  \
can.h   \
ipc.h   \
-   rtdm.h  \
serial.h\
testing.h   \
udd.h
+endif
 
 SUBDIRS = uapi
diff --git a/include/rtdm/uapi/Makefile.am b/include/rtdm/uapi/Makefile.am
index 7cff6c2..9560310 100644
--- a/include/rtdm/uapi/Makefile.am
+++ b/include/rtdm/uapi/Makefile.am
@@ -1,11 +1,14 @@
 includesubdir = $(includedir)/rtdm/uapi
 
-includesub_HEADERS =   \
+includesub_HEADERS = rtdm.h
+
+if XENO_COBALT
+includesub_HEADERS +=  \
analogy.h   \
autotune.h  \
can.h   \
ipc.h   \
-   rtdm.h  \
serial.h\
testing.h   \
udd.h
+endif


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : testsuite/gpiotest: add GPIO test suite

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 0165782dbde8cea4da45cd65df0c7e5f7fc17e12
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0165782dbde8cea4da45cd65df0c7e5f7fc17e12

Author: Philippe Gerum 
Date:   Wed Jun  1 15:59:27 2016 +0200

testsuite/gpiotest: add GPIO test suite

---

 testsuite/Makefile.am  |2 +
 testsuite/gpiotest/Makefile.am |   19 
 testsuite/gpiotest/gpiotest.c  |  188 
 3 files changed, 209 insertions(+)

diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index e83e6cb..c345472 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -4,12 +4,14 @@ SUBDIRS = latency smokey
 if XENO_COBALT
 SUBDIRS += \
clocktest   \
+   gpiotest\
switchtest  \
xeno-test
 endif
 
 DIST_SUBDIRS = \
clocktest   \
+   gpiotest\
latency \
smokey  \
switchtest  \
diff --git a/testsuite/gpiotest/Makefile.am b/testsuite/gpiotest/Makefile.am
new file mode 100644
index 000..b01427b
--- /dev/null
+++ b/testsuite/gpiotest/Makefile.am
@@ -0,0 +1,19 @@
+testdir = @XENO_TEST_DIR@
+
+CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
+
+test_PROGRAMS = gpiotest
+
+gpiotest_SOURCES = gpiotest.c
+
+gpiotest_CPPFLAGS =\
+   $(XENO_USER_CFLAGS) \
+   -I$(top_srcdir)/include
+
+gpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS)
+
+gpiotest_LDADD =   \
+   ../../lib/smokey/libsmokey.la   \
+   ../../lib/@XENO_CORE_LIB@   \
+@XENO_USER_LDADD@  \
+   -lpthread -lrt
diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c
new file mode 100644
index 000..838f498
--- /dev/null
+++ b/testsuite/gpiotest/gpiotest.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2016 Philippe Gerum .
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+smokey_test_plugin(interrupt,
+  SMOKEY_ARGLIST(
+  SMOKEY_STRING(device),
+  ),
+   "Wait for interrupts from a GPIO pin.\n"
+   "\tdevice=."
+);
+
+smokey_test_plugin(read_value,
+  SMOKEY_ARGLIST(
+  SMOKEY_STRING(device),
+  ),
+   "Read GPIO value.\n"
+   "\tdevice=."
+);
+
+smokey_test_plugin(write_value,
+  SMOKEY_ARGLIST(
+  SMOKEY_STRING(device),
+  ),
+   "Write GPIO value.\n"
+   "\tdevice=."
+);
+
+static int run_interrupt(struct smokey_test *t, int argc, char *const argv[])
+{
+   const char *device = NULL;
+   int fd, ret;
+   fd_set set;
+   
+   smokey_parse_args(t, argc, argv);
+
+   if (!SMOKEY_ARG_ISSET(interrupt, device)) {
+   warning("missing device= specification");
+   return -EINVAL;
+   }
+
+   device = SMOKEY_ARG_STRING(interrupt, device);
+   fd = open(device, O_RDWR);
+   if (fd < 0) {
+   ret = -errno;
+   warning("cannot open device %s [%s]",
+   device, symerror(ret));
+   return ret;
+   }
+
+   ret = ioctl(fd, GPIO_RTIOC_IRQEN);
+   if (ret) {
+   ret = -errno;
+   warning("GPIO_RTIOC_IRQEN failed on %s [%s]",
+   device, symerror(ret));
+   return ret;
+   }
+
+   FD_ZERO();
+   FD_SET(fd, );
+   
+   for (;;) {
+   ret = select(fd + 1, , NULL, NULL, NULL);
+   if (ret < 0) {
+   ret = -errno;
+   warning("failed listening to %s [%s]",
+   device, symerror(ret));
+   }
+   printf("kick %d!\n", ret);
+   }
+
+   close(fd);
+
+   return 0;
+}
+
+static int run_read_value(struct smokey_test *t, int argc, char *const argv[])
+{
+   const char *device = NULL;
+   int fd, ret, value = -1;
+
+   smokey_parse_args(t, argc, argv);
+
+   if (!SMOKEY_ARG_ISSET(read_value, device)) {
+   warning("missing device= specification");
+ 

[Xenomai-git] Philippe Gerum : cobalt/clock: fix build issue w/ CONFIG_SMP off

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 8559d512a19a4b49fb0fc365a271627802d93c47
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8559d512a19a4b49fb0fc365a271627802d93c47

Author: Philippe Gerum 
Date:   Fri Nov 18 19:05:19 2016 +0100

cobalt/clock: fix build issue w/ CONFIG_SMP off

---

 kernel/cobalt/clock.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index 796358f..61778cd 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -744,6 +744,7 @@ void xnclock_tick(struct xnclock *clock)
 
atomic_only();
 
+#ifdef CONFIG_SMP
/*
 * Some external clock devices may have no percpu semantics,
 * in which case all timers are queued to slot #0.
@@ -753,6 +754,7 @@ void xnclock_tick(struct xnclock *clock)
!cpumask_test_cpu(xnsched_cpu(sched), >affinity))
tmq = _percpu_timerdata(clock, 0)->q;
else
+#endif
tmq = _this_timerdata(clock)->q;

/*


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : boilerplate/ancillaries: fix unique name generation in pshared mode

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: e539ab0b1db5ca56f8d3db39d2ca0bdf009c9b25
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e539ab0b1db5ca56f8d3db39d2ca0bdf009c9b25

Author: Philippe Gerum 
Date:   Tue Sep 13 09:36:11 2016 +0200

boilerplate/ancillaries: fix unique name generation in pshared mode

---

 lib/boilerplate/ancillaries.c |4 
 1 file changed, 4 insertions(+)

diff --git a/lib/boilerplate/ancillaries.c b/lib/boilerplate/ancillaries.c
index a811a40..0f469a4 100644
--- a/lib/boilerplate/ancillaries.c
+++ b/lib/boilerplate/ancillaries.c
@@ -231,7 +231,11 @@ char *generate_name(char *buf, const char *radix,
buf[len] = '\0';
} else {
tag = atomic_add_fetch(>serial, 1);
+#ifdef CONFIG_XENO_PSHARED
+   snprintf(buf, len, "%s@%d[%d]", ngen->radix, tag, __node_id);
+#else
snprintf(buf, len, "%s@%d", ngen->radix, tag);
+#endif
}
 
return buf;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/rtdm: device: allow switching device class back to default

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 118db7bca9151b12fd737ee40ff3485109336eaf
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=118db7bca9151b12fd737ee40ff3485109336eaf

Author: Philippe Gerum 
Date:   Wed Nov  9 12:48:27 2016 +0100

cobalt/rtdm: device: allow switching device class back to default

Passing NULL to rtdm_drv_set_sysclass() is now allowed, to switch a
driver back to creating devices into the default "rtdm" class.

---

 kernel/cobalt/rtdm/device.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c
index d0df7fa..b174c1b 100644
--- a/kernel/cobalt/rtdm/device.c
+++ b/kernel/cobalt/rtdm/device.c
@@ -575,7 +575,9 @@ EXPORT_SYMBOL_GPL(rtdm_dev_unregister);
  *
  * @param[in] drv Address of the RTDM driver descriptor.
  *
- * @param[in] cls Pointer to the kernel device class.
+ * @param[in] cls Pointer to the kernel device class. NULL is allowed
+ * to clear a previous setting, switching back to the default "rtdm"
+ * device class.
  *
  * @return 0 on success, otherwise:
  *
@@ -592,7 +594,8 @@ EXPORT_SYMBOL_GPL(rtdm_dev_unregister);
  */
 int rtdm_drv_set_sysclass(struct rtdm_driver *drv, struct class *cls)
 {
-   if (drv->profile_info.kdev_class || atomic_read(>refcount))
+   if ((cls && drv->profile_info.kdev_class) ||
+   atomic_read(>refcount))
return -EBUSY;
 
drv->profile_info.kdev_class = cls;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/timer: consider clock event affinity when pinning timers

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: b9642fc43473d91d11a16baee1ce0b1aaa1ec1f1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=b9642fc43473d91d11a16baee1ce0b1aaa1ec1f1

Author: Philippe Gerum 
Date:   Mon Nov 14 11:49:09 2016 +0100

cobalt/timer: consider clock event affinity when pinning timers

Pinning a timer to the same CPU than the caller is affine to must take
into account the affinity of the clock device backing the timer.

When an affinity mismatch is detected by xntimer_set_sched(), the
timer affinity is left unchanged, which will certainly cause
additional overhead due to the requirement of waking up a thread on a
remote CPU from the timer's handler, but will also keep the situation
sane.

---

 include/cobalt/kernel/timer.h |7 ++-
 kernel/cobalt/timer.c |   17 +
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h
index 6cb2bb3..700392e 100644
--- a/include/cobalt/kernel/timer.h
+++ b/include/cobalt/kernel/timer.h
@@ -546,11 +546,8 @@ static inline void xntimer_release_ipi(void) { }
 
 #endif /* CONFIG_SMP */
 
-static inline void xntimer_set_sched(struct xntimer *timer,
-struct xnsched *sched)
-{
-   xntimer_migrate(timer, sched);
-}
+bool xntimer_set_sched(struct xntimer *timer,
+  struct xnsched *sched);
 
 char *xntimer_format_time(xnticks_t ns,
  char *buf, size_t bufsz);
diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index dd78c38..6263f5b 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -541,6 +541,23 @@ void __xntimer_migrate(struct xntimer *timer, struct 
xnsched *sched)
 }
 EXPORT_SYMBOL_GPL(__xntimer_migrate);
 
+bool xntimer_set_sched(struct xntimer *timer,
+  struct xnsched *sched)
+{
+   /*
+* We may deny the request if the target CPU does not receive
+* any event from the clock device backing the timer.
+*/
+   if (cpumask_test_cpu(xnsched_cpu(sched),
+_clock(timer)->affinity)) {
+   xntimer_migrate(timer, sched);
+   return true;
+   }
+
+   return false;
+}
+EXPORT_SYMBOL_GPL(xntimer_set_sched);
+
 int xntimer_setup_ipi(void)
 {
return ipipe_request_irq(_realtime_domain,


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/clock: procfs: output tick count as hex value too

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 644821af26d46ecf9bbab662d8daa735802d6428
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=644821af26d46ecf9bbab662d8daa735802d6428

Author: Philippe Gerum 
Date:   Tue Nov 15 13:15:39 2016 +0100

cobalt/clock: procfs: output tick count as hex value too

---

 kernel/cobalt/clock.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index 647eca3..a4d0df8 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -508,6 +508,7 @@ void print_core_clock_status(struct xnclock *clock,
 static int clock_show(struct xnvfile_regular_iterator *it, void *data)
 {
struct xnclock *clock = xnvfile_priv(it->vfile);
+   xnticks_t now = xnclock_read_raw(clock);
 
if (clock->id >= 0) /* External clock, print id. */
xnvfile_printf(it, "%7s: %d\n", "id", 
__COBALT_CLOCK_EXT(clock->id));
@@ -519,7 +520,8 @@ static int clock_show(struct xnvfile_regular_iterator *it, 
void *data)
 
xnclock_print_status(clock, it);
 
-   xnvfile_printf(it, "%7s: %Lu\n", "ticks", xnclock_read_raw(clock));
+   xnvfile_printf(it, "%7s: %Lu (%.4Lx %.4x)\n", "ticks",
+  now, now >> 32, (u32)(now & -1U));
 
return 0;
 }


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/timer: rbtree: fix inverted logic in helper testing emptiness

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: ff70dfdea9e2ffcb1ad7db10c695fe5dc4aff8a0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ff70dfdea9e2ffcb1ad7db10c695fe5dc4aff8a0

Author: Philippe Gerum 
Date:   Tue Nov  8 16:11:03 2016 +0100

cobalt/timer: rbtree: fix inverted logic in helper testing emptiness

xntimerq_empty() was wrong in the rbtree-based implementation of the
timer management code, not detecting emptiness of timer queues.

This issue caused the debug assertion in xnclock_deregister() to
trigger when XENO_OPT_DEBUG_COBALT is enabled.

---

 include/cobalt/kernel/timer.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h
index f45a753..d92c8c8 100644
--- a/include/cobalt/kernel/timer.h
+++ b/include/cobalt/kernel/timer.h
@@ -163,7 +163,7 @@ typedef struct {
})
 
 #define xntimerq_destroy(q) do { } while (0)
-#define xntimerq_empty(q) ((q)->head != NULL)
+#define xntimerq_empty(q) ((q)->head == NULL)
 
 #define xntimerq_head(q) ((q)->head)
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : scripts/xeno-config: fix include directory chain in compat mode

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: a3fb5d8e7ad19b13cc04ccaa9a031491d881f15c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a3fb5d8e7ad19b13cc04ccaa9a031491d881f15c

Author: Philippe Gerum 
Date:   Fri Sep 30 15:38:21 2016 +0200

scripts/xeno-config: fix include directory chain in compat mode

== Wrong include chain:
. /install/xenomai/cobalt/pthread.h
.. /install/xenomai/trank/posix/pthread.h
... /usr/include/pthread.h

== Right include chain:
. /install/xenomai/trank/posix/pthread.h
.. /install/xenomai/cobalt/pthread.h
... /usr/include/pthread.h

Fix the order the -I directives are emitted by --cflags --compat
accordingly.

---

 scripts/xeno-config-cobalt.in |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index 802b778..62c1f33 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -213,7 +213,7 @@ if test x$do_cflags = xy; then
 for skin in $skin_list; do
case "$skin" in
posix|rtdm)
-   test x$compat = xy && cflags="$cflags 
-I$XENO_INCLUDE_DIR/trank/posix"
+   test x$compat = xy && cflags="-I$XENO_INCLUDE_DIR/trank/posix 
$cflags"
cflags="$cflags -D__COBALT_WRAP__"
;;
cobalt)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Wolfgang Grandegger : rtcan: ems_pci driver update to support more devices

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 6c03c92c496e3f719e8322c4180f865e29daa452
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6c03c92c496e3f719e8322c4180f865e29daa452

Author: Wolfgang Grandegger 
Date:   Fri Oct 28 09:25:00 2016 +0200

rtcan: ems_pci driver update to support more devices

Hi Philippe

Am 06.10.2016 um 21:40 schrieb Philippe Gerum:
> >
> > Hi Wolfgang,
> >
> > On 10/04/2016 08:25 AM, Wolfgang Grandegger wrote:
>> >> The driver follows now more closely the corresponding Linux driver
>> >> to simplify updates in the future.
>> >>
> >
> > Any chance to have this forward ported to 3.x? Xenomai 2.6 has reached EOL.

Below is the patch for Xenomai-3. It's untested for the moment but the
changes compared with 2.6 seem not the be critical.

Wolfgang

>From 0fc42b023eb9f6f58ce3b2381a55cab74757c2a1 Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger 
Date: Fri, 28 Oct 2016 09:21:24 +0200
Subject: [PATCH] [PATCH] rtcan: ems_pci driver update to support more devices

The driver now also follows more closely the corresponding Linux
driver to simplify updates in the future.

Signed-off-by: Wolfgang Grandegger 

---

 kernel/drivers/can/sja1000/rtcan_ems_pci.c  |  487 +--
 kernel/drivers/can/sja1000/rtcan_sja1000_regs.h |1 +
 2 files changed, 281 insertions(+), 207 deletions(-)

diff --git a/kernel/drivers/can/sja1000/rtcan_ems_pci.c 
b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
index be4b704..e3c178f 100644
--- a/kernel/drivers/can/sja1000/rtcan_ems_pci.c
+++ b/kernel/drivers/can/sja1000/rtcan_ems_pci.c
@@ -1,28 +1,28 @@
 /*
- * Copyright (C) 2007 Wolfgang Grandegger 
+ * Copyright (C) 2007, 2016 Wolfgang Grandegger 
+ * Copyright (C) 2008 Markus Plessing 
+ * Copyright (C) 2008 Sebastian Haas 
  *
- * Register definitions and descriptions are taken from LinCAN 0.3.3.
+ * Derived from Linux CAN SJA1000 PCI driver "ems_pci".
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
  *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with this program; if not, see .
  */
 
+#include 
 #include 
-#include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 
@@ -40,23 +40,30 @@
 static char *ems_pci_board_name = "EMS-CPC-PCI";
 
 MODULE_AUTHOR("Wolfgang Grandegger ");
-MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI cards");
-MODULE_SUPPORTED_DEVICE("EMS CPC-PCI card CAN controller");
-MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("RTCAN board driver for EMS CPC-PCI/PCIe/104P CAN cards");
+MODULE_SUPPORTED_DEVICE("EMS CPC-PCI/PCIe/104P CAN card");
+MODULE_LICENSE("GPL v2");
+
+#define EMS_PCI_V1_MAX_CHAN 2
+#define EMS_PCI_V2_MAX_CHAN 4
+#define EMS_PCI_MAX_CHANEMS_PCI_V2_MAX_CHAN
+
+struct ems_pci_card {
+   int version;
+   int channels;
 
-struct rtcan_ems_pci
-{
struct pci_dev *pci_dev;
-   struct rtcan_device *slave_dev;
-   int channel;
-   volatile void __iomem *base_addr;
-   volatile void __iomem *conf_addr;
+   struct rtcan_device *rtcan_dev[EMS_PCI_MAX_CHAN];
+
+   void __iomem *conf_addr;
+   void __iomem *base_addr;
 };
 
-#define EMS_PCI_MASTER 1 /* multi channel device, this device is master */
-#define EMS_PCI_SLAVE  2 /* multi channel device, this is slave */
+#define EMS_PCI_CAN_CLOCK (1600 / 2)
 
 /*
+ * Register definitions and descriptions are from LinCAN 0.3.3.
+ *
  * PSB4610 PITA-2 bridge control registers
  */
 #define PITA2_ICR   0x00   /* Interrupt Control Register */
@@ -64,7 +71,17 @@ struct rtcan_ems_pci
 #define PITA2_ICR_INT0_EN   0x0002 /* [RW] Enable INT0 */
 
 #define PITA2_MISC  0x1c   /* Miscellaneous Register */
-#define PITA2_MISC_CONFIG   0x0400 /* Multiplexed Parallel_interface_model 
*/

[Xenomai-git] Jan Kiszka : cobalt/rtdm: Restore return code tracing

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 639ed39611a63a0c4f8a787ade150b8dbb5e4fab
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=639ed39611a63a0c4f8a787ade150b8dbb5e4fab

Author: Jan Kiszka 
Date:   Thu Sep 15 19:44:33 2016 +0200

cobalt/rtdm: Restore return code tracing

Got broken by a96a6d8e2816.

Signed-off-by: Jan Kiszka 

---

 kernel/cobalt/rtdm/fd.c |   40 ++--
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
index 3381dea..4169e85 100644
--- a/kernel/cobalt/rtdm/fd.c
+++ b/kernel/cobalt/rtdm/fd.c
@@ -438,8 +438,10 @@ int rtdm_fd_ioctl(int ufd, unsigned int request, ...)
int err, ret;
 
fd = get_fd_fixup_mode(ufd);
-   if (IS_ERR(fd))
-   return PTR_ERR(fd);
+   if (IS_ERR(fd)) {
+   err = PTR_ERR(fd);
+   goto out;
+   }
 
va_start(args, request);
arg = va_arg(args, void __user *);
@@ -464,7 +466,7 @@ int rtdm_fd_ioctl(int ufd, unsigned int request, ...)
}
 
rtdm_fd_put(fd);
-
+  out:
if (err < 0)
trace_cobalt_fd_ioctl_status(current, fd, ufd, err);
 
@@ -479,8 +481,10 @@ rtdm_fd_read(int ufd, void __user *buf, size_t size)
ssize_t ret;
 
fd = get_fd_fixup_mode(ufd);
-   if (IS_ERR(fd))
-   return PTR_ERR(fd);
+   if (IS_ERR(fd)) {
+   ret = PTR_ERR(fd);
+   goto out;
+   }
 
set_compat_bit(fd);
 
@@ -492,10 +496,11 @@ rtdm_fd_read(int ufd, void __user *buf, size_t size)
ret = fd->ops->read_rt(fd, buf, size);
 
if (!XENO_ASSERT(COBALT, !spltest()))
-   splnone();
+   splnone();
 
rtdm_fd_put(fd);
 
+  out:
if (ret < 0)
trace_cobalt_fd_read_status(current, fd, ufd, ret);
 
@@ -509,8 +514,10 @@ ssize_t rtdm_fd_write(int ufd, const void __user *buf, 
size_t size)
ssize_t ret;
 
fd = get_fd_fixup_mode(ufd);
-   if (IS_ERR(fd))
-   return PTR_ERR(fd);
+   if (IS_ERR(fd)) {
+   ret = PTR_ERR(fd);
+   goto out;
+   }
 
set_compat_bit(fd);
 
@@ -526,6 +533,7 @@ ssize_t rtdm_fd_write(int ufd, const void __user *buf, 
size_t size)
 
rtdm_fd_put(fd);
 
+  out:
if (ret < 0)
trace_cobalt_fd_write_status(current, fd, ufd, ret);
 
@@ -539,8 +547,10 @@ ssize_t rtdm_fd_recvmsg(int ufd, struct user_msghdr *msg, 
int flags)
ssize_t ret;
 
fd = get_fd_fixup_mode(ufd);
-   if (IS_ERR(fd))
-   return PTR_ERR(fd);
+   if (IS_ERR(fd)) {
+   ret = PTR_ERR(fd);
+   goto out;
+   }
 
set_compat_bit(fd);
 
@@ -555,7 +565,7 @@ ssize_t rtdm_fd_recvmsg(int ufd, struct user_msghdr *msg, 
int flags)
splnone();
 
rtdm_fd_put(fd);
-
+out:
if (ret < 0)
trace_cobalt_fd_recvmsg_status(current, fd, ufd, ret);
 
@@ -569,8 +579,10 @@ ssize_t rtdm_fd_sendmsg(int ufd, const struct user_msghdr 
*msg, int flags)
ssize_t ret;
 
fd = get_fd_fixup_mode(ufd);
-   if (IS_ERR(fd))
-   return PTR_ERR(fd);
+   if (IS_ERR(fd)) {
+   ret = PTR_ERR(fd);
+   goto out;
+   }
 
set_compat_bit(fd);
 
@@ -585,7 +597,7 @@ ssize_t rtdm_fd_sendmsg(int ufd, const struct user_msghdr 
*msg, int flags)
splnone();
 
rtdm_fd_put(fd);
-
+out:
if (ret < 0)
trace_cobalt_fd_sendmsg_status(current, fd, ufd, ret);
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : scripts/xeno-config: do not wrap main() with --auto-init-solib

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 91f7a0c72e20e0eb5df56dfc44d410b4cff0c99c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=91f7a0c72e20e0eb5df56dfc44d410b4cff0c99c

Author: Philippe Gerum 
Date:   Thu Sep 22 10:13:52 2016 +0200

scripts/xeno-config: do not wrap main() with --auto-init-solib

For the auto-init feature to make sense, the main() symbol has to be
defined in the main executable, so there is no need to wrap it when
emitting linker flags for an auto-boostrapped shared library.

---

 scripts/xeno-config-cobalt.in  |   10 +++---
 scripts/xeno-config-mercury.in |   10 +++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index 38f8208..802b778 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -262,10 +262,14 @@ if test x$do_ldflags = xy; then
 done
 wrap_main=
 if test x$do_autoinit = xy; then
-   test x$do_autoinit_solib = xy && codegen=-pic
-   wrap_main="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o 
-Wl,--wrap=main -Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
+   if test x$do_autoinit_solib = xy; then
+   codegen=-pic
+   else
+   wrap_main="-Wl,--wrap=main 
-Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
+   fi
+   bootstrap="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o"
 fi
-echo "$ldflags $copperplate $wrap_main $XENO_POSIX_LDFLAGS"
+echo "$ldflags $copperplate $bootstrap $wrap_main $XENO_POSIX_LDFLAGS"
 fi
 
 exit 0
diff --git a/scripts/xeno-config-mercury.in b/scripts/xeno-config-mercury.in
index 5dab4ba..a0aa75b 100644
--- a/scripts/xeno-config-mercury.in
+++ b/scripts/xeno-config-mercury.in
@@ -206,10 +206,14 @@ if test x$do_ldflags = xy; then
 done
 wrap_main=
 if test x$do_autoinit = xy; then
-   test x$do_autoinit_solib = xy && codegen=-pic
-   wrap_main="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o 
-Wl,--wrap=main -Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
+   if test x$do_autoinit_solib = xy; then
+   codegen=-pic
+   else
+   wrap_main="-Wl,--wrap=main 
-Wl,--dynamic-list=${XENO_LIBRARY_DIR}/dynlist.ld"
+   fi
+   bootstrap="${XENO_LIBRARY_DIR}/xenomai/bootstrap${codegen}.o"
 fi
-echo "$ldflags $copperplate $wrap_main $XENO_BASE_LDFLAGS"
+echo "$ldflags $copperplate $bootstrap $wrap_main $XENO_BASE_LDFLAGS"
 fi
 
 exit 0


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/posix/clock: uapi: strengthen test for external clock ids

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 3e8a9fd398b98482e989b97d4fd721fbff868ecd
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3e8a9fd398b98482e989b97d4fd721fbff868ecd

Author: Philippe Gerum 
Date:   Fri Nov 11 10:52:40 2016 +0100

cobalt/posix/clock: uapi: strengthen test for external clock ids

__COBALT_CLOCK_EXT_P() was way too weak in filtering out invalid clock
ids, also returning a true value for identifiers being obviously out
of range although bit #6 is raised.

This would cause all clock* services depending on such detection to
crash badly due to using bad index values determined from invalid
clock ids they should never have considered in the first place.

The test is strengthened by comparing the clock identifier to the
valid range explicitly, i.e. [ 64...127 ] inclusive.

---

 include/cobalt/uapi/time.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/cobalt/uapi/time.h b/include/cobalt/uapi/time.h
index 4a3679b..411baf5 100644
--- a/include/cobalt/uapi/time.h
+++ b/include/cobalt/uapi/time.h
@@ -41,7 +41,7 @@
 #define COBALT_MAX_EXTCLOCKS  64
 
 #define __COBALT_CLOCK_EXT(nr) ((clockid_t)(nr) | (1 << 6))
-#define __COBALT_CLOCK_EXT_P(id)   ((int)(id) & (1 << 6))
+#define __COBALT_CLOCK_EXT_P(id)   ((int)(id) >= 64 && (int)(id) < 128)
 #define __COBALT_CLOCK_EXT_INDEX(id)   ((int)(id) & ~(1 << 6))
 
 /*


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : boilerplate: drop __real_main() wrapper

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: bc8afd4291cbf1ececf868f4e57feb5cf3f73a0b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bc8afd4291cbf1ececf868f4e57feb5cf3f73a0b

Author: Philippe Gerum 
Date:   Wed Nov  9 11:25:30 2016 +0100

boilerplate: drop __real_main() wrapper

Such kind of wrappers is supposed to help when --wrap is not given at
link time, in resolving direct references to the real symbols such as
those which may be done from the __wrap routines.

This said, __real_main() is special, in that there is no reason to
call such routine explicitly if --wrap is not given, by
definition. Only the bootstrap module (init/bootstrap.c) may call the
real main() entry point this way, and such module is glued to the
executable only if --wrap is passed to the linker.

Therefore we may drop this particular wrapper and the file which only
contains it altogether.

---

 lib/boilerplate/Makefile.am |3 +--
 lib/boilerplate/wrappers.c  |   27 ---
 2 files changed, 1 insertion(+), 29 deletions(-)

diff --git a/lib/boilerplate/Makefile.am b/lib/boilerplate/Makefile.am
index 4176c6d..9b8612d 100644
--- a/lib/boilerplate/Makefile.am
+++ b/lib/boilerplate/Makefile.am
@@ -8,8 +8,7 @@ libboilerplate_la_SOURCES = \
hash.c  \
obstack.c   \
setup.c \
-   time.c  \
-   wrappers.c
+   time.c
 
 if XENO_DEBUG
 libboilerplate_la_SOURCES += debug.c
diff --git a/lib/boilerplate/wrappers.c b/lib/boilerplate/wrappers.c
deleted file mode 100644
index 9d2490c..000
--- a/lib/boilerplate/wrappers.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2013 Philippe Gerum .
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
- */
-#include 
-
-int main(int argc, char *const argv[]);
-
-int __real_main(int argc, char *const argv[]);
-
-__weak int __real_main(int argc, char *const argv[])
-{
-   return main(argc, argv);
-}


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : cobalt/posix/timerfd: allow usage with external clocks

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: dac2df243bcd146a040329df3885131ae77bd5b9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=dac2df243bcd146a040329df3885131ae77bd5b9

Author: Philippe Gerum 
Date:   Fri Nov  4 16:25:21 2016 +0100

cobalt/posix/timerfd: allow usage with external clocks

Same as e6cd961.

---

 kernel/cobalt/posix/timerfd.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/posix/timerfd.c b/kernel/cobalt/posix/timerfd.c
index 90c4b3f..132aba8 100644
--- a/kernel/cobalt/posix/timerfd.c
+++ b/kernel/cobalt/posix/timerfd.c
@@ -166,12 +166,14 @@ COBALT_SYSCALL(timerfd_create, lostage, (int clockid, int 
flags))
 {
struct cobalt_tfd *tfd;
struct xnthread *curr;
+   struct xnclock *clock;
int ret, ufd;
 
-   if (clockid != CLOCK_REALTIME && clockid != CLOCK_MONOTONIC)
+   if (flags & ~TFD_CREATE_FLAGS)
return -EINVAL;
 
-   if (flags & ~TFD_CREATE_FLAGS)
+   clock = cobalt_clock_find(clockid);
+   if (clock == NULL)
return -EINVAL;
 
tfd = xnmalloc(sizeof(*tfd));
@@ -189,7 +191,7 @@ COBALT_SYSCALL(timerfd_create, lostage, (int clockid, int 
flags))
tfd->fd.oflags = (flags & TFD_NONBLOCK) ? O_NONBLOCK : 0;
tfd->clockid = clockid;
curr = xnthread_current();
-   xntimer_init(>timer, , timerfd_handler,
+   xntimer_init(>timer, clock, timerfd_handler,
 curr ? curr->sched : NULL, XNTIMER_UGRAVITY);
xnsynch_init(>readers, XNSYNCH_PRIO | XNSYNCH_NOPIP, NULL);
xnselect_init(>read_select);


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/heapobj: pshared: fix corruption of sub-page block list

2017-02-08 Thread git repository hosting
Module: xenomai-3
Branch: master
Commit: 3746052918643aad50cedbec47df54f03a1f0b92
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3746052918643aad50cedbec47df54f03a1f0b92

Author: Philippe Gerum 
Date:   Thu Sep 22 11:27:58 2016 +0200

copperplate/heapobj: pshared: fix corruption of sub-page block list

Block allocation requests between HOBJ_PAGE_SIZE and HOBJ_PAGE_SIZE *
2 are satisfied by returning free raw pages directly, in which case
there is no free sub-page block list attached to the corresponding
log2 slot. Make sure we don't create a spurious one inadvertently.

This fixes a crash on such an allocation/release pattern:

int *p = xnmalloc(1400);
p[0] = -1;
xnfree(p);
xnmalloc(512);
xnmalloc(512);

Reported-by: Jan Kiszka 

---

 lib/copperplate/heapobj-pshared.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/copperplate/heapobj-pshared.c 
b/lib/copperplate/heapobj-pshared.c
index f4c6f37..e02cfd3 100644
--- a/lib/copperplate/heapobj-pshared.c
+++ b/lib/copperplate/heapobj-pshared.c
@@ -437,10 +437,12 @@ static void *alloc_block(struct shared_heap *heap, size_t 
size)
block = get_free_range(heap, bsize, log2size);
if (block == NULL)
goto done;
-   if (bsize <= HOBJ_PAGE_SIZE)
+   if (bsize < HOBJ_PAGE_SIZE) {
heap->buckets[ilog].fcount += (HOBJ_PAGE_SIZE 
>> log2size) - 1;
+   heap->buckets[ilog].freelist = *((memoff_t 
*)block);
+   }
} else {
-   if (bsize <= HOBJ_PAGE_SIZE)
+   if (bsize < HOBJ_PAGE_SIZE)
--heap->buckets[ilog].fcount;
 
/* Search for the source extent of block. */
@@ -453,9 +455,9 @@ static void *alloc_block(struct shared_heap *heap, size_t 
size)
found:
pgnum = (__shoff(base, block) - extent->membase) >> 
HOBJ_PAGE_SHIFT;
++extent->pagemap[pgnum].bcount;
+   heap->buckets[ilog].freelist = *((memoff_t *)block);
}
 
-   heap->buckets[ilog].freelist = *((memoff_t *)block);
heap->ubytes += bsize;
} else {
if (size > heap->maxcont)


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git