summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-28 12:19:01 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-28 12:19:01 -0600
commit1398381d05cea7c71d83138e36d57b06278bfa33 (patch)
tree426c11fc6e2b9d8435180dea352d2409c229dd99 /nuttx
parent465f0eba5068ad78d659ad5c75cf3e91da60b8c3 (diff)
downloadpx4-nuttx-1398381d05cea7c71d83138e36d57b06278bfa33.tar.gz
px4-nuttx-1398381d05cea7c71d83138e36d57b06278bfa33.tar.bz2
px4-nuttx-1398381d05cea7c71d83138e36d57b06278bfa33.zip
Create a build structure that will (eventually) support using the VFS to manage named semaphores
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/configs/spark/composite/defconfig2
-rw-r--r--nuttx/configs/spark/nsh/defconfig2
-rw-r--r--nuttx/configs/spark/usbmsc/defconfig2
-rw-r--r--nuttx/configs/spark/usbnsh/defconfig2
-rw-r--r--nuttx/configs/spark/usbserial/defconfig2
-rw-r--r--nuttx/fs/Kconfig1
-rw-r--r--nuttx/fs/semaphore/Kconfig20
-rw-r--r--nuttx/fs/semaphore/Make.defs45
-rw-r--r--nuttx/include/semaphore.h9
-rw-r--r--nuttx/include/sys/syscall.h35
-rw-r--r--nuttx/syscall/syscall.csv6
-rw-r--r--nuttx/syscall/syscall_lookup.h17
12 files changed, 121 insertions, 22 deletions
diff --git a/nuttx/configs/spark/composite/defconfig b/nuttx/configs/spark/composite/defconfig
index 0dc4785c8..a9e5dc654 100644
--- a/nuttx/configs/spark/composite/defconfig
+++ b/nuttx/configs/spark/composite/defconfig
@@ -644,6 +644,8 @@ CONFIG_ARCH_HAVE_NET=y
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_FS_READABLE=y
CONFIG_FS_WRITABLE=y
+ONFIG_FS_NAMED_SEMAPHORES=y
+CONFIG_FS_NAMED_SEMPATH="/var/sem"
# CONFIG_FS_RAMMAP is not set
CONFIG_FS_FAT=y
CONFIG_FAT_LCNAMES=y
diff --git a/nuttx/configs/spark/nsh/defconfig b/nuttx/configs/spark/nsh/defconfig
index ae369d91e..ba2f2c000 100644
--- a/nuttx/configs/spark/nsh/defconfig
+++ b/nuttx/configs/spark/nsh/defconfig
@@ -644,6 +644,8 @@ CONFIG_ARCH_HAVE_NET=y
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_FS_READABLE=y
CONFIG_FS_WRITABLE=y
+ONFIG_FS_NAMED_SEMAPHORES=y
+CONFIG_FS_NAMED_SEMPATH="/var/sem"
# CONFIG_FS_RAMMAP is not set
CONFIG_FS_FAT=y
CONFIG_FAT_LCNAMES=y
diff --git a/nuttx/configs/spark/usbmsc/defconfig b/nuttx/configs/spark/usbmsc/defconfig
index 75034aa95..9dba9d6bc 100644
--- a/nuttx/configs/spark/usbmsc/defconfig
+++ b/nuttx/configs/spark/usbmsc/defconfig
@@ -608,6 +608,8 @@ CONFIG_ARCH_HAVE_NET=y
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_FS_READABLE=y
CONFIG_FS_WRITABLE=y
+ONFIG_FS_NAMED_SEMAPHORES=y
+CONFIG_FS_NAMED_SEMPATH="/var/sem"
# CONFIG_FS_RAMMAP is not set
CONFIG_FS_FAT=y
CONFIG_FAT_LCNAMES=y
diff --git a/nuttx/configs/spark/usbnsh/defconfig b/nuttx/configs/spark/usbnsh/defconfig
index c45baddfe..af299c3e7 100644
--- a/nuttx/configs/spark/usbnsh/defconfig
+++ b/nuttx/configs/spark/usbnsh/defconfig
@@ -598,6 +598,8 @@ CONFIG_CDCACM_PRODUCTSTR="CDC/ACM Serial"
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_FS_READABLE=y
CONFIG_FS_WRITABLE=y
+ONFIG_FS_NAMED_SEMAPHORES=y
+CONFIG_FS_NAMED_SEMPATH="/var/sem"
# CONFIG_FS_RAMMAP is not set
CONFIG_FS_FAT=y
# CONFIG_FAT_LCNAMES is not set
diff --git a/nuttx/configs/spark/usbserial/defconfig b/nuttx/configs/spark/usbserial/defconfig
index b3cf0a90c..d9dce6ff9 100644
--- a/nuttx/configs/spark/usbserial/defconfig
+++ b/nuttx/configs/spark/usbserial/defconfig
@@ -618,6 +618,8 @@ CONFIG_ARCH_HAVE_NET=y
CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
CONFIG_FS_READABLE=y
CONFIG_FS_WRITABLE=y
+ONFIG_FS_NAMED_SEMAPHORES=y
+CONFIG_FS_NAMED_SEMPATH="/var/sem"
# CONFIG_FS_RAMMAP is not set
CONFIG_FS_FAT=y
CONFIG_FAT_LCNAMES=y
diff --git a/nuttx/fs/Kconfig b/nuttx/fs/Kconfig
index 12a68e36b..cbb7c6ed9 100644
--- a/nuttx/fs/Kconfig
+++ b/nuttx/fs/Kconfig
@@ -48,6 +48,7 @@ config FS_WRITABLE
bool
default n
+source fs/semaphore/Kconfig
source fs/mmap/Kconfig
source fs/fat/Kconfig
source fs/nfs/Kconfig
diff --git a/nuttx/fs/semaphore/Kconfig b/nuttx/fs/semaphore/Kconfig
new file mode 100644
index 000000000..abf0bb9be
--- /dev/null
+++ b/nuttx/fs/semaphore/Kconfig
@@ -0,0 +1,20 @@
+#
+# For a description of the syntax of this configuration file,
+# see misc/tools/kconfig-language.txt.
+#
+
+config FS_NAMED_SEMAPHORES
+ bool "Named semaphore support"
+ default n
+ ---help---
+ Include support for named semaphores.
+
+if FS_NAMED_SEMAPHORES
+
+config FS_NAMED_SEMPATH
+ string "Path to semaphore storage"
+ default "/var/sem"
+ ---help---
+ The path to where named semaphores will exist in the VFS namespace.
+
+endif # FS_NAMED_SEMAPHORES
diff --git a/nuttx/fs/semaphore/Make.defs b/nuttx/fs/semaphore/Make.defs
new file mode 100644
index 000000000..1664abf28
--- /dev/null
+++ b/nuttx/fs/semaphore/Make.defs
@@ -0,0 +1,45 @@
+############################################################################
+# fs/semaphore/Make.defs
+#
+# Copyright (C) 2014 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <gnutt@nuttx.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+# Include named semaphore support
+
+ifneq ($(CONFIG_FS_NAMED_SEMAPHORES),0)
+
+# Include named semaphore build support
+
+DEPPATH += --dep-path semaphore
+VPATH += :semaphore
+CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)fs$(DELIM)semaphore}
+endif
diff --git a/nuttx/include/semaphore.h b/nuttx/include/semaphore.h
index 99f067824..5818f0fb7 100644
--- a/nuttx/include/semaphore.h
+++ b/nuttx/include/semaphore.h
@@ -129,15 +129,18 @@ struct timespec; /* Defined in time.h */
int sem_init(FAR sem_t *sem, int pshared, unsigned int value);
int sem_destroy(FAR sem_t *sem);
-FAR sem_t *sem_open(FAR const char *name, int oflag, ...);
-int sem_close(FAR sem_t *sem);
-int sem_unlink(FAR const char *name);
int sem_wait(FAR sem_t *sem);
int sem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime);
int sem_trywait(FAR sem_t *sem);
int sem_post(FAR sem_t *sem);
int sem_getvalue(FAR sem_t *sem, FAR int *sval);
+#ifdef CONFIG_FS_NAMED_SEMAPHORES
+FAR sem_t *sem_open(FAR const char *name, int oflag, ...);
+int sem_close(FAR sem_t *sem);
+int sem_unlink(FAR const char *name);
+#endif
+
#undef EXTERN
#ifdef __cplusplus
}
diff --git a/nuttx/include/sys/syscall.h b/nuttx/include/sys/syscall.h
index 6a350eb0a..4a85ee331 100644
--- a/nuttx/include/sys/syscall.h
+++ b/nuttx/include/sys/syscall.h
@@ -80,31 +80,42 @@
#define SYS_sched_setscheduler (CONFIG_SYS_RESERVED+10)
#define SYS_sched_unlock (CONFIG_SYS_RESERVED+11)
#define SYS_sched_yield (CONFIG_SYS_RESERVED+12)
-#define SYS_sem_close (CONFIG_SYS_RESERVED+13)
+#define SYS_set_errno (CONFIG_SYS_RESERVED+13)
+
+/* Semaphores */
+
#define SYS_sem_destroy (CONFIG_SYS_RESERVED+14)
-#define SYS_sem_open (CONFIG_SYS_RESERVED+15)
-#define SYS_sem_post (CONFIG_SYS_RESERVED+16)
-#define SYS_sem_timedwait (CONFIG_SYS_RESERVED+17)
-#define SYS_sem_trywait (CONFIG_SYS_RESERVED+18)
-#define SYS_sem_unlink (CONFIG_SYS_RESERVED+19)
-#define SYS_sem_wait (CONFIG_SYS_RESERVED+20)
-#define SYS_set_errno (CONFIG_SYS_RESERVED+21)
+#define SYS_sem_post (CONFIG_SYS_RESERVED+15)
+#define SYS_sem_timedwait (CONFIG_SYS_RESERVED+16)
+#define SYS_sem_trywait (CONFIG_SYS_RESERVED+17)
+#define SYS_sem_wait (CONFIG_SYS_RESERVED+18)
+
+/* Named semaphores */
+
+#ifdef CONFIG_FS_NAMED_SEMAPHORES
+# define SYS_sem_open (CONFIG_SYS_RESERVED+19)
+# define SYS_sem_close (CONFIG_SYS_RESERVED+20)
+# define SYS_sem_unlink (CONFIG_SYS_RESERVED+21)
+# define __SYS_task_create (CONFIG_SYS_RESERVED+22)
+#else
+# define __SYS_task_create (CONFIG_SYS_RESERVED+19)
+#endif
/* Task creation APIs based on global entry points cannot be use with
* address environments.
*/
#ifndef CONFIG_BUILD_KERNEL
-# define SYS_task_create (CONFIG_SYS_RESERVED+22)
-# define __SYS_task_delete (CONFIG_SYS_RESERVED+23)
+# define SYS_task_create __SYS_task_create
+# define __SYS_task_delete (__SYS_task_create+1)
/* pgalloc() is only available with address environments with the page
* allocator selected. MMU support from the CPU is also required.
*/
#else
-# define SYS_pgalloc (CONFIG_SYS_RESERVED+22)
-# define __SYS_task_delete (CONFIG_SYS_RESERVED+23)
+# define SYS_pgalloc __SYS_task_create
+# define __SYS_task_delete (__SYS_task_create+1)
#endif
# define SYS_task_delete __SYS_task_delete
diff --git a/nuttx/syscall/syscall.csv b/nuttx/syscall/syscall.csv
index 56f8518ed..218f33ae3 100644
--- a/nuttx/syscall/syscall.csv
+++ b/nuttx/syscall/syscall.csv
@@ -99,13 +99,13 @@
"sched_yield","sched.h","","int"
"seekdir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","void","FAR DIR*","off_t"
"select","sys/select.h","!defined(CONFIG_DISABLE_POLL) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","int","FAR fd_set*","FAR fd_set*","FAR fd_set*","FAR struct timeval*"
-"sem_close","semaphore.h","","int","FAR sem_t*"
+"sem_close","semaphore.h","defined(CONFIG_FS_NAMED_SEMAPHORES)","int","FAR sem_t*"
"sem_destroy","semaphore.h","","int","FAR sem_t*"
-"sem_open","semaphore.h","","FAR sem_t*","FAR const char*","int","..."
+"sem_open","semaphore.h","defined(CONFIG_FS_NAMED_SEMAPHORES)","FAR sem_t*","FAR const char*","int","..."
"sem_post","semaphore.h","","int","FAR sem_t*"
"sem_timedwait","semaphore.h","","int","FAR sem_t*","FAR const struct timespec *"
"sem_trywait","semaphore.h","","int","FAR sem_t*"
-"sem_unlink","semaphore.h","","int","FAR const char*"
+"sem_unlink","semaphore.h","defined(CONFIG_FS_NAMED_SEMAPHORES)","int","FAR const char*"
"sem_wait","semaphore.h","","int","FAR sem_t*"
"send","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","ssize_t","int","FAR const void*","size_t","int"
"sendfile","sys/sendfile.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_NET_SENDFILE)","ssize_t","int","int","FAR off_t*","size_t"
diff --git a/nuttx/syscall/syscall_lookup.h b/nuttx/syscall/syscall_lookup.h
index 9b14f9115..ad5d0495c 100644
--- a/nuttx/syscall/syscall_lookup.h
+++ b/nuttx/syscall/syscall_lookup.h
@@ -56,15 +56,24 @@ SYSCALL_LOOKUP(sched_setparam, 2, STUB_sched_setparam)
SYSCALL_LOOKUP(sched_setscheduler, 3, STUB_sched_setscheduler)
SYSCALL_LOOKUP(sched_unlock, 0, STUB_sched_unlock)
SYSCALL_LOOKUP(sched_yield, 0, STUB_sched_yield)
-SYSCALL_LOOKUP(sem_close, 1, STUB_sem_close)
+SYSCALL_LOOKUP(set_errno, 1, STUB_set_errno)
+
+/* Semaphores */
+
SYSCALL_LOOKUP(sem_destroy, 2, STUB_sem_destroy)
-SYSCALL_LOOKUP(sem_open, 6, STUB_sem_open)
SYSCALL_LOOKUP(sem_post, 1, STUB_sem_post)
SYSCALL_LOOKUP(sem_timedwait, 2, STUB_sem_timedwait)
SYSCALL_LOOKUP(sem_trywait, 1, STUB_sem_trywait)
-SYSCALL_LOOKUP(sem_unlink, 1, STUB_sem_unlink)
SYSCALL_LOOKUP(sem_wait, 1, STUB_sem_wait)
-SYSCALL_LOOKUP(set_errno, 1, STUB_set_errno)
+
+/* Named semaphores */
+
+#ifdef defined(CONFIG_FS_NAMED_SEMAPHORES)
+SYSCALL_LOOKUP(sem_open, 6, STUB_sem_open)
+SYSCALL_LOOKUP(sem_close, 1, STUB_sem_close)
+SYSCALL_LOOKUP(sem_unlink, 1, STUB_sem_unlink)
+#endif
+
#ifndef CONFIG_BUILD_KERNEL
SYSCALL_LOOKUP(task_create, 5, STUB_task_create)
#else