source: trunk/kernel/syscalls/shared_syscalls.h @ 410

Last change on this file since 410 was 410, checked in by alain, 6 years ago

Introduce new syscalls.

File size: 12.9 KB
Line 
1/*
2 * syscalls.h - Shared Kernel/User informations for syscalls.
3 *
4 * Author     Alain Greiner (2016,2017)
5 *
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef _SHARED_SYSCALLS_H_
25#define _SHARED_SYSCALLS_H_
26
27/******************************************************************************************
28 * This enum defines the mnemonics for the syscall indexes.
29 * It must be kept consistent with the array defined in do_syscalls.c
30 *****************************************************************************************/
31
32enum
33{
34        SYS_THREAD_EXIT    = 0,
35        SYS_THREAD_YIELD   = 1,
36        SYS_THREAD_CREATE  = 2,
37        SYS_THREAD_JOIN    = 3,
38        SYS_THREAD_DETACH  = 4,
39        SYS_THREAD_CANCEL  = 5,
40        SYS_SEM            = 6,
41        SYS_CONDVAR        = 7,
42        SYS_BARRIER        = 8,
43        SYS_MUTEX          = 9,
44
45    SYS_EXIT           = 10,
46    SYS_MUNMAP         = 11,
47        SYS_OPEN           = 12,
48        SYS_MMAP           = 13,
49        SYS_READ           = 14,
50        SYS_WRITE          = 15,
51        SYS_LSEEK          = 16,
52        SYS_CLOSE          = 17,
53        SYS_UNLINK         = 18,   
54        SYS_PIPE           = 19,
55
56        SYS_CHDIR          = 20,
57        SYS_MKDIR          = 21,
58        SYS_MKFIFO         = 22,   
59        SYS_OPENDIR        = 23,
60        SYS_READDIR        = 24,
61        SYS_CLOSEDIR       = 25,
62        SYS_GETCWD         = 26,
63        SYS_UNDEFINED_27   = 27,   ///
64        SYS_ALARM          = 28,   
65        SYS_RMDIR          = 29,
66
67        SYS_UTLS           = 30, 
68        SYS_CHMOD          = 31,
69        SYS_SIGNAL         = 32,
70        SYS_TIMEOFDAY      = 33,
71        SYS_KILL           = 34,
72        SYS_GETPID         = 35,
73        SYS_FORK           = 36,
74        SYS_EXEC           = 37,
75        SYS_STAT           = 38,     
76        SYS_TRACE          = 39,
77
78    SYS_GET_CONFIG     = 40,
79    SYS_GET_CORE       = 41,
80    SYS_GET_CYCLE      = 42,
81    SYS_GET_SCHED      = 43,
82    SYS_PANIC          = 44,
83        SYS_SLEEP          = 45,
84        SYS_WAKEUP         = 46,
85
86        SYSCALLS_NR        = 47,
87};
88
89/*******************************************************************************************
90 * This enum defines the supported terminaison status values for the exit() syscall.
91 ******************************************************************************************/
92
93typedef enum
94{
95        EXIT_SUCCESS,
96        EXIT_FAILURE,
97} 
98exit_statut_t;
99
100/*******************************************************************************************
101 * These typedef define the POSIX thread related types.
102 ******************************************************************************************/
103
104typedef unsigned int      sem_t;
105typedef unsigned int      pthread_cond_t;
106typedef unsigned int      pthread_condattr_t;
107typedef unsigned int      pthread_rwlock_t;
108typedef unsigned int      pthread_rwlockattr_t;
109typedef unsigned int      pthread_key_t;
110
111/*******************************************************************************************
112 * This structure and enum define the attributes for the "pthread_create" syscall.
113 ******************************************************************************************/
114
115typedef unsigned int  pthread_t;               
116
117typedef struct pthread_attr_s
118{
119        unsigned int      attributes;      /*! user defined attributes bit vector             */
120        unsigned int      cxy;             /*! target cluster identifier                      */
121        unsigned int      lid;             /*! target core local index                        */
122}
123pthread_attr_t;
124
125enum
126{
127    PT_ATTR_DETACH          = 0x0001,  /*! user defined not joinable                      */
128    PT_ATTR_CLUSTER_DEFINED = 0x0002,  /*! user defined target cluster                    */
129    PT_ATTR_CORE_DEFINED    = 0x0004,  /*! user defined core index in cluster             */
130};
131
132/*******************************************************************************************
133 * This enum defines the operation mnemonics for operations on POSIX unnamed semaphores.
134 ******************************************************************************************/
135
136typedef enum
137{
138        SEM_INIT,
139        SEM_DESTROY,
140        SEM_GETVALUE,
141        SEM_WAIT,
142        SEM_POST,
143} 
144sem_operation_t;
145
146/*******************************************************************************************
147 * This enum defines the operation mnemonics for operations on POSIX condition variables.
148 ******************************************************************************************/
149
150typedef enum
151{
152        CONDVAR_INIT,
153        CONDVAR_DESTROY,
154    CONDVAR_WAIT,
155    CONDVAR_SIGNAL,
156    CONDVAR_BROADCAST,
157} 
158condvar_operation_t;
159
160/*******************************************************************************************
161 * This enum defines the operation mnemonics for operations on POSIX barriers.
162 ******************************************************************************************/
163
164typedef enum
165{
166        BARRIER_INIT,
167        BARRIER_DESTROY,
168        BARRIER_WAIT,
169} 
170barrier_operation_t;
171
172/*******************************************************************************************
173 * This enum defines the operation mnemonics for operations on POSIX mutex.
174 ******************************************************************************************/
175
176typedef enum
177{
178        MUTEX_INIT,
179        MUTEX_DESTROY,
180        MUTEX_LOCK,
181        MUTEX_UNLOCK,
182} 
183mutex_operation_t;
184
185/*******************************************************************************************
186 * This enum defines the attributes bit-vector for an "open" syscall.
187 ******************************************************************************************/
188
189typedef enum
190{
191    O_RDONLY   = 0x0010000,    /*! open file in read-only mode                            */
192    O_WRONLY   = 0x0020000,    /*! open file in write-only mode                           */
193    O_RDWR     = 0x0030000,    /*! open file in read/write mode                           */
194    O_NONBLOCK = 0x0040000,    /*! do not block if data non available                     */
195    O_APPEND   = 0x0080000,    /*! append on each write                                   */
196    O_CREAT    = 0x0100000,    /*! create file if it does not exist                       */
197    O_TRUNC    = 0x0200000,    /*! file length is forced to 0                             */
198    O_EXCL     = 0x0400000,    /*! error if VFS_O_CREAT and file exist                    */
199    O_SYNC         = 0x0800000,    /*! synchronize File System on each write                  */
200    O_CLOEXEC  = 0x1000000,    /*! set the close-on-exec flag in file descriptor          */
201    O_DIR      = 0x2000000,    /*! new file descriptor is for a directory                 */
202}
203open_attr_t;
204
205/*******************************************************************************************
206 * This structure contains the arguments passed to the "mmap" syscall.
207 ******************************************************************************************/
208
209#define      MAP_FAILED  0
210
211typedef enum
212{
213    PROT_NONE   = 0x0,         /*! no access                                              */
214    PROT_EXEC   = 0x1,         /*! executable                                             */
215    PROT_WRITE  = 0x2,         /*! writable                                               */
216    PROT_READ   = 0x4,         /*! readable                                               */
217}
218mmap_prot_t;
219
220typedef enum
221{
222    MAP_FILE    = 0x00000000,  /*! map an open file defined by its fdid                   */ 
223    MAP_ANON    = 0x00000001,  /*! map an anonymous vseg in local cluster                 */
224    MAP_REMOTE  = 0x00000002,  /*! map an anonymous vseg in remote cluster (cxy == fdid)  */
225    MAP_PRIVATE = 0x00000010,  /*!                                                        */
226    MAP_SHARED  = 0x00000020,  /*!                                                        */
227    MAP_FIXED   = 0x00000100,  /*! non supported                                          */
228}
229mmap_flags_t;
230
231typedef struct mmap_attr_s
232{
233        void         * addr;       /*! requested virtual address (unused : should be NULL)    */
234        unsigned int   length;     /*! requested vseg size (bytes)                            */
235        unsigned int   prot;       /*! access modes                                           */
236        unsigned int   flags;      /*! MAP_FILE / MAP_ANON / MAP_PRIVATE / MAP_SHARED         */
237        unsigned int   fdid;       /*! file descriptor index (if MAP_FILE)                    */
238        unsigned int   offset;     /*! file offset (if MAP_FILE)                              */
239}
240mmap_attr_t;
241
242/*******************************************************************************************
243 * This enum defines the operation mnemonics for the "lseek" syscall.
244 ******************************************************************************************/
245
246typedef enum
247{
248    SEEK_SET  = 0,             /*! new_offset <= offset                                   */
249    SEEK_CUR  = 1,             /*! new_offset <= current_offset + offset                  */
250    SEEK_END  = 2,             /*! new_offset <= current_size + offset                    */
251}
252lseek_operation_t;
253
254/*******************************************************************************************
255 * This enum defines the operation mnemonics for the "utls" syscall (Thread Local Storage).
256 ******************************************************************************************/
257
258typedef enum
259{
260    UTLS_SET       = 1,
261    UTLS_GET       = 2,
262    UTLS_GET_ERRNO = 3,
263}
264utls_operation_t;
265
266/*******************************************************************************************
267 * This enum defines the operation mnemonics for the "trace" syscall.
268 ******************************************************************************************/
269
270typedef enum
271{
272    TRACE_ON       = 0,
273    TRACE_OFF      = 1,
274}
275trace_operation_t;
276
277/******************************************************************************************
278 * This structure define the informations associated to a file descriptor,
279 * returned to user space by the stat() system call.
280 *****************************************************************************************/
281
282typedef struct stat
283{
284        unsigned int    dev;        /*! ID of device containing file                             */
285        unsigned int    inum;       /*! inode number                                             */
286        unsigned int    mode;       /*! protection                                               */
287        unsigned int    nlink;      /*! number of hard links                                     */
288        unsigned int    uid;        /*! user ID of owner                                         */
289        unsigned int    gid;        /*! group ID of owner                                        */
290        unsigned int    rdev;       /*! device ID (if special file)                              */
291        unsigned int    size;       /*! total size, in bytes                                     */
292        unsigned int    blksize;    /*! blocksize for file system I/O                            */
293        unsigned int    blocks;     /*! number of 512B blocks allocated                          */
294}
295stat_t;
296
297/*******************************************************************************************
298 * These two structure defines the informations returned to user by the opendir()
299 * function, used by the readdir() function, and released by the closedir() function.
300 * - "DIR" describes the complete directory.
301 * - "dirent" describes one directory entry.
302 ******************************************************************************************/
303
304#define DIRENT_NAME_MAX_LENGTH  56
305#define DIRENT_MAX_NUMBER       63
306
307struct dirent
308{
309    unsigned int   inum;                                /*! inode identifier              */
310    unsigned int   type;                                /*! inode type                    */
311    char           name[DIRENT_NAME_MAX_LENGTH];        /*! directory entry name          */
312};
313
314typedef struct user_directory
315{
316    struct dirent   entry[DIRENT_MAX_NUMBER];
317    unsigned int    current;
318}
319DIR;
320
321/*******************************************************************************************
322 * These two structure are used by the gettimeofday() function.
323 ******************************************************************************************/
324
325struct timeval
326{
327    unsigned int tv_sec;                    /*! seconds since Jan. 1, 1970                */
328    unsigned int tv_usec;                   /*! and microseconds                          */
329};
330
331struct timezone
332{
333    int          tz_minuteswest;            /*8 of Greenwich                              */
334    int          tz_dsttime;                /*! type of dst correction to apply           */
335};
336
337
338
339#endif  // _SHARED_SYSCALLS_H_
Note: See TracBrowser for help on using the repository browser.