[Xenomai-git] 3.x build test report
next branch build test: git hash: 13f9fd49a3594794b9fd359f6c8588732a634ccb see: http://git.xenomai.org/xenomai-3.git/log/?id=13f9fd49a3594794b9fd359f6c8588732a634ccb Building /work/build/bx3/build-forge-next/multi_v7/3.10-arm-linux-gnueabihf-gcc-4.9.3: failed Building /work/build/bx3/build-forge-next/multi_v7/3.14-arm-linux-gnueabihf-gcc-4.9.3: failed Building /work/build/bx3/build-forge-next/multi_v7/3.18-arm-linux-gnueabihf-gcc-4.9.3: failed multi_v7/3.10-arm-linux-gnueabihf-gcc-4.9.3: failed with 5 warnings/errors See http://xenomai.org/build-test-next/multi_v7/3.10-arm-linux-gnueabihf-gcc-4.9.3/log.html#1 multi_v7/3.14-arm-linux-gnueabihf-gcc-4.9.3: failed with 7 warnings/errors See http://xenomai.org/build-test-next/multi_v7/3.14-arm-linux-gnueabihf-gcc-4.9.3/log.html#1 multi_v7/3.18-arm-linux-gnueabihf-gcc-4.9.3: failed with 13 warnings/errors See http://xenomai.org/build-test-next/multi_v7/3.18-arm-linux-gnueabihf-gcc-4.9.3/log.html#1 stable branch build test: git hash: e5390e53816d947fc25b537b3ff772911d45e46d see: http://git.xenomai.org/xenomai-3.git/log/?id=e5390e53816d947fc25b537b3ff772911d45e46d Building /work/build/bx3/build-forge-stable/multi_v7/3.10-arm-linux-gnueabihf-gcc-4.9.3: failed Building /work/build/bx3/build-forge-stable/multi_v7/3.14-arm-linux-gnueabihf-gcc-4.9.3: failed Building /work/build/bx3/build-forge-stable/multi_v7/3.18-arm-linux-gnueabihf-gcc-4.9.3: failed multi_v7/3.10-arm-linux-gnueabihf-gcc-4.9.3: failed with 5 warnings/errors See http://xenomai.org/build-test-stable-3.0.x/multi_v7/3.10-arm-linux-gnueabihf-gcc-4.9.3/log.html#1 multi_v7/3.14-arm-linux-gnueabihf-gcc-4.9.3: failed with 7 warnings/errors See http://xenomai.org/build-test-stable-3.0.x/multi_v7/3.14-arm-linux-gnueabihf-gcc-4.9.3/log.html#1 multi_v7/3.18-arm-linux-gnueabihf-gcc-4.9.3: failed with 13 warnings/errors See http://xenomai.org/build-test-stable-3.0.x/multi_v7/3.18-arm-linux-gnueabihf-gcc-4.9.3/log.html#1 ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/arm64: drop legacy pipeline patches
Module: xenomai-3 Branch: wip/dovetail Commit: a876e92435a78b6f514cdc8db2ff4dbe593e1fba URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a876e92435a78b6f514cdc8db2ff4dbe593e1fba Author: Philippe GerumDate: Sat May 21 09:55:45 2016 +0200 cobalt/arm64: drop legacy pipeline patches --- kernel/cobalt/arch/arm64/patches/README | 19 --- 1 file changed, 19 deletions(-) diff --git a/kernel/cobalt/arch/arm64/patches/README b/kernel/cobalt/arch/arm64/patches/README deleted file mode 100644 index e39758e..000 --- a/kernel/cobalt/arch/arm64/patches/README +++ /dev/null @@ -1,19 +0,0 @@ --- arch/arm64/patches - -Cobalt 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 -source tree as published by kernel.org. - -You may want to have a look at -http://xenomai.org/installing-xenomai-3-x/ for detailed information -about installing Xenomai. - -The Cobalt/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/rtdm: ignore base_minor setting for protocol devices
Module: xenomai-3 Branch: wip/dovetail Commit: 6a26cd97507be39402a633950786b62b9f1579b1 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6a26cd97507be39402a633950786b62b9f1579b1 Author: Philippe GerumDate: Wed Jun 15 10:50:56 2016 +0200 cobalt/rtdm: ignore base_minor setting for protocol devices --- kernel/cobalt/rtdm/device.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 6c6299f..6b78fa5 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -287,13 +287,13 @@ static int register_driver(struct rtdm_driver *drv) drv->device_count >= RTDM_MAX_MINOR) return -EINVAL; + if ((drv->device_flags & RTDM_NAMED_DEVICE) == 0) + goto done; + if (drv->base_minor < 0 || drv->base_minor >= RTDM_MAX_MINOR) return -EINVAL; - if ((drv->device_flags & RTDM_NAMED_DEVICE) == 0) - goto done; - ret = alloc_chrdev_region(, drv->base_minor, drv->device_count, drv->profile_info.name); if (ret) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/arm: drop legacy pipeline patches
Module: xenomai-3 Branch: wip/dovetail Commit: d1967ec5c3d3bb147badf9772a3819cfae5aa7e2 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d1967ec5c3d3bb147badf9772a3819cfae5aa7e2 Author: Philippe GerumDate: Sat May 21 09:55:01 2016 +0200 cobalt/arm: drop legacy pipeline patches --- kernel/cobalt/arch/arm/patches/README | 18 - .../arm/patches/ipipe-core-3.10.32-arm-10.patch|21353 - .../arm/patches/ipipe-core-3.14.44-arm-12.patch|22495 -- .../arm/patches/ipipe-core-3.18.20-arm-6.patch |23890 --- .../arch/arm/patches/ipipe-core-4.1.18-arm-1.patch |23942 5 files changed, 91698 deletions(-) Diff: http://git.xenomai.org/?p=xenomai-3.git;a=commitdiff;h=d1967ec5c3d3bb147badf9772a3819cfae5aa7e2 ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: allow up to 1024 minors per driver
Module: xenomai-3 Branch: wip/dovetail Commit: 98834bd6bd0edd168ec9fcdb4d6b5217f669d01f URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=98834bd6bd0edd168ec9fcdb4d6b5217f669d01f Author: Philippe GerumDate: Wed Jun 1 10:53:28 2016 +0200 cobalt/rtdm: allow up to 1024 minors per driver --- include/cobalt/kernel/rtdm/driver.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h index 1354d9a..42f0b73 100644 --- a/include/cobalt/kernel/rtdm/driver.h +++ b/include/cobalt/kernel/rtdm/driver.h @@ -94,7 +94,7 @@ enum rtdm_selecttype; /** @} Device Flags */ /** Maximum number of named devices per driver. */ -#define RTDM_MAX_MINOR 256 +#define RTDM_MAX_MINOR 1024 /** @} rtdm_device_register */ ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/powerpc: drop legacy pipeline patches
Module: xenomai-3 Branch: wip/dovetail Commit: 6d2cd418dcb8f2b91c9071b43c52bad90193f47a URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6d2cd418dcb8f2b91c9071b43c52bad90193f47a Author: Philippe GerumDate: Sat May 21 09:55:12 2016 +0200 cobalt/powerpc: drop legacy pipeline patches --- kernel/cobalt/arch/powerpc/patches/README | 18 - .../patches/ipipe-core-3.10.32-powerpc-6.patch |14664 -- .../patches/ipipe-core-3.14.44-powerpc-9.patch |15627 --- .../patches/ipipe-core-3.18.20-powerpc-3.patch |15631 --- .../patches/ipipe-core-4.1.18-powerpc-2.patch |15898 5 files changed, 61838 deletions(-) Diff: http://git.xenomai.org/?p=xenomai-3.git;a=commitdiff;h=6d2cd418dcb8f2b91c9071b43c52bad90193f47a ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/x86: drop legacy pipeline patches
Module: xenomai-3 Branch: wip/dovetail Commit: 6454973a59019185c1f773c84b57ff7a9e30d7cb URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6454973a59019185c1f773c84b57ff7a9e30d7cb Author: Philippe GerumDate: Sat May 21 09:55:21 2016 +0200 cobalt/x86: drop legacy pipeline patches --- kernel/cobalt/arch/x86/patches/README | 18 - .../x86/patches/ipipe-core-3.10.32-x86-6.patch |14918 --- .../x86/patches/ipipe-core-3.14.39-x86-9.patch |15562 --- .../x86/patches/ipipe-core-3.18.20-x86-3.patch |15409 --- .../arch/x86/patches/ipipe-core-4.1.18-x86-1.patch |15641 5 files changed, 61548 deletions(-) Diff: http://git.xenomai.org/?p=xenomai-3.git;a=commitdiff;h=6454973a59019185c1f773c84b57ff7a9e30d7cb ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate: provide count-leading/trailing-bits ops
Module: xenomai-3 Branch: wip/dovetail Commit: fe5b21b7faa0309fb46325989343c8722ade8107 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fe5b21b7faa0309fb46325989343c8722ade8107 Author: Philippe GerumDate: Tue Jun 7 10:10:17 2016 +0200 boilerplate: provide count-leading/trailing-bits ops --- include/boilerplate/compiler.h | 48 1 file changed, 48 insertions(+) diff --git a/include/boilerplate/compiler.h b/include/boilerplate/compiler.h index e558f73..0509e33 100644 --- a/include/boilerplate/compiler.h +++ b/include/boilerplate/compiler.h @@ -58,4 +58,52 @@ #define __deprecated __attribute__((__deprecated__)) #endif +#ifdef __cplusplus +extern "C" { +#endif + +void __invalid_operand_size(void); + +#define ctz(__v) \ + ({ \ + int __ret; \ + if (!__v) \ + __ret = sizeof(__v) * 8;\ + else\ + switch (sizeof(__v)) { \ + case sizeof(int): \ + __ret = __builtin_ctz((unsigned int)__v); \ + break; \ + case sizeof(long long): \ + __ret = __builtin_ctzll(__v); \ + break; \ + default:\ + __invalid_operand_size(); \ + } \ + __ret; \ + }) + +#define clz(__v) \ + ({ \ + int __ret; \ + if (!__v) \ + __ret = sizeof(__v) * 8;\ + else\ + switch (sizeof(__v)) { \ + case sizeof(int): \ + __ret = __builtin_clz((unsigned int)__v); \ + break; \ + case sizeof(long long): \ + __ret = __builtin_clzll(__v); \ + break; \ + default:\ + __invalid_operand_size(); \ + } \ + __ret; \ + }) + +#ifdef __cplusplus +} +#endif + #endif /* _BOILERPLATE_COMPILER_H */ ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: add base minor setting for named drivers
Module: xenomai-3 Branch: wip/dovetail Commit: c412063da3a4f4f4c1c4d72497f3ac2c54679d0f URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c412063da3a4f4f4c1c4d72497f3ac2c54679d0f Author: Philippe GerumDate: Wed Jun 1 11:18:22 2016 +0200 cobalt/rtdm: add base minor setting for named drivers Some character/named drivers may want to set a non-zero base minor for indexing their devices (e.g. GPIO banks). To this end, the new .base_minor field can be set in device driver descriptors. Most in-tree driver descriptors reside in static memory which guarantees that such field is zero when unspecified. CAUTION: existing out of tree drivers have to initialize .base_minor explicitly if the descriptor does not reside on clean memory. --- include/cobalt/kernel/rtdm/driver.h |2 ++ kernel/cobalt/rtdm/device.c | 19 +-- kernel/drivers/udd/udd.c|1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h index 42f0b73..bcf6e54 100644 --- a/include/cobalt/kernel/rtdm/driver.h +++ b/include/cobalt/kernel/rtdm/driver.h @@ -280,6 +280,8 @@ struct rtdm_driver { * allocate a chrdev region for named devices. */ int device_count; + /** Base minor for named devices. */ + int base_minor; /** Reserved area */ struct { union { diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 3e6a46b..6c6299f 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -283,17 +283,23 @@ static int register_driver(struct rtdm_driver *drv) return -EINVAL; } - if (drv->device_count <= 0) + if (drv->device_count <= 0 || + drv->device_count >= RTDM_MAX_MINOR) + return -EINVAL; + + if (drv->base_minor < 0 || + drv->base_minor >= RTDM_MAX_MINOR) return -EINVAL; if ((drv->device_flags & RTDM_NAMED_DEVICE) == 0) goto done; - ret = alloc_chrdev_region(, 0, drv->device_count, + ret = alloc_chrdev_region(, drv->base_minor, drv->device_count, drv->profile_info.name); if (ret) { - printk(XENO_WARNING "cannot allocate chrdev region %s[0..%d]\n", - drv->profile_info.name, drv->device_count - 1); + printk(XENO_WARNING "cannot allocate chrdev region %s[%d..%d]\n", + drv->profile_info.name, drv->base_minor, + drv->base_minor + drv->device_count - 1); return ret; } @@ -333,7 +339,7 @@ static void unregister_driver(struct rtdm_driver *drv) if (drv->device_flags & RTDM_NAMED_DEVICE) { cdev_del(>named.cdev); - unregister_chrdev_region(MKDEV(drv->named.major, 0), + unregister_chrdev_region(MKDEV(drv->named.major, drv->base_minor), drv->device_count); } } @@ -402,7 +408,8 @@ int rtdm_dev_register(struct rtdm_device *dev) if (drv->device_flags & RTDM_NAMED_DEVICE) { if (drv->device_flags & RTDM_FIXED_MINOR) { minor = dev->minor; - if (minor < 0 || minor >= drv->device_count) { + if (minor < 0 || + minor >= drv->base_minor + drv->device_count) { ret = -ENXIO; goto fail; } diff --git a/kernel/drivers/udd/udd.c b/kernel/drivers/udd/udd.c index 6f12235..e14ff0b 100644 --- a/kernel/drivers/udd/udd.c +++ b/kernel/drivers/udd/udd.c @@ -290,6 +290,7 @@ static inline int register_mapper(struct udd_device *udd) RTDM_SUBCLASS_GENERIC, 0); drv->device_flags = RTDM_NAMED_DEVICE|RTDM_FIXED_MINOR; drv->device_count = UDD_NR_MAPS; + drv->base_minor = 0; drv->ops = (struct rtdm_fd_ops){ .open = mapper_open, .close = mapper_close, ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: add accessor to kernel device struct
Module: xenomai-3 Branch: wip/dovetail Commit: 5d6e1161eaf4f6cd0fa2e8e0becb2596cb02300c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5d6e1161eaf4f6cd0fa2e8e0becb2596cb02300c Author: Philippe GerumDate: Sun Jun 19 20:39:19 2016 +0200 cobalt/rtdm: add accessor to kernel device struct Each RTDM device is mated to a regular kernel device object. Add rtdm_dev_to_kdev() to return the address of such object. --- include/cobalt/kernel/rtdm/driver.h |5 + 1 file changed, 5 insertions(+) diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h index bcf6e54..1133cca 100644 --- a/include/cobalt/kernel/rtdm/driver.h +++ b/include/cobalt/kernel/rtdm/driver.h @@ -398,6 +398,11 @@ void rtdm_dev_unregister(struct rtdm_device *device); #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */ +static inline struct device *rtdm_dev_to_kdev(struct rtdm_device *device) +{ + return device->kdev; +} + /* --- clock services --- */ static inline nanosecs_abs_t rtdm_clock_read(void) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: fix off-by-one error in device_count check
Module: xenomai-3 Branch: wip/dovetail Commit: 2ee27dcd5ff5501b7cf550680379e0319e5836c9 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2ee27dcd5ff5501b7cf550680379e0319e5836c9 Author: Philippe GerumDate: Wed Jun 15 10:51:45 2016 +0200 cobalt/rtdm: fix off-by-one error in device_count check --- kernel/cobalt/rtdm/device.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 6b78fa5..07ad1a6 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -284,7 +284,7 @@ static int register_driver(struct rtdm_driver *drv) } if (drv->device_count <= 0 || - drv->device_count >= RTDM_MAX_MINOR) + drv->device_count > RTDM_MAX_MINOR) return -EINVAL; if ((drv->device_flags & RTDM_NAMED_DEVICE) == 0) ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : testsuite/xeno-test-run: requesting /bin/sh is enough
Module: xenomai-3 Branch: wip/dovetail Commit: c67e05045133758a2f0cb9a47996453131c8bc51 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c67e05045133758a2f0cb9a47996453131c8bc51 Author: Philippe GerumDate: Tue Jun 7 18:17:48 2016 +0200 testsuite/xeno-test-run: requesting /bin/sh is enough --- testsuite/xeno-test/xeno-test-run-wrapper |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/xeno-test/xeno-test-run-wrapper b/testsuite/xeno-test/xeno-test-run-wrapper index e4d5aa8..24698bb 100644 --- a/testsuite/xeno-test/xeno-test-run-wrapper +++ b/testsuite/xeno-test/xeno-test-run-wrapper @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh XENO_TEST_IN="/tmp/xeno-test-in-$$" XENO_TEST_OUT="/tmp/xeno-test-out-$$" ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate: add AVL library
Module: xenomai-3 Branch: wip/dovetail Commit: 0e25606b1dd4c89d42ce5177023ceb2ab180c3f5 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0e25606b1dd4c89d42ce5177023ceb2ab180c3f5 Author: Philippe GerumDate: 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
[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: unlink main heap file on exit if no registry
Module: xenomai-3 Branch: wip/dovetail Commit: c7088a58d3412cd331bb3e3e1f9d1375ccecdcd7 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=c7088a58d3412cd331bb3e3e1f9d1375ccecdcd7 Author: Philippe GerumDate: Mon Jun 6 20:34:10 2016 +0200 copperplate/heapobj-pshared: unlink main heap file on exit if no registry sysregd removes the shared heap upon exit of the last process attached to the session. When registry support is disabled, make sure the backing file is unlinked upon exit of the main process. --- lib/copperplate/heapobj-pshared.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index bd9ea47..f4c6f37 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -678,6 +679,19 @@ out: return ret; } +#ifndef CONFIG_XENO_REGISTRY +static void unlink_main_heap(void) +{ + /* +* Only the master process run this when there is no registry +* support (i.e. the one which has initialized the main shared +* heap for the session). When the registry is enabled, +* sysregd does the housekeeping. +*/ + shm_unlink(main_pool.fsname); +} +#endif + static int create_main_heap(pid_t *cnode_r) { const char *session = __copperplate_setup_data.session_label; @@ -770,6 +784,10 @@ reset: ret = fchown(fd, geteuid(), getegid()); (void)ret; init: +#ifndef CONFIG_XENO_REGISTRY + atexit(unlink_main_heap); +#endif + ret = ftruncate(fd, 0); /* Clear all previous contents if any. */ if (__bterrno(ret)) goto unlink_fail; ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : copperplate/heapobj-pshared: introduce allocation bitmap
Module: xenomai-3 Branch: wip/dovetail Commit: 497af95d240458e758685d940d4eec6a5a9a4388 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=497af95d240458e758685d940d4eec6a5a9a4388 Author: Philippe GerumDate: Fri Jun 3 10:00:38 2016 +0200 copperplate/heapobj-pshared: introduce allocation bitmap Using a free list for maintaining pages leads to pathological execution times when releasing blocks obtained from huge heaps (i.e. hundreds of megabytes). Rework the core to use an allocation bitmap instead. --- lib/copperplate/heapobj-pshared.c | 424 + lib/copperplate/internal.h| 18 +- 2 files changed, 259 insertions(+), 183 deletions(-) diff --git a/lib/copperplate/heapobj-pshared.c b/lib/copperplate/heapobj-pshared.c index 8c5dac6..bd9ea47 100644 --- a/lib/copperplate/heapobj-pshared.c +++ b/lib/copperplate/heapobj-pshared.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -43,15 +44,7 @@ #include "xenomai/init.h" #include "internal.h" -#define HOBJ_PAGE_SHIFT9 /* 2^9 => 512 bytes */ -#define HOBJ_PAGE_SIZE (1U << HOBJ_PAGE_SHIFT) -#define HOBJ_PAGE_MASK (~(HOBJ_PAGE_SIZE-1)) -#define HOBJ_PAGE_ALIGN(addr) (((addr)+HOBJ_PAGE_SIZE-1)_PAGE_MASK) - -#define HOBJ_MINALIGNSZ (1U << 4) /* i.e. 16 bytes */ -#define HOBJ_MAXEXTSZ (1U << 31) /* i.e. 2Gb */ - -enum { +enum { /* FIXME: page_free redundant with bitmap */ page_free =0, page_cont =1, page_list =2 @@ -66,8 +59,9 @@ struct shared_extent { struct holder link; memoff_t membase; /* Base offset of page array */ memoff_t memlim;/* Offset limit of page array */ - memoff_t freelist; /* Head of free page list */ - struct page_entry pagemap[1]; /* Start of page map */ + memoff_t bitmap;/* Offset of allocation bitmap */ + int bitwords; /* 32bit words in bitmap */ + struct page_entry pagemap[0]; /* Start of page map */ }; /* @@ -117,24 +111,38 @@ static inline size_t __align_to(size_t size, size_t al) return ((size+al-1)&(~(al-1))); } -static inline size_t get_pagemap_size(size_t h) +static inline size_t get_pagemap_size(size_t h, + memoff_t *bmapoff, int *bmapwords) { + int nrpages = h >> HOBJ_PAGE_SHIFT, bitmapw; + size_t pagemapsz; + /* * Return the size of the meta data required to map 'h' bytes * of user memory in pages of HOBJ_PAGE_SIZE bytes. The meta * data includes the length of the extent descriptor, plus the -* length of the page mapping array. 'h' must be a multiple of -* HOBJ_PAGE_SIZE on entry. +* length of the page mapping array followed by the allocation +* bitmap. 'h' must be a multiple of HOBJ_PAGE_SIZE on entry. */ assert((h & ~HOBJ_PAGE_MASK) == 0); - return __align_to((h >> HOBJ_PAGE_SHIFT) * sizeof(struct page_entry) - + sizeof(struct shared_extent), HOBJ_MINALIGNSZ); + pagemapsz = __align_to(nrpages * sizeof(struct page_entry), + sizeof(uint32_t)); + bitmapw =__align_to(nrpages, 32) / 32; + if (bmapoff) + *bmapoff = offsetof(struct shared_extent, pagemap) + pagemapsz; + if (bmapwords) + *bmapwords = bitmapw; + + return __align_to(pagemapsz + + sizeof(struct shared_extent) + + bitmapw * sizeof(uint32_t), + HOBJ_MINALIGNSZ); } static void init_extent(void *base, struct shared_extent *extent) { - caddr_t freepage; - int n, lastpgnum; + int lastpgnum; + uint32_t *p; __holder_init_nocheck(base, >link); @@ -146,20 +154,18 @@ static void init_extent(void *base, struct shared_extent *extent) */ assert(lastpgnum >= 1); - /* Mark each page as free in the page map. */ - for (n = 0, freepage = __shref(base, extent->membase); -n < lastpgnum; n++, freepage += HOBJ_PAGE_SIZE) { - *((memoff_t *)freepage) = __shoff(base, freepage) + HOBJ_PAGE_SIZE; - extent->pagemap[n].type = page_free; - extent->pagemap[n].bcount = 0; - } - - *((memoff_t *)freepage) = 0; - extent->pagemap[lastpgnum].type = page_free; - extent->pagemap[lastpgnum].bcount = 0; + /* Mark all pages as free in the page map. */ + memset(extent->pagemap, 0, lastpgnum * sizeof(struct page_entry)); - /* The first page starts the free list of a new extent. */ - extent->freelist = extent->membase; + /* Clear the allocation bitmap. */ + p = __shref(base, extent->bitmap); + memset(p, 0, extent->bitwords * sizeof(uint32_t)); + /* +* Mark the unused trailing bits (due to
[Xenomai-git] Philippe Gerum : include/trank: add missing C bindings
Module: xenomai-3 Branch: wip/dovetail Commit: 7099d6464aead376db2bceef0ffae17c591a5d5d URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7099d6464aead376db2bceef0ffae17c591a5d5d Author: Philippe GerumDate: Thu Jun 2 16:17:54 2016 +0200 include/trank: add missing C bindings --- include/trank/posix/pthread.h |8 include/trank/rtdk.h |8 include/trank/trank.h |8 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/trank/posix/pthread.h b/include/trank/posix/pthread.h index 25e581d..a7364c5 100644 --- a/include/trank/posix/pthread.h +++ b/include/trank/posix/pthread.h @@ -21,6 +21,10 @@ #ifndef _XENOMAI_TRANK_POSIX_PTHREAD_H #define _XENOMAI_TRANK_POSIX_PTHREAD_H +#ifdef __cplusplus +extern "C" { +#endif + /** * Set the mode of the current thread (compatibility service) * @@ -76,10 +80,6 @@ static inline int pthread_set_name_np(pthread_t thread, return pthread_setname_np(thread, name); } -#ifdef __cplusplus -extern "C" { -#endif - int pthread_make_periodic_np(pthread_t thread, struct timespec *starttp, struct timespec *periodtp); diff --git a/include/trank/rtdk.h b/include/trank/rtdk.h index 6030785..e8bb6d1 100644 --- a/include/trank/rtdk.h +++ b/include/trank/rtdk.h @@ -20,6 +20,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + static inline void rt_print_auto_init(int enable) { /* stdio support is automatically enabled by libcobalt. */ @@ -27,4 +31,8 @@ static inline void rt_print_auto_init(int enable) static inline void rt_print_cleanup(void) { } +#ifdef __cplusplus +} +#endif + #endif /* _XENOMAI_TRANK_RTDK_H */ diff --git a/include/trank/trank.h b/include/trank/trank.h index 2477d45..cc68837 100644 --- a/include/trank/trank.h +++ b/include/trank/trank.h @@ -22,8 +22,16 @@ #ifdef __XENO_COMPAT__ +#ifdef __cplusplus +extern "C" { +#endif + void warning(const char *fmt, ...); +#ifdef __cplusplus +} +#endif + #define trank_warning(__fmt, __args...)\ warning("%s: " __fmt, __func__, ##__args) ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: ignore base_minor setting for protocol devices
Module: xenomai-3 Branch: next Commit: 6a26cd97507be39402a633950786b62b9f1579b1 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6a26cd97507be39402a633950786b62b9f1579b1 Author: Philippe GerumDate: Wed Jun 15 10:50:56 2016 +0200 cobalt/rtdm: ignore base_minor setting for protocol devices --- kernel/cobalt/rtdm/device.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 6c6299f..6b78fa5 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -287,13 +287,13 @@ static int register_driver(struct rtdm_driver *drv) drv->device_count >= RTDM_MAX_MINOR) return -EINVAL; + if ((drv->device_flags & RTDM_NAMED_DEVICE) == 0) + goto done; + if (drv->base_minor < 0 || drv->base_minor >= RTDM_MAX_MINOR) return -EINVAL; - if ((drv->device_flags & RTDM_NAMED_DEVICE) == 0) - goto done; - ret = alloc_chrdev_region(, drv->base_minor, drv->device_count, drv->profile_info.name); if (ret) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: add accessor to kernel device struct
Module: xenomai-3 Branch: next Commit: 5d6e1161eaf4f6cd0fa2e8e0becb2596cb02300c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5d6e1161eaf4f6cd0fa2e8e0becb2596cb02300c Author: Philippe GerumDate: Sun Jun 19 20:39:19 2016 +0200 cobalt/rtdm: add accessor to kernel device struct Each RTDM device is mated to a regular kernel device object. Add rtdm_dev_to_kdev() to return the address of such object. --- include/cobalt/kernel/rtdm/driver.h |5 + 1 file changed, 5 insertions(+) diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h index bcf6e54..1133cca 100644 --- a/include/cobalt/kernel/rtdm/driver.h +++ b/include/cobalt/kernel/rtdm/driver.h @@ -398,6 +398,11 @@ void rtdm_dev_unregister(struct rtdm_device *device); #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */ +static inline struct device *rtdm_dev_to_kdev(struct rtdm_device *device) +{ + return device->kdev; +} + /* --- clock services --- */ static inline nanosecs_abs_t rtdm_clock_read(void) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: fix off-by-one error in device_count check
Module: xenomai-3 Branch: next Commit: 2ee27dcd5ff5501b7cf550680379e0319e5836c9 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2ee27dcd5ff5501b7cf550680379e0319e5836c9 Author: Philippe GerumDate: Wed Jun 15 10:51:45 2016 +0200 cobalt/rtdm: fix off-by-one error in device_count check --- kernel/cobalt/rtdm/device.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 6b78fa5..07ad1a6 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -284,7 +284,7 @@ static int register_driver(struct rtdm_driver *drv) } if (drv->device_count <= 0 || - drv->device_count >= RTDM_MAX_MINOR) + drv->device_count > RTDM_MAX_MINOR) return -EINVAL; if ((drv->device_flags & RTDM_NAMED_DEVICE) == 0) ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: explain issues with driver registration
Module: xenomai-3 Branch: next Commit: 13f9fd49a3594794b9fd359f6c8588732a634ccb URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=13f9fd49a3594794b9fd359f6c8588732a634ccb Author: Philippe GerumDate: Sat Jun 25 11:23:22 2016 +0200 cobalt/rtdm: explain issues with driver registration --- kernel/cobalt/rtdm/device.c | 22 ++ 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 07ad1a6..d0df7fa 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -272,27 +272,38 @@ static int register_driver(struct rtdm_driver *drv) return 0; } - if (drv->profile_info.magic != ~RTDM_CLASS_MAGIC) + if (drv->profile_info.magic != ~RTDM_CLASS_MAGIC) { + XENO_WARN_ON_ONCE(COBALT, 1); return -EINVAL; + } switch (drv->device_flags & RTDM_DEVICE_TYPE_MASK) { case RTDM_NAMED_DEVICE: case RTDM_PROTOCOL_DEVICE: break; default: + printk(XENO_WARNING "%s has invalid device type (%#x)\n", + drv->profile_info.name, + drv->device_flags & RTDM_DEVICE_TYPE_MASK); return -EINVAL; } if (drv->device_count <= 0 || - drv->device_count > RTDM_MAX_MINOR) + drv->device_count > RTDM_MAX_MINOR) { + printk(XENO_WARNING "%s has invalid device count (%d)\n", + drv->profile_info.name, drv->device_count); return -EINVAL; + } if ((drv->device_flags & RTDM_NAMED_DEVICE) == 0) goto done; if (drv->base_minor < 0 || - drv->base_minor >= RTDM_MAX_MINOR) + drv->base_minor >= RTDM_MAX_MINOR) { + printk(XENO_WARNING "%s has invalid base minor (%d)\n", + drv->profile_info.name, drv->base_minor); return -EINVAL; + } ret = alloc_chrdev_region(, drv->base_minor, drv->device_count, drv->profile_info.name); @@ -305,8 +316,11 @@ static int register_driver(struct rtdm_driver *drv) cdev_init(>named.cdev, _dumb_fops); ret = cdev_add(>named.cdev, rdev, drv->device_count); - if (ret) + if (ret) { + printk(XENO_WARNING "cannot create cdev series for %s\n", + drv->profile_info.name); goto fail_cdev; + } drv->named.major = MAJOR(rdev); bitmap_zero(drv->minor_map, RTDM_MAX_MINOR); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: explain issues with driver registration
Module: xenomai-3 Branch: stable-3.0.x Commit: e5390e53816d947fc25b537b3ff772911d45e46d URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e5390e53816d947fc25b537b3ff772911d45e46d Author: Philippe GerumDate: Sat Jun 25 11:23:22 2016 +0200 cobalt/rtdm: explain issues with driver registration --- kernel/cobalt/rtdm/device.c | 22 ++ 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/kernel/cobalt/rtdm/device.c b/kernel/cobalt/rtdm/device.c index 07ad1a6..d0df7fa 100644 --- a/kernel/cobalt/rtdm/device.c +++ b/kernel/cobalt/rtdm/device.c @@ -272,27 +272,38 @@ static int register_driver(struct rtdm_driver *drv) return 0; } - if (drv->profile_info.magic != ~RTDM_CLASS_MAGIC) + if (drv->profile_info.magic != ~RTDM_CLASS_MAGIC) { + XENO_WARN_ON_ONCE(COBALT, 1); return -EINVAL; + } switch (drv->device_flags & RTDM_DEVICE_TYPE_MASK) { case RTDM_NAMED_DEVICE: case RTDM_PROTOCOL_DEVICE: break; default: + printk(XENO_WARNING "%s has invalid device type (%#x)\n", + drv->profile_info.name, + drv->device_flags & RTDM_DEVICE_TYPE_MASK); return -EINVAL; } if (drv->device_count <= 0 || - drv->device_count > RTDM_MAX_MINOR) + drv->device_count > RTDM_MAX_MINOR) { + printk(XENO_WARNING "%s has invalid device count (%d)\n", + drv->profile_info.name, drv->device_count); return -EINVAL; + } if ((drv->device_flags & RTDM_NAMED_DEVICE) == 0) goto done; if (drv->base_minor < 0 || - drv->base_minor >= RTDM_MAX_MINOR) + drv->base_minor >= RTDM_MAX_MINOR) { + printk(XENO_WARNING "%s has invalid base minor (%d)\n", + drv->profile_info.name, drv->base_minor); return -EINVAL; + } ret = alloc_chrdev_region(, drv->base_minor, drv->device_count, drv->profile_info.name); @@ -305,8 +316,11 @@ static int register_driver(struct rtdm_driver *drv) cdev_init(>named.cdev, _dumb_fops); ret = cdev_add(>named.cdev, rdev, drv->device_count); - if (ret) + if (ret) { + printk(XENO_WARNING "cannot create cdev series for %s\n", + drv->profile_info.name); goto fail_cdev; + } drv->named.major = MAJOR(rdev); bitmap_zero(drv->minor_map, RTDM_MAX_MINOR); ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/rtdm: add accessor to kernel device struct
Module: xenomai-3 Branch: stable-3.0.x Commit: 403d39c5777b0c1e3e97baf6adf8bd53986f036c URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=403d39c5777b0c1e3e97baf6adf8bd53986f036c Author: Philippe GerumDate: Sun Jun 19 20:39:19 2016 +0200 cobalt/rtdm: add accessor to kernel device struct Each RTDM device is mated to a regular kernel device object. Add rtdm_dev_to_kdev() to return the address of such object. --- include/cobalt/kernel/rtdm/driver.h |5 + 1 file changed, 5 insertions(+) diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h index bcf6e54..1133cca 100644 --- a/include/cobalt/kernel/rtdm/driver.h +++ b/include/cobalt/kernel/rtdm/driver.h @@ -398,6 +398,11 @@ void rtdm_dev_unregister(struct rtdm_device *device); #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */ +static inline struct device *rtdm_dev_to_kdev(struct rtdm_device *device) +{ + return device->kdev; +} + /* --- clock services --- */ static inline nanosecs_abs_t rtdm_clock_read(void) { ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : drivers/gpio: allow setting trigger type w/ GPIO_RTIOC_IRQEN
Module: xenomai-3 Branch: wip/drivers Commit: d4ef0363fe6fd10e9447ca3785b908d15729d2df URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d4ef0363fe6fd10e9447ca3785b908d15729d2df Author: Philippe GerumDate: Tue Jun 28 12:16:02 2016 +0200 drivers/gpio: allow setting trigger type w/ GPIO_RTIOC_IRQEN --- include/rtdm/uapi/gpio.h|9 - kernel/drivers/gpio/gpio-core.c | 31 +++ testsuite/gpiotest/gpiotest.c | 34 +++--- 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/include/rtdm/uapi/gpio.h b/include/rtdm/uapi/gpio.h index b0d4899..307e190 100644 --- a/include/rtdm/uapi/gpio.h +++ b/include/rtdm/uapi/gpio.h @@ -22,7 +22,14 @@ #define GPIO_RTIOC_DIR_OUT _IOW(RTDM_CLASS_GPIO, 0, int) #define GPIO_RTIOC_DIR_IN _IO(RTDM_CLASS_GPIO, 1) -#define GPIO_RTIOC_IRQEN _IO(RTDM_CLASS_GPIO, 2) +#define GPIO_RTIOC_IRQEN _IOW(RTDM_CLASS_GPIO, 2, int) /* GPIO trigger */ #define GPIO_RTIOC_IRQDIS _IO(RTDM_CLASS_GPIO, 3) +#define GPIO_TRIGGER_NONE 0x0 /* unspecified */ +#define GPIO_TRIGGER_EDGE_RISING 0x1 +#define GPIO_TRIGGER_EDGE_FALLING 0x2 +#define GPIO_TRIGGER_LEVEL_HIGH0x4 +#define GPIO_TRIGGER_LEVEL_LOW 0x8 +#define GPIO_TRIGGER_MASK 0xf + #endif /* !_RTDM_UAPI_GPIO_H */ diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c index e8a7ba1..6c1f351 100644 --- a/kernel/drivers/gpio/gpio-core.c +++ b/kernel/drivers/gpio/gpio-core.c @@ -44,10 +44,20 @@ static int gpio_pin_interrupt(rtdm_irq_t *irqh) return RTDM_IRQ_HANDLED; } -static int request_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin) +static int request_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin, + int trigger) { + static const int trigger_flags[] = { + IRQ_TYPE_EDGE_RISING, + IRQ_TYPE_EDGE_FALLING, + IRQ_TYPE_LEVEL_HIGH, + IRQ_TYPE_LEVEL_LOW, + }; + int irq_trigger, ret; unsigned int irq; - int ret; + + if (trigger & ~GPIO_TRIGGER_MASK) + return -EINVAL; ret = gpio_request(gpio, pin->name); if (ret) { @@ -66,6 +76,15 @@ static int request_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin) rtdm_event_clear(>event); irq = gpio_to_irq(gpio); + /* +* Assumes GPIO_TRIGGER_xx values are forming a continuous +* sequence of bits starting at bit #0. +*/ + if (trigger) { + irq_trigger = trigger_flags[ffs(trigger) - 1]; + irq_set_irq_type(irq, irq_trigger); + } + ret = rtdm_irq_request(>irqh, irq, gpio_pin_interrupt, 0, pin->name, pin); if (ret) { @@ -93,8 +112,8 @@ static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd, { struct rtdm_device *dev = rtdm_fd_device(fd); unsigned int gpio = rtdm_fd_minor(fd); + int ret = 0, val, trigger; struct rtdm_gpio_pin *pin; - int ret = 0, val; pin = container_of(dev, struct rtdm_gpio_pin, dev); @@ -109,7 +128,11 @@ static int gpio_pin_ioctl_nrt(struct rtdm_fd *fd, ret = gpio_direction_input(gpio); break; case GPIO_RTIOC_IRQEN: - ret = request_gpio_irq(gpio, pin); + ret = rtdm_safe_copy_from_user(fd, , + arg, sizeof(trigger)); + if (ret) + return ret; + ret = request_gpio_irq(gpio, pin, trigger); break; case GPIO_RTIOC_IRQDIS: release_gpio_irq(gpio, pin); diff --git a/testsuite/gpiotest/gpiotest.c b/testsuite/gpiotest/gpiotest.c index 0bdd39f..6e9ce5b 100644 --- a/testsuite/gpiotest/gpiotest.c +++ b/testsuite/gpiotest/gpiotest.c @@ -55,8 +55,21 @@ smokey_test_plugin(write_value, static int run_interrupt(struct smokey_test *t, int argc, char *const argv[]) { - const char *device = NULL; - int fd, ret; + static struct { + const char *name; + int flag; + } trigger_types[] = { + { .name = "edge", .flag = GPIO_TRIGGER_EDGE_RISING }, + { .name = "edge-rising", .flag = GPIO_TRIGGER_EDGE_RISING }, + { .name = "edge-falling", .flag = GPIO_TRIGGER_EDGE_FALLING }, + { .name = "edge-both", .flag = GPIO_TRIGGER_EDGE_FALLING|GPIO_TRIGGER_EDGE_RISING }, + { .name = "level", .flag = GPIO_TRIGGER_LEVEL_LOW }, + { .name = "level-low", .flag = GPIO_TRIGGER_LEVEL_LOW }, + { .name = "level-high", .flag = GPIO_TRIGGER_LEVEL_HIGH }, + { NULL, 0 }, + }; + const char *device = NULL, *trigname; + int fd, ret, trigger, n;
[Xenomai-git] Philippe Gerum : drivers/gpio: sanitize DEBUG mode switch
Module: xenomai-3 Branch: wip/drivers Commit: 8fa7b901f23558a382d91cb5c4d8648d909ca1b2 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=8fa7b901f23558a382d91cb5c4d8648d909ca1b2 Author: Philippe GerumDate: Tue Jun 28 10:49:17 2016 +0200 drivers/gpio: sanitize DEBUG mode switch --- kernel/drivers/gpio/Makefile|2 ++ kernel/drivers/gpio/gpio-core.c |3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/drivers/gpio/Makefile b/kernel/drivers/gpio/Makefile index e237279..c9e976f 100644 --- a/kernel/drivers/gpio/Makefile +++ b/kernel/drivers/gpio/Makefile @@ -1,4 +1,6 @@ +ccflags-$(CONFIG_XENO_DRIVERS_GPIO_DEBUG) := -DDEBUG + obj-$(CONFIG_XENO_DRIVERS_GPIO) += xeno_gpio.o xeno_gpio-y := gpio-core.o diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c index d9863d9..e8a7ba1 100644 --- a/kernel/drivers/gpio/gpio-core.c +++ b/kernel/drivers/gpio/gpio-core.c @@ -15,9 +15,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef CONFIG_XENO_DRIVERS_GPIO_DEBUG -#define DEBUG -#endif #include #include #include ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : drivers/spi: introduce iobufs.map_len to expose the mapping length
Module: xenomai-3 Branch: wip/drivers Commit: 944d71060834888551fb2834a9cd5cfb8d079f28 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=944d71060834888551fb2834a9cd5cfb8d079f28 Author: Philippe GerumDate: Tue Jun 28 10:41:33 2016 +0200 drivers/spi: introduce iobufs.map_len to expose the mapping length Overwriting iobufs.io_len for returning the length of the user-space mapping makes no sense, since both values have different meanings (DMA_ALIGNED(io_len) * 2 == map_len). --- include/rtdm/uapi/spi.h |1 + kernel/drivers/spi/spi-bcm2835.c |2 +- testsuite/spitest/spitest.c |4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/rtdm/uapi/spi.h b/include/rtdm/uapi/spi.h index 45bc92d..8f04237 100644 --- a/include/rtdm/uapi/spi.h +++ b/include/rtdm/uapi/spi.h @@ -30,6 +30,7 @@ struct rtdm_spi_iobufs { __u32 io_len; __u32 i_offset; __u32 o_offset; + __u32 map_len; }; #define SPI_RTIOC_SET_CONFIG _IOW(RTDM_CLASS_SPI, 0, struct rtdm_spi_config) diff --git a/kernel/drivers/spi/spi-bcm2835.c b/kernel/drivers/spi/spi-bcm2835.c index 02ebecd..118cfd5 100644 --- a/kernel/drivers/spi/spi-bcm2835.c +++ b/kernel/drivers/spi/spi-bcm2835.c @@ -409,7 +409,7 @@ static int bcm2835_set_iobufs(struct rtdm_spi_remote_slave *slave, p->i_offset = 0; p->o_offset = bcm->io_len / 2; - p->io_len = bcm->io_len; + p->map_len = bcm->io_len; return 0; } diff --git a/testsuite/spitest/spitest.c b/testsuite/spitest/spitest.c index 0609bad..40ef9a9 100644 --- a/testsuite/spitest/spitest.c +++ b/testsuite/spitest/spitest.c @@ -385,14 +385,14 @@ static int run_spi_transfer(struct smokey_test *t, int argc, char *const argv[]) if (!__T(ret, ioctl(fd, SPI_RTIOC_SET_IOBUFS, ))) return ret; - p = mmap(NULL, iobufs.io_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); + p = mmap(NULL, iobufs.map_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (!__Fassert(p == MAP_FAILED)) return -EINVAL; smokey_trace("input_area[%u..%u], output_area[%u..%u], mapping length=%u", iobufs.i_offset, iobufs.i_offset + TRANSFER_SIZE - 1, iobufs.o_offset, iobufs.o_offset + TRANSFER_SIZE - 1, -iobufs.io_len); +iobufs.map_len); i_area = p + iobufs.i_offset; o_area = p + iobufs.o_offset; ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : drivers/spi: enable GPIO-based chip select
Module: xenomai-3 Branch: wip/drivers Commit: 19b67f374050aa430a028078fe94633e57a8ff98 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=19b67f374050aa430a028078fe94633e57a8ff98 Author: Philippe GerumDate: Tue Jun 28 09:58:10 2016 +0200 drivers/spi: enable GPIO-based chip select --- kernel/drivers/spi/spi-device.c | 38 +- kernel/drivers/spi/spi-device.h |1 + kernel/drivers/spi/spi-master.c | 18 -- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/kernel/drivers/spi/spi-device.c b/kernel/drivers/spi/spi-device.c index 62482b2..08cf9b0 100644 --- a/kernel/drivers/spi/spi-device.c +++ b/kernel/drivers/spi/spi-device.c @@ -43,22 +43,14 @@ int rtdm_spi_add_remote_slave(struct rtdm_spi_remote_slave *slave, slave->config.speed_hz = spi->max_speed_hz; slave->config.mode = spi->mode; slave->master = master; - mutex_init(>ctl_lock); dev = >dev; dev->driver = >driver; dev->label = kasprintf(GFP_KERNEL, "%s/slave%d.%%d", dev_name(>dev), kmaster->bus_num); - if (dev->label == NULL) { - ret = -ENOMEM; - goto fail_label; - } - - dev->device_data = master; - ret = rtdm_dev_register(dev); - if (ret) - goto fail_register; + if (dev->label == NULL) + return -ENOMEM; if (gpio_is_valid(spi->cs_gpio)) slave->cs_gpio = spi->cs_gpio; @@ -68,21 +60,30 @@ int rtdm_spi_add_remote_slave(struct rtdm_spi_remote_slave *slave, slave->cs_gpio = kmaster->cs_gpios[spi->chip_select]; } - if (gpio_is_valid(slave->cs_gpio)) - dev_dbg(slave_to_kdev(slave), "using CS GPIO%d\n", - slave->cs_gpio); + if (gpio_is_valid(slave->cs_gpio)) { + ret = gpio_request(slave->cs_gpio, dev->label); + if (ret) + goto fail; + slave->cs_gpiod = gpio_to_desc(slave->cs_gpio); + if (slave->cs_gpiod == NULL) + goto fail; + } + + mutex_init(>ctl_lock); + + dev->device_data = master; + ret = rtdm_dev_register(dev); + if (ret) + goto fail; rtdm_lock_get_irqsave(>lock, c); list_add_tail(>next, >slaves); rtdm_lock_put_irqrestore(>lock, c); return 0; - -fail_register: +fail: kfree(dev->label); -fail_label: - return ret; } EXPORT_SYMBOL_GPL(rtdm_spi_add_remote_slave); @@ -93,6 +94,9 @@ void rtdm_spi_remove_remote_slave(struct rtdm_spi_remote_slave *slave) struct rtdm_device *dev; rtdm_lockctx_t c; + if (gpio_is_valid(slave->cs_gpio)) + gpio_free(slave->cs_gpio); + mutex_destroy(>ctl_lock); rtdm_lock_get_irqsave(>lock, c); list_del(>next); diff --git a/kernel/drivers/spi/spi-device.h b/kernel/drivers/spi/spi-device.h index fcfca90..ee43c38 100644 --- a/kernel/drivers/spi/spi-device.h +++ b/kernel/drivers/spi/spi-device.h @@ -30,6 +30,7 @@ struct rtdm_spi_master; struct rtdm_spi_remote_slave { u8 chip_select; int cs_gpio; + struct gpio_desc *cs_gpiod; struct rtdm_device dev; struct list_head next; struct rtdm_spi_config config; diff --git a/kernel/drivers/spi/spi-master.c b/kernel/drivers/spi/spi-master.c index 132a3b9..fe2ee40 100644 --- a/kernel/drivers/spi/spi-master.c +++ b/kernel/drivers/spi/spi-master.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "spi-master.h" static inline @@ -105,6 +106,7 @@ static int do_chip_select(struct rtdm_spi_remote_slave *slave) { /* master->bus_lock held */ struct rtdm_spi_master *master = slave->master; rtdm_lockctx_t c; + int state; if (slave->config.speed_hz == 0) return -EINVAL; /* Setup is missing. */ @@ -113,7 +115,11 @@ static int do_chip_select(struct rtdm_spi_remote_slave *slave) rtdm_lock_get_irqsave(>lock, c); if (master->cs != slave) { - master->ops->chip_select(slave, true); + if (gpio_is_valid(slave->cs_gpio)) { + state = !!(slave->config.mode & SPI_CS_HIGH); + gpiod_set_raw_value(slave->cs_gpiod, state); + } else + master->ops->chip_select(slave, true); master->cs = slave; } @@ -126,10 +132,18 @@ static void do_chip_deselect(struct rtdm_spi_remote_slave *slave) { /* master->bus_lock held */ struct rtdm_spi_master *master = slave->master; rtdm_lockctx_t c; + int state; rtdm_lock_get_irqsave(>lock, c); - master->ops->chip_select(slave, false);
[Xenomai-git] Philippe Gerum : drivers/spi: enable GPIO-based chip select
Module: xenomai-3 Branch: wip/drivers Commit: 2e3034e16e8ef107fff1168b23ef3708b15f888e URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2e3034e16e8ef107fff1168b23ef3708b15f888e Author: Philippe GerumDate: Tue Jun 28 09:58:10 2016 +0200 drivers/spi: enable GPIO-based chip select --- kernel/drivers/spi/spi-device.c | 38 +- kernel/drivers/spi/spi-device.h |1 + kernel/drivers/spi/spi-master.c | 17 +++-- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/kernel/drivers/spi/spi-device.c b/kernel/drivers/spi/spi-device.c index 62482b2..08cf9b0 100644 --- a/kernel/drivers/spi/spi-device.c +++ b/kernel/drivers/spi/spi-device.c @@ -43,22 +43,14 @@ int rtdm_spi_add_remote_slave(struct rtdm_spi_remote_slave *slave, slave->config.speed_hz = spi->max_speed_hz; slave->config.mode = spi->mode; slave->master = master; - mutex_init(>ctl_lock); dev = >dev; dev->driver = >driver; dev->label = kasprintf(GFP_KERNEL, "%s/slave%d.%%d", dev_name(>dev), kmaster->bus_num); - if (dev->label == NULL) { - ret = -ENOMEM; - goto fail_label; - } - - dev->device_data = master; - ret = rtdm_dev_register(dev); - if (ret) - goto fail_register; + if (dev->label == NULL) + return -ENOMEM; if (gpio_is_valid(spi->cs_gpio)) slave->cs_gpio = spi->cs_gpio; @@ -68,21 +60,30 @@ int rtdm_spi_add_remote_slave(struct rtdm_spi_remote_slave *slave, slave->cs_gpio = kmaster->cs_gpios[spi->chip_select]; } - if (gpio_is_valid(slave->cs_gpio)) - dev_dbg(slave_to_kdev(slave), "using CS GPIO%d\n", - slave->cs_gpio); + if (gpio_is_valid(slave->cs_gpio)) { + ret = gpio_request(slave->cs_gpio, dev->label); + if (ret) + goto fail; + slave->cs_gpiod = gpio_to_desc(slave->cs_gpio); + if (slave->cs_gpiod == NULL) + goto fail; + } + + mutex_init(>ctl_lock); + + dev->device_data = master; + ret = rtdm_dev_register(dev); + if (ret) + goto fail; rtdm_lock_get_irqsave(>lock, c); list_add_tail(>next, >slaves); rtdm_lock_put_irqrestore(>lock, c); return 0; - -fail_register: +fail: kfree(dev->label); -fail_label: - return ret; } EXPORT_SYMBOL_GPL(rtdm_spi_add_remote_slave); @@ -93,6 +94,9 @@ void rtdm_spi_remove_remote_slave(struct rtdm_spi_remote_slave *slave) struct rtdm_device *dev; rtdm_lockctx_t c; + if (gpio_is_valid(slave->cs_gpio)) + gpio_free(slave->cs_gpio); + mutex_destroy(>ctl_lock); rtdm_lock_get_irqsave(>lock, c); list_del(>next); diff --git a/kernel/drivers/spi/spi-device.h b/kernel/drivers/spi/spi-device.h index fcfca90..ee43c38 100644 --- a/kernel/drivers/spi/spi-device.h +++ b/kernel/drivers/spi/spi-device.h @@ -30,6 +30,7 @@ struct rtdm_spi_master; struct rtdm_spi_remote_slave { u8 chip_select; int cs_gpio; + struct gpio_desc *cs_gpiod; struct rtdm_device dev; struct list_head next; struct rtdm_spi_config config; diff --git a/kernel/drivers/spi/spi-master.c b/kernel/drivers/spi/spi-master.c index 132a3b9..35e0f55 100644 --- a/kernel/drivers/spi/spi-master.c +++ b/kernel/drivers/spi/spi-master.c @@ -105,6 +105,7 @@ static int do_chip_select(struct rtdm_spi_remote_slave *slave) { /* master->bus_lock held */ struct rtdm_spi_master *master = slave->master; rtdm_lockctx_t c; + int state; if (slave->config.speed_hz == 0) return -EINVAL; /* Setup is missing. */ @@ -113,7 +114,11 @@ static int do_chip_select(struct rtdm_spi_remote_slave *slave) rtdm_lock_get_irqsave(>lock, c); if (master->cs != slave) { - master->ops->chip_select(slave, true); + if (gpio_is_valid(slave->cs_gpio)) { + state = !!(slave->config.mode & SPI_CS_HIGH); + gpiod_set_raw_value(slave->cs_gpiod, state); + } else + master->ops->chip_select(slave, true); master->cs = slave; } @@ -126,10 +131,18 @@ static void do_chip_deselect(struct rtdm_spi_remote_slave *slave) { /* master->bus_lock held */ struct rtdm_spi_master *master = slave->master; rtdm_lockctx_t c; + int state; rtdm_lock_get_irqsave(>lock, c); - master->ops->chip_select(slave, false); + + if (gpio_is_valid(slave->cs_gpio)) { + state = !(slave->config.mode &