[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: prepare-kernel: add arm64 arch

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 105a370bb0a50c45f3db72bc0f110675fe270b29
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=105a370bb0a50c45f3db72bc0f110675fe270b29

Author: Dmitriy Cherkasov 
Date:   Wed May  6 15:27:10 2015 -0700

cobalt/arm64: prepare-kernel: add arm64 arch

---

 scripts/prepare-kernel.sh |3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 398ebcb..d4aa2ef 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -284,6 +284,9 @@ while : ; do
arm)
   linux_arch=arm
   ;;
+   arm64)
+  linux_arch=arm64
+  ;;
sh|sh4)
   linux_arch=sh
   ;;


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


[Xenomai-git] Philippe Gerum : cobalt/synch: add __must_check annotation to lock acquisition routines

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 9000dc953d740fa4bf48db88d9c7c0b4de69407b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9000dc953d740fa4bf48db88d9c7c0b4de69407b

Author: Philippe Gerum 
Date:   Sun Mar 12 10:23:47 2017 +0100

cobalt/synch: add __must_check annotation to lock acquisition routines

---

 include/cobalt/kernel/synch.h |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h
index ffb884a..f419698 100644
--- a/include/cobalt/kernel/synch.h
+++ b/include/cobalt/kernel/synch.h
@@ -149,11 +149,11 @@ int xnsynch_wakeup_many_sleepers(struct xnsynch *synch, 
int nr);
 void xnsynch_wakeup_this_sleeper(struct xnsynch *synch,
 struct xnthread *sleeper);
 
-int xnsynch_acquire(struct xnsynch *synch,
-   xnticks_t timeout,
-   xntmode_t timeout_mode);
+int __must_check xnsynch_acquire(struct xnsynch *synch,
+xnticks_t timeout,
+xntmode_t timeout_mode);
 
-int xnsynch_try_acquire(struct xnsynch *synch);
+int __must_check xnsynch_try_acquire(struct xnsynch *synch);
 
 struct xnthread *xnsynch_release(struct xnsynch *synch,
 struct xnthread *thread);


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: Makefile: fix arch path

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 24c8881e96db2f52de2d38991bbbdaec7c31a5fe
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=24c8881e96db2f52de2d38991bbbdaec7c31a5fe

Author: Dmitriy Cherkasov 
Date:   Thu May  7 13:54:32 2015 -0700

cobalt/arm64: Makefile: fix arch path

---

 kernel/cobalt/arch/arm64/Makefile |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/arch/arm64/Makefile 
b/kernel/cobalt/arch/arm64/Makefile
index f2e4e20..a135f99 100644
--- a/kernel/cobalt/arch/arm64/Makefile
+++ b/kernel/cobalt/arch/arm64/Makefile
@@ -2,4 +2,4 @@ obj-$(CONFIG_XENOMAI) += xenomai.o
 
 xenomai-y := machine.o mayday.o thread.o switch.o syscall.o
 
-ccflags-y := -Iarch/arm/xenomai/include -Iinclude/xenomai
+ccflags-y := -Iarch/arm64/xenomai/include -Iinclude/xenomai


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: restrict unlocked switch to SMP

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7b4f8e2b81d8c5b27cf061ee7df2e509c32e03b2
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7b4f8e2b81d8c5b27cf061ee7df2e509c32e03b2

Author: Philippe Gerum 
Date:   Thu Sep 17 11:43:50 2015 +0200

cobalt/arm64: restrict unlocked switch to SMP

Unlocked switching for Xenomai/ARM was specifically introduced for
improving the interrupt latency on low-end armv4/armv5 platforms with
VIVT caches.

The once massive overhead imposed on the MMU context switching code
for invalidating the cache is long gone with VIPT indexing, and
keeping IRQs off while switching the memory context on armv8 these
days is not an issue. Actually, the complexity of the code involved in
dealing with unlocked switching may overbalance the expected gain.

However, the mainline kernel implementation for ASID management in the
SMP case currently requires us to keep IRQs enabled when allocating a
new MM context over the Xenomai domain, just like it did for aarch32
during the 2.6.3x time frame until the IPI-based approach was
eventually dropped.

So, let's restrict unlocked switching to the SMP case, forcing it off
otherwise, in the hope we can drop it entirely in the future.

At this chance, CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH moves to the
kernel area, where it actually belongs.

---

 kernel/cobalt/arch/arm64/Kconfig |   21 +
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/Kconfig b/kernel/cobalt/arch/arm64/Kconfig
index dc6485d..927c647 100644
--- a/kernel/cobalt/arch/arm64/Kconfig
+++ b/kernel/cobalt/arch/arm64/Kconfig
@@ -1,27 +1,8 @@
 source "kernel/xenomai/Kconfig"
 source "drivers/xenomai/Kconfig"
 
-menu "Machine/platform-specific options"
-
 config XENO_ARCH_UNLOCKED_SWITCH
-   bool "Unlocked context switch"
-   default y
-   help
-   The Cobalt core may allow non-atomic execution of the
-   machine-dependent context switching code, so that other CPUs
-   and/or local interrupts may execute concurrently.
-
-   This option reduces interrupt latency when costly cache and
-   TLB flushes are required to switch context.
-
-   You definitely want to enable that option on low-end ARM
-   platforms.
-endmenu
-
-config IPIPE_WANT_PREEMPTIBLE_SWITCH
-   bool
-   default y if XENO_ARCH_UNLOCKED_SWITCH
-   default n if !XENO_ARCH_UNLOCKED_SWITCH
+   def_bool IPIPE_WANT_PREEMPTIBLE_SWITCH
 
 config IPIPE_WANT_ACTIVE_MM
def_bool y


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


[Xenomai-git] Philippe Gerum : config: bump UAPI level

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 2bb2a2ba8f307b58a61b0ee64f44c875d6c409ad
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2bb2a2ba8f307b58a61b0ee64f44c875d6c409ad

Author: Philippe Gerum 
Date:   Sat Feb 15 16:42:09 2014 +0100

config: bump UAPI level

---

 config/apirev   |2 +-
 include/cobalt/sys/cobalt.h |4 
 lib/cobalt/internal.c   |9 -
 3 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/config/apirev b/config/apirev
index 8351c19..60d3b2f 100644
--- a/config/apirev
+++ b/config/apirev
@@ -1 +1 @@
-14
+15
diff --git a/include/cobalt/sys/cobalt.h b/include/cobalt/sys/cobalt.h
index 1da8a46..1687e2b 100644
--- a/include/cobalt/sys/cobalt.h
+++ b/include/cobalt/sys/cobalt.h
@@ -134,10 +134,6 @@ void cobalt_register_tsd_hook(struct cobalt_tsd_hook *th);
 
 void cobalt_assert_nrt(void);
 
-/* Use cobalt_assert_nrt() instead of: */
-__deprecated void assert_nrt(void);
-__deprecated void assert_nrt_fast(void);
-
 extern int __cobalt_control_bind;
 
 #ifdef __cplusplus
diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c
index ebc3624..4333006 100644
--- a/lib/cobalt/internal.c
+++ b/lib/cobalt/internal.c
@@ -560,15 +560,6 @@ int cobalt_xlate_schedparam(int policy,
return std_policy;
 }
 
-/*
- * Temporary compatibility aliases which should be phased out at next
- * API revision.
- */
-void assert_nrt(void)
-__attribute__((alias("cobalt_assert_nrt")));
-void assert_nrt_fast(void)
-__attribute__((alias("cobalt_assert_nrt")));
-
 void cobalt_assert_nrt(void)
 {
if (cobalt_should_warn())


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


[Xenomai-git] Philippe Gerum : cobalt/kernel: fixup for v3.19+ (trace_seq)

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 6bcd4b8364f39a3d0c6105f73f7a3d74a62739c5
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6bcd4b8364f39a3d0c6105f73f7a3d74a62739c5

Author: Philippe Gerum 
Date:   Tue Nov  3 13:11:25 2015 +0100

cobalt/kernel: fixup for v3.19+ (trace_seq)

---

 kernel/cobalt/include/asm-generic/xenomai/wrappers.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index 8ad4108..a9424b9 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -50,6 +50,7 @@
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
 #include 
+#include 
 
 #undef alloc_netdev
 #define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
@@ -62,7 +63,6 @@ trace_seq_buffer_ptr(struct trace_seq *s)
 {
return s->buffer + s->len;
 }
-
 #endif /* < 3.17 */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)


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


[Xenomai-git] Jorge Ramirez-Ortiz : gpiopwm: display udp server information

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7e1444a56c01467d1d21552529457b2f3b36984e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7e1444a56c01467d1d21552529457b2f3b36984e

Author: Jorge Ramirez-Ortiz 
Date:   Wed Mar 30 13:30:11 2016 -0400

gpiopwm: display udp server information

---

 demo/posix/cobalt/gpiopwm.c |   62 ---
 1 file changed, 59 insertions(+), 3 deletions(-)

diff --git a/demo/posix/cobalt/gpiopwm.c b/demo/posix/cobalt/gpiopwm.c
index e093fbe..71a87d4 100644
--- a/demo/posix/cobalt/gpiopwm.c
+++ b/demo/posix/cobalt/gpiopwm.c
@@ -18,9 +18,10 @@
 #include 
 #include 
 #include 
+#include 
 
-#define MIN_DUTY_CYCLE 0
-#define MAX_DUTY_CYCLE 100
+#define MIN_DUTY_CYCLE (0)
+#define MAX_DUTY_CYCLE (100)
 
 typedef void *(*gpiopwm_control_thread)(void *cookie);
 #define DEVICE_NAME "/dev/rtdm/gpiopwm"
@@ -33,6 +34,11 @@ static int stop;
 static int step = 1;
 static int port = 6;
 
+#define MAX_IP_INTERFACES  (9)
+static char *ip_str[MAX_IP_INTERFACES + 1];
+static int last_ip;
+
+
 #define GPIO_PWM_SERVO_CONFIG  \
 {  \
.duty_cycle =   50, \
@@ -75,7 +81,11 @@ static inline void clear_screen(void)
 
 static inline void print_config(char *str)
 {
+   int i;
+
printf("Config: %s\n", str);
+   for (i = 0; i < last_ip ; i++)
+   printf("%s", ip_str[i]);
printf(" device : %s\n", device_name);
printf(" range  : [%d, %d]\n", config.range_min, config.range_max);
printf(" period : %d nsec\n", config.period);
@@ -90,6 +100,51 @@ static inline void input_message(void)
printf( "  Enter duty_cycle [0-100] : ");
 }
 
+static void get_ip_addresses(void)
+{
+   char ip[INET_ADDRSTRLEN];
+   struct sockaddr_in *s_in;
+   struct ifconf ifconf;
+   struct ifreq ifr[10];
+   int ret;
+   int ifs;
+   int i;
+   int s;
+
+   s = socket(AF_INET, SOCK_STREAM, 0);
+   if (s < 0)
+   return;
+
+   ifconf.ifc_buf = (char *) ifr;
+   ifconf.ifc_len = sizeof(ifr);
+
+   if (ioctl(s, SIOCGIFCONF, ) == -1)
+   return;
+
+   ifs = ifconf.ifc_len / sizeof(ifr[0]);
+
+   /* we wont _display_ more than MAX_IP_INTERFACES */
+   if (ifs > MAX_IP_INTERFACES)
+   ifs = MAX_IP_INTERFACES;
+
+   last_ip = ifs + 1;
+
+   for (i = 0; i < ifs; i++) {
+   s_in = (struct sockaddr_in *) [i].ifr_addr;
+   if (!inet_ntop(AF_INET, _in->sin_addr, ip, sizeof(ip)))
+   return;
+   ret = asprintf(_str[i]," ip  : %s\n", ip);
+   if (ret)
+   perror("asprintf");
+   }
+
+   ret = asprintf(_str[i]," port: %d\n\n", port);
+   if (ret)
+   perror("asprintf");
+
+   close(s);
+}
+
 static void setup_sched_parameters(pthread_attr_t *attr, int prio)
 {
struct sched_param p;
@@ -171,7 +226,7 @@ static void *gpiopwm_udp_ctrl_thread(void *cookie)
for (;;) {
 
clear_screen();
-   print_config("UDP server");
+   print_config("UDP Server\n");
 
memset(buf,'\0', blen);
ret = recvfrom(sockfd, buf, blen - 1, 0, , );
@@ -382,6 +437,7 @@ int main(int argc, char *argv[])
case udp_opt:
handler = gpiopwm_udp_ctrl_thread;
port = atoi(optarg);
+   get_ip_addresses();
break;
case config_opt:
p = strtok(optarg,":");


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


[Xenomai-git] Jorge Ramirez-Ortiz : gpiopwm: pwm signal generator and servo motor control demo code

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 477006f93072807a16272c60c3dcdecb6d17a7bb
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=477006f93072807a16272c60c3dcdecb6d17a7bb

Author: Jorge Ramirez-Ortiz 
Date:   Tue Mar 15 19:18:15 2016 -0400

gpiopwm: pwm signal generator and servo motor control demo code

---

 demo/posix/cobalt/Makefile.am|6 +
 demo/posix/cobalt/gpiopwm.c  |  448 ++
 include/cobalt/kernel/rtdm/gpiopwm.h |   24 ++
 include/rtdm/uapi/gpiopwm.h  |   56 +
 include/rtdm/uapi/rtdm.h |1 +
 kernel/drivers/Kconfig   |1 +
 kernel/drivers/Makefile  |2 +-
 kernel/drivers/gpiopwm/Kconfig   |9 +
 kernel/drivers/gpiopwm/Makefile  |5 +
 kernel/drivers/gpiopwm/gpiopwm.c |  301 +++
 10 files changed, 852 insertions(+), 1 deletion(-)

diff --git a/demo/posix/cobalt/Makefile.am b/demo/posix/cobalt/Makefile.am
index cba9247..2a22967 100644
--- a/demo/posix/cobalt/Makefile.am
+++ b/demo/posix/cobalt/Makefile.am
@@ -3,6 +3,7 @@ demodir = @XENO_DEMO_DIR@
 CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC)
 
 demo_PROGRAMS =\
+   gpiopwm \
bufp-label  \
bufp-readwrite  \
can_rtt \
@@ -24,6 +25,11 @@ ldadd =  \
 @XENO_USER_LDADD@  \
-lpthread -lrt
 
+gpiopwm_SOURCES = gpiopwm.c
+gpiopwm_CPPFLAGS = $(cppflags) -I$(top_srcdir)/include/rtdm/uapi
+gpiopwm_LDFLAGS = $(ldflags)
+gpiopwm_LDADD = $(ldadd)
+
 bufp_label_SOURCES = bufp-label.c
 bufp_label_CPPFLAGS = $(cppflags)
 bufp_label_LDFLAGS = $(ldflags)
diff --git a/demo/posix/cobalt/gpiopwm.c b/demo/posix/cobalt/gpiopwm.c
new file mode 100644
index 000..e093fbe
--- /dev/null
+++ b/demo/posix/cobalt/gpiopwm.c
@@ -0,0 +1,448 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MIN_DUTY_CYCLE 0
+#define MAX_DUTY_CYCLE 100
+
+typedef void *(*gpiopwm_control_thread)(void *cookie);
+#define DEVICE_NAME "/dev/rtdm/gpiopwm"
+char *device_name;
+int dev;
+
+static sem_t synch;
+static sem_t setup;
+static int stop;
+static int step = 1;
+static int port = 6;
+
+#define GPIO_PWM_SERVO_CONFIG  \
+{  \
+   .duty_cycle =   50, \
+   .range_min  =   950,\
+   .range_max  =   2050,   \
+   .period =   2000,   \
+   .gpio   =   1,  \
+}
+
+static struct gpiopwm config = GPIO_PWM_SERVO_CONFIG;
+
+static void fail(const char *reason)
+{
+   perror(reason);
+   exit(EXIT_FAILURE);
+}
+
+static void sem_sync(sem_t *sem)
+{
+   int ret;
+
+   for (;;) {
+   ret = sem_wait(sem);
+   if (ret == 0)
+   return;
+   if (errno != EINTR)
+   fail("sem_wait");
+   }
+}
+
+static inline void clear_screen(void)
+{
+   const char* cmd = "\e[1;1H\e[2J";
+   int ret;
+
+   ret = write(2, cmd, strlen(cmd));
+   if (!ret)
+   error(1, ret, "clear screen error");
+}
+
+static inline void print_config(char *str)
+{
+   printf("Config: %s\n", str);
+   printf(" device : %s\n", device_name);
+   printf(" range  : [%d, %d]\n", config.range_min, config.range_max);
+   printf(" period : %d nsec\n", config.period);
+   printf(" gpio pin   : %d\n", config.gpio);
+   printf(" duty cycle : %d\n", config.duty_cycle);
+}
+
+static inline void input_message(void)
+{
+   print_config("");
+   printf("\n GPIO PWM Control\n");
+   printf( "  Enter duty_cycle [0-100] : ");
+}
+
+static void setup_sched_parameters(pthread_attr_t *attr, int prio)
+{
+   struct sched_param p;
+   int ret;
+
+   ret = pthread_attr_init(attr);
+   if (ret)
+   error(1, ret, "pthread_attr_init()");
+
+   ret = pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED);
+   if (ret)
+   error(1, ret, "pthread_attr_setinheritsched()");
+
+   ret = pthread_attr_setschedpolicy(attr, prio ? SCHED_FIFO : 
SCHED_OTHER);
+   if (ret)
+   error(1, ret, "pthread_attr_setschedpolicy()");
+
+   p.sched_priority = prio;
+   ret = pthread_attr_setschedparam(attr, );
+   if (ret)
+   error(1, ret, "pthread_attr_setschedparam()");
+}
+
+static void *gpiopwm_init_thread(void *cookie)
+{
+   int ret;
+
+   pthread_setname_np(pthread_self(), "gpio-pwm-handler");
+   ret = ioctl(dev, GPIOPWM_RTIOC_SET_CONFIG, config);
+   if (ret)
+   error(1, ret, "failed to set config");
+
+   ioctl(dev, GPIOPWM_RTIOC_START);
+
+ 

[Xenomai-git] Philippe Gerum : cobalt/arm64: add README

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 4c82fa977c0ace78ab49adc986988c6e3cf8ce69
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4c82fa977c0ace78ab49adc986988c6e3cf8ce69

Author: Philippe Gerum 
Date:   Wed Feb 15 16:17:54 2017 +0100

cobalt/arm64: add README

---

 kernel/cobalt/arch/arm64/README |3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/cobalt/arch/arm64/README b/kernel/cobalt/arch/arm64/README
new file mode 100644
index 000..80f954a
--- /dev/null
+++ b/kernel/cobalt/arch/arm64/README
@@ -0,0 +1,3 @@
+Get the interrupt pipeline code for the target kernel from
+http://xenomai.org/downloads/ipipe/, or
+git://git.xenomai.org/ipipe.git


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


[Xenomai-git] Philippe Gerum : testsuite/smokey: mutex: simplify, introduce PP tests

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ebaba02a59849cc478040207f6acfd73c183ad75
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ebaba02a59849cc478040207f6acfd73c183ad75

Author: Philippe Gerum 
Date:   Wed Feb 17 09:21:27 2016 +0100

testsuite/smokey: mutex: simplify, introduce PP tests

At this chance, the lock stealing test is also fixed.

---

 testsuite/smokey/posix-mutex/posix-mutex.c | 1357 ++--
 1 file changed, 670 insertions(+), 687 deletions(-)

diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c 
b/testsuite/smokey/posix-mutex/posix-mutex.c
index ac71b31..ae82fc1 100644
--- a/testsuite/smokey/posix-mutex/posix-mutex.c
+++ b/testsuite/smokey/posix-mutex/posix-mutex.c
@@ -4,6 +4,7 @@
  * Copyright (C) Gilles Chanteperdrix  ,
  *   Marion Deveaud ,
  *   Jan Kiszka 
+ *   Philippe Gerum 
  *
  * Released under the terms of GPLv2.
  */
@@ -17,8 +18,6 @@
 #include 
 #include 
 #include 
-#include 
-#include "lib/cobalt/current.h"
 #include 
 
 smokey_test_plugin(posix_mutex,
@@ -26,886 +25,870 @@ smokey_test_plugin(posix_mutex,
   "Check POSIX mutex services"
 );
 
-#define MUTEX_CREATE   1
-#define MUTEX_LOCK 2
-#define MUTEX_TRYLOCK  3
-#define MUTEX_TIMED_LOCK   4
-#define MUTEX_UNLOCK   5
-#define MUTEX_DESTROY  6
-#define COND_CREATE7
-#define COND_SIGNAL8
-#define COND_WAIT  9
-#define COND_DESTROY   10
-#define THREAD_DETACH  11
-#define THREAD_CREATE  12
-#define THREAD_JOIN13
-#define THREAD_RENICE   14
-
-#define NS_PER_MS  100
-
 static const char *reason_str[] = {
-   [SIGDEBUG_UNDEFINED] = "undefined",
+   [SIGDEBUG_UNDEFINED] = "received SIGDEBUG for unknown reason",
[SIGDEBUG_MIGRATE_SIGNAL] = "received signal",
[SIGDEBUG_MIGRATE_SYSCALL] = "invoked syscall",
[SIGDEBUG_MIGRATE_FAULT] = "triggered fault",
[SIGDEBUG_MIGRATE_PRIOINV] = "affected by priority inversion",
-   [SIGDEBUG_NOMLOCK] = "missing mlockall",
-   [SIGDEBUG_WATCHDOG] = "runaway thread",
+   [SIGDEBUG_NOMLOCK] = "process memory not locked",
+   [SIGDEBUG_WATCHDOG] = "watchdog triggered (period too short?)",
+   [SIGDEBUG_LOCK_BREAK] = "scheduler lock break",
 };
 
 static void sigdebug(int sig, siginfo_t *si, void *context)
 {
+   const char fmt[] = "%s, this is unexpected.\n"
+   "(enabling CONFIG_XENO_OPT_DEBUG_TRACE_RELAX may help)\n";
unsigned int reason = sigdebug_reason(si);
+   int n __attribute__ ((unused));
+   static char buffer[256];
 
-   smokey_trace("\nSIGDEBUG received, reason %d: %s\n", reason,
-reason <= SIGDEBUG_WATCHDOG ? reason_str[reason] : 
"");
-}
+   if (reason > SIGDEBUG_WATCHDOG)
+   reason = SIGDEBUG_UNDEFINED;
 
-static inline unsigned long long timer_get_tsc(void)
-{
-   return clockobj_get_tsc();
+   n = snprintf(buffer, sizeof(buffer), fmt, reason_str[reason]);
+   n = write(STDERR_FILENO, buffer, n);
 }
 
-static inline unsigned long long timer_tsc2ns(unsigned long long tsc)
-{
-   return clockobj_tsc_to_ns(tsc);
-}
+#define THREAD_PRIO_WEAK   0
+#define THREAD_PRIO_LOW1
+#define THREAD_PRIO_MEDIUM 2
+#define THREAD_PRIO_HIGH   3
+#define THREAD_PRIO_VERY_HIGH  4
 
-static void add_timespec(struct timespec *ts, unsigned long long value)
-{
-   ts->tv_sec += value / 10;
-   ts->tv_nsec += value % 10;
-   if (ts->tv_nsec > 10) {
-   ts->tv_sec++;
-   ts->tv_nsec -= 10;
-   }
-}
+#define MAX_100_MS  1ULL
+
+struct locker_context {
+   pthread_mutex_t *mutex;
+   struct smokey_barrier *barrier;
+   int lock_acquired;
+};
 
-static void ms_sleep(int time)
+static void sleep_ms(unsigned int ms)  /* < 1000 */
 {
struct timespec ts;
-
+   
ts.tv_sec = 0;
-   ts.tv_nsec = time*NS_PER_MS;
-
-   nanosleep(, NULL);
+   ts.tv_nsec = ms * 100;
+   clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL);
 }
 
-static void check_current_prio(int expected_prio)
+static int get_effective_prio(void) 
 {
struct cobalt_threadstat stat;
int ret;
 
ret = cobalt_thread_stat(0, );
-   if (ret) {
-   fprintf(stderr,
-   "FAILURE: cobalt_threadstat (%s)\n", strerror(-ret));
-   exit(EXIT_FAILURE);
-   }
+   if (ret)
+   return ret;
 
-   if (stat.cprio != expected_prio) {
-   fprintf(stderr,
-   "FAILURE: current prio (%d) != expected prio (%d)\n",
-   stat.cprio, expected_prio);
-   exit(EXIT_FAILURE);
-   }
+   

[Xenomai-git] Jan Kiszka : cobalt/kernel: Introduce __SCHED_CURRENT policy to setschedparam_ex

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 97b39bc46da70a15dbfe8f76b1912ba9afea219c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=97b39bc46da70a15dbfe8f76b1912ba9afea219c

Author: Jan Kiszka 
Date:   Tue Mar  8 14:41:28 2016 +0100

cobalt/kernel: Introduce __SCHED_CURRENT policy to setschedparam_ex

Define the internal scheduling policy "current": it shall refer to the
target thread's current scheduling policy. This will allow to model
pthread_setschedprio on top of pthread_setschedparam_ex with only a
single syscall.

Signed-off-by: Jan Kiszka 

---

 include/cobalt/uapi/sched.h|3 +++
 kernel/cobalt/posix/thread.c   |   10 ++
 kernel/cobalt/trace/cobalt-posix.h |3 ++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/cobalt/uapi/sched.h b/include/cobalt/uapi/sched.h
index b672095..2a1df44 100644
--- a/include/cobalt/uapi/sched.h
+++ b/include/cobalt/uapi/sched.h
@@ -21,6 +21,9 @@
 #define SCHED_COBALT   42
 #define SCHED_WEAK 43
 
+/* for internal use */
+#define __SCHED_CURRENT44
+
 #ifndef SCHED_SPORADIC
 #define SCHED_SPORADIC 10
 #define sched_ss_low_priority  sched_u.ss.__sched_low_priority
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index d87edb1..217b81b 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -242,6 +242,7 @@ struct xnthread_personality *cobalt_thread_finalize(struct 
xnthread *zombie)
 int __cobalt_thread_setschedparam_ex(struct cobalt_thread *thread, int policy,
 const struct sched_param_ex *param_ex)
 {
+   struct xnthread *base_thread = >threadbase;
struct xnsched_class *sched_class;
union xnsched_policy_param param;
xnticks_t tslice;
@@ -256,6 +257,15 @@ int __cobalt_thread_setschedparam_ex(struct cobalt_thread 
*thread, int policy,
goto out;
}
 
+   if (policy == __SCHED_CURRENT) {
+   policy = base_thread->base_class->policy;
+   if (xnthread_base_priority(base_thread) == 0)
+   policy = SCHED_NORMAL;
+   else if (base_thread->base_class == _class_rt &&
+xnthread_test_state(base_thread, XNRRB))
+   policy = SCHED_RR;
+   }
+
tslice = thread->threadbase.rrperiod;
sched_class = cobalt_sched_policy_param(, policy,
param_ex, );
diff --git a/kernel/cobalt/trace/cobalt-posix.h 
b/kernel/cobalt/trace/cobalt-posix.h
index 3d0e20c..cc0eb05 100644
--- a/kernel/cobalt/trace/cobalt-posix.h
+++ b/kernel/cobalt/trace/cobalt-posix.h
@@ -90,7 +90,8 @@ DECLARE_EVENT_CLASS(syscall_exit,
 {SCHED_QUOTA, "quota"},\
 {SCHED_SPORADIC, "sporadic"},  \
 {SCHED_COBALT, "cobalt"},  \
-{SCHED_WEAK, "weak"})
+{SCHED_WEAK, "weak"},  \
+{__SCHED_CURRENT, ""})
 
 #define cobalt_print_sched_params(__policy, __p_ex)\
 ({ \


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


[Xenomai-git] Philippe Gerum : cobalt/kernel: fixup for v3.19+ (user_msghdr)

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 3e71b17ed785d2c276a31a0767cd0a0fd190110f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3e71b17ed785d2c276a31a0767cd0a0fd190110f

Author: Philippe Gerum 
Date:   Mon Nov  2 20:45:10 2015 +0100

cobalt/kernel: fixup for v3.19+ (user_msghdr)

---

 kernel/cobalt/include/asm-generic/xenomai/wrappers.h |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index 0f9ab14..8ad4108 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -38,6 +38,12 @@
  *   symbol, so that obsolete wrappers can be spotted.
  */
 
+#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
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0)
 #define user_msghdr msghdr
 #endif
@@ -133,10 +139,4 @@ 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 */


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


[Xenomai-git] Philippe Gerum : cobalt/wrappers: add wrapper for reinit_completion()

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 0d05921408b3acabc318f7d738fce963a861dc73
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0d05921408b3acabc318f7d738fce963a861dc73

Author: Philippe Gerum 
Date:   Thu Mar  3 09:16:21 2016 +0100

cobalt/wrappers: add wrapper for reinit_completion()

---

 kernel/cobalt/include/asm-generic/xenomai/wrappers.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h 
b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index a9424b9..8ad4108 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -50,7 +50,6 @@
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
 #include 
-#include 
 
 #undef alloc_netdev
 #define alloc_netdev(sizeof_priv, name, name_assign_type, setup) \
@@ -63,6 +62,7 @@ trace_seq_buffer_ptr(struct trace_seq *s)
 {
return s->buffer + s->len;
 }
+
 #endif /* < 3.17 */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)


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


[Xenomai-git] Philippe Gerum : cobalt/powerpc: drop support for unlocked context switch

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 232718885e6afa727a487eb170ef02d254da70ee
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=232718885e6afa727a487eb170ef02d254da70ee

Author: Philippe Gerum 
Date:   Sat Nov 14 16:41:13 2015 +0100

cobalt/powerpc: drop support for unlocked context switch

This feature never actually brought any measurable gain on powerpc
platforms, compared to the complexity of its implementation in the
pipeline. It was primarily aimed at reducing latency for interrupt
handlers when costly cache and TLB flushes are required to switch
context, at the expense of increasing the scheduling latency.  It
turned out to be counter-productive on common powerpc platforms, with
efficient MMUs.

This feature has been default off for a while now, and 4.1+ pipelines
won't provide support for it anymore. Time to drop support from
Xenomai too.

---

 kernel/cobalt/arch/powerpc/Kconfig |   20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/kernel/cobalt/arch/powerpc/Kconfig 
b/kernel/cobalt/arch/powerpc/Kconfig
index 40eae0b..1cabef3 100644
--- a/kernel/cobalt/arch/powerpc/Kconfig
+++ b/kernel/cobalt/arch/powerpc/Kconfig
@@ -5,29 +5,11 @@ config XENO_ARCH_MATH_EMU
 bool
default y if MATH_EMU || MATH_EMULATION
 
-config IPIPE_WANT_PREEMPTIBLE_SWITCH
-bool
-   default y if XENO_ARCH_UNLOCKED_SWITCH
-   default n if !XENO_ARCH_UNLOCKED_SWITCH
-
 config XENO_ARCH_FPU
def_bool PPC_FPU
 
 config XENO_ARCH_SYS3264
 def_bool n
 
-menu "Machine/platform-specific options"
-
 config XENO_ARCH_UNLOCKED_SWITCH
-   bool "Unlocked context switch"
-   depends on IPIPE_HAVE_PREEMPTIBLE_SWITCH
-   default y
-   help
-
-   The Cobalt core may allow non-atomic execution of the
-   machine-dependent context switching code, so that other CPUs
-   and/or local interrupts may execute concurrently.
-
-   This option reduces interrupt latency when costly cache and
-   TLB flushes are required to switch context.
-endmenu
+   def_bool n


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


[Xenomai-git] Philippe Gerum : config: bump version info to 3.1-devel

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a516833380e0ad1d8eb3ac8f55ad86fb71cb1fbf
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a516833380e0ad1d8eb3ac8f55ad86fb71cb1fbf

Author: Philippe Gerum 
Date:   Sun Mar 20 18:51:17 2016 +0100

config: bump version info to 3.1-devel

---

 config/version-code  |2 +-
 config/version-label |2 +-
 config/version-name  |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/config/version-code b/config/version-code
index b0f2dcb..ddd61cc 100644
--- a/config/version-code
+++ b/config/version-code
@@ -1 +1 @@
-3.0.4
+3.0.90
diff --git a/config/version-label b/config/version-label
index b0f2dcb..302fdd0 100644
--- a/config/version-label
+++ b/config/version-label
@@ -1 +1 @@
-3.0.4
+3.1-devel
diff --git a/config/version-name b/config/version-name
index 76b0401..8c51501 100644
--- a/config/version-name
+++ b/config/version-name
@@ -1 +1 @@
-Washed Out Harlequin
+Xenomai -next


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


[Xenomai-git] Philippe Gerum : cobalt/thread: track thread_info unconditionally

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 93f483b2c774f5b31a020cf466160d80d5746b51
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=93f483b2c774f5b31a020cf466160d80d5746b51

Author: Philippe Gerum 
Date:   Sat Nov 14 14:47:44 2015 +0100

cobalt/thread: track thread_info unconditionally

We almost always want to track the thread_info structure of the host
task in the core tcb, and doing so is cheap, so there is no point in
building this support conditionally.

---

 kernel/cobalt/arch/arm/Kconfig |3 ---
 kernel/cobalt/arch/arm64/Kconfig   |3 ---
 kernel/cobalt/arch/powerpc/Kconfig |4 
 kernel/cobalt/include/asm-generic/xenomai/thread.h |2 --
 kernel/cobalt/sched.c  |2 --
 kernel/cobalt/thread.c |4 
 6 files changed, 18 deletions(-)

diff --git a/kernel/cobalt/arch/arm/Kconfig b/kernel/cobalt/arch/arm/Kconfig
index dc6485d..2043d70 100644
--- a/kernel/cobalt/arch/arm/Kconfig
+++ b/kernel/cobalt/arch/arm/Kconfig
@@ -26,9 +26,6 @@ config IPIPE_WANT_PREEMPTIBLE_SWITCH
 config IPIPE_WANT_ACTIVE_MM
def_bool y
 
-config XENO_ARCH_WANT_TIP
-   def_bool y
-
 config XENO_ARCH_FPU
def_bool VFP
 
diff --git a/kernel/cobalt/arch/arm64/Kconfig b/kernel/cobalt/arch/arm64/Kconfig
index 27b5026..572de3e 100644
--- a/kernel/cobalt/arch/arm64/Kconfig
+++ b/kernel/cobalt/arch/arm64/Kconfig
@@ -4,9 +4,6 @@ source "drivers/xenomai/Kconfig"
 config XENO_ARCH_UNLOCKED_SWITCH
def_bool IPIPE_WANT_PREEMPTIBLE_SWITCH
 
-config XENO_ARCH_WANT_TIP
-   def_bool y
-
 config XENO_ARCH_FPU
def_bool y
 
diff --git a/kernel/cobalt/arch/powerpc/Kconfig 
b/kernel/cobalt/arch/powerpc/Kconfig
index 3e950f5..4d5e6db 100644
--- a/kernel/cobalt/arch/powerpc/Kconfig
+++ b/kernel/cobalt/arch/powerpc/Kconfig
@@ -10,9 +10,6 @@ config IPIPE_WANT_PREEMPTIBLE_SWITCH
default y if XENO_ARCH_UNLOCKED_SWITCH
default n if !XENO_ARCH_UNLOCKED_SWITCH
 
-config XENO_ARCH_WANT_TIP
-   bool
-
 config XENO_ARCH_FPU
def_bool PPC_FPU
 
@@ -24,7 +21,6 @@ menu "Machine/platform-specific options"
 config XENO_ARCH_UNLOCKED_SWITCH
bool "Unlocked context switch"
depends on IPIPE_HAVE_PREEMPTIBLE_SWITCH
-   select XENO_ARCH_WANT_TIP
default y
help
 
diff --git a/kernel/cobalt/include/asm-generic/xenomai/thread.h 
b/kernel/cobalt/include/asm-generic/xenomai/thread.h
index 2ff19a4..cd0c6e9 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/thread.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/thread.h
@@ -33,9 +33,7 @@ struct xntcb {
struct mm_struct *mm;
struct mm_struct *active_mm;
struct thread_struct ts;
-#ifdef CONFIG_XENO_ARCH_WANT_TIP
struct thread_info *tip;
-#endif
 #ifdef CONFIG_XENO_ARCH_FPU
struct task_struct *user_fpu_owner;
 #endif
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index cbe14bd..09960ac 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -806,9 +806,7 @@ static inline void leave_root(struct xnthread *root)
rootcb->core.host_task = p;
rootcb->core.tsp = >thread;
rootcb->core.mm = rootcb->core.active_mm = ipipe_get_active_mm();
-#ifdef CONFIG_XENO_ARCH_WANT_TIP
rootcb->core.tip = task_thread_info(p);
-#endif
xnarch_leave_root(root);
 }
 
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index 34eca35..e0c488e 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -260,9 +260,7 @@ void xnthread_init_shadow_tcb(struct xnthread *thread)
tcb->core.tsp = >thread;
tcb->core.mm = p->mm;
tcb->core.active_mm = p->mm;
-#ifdef CONFIG_XENO_ARCH_WANT_TIP
tcb->core.tip = task_thread_info(p);
-#endif
 #ifdef CONFIG_XENO_ARCH_FPU
tcb->core.user_fpu_owner = p;
 #endif /* CONFIG_XENO_ARCH_FPU */
@@ -278,9 +276,7 @@ void xnthread_init_root_tcb(struct xnthread *thread)
tcb->core.host_task = p;
tcb->core.tsp = >core.ts;
tcb->core.mm = p->mm;
-#ifdef CONFIG_XENO_ARCH_WANT_TIP
tcb->core.tip = NULL;
-#endif
xnarch_init_root_tcb(thread);
 }
 


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


[Xenomai-git] Gilles Chanteperdrix : testsuite/smokey: add RTnet testsuite

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: cd7b2a333155900ba547c87cb31c2780ef2375c9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cd7b2a333155900ba547c87cb31c2780ef2375c9

Author: Gilles Chanteperdrix 
Date:   Sun Oct 11 16:05:18 2015 +0200

testsuite/smokey: add RTnet testsuite

Starting with UDP and raw sockets.
Measuring round trip time and checking for lost packets.

---

 configure.ac |3 +++
 1 file changed, 3 insertions(+)

diff --git a/configure.ac b/configure.ac
index 1432ef2..12007f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -919,6 +919,9 @@ AC_CONFIG_FILES([ \
testsuite/smokey/tsc/Makefile \
testsuite/smokey/leaks/Makefile \
testsuite/smokey/fpu-stress/Makefile \
+   testsuite/smokey/net_udp/Makefile \
+   testsuite/smokey/net_packet_dgram/Makefile \
+   testsuite/smokey/net_common/Makefile \
testsuite/clocktest/Makefile \
testsuite/xeno-test/Makefile \
utils/Makefile \


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: fpu: drop obsolete xnarch_save_fpu()

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 9fcb91a9f0df86af128ab8527305bc4a323aab4a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9fcb91a9f0df86af128ab8527305bc4a323aab4a

Author: Philippe Gerum 
Date:   Thu Sep  8 16:29:59 2016 +0200

cobalt/arm64: fpu: drop obsolete xnarch_save_fpu()

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h |4 
 1 file changed, 4 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index 4b247ac..ac1f1f7 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -75,8 +75,6 @@ static inline int xnarch_fault_fpu_p(struct ipipe_trap_data 
*d)
 
 void xnarch_leave_root(struct xnthread *root);
 
-void xnarch_save_fpu(struct xnthread *thread);
-
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
 static inline int
@@ -103,8 +101,6 @@ static inline int xnarch_fault_fpu_p(struct ipipe_trap_data 
*d)
 
 static inline void xnarch_leave_root(struct xnthread *root) { }
 
-static inline void xnarch_save_fpu(struct xnthread *thread) { }
-
 static inline void xnarch_switch_fpu(struct xnthread *f, struct xnthread *t) { 
}
 
 static inline int xnarch_handle_fpu_fault(struct xnthread *from, 


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


[Xenomai-git] Jan Kiszka : cobalt/kernel: Trigger missing reschedule after PP deboost

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 43a6857a337743d649519ed7982523c40cae1f5a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=43a6857a337743d649519ed7982523c40cae1f5a

Author: Jan Kiszka 
Date:   Mon May  9 21:22:23 2016 +0200

cobalt/kernel: Trigger missing reschedule after PP deboost

xnsynch_release also needs to tell the caller about the potential need
for a reschedule after deboosting for prio-protection.

Signed-off-by: Jan Kiszka 

---

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

diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c
index d8b83d9..f3b70a2 100644
--- a/kernel/cobalt/synch.c
+++ b/kernel/cobalt/synch.c
@@ -949,8 +949,10 @@ bool xnsynch_release(struct xnsynch *synch, struct 
xnthread *curr)
else if (h != currh)/* FLCEIL set, FLCLAIM clear. */
atomic_set(lockp, XN_NO_HANDLE);
 
-   if (synch->status & XNSYNCH_PP)
+   if (synch->status & XNSYNCH_PP) {
clear_pp_boost(synch, curr);
+   need_resched = true;
+   }
 
xnlock_put_irqrestore(, s);
 


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


[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: fc0164bc20716ec32251c3ea2029597b203a7727
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fc0164bc20716ec32251c3ea2029597b203a7727

Author: Philippe Gerum 
Date:   Fri Mar 18 12:12:50 2016 +0100

cobalt/thread: add schedparam lazy propagation

Provide a mechanism for carrying out a lazy propagation of schedparam
updates to the regular kernel, so that userland does not have to
switch to secondary mode for this.

When userland issues sc_cobalt_thread_setschedparam_ex for updating
the scheduling parameters of a Xenomai thread, a request for
propagating this change to the regular kernel is made pending. Such
request will be committed later, either when:

- the thread relaxes if it is running in primary mode when the update
  request is received;

- next time the thread calls back into the Cobalt core as a result of
  receiving a HOME action from a SIGSHADOW notification, which is sent
  if such thread was relaxed at the time of the update request.

As a result, the target thread will have propagated the schedparams
update to the regular kernel as soon as it resumes (relaxed) execution
in user-space.

---

 include/cobalt/kernel/thread.h  |8 +
 include/cobalt/uapi/kernel/thread.h |1 +
 include/cobalt/uapi/signal.h|1 +
 kernel/cobalt/posix/syscall.c   |9 ++
 kernel/cobalt/thread.c  |   55 +++
 5 files changed, 74 insertions(+)

diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index 07b6996..a4d826e 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -567,6 +567,14 @@ int xnthread_set_schedparam(struct xnthread *thread,
 
 int xnthread_killall(int grace, int mask);
 
+void __xnthread_propagate_schedparam(struct xnthread *curr);
+
+static inline void xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   if (xnthread_test_info(curr, XNSCHEDP))
+   __xnthread_propagate_schedparam(curr);
+}
+
 extern struct xnthread_personality xenomai_personality;
 
 /** @} */
diff --git a/include/cobalt/uapi/kernel/thread.h 
b/include/cobalt/uapi/kernel/thread.h
index 37637f6..6f30fcd 100644
--- a/include/cobalt/uapi/kernel/thread.h
+++ b/include/cobalt/uapi/kernel/thread.h
@@ -71,6 +71,7 @@
 #define XNROBBED  0x0020 /**< Robbed from resource ownership */
 #define XNCANCELD 0x0040 /**< Cancellation request is pending */
 #define XNPIALERT 0x0080 /**< Priority inversion alert (SIGDEBUG sent) */
+#define XNSCHEDP  0x0100 /**< schedparam propagation is pending */
 
 /* Local information flags (private to current thread) */
 
diff --git a/include/cobalt/uapi/signal.h b/include/cobalt/uapi/signal.h
index b5483d7..8a7ea15 100644
--- a/include/cobalt/uapi/signal.h
+++ b/include/cobalt/uapi/signal.h
@@ -47,6 +47,7 @@
 /* SIGSHADOW action codes. */
 #define SIGSHADOW_ACTION_HARDEN1
 #define SIGSHADOW_ACTION_BACKTRACE 2
+#define SIGSHADOW_ACTION_HOME  3
 #define SIGSHADOW_BACKTRACE_DEPTH  16
 
 #define SIGDEBUG   SIGXCPU
diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 2582949..0aeff28 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -731,6 +731,15 @@ restart:
goto ret_handled;
}
switched = 1;
+   } else {
+   /*
+* We want to run the syscall in the current Linux
+* domain. This is a slow path, so proceed with any
+* pending schedparam update on the fly.
+*/
+   switched = 0;
+   if (thread)
+   xnthread_propagate_schedparam(thread);
}
 
ret = handler(__xn_reg_arglist(regs));
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index d00714c..7db3c1b 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1961,6 +1962,11 @@ int __xnthread_set_schedparam(struct xnthread *thread,
thread->lock_count == 0)
xnsched_putback(thread);
 
+   xnthread_set_info(thread, XNSCHEDP);
+   /* Ask the target thread to call back if relaxed. */
+   if (xnthread_test_state(thread, XNRELAX))
+   xnthread_signal(thread, SIGSHADOW, SIGSHADOW_ACTION_HOME);
+   
return ret;
 }
 
@@ -2082,6 +2088,40 @@ static void post_wakeup(struct task_struct *p)
ipipe_post_work_root(, work);
 }
 
+void __xnthread_propagate_schedparam(struct xnthread *curr)
+{
+   int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret;
+   struct task_struct *p = current;
+   struct sched_param param;
+   spl_t s;
+
+   /*
+* Test-set race for XNSCHEDP is ok, the propagation is meant
+* to be done asap but not guaranteed to be 

[Xenomai-git] Gilles Chanteperdrix : testsuite/smokey: add RTnet raw packets test

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 208cfe0995d6d402d9f8bee95130338a1ea446cc
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=208cfe0995d6d402d9f8bee95130338a1ea446cc

Author: Gilles Chanteperdrix 
Date:   Sun Nov  1 19:14:40 2015 +0100

testsuite/smokey: add RTnet raw packets test

---

 configure.ac |1 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index 12007f3..f42538c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -921,6 +921,7 @@ AC_CONFIG_FILES([ \
testsuite/smokey/fpu-stress/Makefile \
testsuite/smokey/net_udp/Makefile \
testsuite/smokey/net_packet_dgram/Makefile \
+   testsuite/smokey/net_packet_raw/Makefile \
testsuite/smokey/net_common/Makefile \
testsuite/clocktest/Makefile \
testsuite/xeno-test/Makefile \


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


[Xenomai-git] Philippe Gerum : cobalt/powerpc: remove dependency on obsolete CONFIG_MATH_EMU

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 614d967074db60694677d4d4bd33145e7689b419
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=614d967074db60694677d4d4bd33145e7689b419

Author: Philippe Gerum 
Date:   Mon Jul 11 15:42:01 2016 +0200

cobalt/powerpc: remove dependency on obsolete CONFIG_MATH_EMU

---

 kernel/cobalt/arch/powerpc/Kconfig |4 
 1 file changed, 4 deletions(-)

diff --git a/kernel/cobalt/arch/powerpc/Kconfig 
b/kernel/cobalt/arch/powerpc/Kconfig
index 2069288..6ce3440 100644
--- a/kernel/cobalt/arch/powerpc/Kconfig
+++ b/kernel/cobalt/arch/powerpc/Kconfig
@@ -1,10 +1,6 @@
 source "kernel/xenomai/Kconfig"
 source "drivers/xenomai/Kconfig"
 
-config XENO_ARCH_MATH_EMU
-bool
-   default y if MATH_EMU || MATH_EMULATION
-
 config XENO_ARCH_FPU
def_bool PPC_FPU
 


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: thread: move all TCB initializers out of line

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 4c29370639900fae55d60a282dca7364d4880067
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4c29370639900fae55d60a282dca7364d4880067

Author: Philippe Gerum 
Date:   Fri Sep  9 16:07:54 2016 +0200

cobalt/arm64: thread: move all TCB initializers out of line

Does not impact performances and fixes inclusion hell for pulling the
struct xnthread definition for good.

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h |6 +-
 kernel/cobalt/arch/arm64/thread.c |6 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index ac1f1f7..319f4d8 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -60,11 +60,7 @@ int xnarch_escalate(void);
 
 #if defined(CONFIG_XENO_ARCH_FPU)
 
-static inline void xnarch_init_root_tcb(struct xnthread *thread)
-{
-   struct xnarchtcb *tcb = xnthread_archtcb(thread);
-   tcb->fpup = NULL;
-}
+void xnarch_init_root_tcb(struct xnthread *thread);
 
 void xnarch_init_shadow_tcb(struct xnthread *thread);
 
diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index b987e09..3097aeb 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -98,6 +98,12 @@ void xnarch_init_shadow_tcb(struct xnthread *thread)
tcb->fpup = >core.host_task->thread.fpsimd_state;
 }
 
+void xnarch_init_root_tcb(struct xnthread *thread)
+{
+   struct xnarchtcb *tcb = >tcb;
+   tcb->fpup = NULL;
+}
+
 #endif /* CONFIG_XENO_ARCH_FPU */
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in)


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


[Xenomai-git] Philippe Gerum : boilerplate: add AVL library

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 62be024e6600f6cec6382f32f8808509289059d9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=62be024e6600f6cec6382f32f8808509289059d9

Author: Philippe Gerum 
Date:   Tue May 31 17:30:21 2016 +0200

boilerplate: add AVL library

---

 include/boilerplate/Makefile.am |1 +
 include/boilerplate/avl.h   |  298 ++
 lib/boilerplate/Makefile.am |1 +
 lib/boilerplate/avl.c   |  380 +++
 4 files changed, 680 insertions(+)

diff --git a/include/boilerplate/Makefile.am b/include/boilerplate/Makefile.am
index 2d3ace8..c975509 100644
--- a/include/boilerplate/Makefile.am
+++ b/include/boilerplate/Makefile.am
@@ -3,6 +3,7 @@ includesubdir = $(includedir)/boilerplate
 includesub_HEADERS =   \
ancillaries.h   \
atomic.h\
+   avl.h   \
compiler.h  \
debug.h \
hash.h  \
diff --git a/include/boilerplate/avl.h b/include/boilerplate/avl.h
new file mode 100644
index 000..1aa84bf
--- /dev/null
+++ b/include/boilerplate/avl.h
@@ -0,0 +1,298 @@
+/*
+ * Copyright (c) 2015 Gilles Chanteperdrix
+ *
+ * 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:
+ *
+ * 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.
+ */
+#ifndef _BOILERPLATE_AVL_H
+#define _BOILERPLATE_AVL_H
+
+#include 
+
+struct avlh {
+   unsigned int thr: 3;
+   int type: 2;
+   int balance :2;
+   unsigned int flags :25; /* Application-specific */
+   struct avlh *link[3];
+};
+
+/* Using -1 and 1 for left and right is slightly faster than 0 and 1, using 0
+   for "up" is just here for orthogonality... and avoid wasting 4 bytes or
+   having to use a union in struct avlh. */
+#define AVL_LEFT -1
+#define AVL_UP0
+#define AVL_RIGHT 1
+/* maps AVL_LEFT to AVL_RIGHT and reciprocally. */
+#define avl_opposite(type)   (-(type))
+/* maps AVL_LEFT to -1 and AVL_RIGHT to 1. */
+#define avl_type2sign(type)  (type)
+/* maps AVL_LEFT and AVL_RIGHT to arrays index (or bit positions). */
+#define avl_type2index(type) ((type)+1)
+/* maps <0 to AVL_LEFT and >0 to AVL_RIGHT. */
+#define avl_sign2type(sign)  (sign)
+
+#define AVL_THR_LEFT  (1<thr |= 1 << avl_type2index(side))
+#define avlh_thr_clr(holder, side) ((holder)->thr &= ~(1 << 
avl_type2index(side)))
+#define avlh_thr_tst(holder, side) ((holder)->thr & (1 << 
avl_type2index(side)))
+#define avlh_link(holder, dir) ((holder)->link[avl_type2index(dir)])
+#define avlh_up(holder)avlh_link((holder), AVL_UP)
+#define avlh_left(holder)  avlh_link((holder), AVL_LEFT)
+#define avlh_right(holder) avlh_link((holder), AVL_RIGHT)
+#define avlh_parent_link(holder)   (avlh_link(avlh_up(holder), (holder)->type))
+
+struct avl;
+
+typedef struct avlh *avl_search_t(const struct avl *, const struct avlh *, int 
*);
+
+typedef int avlh_cmp_t(const struct avlh *const, const struct avlh *const);
+
+struct avl {
+   struct avlh anchor;
+   avl_search_t *search;
+   avlh_cmp_t *cmp;
+   struct avlh *end[3];
+   unsigned int count;
+   unsigned int height;
+};
+
+#define avl_searchfn(avl) ((avl)->search)
+#define avl_cmp(avl)  ((avl)->cmp)
+#define avl_count(avl)((avl)->count)
+#define avl_height(avl)   ((avl)->height)
+#define avl_anchor(avl)   (&(avl)->anchor)
+#define avl_end(avl, dir) ((avl)->end[avl_type2index(dir)])
+#define avl_top(avl)  (avlh_right(avl_anchor(avl)))
+#define avl_head(avl) (avl_end((avl), AVL_LEFT))
+#define avl_tail(avl) (avl_end((avl), AVL_RIGHT))
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void avl_init(struct avl *avl, avl_search_t *search, avlh_cmp_t *cmp);
+
+void avl_destroy(struct avl *avl);
+
+void avl_clear(struct avl *avl, void (*destruct)(struct avlh 

[Xenomai-git] Jorge Ramirez-Ortiz : utils/analogy: fix error check [SIGSEGV]

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 44bb3b770f7636c59674b6183a9e17069ae0639d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=44bb3b770f7636c59674b6183a9e17069ae0639d

Author: Jorge Ramirez-Ortiz 
Date:   Wed Oct  5 21:34:27 2016 +0200

utils/analogy: fix error check [SIGSEGV]

---

 utils/analogy/cmd_read.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/analogy/cmd_read.c b/utils/analogy/cmd_read.c
index a507801..86522f4 100644
--- a/utils/analogy/cmd_read.c
+++ b/utils/analogy/cmd_read.c
@@ -261,12 +261,12 @@ static int map_subdevice_buffer(a4l_desc_t *dsc, unsigned 
long *buf_size, void *
 
 static int cmd_read(struct arguments *arg)
 {
-   unsigned int i, scan_size = 0, cnt = 0, ret = 0, len, ofs;
+   unsigned int i, scan_size = 0, cnt = 0, len, ofs;
dump_function_t dump_function = dump_text;
a4l_desc_t dsc = { .sbdata = NULL };
unsigned long buf_size;
char **argv = arg->argv;
-   int argc = arg->argc;
+   int ret = 0, argc = arg->argc;
void *map = NULL;
 
for (;;) {


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


[Xenomai-git] Jan Kiszka : smokey/posix-mutex: Fix test case /wrt mutex object reuse

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: f6394c3e360931b57ae17ec0ba9b0899fff7c142
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f6394c3e360931b57ae17ec0ba9b0899fff7c142

Author: Jan Kiszka 
Date:   Thu Feb 25 11:29:00 2016 +0100

smokey/posix-mutex: Fix test case /wrt mutex object reuse

Mutex objects created on the stack must be properly destroyed after use.
Otherwise, succeeding tests that use the same stack layout will consider
them busy and refuse to recreate the mutexes.

Signed-off-by: Jan Kiszka 

---

 testsuite/smokey/posix-mutex/posix-mutex.c |   26 +-
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c 
b/testsuite/smokey/posix-mutex/posix-mutex.c
index ae82fc1..151c2f3 100644
--- a/testsuite/smokey/posix-mutex/posix-mutex.c
+++ b/testsuite/smokey/posix-mutex/posix-mutex.c
@@ -623,7 +623,10 @@ static int protect_raise(void)
 
if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM))
return -EINVAL;
-   
+
+   if (!__T(ret, pthread_mutex_destroy()))
+   return ret;
+
return 0;
 }
 
@@ -651,7 +654,10 @@ static int protect_lower(void)
 
if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM))
return -EINVAL;
-   
+
+   if (!__T(ret, pthread_mutex_destroy()))
+   return ret;
+
return 0;
 }
 
@@ -699,7 +705,10 @@ static int protect_weak(void)
if (!__T(ret, pthread_setschedparam(pthread_self(),
old_policy, _param)))
return ret;
-   
+
+   if (!__T(ret, pthread_mutex_destroy()))
+   return ret;
+
return 0;
 }
 
@@ -745,7 +754,11 @@ static int protect_nesting_protect(void)
 
if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM))
return -EINVAL;
-   
+
+   if (!__T(ret, pthread_mutex_destroy(_high)) ||
+   !__T(ret, pthread_mutex_destroy(_very_high)))
+   return ret;
+
return 0;
 }
 
@@ -782,7 +795,10 @@ static int protect_nesting_pi(void)
/* PP boost just dropped: HIGH -> MEDIUM. */
if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM))
return -EINVAL;
-   
+
+   if (!__T(ret, pthread_mutex_destroy(_pp)))
+   return ret;
+
return 0;
 }
 


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


[Xenomai-git] Philippe Gerum : testsuite/smokey: add test checking Cobalt' s cpu affinity control

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 602c2eb85d2c1d803d9d4ae525a4966fd07ee68f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=602c2eb85d2c1d803d9d4ae525a4966fd07ee68f

Author: Philippe Gerum 
Date:   Fri Feb 26 11:44:16 2016 +0100

testsuite/smokey: add test checking Cobalt's cpu affinity control

---

 configure.ac |1 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index f42538c..5418e11 100644
--- a/configure.ac
+++ b/configure.ac
@@ -923,6 +923,7 @@ AC_CONFIG_FILES([ \
testsuite/smokey/net_packet_dgram/Makefile \
testsuite/smokey/net_packet_raw/Makefile \
testsuite/smokey/net_common/Makefile \
+   testsuite/smokey/cpu-affinity/Makefile \
testsuite/clocktest/Makefile \
testsuite/xeno-test/Makefile \
utils/Makefile \


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


[Xenomai-git] Jan Kiszka : lib/cobalt: Provide RT-capable usleep

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ae7fac3cc87f85b4242f65bedef93ecf004f9a15
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ae7fac3cc87f85b4242f65bedef93ecf004f9a15

Author: Jan Kiszka 
Date:   Mon May 30 14:58:07 2016 +0200

lib/cobalt: Provide RT-capable usleep

User may expect this (probably last) sleeping service to be available
under Cobalt just like sleep, nanosleep & Co.

Signed-off-by: Jan Kiszka 

---

 include/cobalt/unistd.h|2 ++
 lib/cobalt/clock.c |   14 ++
 lib/cobalt/cobalt.wrappers |1 +
 lib/cobalt/wrappers.c  |6 ++
 4 files changed, 23 insertions(+)

diff --git a/include/cobalt/unistd.h b/include/cobalt/unistd.h
index 8ad2b40..fe3992a 100644
--- a/include/cobalt/unistd.h
+++ b/include/cobalt/unistd.h
@@ -35,6 +35,8 @@ COBALT_DECL(int, close(int fildes));
 
 COBALT_DECL(unsigned int, sleep(unsigned int seconds));
 
+COBALT_DECL(int, usleep(useconds_t usec));
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c
index 0450019..7b4ef54 100644
--- a/lib/cobalt/clock.c
+++ b/lib/cobalt/clock.c
@@ -364,6 +364,20 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds))
return 0;
 }
 
+/* @apitags{thread-unrestricted, switch-primary} */
+
+COBALT_IMPL(int, usleep, (useconds_t usec))
+{
+   struct timespec rqt;
+
+   if (cobalt_get_current_fast() == XN_NO_HANDLE)
+   return __STD(usleep(usec));
+
+   rqt.tv_sec = usec / 100;
+   rqt.tv_nsec = (usec % 100) * 1000;
+   return __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL));
+}
+
 /* @apitags{unrestricted} */
 
 COBALT_IMPL(int, gettimeofday, (struct timeval *tv, struct timezone *tz))
diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers
index f8bda39..91bd5ef 100644
--- a/lib/cobalt/cobalt.wrappers
+++ b/lib/cobalt/cobalt.wrappers
@@ -108,6 +108,7 @@
 --wrap sigqueue
 --wrap kill
 --wrap sleep
+--wrap usleep
 --wrap mmap
 --wrap mmap64
 --wrap time
diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index 51f470f..b7e6271 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -526,3 +526,9 @@ unsigned int __real_sleep(unsigned int seconds)
 {
return sleep(seconds);
 }
+
+__weak
+int __real_usleep(useconds_t usec)
+{
+   return usleep(usec);
+}


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


[Xenomai-git] Philippe Gerum : boilerplate/libc: provide placeholders for prioceiling ops

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 80c9653253442a9a4cb572dc70cbb2451895ae63
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=80c9653253442a9a4cb572dc70cbb2451895ae63

Author: Philippe Gerum 
Date:   Sun Mar 20 17:20:58 2016 +0100

boilerplate/libc: provide placeholders for prioceiling ops

---

 configure.ac   |2 ++
 include/boilerplate/libc.h |   19 +++
 2 files changed, 21 insertions(+)

diff --git a/configure.ac b/configure.ac
index 6b60723..87737e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -517,6 +517,8 @@ AC_CHECK_FUNCS([pthread_mutexattr_setprotocol   \
pthread_mutexattr_getprioceiling \
pthread_mutexattr_setprioceiling \
pthread_mutexattr_setrobust_np  \
+   pthread_mutex_getprioceiling\
+   pthread_mutex_setprioceiling\
pthread_condattr_getclock   \
pthread_condattr_setclock   \
pthread_spin_lock fork  \
diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h
index 4cd80b0..6616cef 100644
--- a/include/boilerplate/libc.h
+++ b/include/boilerplate/libc.h
@@ -127,6 +127,25 @@ int pthread_mutexattr_getprioceiling(const 
pthread_mutexattr_t *
 }
 #endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */
 
+#ifndef HAVE_PTHREAD_MUTEX_SETPRIOCEILING
+static inline
+int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict attr,
+int prioceiling,
+int *__restrict old_ceiling)
+{
+   return ENOSYS;
+}
+#endif /* !HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING */
+
+#ifndef HAVE_PTHREAD_MUTEX_GETPRIOCEILING
+static inline
+int pthread_mutex_getprioceiling(pthread_mutex_t *__restrict attr,
+int *__restrict prioceiling)
+{
+   return ENOSYS;
+}
+#endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */
+
 #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP
 #include 
 static inline


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


[Xenomai-git] Philippe Gerum : lib/cobalt: add config switch to enable lazy setsched update mode

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 0f535ef298976eb799b19e90ade2aac58c674d9b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0f535ef298976eb799b19e90ade2aac58c674d9b

Author: Philippe Gerum 
Date:   Sun Mar 20 17:58:33 2016 +0100

lib/cobalt: add config switch to enable lazy setsched update mode

--enable-lazy-setsched should be given for enabling lazy propagation
of scheduling parameters upon calls to pthread_setschedparam*(),
sched_setscheduler(). Defaults to off.

---

 configure.ac  |   19 +++
 lib/cobalt/internal.h |   12 
 lib/cobalt/sched.c|2 +-
 lib/cobalt/thread.c   |3 ++-
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 87737e7..36067ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -291,6 +291,25 @@ if test x$workaround_condvar_pi = xy; then
fi
 fi
 
+dnl Lazy schedparam propagation for Cobalt (default: off)
+
+unset lazy_setsched_update
+AC_MSG_CHECKING(whether to enable lazy scheduling parameter update)
+AC_ARG_ENABLE(lazy-setsched,
+   AS_HELP_STRING([--enable-lazy-setsched], [Enable lazy scheduling 
parameter update]),
+   [case "$enableval" in
+   y | yes) lazy_setsched_update=y ;;
+   *) unset lazy_setsched_update ;;
+   esac])
+AC_MSG_RESULT(${lazy_setsched_update:-no})
+if test x$lazy_setsched_update = xy; then
+   if test x$rtcore_type = xcobalt; then
+   AC_DEFINE(CONFIG_XENO_LAZY_SETSCHED,1,[config])
+   else
+AC_MSG_WARN([No lazy scheduling parameter updates over Mercury - 
ignoring])
+   fi
+fi
+
 dnl Enable shared multi-processing (default: off)
 
 use_pshared=
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index 3241e9b..cccbbf1 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -37,6 +37,18 @@ static inline int cobalt_should_warn(void)
return (cobalt_get_current_mode() & (XNRELAX|XNWARN)) == XNWARN;
 }
 
+#ifdef CONFIG_XENO_LAZY_SETSCHED
+static inline int cobalt_eager_setsched(void)
+{
+   return cobalt_is_relaxed();
+}
+#else
+static inline int cobalt_eager_setsched(void)
+{
+   return 1;
+}
+#endif
+
 static inline
 struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow)
 {
diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c
index 87b9235..94f3323 100644
--- a/lib/cobalt/sched.c
+++ b/lib/cobalt/sched.c
@@ -297,7 +297,7 @@ int sched_setscheduler_ex(pid_t pid,
 
/* See pthread_setschedparam_ex(). */
 
-   if (cobalt_is_relaxed()) {
+   if (cobalt_eager_setsched()) {
std_policy = cobalt_xlate_schedparam(policy, param_ex, 
_param);
ret = __STD(sched_setscheduler(pid, std_policy, _param));
if (ret)
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index 8b4568d..908516f 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -629,7 +629,8 @@ int pthread_setschedparam_ex(pthread_t thread,
 * threads should refrain from mixing APIs for managing
 * scheduling parameters, and only rely on libcobalt for this.
 */
-   if (cobalt_is_relaxed()) { /* True if shadow not mapped yet. */
+   if (cobalt_eager_setsched()) {
+   /* True if disabled or shadow not mapped yet. */
std_policy = cobalt_xlate_schedparam(policy, param_ex, 
_param);
ret = __STD(pthread_setschedparam(thread, std_policy, 
_param));
if (ret)


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


[Xenomai-git] Philippe Gerum : boilerplate/libc: add placeholder for pthread_setschedprio()

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 653032b20878b5b3a9a8a5b9cbd0636a3e2218c9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=653032b20878b5b3a9a8a5b9cbd0636a3e2218c9

Author: Philippe Gerum 
Date:   Tue May 24 09:43:29 2016 +0200

boilerplate/libc: add placeholder for pthread_setschedprio()

For outdated uClibc.

---

 configure.ac   |1 +
 include/boilerplate/libc.h |   19 +++
 2 files changed, 20 insertions(+)

diff --git a/configure.ac b/configure.ac
index 36067ad..1ba7f8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -546,6 +546,7 @@ AC_CHECK_FUNCS([pthread_mutexattr_setprotocol   \
pthread_getattr_np  \
pthread_atfork  \
pthread_setname_np  \
+   pthread_setschedprio\
sched_getcpu\
clock_nanosleep \
shm_open\
diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h
index 6616cef..3c9c970 100644
--- a/include/boilerplate/libc.h
+++ b/include/boilerplate/libc.h
@@ -168,6 +168,25 @@ int pthread_setaffinity_np(pthread_t thread, size_t 
cpusetsize,
 
 #endif /* !HAVE_PTHREAD_ATTR_SETAFFINITY_NP */
 
+#ifndef HAVE_PTHREAD_SETSCHEDPRIO
+
+static inline
+int pthread_setschedprio(pthread_t thread, int prio)
+{
+   struct sched_param param;
+   int policy, ret;
+
+   ret = pthread_getschedparam(thread, , );
+   if (ret)
+   return ret;
+
+   param.sched_priority = prio;
+
+   return pthread_setschedparam(thread, policy, );
+}
+
+#endif /* !HAVE_PTHREAD_SETSCHEDPRIO */
+
 #if !defined(HAVE_CLOCK_NANOSLEEP) && defined(CONFIG_XENO_MERCURY)
 /*
  * Best effort for a Mercury setup based on an outdated libc lacking


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


[Xenomai-git] Philippe Gerum : cobalt/arch: fixup READMEs

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 07e8a65b940cb6e66046194ceffd2bec3980bc31
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=07e8a65b940cb6e66046194ceffd2bec3980bc31

Author: Philippe Gerum 
Date:   Mon Nov  2 15:41:31 2015 +0100

cobalt/arch: fixup READMEs

---

 kernel/cobalt/arch/arm64/patches/README |   16 
 1 file changed, 16 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/patches/README 
b/kernel/cobalt/arch/arm64/patches/README
deleted file mode 100644
index fd85e06..000
--- a/kernel/cobalt/arch/arm64/patches/README
+++ /dev/null
@@ -1,16 +0,0 @@
--- arch/arm64/patches
-
-Xenomai needs special kernel support to deliver fast and deterministic
-response time to external interrupts, and also to provide real-time
-services highly integrated with the standard Linux kernel.
-
-This support is provided by the interrupt pipeline (aka I-pipe) in the
-form of a kernel patch you have to apply against a vanilla kernel
-tree, before you attempt to compile the Xenomai codebase against the
-latter kernel.
-
-The Xenomai arm64 port is work in progress. The I-pipe support for
-this architecture is exclusively available from this development tree
-at the moment:
-
-git://git.xenomai.org/ipipe.git, branch devel/ipipe-3.18-linaro-arm64.


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: disable callee-saved logic in fptest helpers

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 8f4357490bef9b311085b4baafbae6e309c54b10
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8f4357490bef9b311085b4baafbae6e309c54b10

Author: Philippe Gerum 
Date:   Thu Oct 22 14:45:05 2015 +0200

cobalt/arm64: disable callee-saved logic in fptest helpers

We don't want GCC to apply any callee-saved logic to fpsimd registers
in fp_regs_set() before fp_regs_check() can verify their contents, but
we still want GCC to know about the registers we have clobbered.

---

 .../arch/arm64/include/asm/xenomai/uapi/fptest.h   |  160 ++--
 testsuite/switchtest/switchtest.c  |   14 +-
 2 files changed, 92 insertions(+), 82 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
index 84607b7..7a2cb92 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
@@ -20,86 +20,86 @@
 
 #define __COBALT_HAVE_FPU  0x1
 
-static inline void fp_regs_set(int features, unsigned int val)
-{
-
-   unsigned long long e[32];
-   unsigned int i;
-
-   if (features & __COBALT_HAVE_FPU) {
-
-   for (i = 0; i < 32; i++)
-   e[i] = val;
-
-   __asm__ __volatile__("ldp d0, d1, [%0, #8 * 0] \n\
-   ldp   d2, d3, [%0, #8 * 
2] \n\
-   ldp d4, d5, [%0, #8 
* 4]\n\
-   ldp d6, d7, [%0, #8 
* 6]\n\
-   ldp d8, d9, [%0, #8 
* 8]\n\
-   ldp d10, d11, [%0, 
#8 * 10]\n\
-   ldp d12, d13, [%0, 
#8 * 12]\n\
-   ldp d14, d15, [%0, 
#8 * 14]\n\
-   ldp d16, d17, [%0, 
#8 * 16]\n\
-   ldp d18, d19, [%0, 
#8 * 18]\n\
-   ldp d20, d21, [%0, 
#8 * 20]\n\
-   ldp d22, d23, [%0, 
#8 * 22]\n\
-   ldp d24, d25, [%0, 
#8 * 24]\n\
-   ldp d26, d27, [%0, 
#8 * 26]\n\
-   ldp d28, d29, [%0, 
#8 * 28]\n\
-   ldp d30, d31, [%0, 
#8 * 30]"
-
-   : /* No outputs. */
-   : "r"([0])
- : "d0", "d1", "d2", "d3", "d4", "d5", "d6", 
"d7", "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15",
-   "d16", "d17", "d18", "d19", "d20", 
"d21", "d22", "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31", 
"memory"
-   );
-   }
-
-}
-
-static inline unsigned int fp_regs_check(int features, unsigned int val,
-int (*report)(const char *fmt, ...))
-{
-   unsigned int result = val;
-
-   unsigned int i;
-   unsigned long long e[32];
-
-   if (features & __COBALT_HAVE_FPU) {
-
-   __asm__ __volatile__("stp d0, d1, [%0, #8 * 0] \n\
-   stp   d2, d3, [%0, #8 * 
2] \n\
-   stp d4, d5, [%0, #8 
* 4]\n\
-   stp d6, d7, [%0, #8 
* 6]\n\
-   stp d8, d9, 
[%0, #8 * 8]\n\
-   stp d10, d11, [%0, 
#8 * 10]\n\
-   stp d12, d13, [%0, 
#8 * 12]\n\
-   stp d14, d15, [%0, 
#8 * 14]\n\
-   stp d16, d17, [%0, 
#8 * 16]\n\
-   stp d18, d19, [%0, 
#8 * 18]\n\
-   stp d20, d21, [%0, 
#8 * 20]\n\
-   stp d22, d23, [%0, 
#8 * 22]\n\
-   stp d24, d25, [%0, 
#8 * 24]\n\
-   stp d26, d27, [%0, 
#8 * 26]\n\
-   stp d28, d29, [%0, 
#8 * 28]\n\
-   stp d30, d31, [%0, 
#8 * 30]"
-
-   :  /* No 

[Xenomai-git] Philippe Gerum : cobalt/sched: detect preemptible switch support in pipeline

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 435c844fec5c05c3c395d1a6a97c50363ce88cdf
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=435c844fec5c05c3c395d1a6a97c50363ce88cdf

Author: Philippe Gerum 
Date:   Sat Nov 14 18:07:15 2015 +0100

cobalt/sched: detect preemptible switch support in pipeline

CONFIG_XENO_ARCH_UNLOCKED_SWITCH is merely an alias for
CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH, which is only meaningful to the
ARM architecture, now that PowerPC dropped such support.

Use the pipeline symbol directly to make the dependency explicit.

---

 include/cobalt/kernel/sched.h |8 
 kernel/cobalt/sched.c |   16 
 kernel/cobalt/thread.c|2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/cobalt/kernel/sched.h b/include/cobalt/kernel/sched.h
index fe1df7d..d5d93c2 100644
--- a/include/cobalt/kernel/sched.h
+++ b/include/cobalt/kernel/sched.h
@@ -93,7 +93,7 @@ struct xnsched {
struct xntimer rrbtimer;
/*!< Root thread control block. */
struct xnthread rootcb;
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
struct xnthread *last;
 #endif
 #ifdef CONFIG_XENO_ARCH_FPU
@@ -329,7 +329,7 @@ static inline int xnsched_primary_p(void)
return !xnsched_unblockable_p();
 }
 
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
 
 struct xnsched *xnsched_finish_unlocked_switch(struct xnsched *sched);
 
@@ -341,7 +341,7 @@ int xnsched_maybe_resched_after_unlocked_switch(struct 
xnsched *sched)
return sched->status & XNRESCHED;
 }
 
-#else /* !CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#else /* !CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH */
 
 static inline struct xnsched *
 xnsched_finish_unlocked_switch(struct xnsched *sched)
@@ -358,7 +358,7 @@ xnsched_maybe_resched_after_unlocked_switch(struct xnsched 
*sched)
return 0;
 }
 
-#endif /* !CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#endif /* !CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH */
 
 #ifdef CONFIG_XENO_OPT_WATCHDOG
 static inline void xnsched_reset_watchdog(struct xnsched *sched)
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index 09960ac..b0d65d3 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -293,7 +293,7 @@ struct xnthread *xnsched_pick_next(struct xnsched *sched)
 #endif /* CONFIG_XENO_OPT_SCHED_CLASSES */
 }
 
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
 
 struct xnsched *xnsched_finish_unlocked_switch(struct xnsched *sched)
 {
@@ -319,7 +319,7 @@ struct xnsched *xnsched_finish_unlocked_switch(struct 
xnsched *sched)
return sched;
 }
 
-#endif /* CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#endif /* CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH */
 
 void xnsched_lock(void)
 {
@@ -494,16 +494,16 @@ void xnsched_migrate(struct xnthread *thread, struct 
xnsched *sched)
xnsched_set_resched(thread->sched);
migrate_thread(thread, sched);
 
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
/*
 * Mark the thread in flight, xnsched_finish_unlocked_switch()
 * will put the thread on the remote runqueue.
 */
xnthread_set_state(thread, XNMIGRATE);
-#else /* !CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#else
/* Move thread to the remote runnable queue. */
xnsched_putback(thread);
-#endif /* !CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#endif
 }
 
 /*
@@ -709,11 +709,11 @@ struct xnthread *xnsched_rt_pick(struct xnsched *sched)
 static inline void switch_context(struct xnsched *sched,
  struct xnthread *prev, struct xnthread *next)
 {
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
sched->last = prev;
sched->status |= XNINSW;
xnlock_clear_irqon();
-#endif /* !CONFIG_XENO_ARCH_UNLOCKED_SWITCH */
+#endif
 
xnarch_switch_to(prev, next);
 }
@@ -788,7 +788,7 @@ static inline void enter_root(struct xnthread *root)
 {
struct xnarchtcb *rootcb __maybe_unused = xnthread_archtcb(root);
 
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
if (rootcb->core.mm == NULL)
set_ti_thread_flag(rootcb->core.tip, TIF_MMSWITCH_INT);
 #endif
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index e0c488e..76dfbce 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -407,7 +407,7 @@ EXPORT_SYMBOL_GPL(xnthread_prepare_wait);
 static inline int moving_target(struct xnsched *sched, struct xnthread *thread)
 {
int ret = 0;
-#ifdef CONFIG_XENO_ARCH_UNLOCKED_SWITCH
+#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
/*
 * When deleting a thread in the course of a context switch or
 * in flight to another CPU with nklock unlocked on a distant


___
Xenomai-git mailing list

[Xenomai-git] Jan Kiszka : cobalt/kernel: Return need_resched flag from xnsynch_release

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d5dcfdcd72a77d8c88bd2825450565c4f07cb7c9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d5dcfdcd72a77d8c88bd2825450565c4f07cb7c9

Author: Jan Kiszka 
Date:   Mon May  9 21:19:04 2016 +0200

cobalt/kernel: Return need_resched flag from xnsynch_release

We currently return the next owner, but no caller of xnsynch_release
evaluates this beyond != NULL and calls xnsched_run in that case.
Simplify the API by returning a need_resched flag directly. This will
also help with fixing the missing reschedule after PP deboost.

Signed-off-by: Jan Kiszka 

---

 include/cobalt/kernel/synch.h |3 +--
 kernel/cobalt/posix/mutex.c   |2 +-
 kernel/cobalt/rtdm/drvlib.c   |2 +-
 kernel/cobalt/synch.c |   23 +++
 4 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h
index 246d2b9..b3a8004 100644
--- a/include/cobalt/kernel/synch.h
+++ b/include/cobalt/kernel/synch.h
@@ -164,8 +164,7 @@ int __must_check xnsynch_acquire(struct xnsynch *synch,
 
 int __must_check xnsynch_try_acquire(struct xnsynch *synch);
 
-struct xnthread *xnsynch_release(struct xnsynch *synch,
-struct xnthread *thread);
+bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread);
 
 struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch);
 
diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c
index c6020ff..f99874b 100644
--- a/kernel/cobalt/posix/mutex.c
+++ b/kernel/cobalt/posix/mutex.c
@@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr,
cobalt_cond_deferred_signals(cond);
}
}
-   need_resched |= xnsynch_release(>synchbase, curr) != NULL;
+   need_resched |= xnsynch_release(>synchbase, curr);
 
return need_resched;
 }
diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index 7abdb1e..4808b93 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex)
trace_cobalt_driver_mutex_release(mutex);
 
if (unlikely(xnsynch_release(>synch_base,
-xnsched_current_thread()) != NULL))
+xnsched_current_thread(
xnsched_run();
 }
 EXPORT_SYMBOL_GPL(rtdm_mutex_unlock);
diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c
index 976261d..d8b83d9 100644
--- a/kernel/cobalt/synch.c
+++ b/kernel/cobalt/synch.c
@@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch,
drop_booster(synch, owner);
 }
 
-static struct xnthread *transfer_ownership(struct xnsynch *synch,
-  struct xnthread *lastowner)
+static bool transfer_ownership(struct xnsynch *synch,
+  struct xnthread *lastowner)
 {  /* nklock held, irqs off */
struct xnthread *nextowner;
xnhandle_t nextownerh;
@@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch 
*synch,
if (list_empty(>pendq)) {
synch->owner = NULL;
atomic_set(lockp, XN_NO_HANDLE);
-   return NULL;
+   return false;
}
 
nextowner = list_first_entry(>pendq, struct xnthread, plink);
@@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch 
*synch,
 
atomic_set(lockp, nextownerh);
 
-   return nextowner;
+   return true;
 }
 
 /**
- * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread 
*curr)
+ * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr)
  * @brief Release a resource and pass it to the next waiting thread.
  *
  * This service releases the ownership of the given synchronization
@@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch 
*synch,
  * @param curr The descriptor address of the current thread, which
  * must own the object at the time of calling.
  *
- * @return The descriptor address of the unblocked thread.
+ * @return True if a reschedule is required.
  *
  * @sideeffect
  *
@@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch 
*synch,
  *
  * @coretags{primary-only, might-switch}
  */
-struct xnthread *xnsynch_release(struct xnsynch *synch,
-struct xnthread *curr)
+bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr)
 {
-   struct xnthread *nextowner = NULL;
+   bool need_resched = false;
xnhandle_t currh, h;
atomic_t *lockp;
spl_t s;
@@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch,
trace_cobalt_synch_release(synch);
 
if (xnthread_put_resource(curr))
-   return NULL;
+

[Xenomai-git] Philippe Gerum : cobalt/arm64: use lazy fpsimd switch mode

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d93c139ded9d2abe4a40028d2f47440b8ab0513e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d93c139ded9d2abe4a40028d2f47440b8ab0513e

Author: Philippe Gerum 
Date:   Mon Oct 19 10:38:21 2015 +0200

cobalt/arm64: use lazy fpsimd switch mode

---

 kernel/cobalt/arch/arm64/thread.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index 5282b0c..2238751 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -153,7 +153,7 @@ void xnarch_switch_to(struct xnthread *out, struct xnthread 
*in)
enter_lazy_tlb(prev_mm, next);
}
 
-   __switch_to(prev, next);
+   ipipe_switch_to(prev, next);
 }
 
 int xnarch_escalate(void)


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: fix inclusion guards

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 3dbdd4da43ad954f494c91066ed5f78b37a6b216
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3dbdd4da43ad954f494c91066ed5f78b37a6b216

Author: Philippe Gerum 
Date:   Sat Oct 17 14:40:53 2015 +0200

cobalt/arm64: fix inclusion guards

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/features.h  |8 
 kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h|6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h   |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h   |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/syscall32.h |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h|7 +++
 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/arith.h|6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h   |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/syscall.h  |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/tsc.h  |6 +++---
 kernel/cobalt/arch/arm64/include/asm/xenomai/wrappers.h  |6 +++---
 12 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/features.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/features.h
index d485286..112408f 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/features.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/features.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Philippe Gerum .
+ * Copyright (C) 2015 Philippe Gerum .
  *
  * ARM port
  *   Copyright (C) 2005 Stelian Pop
@@ -19,12 +19,12 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-#ifndef _COBALT_ARM_ASM_FEATURES_H
-#define _COBALT_ARM_ASM_FEATURES_H
+#ifndef _COBALT_ARM64_ASM_FEATURES_H
+#define _COBALT_ARM64_ASM_FEATURES_H
 
 struct cobalt_featinfo;
 static inline void collect_arch_features(struct cobalt_featinfo *p) { }
 
 #include 
 
-#endif /* !_COBALT_ARM_ASM_FEATURES_H */
+#endif /* !_COBALT_ARM64_ASM_FEATURES_H */
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
index 743d758..cfdf0b3 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/fptest.h
@@ -16,8 +16,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-#ifndef _COBALT_ARM_ASM_FPTEST_H
-#define _COBALT_ARM_ASM_FPTEST_H
+#ifndef _COBALT_ARM64_ASM_FPTEST_H
+#define _COBALT_ARM64_ASM_FPTEST_H
 
 #include 
 #include 
@@ -44,4 +44,4 @@ static inline int fp_detect(void)
return have_fp ? __COBALT_HAVE_FPU : 0;
 }
 
-#endif /* _COBALT_ARM_ASM_FPTEST_H */
+#endif /* _COBALT_ARM64_ASM_FPTEST_H */
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
index b8290bf..7444cc8 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
@@ -20,8 +20,8 @@
  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  *   02111-1307, USA.
  */
-#ifndef _COBALT_ARM_ASM_MACHINE_H
-#define _COBALT_ARM_ASM_MACHINE_H
+#ifndef _COBALT_ARM64_ASM_MACHINE_H
+#define _COBALT_ARM64_ASM_MACHINE_H
 
 #include 
 #include 
@@ -58,4 +58,4 @@ static inline __attribute_const__ unsigned long ffnz(unsigned 
long ul)
 
 #include 
 
-#endif /* !_COBALT_ARM_ASM_MACHINE_H */
+#endif /* !_COBALT_ARM64_ASM_MACHINE_H */
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index 77c1716..949f287 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -19,8 +19,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-#ifndef _COBALT_ARM_ASM_SYSCALL_H
-#define _COBALT_ARM_ASM_SYSCALL_H
+#ifndef _COBALT_ARM64_ASM_SYSCALL_H
+#define _COBALT_ARM64_ASM_SYSCALL_H
 
 #include 
 #include 
@@ -75,4 +75,4 @@ int xnarch_local_syscall(unsigned long a1, unsigned long a2,
 unsigned long a3, unsigned long a4,
 unsigned long a5);
 
-#endif /* !_COBALT_ARM_ASM_SYSCALL_H */
+#endif /* !_COBALT_ARM64_ASM_SYSCALL_H */
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall32.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall32.h
index 95c5a11..a66ddd6 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall32.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall32.h
@@ -16,9 +16,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-#ifndef _COBALT_ARM_ASM_SYSCALL32_H
-#define _COBALT_ARM_ASM_SYSCALL32_H
+#ifndef 

[Xenomai-git] Philippe Gerum : cobalt/powerpc: drop obsolete config knob

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 6ad9a06ea72be593cc2c00f144713645b4a51640
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6ad9a06ea72be593cc2c00f144713645b4a51640

Author: Philippe Gerum 
Date:   Sat Nov 14 18:14:53 2015 +0100

cobalt/powerpc: drop obsolete config knob

As of fbe1164, CONFIG_XENO_ARCH_UNLOCKED_SWITCH is not tested anymore
in the code base.

---

 kernel/cobalt/arch/powerpc/Kconfig |3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/cobalt/arch/powerpc/Kconfig 
b/kernel/cobalt/arch/powerpc/Kconfig
index 1cabef3..2069288 100644
--- a/kernel/cobalt/arch/powerpc/Kconfig
+++ b/kernel/cobalt/arch/powerpc/Kconfig
@@ -10,6 +10,3 @@ config XENO_ARCH_FPU
 
 config XENO_ARCH_SYS3264
 def_bool n
-
-config XENO_ARCH_UNLOCKED_SWITCH
-   def_bool n


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: FPU code cleanup

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 12191a1f540e2fec5ba4219755836d5fdae8772c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=12191a1f540e2fec5ba4219755836d5fdae8772c

Author: Dmitriy Cherkasov 
Date:   Fri Oct  2 12:54:37 2015 -0700

cobalt/arm64: FPU code cleanup

---

 kernel/cobalt/arch/arm64/thread.c |   89 -
 1 file changed, 39 insertions(+), 50 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index db369be..35dbd72 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -36,31 +36,44 @@
 
 #if defined(CONFIG_XENO_ARCH_FPU)
 
-static void enable_fpsimd(void) {
-   __asm__ __volatile__("mrs x1, cpacr_el1\n\
-   orr x1, x1, #(0x3 << 20)\n\
-   msr cpacr_el1, x1\n\
-   isb" : : : "x1", "memory", "cc");
+#define FPSIMD_EN (0x3 << 20)
+
+static inline unsigned long get_cpacr(void)
+{
+   unsigned long result;
+   __asm__ __volatile__("mrs %0, cpacr_el1": "=r"(result));
+   return result;
+}
+
+static inline void set_cpacr(long val)
+{
+   __asm__ __volatile__ (
+   "msr cpacr_el1, %0\n\t"
+   "isb"
+   : /* */ : "r"(val));
 }
 
-static void disable_fpsimd(void) {
-   __asm__ __volatile__("mrs x1, cpacr_el1\n\
-   and x1, x1, #~(0x3 << 20)\n\
-   msr cpacr_el1, x1\n\
-   isb" : : : "x1", "memory", "cc");
+static void enable_fpsimd(void)
+{
+   unsigned long cpacr = get_cpacr();
+   cpacr |= FPSIMD_EN;
+   set_cpacr(cpacr);
+}
+
+static void disable_fpsimd(void)
+{
+   unsigned long cpacr = get_cpacr();
+   cpacr &= ~FPSIMD_EN;
+   set_cpacr(cpacr);
 }
 
 int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
 {
-   /* check if this is an FPU access trap to be handled by Xenomai */
-   if(d->exception == IPIPE_TRAP_FPU_ACC){
-   return 1;
-   }
-   /* FPU already enabled, propagate fault to kernel */
-   return 0;
+   return (d->exception == IPIPE_TRAP_FPU_ACC);
 }
 
-static inline struct fpsimd_state *get_fpu_owner(struct xnarchtcb *tcb) {
+static inline struct fpsimd_state *get_fpu_owner(struct xnarchtcb *tcb)
+{
return &(tcb->core.tsp->fpsimd_state);
 }
 
@@ -68,7 +81,6 @@ void xnarch_leave_root(struct xnthread *root)
 {
struct xnarchtcb *rootcb = xnthread_archtcb(root);
rootcb->fpup = get_fpu_owner(rootcb);
-   disable_fpsimd();
 }
 
 void xnarch_save_fpu(struct xnthread *thread)
@@ -83,29 +95,15 @@ void xnarch_switch_fpu(struct xnthread *from, struct 
xnthread *to)
struct fpsimd_state *const from_fpup = from ? from->tcb.fpup : NULL;
struct fpsimd_state *const to_fpup = to->tcb.fpup;
 
-   /*
-* This only gets called if XNFPU flag is set, or if migrating to Linux.
-* In both cases, this means turn on FPU and switch.
-*/
enable_fpsimd();
 
-   if (xnthread_test_state(to, XNROOT) == 0) {
-   if (from_fpup == to_fpup)
-   return;
-
-   if (from_fpup)
-   fpsimd_save_state(from_fpup);
-
-   fpsimd_load_state(to_fpup);
-   }
-   else {
-   /* Going to Linux. */
-   if (from_fpup)
-   fpsimd_save_state(from_fpup);
+   if (from_fpup == to_fpup)
+   return;
 
-   fpsimd_load_state(to_fpup);
-   }
+   if (from_fpup)
+   fpsimd_save_state(from_fpup);
 
+   fpsimd_load_state(to_fpup);
 }
 
 int xnarch_handle_fpu_fault(struct xnthread *from, 
@@ -113,9 +111,9 @@ int xnarch_handle_fpu_fault(struct xnthread *from,
 {
spl_t s;
 
+   /* FPU should already be enabled for XNFPU tasks. */
if (xnthread_test_state(to, XNFPU))
-   /* FPU is already enabled, probably an exception */
-  return 0;
+   BUG();
 
xnlock_get_irqsave(, s);
xnthread_set_state(to, XNFPU);
@@ -124,20 +122,13 @@ int xnarch_handle_fpu_fault(struct xnthread *from,
xnarch_switch_fpu(from, to);
 
return 1;
-
 }
 
 void xnarch_init_shadow_tcb(struct xnthread *thread)
 {
-   spl_t s;
struct xnarchtcb *tcb = xnthread_archtcb(thread);
-
tcb->fpup = &(tcb->core.host_task->thread.fpsimd_state);
-
-   xnlock_get_irqsave(, s);
xnthread_clear_state(thread, XNFPU);
-   xnlock_put_irqrestore(, s);
-
 }
 #endif /* CONFIG_XENO_ARCH_FPU */
 
@@ -210,16 +201,14 @@ void xnarch_switch_to(struct xnthread *out, struct 
xnthread *in)
xnarch_tls_thread_switch(in_tcb->core.tip->task);
xnarch_contextidr_thread_switch(in_tcb->core.tip->task);
 
-   /* check if we need to switch FPU on return to Linux */
-   if (xnthread_test_state(in, XNROOT) == 1)
-   

[Xenomai-git] Philippe Gerum : cobalt/arm64: add README for I-pipe support

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 13cc2757d57524dd19901c17e930f45293b552ff
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=13cc2757d57524dd19901c17e930f45293b552ff

Author: Philippe Gerum 
Date:   Sun Nov  1 17:22:33 2015 +0100

cobalt/arm64: add README for I-pipe support

---

 kernel/cobalt/arch/arm64/patches/README |   16 
 1 file changed, 16 insertions(+)

diff --git a/kernel/cobalt/arch/arm64/patches/README 
b/kernel/cobalt/arch/arm64/patches/README
new file mode 100644
index 000..fd85e06
--- /dev/null
+++ b/kernel/cobalt/arch/arm64/patches/README
@@ -0,0 +1,16 @@
+-- arch/arm64/patches
+
+Xenomai needs special kernel support to deliver fast and deterministic
+response time to external interrupts, and also to provide real-time
+services highly integrated with the standard Linux kernel.
+
+This support is provided by the interrupt pipeline (aka I-pipe) in the
+form of a kernel patch you have to apply against a vanilla kernel
+tree, before you attempt to compile the Xenomai codebase against the
+latter kernel.
+
+The Xenomai arm64 port is work in progress. The I-pipe support for
+this architecture is exclusively available from this development tree
+at the moment:
+
+git://git.xenomai.org/ipipe.git, branch devel/ipipe-3.18-linaro-arm64.


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: add lazy FPU switching

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c90bfe8bb4dea675c1758e9675d731b3920a4d02
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c90bfe8bb4dea675c1758e9675d731b3920a4d02

Author: Dmitriy Cherkasov 
Date:   Thu Oct  1 15:47:41 2015 -0700

cobalt/arm64: add lazy FPU switching

---

 kernel/cobalt/arch/arm64/thread.c |   83 +++--
 1 file changed, 62 insertions(+), 21 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index 316525f6..db369be 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -32,16 +32,31 @@
 #include 
 #include 
 #include 
-
+#include 
 
 #if defined(CONFIG_XENO_ARCH_FPU)
 
-static DEFINE_MUTEX(vfp_check_lock);
+static void enable_fpsimd(void) {
+   __asm__ __volatile__("mrs x1, cpacr_el1\n\
+   orr x1, x1, #(0x3 << 20)\n\
+   msr cpacr_el1, x1\n\
+   isb" : : : "x1", "memory", "cc");
+}
 
+static void disable_fpsimd(void) {
+   __asm__ __volatile__("mrs x1, cpacr_el1\n\
+   and x1, x1, #~(0x3 << 20)\n\
+   msr cpacr_el1, x1\n\
+   isb" : : : "x1", "memory", "cc");
+}
 
 int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
 {
-   /* FPU never trapped, this will be a fault */
+   /* check if this is an FPU access trap to be handled by Xenomai */
+   if(d->exception == IPIPE_TRAP_FPU_ACC){
+   return 1;
+   }
+   /* FPU already enabled, propagate fault to kernel */
return 0;
 }
 
@@ -53,6 +68,7 @@ void xnarch_leave_root(struct xnthread *root)
 {
struct xnarchtcb *rootcb = xnthread_archtcb(root);
rootcb->fpup = get_fpu_owner(rootcb);
+   disable_fpsimd();
 }
 
 void xnarch_save_fpu(struct xnthread *thread)
@@ -65,45 +81,67 @@ void xnarch_save_fpu(struct xnthread *thread)
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to)
 {
struct fpsimd_state *const from_fpup = from ? from->tcb.fpup : NULL;
-
-   /* always switch, no lazy switching */
-
struct fpsimd_state *const to_fpup = to->tcb.fpup;
 
-   if (from_fpup == to_fpup)
-   return;
+   /*
+* This only gets called if XNFPU flag is set, or if migrating to Linux.
+* In both cases, this means turn on FPU and switch.
+*/
+   enable_fpsimd();
+
+   if (xnthread_test_state(to, XNROOT) == 0) {
+   if (from_fpup == to_fpup)
+   return;
 
-   if (from_fpup)
-   fpsimd_save_state(from_fpup);
+   if (from_fpup)
+   fpsimd_save_state(from_fpup);
 
-   fpsimd_load_state(to_fpup);
+   fpsimd_load_state(to_fpup);
+   }
+   else {
+   /* Going to Linux. */
+   if (from_fpup)
+   fpsimd_save_state(from_fpup);
 
-   /* always set FPU enabled */
-   xnthread_set_state(to, XNFPU);
+   fpsimd_load_state(to_fpup);
+   }
 
 }
 
 int xnarch_handle_fpu_fault(struct xnthread *from, 
struct xnthread *to, struct ipipe_trap_data *d)
 {
-   /* FPU always enabled, faults force exit to Linux */
-   return 0;
+   spl_t s;
+
+   if (xnthread_test_state(to, XNFPU))
+   /* FPU is already enabled, probably an exception */
+  return 0;
+
+   xnlock_get_irqsave(, s);
+   xnthread_set_state(to, XNFPU);
+   xnlock_put_irqrestore(, s);
+
+   xnarch_switch_fpu(from, to);
+
+   return 1;
+
 }
 
 void xnarch_init_shadow_tcb(struct xnthread *thread)
 {
+   spl_t s;
struct xnarchtcb *tcb = xnthread_archtcb(thread);
 
tcb->fpup = &(tcb->core.host_task->thread.fpsimd_state);
 
-   /* XNFPU is always set, no lazy switching */
-   xnthread_set_state(thread, XNFPU);
+   xnlock_get_irqsave(, s);
+   xnthread_clear_state(thread, XNFPU);
+   xnlock_put_irqrestore(, s);
+
 }
 #endif /* CONFIG_XENO_ARCH_FPU */
 
-
 /* Switch support functions */
-
 static void xnarch_tls_thread_switch(struct task_struct *next)
 {
unsigned long tpidr, tpidrro;
@@ -141,8 +179,7 @@ static inline void xnarch_contextidr_thread_switch(struct 
task_struct *next)
 {
 }
 #endif
-
-/*/Switch support functions */
+/* End switch support functions */
 
 void xnarch_switch_to(struct xnthread *out, struct xnthread *in)
 {
@@ -173,6 +210,10 @@ void xnarch_switch_to(struct xnthread *out, struct 
xnthread *in)
xnarch_tls_thread_switch(in_tcb->core.tip->task);
xnarch_contextidr_thread_switch(in_tcb->core.tip->task);
 
+   /* check if we need to switch FPU on return to Linux */
+   if (xnthread_test_state(in, XNROOT) == 1)
+   xnarch_switch_fpu(out, in);
+
/*
 * Complete any pending TLB or cache maintenance on this CPU in case
 * the thread 

[Xenomai-git] Gilles Chanteperdrix : cobalt/arm64: attempt at fixing fpu switch

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: e3da159beec50736863c3270b65b01a4392a599b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e3da159beec50736863c3270b65b01a4392a599b

Author: Gilles Chanteperdrix 
Date:   Fri Oct 30 17:14:00 2015 +0100

cobalt/arm64: attempt at fixing fpu switch

Return to eager switching, since user-space applications use FPU
registers even when not using the FPU, but use an auxiliary backup area
when the "TIF_FOREIGN_FPSTATE" bit is set, in order to avoid clobbering
the saved FPU state.

---

 .../cobalt/arch/arm64/include/asm/xenomai/thread.h |   14 +++--
 kernel/cobalt/arch/arm64/thread.c  |   54 +---
 2 files changed, 25 insertions(+), 43 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index 9055e58..4b247ac 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -24,6 +24,7 @@
 struct xnarchtcb {
struct xntcb core;
 #ifdef CONFIG_XENO_ARCH_FPU
+   struct fpsimd_state xnfpsimd_state;
struct fpsimd_state *fpup;
 #define xnarch_fpu_ptr(tcb) ((tcb)->fpup)
 #endif
@@ -67,7 +68,10 @@ static inline void xnarch_init_root_tcb(struct xnthread 
*thread)
 
 void xnarch_init_shadow_tcb(struct xnthread *thread);
 
-int xnarch_fault_fpu_p(struct ipipe_trap_data *d);
+static inline int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
+{
+   return xnarch_fault_trap(d) == IPIPE_TRAP_FPU_ACC;
+}
 
 void xnarch_leave_root(struct xnthread *root);
 
@@ -75,8 +79,12 @@ void xnarch_save_fpu(struct xnthread *thread);
 
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *thread);
 
-int xnarch_handle_fpu_fault(struct xnthread *from, 
-   struct xnthread *to, struct ipipe_trap_data *d);
+static inline int
+xnarch_handle_fpu_fault(struct xnthread *from,
+   struct xnthread *to, struct ipipe_trap_data *d)
+{
+   return 0;
+}
 
 #else /* !CONFIG_XENO_ARCH_FPU */
 
diff --git a/kernel/cobalt/arch/arm64/thread.c 
b/kernel/cobalt/arch/arm64/thread.c
index 2238751..b987e09 100644
--- a/kernel/cobalt/arch/arm64/thread.c
+++ b/kernel/cobalt/arch/arm64/thread.c
@@ -6,6 +6,7 @@
  * 
  * ARM64 port
  *   Copyright (C) 2015 Dmitriy Cherkasov 
+ *   Copyright (C) 2015 Gilles Chanteperdrix 
  *
  * Xenomai is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by
@@ -41,7 +42,7 @@
 static inline unsigned long get_cpacr(void)
 {
unsigned long result;
-   __asm__ __volatile__("mrs %0, cpacr_el1": "=r"(result));
+   __asm__ ("mrs %0, cpacr_el1": "=r"(result));
return result;
 }
 
@@ -53,21 +54,20 @@ static inline void set_cpacr(long val)
: /* */ : "r"(val));
 }
 
-static void enable_fpsimd(void)
+static inline void enable_fpsimd(void)
 {
-   unsigned long cpacr = get_cpacr();
-   cpacr |= FPSIMD_EN;
-   set_cpacr(cpacr);
+   set_cpacr(get_cpacr() | FPSIMD_EN);
 }
 
-int xnarch_fault_fpu_p(struct ipipe_trap_data *d)
+static inline struct fpsimd_state *get_fpu_owner(struct xnarchtcb *rootcb)
 {
-   return (d->exception == IPIPE_TRAP_FPU_ACC);
-}
+   struct task_struct *curr = rootcb->core.host_task;
 
-static inline struct fpsimd_state *get_fpu_owner(struct xnarchtcb *tcb)
-{
-   return &(tcb->core.tsp->fpsimd_state);
+   if (test_ti_thread_flag(task_thread_info(curr), TIF_FOREIGN_FPSTATE))
+   /* Foreign fpu state, use auxiliary backup area */
+   return >xnfpsimd_state;
+
+   return >thread.fpsimd_state;
 }
 
 void xnarch_leave_root(struct xnthread *root)
@@ -76,13 +76,6 @@ void xnarch_leave_root(struct xnthread *root)
rootcb->fpup = get_fpu_owner(rootcb);
 }
 
-void xnarch_save_fpu(struct xnthread *thread)
-{
-   struct xnarchtcb *tcb = &(thread->tcb);
-   if (xnarch_fpu_ptr(tcb))
-   fpsimd_save_state(tcb->fpup);
-}
-
 void xnarch_switch_fpu(struct xnthread *from, struct xnthread *to)
 {
struct fpsimd_state *const from_fpup = from ? from->tcb.fpup : NULL;
@@ -93,35 +86,16 @@ void xnarch_switch_fpu(struct xnthread *from, struct 
xnthread *to)
if (from_fpup == to_fpup)
return;
 
-   if (from_fpup)
-   fpsimd_save_state(from_fpup);
+   fpsimd_save_state(from_fpup);
 
fpsimd_load_state(to_fpup);
-}
-
-int xnarch_handle_fpu_fault(struct xnthread *from, 
-   struct xnthread *to, struct ipipe_trap_data *d)
-{
-   spl_t s;
-
-   /* FPU should already be enabled for XNFPU tasks. */
-   if (xnthread_test_state(to, XNFPU))
-   BUG();
-
-   xnlock_get_irqsave(, s);
-   xnthread_set_state(to, XNFPU);
-   xnlock_put_irqrestore(, s);
-
-   xnarch_switch_fpu(from, 

[Xenomai-git] Philippe Gerum : cobalt/arm64: drop useless test on target architecture

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 2c0054730f0320c897ae87e8c7c9343beabd9bc2
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2c0054730f0320c897ae87e8c7c9343beabd9bc2

Author: Philippe Gerum 
Date:   Sat Oct 17 14:43:25 2015 +0200

cobalt/arm64: drop useless test on target architecture

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
index ea1b06e..74423f6 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
@@ -28,10 +28,9 @@
 
 #define XENOMAI_FEAT_MAN (__xn_feat_generic_man_mask)
 
-#ifndef __aarch64__
-#define XNARCH_HAVE_LLMULSHFT1
-#define XNARCH_HAVE_NODIV_LLIMD  1
-#endif
+#undef XNARCH_HAVE_LLMULSHFT
+
+#undef XNARCH_HAVE_NODIV_LLIMD
 
 struct cobalt_featinfo_archdep { /* no arch-specific feature */ };
 


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


[Xenomai-git] Philippe Gerum : cobalt/powerpc: track current mm unconditionally

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: c145e205613d8ec1d94697d8ea84e8a5006400c5
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c145e205613d8ec1d94697d8ea84e8a5006400c5

Author: Philippe Gerum 
Date:   Sat Nov 14 15:21:02 2015 +0100

cobalt/powerpc: track current mm unconditionally

All pipelines Cobalt can work with (i.e. 3.10+) for the powerpc
architecture do provide the mm tracking feature unconditionally, so
there is no point in keeping any build switch for it.

---

 kernel/cobalt/arch/powerpc/Kconfig |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/arch/powerpc/Kconfig 
b/kernel/cobalt/arch/powerpc/Kconfig
index 4d5e6db..40eae0b 100644
--- a/kernel/cobalt/arch/powerpc/Kconfig
+++ b/kernel/cobalt/arch/powerpc/Kconfig
@@ -1,12 +1,12 @@
 source "kernel/xenomai/Kconfig"
 source "drivers/xenomai/Kconfig"
 
-config IPIPE_WANT_ACTIVE_MM
+config XENO_ARCH_MATH_EMU
 bool
+   default y if MATH_EMU || MATH_EMULATION
 
 config IPIPE_WANT_PREEMPTIBLE_SWITCH
 bool
-   select IPIPE_WANT_ACTIVE_MM
default y if XENO_ARCH_UNLOCKED_SWITCH
default n if !XENO_ARCH_UNLOCKED_SWITCH
 


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: machine.h: use slightly faster ffnz implementation

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 6a621258a97e30d39e97e4ba94688db71e455484
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6a621258a97e30d39e97e4ba94688db71e455484

Author: Dmitriy Cherkasov 
Date:   Wed Jun 17 16:09:20 2015 -0700

cobalt/arm64: machine.h: use slightly faster ffnz implementation

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
index 417a7b0..b8290bf 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
@@ -37,13 +37,23 @@
 #include 
 #include 
 #include 
+#include 
 
 /* D-side always behaves as PIPT on AArch64 (see 
arch/arm64/include/asm/cachetype.h) */
 #define xnarch_cache_aliasing() 0
 
 static inline __attribute_const__ unsigned long ffnz(unsigned long ul)
 {
-   return __builtin_ffsl(ul) - 1;
+   int __r;
+
+   /* zero input is not valid */
+   XENO_WARN_ON(COBALT, ul == 0);
+
+   __asm__ ("rbit\t%0, %1\n"
+"clz\t%0, %0\n"
+   : "=r" (__r) : "r"(ul) : "cc");
+
+   return __r;
 }
 
 #include 


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


[Xenomai-git] Philippe Gerum : cobalt/arm64: leave mm tracking to the pipeline

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7a6125b386afd0fbe5a6dd97ee2fc4556eed7f30
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7a6125b386afd0fbe5a6dd97ee2fc4556eed7f30

Author: Philippe Gerum 
Date:   Thu Sep 17 15:08:34 2015 +0200

cobalt/arm64: leave mm tracking to the pipeline

---

 kernel/cobalt/arch/arm64/Kconfig |3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/Kconfig b/kernel/cobalt/arch/arm64/Kconfig
index 927c647..dd5a8c6 100644
--- a/kernel/cobalt/arch/arm64/Kconfig
+++ b/kernel/cobalt/arch/arm64/Kconfig
@@ -4,9 +4,6 @@ source "drivers/xenomai/Kconfig"
 config XENO_ARCH_UNLOCKED_SWITCH
def_bool IPIPE_WANT_PREEMPTIBLE_SWITCH
 
-config IPIPE_WANT_ACTIVE_MM
-   def_bool y
-
 config XENO_ARCH_WANT_TIP
def_bool y
 


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


[Xenomai-git] Philippe Gerum : testsuite/smokey: add basic FPU stress test

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: e249c2c8349dbcba15d51645e9da751f6efca74f
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e249c2c8349dbcba15d51645e9da751f6efca74f

Author: Philippe Gerum 
Date:   Sat Oct 24 15:52:48 2015 +0200

testsuite/smokey: add basic FPU stress test

---

 configure.ac |6 +-
 testsuite/smokey/Makefile.am |1 +
 testsuite/smokey/fpu-stress/Makefile.am  |8 +++
 testsuite/smokey/fpu-stress/fpu-stress.c |   95 ++
 4 files changed, 105 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2170d0e..1432ef2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -918,11 +918,7 @@ AC_CONFIG_FILES([ \
testsuite/smokey/timerfd/Makefile \
testsuite/smokey/tsc/Makefile \
testsuite/smokey/leaks/Makefile \
-   testsuite/smokey/net_udp/Makefile \
-   testsuite/smokey/net_packet_dgram/Makefile \
-   testsuite/smokey/net_packet_raw/Makefile \
-   testsuite/smokey/net_common/Makefile \
-   testsuite/smokey/cpu-affinity/Makefile \
+   testsuite/smokey/fpu-stress/Makefile \
testsuite/clocktest/Makefile \
testsuite/xeno-test/Makefile \
utils/Makefile \
diff --git a/testsuite/smokey/Makefile.am b/testsuite/smokey/Makefile.am
index 5a82018..ae60a44 100644
--- a/testsuite/smokey/Makefile.am
+++ b/testsuite/smokey/Makefile.am
@@ -9,6 +9,7 @@ COBALT_SUBDIRS =\
arith   \
bufp\
cpu-affinity\
+   fpu-stress  \
iddp\
leaks   \
net_packet_dgram\
diff --git a/testsuite/smokey/fpu-stress/Makefile.am 
b/testsuite/smokey/fpu-stress/Makefile.am
new file mode 100644
index 000..c90d0dd
--- /dev/null
+++ b/testsuite/smokey/fpu-stress/Makefile.am
@@ -0,0 +1,8 @@
+
+noinst_LIBRARIES = libfpu-stress.a
+
+libfpu_stress_a_SOURCES = fpu-stress.c
+
+libfpu_stress_a_CPPFLAGS = \
+   @XENO_USER_CFLAGS@  \
+   -I$(top_srcdir)/include
diff --git a/testsuite/smokey/fpu-stress/fpu-stress.c 
b/testsuite/smokey/fpu-stress/fpu-stress.c
new file mode 100644
index 000..59383c9
--- /dev/null
+++ b/testsuite/smokey/fpu-stress/fpu-stress.c
@@ -0,0 +1,95 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+
+smokey_test_plugin(fpu_stress,
+  SMOKEY_ARGLIST(
+  SMOKEY_INT(duration),
+  ),
+  "Check FPU context sanity during real-time stress\n"
+  "\tduration=\thow long to run the stress loop 
(0=indefinitely)"
+);
+
+static int fp_features;
+
+static void *stress_loop(void *arg)
+{
+   struct timespec rqt = {
+   .tv_sec = 0,
+   .tv_nsec = CONFIG_XENO_DEFAULT_PERIOD
+   };
+   
+   for (;;) {
+   fp_regs_set(fp_features, 0xf1f5f1f5);
+   clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL);
+   }
+
+   return NULL;
+}
+
+static int report_error(const char *fmt, ...)
+{
+   va_list ap;
+
+   va_start(ap, fmt);
+   smokey_vatrace(fmt, ap);
+   va_end(ap);
+
+   return 0;
+}
+
+static int run_fpu_stress(struct smokey_test *t,
+ int argc, char *const argv[])
+{
+   unsigned sleep_ms, n, rounds, duration = 3;
+   struct sched_param param;
+   pthread_attr_t attr;
+   struct timespec rqt;
+   pthread_t tid;
+   int ret;
+
+   fp_features = cobalt_fp_detect();
+   if (fp_features == 0)
+   return -ENOSYS;
+
+   smokey_parse_args(t, argc, argv);
+   
+   if (SMOKEY_ARG_ISSET(fpu_stress, duration))
+   duration = SMOKEY_ARG_INT(fpu_stress, duration);
+   
+   rqt.tv_sec = 0;
+   rqt.tv_nsec = CONFIG_XENO_DEFAULT_PERIOD;
+   sleep_ms = 100UL / rqt.tv_nsec; /* wake up each ms */
+   rounds = duration * 1000UL / sleep_ms;
+
+   pthread_attr_init();
+   pthread_attr_setdetachstate(, PTHREAD_CREATE_JOINABLE);
+   pthread_attr_setinheritsched(, PTHREAD_EXPLICIT_SCHED);
+   pthread_attr_setschedpolicy(, SCHED_FIFO);
+   param.sched_priority = 10;
+   pthread_attr_setschedparam(, );
+   ret = pthread_create(, , stress_loop, NULL);
+   if (ret)
+   return -ret;
+
+   if (rounds)
+   smokey_trace("running for %d seconds", duration);
+   else
+   smokey_trace("running indefinitely...");
+
+   for (n = 0; rounds == 0 || n < rounds; n++) {
+   fp_regs_set(fp_features, n);
+   __STD(clock_nanosleep(CLOCK_MONOTONIC, 0, , NULL));
+   if (fp_regs_check(fp_features, n, report_error) != n) {
+   ret = -EINVAL;
+   break;
+   }
+   }
+
+   pthread_cancel(tid);
+   pthread_join(tid, NULL);
+
+   return ret;
+}


___
Xenomai-git 

[Xenomai-git] Don Mahurin : cobalt/arm64: Use empty mayday implementation for arm64.

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 784a730458be93785cbc55832d13be4392f86c71
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=784a730458be93785cbc55832d13be4392f86c71

Author: Don Mahurin 
Date:   Mon Sep 14 12:52:27 2015 -0700

cobalt/arm64: Use empty mayday implementation for arm64.

The arm mayday implementation was not correct for arm64. Replace with empty 
implementation.
Handle mayday in the linux domain, using xnthread_relax. This change is 
essentially the same as the general change proposed in the 'Mayday issues 
again' discussion (Jan Kiszka, Jun 21), though only applied to arch/arm64.

---

 kernel/cobalt/arch/arm64/mayday.c |   86 +
 1 file changed, 1 insertion(+), 85 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/mayday.c 
b/kernel/cobalt/arch/arm64/mayday.c
index bc51ad6..ca1151c 100644
--- a/kernel/cobalt/arch/arm64/mayday.c
+++ b/kernel/cobalt/arch/arm64/mayday.c
@@ -28,72 +28,6 @@ static void *mayday;
 
 static inline void setup_mayday(void *page)
 {
-   /*
-* We want this code to appear at the top of the MAYDAY page:
-*
-* ifdef ARM_EABI
-*
-* e59f000c ldr r0, [pc, #12]
-* e59f700c ldr r7, [pc, #12]
-* ef00 svc 0x
-* e3a0 mov r0, #0
-* e580 str r0, [r0]; 
-* 105e .word   0x105e  ; sc_cobalt_mayday | 
__COBALT_SYSCALL_BIT
-* 000f0042 .word   0x000f0042
-*
-* elif ARM_OABI
-*
-* e59f0008 ldr r0, [pc, #8]
-* ef9f0042 swi 0x009f0042
-* e3a0 mov r0, #0
-* e580 str r0, [r0]; 
-* 105e .word   0x105e  ; sc_cobalt_mayday | 
__COBALT_SYSCALL_BIT
-*
-* endif
-*
-* 32bit instruction words will be laid out by the compiler as
-* the target endianness requires.
-*
-* We don't mess with CPSR here, so no need to save/restore it
-* in handle/fixup code.
-*/
-#ifdef __ARM_EABI__
-   static const struct {
-   u32 ldr_r0;
-   u32 ldr_r7;
-   u32 swi_0;
-   u32 mov_r0;
-   u32 str_r0;
-   u32 cst_r0;
-   u32 cst_r7;
-   } code = {
-   .ldr_r0 = 0xe59f000c,
-   .ldr_r7 = 0xe59f700c,
-   .swi_0 = 0xef00,
-   .mov_r0 = 0xe3a0,
-   .str_r0 = 0xe580,
-   .cst_r0 =  __xn_syscode(sc_cobalt_mayday),
-   .cst_r7 = 0x000f0042,
-   };
-#else /* OABI */
-   static const struct {
-   u32 ldr_r0;
-   u32 swi_syscall;
-   u32 mov_r0;
-   u32 str_r0;
-   u32 cst_r0;
-   } code = {
-   .ldr_r0 = 0xe59f0008,
-   .swi_syscall = 0xef9f0042,
-   .mov_r0 = 0xe3a0,
-   .str_r0 = 0xe580,
-   .cst_r0 =  __xn_syscode(sc_cobalt_mayday),
-   };
-#endif /* OABI */
-
-   memcpy(page, , sizeof(code));
-
-   flush_dcache_page(vmalloc_to_page(page));
 }
 
 int xnarch_init_mayday(void)
@@ -120,27 +54,9 @@ void *xnarch_get_mayday_page(void)
 void xnarch_handle_mayday(struct xnarchtcb *tcb, struct pt_regs *regs,
  unsigned long tramp)
 {
-   tcb->mayday.pc = regs->pc;
-   tcb->mayday.r0 = regs->regs[0];
-#ifdef __ARM_EABI__
-   tcb->mayday.r7 = regs->regs[7];
-#endif
-#ifdef CONFIG_ARM_THUMB
-   /* The code on the mayday page must be run in ARM mode */
-   tcb->mayday.psr = regs->cpsr;
-   regs->cpsr &= ~PSR_T_BIT;
-#endif
-   regs->pc = tramp;
+   xnthread_relax(0, 0);
 }
 
 void xnarch_fixup_mayday(struct xnarchtcb *tcb, struct pt_regs *regs)
 {
-   regs->pc = tcb->mayday.pc;
-   regs->regs[0] = tcb->mayday.r0;
-#ifdef __ARM_EABI__
-   regs->regs[7] = tcb->mayday.r7;
-#endif
-#ifdef CONFIG_ARM_THUMB
-   regs->cpsr = tcb->mayday.psr;
-#endif
 }


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: xenomai/syscall.h: update syscall register

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 371ea76c3f27c6a664299c79135599873cc810c0
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=371ea76c3f27c6a664299c79135599873cc810c0

Author: Dmitriy Cherkasov 
Date:   Fri May  8 15:54:18 2015 -0700

cobalt/arm64: xenomai/syscall.h: update syscall register

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index 2fdd890..7bf95fb 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -40,10 +40,10 @@
 #define __xn_reg_sys(__regs)   ((__regs)->orig_x0)
 /* In OABI_COMPAT mode, handle both OABI and EABI userspace syscalls */
 #ifdef CONFIG_OABI_COMPAT
-#define __xn_syscall_p(__regs) (((__regs)->regs[7] == __NR_OABI_SYSCALL_BASE + 
XENO_ARM_SYSCALL) || \
-((__regs)->regs[7] == __ARM_NR_ipipe))
+#define __xn_syscall_p(__regs) (((__regs)->regs[8] == __NR_OABI_SYSCALL_BASE + 
XENO_ARM_SYSCALL) || \
+((__regs)->regs[8] == __ARM_NR_ipipe))
 #else /* !CONFIG_OABI_COMPAT */
-#define __xn_syscall_p(__regs) ((__regs)->regs[7] == __ARM_NR_ipipe)
+#define __xn_syscall_p(__regs) ((__regs)->regs[8] == __ARM_NR_ipipe)
 #endif /* !CONFIG_OABI_COMPAT */
 #define __xn_syscall(__regs)   (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
 


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


[Xenomai-git] Don Mahurin : cobalt/arm64: fix warning: expects argument of type ' long unsigned int', but argument has type 'u64'

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a38e19c97eb45b584e71d3f8e02cf48c33a35c31
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a38e19c97eb45b584e71d3f8e02cf48c33a35c31

Author: Don Mahurin 
Date:   Thu May 14 17:34:53 2015 -0700

cobalt/arm64: fix warning: expects argument of type 'long unsigned int', but 
argument has type 'u64'

---

 kernel/cobalt/posix/syscall.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 8186a0f..2926d7e 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -666,7 +666,7 @@ linux_syscall:
return KEVENT_PROPAGATE;
 
 bad_syscall:
-   printk(XENO_WARNING "bad syscall <%#lx>\n", __xn_syscall(regs));
+   printk(XENO_WARNING "bad syscall <%#llx>\n", __xn_syscall(regs));
 
__xn_error_return(regs, -ENOSYS);
 


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


[Xenomai-git] Philippe Gerum : lib/cobalt: modechk: rename assertion helper, fix header

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: dd131f1d6d76cc3aae14c542926f6622563b2062
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=dd131f1d6d76cc3aae14c542926f6622563b2062

Author: Philippe Gerum 
Date:   Mon Mar 13 15:51:31 2017 +0100

lib/cobalt: modechk: rename assertion helper, fix header

---

 include/cobalt/stdio.h  |4 
 include/cobalt/sys/cobalt.h |6 ++
 lib/cobalt/Makefile.am  |1 -
 lib/cobalt/assert_context.c |   40 
 lib/cobalt/cxaguard.c   |9 -
 lib/cobalt/internal.c   |   19 ++-
 lib/cobalt/malloc.c |7 +++
 lib/cobalt/printf.c |6 +++---
 8 files changed, 34 insertions(+), 58 deletions(-)

diff --git a/include/cobalt/stdio.h b/include/cobalt/stdio.h
index 81486d5..c915e6d 100644
--- a/include/cobalt/stdio.h
+++ b/include/cobalt/stdio.h
@@ -112,10 +112,6 @@ const char *rt_print_buffer_name(void);
 
 void rt_print_flush_buffers(void);
 
-void assert_nrt(void);
-
-__deprecated void assert_nrt_fast(void);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/include/cobalt/sys/cobalt.h b/include/cobalt/sys/cobalt.h
index e7c58d7..1da8a46 100644
--- a/include/cobalt/sys/cobalt.h
+++ b/include/cobalt/sys/cobalt.h
@@ -132,6 +132,12 @@ int cobalt_sched_weighted_prio(int policy,
 
 void cobalt_register_tsd_hook(struct cobalt_tsd_hook *th);
 
+void cobalt_assert_nrt(void);
+
+/* Use cobalt_assert_nrt() instead of: */
+__deprecated void assert_nrt(void);
+__deprecated void assert_nrt_fast(void);
+
 extern int __cobalt_control_bind;
 
 #ifdef __cplusplus
diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 6275eb4..c2d5956 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -14,7 +14,6 @@ libcobalt_la_LIBADD = \
../boilerplate/libboilerplate.la
 
 libcobalt_la_SOURCES = \
-   assert_context.c\
attr.c  \
clock.c \
cond.c  \
diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
deleted file mode 100644
index 11739db..000
--- a/lib/cobalt/assert_context.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Jan Kiszka .
- *
- * 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 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "current.h"
-#include "internal.h"
-
-void assert_nrt(void)
-{
-   if (cobalt_should_warn())
-   pthread_kill(pthread_self(), SIGDEBUG);
-}
-
-void assert_nrt_fast(void) /* OBSOLETE */
-{
-   assert_nrt();
-}
diff --git a/lib/cobalt/cxaguard.c b/lib/cobalt/cxaguard.c
index 13432af..6df471a 100644
--- a/lib/cobalt/cxaguard.c
+++ b/lib/cobalt/cxaguard.c
@@ -16,10 +16,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 #include 
+#include 
 #include 
 
-void assert_nrt(void);
-
 #ifdef __ARM_EABI__
 typedef uint32_t __cxa_guard_type;
 #else
@@ -32,7 +31,7 @@ int __real_cxa_guard_acquire(__cxa_guard_type *g);
 /* CXXABI 3.3.2 One-time Construction API */
 COBALT_IMPL(int, __cxa_guard_acquire, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
return __STD(__cxa_guard_acquire(g));
 }
 
@@ -41,7 +40,7 @@ void __real_cxa_guard_release(__cxa_guard_type *g);
 
 COBALT_IMPL(void, __cxa_guard_release, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
__STD(__cxa_guard_release(g));
 }
 
@@ -50,6 +49,6 @@ void __real_cxa_guard_abort(__cxa_guard_type *g);
 
 COBALT_IMPL(void, __cxa_guard_abort, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
__STD(__cxa_guard_abort(g));
 }
diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c
index 5b89db5..49744c4 100644
--- a/lib/cobalt/internal.c
+++ b/lib/cobalt/internal.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Philippe Gerum .
+ * Copyright (C) 2008, 2009 Jan Kiszka .
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,7 +31,7 @@
 #include 
 #include 
 #include 

[Xenomai-git] Philippe Gerum : cobalt/arm64: drop aarch32 bits from feature set

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 1b803db585be5129d1bf20ef2d653be0b703087e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1b803db585be5129d1bf20ef2d653be0b703087e

Author: Philippe Gerum 
Date:   Thu Sep 17 02:16:10 2015 +0200

cobalt/arm64: drop aarch32 bits from feature set

---

 .../arch/arm64/include/asm/xenomai/features.h  |   44 ++--
 1 file changed, 4 insertions(+), 40 deletions(-)

diff --git a/lib/cobalt/arch/arm64/include/asm/xenomai/features.h 
b/lib/cobalt/arch/arm64/include/asm/xenomai/features.h
index 0d6702b..6dfe64c 100644
--- a/lib/cobalt/arch/arm64/include/asm/xenomai/features.h
+++ b/lib/cobalt/arch/arm64/include/asm/xenomai/features.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005 Philippe Gerum .
+ * Copyright (C) 2015 Philippe Gerum .
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -15,52 +15,16 @@
  * 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 _LIB_COBALT_ARM_FEATURES_H
-#define _LIB_COBALT_ARM_FEATURES_H
+#ifndef _LIB_COBALT_ARM64_FEATURES_H
+#define _LIB_COBALT_ARM64_FEATURES_H
 
 #include_next 
 #include 
 
-#if defined(__ARM_ARCH_2__)
-#define __LINUX_ARM_ARCH__ 2
-#endif /* armv2 */
-
-#if defined(__ARM_ARCH_3__)
-#define __LINUX_ARM_ARCH__ 3
-#endif /* armv3 */
-
-#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
-#define __LINUX_ARM_ARCH__ 4
-#endif /* armv4 */
-
-#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
-   || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__)
-#define __LINUX_ARM_ARCH__ 5
-#endif /* armv5 */
-
-#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6K__) \
-   || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__)
-#define __LINUX_ARM_ARCH__ 6
-#endif /* armv6 */
-
-#if defined(__ARM_ARCH_7A__)
-#define __LINUX_ARM_ARCH__ 7
-#endif /* armv7 */
-
-#if defined(__aarch64__)
 #define __LINUX_ARM_ARCH__ 8
-#endif /* armv8 */
-
-#ifndef __LINUX_ARM_ARCH__
-#error "Could not find current ARM architecture"
-#endif
-
-#if __LINUX_ARM_ARCH__ < 6 && defined(CONFIG_SMP)
-#error "SMP not supported below armv6, compile with -march=armv6 or above"
-#endif
 
 #include 
 
 int cobalt_fp_detect(void);
 
-#endif /* !_LIB_COBALT_ARM_FEATURES_H */
+#endif /* !_LIB_COBALT_ARM64_FEATURES_H */


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


[Xenomai-git] Philippe Gerum : lib/cobalt: move mode checking wrappers to static archive

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a7243543ecca5d8cfe9b7a4d76cdb57ae252f6a9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a7243543ecca5d8cfe9b7a4d76cdb57ae252f6a9

Author: Philippe Gerum 
Date:   Sun Mar 12 12:21:18 2017 +0100

lib/cobalt: move mode checking wrappers to static archive

The mode checking wrappers must reside in a static archive, so that
the linker will pull them on demand, dropping the requirement for
providing potentially conflicting placeholders for wrapped symbols
which may not be present in both C and C++ support libraries
(e.g. __cxa_guard_acquire/release/abort from the one-time C++
constructor API).

See http://www.xenomai.org/pipermail/xenomai/2017-March/037184.html

---

 configure.ac |   15 ++
 debian/libxenomai-dev.install|2 +-
 demo/alchemy/Makefile.am |5 ++--
 demo/alchemy/cobalt/Makefile.am  |   16 +--
 demo/posix/cobalt/Makefile.am|2 +-
 demo/posix/cyclictest/Makefile.am|6 ++--
 lib/boilerplate/init/bootstrap.c |   12 
 lib/cobalt/Makefile.am   |   24 ++--
 lib/cobalt/assert_context.c  |   13 -
 lib/cobalt/malloc-nowrap.c   |   30 
 lib/cobalt/malloc.c  |   33 ++
 lib/cobalt/{assert.wrappers => modechk.wrappers} |0
 lib/cobalt/wrappers.c|   12 
 lib/copperplate/regd/Makefile.am |2 +-
 scripts/wrap-link.sh |6 ++--
 scripts/xeno-config-cobalt.in|4 +--
 testsuite/clocktest/Makefile.am  |2 +-
 testsuite/gpiotest/Makefile.am   |4 +--
 testsuite/latency/Makefile.am|6 ++--
 testsuite/smokey/Makefile.am |2 +-
 testsuite/smokey/net_common/Makefile.am  |2 +-
 testsuite/spitest/Makefile.am|4 +--
 testsuite/switchtest/Makefile.am |6 ++--
 utils/analogy/Makefile.am|   18 ++--
 utils/autotune/Makefile.am   |2 +-
 utils/can/Makefile.am|6 ++--
 utils/corectl/Makefile.am|2 +-
 utils/hdb/Makefile.am|4 +--
 28 files changed, 150 insertions(+), 90 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4792e46..d5c5aaa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -796,19 +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"
+   modechk_wrappers="$topdir/lib/cobalt/modechk.wrappers"
cobalt_wrappers="$topdir/lib/cobalt/cobalt.wrappers"
if [[ $ac_cv_ld_file_option = yes ]]; then
-   XENO_POSIX_WRAPPERS="-Wl,@$assert_wrappers -Wl,@$cobalt_wrappers"
+   XENO_POSIX_WRAPPERS="-Wl,@$modechk_wrappers -Wl,@$cobalt_wrappers"
else
-   XENO_POSIX_WRAPPERS=`cat $assert_wrappers $cobalt_wrappers | \
+   XENO_POSIX_WRAPPERS=`cat $modechk_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], ["$assert_wrappers 
$cobalt_wrappers"])
+   AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ["$modechk_wrappers 
$cobalt_wrappers"])
 fi
 
 dnl
@@ -818,8 +818,11 @@ dnl
 
XENO_AUTOINIT_LDFLAGS='$(top_builddir)/lib/boilerplate/init/bootstrap-internal.o'"
 -Wl,--wrap=main -Wl,--dynamic-list=$topdir/scripts/dynlist.ld"
 AC_SUBST(XENO_AUTOINIT_LDFLAGS)
 
-XENO_CORE_LIB=$rtcore_type/lib${rtcore_type}.la
-AC_SUBST(XENO_CORE_LIB)
+XENO_CORE_LDADD="\$(top_builddir)/lib/$rtcore_type/lib${rtcore_type}.la"
+if test $rtcore_type = cobalt; then
+   XENO_CORE_LDADD="$XENO_CORE_LDADD \$(top_builddir)/lib/cobalt/libmodechk.a"
+fi
+AC_SUBST(XENO_CORE_LDADD)
 
 AC_SUBST(DOXYGEN_SHOW_INCLUDE_FILES)
 AC_SUBST(DOXYGEN_HAVE_DOT)
diff --git a/debian/libxenomai-dev.install b/debian/libxenomai-dev.install
index 6d7eb7b..9f95c35 100644
--- a/debian/libxenomai-dev.install
+++ b/debian/libxenomai-dev.install
@@ -2,6 +2,6 @@ usr/include
 usr/lib/*.la
 usr/lib/*.a
 usr/lib/*.so
-usr/lib/assert.wrappers
+usr/lib/modechk.wrappers
 usr/lib/cobalt.wrappers
 usr/lib/dynlist.ld
diff --git a/demo/alchemy/Makefile.am b/demo/alchemy/Makefile.am
index e6cda07..80def4f 100644
--- a/demo/alchemy/Makefile.am
+++ b/demo/alchemy/Makefile.am
@@ -13,8 +13,9 @@ cppflags =\
 ldadd =  

[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: thread: use kernel switch_to

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 1fcec37485180e55af4dd12bf8557ca4be426930
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1fcec37485180e55af4dd12bf8557ca4be426930

Author: Dmitriy Cherkasov 
Date:   Fri May 15 23:26:18 2015 -0700

cobalt/arm64: thread: use kernel switch_to

---

 kernel/cobalt/arch/arm64/Makefile |2 +-
 kernel/cobalt/arch/arm64/switch.S |  167 -
 kernel/cobalt/arch/arm64/thread.c |5 +-
 3 files changed, 2 insertions(+), 172 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/Makefile 
b/kernel/cobalt/arch/arm64/Makefile
index a135f99..af0a0e8 100644
--- a/kernel/cobalt/arch/arm64/Makefile
+++ b/kernel/cobalt/arch/arm64/Makefile
@@ -1,5 +1,5 @@
 obj-$(CONFIG_XENOMAI) += xenomai.o
 
-xenomai-y := machine.o mayday.o thread.o switch.o syscall.o
+xenomai-y := machine.o mayday.o thread.o syscall.o
 
 ccflags-y := -Iarch/arm64/xenomai/include -Iinclude/xenomai
diff --git a/kernel/cobalt/arch/arm64/switch.S 
b/kernel/cobalt/arch/arm64/switch.S
deleted file mode 100644
index 505fd5a..000
--- a/kernel/cobalt/arch/arm64/switch.S
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2005 Stelian Pop.
- *
- * 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, Inc., 675 Mass Ave, Cambridge MA 02139,
- * USA; 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 
-#ifdef CONFIG_VFP
-#include 
-#endif
-
-   .macro fpu_switch tmp
-#ifdef CONFIG_VFP
-#if __LINUX_ARM_ARCH__ <= 6
-#ifdef CONFIG_JUMP_LABEL
-9998:  nop
-   .pushsection __jump_table, "aw"
-   .word   9998b, f, __xeno_vfp_key
-   .popsection
-#else
-   ldr \tmp, =elf_hwcap
-   ldr \tmp, [\tmp]
-   tst \tmp, #HWCAP_VFP
-   beq f
-#endif
-#endif
-   @ Always disable VFP so we can lazily save/restore the old
-   @ state. This occurs in the context of the previous thread.
-   VFPFMRX \tmp, FPEXC
-   bic \tmp, \tmp, #FPEXC_EN
-   VFPFMXR FPEXC, \tmp
-#if __LINUX_ARM_ARCH__ <= 6
-:
-#endif
-#endif
-   .endm
-
-   .text
-
-#if defined(CONFIG_VFP) && defined(CONFIG_XENO_ARCH_FPU)
-/* Copied from vfp_save_state in arch/arm/vfp/vfphw.S
- * r0 = pointer to union vfp_state, r1 = fpexc
- */
-ENTRY(__asm_vfp_save)
-   VFPFSTMIA   r0, r2  @ save the working registers
-   VFPFMRX r2, FPSCR   @ current status
-   tst r1, #FPEXC_EX   @ is there additional state to save?
-   beq 1f
-   VFPFMRX r3, FPINST  @ FPINST (only if FPEXC.EX is set)
-   tst r1, #FPEXC_FP2V @ is there an FPINST2 to read?
-   beq 1f
-   VFPFMRX r12, FPINST2@ FPINST2 if needed (and present)
-1:
-   stmia   r0, {r1, r2, r3, r12}   @ save FPEXC, FPSCR, FPINST, 
FPINST2
-   mov pc, lr
-ENDPROC(__asm_vfp_save)
-
-/* Copied from no_old_VFP_process in arch/arm/vfp/vfphw.S
- * r0 = pointer to union vfp_state
- * r1 = current cpu
- */
-ENTRY(__asm_vfp_load)
-#ifdef CONFIG_SMP
-   str r1, [r0, #VFP_CPU]
-#endif
-   VFPFLDMIA   r0, r2  @ reload the working registers while
-   @ FPEXC is in a safe state
-   ldmia   r0, {r1, r2, r3, r12}   @ load FPEXC, FPSCR, FPINST, 
FPINST2
-   tst r1, #FPEXC_EX   @ is there additional state to restore?
-   beq 1f
-   VFPFMXR FPINST, r3  @ restore FPINST (only if FPEXC.EX is 
set)
-   tst r1, #FPEXC_FP2V @ is there an FPINST2 to write?
-   beq 1f
-   VFPFMXR FPINST2, r12@ FPINST2 if needed (and present)
-1:
-   VFPFMXR FPSCR, r2   @ restore status
-   mov pc, lr
-ENDPROC(__asm_vfp_load)
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
-   .macro load_tls base, tp, tpuser
-   ldr \tp, [\base, #TI_TP_VALUE]
-   .endm
-
-   .macro switch_tls base, tp, tpuser, tmp1, tmp2
-   set_tls \tp, \tmp1, \tmp2
-   .endm
-#else
-   .macro load_tls base, tp, tpuser
-   ldr \tp, [\base, #TI_TP_VALUE]
-   ldr \tpuser, [\base, #TI_TP_VALUE + 4]
-   .endm
-#endif
-
-/*
-/*
- * Switch context routine.
- *
- * Registers 

[Xenomai-git] Philippe Gerum : scripts/xeno-config: cobalt: add --[no-]mode-check switch

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d8f5eee72c5d4fb349d23f2d924645ccd12f8c9c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d8f5eee72c5d4fb349d23f2d924645ccd12f8c9c

Author: Philippe Gerum 
Date:   Mon Mar 13 10:50:34 2017 +0100

scripts/xeno-config: cobalt: add --[no-]mode-check switch

These switches control whether xeno-config should emit the linker
flags for interposing on a set of standard routines which may invoke
regular Linux system calls, triggering an assertion failure on entry
if the caller must switch to secondary mode.

For the assertion failure to trigger, PTHREAD_WARNSW must have been
set for the calling thread.

---

 doc/asciidoc/man1/xeno-config.adoc |   21 +++--
 scripts/xeno-config-cobalt.in  |   21 +
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/doc/asciidoc/man1/xeno-config.adoc 
b/doc/asciidoc/man1/xeno-config.adoc
index 62ab888..14acc67 100644
--- a/doc/asciidoc/man1/xeno-config.adoc
+++ b/doc/asciidoc/man1/xeno-config.adoc
@@ -35,7 +35,7 @@ SYNOPSIS
 
 *xeno-config* *--version*
 
-*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*--libdir*|*--user-libdir*]
+*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] 
[*--mode-check*|*no-mode-check*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*libdir*|*user-libdir*]
 
 DESCRIPTION
 
@@ -130,6 +130,23 @@ This flag makes sense when passed along with --ldflags
 only. *xeno-config* enables the Copperplate auto-init feature by
 default.
 
+*--mode-check*::
+*--no-mode-check*::
+
+Over Cobalt, a set of standard routines which may invoke regular Linux
+system calls can trigger an assertion failure on entry, if the caller
+must leave the real-time mode (aka "secondary mode switch") to execute
+such routine.
+
+The assertion failure is triggered if the calling thread has set the
+PTHREAD_WARNSW flag by a call to +pthread_setmode_np()+.
+
+By default, the mode checking routines are substituted to the original
+ones using the symbol wrapping mechanism also used for interposing on
+POSIX services. *--no-mode-check* disables such substitution.
+
+These flags make sense when passed along with --ldflags only.
+
 *--auto-init-solib*::
 
 This switch enables the auto-initialization feature described above
@@ -140,7 +157,7 @@ used for bootstrapping the initialization.
 The bootstrap code runs when the shared library is attached to a
 running executable, either because it appears in the static
 dependencies of this executable, or when loaded dynamically via the
-dlopen() interface.
++dlopen()+ interface.
 
 *--core*::
 Output the name of the real-time core the current Xenomai installation
diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index c014176..82815e1 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -52,9 +52,10 @@ Options :
 --prefix
 --[skin=]posix|vxworks|psos|alchemy|rtdm|smokey|cobalt
 --auto-init|auto-init-solib|no-auto-init
+--mode-check|no-mode-check
 --cflags
 --ldflags
---lib*-dir,--libdir,--user-libdir
+--lib*-dir|libdir|user-libdir
 --core
 --info
 --compat
@@ -109,6 +110,7 @@ do_cflags=
 do_setinit=
 do_autoinit=y
 do_autoinit_solib=
+do_mode_check=y
 
 while test $# -gt 0; do
 case "$1" in
@@ -191,6 +193,12 @@ while test $# -gt 0; do
--compat)
compat=y
 ;;
+   --mode-check)
+   do_mode_check=y
+   ;;
+   --no-mode-check)
+   do_mode_check=
+   ;;
 *)
  usage 1 1>&2
  ;;
@@ -235,7 +243,10 @@ if test x$do_ldflags = xy; then
echo "no API specified, missing --skin before --ldflags" 1>&2
exit 1
 fi
-ldflags="`dump_wrappers modechk.wrappers`"
+ldflags=
+if test x$do_mode_check = xy; then
+   ldflags="`dump_wrappers modechk.wrappers`"
+fi
 test x$compat = xy && ldflags="-ltrank $ldflags"
 copperplate=
 for skin in $skin_list; do
@@ -244,8 +255,10 @@ if test x$do_ldflags = xy; then
ldflags="`dump_wrappers cobalt.wrappers` $ldflags"
;;
cobalt)
-   # do NOT wrap POSIX symbols in application code
-   # with --cobalt. On the contrary, --posix does.
+   # do NOT wrap POSIX symbols in application code with
+   # --cobalt. On the contrary, --posix does. This switch
+   # does not affect mode checking wrappers,
+   # --[no-]mode-check does.
;;
vxworks|psos|alchemy|smokey)
copperplate="-lcopperplate"



[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: populate arch/arm64 with a copy of arch/ arm.

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 71f43e5c29f5d974cae7c65e42c3d043805fe99a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=71f43e5c29f5d974cae7c65e42c3d043805fe99a

Author: Dmitriy Cherkasov 
Date:   Wed May  6 15:27:23 2015 -0700

cobalt/arm64: populate arch/arm64 with a copy of arch/arm.

kernel/cobalt/arch/arm -> kernel/cobalt/arch/arm64
lib/cobalt/arch/arm -> lib/cobalt/arch/arm64

---

 configure.ac   |   12 +-
 kernel/cobalt/arch/arm64/Kconfig   |   40 +++
 kernel/cobalt/arch/arm64/Makefile  |5 +
 .../arch/arm64/include/asm/xenomai/calibration.h   |   59 
 .../arch/arm64/include/asm/xenomai/features.h  |   30 ++
 .../cobalt/arch/arm64/include/asm/xenomai/fptest.h |   52 +++
 .../arch/arm64/include/asm/xenomai/machine.h   |   85 +
 .../arch/arm64/include/asm/xenomai/syscall.h   |   74 
 .../arch/arm64/include/asm/xenomai/syscall32.h |   24 ++
 .../cobalt/arch/arm64/include/asm/xenomai/thread.h |  123 +++
 .../arch/arm64/include/asm/xenomai/uapi/arith.h|  142 
 .../arch/arm64/include/asm/xenomai/uapi/features.h |   43 +++
 .../arch/arm64/include/asm/xenomai/uapi/fptest.h   |   61 
 .../arch/arm64/include/asm/xenomai/uapi/syscall.h  |   34 ++
 .../arch/arm64/include/asm/xenomai/uapi/tsc.h  |   25 ++
 .../arch/arm64/include/asm/xenomai/wrappers.h  |   27 ++
 kernel/cobalt/arch/arm64/machine.c |  119 +++
 kernel/cobalt/arch/arm64/mayday.c  |  146 
 kernel/cobalt/arch/arm64/switch.S  |  167 +
 kernel/cobalt/arch/arm64/syscall.c |   53 +++
 kernel/cobalt/arch/arm64/thread.c  |  355 
 lib/cobalt/arch/Makefile.am|2 +-
 lib/cobalt/arch/arm64/Makefile.am  |   13 +
 lib/cobalt/arch/arm64/features.c   |  102 ++
 lib/cobalt/arch/arm64/include/Makefile.am  |2 +
 lib/cobalt/arch/arm64/include/asm/Makefile.am  |2 +
 .../arch/arm64/include/asm/xenomai/Makefile.am |5 +
 .../arch/arm64/include/asm/xenomai/features.h  |   62 
 .../arch/arm64/include/asm/xenomai/syscall.h   |  138 
 lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h|   48 +++
 30 files changed, 2047 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index d5c5aaa..2170d0e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -139,6 +139,10 @@ case "$build_for" in
target_cpu_arch=arm
CONFIG_XENO_DEFAULT_PERIOD=100
;;
+ aarch64-*)
+   target_cpu_arch=arm64
+   CONFIG_XENO_DEFAULT_PERIOD=100
+   ;;
  x86_64-*|amd64-*)
use_tls=yes
target_cpu_arch=x86
@@ -361,7 +365,7 @@ fi
 
 dnl VSYSCALL (default: enabled) for Cobalt/x86
 
-if test $XENO_TARGET_ARCH = x86 -a $rtcore_type = cobalt; then
+if test $target_cpu_arch = x86 -a $rtcore_type = cobalt; then
   CONFIG_XENO_X86_VSYSCALL=y
   AC_MSG_CHECKING(for x86 VSYSCALL availability)
   AC_ARG_ENABLE(x86-vsyscall,
@@ -786,7 +790,7 @@ dnl Autoconf-generated symbols have been listed.
 AH_BOTTOM([#endif /* __IN_XENO__ */])
 
 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"
+   XENO_USER_CFLAGS="-I$topdir/lib/cobalt/arch/$target_cpu_arch/include 
-I$topdir/kernel/cobalt/arch/$target_cpu_arch/include $XENO_USER_CFLAGS"
XENO_COBALT_CFLAGS="$XENO_USER_CFLAGS"
case "$build_for" in
 i*86*-*) XENO_COBALT_CFLAGS="$XENO_COBALT_CFLAGS -fno-omit-frame-pointer";;
@@ -865,6 +869,10 @@ AC_CONFIG_FILES([ \
lib/cobalt/arch/arm/include/Makefile \
lib/cobalt/arch/arm/include/asm/Makefile \
lib/cobalt/arch/arm/include/asm/xenomai/Makefile \
+   lib/cobalt/arch/arm64/Makefile \
+   lib/cobalt/arch/arm64/include/Makefile \
+   lib/cobalt/arch/arm64/include/asm/Makefile \
+   lib/cobalt/arch/arm64/include/asm/xenomai/Makefile \
lib/cobalt/arch/powerpc/Makefile \
lib/cobalt/arch/powerpc/include/Makefile \
lib/cobalt/arch/powerpc/include/asm/Makefile \
diff --git a/kernel/cobalt/arch/arm64/Kconfig b/kernel/cobalt/arch/arm64/Kconfig
new file mode 100644
index 000..dc6485d
--- /dev/null
+++ b/kernel/cobalt/arch/arm64/Kconfig
@@ -0,0 +1,40 @@
+source "kernel/xenomai/Kconfig"
+source "drivers/xenomai/Kconfig"
+
+menu "Machine/platform-specific options"
+
+config XENO_ARCH_UNLOCKED_SWITCH
+   bool "Unlocked context switch"
+   default y
+   help
+   The Cobalt core may allow non-atomic execution of the
+   machine-dependent context switching code, so that other CPUs
+   and/or local interrupts may execute concurrently.
+
+   This option reduces interrupt latency when costly cache and
+   TLB flushes are required to switch context.
+
+  

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

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: e462c8499eaff9c2ff1bf5a745a64613420a9aa1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e462c8499eaff9c2ff1bf5a745a64613420a9aa1

Author: Henning Schild 
Date:   Sun Mar 12 18:30:57 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/Makefile.am  |1 +
 lib/cobalt/cxaguard.c   |   55 +++
 lib/cobalt/modechk.wrappers |3 +++
 3 files changed, 59 insertions(+)

diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 6189755..6275eb4 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -53,6 +53,7 @@ libcobalt_la_CPPFLAGS =   \
 lib_LIBRARIES = libmodechk.a
 
 libmodechk_a_SOURCES = \
+   cxaguard.c  \
malloc.c\
malloc-nowrap.c
 
diff --git a/lib/cobalt/cxaguard.c b/lib/cobalt/cxaguard.c
new file mode 100644
index 000..13432af
--- /dev/null
+++ b/lib/cobalt/cxaguard.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2017 Henning Schild 
+ *
+ * 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 
+#include 
+
+void assert_nrt(void);
+
+#ifdef __ARM_EABI__
+typedef uint32_t __cxa_guard_type;
+#else
+typedef uint64_t __cxa_guard_type;
+#endif
+
+COBALT_DECL(int, __cxa_guard_acquire(__cxa_guard_type *g));
+int __real_cxa_guard_acquire(__cxa_guard_type *g);
+
+/* CXXABI 3.3.2 One-time Construction API */
+COBALT_IMPL(int, __cxa_guard_acquire, (__cxa_guard_type *g))
+{
+   assert_nrt();
+   return __STD(__cxa_guard_acquire(g));
+}
+
+COBALT_DECL(void, __cxa_guard_release(__cxa_guard_type *g));
+void __real_cxa_guard_release(__cxa_guard_type *g);
+
+COBALT_IMPL(void, __cxa_guard_release, (__cxa_guard_type *g))
+{
+   assert_nrt();
+   __STD(__cxa_guard_release(g));
+}
+
+COBALT_DECL(void, __cxa_guard_abort(__cxa_guard_type *g));
+void __real_cxa_guard_abort(__cxa_guard_type *g);
+
+COBALT_IMPL(void, __cxa_guard_abort, (__cxa_guard_type *g))
+{
+   assert_nrt();
+   __STD(__cxa_guard_abort(g));
+}
diff --git a/lib/cobalt/modechk.wrappers b/lib/cobalt/modechk.wrappers
index 7164858..65320ab 100644
--- a/lib/cobalt/modechk.wrappers
+++ b/lib/cobalt/modechk.wrappers
@@ -1,2 +1,5 @@
 --wrap malloc
 --wrap free
+--wrap __cxa_guard_acquire
+--wrap __cxa_guard_release
+--wrap __cxa_guard_abort


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


[Xenomai-git] Philippe Gerum : drivers/ipc: reduce stack footprint of I/O vectors

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 1ba2fc8ef98d927f07a8d7465fe9ea541f501e39
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1ba2fc8ef98d927f07a8d7465fe9ea541f501e39

Author: Philippe Gerum 
Date:   Sun Mar 12 11:37:20 2017 +0100

drivers/ipc: reduce stack footprint of I/O vectors

Resort to dynamic allocation of the I/O vector when more than 16
entries are needed, otherwise stick to a stack-based fast vector as
previously.

As a by-product of this change, we can now align on the regular
UIO_MAXIOV limit for all RTIPC protocols.

---

 kernel/drivers/ipc/bufp.c |   24 +-
 kernel/drivers/ipc/iddp.c |   24 +-
 kernel/drivers/ipc/internal.h |   20 +-
 kernel/drivers/ipc/rtipc.c|   45 +
 kernel/drivers/ipc/xddp.c |   24 +-
 5 files changed, 89 insertions(+), 48 deletions(-)

diff --git a/kernel/drivers/ipc/bufp.c b/kernel/drivers/ipc/bufp.c
index 2e7f5ad..3b565bd 100644
--- a/kernel/drivers/ipc/bufp.c
+++ b/kernel/drivers/ipc/bufp.c
@@ -359,7 +359,7 @@ static ssize_t __bufp_recvmsg(struct rtdm_fd *fd,
 static ssize_t bufp_recvmsg(struct rtdm_fd *fd,
struct user_msghdr *msg, int flags)
 {
-   struct iovec iov[RTIPC_IOV_MAX];
+   struct iovec iov_fast[RTIPC_IOV_FASTMAX], *iov;
struct sockaddr_ipc saddr;
ssize_t ret;
 
@@ -372,20 +372,22 @@ static ssize_t bufp_recvmsg(struct rtdm_fd *fd,
} else if (msg->msg_namelen != 0)
return -EINVAL;
 
-   if (msg->msg_iovlen >= RTIPC_IOV_MAX)
+   if (msg->msg_iovlen >= UIO_MAXIOV)
return -EINVAL;
 
/* Copy I/O vector in */
-   ret = rtipc_get_iovec(fd, iov, msg);
+   ret = rtipc_get_iovec(fd, , msg, iov_fast);
if (ret)
return ret;
 
ret = __bufp_recvmsg(fd, iov, msg->msg_iovlen, flags, );
-   if (ret <= 0)
+   if (ret <= 0) {
+   rtipc_drop_iovec(iov, iov_fast);
return ret;
+   }
 
/* Copy the updated I/O vector back */
-   if (rtipc_put_iovec(fd, iov, msg))
+   if (rtipc_put_iovec(fd, iov, msg, iov_fast))
return -EFAULT;
 
/* Copy the source address if required. */
@@ -607,8 +609,8 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd,
const struct user_msghdr *msg, int flags)
 {
struct rtipc_private *priv = rtdm_fd_to_private(fd);
+   struct iovec iov_fast[RTIPC_IOV_FASTMAX], *iov;
struct bufp_socket *sk = priv->state;
-   struct iovec iov[RTIPC_IOV_MAX];
struct sockaddr_ipc daddr;
ssize_t ret;
 
@@ -634,20 +636,22 @@ static ssize_t bufp_sendmsg(struct rtdm_fd *fd,
return -EDESTADDRREQ;
}
 
-   if (msg->msg_iovlen >= RTIPC_IOV_MAX)
+   if (msg->msg_iovlen >= UIO_MAXIOV)
return -EINVAL;
 
/* Copy I/O vector in */
-   ret = rtipc_get_iovec(fd, iov, msg);
+   ret = rtipc_get_iovec(fd, , msg, iov_fast);
if (ret)
return ret;
 
ret = __bufp_sendmsg(fd, iov, msg->msg_iovlen, flags, );
-   if (ret <= 0)
+   if (ret <= 0) {
+   rtipc_drop_iovec(iov, iov_fast);
return ret;
+   }
 
/* Copy updated I/O vector back */
-   return rtipc_put_iovec(fd, iov, msg) ?: ret;
+   return rtipc_put_iovec(fd, iov, msg, iov_fast) ?: ret;
 }
 
 static ssize_t bufp_write(struct rtdm_fd *fd,
diff --git a/kernel/drivers/ipc/iddp.c b/kernel/drivers/ipc/iddp.c
index 6d3da57..5e2a2a1 100644
--- a/kernel/drivers/ipc/iddp.c
+++ b/kernel/drivers/ipc/iddp.c
@@ -326,7 +326,7 @@ static ssize_t __iddp_recvmsg(struct rtdm_fd *fd,
 static ssize_t iddp_recvmsg(struct rtdm_fd *fd,
struct user_msghdr *msg, int flags)
 {
-   struct iovec iov[RTIPC_IOV_MAX];
+   struct iovec iov_fast[RTIPC_IOV_FASTMAX], *iov;
struct sockaddr_ipc saddr;
ssize_t ret;
 
@@ -339,20 +339,22 @@ static ssize_t iddp_recvmsg(struct rtdm_fd *fd,
} else if (msg->msg_namelen != 0)
return -EINVAL;
 
-   if (msg->msg_iovlen >= RTIPC_IOV_MAX)
+   if (msg->msg_iovlen >= UIO_MAXIOV)
return -EINVAL;
 
/* Copy I/O vector in */
-   ret = rtipc_get_iovec(fd, iov, msg);
+   ret = rtipc_get_iovec(fd, , msg, iov_fast);
if (ret)
return ret;
 
ret = __iddp_recvmsg(fd, iov, msg->msg_iovlen, flags, );
-   if (ret <= 0)
+   if (ret <= 0) {
+   rtipc_drop_iovec(iov, iov_fast);
return ret;
+   }
 
/* Copy the updated I/O vector back */
-   if (rtipc_put_iovec(fd, iov, msg))
+   if (rtipc_put_iovec(fd, iov, msg, iov_fast))
return -EFAULT;
 
/* Copy the source address if required. */
@@ -468,8 +470,8 @@ static ssize_t iddp_sendmsg(struct 

[Xenomai-git] Philippe Gerum : cobalt/synch: add __must_check annotation to sleep_on call

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 4336b93138754b0f4a6f4373ef187212948c1974
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4336b93138754b0f4a6f4373ef187212948c1974

Author: Philippe Gerum 
Date:   Sun Mar 12 10:24:58 2017 +0100

cobalt/synch: add __must_check annotation to sleep_on call

---

 include/cobalt/kernel/synch.h |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h
index f419698..f5ac217 100644
--- a/include/cobalt/kernel/synch.h
+++ b/include/cobalt/kernel/synch.h
@@ -138,9 +138,9 @@ static inline void xnsynch_register_cleanup(struct xnsynch 
*synch,
synch->cleanup = handler;
 }
 
-int xnsynch_sleep_on(struct xnsynch *synch,
-xnticks_t timeout,
-xntmode_t timeout_mode);
+int __must_check xnsynch_sleep_on(struct xnsynch *synch,
+ xnticks_t timeout,
+ xntmode_t timeout_mode);
 
 struct xnthread *xnsynch_wakeup_one_sleeper(struct xnsynch *synch);
 


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


[Xenomai-git] Don Mahurin : lib/cobalt/arm64: replace tsc counter

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7b07fc3b4bdaef0ed296b35e593e7c49e054468c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7b07fc3b4bdaef0ed296b35e593e7c49e054468c

Author: Don Mahurin 
Date:   Wed May 13 09:36:25 2015 -0700

lib/cobalt/arm64: replace tsc counter

---

 lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h |   19 +++
 1 file changed, 19 insertions(+)

diff --git a/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h 
b/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h
index 594c4ad..a055427 100644
--- a/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h
+++ b/lib/cobalt/arch/arm64/include/asm/xenomai/tsc.h
@@ -27,6 +27,8 @@
 
 #include 
 #include 
+#include 
+#include 
 
 /*
  * Putting kuser_tsc_get and kinfo.counter in the same struct results
@@ -39,10 +41,27 @@ struct __xn_full_tscinfo {
 };
 extern struct __xn_full_tscinfo __xn_tscinfo;
 
+static inline uint64_t get_counter(void)
+{
+uint64_t cval;
+
+#ifdef __aarch64__
+   asm volatile("isb; mrs %0, cntvct_el0; isb; " : "=r" (cval) :: 
"memory");
+#else
+   asm volatile("isb; mrrc p15, 1, %Q0, %R0, c14; isb" : "=r" (cval) :: 
"memory");
+#endif
+
+   return cval;
+}
+
 static inline __attribute__((always_inline))
 unsigned long long cobalt_read_tsc(void)
 {
+#ifndef __aarch64__
return __xn_tscinfo.kuser_tsc_get(__xn_tscinfo.kinfo.counter);
+#else
+   return get_counter();
+#endif
 }
 
 #endif /* !_LIB_COBALT_ARM_TSC_H */


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


[Xenomai-git] Don Mahurin : cobalt/arm64: fix build for mismatched printf type (%lx, u64) on arm64.

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 98cc5e5c9a748584365b23e0811c0fd49e452462
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=98cc5e5c9a748584365b23e0811c0fd49e452462

Author: Don Mahurin 
Date:   Wed Sep  2 13:48:36 2015 -0700

cobalt/arm64: fix build for mismatched printf type (%lx,u64) on arm64.

pc and orig_r0 are u64 on arm64 and 'unsigned long' or arm and other platforms. 
printf referencing these are using %lx. On arm64, long and long long (and u64) 
are 64 bits. Rather than changing printf format, chnage arm64 macros to cast to 
unsigned long.

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h |2 +-
 kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h  |2 +-
 kernel/cobalt/posix/syscall.c  |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index 7bf95fb..77c1716 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -45,7 +45,7 @@
 #else /* !CONFIG_OABI_COMPAT */
 #define __xn_syscall_p(__regs) ((__regs)->regs[8] == __ARM_NR_ipipe)
 #endif /* !CONFIG_OABI_COMPAT */
-#define __xn_syscall(__regs)   (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
+#define __xn_syscall(__regs)   ((unsigned long)(__xn_reg_sys(__regs) & 
~__COBALT_SYSCALL_BIT))
 
 #define __xn_reg_rval(__regs)  ((__regs)->regs[0])
 #define __xn_reg_arg1(__regs)  ((__regs)->regs[1])
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
index 958f340..a8d7ed4 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/thread.h
@@ -52,7 +52,7 @@ struct xnarchtcb {
 #define xnarch_fault_regs(d)   ((d)->regs)
 #define xnarch_fault_trap(d)   ((d)->exception)
 #define xnarch_fault_code(d)   (0)
-#define xnarch_fault_pc(d) ((d)->regs->pc - 4) /* XXX ? */
+#define xnarch_fault_pc(d) ((unsigned long)((d)->regs->pc - 4)) /* XXX ? */
 
 #define xnarch_fault_pf_p(d)   ((d)->exception == IPIPE_TRAP_ACCESS)
 #define xnarch_fault_bp_p(d)   ((current->ptrace & PT_PTRACED) &&  \
diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 2926d7e..8186a0f 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -666,7 +666,7 @@ linux_syscall:
return KEVENT_PROPAGATE;
 
 bad_syscall:
-   printk(XENO_WARNING "bad syscall <%#llx>\n", __xn_syscall(regs));
+   printk(XENO_WARNING "bad syscall <%#lx>\n", __xn_syscall(regs));
 
__xn_error_return(regs, -ENOSYS);
 


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: features.h: disable XNARCH_HAVE_LLMULSHFT, XNARCH_HAVE_NODIV_LLIMD for armv8/aarch64, as arm64 does not have these

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 0701866647e35566578b9a408a3fb8048738b8d6
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0701866647e35566578b9a408a3fb8048738b8d6

Author: Dmitriy Cherkasov 
Date:   Thu May  7 16:40:07 2015 -0700

cobalt/arm64: features.h: disable XNARCH_HAVE_LLMULSHFT, 
XNARCH_HAVE_NODIV_LLIMD for armv8/aarch64, as arm64 does not have these

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h |2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
index 2dd1ada..cf7bbf4 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
@@ -28,8 +28,10 @@
 
 #define XENOMAI_FEAT_MAN (__xn_feat_generic_man_mask)
 
+#ifndef __aarch64__
 #define XNARCH_HAVE_LLMULSHFT1
 #define XNARCH_HAVE_NODIV_LLIMD  1
+#endif
 
 struct cobalt_featinfo_archdep { /* no arch-specific feature */ };
 


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


[Xenomai-git] Don Mahurin : lib/cobalt/arm64: add __LINUX_ARM_ARCH__ form armv8/aarch64

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: cc031cb89e08bd92ac210daae474c41d84b295dd
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=cc031cb89e08bd92ac210daae474c41d84b295dd

Author: Don Mahurin 
Date:   Fri May  8 10:39:01 2015 -0700

lib/cobalt/arm64: add __LINUX_ARM_ARCH__ form armv8/aarch64

---

 lib/cobalt/arch/arm64/include/asm/xenomai/features.h |4 
 1 file changed, 4 insertions(+)

diff --git a/lib/cobalt/arch/arm64/include/asm/xenomai/features.h 
b/lib/cobalt/arch/arm64/include/asm/xenomai/features.h
index 10bd0c7..0d6702b 100644
--- a/lib/cobalt/arch/arm64/include/asm/xenomai/features.h
+++ b/lib/cobalt/arch/arm64/include/asm/xenomai/features.h
@@ -47,6 +47,10 @@
 #define __LINUX_ARM_ARCH__ 7
 #endif /* armv7 */
 
+#if defined(__aarch64__)
+#define __LINUX_ARM_ARCH__ 8
+#endif /* armv8 */
+
 #ifndef __LINUX_ARM_ARCH__
 #error "Could not find current ARM architecture"
 #endif


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


[Xenomai-git] Philippe Gerum : lib/cobalt: modechk: fetch WARNSW flag from u_window

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: bad288b6bab74cc230d1fc6e2d80f9e388be7d3e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bad288b6bab74cc230d1fc6e2d80f9e388be7d3e

Author: Philippe Gerum 
Date:   Mon Mar 13 12:33:37 2017 +0100

lib/cobalt: modechk: fetch WARNSW flag from u_window

---

 lib/cobalt/assert_context.c |   19 ++-
 lib/cobalt/internal.h   |5 +
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
index 625cb76..11739db 100644
--- a/lib/cobalt/assert_context.c
+++ b/lib/cobalt/assert_context.c
@@ -28,25 +28,10 @@
 #include "current.h"
 #include "internal.h"
 
-static void assert_nrt_inner(void)
-{
-   struct cobalt_threadstat stat;
-   int ret;
-
-   ret = cobalt_thread_stat(0, );
-   if (ret) {
-   warning("cobalt_thread_stat() failed: %s", strerror(-ret));
-   return;
-   }
-
-   if (stat.status & XNWARN)
-   pthread_kill(pthread_self(), SIGDEBUG);
-}
-
 void assert_nrt(void)
 {
-   if (!cobalt_is_relaxed())
-   assert_nrt_inner();
+   if (cobalt_should_warn())
+   pthread_kill(pthread_self(), SIGDEBUG);
 }
 
 void assert_nrt_fast(void) /* OBSOLETE */
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index fee3fe1..df1f7c0 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -32,6 +32,11 @@ static inline int cobalt_is_relaxed(void)
return cobalt_get_current_mode() & XNRELAX;
 }
 
+static inline int cobalt_should_warn(void)
+{
+   return (cobalt_get_current_mode() & (XNRELAX|XNWARN)) == XNWARN;
+}
+
 static inline
 struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow)
 {


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: set cache aliasing and disable floating point coprocessor instructions form aarch64 /arm64

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ad62d1851f89e8b4447b52702dce39cc23e587b4
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ad62d1851f89e8b4447b52702dce39cc23e587b4

Author: Dmitriy Cherkasov 
Date:   Thu May  7 16:41:45 2015 -0700

cobalt/arm64: set cache aliasing and disable floating point coprocessor 
instructions form aarch64/arm64

---

 kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h|3 ++-
 .../cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h   |   13 -
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
index cf07a3f..e078564 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/machine.h
@@ -38,7 +38,8 @@
 #include 
 #include 
 
-#define xnarch_cache_aliasing() cache_is_vivt()
+/* D-side always behaves as PIPT on AArch64 (see 
arch/arm64/include/asm/cachetype.h) */
+#define xnarch_cache_aliasing() 0
 
 static inline __attribute_const__ unsigned long ffnz(unsigned long ul)
 {
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
index b81d109..65a3e31 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/fptest.h
@@ -18,10 +18,17 @@
 #ifndef _COBALT_ARM_ASM_UAPI_FPTEST_H
 #define _COBALT_ARM_ASM_UAPI_FPTEST_H
 
+#ifdef __aarch64__
+/* CP10 and CP11, used for the FP/NEON operations, are already excluded from
+the list of valid operands for the generic coprocessor instructions */
+#define __COBALT_HAVE_VFP  0
+#else
 #define __COBALT_HAVE_VFP  0x1
+#endif
 
 static inline void fp_regs_set(int features, unsigned int val)
 {
+#if __COBALT_HAVE_VFP != 0
unsigned long long e[16];
unsigned int i;
 
@@ -34,12 +41,15 @@ static inline void fp_regs_set(int features, unsigned int 
val)
__asm__ __volatile__("ldc p11, cr0, [%0],#32*4":
 "=r"(i): "0"([0]): "memory");
}
+#endif
 }
 
 static inline unsigned int fp_regs_check(int features, unsigned int val,
 int (*report)(const char *fmt, ...))
 {
-   unsigned int result = val, i;
+   unsigned int result = val;
+#if __COBALT_HAVE_VFP != 0
+   unsigned int i;
unsigned long long e[16];
 
if (features & __COBALT_HAVE_VFP) {
@@ -54,6 +64,7 @@ static inline unsigned int fp_regs_check(int features, 
unsigned int val,
result = e[i];
}
}
+#endif
 
return result;
 }


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


[Xenomai-git] Don Mahurin : lib/cobalt/arm64: disable kuser tsc get setting for armv8/ aarch64

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 72af1a3025d822e3f19551cbde63fa17a259df82
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=72af1a3025d822e3f19551cbde63fa17a259df82

Author: Don Mahurin 
Date:   Fri May  8 10:37:36 2015 -0700

lib/cobalt/arm64: disable kuser tsc get setting for armv8/aarch64

---

 lib/cobalt/arch/arm64/features.c |4 
 1 file changed, 4 insertions(+)

diff --git a/lib/cobalt/arch/arm64/features.c b/lib/cobalt/arch/arm64/features.c
index edabcf2..7c7e76a 100644
--- a/lib/cobalt/arch/arm64/features.c
+++ b/lib/cobalt/arch/arm64/features.c
@@ -59,9 +59,13 @@ void cobalt_check_features(struct cobalt_featinfo *finfo)
 
page_size = sysconf(_SC_PAGESIZE);
 
+#ifndef __aarch64__
__xn_tscinfo.kuser_tsc_get =
(__xn_rdtsc_t *)(0x1004 -
((*(unsigned *)(0x0ffc) + 3) << 5));
+#else
+   __xn_tscinfo.kuser_tsc_get = 0;
+#endif
 
phys_addr = (unsigned long)__xn_tscinfo.kinfo.counter;
 


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


[Xenomai-git] Dmitriy Cherkasov : cobalt/arm64: update register struct usage for arm64

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ee80575e10619581c187891c122958ada437bd3a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ee80575e10619581c187891c122958ada437bd3a

Author: Dmitriy Cherkasov 
Date:   Thu May  7 13:58:14 2015 -0700

cobalt/arm64: update register struct usage for arm64

---

 .../arch/arm64/include/asm/xenomai/syscall.h   |   22 ++--
 kernel/cobalt/arch/arm64/mayday.c  |   20 +-
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h 
b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
index d80df77..f0a1090 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/syscall.h
@@ -36,21 +36,21 @@
 #define __xn_reg_sys(__regs)   ((__regs)->ARM_ORIG_r0)
 /* In OABI_COMPAT mode, handle both OABI and EABI userspace syscalls */
 #ifdef CONFIG_OABI_COMPAT
-#define __xn_syscall_p(__regs) (((__regs)->ARM_r7 == __NR_OABI_SYSCALL_BASE + 
XENO_ARM_SYSCALL) || \
-((__regs)->ARM_r7 == __ARM_NR_ipipe))
+#define __xn_syscall_p(__regs) (((__regs)->regs[7] == __NR_OABI_SYSCALL_BASE + 
XENO_ARM_SYSCALL) || \
+((__regs)->regs[7] == __ARM_NR_ipipe))
 #else /* !CONFIG_OABI_COMPAT */
-#define __xn_syscall_p(__regs) ((__regs)->ARM_r7 == __ARM_NR_ipipe)
+#define __xn_syscall_p(__regs) ((__regs)->regs[7] == __ARM_NR_ipipe)
 #endif /* !CONFIG_OABI_COMPAT */
 #define __xn_syscall(__regs)   (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
 
-#define __xn_reg_rval(__regs)  ((__regs)->ARM_r0)
-#define __xn_reg_arg1(__regs)  ((__regs)->ARM_r1)
-#define __xn_reg_arg2(__regs)  ((__regs)->ARM_r2)
-#define __xn_reg_arg3(__regs)  ((__regs)->ARM_r3)
-#define __xn_reg_arg4(__regs)  ((__regs)->ARM_r4)
-#define __xn_reg_arg5(__regs)  ((__regs)->ARM_r5)
-#define __xn_reg_pc(__regs)((__regs)->ARM_ip)
-#define __xn_reg_sp(__regs)((__regs)->ARM_sp)
+#define __xn_reg_rval(__regs)  ((__regs)->regs[0])
+#define __xn_reg_arg1(__regs)  ((__regs)->regs[1])
+#define __xn_reg_arg2(__regs)  ((__regs)->regs[2])
+#define __xn_reg_arg3(__regs)  ((__regs)->regs[3])
+#define __xn_reg_arg4(__regs)  ((__regs)->regs[4])
+#define __xn_reg_arg5(__regs)  ((__regs)->regs[5])
+#define __xn_reg_pc(__regs)((__regs)->ip)
+#define __xn_reg_sp(__regs)((__regs)->sp)
 
 static inline void __xn_error_return(struct pt_regs *regs, int v)
 {
diff --git a/kernel/cobalt/arch/arm64/mayday.c 
b/kernel/cobalt/arch/arm64/mayday.c
index 20e4559..bc51ad6 100644
--- a/kernel/cobalt/arch/arm64/mayday.c
+++ b/kernel/cobalt/arch/arm64/mayday.c
@@ -120,27 +120,27 @@ void *xnarch_get_mayday_page(void)
 void xnarch_handle_mayday(struct xnarchtcb *tcb, struct pt_regs *regs,
  unsigned long tramp)
 {
-   tcb->mayday.pc = regs->ARM_pc;
-   tcb->mayday.r0 = regs->ARM_r0;
+   tcb->mayday.pc = regs->pc;
+   tcb->mayday.r0 = regs->regs[0];
 #ifdef __ARM_EABI__
-   tcb->mayday.r7 = regs->ARM_r7;
+   tcb->mayday.r7 = regs->regs[7];
 #endif
 #ifdef CONFIG_ARM_THUMB
/* The code on the mayday page must be run in ARM mode */
-   tcb->mayday.psr = regs->ARM_cpsr;
-   regs->ARM_cpsr &= ~PSR_T_BIT;
+   tcb->mayday.psr = regs->cpsr;
+   regs->cpsr &= ~PSR_T_BIT;
 #endif
-   regs->ARM_pc = tramp;
+   regs->pc = tramp;
 }
 
 void xnarch_fixup_mayday(struct xnarchtcb *tcb, struct pt_regs *regs)
 {
-   regs->ARM_pc = tcb->mayday.pc;
-   regs->ARM_r0 = tcb->mayday.r0;
+   regs->pc = tcb->mayday.pc;
+   regs->regs[0] = tcb->mayday.r0;
 #ifdef __ARM_EABI__
-   regs->ARM_r7 = tcb->mayday.r7;
+   regs->regs[7] = tcb->mayday.r7;
 #endif
 #ifdef CONFIG_ARM_THUMB
-   regs->ARM_cpsr = tcb->mayday.psr;
+   regs->cpsr = tcb->mayday.psr;
 #endif
 }


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


[Xenomai-git] Philippe Gerum : lib/cobalt: modechk: rename assertion helper, fix header

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: dd131f1d6d76cc3aae14c542926f6622563b2062
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=dd131f1d6d76cc3aae14c542926f6622563b2062

Author: Philippe Gerum 
Date:   Mon Mar 13 15:51:31 2017 +0100

lib/cobalt: modechk: rename assertion helper, fix header

---

 include/cobalt/stdio.h  |4 
 include/cobalt/sys/cobalt.h |6 ++
 lib/cobalt/Makefile.am  |1 -
 lib/cobalt/assert_context.c |   40 
 lib/cobalt/cxaguard.c   |9 -
 lib/cobalt/internal.c   |   19 ++-
 lib/cobalt/malloc.c |7 +++
 lib/cobalt/printf.c |6 +++---
 8 files changed, 34 insertions(+), 58 deletions(-)

diff --git a/include/cobalt/stdio.h b/include/cobalt/stdio.h
index 81486d5..c915e6d 100644
--- a/include/cobalt/stdio.h
+++ b/include/cobalt/stdio.h
@@ -112,10 +112,6 @@ const char *rt_print_buffer_name(void);
 
 void rt_print_flush_buffers(void);
 
-void assert_nrt(void);
-
-__deprecated void assert_nrt_fast(void);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/include/cobalt/sys/cobalt.h b/include/cobalt/sys/cobalt.h
index e7c58d7..1da8a46 100644
--- a/include/cobalt/sys/cobalt.h
+++ b/include/cobalt/sys/cobalt.h
@@ -132,6 +132,12 @@ int cobalt_sched_weighted_prio(int policy,
 
 void cobalt_register_tsd_hook(struct cobalt_tsd_hook *th);
 
+void cobalt_assert_nrt(void);
+
+/* Use cobalt_assert_nrt() instead of: */
+__deprecated void assert_nrt(void);
+__deprecated void assert_nrt_fast(void);
+
 extern int __cobalt_control_bind;
 
 #ifdef __cplusplus
diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 6275eb4..c2d5956 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -14,7 +14,6 @@ libcobalt_la_LIBADD = \
../boilerplate/libboilerplate.la
 
 libcobalt_la_SOURCES = \
-   assert_context.c\
attr.c  \
clock.c \
cond.c  \
diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
deleted file mode 100644
index 11739db..000
--- a/lib/cobalt/assert_context.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Jan Kiszka .
- *
- * 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 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "current.h"
-#include "internal.h"
-
-void assert_nrt(void)
-{
-   if (cobalt_should_warn())
-   pthread_kill(pthread_self(), SIGDEBUG);
-}
-
-void assert_nrt_fast(void) /* OBSOLETE */
-{
-   assert_nrt();
-}
diff --git a/lib/cobalt/cxaguard.c b/lib/cobalt/cxaguard.c
index 13432af..6df471a 100644
--- a/lib/cobalt/cxaguard.c
+++ b/lib/cobalt/cxaguard.c
@@ -16,10 +16,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 #include 
+#include 
 #include 
 
-void assert_nrt(void);
-
 #ifdef __ARM_EABI__
 typedef uint32_t __cxa_guard_type;
 #else
@@ -32,7 +31,7 @@ int __real_cxa_guard_acquire(__cxa_guard_type *g);
 /* CXXABI 3.3.2 One-time Construction API */
 COBALT_IMPL(int, __cxa_guard_acquire, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
return __STD(__cxa_guard_acquire(g));
 }
 
@@ -41,7 +40,7 @@ void __real_cxa_guard_release(__cxa_guard_type *g);
 
 COBALT_IMPL(void, __cxa_guard_release, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
__STD(__cxa_guard_release(g));
 }
 
@@ -50,6 +49,6 @@ void __real_cxa_guard_abort(__cxa_guard_type *g);
 
 COBALT_IMPL(void, __cxa_guard_abort, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
__STD(__cxa_guard_abort(g));
 }
diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c
index 5b89db5..49744c4 100644
--- a/lib/cobalt/internal.c
+++ b/lib/cobalt/internal.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Philippe Gerum .
+ * Copyright (C) 2008, 2009 Jan Kiszka .
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,7 +31,7 @@
 #include 
 #include 
 #include 

[Xenomai-git] Philippe Gerum : lib/cobalt: modechk: fetch WARNSW flag from u_window

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: wip/modechk
Commit: bad288b6bab74cc230d1fc6e2d80f9e388be7d3e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bad288b6bab74cc230d1fc6e2d80f9e388be7d3e

Author: Philippe Gerum 
Date:   Mon Mar 13 12:33:37 2017 +0100

lib/cobalt: modechk: fetch WARNSW flag from u_window

---

 lib/cobalt/assert_context.c |   19 ++-
 lib/cobalt/internal.h   |5 +
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
index 625cb76..11739db 100644
--- a/lib/cobalt/assert_context.c
+++ b/lib/cobalt/assert_context.c
@@ -28,25 +28,10 @@
 #include "current.h"
 #include "internal.h"
 
-static void assert_nrt_inner(void)
-{
-   struct cobalt_threadstat stat;
-   int ret;
-
-   ret = cobalt_thread_stat(0, );
-   if (ret) {
-   warning("cobalt_thread_stat() failed: %s", strerror(-ret));
-   return;
-   }
-
-   if (stat.status & XNWARN)
-   pthread_kill(pthread_self(), SIGDEBUG);
-}
-
 void assert_nrt(void)
 {
-   if (!cobalt_is_relaxed())
-   assert_nrt_inner();
+   if (cobalt_should_warn())
+   pthread_kill(pthread_self(), SIGDEBUG);
 }
 
 void assert_nrt_fast(void) /* OBSOLETE */
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index fee3fe1..df1f7c0 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -32,6 +32,11 @@ static inline int cobalt_is_relaxed(void)
return cobalt_get_current_mode() & XNRELAX;
 }
 
+static inline int cobalt_should_warn(void)
+{
+   return (cobalt_get_current_mode() & (XNRELAX|XNWARN)) == XNWARN;
+}
+
 static inline
 struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow)
 {


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


[Xenomai-git] Philippe Gerum : lib/cobalt: move mode checking wrappers to static archive

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: a7243543ecca5d8cfe9b7a4d76cdb57ae252f6a9
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a7243543ecca5d8cfe9b7a4d76cdb57ae252f6a9

Author: Philippe Gerum 
Date:   Sun Mar 12 12:21:18 2017 +0100

lib/cobalt: move mode checking wrappers to static archive

The mode checking wrappers must reside in a static archive, so that
the linker will pull them on demand, dropping the requirement for
providing potentially conflicting placeholders for wrapped symbols
which may not be present in both C and C++ support libraries
(e.g. __cxa_guard_acquire/release/abort from the one-time C++
constructor API).

See http://www.xenomai.org/pipermail/xenomai/2017-March/037184.html

---

 configure.ac |   15 ++
 debian/libxenomai-dev.install|2 +-
 demo/alchemy/Makefile.am |5 ++--
 demo/alchemy/cobalt/Makefile.am  |   16 +--
 demo/posix/cobalt/Makefile.am|2 +-
 demo/posix/cyclictest/Makefile.am|6 ++--
 lib/boilerplate/init/bootstrap.c |   12 
 lib/cobalt/Makefile.am   |   24 ++--
 lib/cobalt/assert_context.c  |   13 -
 lib/cobalt/malloc-nowrap.c   |   30 
 lib/cobalt/malloc.c  |   33 ++
 lib/cobalt/{assert.wrappers => modechk.wrappers} |0
 lib/cobalt/wrappers.c|   12 
 lib/copperplate/regd/Makefile.am |2 +-
 scripts/wrap-link.sh |6 ++--
 scripts/xeno-config-cobalt.in|4 +--
 testsuite/clocktest/Makefile.am  |2 +-
 testsuite/gpiotest/Makefile.am   |4 +--
 testsuite/latency/Makefile.am|6 ++--
 testsuite/smokey/Makefile.am |2 +-
 testsuite/smokey/net_common/Makefile.am  |2 +-
 testsuite/spitest/Makefile.am|4 +--
 testsuite/switchtest/Makefile.am |6 ++--
 utils/analogy/Makefile.am|   18 ++--
 utils/autotune/Makefile.am   |2 +-
 utils/can/Makefile.am|6 ++--
 utils/corectl/Makefile.am|2 +-
 utils/hdb/Makefile.am|4 +--
 28 files changed, 150 insertions(+), 90 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4792e46..d5c5aaa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -796,19 +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"
+   modechk_wrappers="$topdir/lib/cobalt/modechk.wrappers"
cobalt_wrappers="$topdir/lib/cobalt/cobalt.wrappers"
if [[ $ac_cv_ld_file_option = yes ]]; then
-   XENO_POSIX_WRAPPERS="-Wl,@$assert_wrappers -Wl,@$cobalt_wrappers"
+   XENO_POSIX_WRAPPERS="-Wl,@$modechk_wrappers -Wl,@$cobalt_wrappers"
else
-   XENO_POSIX_WRAPPERS=`cat $assert_wrappers $cobalt_wrappers | \
+   XENO_POSIX_WRAPPERS=`cat $modechk_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], ["$assert_wrappers 
$cobalt_wrappers"])
+   AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ["$modechk_wrappers 
$cobalt_wrappers"])
 fi
 
 dnl
@@ -818,8 +818,11 @@ dnl
 
XENO_AUTOINIT_LDFLAGS='$(top_builddir)/lib/boilerplate/init/bootstrap-internal.o'"
 -Wl,--wrap=main -Wl,--dynamic-list=$topdir/scripts/dynlist.ld"
 AC_SUBST(XENO_AUTOINIT_LDFLAGS)
 
-XENO_CORE_LIB=$rtcore_type/lib${rtcore_type}.la
-AC_SUBST(XENO_CORE_LIB)
+XENO_CORE_LDADD="\$(top_builddir)/lib/$rtcore_type/lib${rtcore_type}.la"
+if test $rtcore_type = cobalt; then
+   XENO_CORE_LDADD="$XENO_CORE_LDADD \$(top_builddir)/lib/cobalt/libmodechk.a"
+fi
+AC_SUBST(XENO_CORE_LDADD)
 
 AC_SUBST(DOXYGEN_SHOW_INCLUDE_FILES)
 AC_SUBST(DOXYGEN_HAVE_DOT)
diff --git a/debian/libxenomai-dev.install b/debian/libxenomai-dev.install
index 6d7eb7b..9f95c35 100644
--- a/debian/libxenomai-dev.install
+++ b/debian/libxenomai-dev.install
@@ -2,6 +2,6 @@ usr/include
 usr/lib/*.la
 usr/lib/*.a
 usr/lib/*.so
-usr/lib/assert.wrappers
+usr/lib/modechk.wrappers
 usr/lib/cobalt.wrappers
 usr/lib/dynlist.ld
diff --git a/demo/alchemy/Makefile.am b/demo/alchemy/Makefile.am
index e6cda07..80def4f 100644
--- a/demo/alchemy/Makefile.am
+++ b/demo/alchemy/Makefile.am
@@ -13,8 +13,9 @@ cppflags =\
 ldadd =  

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

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: e462c8499eaff9c2ff1bf5a745a64613420a9aa1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e462c8499eaff9c2ff1bf5a745a64613420a9aa1

Author: Henning Schild 
Date:   Sun Mar 12 18:30:57 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/Makefile.am  |1 +
 lib/cobalt/cxaguard.c   |   55 +++
 lib/cobalt/modechk.wrappers |3 +++
 3 files changed, 59 insertions(+)

diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 6189755..6275eb4 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -53,6 +53,7 @@ libcobalt_la_CPPFLAGS =   \
 lib_LIBRARIES = libmodechk.a
 
 libmodechk_a_SOURCES = \
+   cxaguard.c  \
malloc.c\
malloc-nowrap.c
 
diff --git a/lib/cobalt/cxaguard.c b/lib/cobalt/cxaguard.c
new file mode 100644
index 000..13432af
--- /dev/null
+++ b/lib/cobalt/cxaguard.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2017 Henning Schild 
+ *
+ * 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 
+#include 
+
+void assert_nrt(void);
+
+#ifdef __ARM_EABI__
+typedef uint32_t __cxa_guard_type;
+#else
+typedef uint64_t __cxa_guard_type;
+#endif
+
+COBALT_DECL(int, __cxa_guard_acquire(__cxa_guard_type *g));
+int __real_cxa_guard_acquire(__cxa_guard_type *g);
+
+/* CXXABI 3.3.2 One-time Construction API */
+COBALT_IMPL(int, __cxa_guard_acquire, (__cxa_guard_type *g))
+{
+   assert_nrt();
+   return __STD(__cxa_guard_acquire(g));
+}
+
+COBALT_DECL(void, __cxa_guard_release(__cxa_guard_type *g));
+void __real_cxa_guard_release(__cxa_guard_type *g);
+
+COBALT_IMPL(void, __cxa_guard_release, (__cxa_guard_type *g))
+{
+   assert_nrt();
+   __STD(__cxa_guard_release(g));
+}
+
+COBALT_DECL(void, __cxa_guard_abort(__cxa_guard_type *g));
+void __real_cxa_guard_abort(__cxa_guard_type *g);
+
+COBALT_IMPL(void, __cxa_guard_abort, (__cxa_guard_type *g))
+{
+   assert_nrt();
+   __STD(__cxa_guard_abort(g));
+}
diff --git a/lib/cobalt/modechk.wrappers b/lib/cobalt/modechk.wrappers
index 7164858..65320ab 100644
--- a/lib/cobalt/modechk.wrappers
+++ b/lib/cobalt/modechk.wrappers
@@ -1,2 +1,5 @@
 --wrap malloc
 --wrap free
+--wrap __cxa_guard_acquire
+--wrap __cxa_guard_release
+--wrap __cxa_guard_abort


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


[Xenomai-git] Philippe Gerum : scripts/xeno-config: cobalt: add --[no-]mode-check switch

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: wip/modechk
Commit: d8f5eee72c5d4fb349d23f2d924645ccd12f8c9c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d8f5eee72c5d4fb349d23f2d924645ccd12f8c9c

Author: Philippe Gerum 
Date:   Mon Mar 13 10:50:34 2017 +0100

scripts/xeno-config: cobalt: add --[no-]mode-check switch

These switches control whether xeno-config should emit the linker
flags for interposing on a set of standard routines which may invoke
regular Linux system calls, triggering an assertion failure on entry
if the caller must switch to secondary mode.

For the assertion failure to trigger, PTHREAD_WARNSW must have been
set for the calling thread.

---

 doc/asciidoc/man1/xeno-config.adoc |   21 +++--
 scripts/xeno-config-cobalt.in  |   21 +
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/doc/asciidoc/man1/xeno-config.adoc 
b/doc/asciidoc/man1/xeno-config.adoc
index 62ab888..14acc67 100644
--- a/doc/asciidoc/man1/xeno-config.adoc
+++ b/doc/asciidoc/man1/xeno-config.adoc
@@ -35,7 +35,7 @@ SYNOPSIS
 
 *xeno-config* *--version*
 
-*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*--libdir*|*--user-libdir*]
+*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] 
[*--mode-check*|*no-mode-check*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*libdir*|*user-libdir*]
 
 DESCRIPTION
 
@@ -130,6 +130,23 @@ This flag makes sense when passed along with --ldflags
 only. *xeno-config* enables the Copperplate auto-init feature by
 default.
 
+*--mode-check*::
+*--no-mode-check*::
+
+Over Cobalt, a set of standard routines which may invoke regular Linux
+system calls can trigger an assertion failure on entry, if the caller
+must leave the real-time mode (aka "secondary mode switch") to execute
+such routine.
+
+The assertion failure is triggered if the calling thread has set the
+PTHREAD_WARNSW flag by a call to +pthread_setmode_np()+.
+
+By default, the mode checking routines are substituted to the original
+ones using the symbol wrapping mechanism also used for interposing on
+POSIX services. *--no-mode-check* disables such substitution.
+
+These flags make sense when passed along with --ldflags only.
+
 *--auto-init-solib*::
 
 This switch enables the auto-initialization feature described above
@@ -140,7 +157,7 @@ used for bootstrapping the initialization.
 The bootstrap code runs when the shared library is attached to a
 running executable, either because it appears in the static
 dependencies of this executable, or when loaded dynamically via the
-dlopen() interface.
++dlopen()+ interface.
 
 *--core*::
 Output the name of the real-time core the current Xenomai installation
diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index c014176..82815e1 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -52,9 +52,10 @@ Options :
 --prefix
 --[skin=]posix|vxworks|psos|alchemy|rtdm|smokey|cobalt
 --auto-init|auto-init-solib|no-auto-init
+--mode-check|no-mode-check
 --cflags
 --ldflags
---lib*-dir,--libdir,--user-libdir
+--lib*-dir|libdir|user-libdir
 --core
 --info
 --compat
@@ -109,6 +110,7 @@ do_cflags=
 do_setinit=
 do_autoinit=y
 do_autoinit_solib=
+do_mode_check=y
 
 while test $# -gt 0; do
 case "$1" in
@@ -191,6 +193,12 @@ while test $# -gt 0; do
--compat)
compat=y
 ;;
+   --mode-check)
+   do_mode_check=y
+   ;;
+   --no-mode-check)
+   do_mode_check=
+   ;;
 *)
  usage 1 1>&2
  ;;
@@ -235,7 +243,10 @@ if test x$do_ldflags = xy; then
echo "no API specified, missing --skin before --ldflags" 1>&2
exit 1
 fi
-ldflags="`dump_wrappers modechk.wrappers`"
+ldflags=
+if test x$do_mode_check = xy; then
+   ldflags="`dump_wrappers modechk.wrappers`"
+fi
 test x$compat = xy && ldflags="-ltrank $ldflags"
 copperplate=
 for skin in $skin_list; do
@@ -244,8 +255,10 @@ if test x$do_ldflags = xy; then
ldflags="`dump_wrappers cobalt.wrappers` $ldflags"
;;
cobalt)
-   # do NOT wrap POSIX symbols in application code
-   # with --cobalt. On the contrary, --posix does.
+   # do NOT wrap POSIX symbols in application code with
+   # --cobalt. On the contrary, --posix does. This switch
+   # does not affect mode checking wrappers,
+   # --[no-]mode-check does.
;;
vxworks|psos|alchemy|smokey)
copperplate="-lcopperplate"



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

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: wip/modechk
Commit: e462c8499eaff9c2ff1bf5a745a64613420a9aa1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e462c8499eaff9c2ff1bf5a745a64613420a9aa1

Author: Henning Schild 
Date:   Sun Mar 12 18:30:57 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/Makefile.am  |1 +
 lib/cobalt/cxaguard.c   |   55 +++
 lib/cobalt/modechk.wrappers |3 +++
 3 files changed, 59 insertions(+)

diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 6189755..6275eb4 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -53,6 +53,7 @@ libcobalt_la_CPPFLAGS =   \
 lib_LIBRARIES = libmodechk.a
 
 libmodechk_a_SOURCES = \
+   cxaguard.c  \
malloc.c\
malloc-nowrap.c
 
diff --git a/lib/cobalt/cxaguard.c b/lib/cobalt/cxaguard.c
new file mode 100644
index 000..13432af
--- /dev/null
+++ b/lib/cobalt/cxaguard.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2017 Henning Schild 
+ *
+ * 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 
+#include 
+
+void assert_nrt(void);
+
+#ifdef __ARM_EABI__
+typedef uint32_t __cxa_guard_type;
+#else
+typedef uint64_t __cxa_guard_type;
+#endif
+
+COBALT_DECL(int, __cxa_guard_acquire(__cxa_guard_type *g));
+int __real_cxa_guard_acquire(__cxa_guard_type *g);
+
+/* CXXABI 3.3.2 One-time Construction API */
+COBALT_IMPL(int, __cxa_guard_acquire, (__cxa_guard_type *g))
+{
+   assert_nrt();
+   return __STD(__cxa_guard_acquire(g));
+}
+
+COBALT_DECL(void, __cxa_guard_release(__cxa_guard_type *g));
+void __real_cxa_guard_release(__cxa_guard_type *g);
+
+COBALT_IMPL(void, __cxa_guard_release, (__cxa_guard_type *g))
+{
+   assert_nrt();
+   __STD(__cxa_guard_release(g));
+}
+
+COBALT_DECL(void, __cxa_guard_abort(__cxa_guard_type *g));
+void __real_cxa_guard_abort(__cxa_guard_type *g);
+
+COBALT_IMPL(void, __cxa_guard_abort, (__cxa_guard_type *g))
+{
+   assert_nrt();
+   __STD(__cxa_guard_abort(g));
+}
diff --git a/lib/cobalt/modechk.wrappers b/lib/cobalt/modechk.wrappers
index 7164858..65320ab 100644
--- a/lib/cobalt/modechk.wrappers
+++ b/lib/cobalt/modechk.wrappers
@@ -1,2 +1,5 @@
 --wrap malloc
 --wrap free
+--wrap __cxa_guard_acquire
+--wrap __cxa_guard_release
+--wrap __cxa_guard_abort


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


[Xenomai-git] Philippe Gerum : lib/cobalt: modechk: rename assertion helper, fix header

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: wip/modechk
Commit: dd131f1d6d76cc3aae14c542926f6622563b2062
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=dd131f1d6d76cc3aae14c542926f6622563b2062

Author: Philippe Gerum 
Date:   Mon Mar 13 15:51:31 2017 +0100

lib/cobalt: modechk: rename assertion helper, fix header

---

 include/cobalt/stdio.h  |4 
 include/cobalt/sys/cobalt.h |6 ++
 lib/cobalt/Makefile.am  |1 -
 lib/cobalt/assert_context.c |   40 
 lib/cobalt/cxaguard.c   |9 -
 lib/cobalt/internal.c   |   19 ++-
 lib/cobalt/malloc.c |7 +++
 lib/cobalt/printf.c |6 +++---
 8 files changed, 34 insertions(+), 58 deletions(-)

diff --git a/include/cobalt/stdio.h b/include/cobalt/stdio.h
index 81486d5..c915e6d 100644
--- a/include/cobalt/stdio.h
+++ b/include/cobalt/stdio.h
@@ -112,10 +112,6 @@ const char *rt_print_buffer_name(void);
 
 void rt_print_flush_buffers(void);
 
-void assert_nrt(void);
-
-__deprecated void assert_nrt_fast(void);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/include/cobalt/sys/cobalt.h b/include/cobalt/sys/cobalt.h
index e7c58d7..1da8a46 100644
--- a/include/cobalt/sys/cobalt.h
+++ b/include/cobalt/sys/cobalt.h
@@ -132,6 +132,12 @@ int cobalt_sched_weighted_prio(int policy,
 
 void cobalt_register_tsd_hook(struct cobalt_tsd_hook *th);
 
+void cobalt_assert_nrt(void);
+
+/* Use cobalt_assert_nrt() instead of: */
+__deprecated void assert_nrt(void);
+__deprecated void assert_nrt_fast(void);
+
 extern int __cobalt_control_bind;
 
 #ifdef __cplusplus
diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 6275eb4..c2d5956 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -14,7 +14,6 @@ libcobalt_la_LIBADD = \
../boilerplate/libboilerplate.la
 
 libcobalt_la_SOURCES = \
-   assert_context.c\
attr.c  \
clock.c \
cond.c  \
diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
deleted file mode 100644
index 11739db..000
--- a/lib/cobalt/assert_context.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Jan Kiszka .
- *
- * 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 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "current.h"
-#include "internal.h"
-
-void assert_nrt(void)
-{
-   if (cobalt_should_warn())
-   pthread_kill(pthread_self(), SIGDEBUG);
-}
-
-void assert_nrt_fast(void) /* OBSOLETE */
-{
-   assert_nrt();
-}
diff --git a/lib/cobalt/cxaguard.c b/lib/cobalt/cxaguard.c
index 13432af..6df471a 100644
--- a/lib/cobalt/cxaguard.c
+++ b/lib/cobalt/cxaguard.c
@@ -16,10 +16,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 #include 
+#include 
 #include 
 
-void assert_nrt(void);
-
 #ifdef __ARM_EABI__
 typedef uint32_t __cxa_guard_type;
 #else
@@ -32,7 +31,7 @@ int __real_cxa_guard_acquire(__cxa_guard_type *g);
 /* CXXABI 3.3.2 One-time Construction API */
 COBALT_IMPL(int, __cxa_guard_acquire, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
return __STD(__cxa_guard_acquire(g));
 }
 
@@ -41,7 +40,7 @@ void __real_cxa_guard_release(__cxa_guard_type *g);
 
 COBALT_IMPL(void, __cxa_guard_release, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
__STD(__cxa_guard_release(g));
 }
 
@@ -50,6 +49,6 @@ void __real_cxa_guard_abort(__cxa_guard_type *g);
 
 COBALT_IMPL(void, __cxa_guard_abort, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
__STD(__cxa_guard_abort(g));
 }
diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c
index 5b89db5..49744c4 100644
--- a/lib/cobalt/internal.c
+++ b/lib/cobalt/internal.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Philippe Gerum .
+ * Copyright (C) 2008, 2009 Jan Kiszka .
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,7 +31,7 @@
 #include 
 #include 
 #include 

[Xenomai-git] Philippe Gerum : scripts/xeno-config: cobalt: add --[no-]mode-check switch

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: d8f5eee72c5d4fb349d23f2d924645ccd12f8c9c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d8f5eee72c5d4fb349d23f2d924645ccd12f8c9c

Author: Philippe Gerum 
Date:   Mon Mar 13 10:50:34 2017 +0100

scripts/xeno-config: cobalt: add --[no-]mode-check switch

These switches control whether xeno-config should emit the linker
flags for interposing on a set of standard routines which may invoke
regular Linux system calls, triggering an assertion failure on entry
if the caller must switch to secondary mode.

For the assertion failure to trigger, PTHREAD_WARNSW must have been
set for the calling thread.

---

 doc/asciidoc/man1/xeno-config.adoc |   21 +++--
 scripts/xeno-config-cobalt.in  |   21 +
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/doc/asciidoc/man1/xeno-config.adoc 
b/doc/asciidoc/man1/xeno-config.adoc
index 62ab888..14acc67 100644
--- a/doc/asciidoc/man1/xeno-config.adoc
+++ b/doc/asciidoc/man1/xeno-config.adoc
@@ -35,7 +35,7 @@ SYNOPSIS
 
 *xeno-config* *--version*
 
-*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*--libdir*|*--user-libdir*]
+*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] 
[*--mode-check*|*no-mode-check*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*libdir*|*user-libdir*]
 
 DESCRIPTION
 
@@ -130,6 +130,23 @@ This flag makes sense when passed along with --ldflags
 only. *xeno-config* enables the Copperplate auto-init feature by
 default.
 
+*--mode-check*::
+*--no-mode-check*::
+
+Over Cobalt, a set of standard routines which may invoke regular Linux
+system calls can trigger an assertion failure on entry, if the caller
+must leave the real-time mode (aka "secondary mode switch") to execute
+such routine.
+
+The assertion failure is triggered if the calling thread has set the
+PTHREAD_WARNSW flag by a call to +pthread_setmode_np()+.
+
+By default, the mode checking routines are substituted to the original
+ones using the symbol wrapping mechanism also used for interposing on
+POSIX services. *--no-mode-check* disables such substitution.
+
+These flags make sense when passed along with --ldflags only.
+
 *--auto-init-solib*::
 
 This switch enables the auto-initialization feature described above
@@ -140,7 +157,7 @@ used for bootstrapping the initialization.
 The bootstrap code runs when the shared library is attached to a
 running executable, either because it appears in the static
 dependencies of this executable, or when loaded dynamically via the
-dlopen() interface.
++dlopen()+ interface.
 
 *--core*::
 Output the name of the real-time core the current Xenomai installation
diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index c014176..82815e1 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -52,9 +52,10 @@ Options :
 --prefix
 --[skin=]posix|vxworks|psos|alchemy|rtdm|smokey|cobalt
 --auto-init|auto-init-solib|no-auto-init
+--mode-check|no-mode-check
 --cflags
 --ldflags
---lib*-dir,--libdir,--user-libdir
+--lib*-dir|libdir|user-libdir
 --core
 --info
 --compat
@@ -109,6 +110,7 @@ do_cflags=
 do_setinit=
 do_autoinit=y
 do_autoinit_solib=
+do_mode_check=y
 
 while test $# -gt 0; do
 case "$1" in
@@ -191,6 +193,12 @@ while test $# -gt 0; do
--compat)
compat=y
 ;;
+   --mode-check)
+   do_mode_check=y
+   ;;
+   --no-mode-check)
+   do_mode_check=
+   ;;
 *)
  usage 1 1>&2
  ;;
@@ -235,7 +243,10 @@ if test x$do_ldflags = xy; then
echo "no API specified, missing --skin before --ldflags" 1>&2
exit 1
 fi
-ldflags="`dump_wrappers modechk.wrappers`"
+ldflags=
+if test x$do_mode_check = xy; then
+   ldflags="`dump_wrappers modechk.wrappers`"
+fi
 test x$compat = xy && ldflags="-ltrank $ldflags"
 copperplate=
 for skin in $skin_list; do
@@ -244,8 +255,10 @@ if test x$do_ldflags = xy; then
ldflags="`dump_wrappers cobalt.wrappers` $ldflags"
;;
cobalt)
-   # do NOT wrap POSIX symbols in application code
-   # with --cobalt. On the contrary, --posix does.
+   # do NOT wrap POSIX symbols in application code with
+   # --cobalt. On the contrary, --posix does. This switch
+   # does not affect mode checking wrappers,
+   # --[no-]mode-check does.
;;
vxworks|psos|alchemy|smokey)
copperplate="-lcopperplate"



[Xenomai-git] Philippe Gerum : lib/cobalt: modechk: fetch WARNSW flag from u_window

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: stable-3.0.x
Commit: bad288b6bab74cc230d1fc6e2d80f9e388be7d3e
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=bad288b6bab74cc230d1fc6e2d80f9e388be7d3e

Author: Philippe Gerum 
Date:   Mon Mar 13 12:33:37 2017 +0100

lib/cobalt: modechk: fetch WARNSW flag from u_window

---

 lib/cobalt/assert_context.c |   19 ++-
 lib/cobalt/internal.h   |5 +
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
index 625cb76..11739db 100644
--- a/lib/cobalt/assert_context.c
+++ b/lib/cobalt/assert_context.c
@@ -28,25 +28,10 @@
 #include "current.h"
 #include "internal.h"
 
-static void assert_nrt_inner(void)
-{
-   struct cobalt_threadstat stat;
-   int ret;
-
-   ret = cobalt_thread_stat(0, );
-   if (ret) {
-   warning("cobalt_thread_stat() failed: %s", strerror(-ret));
-   return;
-   }
-
-   if (stat.status & XNWARN)
-   pthread_kill(pthread_self(), SIGDEBUG);
-}
-
 void assert_nrt(void)
 {
-   if (!cobalt_is_relaxed())
-   assert_nrt_inner();
+   if (cobalt_should_warn())
+   pthread_kill(pthread_self(), SIGDEBUG);
 }
 
 void assert_nrt_fast(void) /* OBSOLETE */
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index fee3fe1..df1f7c0 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -32,6 +32,11 @@ static inline int cobalt_is_relaxed(void)
return cobalt_get_current_mode() & XNRELAX;
 }
 
+static inline int cobalt_should_warn(void)
+{
+   return (cobalt_get_current_mode() & (XNRELAX|XNWARN)) == XNWARN;
+}
+
 static inline
 struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow)
 {


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


[Xenomai-git] Philippe Gerum : lib/cobalt: modechk: rename assertion helper, fix header

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: wip/modechk
Commit: 8535143c109b453d9021dd9626867388ad488801
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8535143c109b453d9021dd9626867388ad488801

Author: Philippe Gerum 
Date:   Mon Mar 13 15:51:31 2017 +0100

lib/cobalt: modechk: rename assertion helper, fix header

---

 include/cobalt/stdio.h  |4 
 include/cobalt/sys/cobalt.h |6 ++
 lib/cobalt/Makefile.am  |1 -
 lib/cobalt/assert_context.c |   40 
 lib/cobalt/cxaguard.c   |9 -
 lib/cobalt/internal.c   |   19 ++-
 lib/cobalt/malloc.c |7 +++
 lib/cobalt/printf.c |6 +++---
 8 files changed, 34 insertions(+), 58 deletions(-)

diff --git a/include/cobalt/stdio.h b/include/cobalt/stdio.h
index 81486d5..c915e6d 100644
--- a/include/cobalt/stdio.h
+++ b/include/cobalt/stdio.h
@@ -112,10 +112,6 @@ const char *rt_print_buffer_name(void);
 
 void rt_print_flush_buffers(void);
 
-void assert_nrt(void);
-
-__deprecated void assert_nrt_fast(void);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/include/cobalt/sys/cobalt.h b/include/cobalt/sys/cobalt.h
index e7c58d7..1da8a46 100644
--- a/include/cobalt/sys/cobalt.h
+++ b/include/cobalt/sys/cobalt.h
@@ -132,6 +132,12 @@ int cobalt_sched_weighted_prio(int policy,
 
 void cobalt_register_tsd_hook(struct cobalt_tsd_hook *th);
 
+void cobalt_assert_nrt(void);
+
+/* Use cobalt_assert_nrt() instead of: */
+__deprecated void assert_nrt(void);
+__deprecated void assert_nrt_fast(void);
+
 extern int __cobalt_control_bind;
 
 #ifdef __cplusplus
diff --git a/lib/cobalt/Makefile.am b/lib/cobalt/Makefile.am
index 6275eb4..c2d5956 100644
--- a/lib/cobalt/Makefile.am
+++ b/lib/cobalt/Makefile.am
@@ -14,7 +14,6 @@ libcobalt_la_LIBADD = \
../boilerplate/libboilerplate.la
 
 libcobalt_la_SOURCES = \
-   assert_context.c\
attr.c  \
clock.c \
cond.c  \
diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
deleted file mode 100644
index 11739db..000
--- a/lib/cobalt/assert_context.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Jan Kiszka .
- *
- * 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 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "current.h"
-#include "internal.h"
-
-void assert_nrt(void)
-{
-   if (cobalt_should_warn())
-   pthread_kill(pthread_self(), SIGDEBUG);
-}
-
-void assert_nrt_fast(void) /* OBSOLETE */
-{
-   assert_nrt();
-}
diff --git a/lib/cobalt/cxaguard.c b/lib/cobalt/cxaguard.c
index 13432af..6df471a 100644
--- a/lib/cobalt/cxaguard.c
+++ b/lib/cobalt/cxaguard.c
@@ -16,10 +16,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 #include 
+#include 
 #include 
 
-void assert_nrt(void);
-
 #ifdef __ARM_EABI__
 typedef uint32_t __cxa_guard_type;
 #else
@@ -32,7 +31,7 @@ int __real_cxa_guard_acquire(__cxa_guard_type *g);
 /* CXXABI 3.3.2 One-time Construction API */
 COBALT_IMPL(int, __cxa_guard_acquire, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
return __STD(__cxa_guard_acquire(g));
 }
 
@@ -41,7 +40,7 @@ void __real_cxa_guard_release(__cxa_guard_type *g);
 
 COBALT_IMPL(void, __cxa_guard_release, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
__STD(__cxa_guard_release(g));
 }
 
@@ -50,6 +49,6 @@ void __real_cxa_guard_abort(__cxa_guard_type *g);
 
 COBALT_IMPL(void, __cxa_guard_abort, (__cxa_guard_type *g))
 {
-   assert_nrt();
+   cobalt_assert_nrt();
__STD(__cxa_guard_abort(g));
 }
diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c
index 5b89db5..49744c4 100644
--- a/lib/cobalt/internal.c
+++ b/lib/cobalt/internal.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011 Philippe Gerum .
+ * Copyright (C) 2008, 2009 Jan Kiszka .
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,7 +31,7 @@
 #include 
 #include 
 #include 

[Xenomai-git] Philippe Gerum : lib/cobalt: modechk: fetch WARNSW flag from u_window

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: wip/modechk
Commit: 080322b04a0ab5f76ee3d1a185fc456e585a2ae1
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=080322b04a0ab5f76ee3d1a185fc456e585a2ae1

Author: Philippe Gerum 
Date:   Mon Mar 13 12:33:37 2017 +0100

lib/cobalt: modechk: fetch WARNSW flag from u_window

---

 lib/cobalt/assert_context.c |   19 ++-
 lib/cobalt/internal.h   |5 +
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/lib/cobalt/assert_context.c b/lib/cobalt/assert_context.c
index 625cb76..11739db 100644
--- a/lib/cobalt/assert_context.c
+++ b/lib/cobalt/assert_context.c
@@ -28,25 +28,10 @@
 #include "current.h"
 #include "internal.h"
 
-static void assert_nrt_inner(void)
-{
-   struct cobalt_threadstat stat;
-   int ret;
-
-   ret = cobalt_thread_stat(0, );
-   if (ret) {
-   warning("cobalt_thread_stat() failed: %s", strerror(-ret));
-   return;
-   }
-
-   if (stat.status & XNWARN)
-   pthread_kill(pthread_self(), SIGDEBUG);
-}
-
 void assert_nrt(void)
 {
-   if (!cobalt_is_relaxed())
-   assert_nrt_inner();
+   if (cobalt_should_warn())
+   pthread_kill(pthread_self(), SIGDEBUG);
 }
 
 void assert_nrt_fast(void) /* OBSOLETE */
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index fee3fe1..df1f7c0 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -32,6 +32,11 @@ static inline int cobalt_is_relaxed(void)
return cobalt_get_current_mode() & XNRELAX;
 }
 
+static inline int cobalt_should_warn(void)
+{
+   return (cobalt_get_current_mode() & (XNRELAX|XNWARN)) == XNWARN;
+}
+
 static inline
 struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow)
 {


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


[Xenomai-git] Philippe Gerum : scripts/xeno-config: cobalt: add --[no-]mode-check switch

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: wip/modechk
Commit: ecc4b5385b1d9270b9b20ec738e4a59aaf0c156c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ecc4b5385b1d9270b9b20ec738e4a59aaf0c156c

Author: Philippe Gerum 
Date:   Mon Mar 13 10:50:34 2017 +0100

scripts/xeno-config: cobalt: add --[no-]mode-check switch

These switches control whether xeno-config should emit the linker
flags for interposing on a set of standard routines which may invoke
regular Linux system calls, triggering an assertion failure on entry
if the caller must switch to secondary mode.

For the assertion failure to trigger, PTHREAD_WARNSW must have been
set for the calling thread.

---

 doc/asciidoc/man1/xeno-config.adoc |   21 +++--
 scripts/xeno-config-cobalt.in  |   21 +
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/doc/asciidoc/man1/xeno-config.adoc 
b/doc/asciidoc/man1/xeno-config.adoc
index 62ab888..14acc67 100644
--- a/doc/asciidoc/man1/xeno-config.adoc
+++ b/doc/asciidoc/man1/xeno-config.adoc
@@ -35,7 +35,7 @@ SYNOPSIS
 
 *xeno-config* *--version*
 
-*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*--libdir*|*--user-libdir*]
+*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] 
[*--mode-check*|*no-mode-check*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*libdir*|*user-libdir*]
 
 DESCRIPTION
 
@@ -130,6 +130,23 @@ This flag makes sense when passed along with --ldflags
 only. *xeno-config* enables the Copperplate auto-init feature by
 default.
 
+*--mode-check*::
+*--no-mode-check*::
+
+Over Cobalt, a set of standard routines which may invoke regular Linux
+system calls can trigger an assertion failure on entry, if the caller
+must leave the real-time mode (aka "secondary mode switch") to execute
+such routine.
+
+The assertion failure is triggered if the calling thread has set the
+PTHREAD_WARNSW flag by a call to +pthread_setmode_np()+.
+
+By default, the mode checking routines are substituted to the original
+ones using the symbol wrapping mechanism also used for interposing on
+POSIX services. *--no-mode-check* disables such substitution.
+
+These flags make sense when passed along with --ldflags only.
+
 *--auto-init-solib*::
 
 This switch enables the auto-initialization feature described above
@@ -140,7 +157,7 @@ used for bootstrapping the initialization.
 The bootstrap code runs when the shared library is attached to a
 running executable, either because it appears in the static
 dependencies of this executable, or when loaded dynamically via the
-dlopen() interface.
++dlopen()+ interface.
 
 *--core*::
 Output the name of the real-time core the current Xenomai installation
diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index c014176..82815e1 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -52,9 +52,10 @@ Options :
 --prefix
 --[skin=]posix|vxworks|psos|alchemy|rtdm|smokey|cobalt
 --auto-init|auto-init-solib|no-auto-init
+--mode-check|no-mode-check
 --cflags
 --ldflags
---lib*-dir,--libdir,--user-libdir
+--lib*-dir|libdir|user-libdir
 --core
 --info
 --compat
@@ -109,6 +110,7 @@ do_cflags=
 do_setinit=
 do_autoinit=y
 do_autoinit_solib=
+do_mode_check=y
 
 while test $# -gt 0; do
 case "$1" in
@@ -191,6 +193,12 @@ while test $# -gt 0; do
--compat)
compat=y
 ;;
+   --mode-check)
+   do_mode_check=y
+   ;;
+   --no-mode-check)
+   do_mode_check=
+   ;;
 *)
  usage 1 1>&2
  ;;
@@ -235,7 +243,10 @@ if test x$do_ldflags = xy; then
echo "no API specified, missing --skin before --ldflags" 1>&2
exit 1
 fi
-ldflags="`dump_wrappers modechk.wrappers`"
+ldflags=
+if test x$do_mode_check = xy; then
+   ldflags="`dump_wrappers modechk.wrappers`"
+fi
 test x$compat = xy && ldflags="-ltrank $ldflags"
 copperplate=
 for skin in $skin_list; do
@@ -244,8 +255,10 @@ if test x$do_ldflags = xy; then
ldflags="`dump_wrappers cobalt.wrappers` $ldflags"
;;
cobalt)
-   # do NOT wrap POSIX symbols in application code
-   # with --cobalt. On the contrary, --posix does.
+   # do NOT wrap POSIX symbols in application code with
+   # --cobalt. On the contrary, --posix does. This switch
+   # does not affect mode checking wrappers,
+   # --[no-]mode-check does.
;;
vxworks|psos|alchemy|smokey)
copperplate="-lcopperplate"



[Xenomai-git] Philippe Gerum : scripts/xeno-config: cobalt: add --[no-]mode-check switch

2017-03-13 Thread git repository hosting
Module: xenomai-3
Branch: wip/modechk
Commit: 60daa48dfb4c785c7efb166d41a83a161d5ab29a
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=60daa48dfb4c785c7efb166d41a83a161d5ab29a

Author: Philippe Gerum 
Date:   Mon Mar 13 10:50:34 2017 +0100

scripts/xeno-config: cobalt: add --[no-]mode-check switch

These switches control whether xeno-config should emit the linker
flags interposing on a set of standard routines which may invoke
regular Linux system calls, triggering an assertion failure on entry
if the caller must switch to secondary mode.

For the assertion failure to trigger, PTHREAD_WARNSW must have been
set for the calling thread.

---

 doc/asciidoc/man1/xeno-config.adoc |   21 +++--
 scripts/xeno-config-cobalt.in  |   21 +
 2 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/doc/asciidoc/man1/xeno-config.adoc 
b/doc/asciidoc/man1/xeno-config.adoc
index 62ab888..14acc67 100644
--- a/doc/asciidoc/man1/xeno-config.adoc
+++ b/doc/asciidoc/man1/xeno-config.adoc
@@ -35,7 +35,7 @@ SYNOPSIS
 
 *xeno-config* *--version*
 
-*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*--libdir*|*--user-libdir*]
+*xeno-config* [*--cc*] [*--ccld*] [*--arch*] [*--prefix*] 
[*--posix|alchemy|rtdm|psos|vxworks|smokey*] [*--compat*] 
[*--auto-init*|*no-auto-init*] [*--auto-init-solib*] 
[*--mode-check*|*no-mode-check*] [*--cflags*] [*--ldflags*] 
[*--library-dir*|*libdir*|*user-libdir*]
 
 DESCRIPTION
 
@@ -130,6 +130,23 @@ This flag makes sense when passed along with --ldflags
 only. *xeno-config* enables the Copperplate auto-init feature by
 default.
 
+*--mode-check*::
+*--no-mode-check*::
+
+Over Cobalt, a set of standard routines which may invoke regular Linux
+system calls can trigger an assertion failure on entry, if the caller
+must leave the real-time mode (aka "secondary mode switch") to execute
+such routine.
+
+The assertion failure is triggered if the calling thread has set the
+PTHREAD_WARNSW flag by a call to +pthread_setmode_np()+.
+
+By default, the mode checking routines are substituted to the original
+ones using the symbol wrapping mechanism also used for interposing on
+POSIX services. *--no-mode-check* disables such substitution.
+
+These flags make sense when passed along with --ldflags only.
+
 *--auto-init-solib*::
 
 This switch enables the auto-initialization feature described above
@@ -140,7 +157,7 @@ used for bootstrapping the initialization.
 The bootstrap code runs when the shared library is attached to a
 running executable, either because it appears in the static
 dependencies of this executable, or when loaded dynamically via the
-dlopen() interface.
++dlopen()+ interface.
 
 *--core*::
 Output the name of the real-time core the current Xenomai installation
diff --git a/scripts/xeno-config-cobalt.in b/scripts/xeno-config-cobalt.in
index c014176..82815e1 100644
--- a/scripts/xeno-config-cobalt.in
+++ b/scripts/xeno-config-cobalt.in
@@ -52,9 +52,10 @@ Options :
 --prefix
 --[skin=]posix|vxworks|psos|alchemy|rtdm|smokey|cobalt
 --auto-init|auto-init-solib|no-auto-init
+--mode-check|no-mode-check
 --cflags
 --ldflags
---lib*-dir,--libdir,--user-libdir
+--lib*-dir|libdir|user-libdir
 --core
 --info
 --compat
@@ -109,6 +110,7 @@ do_cflags=
 do_setinit=
 do_autoinit=y
 do_autoinit_solib=
+do_mode_check=y
 
 while test $# -gt 0; do
 case "$1" in
@@ -191,6 +193,12 @@ while test $# -gt 0; do
--compat)
compat=y
 ;;
+   --mode-check)
+   do_mode_check=y
+   ;;
+   --no-mode-check)
+   do_mode_check=
+   ;;
 *)
  usage 1 1>&2
  ;;
@@ -235,7 +243,10 @@ if test x$do_ldflags = xy; then
echo "no API specified, missing --skin before --ldflags" 1>&2
exit 1
 fi
-ldflags="`dump_wrappers modechk.wrappers`"
+ldflags=
+if test x$do_mode_check = xy; then
+   ldflags="`dump_wrappers modechk.wrappers`"
+fi
 test x$compat = xy && ldflags="-ltrank $ldflags"
 copperplate=
 for skin in $skin_list; do
@@ -244,8 +255,10 @@ if test x$do_ldflags = xy; then
ldflags="`dump_wrappers cobalt.wrappers` $ldflags"
;;
cobalt)
-   # do NOT wrap POSIX symbols in application code
-   # with --cobalt. On the contrary, --posix does.
+   # do NOT wrap POSIX symbols in application code with
+   # --cobalt. On the contrary, --posix does. This switch
+   # does not affect mode checking wrappers,
+   # --[no-]mode-check does.
;;
vxworks|psos|alchemy|smokey)
copperplate="-lcopperplate"