From 54a87e1e91181878547c0a4309a85752cc2ac372 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 30 Mar 2011 02:59:01 +0000 Subject: [PATCH] Add syscall directory git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3438 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/include/pthread.h | 2 +- nuttx/include/signal.h | 2 +- nuttx/include/stdio.h | 2 +- nuttx/include/sys/select.h | 2 +- nuttx/include/sys/socket.h | 2 +- nuttx/include/time.h | 2 +- nuttx/syscall/README.txt | 107 +++++++++++++++++++++ nuttx/syscall/syscall.csv | 186 +++++++++++++++++++++++++++++++++++++ 8 files changed, 299 insertions(+), 6 deletions(-) create mode 100644 nuttx/syscall/README.txt create mode 100644 nuttx/syscall/syscall.csv diff --git a/nuttx/include/pthread.h b/nuttx/include/pthread.h index c0cf9b75e..b761678a6 100644 --- a/nuttx/include/pthread.h +++ b/nuttx/include/pthread.h @@ -1,7 +1,7 @@ /******************************************************************************** * pthread.h * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/include/signal.h b/nuttx/include/signal.h index 59bf891e8..0d0357704 100644 --- a/nuttx/include/signal.h +++ b/nuttx/include/signal.h @@ -1,7 +1,7 @@ /******************************************************************************** * include/signal.h * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/include/stdio.h b/nuttx/include/stdio.h index 1e14655fd..4ab0f142b 100644 --- a/nuttx/include/stdio.h +++ b/nuttx/include/stdio.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/stdio.h * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/include/sys/select.h b/nuttx/include/sys/select.h index ec11349c8..f9e0d573c 100644 --- a/nuttx/include/sys/select.h +++ b/nuttx/include/sys/select.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/sys/select.h * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/include/sys/socket.h b/nuttx/include/sys/socket.h index fdfb97787..bebef84d0 100644 --- a/nuttx/include/sys/socket.h +++ b/nuttx/include/sys/socket.h @@ -1,7 +1,7 @@ /**************************************************************************** * sys/socket.h * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/include/time.h b/nuttx/include/time.h index d38e96283..e3560b5c1 100644 --- a/nuttx/include/time.h +++ b/nuttx/include/time.h @@ -1,7 +1,7 @@ /******************************************************************************** * include/time.h * - * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/syscall/README.txt b/nuttx/syscall/README.txt new file mode 100644 index 000000000..bfaabcc65 --- /dev/null +++ b/nuttx/syscall/README.txt @@ -0,0 +1,107 @@ +sycall/README.txt +================= + +This directory supports a syscall layer from communication between a +monolithic, kernel-mode NuttX kernel and a separately built, user-mode +application set. + +With most MCUs, NuttX is built as a flat, single executable image +containing the NuttX RTOS along with all application code. The RTOS code +and the application run in the same address space and at the same kernel- +mode privileges. In order to exploit security features of certain +processors, an alternative build model is also supported: NuttX can +be built separately as a monolithic, kernel-mode module and the applications +can be add as a separately built, user-mode module. + +The syscall layer provided in this directory serves as the communication +layer from the user-mode application into the kernel-mode RTOS. The +switch from user-mode to kernel-mode is accomplished using software +interrupts (SWIs). SWIs are implemented differently and named differently +by different manufacters but all work essentially the same: A special +instruction is executed in user-mode that causes a software generated +interrupt. The software generated interrrupt is caught within the kernel +and handle in kernel-mode. + +Header Files +============ + +include/syscall.h + + This header file supports general access to SWI facilities. It is simply + a wrapper file that includes include/sys/syscall.h and + include/arch/syscall.h. + +include/sys/syscall.h + + The SWIs received by the kernel are distinguish by a code that identifies + how to process the SWI. This header file defines all such codes understood + by the NuttX kernel. + +include/arch/syscall.h (or arch//include/syscall.h) + + This header file is provided by the platform-specific logic and declares + (or defines) the mechanism for providing software interrupts on this + platform. The following functions must be declared (or defined) in this + header file: + + - SWI with SYS_ call number and one parameter + + uintptr_t sys_call0(unsigned int nbr); + + - SWI with SYS_ call number and one parameter + + uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1); + + - SWI with SYS_ call number and two parameters + + uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1, uintptr_t parm2); + + - SWI with SYS_ call number and three parameters + + uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1, + uintptr_t parm2, uintptr_t parm3); + + - SWI with SYS_ call number and four parameters + + uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3, uintptr_t parm4); + + - SWI with SYS_ call number and five parameters + + uintptr_t sys_call5(unsigned int nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3, uintptr_t parm4, uintptr_t parm5); + + - SWI with SYS_ call number and six parameters + + uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1, uintptr_t parm2, + uintptr_t parm3, uintptr_t parm4, uintptr_t parm5, + uintptr_t parm6); +Syscall Database +================ + +Sycall information is maintained in a database. That "database" is +implemented as a simple comma-separated-value file, syscall.csv. Most +spreadsheets programs will accept this format and can be used to maintain +the syscall database. + +The format of the CVS file for each line is: + + Field 1: Function name + Field 2: The header file that contains the function prototype + Field 3: The type of function return value. + Field 4 - N+4: The type of each of the N formal parameters of the function + +Auto-Generated Files +==================== + +Stubs and proxies for the sycalls are automatically generated from this CSV +database. Here the following definition is used: + + STUB - A tiny bit of code that executes with within the NuttX kernel that + is used to map a software interrupt received by the kernel to a + kernel function call. + + Proxy - Another tiny bit of code that executes in the user space. A proxy + has exactly the same function prototype as does the "real" function + for which it proxies. However, it only serves to map the function + call into a syscall, marshalling all of the parameters as necessary. diff --git a/nuttx/syscall/syscall.csv b/nuttx/syscall/syscall.csv new file mode 100644 index 000000000..e488799cd --- /dev/null +++ b/nuttx/syscall/syscall.csv @@ -0,0 +1,186 @@ +"_exit","unistd.h","void","int" +"abort","stdlib.h","void" +"accept","sys/socket.h","int","int","struct sockaddr*","socklen_t*" +"atexit","stdlib.h","int","void *(*)(void)" +"bind","sys/socket.h","int","int","FAR const struct sockaddr*","socklen_t" +"chdir","unistd.h","int","FAR const char*" +"clearenv","stdlib.h","int" +"clock_getres","time.h","int","clockid_t","struct timespec*" +"clock_gettime","time.h","int","clockid_t","struct timespec*" +"clock_settime","time.h","int","clockid_t","const struct timespec*" +"close","unistd.h","int","int" +"closedir","dirent.h","int","FAR DIR*" +"connect","sys/socket.h","int","int","FAR const struct sockaddr*","socklen_t" +"creat","fcntl.h","int","const char*","mode_t" +"dup","unistd.h","int","int" +"dup2","unistd.h","int","int","int" +"exit","stdlib.h","void","int" +"fcntl","fcntl.h","int","int","int","..." +"fstat","sys/stat.h","int","int","FAR struct stat*" +"fstatfs","sys/statfs.h","int","int","struct statfs*" +"fsync","unistd.h","int","int" +"get_environ_ptr","stdlib.h","FAR char**"," void " +"get_errno_ptr","errno.h","FAR int*" +"getcwd","unistd.h","FAR char*","FAR char*","size_t" +"getenv","stdlib.h","FAR char*","FAR const char*" +"getpid","unistd.h","pidt_t" +"getsockopt","sys/socket.h","int","int","int","int","FAR void*","FAR socklen_t*" +"gettimeofday","sys/time.h","int","struct timeval*","FAR void*" +"ioctl","sys/ioctl.h","int","int","int","unsigned long" +"kill","signal.h","int","pid_t","int" +"listen","sys/socket.h","int","int","int" +"lseek","unistd.h","off_t","int","off_t offset","int" +"mkdir","sys/stat.h","int","FAR const char*","mode_t mode" +"mkfifo","sys/stat.h","int","FAR const char*","mode_t mode" +"mmap","sys/mman.h","FAR void*","FAR void*","size_t","int","int","int","off_t" +"mount","sys/mount.h","int","const char*","const char*","const char*","unsigned long","const void*" +"mq_close","mqueue.h","int","mqd_t" +"mq_getattr","mqueue.h","int","mqd_t","struct mq_attr*" +"mq_notify","mqueue.h","int","mqd_t","const struct sigevent*" +"mq_open","mqueue.h","mqd_t","const char*","int","..." +"mq_receive","mqueue.h","ssize_t","mqd_t","void*","size_t","int*" +"mq_send","mqueue.h","int","mqd_t","const void*","size_t","int" +"mq_setattr","mqueue.h","int","mqd_t","const struct mq_attr*","struct mq_attr*" +"mq_timedreceive","mqueue.h","ssize_t","mqd_t","void*","size_t","int","const struct timespec*" +"mq_timedsend","mqueue.h","int","mqd_t","const char*","size_t","int prio","const struct timespec*" +"mq_unlink","mqueue.h","int","const char*" +"open","fcntl.h","int","const char*","int","..." +"opendir","dirent.h","FAR DIR*","FAR const char*" +"pipe","unistd.h","int","int[2]" +"poll","poll.h","int","FAR struct pollfd*","nfds_t","int" +"pthread_attr_destroy","pthread.h","int","pthread_attr_t*" +"pthread_attr_getinheritsched","pthread.h","int","FAR const pthread_attr_t*","FAR int*" +"pthread_attr_getschedparam","pthread.h","int","FAR pthread_attr_t*","FAR struct sched_param*" +"pthread_attr_getschedpolicy","pthread.h","int","FAR pthread_attr_t*","int*" +"pthread_attr_getstacksize","pthread.h","int","FAR pthread_attr_t*","long*" +"pthread_attr_init","pthread.h","int","FAR pthread_attr_t*" +"pthread_attr_setinheritsched","pthread.h","int","FAR pthread_attr_t*","int" +"pthread_attr_setschedparam","pthread.h","int","FAR pthread_attr_t*","FAR const struct sched_param*" +"pthread_attr_setschedpolicy","pthread.h","int","FAR pthread_attr_t*","int" +"pthread_attr_setstacksize","pthread.h","int","FAR pthread_attr_t*","long" +"pthread_barrier_destroy","pthread.h","int","FAR pthread_barrier_t*" +"pthread_barrier_init","pthread.h","int","FAR pthread_barrier_t*","FAR const pthread_barrierattr_t*","unsigned int" +"pthread_barrier_wait","pthread.h","int","FAR pthread_barrier_t*" +"pthread_barrierattr_destroy","pthread.h","int","FAR pthread_barrierattr_t*" +"pthread_barrierattr_getpshared","pthread.h","int","FAR const pthread_barrierattr_t*","FAR int*" +"pthread_barrierattr_init","pthread.h","int","FAR pthread_barrierattr_t*" +"pthread_barrierattr_setpshared","pthread.h","int","FAR pthread_barrierattr_t*","int" +"pthread_cancel","pthread.h","int","pthread_t" +"pthread_cond_broadcast","pthread.h","int","FAR pthread_cond_t*" +"pthread_cond_destroy","pthread.h","int","FAR pthread_cond_t*" +"pthread_cond_init","pthread.h","int","FAR pthread_cond_t*","FAR pthread_condattr_t*" +"pthread_cond_signal","pthread.h","int","FAR pthread_cond_t*" +"pthread_cond_timedwait","pthread.h","int","FAR pthread_cond_t*","FAR pthread_mutex_t*","FAR const struct timespec*" +"pthread_cond_wait","pthread.h","int","FAR pthread_cond_t*","FAR pthread_mutex_t*" +"pthread_condattr_destroy","pthread.h","int","FAR pthread_condattr_t*" +"pthread_condattr_init","pthread.h","int","FAR pthread_condattr_t*" +"pthread_create","pthread.h","int","FAR pthread_t*","FAR pthread_attr_t*","pthread_startroutine_t","pthread_addr_t" +"pthread_detach","pthread.h","int","pthread_t" +"pthread_exit","pthread.h","void","pthread_addr_t" +"pthread_getschedparam","pthread.h","int","pthread_t","FAR int*","FAR struct sched_param*" +"pthread_getspecific","pthread.h","FAR void*","pthread_key_t" +"pthread_join","pthread.h","int","pthread_t","FAR pthread_addr_t*" +"pthread_key_create","pthread.h","int","FAR pthread_key_t*","CODE void (*)(FAR void*)" +"pthread_key_delete","pthread.h","int","pthread_key_t" +"pthread_kill","pthread.h","int","pthread_t","int" +"pthread_mutex_destroy","pthread.h","int","FAR pthread_mutex_t*" +"pthread_mutex_init","pthread.h","int","FAR pthread_mutex_t*","FAR pthread_mutexattr_t*" +"pthread_mutex_lock","pthread.h","int","FAR pthread_mutex_t*" +"pthread_mutex_trylock","pthread.h","int","FAR pthread_mutex_t*" +"pthread_mutex_unlock","pthread.h","int","FAR pthread_mutex_t*" +"pthread_mutexattr_destroy","pthread.h","int","FAR pthread_mutexattr_t*" +"pthread_mutexattr_getpshared","pthread.h","int","FAR pthread_mutexattr_t*","FAR int*" +"pthread_mutexattr_gettype","pthread.h","int","const pthread_mutexattr_t*","int*" +"pthread_mutexattr_init","pthread.h","int","FAR pthread_mutexattr_t*" +"pthread_mutexattr_setpshared","pthread.h","int","FAR pthread_mutexattr_t*","int" +"pthread_mutexattr_settype","pthread.h","int","pthread_mutexattr_t*","int" +"pthread_once","pthread.h","int","FAR pthread_once_t*","CODE void (*)(void)" +"pthread_setcancelstate","pthread.h","int","int","FAR int*" +"pthread_setschedparam","pthread.h","int","pthread_t","int","FAR const struct sched_param*" +"pthread_setschedprio","pthread.h","int","pthread_t","int" +"pthread_setspecific","pthread.h","int","pthread_key_t","FAR void*" +"pthread_sigmask","pthread.h","int","int","FAR const sigset_t*","FAR sigset_t*" +"pthread_testcancel","pthread.h","void" +"pthread_yield","pthread.h","void" +"putenv","stdlib.h","int","FAR const char*" +"read","unistd.h","ssize_t","int","FAR void*","size_t" +"readdir","dirent.h","FAR struct dirent*","FAR DIR*" +"readdir_r","dirent.h","int","FAR DIR*","FAR struct dirent*","FAR struct dirent**" +"recv","sys/socket.h","ssize_t","int","FAR void*","size_t","int" +"recvfrom","sys/socket.h","ssize_t","int","FAR void*","size_t","int","FAR struct sockaddr*","FAR socklen_t*" +"rename","stdio.h","int","FAR const char*","FAR const char*" +"rewinddir","dirent.h","void","FAR DIR*" +"rmdir","unistd.h","int","FAR const char*" +"sched_get_priority_max","sched.h","int","int" +"sched_get_priority_min","sched.h","int","int" +"sched_getparam","sched.h","int","pid_t","struct sched_param*" +"sched_getscheduler","sched.h","int","pid_t" +"sched_lock","sched.h","int" +"sched_lockcount","sched.h","int32_t" +"sched_note_start","sched.h","void","FAR _TCB* " +"sched_note_stop","sched.h","void","FAR _TCB* " +"sched_note_switch","sched.h","void","FAR _TCB*","FAR _TCB*" +"sched_rr_get_interval","sched.h","int","pid_t","struct timespec*" +"sched_setparam","sched.h","int","pid_t","const struct sched_param*" +"sched_setscheduler","sched.h","int","pid_t","int","const struct sched_param*" +"sched_unlock","sched.h","int" +"sched_yield","sched.h","int" +"seekdir","dirent.h","void","FAR DIR*","off_t" +"select","sys/select.h","int","int","FAR fd_set*","FAR fd_set*","FAR fd_set*","FAR struct timeval*" +"sem_close","semaphore.h","int","FAR sem_t*" +"sem_destroy","semaphore.h","int","FAR sem_t*" +"sem_getvalue","semaphore.h","int","FAR sem_t*","FAR int*" +"sem_init","semaphore.h","int","FAR sem_t*","int","unsigned int value" +"sem_open","semaphore.h","FAR sem_t*","FAR const char*","int","..." +"sem_post","semaphore.h","int","FAR sem_t*" +"sem_trywait","semaphore.h","int","FAR sem_t*" +"sem_unlink","semaphore.h","int","FAR const char*" +"sem_wait","semaphore.h","int","FAR sem_t*" +"send","sys/socket.h","ssize_t","int","FAR const void*","size_t","int" +"sendto","sys/socket.h","ssize_t","int","FAR const void*","size_t","int","FAR const struct sockaddr*","socklen_t" +"setenv","stdlib.h","int","const char*","const char*","int" +"setsockopt","sys/socket.h","int","int","int","int","FAR const void*","socklen_t" +"sigaction","signal.h","int","int","FAR const struct sigaction*","FAR struct sigaction*" +"sigaddset","signal.h","int","FAR sigset_t*","int" +"sigdelset","signal.h","int","FAR sigset_t*","int" +"sigemptyset","signal.h","int","FAR sigset_t*" +"sigfillset","signal.h","int","FAR sigset_t*" +"sigismember","signal.h","int","FAR const sigset_t*","int" +"sigpending","signal.h","int","FAR sigset_t*" +"sigprocmask","signal.h","int","int","FAR const sigset_t*","FAR sigset_t*" +"sigqueue","signal.h","int","int","int","FAR void*" +"sigqueue","signal.h","int","int","int","union sigval" +"sigsuspend","signal.h","int","FAR const sigset_t*" +"sigtimedwait","signal.h","int","FAR const sigset_t*","FAR struct siginfo*","FAR const struct timespec*" +"sigwaitinfo","signal.h","int","FAR const sigset_t*","FAR struct siginfo*" +"sleep","unistd.h","unsigned int","unsigned int" +"snprintf","stdio.h","int","FAR char*","size_t","const char*","..." +"socket","sys/socket.h","int","int","int","int" +"stat","sys/stat.h","int","const char*","FAR struct stat*" +"statfs","stdio.h","int","FAR const char*","FAR struct statfs*" +"statfs","sys/statfs.h","int","const char*","struct statfs*" +"task_activate","sched.h","int","FAR _TCB*" +"task_create","sched.h","int","const char*","int","int","main_t","const char*[]" +"task_create","sched.h","int","const char*","int","main_t","const char*[]" +"task_delete","sched.h","int","pid_t" +"task_init","sched.h","int","FAR _TCB*","const char*","int","FAR uint32_t*","uint32_t","main_t","const char*[]" +"task_init","sched.h","int","FAR _TCB*","const char*","int","main_t","const char*[]" +"task_restart","sched.h","int","pid_t" +"telldir","dirent.h","off_t","FAR DIR*" +"timer_create","time.h","int","clockid_t","FAR struct sigevent*","FAR timer_t*" +"timer_delete","time.h","int","timer_t" +"timer_getoverrun","time.h","int","timer_t" +"timer_gettime","time.h","int","timer_t","FAR struct itimerspec*" +"timer_settime","time.h","int","timer_t","int","FAR const struct itimerspec*","FAR struct itimerspec*" +"umount","sys/mount.h","int","const char*" +"unlink","unistd.h","int","FAR const char*" +"unsetenv","stdlib.h","int","const char*" +"up_assert","assert.h","void","FAR const uint8_t*","int" +"up_assert","assert.h","void" +"up_assert_code","assert.h","void","FAR const uint8_t*","int","int" +"up_assert_code","assert.h","void","int" +"usleep","unistd.h","void","useconds_t" +"wait","sys/wait.h","pidt_t","int*" +"waitid","sys/wait.h","int","idtype_t","id_t id","siginfo_t*","int" +"waitpid","sys/wait.h","pidt_t","pid_t","int*","int" +"write","unistd.h","ssize_t","int","FAR const void*","size_t"