Module: xenomai-3
Branch: next
Commit: a9c523592e7d96ccf6bdc99df4e1cacf99f3b795
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a9c523592e7d96ccf6bdc99df4e1cacf99f3b795

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Thu Jul  2 22:22:13 2015 +0200

cobalt/kernel: Generate cobalt_syscalls and cobalt_sysmodes

Avoid that information has to be provided multiple times, specifically
the sensitive syscall modes. For that purpose, both entry points and
modes are picked up by a script from COBALT_SYSCALL macros in all
kernel/cobalt/posix/*.c files. These are translated into entries for
both tables and filled into a generated header. syscall.c can then
include the header and use the accumulating macros __COBALT_CALL_ENTRIES
and __COBALT_CALL_MODES in its table definitions.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 kernel/cobalt/posix/Makefile               |   12 ++
 kernel/cobalt/posix/gen-syscall-entries.sh |   32 +++++
 kernel/cobalt/posix/syscall.c              |  194 +---------------------------
 scripts/prepare-kernel.sh                  |    4 +-
 4 files changed, 50 insertions(+), 192 deletions(-)

diff --git a/kernel/cobalt/posix/Makefile b/kernel/cobalt/posix/Makefile
index 3049be4..2da764a 100644
--- a/kernel/cobalt/posix/Makefile
+++ b/kernel/cobalt/posix/Makefile
@@ -22,4 +22,16 @@ xenomai-y :=         \
        timer.o         \
        timerfd.o
 
+syscall_entries := $(srctree)/$(src)/gen-syscall-entries.sh
+
+quiet_cmd_syscall_entries = GEN     $@
+      cmd_syscall_entries = $(CONFIG_SHELL) '$(syscall_entries)' $^ > $@
+
+$(obj)/syscall_entries.h: $(syscall_entries) $(wildcard $(srctree)/$(src)/*.c)
+       $(call if_changed,syscall_entries)
+
+target += syscall_entries.h
+
+$(obj)/syscall.o: $(obj)/syscall_entries.h
+
 xenomai-$(CONFIG_XENO_ARCH_SYS3264) += compat.o syscall32.o
diff --git a/kernel/cobalt/posix/gen-syscall-entries.sh 
b/kernel/cobalt/posix/gen-syscall-entries.sh
new file mode 100755
index 0000000..0f99fff
--- /dev/null
+++ b/kernel/cobalt/posix/gen-syscall-entries.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+
+set -e
+
+shift
+
+awk '
+match($0, /COBALT_SYSCALL\([^,]*,[ \t]*[^,]*/)  {
+       str=substr($0, RSTART + 15, RLENGTH - 15)
+       match(str, /[^, \t]*/)
+       syscall=substr(str, RSTART, RLENGTH)
+
+       if (syscall == "") {
+               print "Failed to find syscall name in line " $0 > "/dev/stderr"
+               exit 1
+       }
+
+       calls = calls " __COBALT_CALL_ENTRY(" syscall ") \\\n"
+       modes = modes " __COBALT_MODE(" str ") \\\n"
+       next
+}
+
+/COBALT_SYSCALL\(/  {
+       print "Failed to parse line " $0 > "/dev/stderr"
+       exit 1
+}
+
+END {
+       print "#define __COBALT_CALL_ENTRIES \\\n" calls "      /* end */"
+       print "#define __COBALT_CALL_MODES \\\n" modes "        /* end */"
+}
+' $*
diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 9677f41..a128dea 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -608,103 +608,11 @@ static int cobalt_ni(void)
 #include "syscall32.h"
 #endif
 
+#include "syscall_entries.h"
+
 static const cobalt_syshand cobalt_syscalls[] = {
        __COBALT_CALL_NI
-       __COBALT_CALL_ENTRY(thread_create)
-       __COBALT_CALL_ENTRY(thread_getpid)
-       __COBALT_CALL_ENTRY(thread_setschedparam_ex)
-       __COBALT_CALL_ENTRY(thread_getschedparam_ex)
-       __COBALT_CALL_ENTRY(sched_weightprio)
-       __COBALT_CALL_ENTRY(sched_yield)
-       __COBALT_CALL_ENTRY(thread_setmode)
-       __COBALT_CALL_ENTRY(thread_setname)
-       __COBALT_CALL_ENTRY(thread_kill)
-       __COBALT_CALL_ENTRY(thread_getstat)
-       __COBALT_CALL_ENTRY(thread_join)
-       __COBALT_CALL_ENTRY(sem_init)
-       __COBALT_CALL_ENTRY(sem_destroy)
-       __COBALT_CALL_ENTRY(sem_post)
-       __COBALT_CALL_ENTRY(sem_wait)
-       __COBALT_CALL_ENTRY(sem_timedwait)
-       __COBALT_CALL_ENTRY(sem_trywait)
-       __COBALT_CALL_ENTRY(sem_getvalue)
-       __COBALT_CALL_ENTRY(sem_open)
-       __COBALT_CALL_ENTRY(sem_close)
-       __COBALT_CALL_ENTRY(sem_unlink)
-       __COBALT_CALL_ENTRY(sem_broadcast_np)
-       __COBALT_CALL_ENTRY(sem_inquire)
-       __COBALT_CALL_ENTRY(clock_getres)
-       __COBALT_CALL_ENTRY(clock_gettime)
-       __COBALT_CALL_ENTRY(clock_settime)
-       __COBALT_CALL_ENTRY(clock_nanosleep)
-       __COBALT_CALL_ENTRY(mutex_init)
-       __COBALT_CALL_ENTRY(mutex_check_init)
-       __COBALT_CALL_ENTRY(mutex_destroy)
-       __COBALT_CALL_ENTRY(mutex_lock)
-       __COBALT_CALL_ENTRY(mutex_timedlock)
-       __COBALT_CALL_ENTRY(mutex_trylock)
-       __COBALT_CALL_ENTRY(mutex_unlock)
-       __COBALT_CALL_ENTRY(cond_init)
-       __COBALT_CALL_ENTRY(cond_destroy)
-       __COBALT_CALL_ENTRY(cond_wait_prologue)
-       __COBALT_CALL_ENTRY(cond_wait_epilogue)
-       __COBALT_CALL_ENTRY(mq_open)
-       __COBALT_CALL_ENTRY(mq_close)
-       __COBALT_CALL_ENTRY(mq_unlink)
-       __COBALT_CALL_ENTRY(mq_getattr)
-       __COBALT_CALL_ENTRY(mq_timedsend)
-       __COBALT_CALL_ENTRY(mq_timedreceive)
-       __COBALT_CALL_ENTRY(mq_notify)
-       __COBALT_CALL_ENTRY(sigwait)
-       __COBALT_CALL_ENTRY(sigwaitinfo)
-       __COBALT_CALL_ENTRY(sigtimedwait)
-       __COBALT_CALL_ENTRY(sigpending)
-       __COBALT_CALL_ENTRY(kill)
-       __COBALT_CALL_ENTRY(sigqueue)
-       __COBALT_CALL_ENTRY(timer_create)
-       __COBALT_CALL_ENTRY(timer_delete)
-       __COBALT_CALL_ENTRY(timer_settime)
-       __COBALT_CALL_ENTRY(timer_gettime)
-       __COBALT_CALL_ENTRY(timer_getoverrun)
-       __COBALT_CALL_ENTRY(timerfd_create)
-       __COBALT_CALL_ENTRY(timerfd_gettime)
-       __COBALT_CALL_ENTRY(timerfd_settime)
-       __COBALT_CALL_ENTRY(select)
-       __COBALT_CALL_ENTRY(sched_minprio)
-       __COBALT_CALL_ENTRY(sched_maxprio)
-       __COBALT_CALL_ENTRY(monitor_init)
-       __COBALT_CALL_ENTRY(monitor_destroy)
-       __COBALT_CALL_ENTRY(monitor_enter)
-       __COBALT_CALL_ENTRY(monitor_wait)
-       __COBALT_CALL_ENTRY(monitor_sync)
-       __COBALT_CALL_ENTRY(monitor_exit)
-       __COBALT_CALL_ENTRY(event_init)
-       __COBALT_CALL_ENTRY(event_destroy)
-       __COBALT_CALL_ENTRY(event_wait)
-       __COBALT_CALL_ENTRY(event_sync)
-       __COBALT_CALL_ENTRY(event_inquire)
-       __COBALT_CALL_ENTRY(sched_setconfig_np)
-       __COBALT_CALL_ENTRY(sched_getconfig_np)
-       __COBALT_CALL_ENTRY(open)
-       __COBALT_CALL_ENTRY(socket)
-       __COBALT_CALL_ENTRY(close)
-       __COBALT_CALL_ENTRY(mmap)
-       __COBALT_CALL_ENTRY(ioctl)
-       __COBALT_CALL_ENTRY(read)
-       __COBALT_CALL_ENTRY(write)
-       __COBALT_CALL_ENTRY(recvmsg)
-       __COBALT_CALL_ENTRY(sendmsg)
-       __COBALT_CALL_ENTRY(migrate)
-       __COBALT_CALL_ENTRY(archcall)
-       __COBALT_CALL_ENTRY(bind)
-       __COBALT_CALL_ENTRY(extend)
-       __COBALT_CALL_ENTRY(trace)
-       __COBALT_CALL_ENTRY(get_current)
-       __COBALT_CALL_ENTRY(mayday)
-       __COBALT_CALL_ENTRY(backtrace)
-       __COBALT_CALL_ENTRY(serialdbg)
-       __COBALT_CALL_ENTRY(corectl)
-       __COBALT_CALL_ENTRY(fcntl)
+       __COBALT_CALL_ENTRIES
 #ifdef CONFIG_XENO_ARCH_SYS3264
 #include <asm/xenomai/syscall32-table.h>
 #endif
@@ -712,101 +620,7 @@ static const cobalt_syshand cobalt_syscalls[] = {
 
 static const int cobalt_sysmodes[] = {
        __COBALT_CALL_NFLAGS
-       __COBALT_MODE(thread_create, init)
-       __COBALT_MODE(thread_getpid, current)
-       __COBALT_MODE(thread_setschedparam_ex, conforming)
-       __COBALT_MODE(thread_getschedparam_ex, current)
-       __COBALT_MODE(sched_weightprio, current)
-       __COBALT_MODE(sched_yield, primary)
-       __COBALT_MODE(thread_setmode, primary)
-       __COBALT_MODE(thread_setname, current)
-       __COBALT_MODE(thread_kill, conforming)
-       __COBALT_MODE(thread_getstat, current)
-       __COBALT_MODE(thread_join, primary)
-       __COBALT_MODE(sem_init, current)
-       __COBALT_MODE(sem_destroy, current)
-       __COBALT_MODE(sem_post, current)
-       __COBALT_MODE(sem_wait, primary)
-       __COBALT_MODE(sem_timedwait, primary)
-       __COBALT_MODE(sem_trywait, primary)
-       __COBALT_MODE(sem_getvalue, current)
-       __COBALT_MODE(sem_open, lostage)
-       __COBALT_MODE(sem_close, lostage)
-       __COBALT_MODE(sem_unlink, lostage)
-       __COBALT_MODE(sem_broadcast_np, current)
-       __COBALT_MODE(sem_inquire, current)
-       __COBALT_MODE(clock_getres, current)
-       __COBALT_MODE(clock_gettime, current)
-       __COBALT_MODE(clock_settime, current)
-       __COBALT_MODE(clock_nanosleep, nonrestartable)
-       __COBALT_MODE(mutex_init, current)
-       __COBALT_MODE(mutex_check_init, current)
-       __COBALT_MODE(mutex_destroy, current)
-       __COBALT_MODE(mutex_lock, primary)
-       __COBALT_MODE(mutex_timedlock, primary)
-       __COBALT_MODE(mutex_trylock, primary)
-       __COBALT_MODE(mutex_unlock, nonrestartable)
-       __COBALT_MODE(cond_init, current)
-       __COBALT_MODE(cond_destroy, current)
-       __COBALT_MODE(cond_wait_prologue, nonrestartable)
-       __COBALT_MODE(cond_wait_epilogue, primary)
-       __COBALT_MODE(mq_open, lostage)
-       __COBALT_MODE(mq_close, lostage)
-       __COBALT_MODE(mq_unlink, lostage)
-       __COBALT_MODE(mq_getattr, current)
-       __COBALT_MODE(mq_timedsend, primary)
-       __COBALT_MODE(mq_timedreceive, primary)
-       __COBALT_MODE(mq_notify, primary)
-       __COBALT_MODE(sigwait, primary)
-       __COBALT_MODE(sigwaitinfo, nonrestartable)
-       __COBALT_MODE(sigtimedwait, nonrestartable)
-       __COBALT_MODE(sigpending, primary)
-       __COBALT_MODE(kill, conforming)
-       __COBALT_MODE(sigqueue, conforming)
-       __COBALT_MODE(timer_create, current)
-       __COBALT_MODE(timer_delete, current)
-       __COBALT_MODE(timer_settime, primary)
-       __COBALT_MODE(timer_gettime, current)
-       __COBALT_MODE(timer_getoverrun, current)
-       __COBALT_MODE(timerfd_create, lostage)
-       __COBALT_MODE(timerfd_gettime, current)
-       __COBALT_MODE(timerfd_settime, primary)
-       __COBALT_MODE(select, nonrestartable)
-       __COBALT_MODE(sched_minprio, current)
-       __COBALT_MODE(sched_maxprio, current)
-       __COBALT_MODE(monitor_init, current)
-       __COBALT_MODE(monitor_destroy, primary)
-       __COBALT_MODE(monitor_enter, primary)
-       __COBALT_MODE(monitor_wait, nonrestartable)
-       __COBALT_MODE(monitor_sync, nonrestartable)
-       __COBALT_MODE(monitor_exit, primary)
-       __COBALT_MODE(event_init, current)
-       __COBALT_MODE(event_destroy, current)
-       __COBALT_MODE(event_wait, primary)
-       __COBALT_MODE(event_sync, current)
-       __COBALT_MODE(event_inquire, current)
-       __COBALT_MODE(sched_setconfig_np, conforming)
-       __COBALT_MODE(sched_getconfig_np, conforming)
-       __COBALT_MODE(open, lostage)
-       __COBALT_MODE(socket, lostage)
-       __COBALT_MODE(close, lostage)
-       __COBALT_MODE(mmap, lostage)
-       __COBALT_MODE(ioctl, probing)
-       __COBALT_MODE(read, probing)
-       __COBALT_MODE(write, probing)
-       __COBALT_MODE(recvmsg, probing)
-       __COBALT_MODE(sendmsg, probing)
-       __COBALT_MODE(migrate, current)
-       __COBALT_MODE(archcall, current)
-       __COBALT_MODE(bind, lostage)
-       __COBALT_MODE(extend, lostage)
-       __COBALT_MODE(trace, current)
-       __COBALT_MODE(get_current, current)
-       __COBALT_MODE(mayday, current)
-       __COBALT_MODE(backtrace, lostage)
-       __COBALT_MODE(serialdbg, current)
-       __COBALT_MODE(corectl, probing)
-       __COBALT_MODE(fcntl, current)
+       __COBALT_CALL_MODES
 };
 
 static inline int allowed_syscall(struct cobalt_process *process,
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index dbc5d24..8e960e8 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -100,8 +100,8 @@ patch_link() {
               recursive_opt="-maxdepth 1"
               dir_opt=""
            fi
-          find_clean_opt="$recursive_opt \( $dir_opt $link_makefiles_opt -name 
Kconfig -o -name '*.[chS]' \)"
-          find_link_opt="$recursive_opt \( $link_makefiles_opt -name Kconfig 
-o -name '*.[chS]' \)"
+          find_clean_opt="$recursive_opt \( $dir_opt $link_makefiles_opt -name 
Kconfig -o -name '*.[chS]' -o -name '*.sh' \)"
+          find_link_opt="$recursive_opt \( $link_makefiles_opt -name Kconfig 
-o -name '*.[chS]' -o -name '*.sh' \)"
        fi
 
         if test "x$output_patch" = "x" -a -e $linux_tree/$link_dir; then


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to