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

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

Improve sys_exec.

File size: 16.0 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 defines the signal type mnemonics for the kill() syscall.
91 * WARNING : Only the three SIGKILL / SIGSTOP / SIGCONT are supported (december 2017)
92 ******************************************************************************************/
93
94#define SIGHUP     1       /*! hangup                                                     */
95#define SIGINT     2       /*! interrupt                                                  */
96#define SIGQUIT    3       /*! quit                                                       */
97#define SIGILL     4       /*! illegal instruction (not reset when caught)                */
98#define SIGTRAP    5       /*! trace trap (not reset when caught)                         */
99#define SIGABRT    6       /*! used by abort, replace SIGIOT in the future                */
100#define SIGEMT     7       /*! EMT instruction                                            */
101#define SIGFPE     8       /*! floating point exception                                   */
102#define SIGKILL    9       /*! kill (cannot be caught or ignored)                         */
103#define SIGBUS     10      /*! bus error                                                  */
104#define SIGSEGV    11      /*! segmentation violation                                     */
105#define SIGSYS     12      /*! bad argument to system call                                */
106#define SIGPIPE    13      /*! write on a pipe with no one to read it                     */
107#define SIGALRM    14      /*! alarm clock                                                */
108#define SIGTERM    15      /*! software termination signal from kill                      */
109#define SIGURG     16      /*! urgent condition on IO channel                             */
110#define SIGSTOP    17      /*! sendable stop signal not from tty                          */
111#define SIGTSTP    18      /*! stop signal from tty                                       */
112#define SIGCONT    19      /*! continue a stopped process                                 */
113#define SIGCHLD    20      /*! to parent on child stop or exit                            */
114#define SIGTTIN    21      /*! to readers pgrp upon background tty read                   */
115#define SIGTTOU    22      /*! like TTIN for output if (tp->t_local&LTOSTOP)              */
116#define SIGIO      23      /*! input/output possible signal                               */
117#define SIGXCPU    24      /*! exceeded CPU time limit                                    */
118#define SIGXFSZ    25      /*! exceeded file size limit                                   */
119#define SIGVTALRM  26      /*! virtual time alarm                                         */
120#define SIGPROF    27      /*! profiling time alarm                                       */
121#define SIGWINCH   28      /*! window changed                                             */
122#define SIGLOST    29      /*! resource lost (eg, record-lock lost)                       */
123#define SIGUSR1    30      /*! user defined signal 1                                      */
124#define SIGUSR2    31      /*! user defined signal 2                                      */
125
126/*******************************************************************************************
127 * This enum defines the supported terminaison status values for the exit() syscall.
128 ******************************************************************************************/
129
130typedef enum
131{
132        EXIT_SUCCESS,
133        EXIT_FAILURE,
134} 
135exit_statut_t;
136
137/*******************************************************************************************
138 * These typedef define the POSIX thread related types.
139 ******************************************************************************************/
140
141typedef unsigned int      sem_t;
142typedef unsigned int      pthread_cond_t;
143typedef unsigned int      pthread_condattr_t;
144typedef unsigned int      pthread_rwlock_t;
145typedef unsigned int      pthread_rwlockattr_t;
146typedef unsigned int      pthread_key_t;
147
148/*******************************************************************************************
149 * This structure and enum define the attributes for the "pthread_create" syscall.
150 ******************************************************************************************/
151
152typedef unsigned int  pthread_t;               
153
154typedef struct pthread_attr_s
155{
156        unsigned int      attributes;      /*! user defined attributes bit vector             */
157        unsigned int      cxy;             /*! target cluster identifier                      */
158        unsigned int      lid;             /*! target core local index                        */
159}
160pthread_attr_t;
161
162enum
163{
164    PT_ATTR_DETACH          = 0x0001,  /*! user defined not joinable                      */
165    PT_ATTR_CLUSTER_DEFINED = 0x0002,  /*! user defined target cluster                    */
166    PT_ATTR_CORE_DEFINED    = 0x0004,  /*! user defined core index in cluster             */
167};
168
169/*******************************************************************************************
170 * This enum defines the operation mnemonics for operations on POSIX unnamed semaphores.
171 ******************************************************************************************/
172
173typedef enum
174{
175        SEM_INIT,
176        SEM_DESTROY,
177        SEM_GETVALUE,
178        SEM_WAIT,
179        SEM_POST,
180} 
181sem_operation_t;
182
183/*******************************************************************************************
184 * This enum defines the operation mnemonics for operations on POSIX condition variables.
185 ******************************************************************************************/
186
187typedef enum
188{
189        CONDVAR_INIT,
190        CONDVAR_DESTROY,
191    CONDVAR_WAIT,
192    CONDVAR_SIGNAL,
193    CONDVAR_BROADCAST,
194} 
195condvar_operation_t;
196
197/*******************************************************************************************
198 * This enum defines the operation mnemonics for operations on POSIX barriers.
199 ******************************************************************************************/
200
201typedef enum
202{
203        BARRIER_INIT,
204        BARRIER_DESTROY,
205        BARRIER_WAIT,
206} 
207barrier_operation_t;
208
209/*******************************************************************************************
210 * This enum defines the operation mnemonics for operations on POSIX mutex.
211 ******************************************************************************************/
212
213typedef enum
214{
215        MUTEX_INIT,
216        MUTEX_DESTROY,
217        MUTEX_LOCK,
218        MUTEX_UNLOCK,
219} 
220mutex_operation_t;
221
222/*******************************************************************************************
223 * This enum defines the attributes bit-vector for an "open" syscall.
224 ******************************************************************************************/
225
226typedef enum
227{
228    O_RDONLY   = 0x0010000,    /*! open file in read-only mode                            */
229    O_WRONLY   = 0x0020000,    /*! open file in write-only mode                           */
230    O_RDWR     = 0x0030000,    /*! open file in read/write mode                           */
231    O_NONBLOCK = 0x0040000,    /*! do not block if data non available                     */
232    O_APPEND   = 0x0080000,    /*! append on each write                                   */
233    O_CREAT    = 0x0100000,    /*! create file if it does not exist                       */
234    O_TRUNC    = 0x0200000,    /*! file length is forced to 0                             */
235    O_EXCL     = 0x0400000,    /*! error if VFS_O_CREAT and file exist                    */
236    O_SYNC         = 0x0800000,    /*! synchronize File System on each write                  */
237    O_CLOEXEC  = 0x1000000,    /*! set the close-on-exec flag in file descriptor          */
238    O_DIR      = 0x2000000,    /*! new file descriptor is for a directory                 */
239}
240open_attr_t;
241
242/*******************************************************************************************
243 * This structure contains the arguments passed to the "mmap" syscall.
244 ******************************************************************************************/
245
246#define      MAP_FAILED  0
247
248typedef enum
249{
250    PROT_NONE   = 0x0,         /*! no access                                              */
251    PROT_EXEC   = 0x1,         /*! executable                                             */
252    PROT_WRITE  = 0x2,         /*! writable                                               */
253    PROT_READ   = 0x4,         /*! readable                                               */
254}
255mmap_prot_t;
256
257typedef enum
258{
259    MAP_FILE    = 0x00000000,  /*! map an open file defined by its fdid                   */ 
260    MAP_ANON    = 0x00000001,  /*! map an anonymous vseg in local cluster                 */
261    MAP_REMOTE  = 0x00000002,  /*! map an anonymous vseg in remote cluster (cxy == fdid)  */
262    MAP_PRIVATE = 0x00000010,  /*!                                                        */
263    MAP_SHARED  = 0x00000020,  /*!                                                        */
264    MAP_FIXED   = 0x00000100,  /*! non supported                                          */
265}
266mmap_flags_t;
267
268typedef struct mmap_attr_s
269{
270        void         * addr;       /*! requested virtual address (unused : should be NULL)    */
271        unsigned int   length;     /*! requested vseg size (bytes)                            */
272        unsigned int   prot;       /*! access modes                                           */
273        unsigned int   flags;      /*! MAP_FILE / MAP_ANON / MAP_PRIVATE / MAP_SHARED         */
274        unsigned int   fdid;       /*! file descriptor index (if MAP_FILE)                    */
275        unsigned int   offset;     /*! file offset (if MAP_FILE)                              */
276}
277mmap_attr_t;
278
279/*******************************************************************************************
280 * This enum defines the operation mnemonics for the "lseek" syscall.
281 ******************************************************************************************/
282
283typedef enum
284{
285    SEEK_SET  = 0,             /*! new_offset <= offset                                   */
286    SEEK_CUR  = 1,             /*! new_offset <= current_offset + offset                  */
287    SEEK_END  = 2,             /*! new_offset <= current_size + offset                    */
288}
289lseek_operation_t;
290
291/*******************************************************************************************
292 * This enum defines the operation mnemonics for the "utls" syscall (Thread Local Storage).
293 ******************************************************************************************/
294
295typedef enum
296{
297    UTLS_SET       = 1,
298    UTLS_GET       = 2,
299    UTLS_GET_ERRNO = 3,
300}
301utls_operation_t;
302
303/*******************************************************************************************
304 * This enum defines the operation mnemonics for the "trace" syscall.
305 ******************************************************************************************/
306
307typedef enum
308{
309    TRACE_ON       = 0,
310    TRACE_OFF      = 1,
311}
312trace_operation_t;
313
314/******************************************************************************************
315 * This structure define the informations associated to a file descriptor,
316 * returned to user space by the stat() system call.
317 *****************************************************************************************/
318
319typedef struct stat
320{
321        unsigned int    dev;        /*! ID of device containing file                             */
322        unsigned int    inum;       /*! inode number                                             */
323        unsigned int    mode;       /*! protection                                               */
324        unsigned int    nlink;      /*! number of hard links                                     */
325        unsigned int    uid;        /*! user ID of owner                                         */
326        unsigned int    gid;        /*! group ID of owner                                        */
327        unsigned int    rdev;       /*! device ID (if special file)                              */
328        unsigned int    size;       /*! total size, in bytes                                     */
329        unsigned int    blksize;    /*! blocksize for file system I/O                            */
330        unsigned int    blocks;     /*! number of 512B blocks allocated                          */
331}
332stat_t;
333
334/*******************************************************************************************
335 * These two structure defines the informations returned to user by the opendir()
336 * function, used by the readdir() function, and released by the closedir() function.
337 * - "DIR" describes the complete directory.
338 * - "dirent" describes one directory entry.
339 ******************************************************************************************/
340
341#define DIRENT_NAME_MAX_LENGTH  56
342#define DIRENT_MAX_NUMBER       63
343
344struct dirent
345{
346    unsigned int   inum;                                /*! inode identifier              */
347    unsigned int   type;                                /*! inode type                    */
348    char           name[DIRENT_NAME_MAX_LENGTH];        /*! directory entry name          */
349};
350
351typedef struct user_directory
352{
353    struct dirent   entry[DIRENT_MAX_NUMBER];
354    unsigned int    current;
355}
356DIR;
357
358/*******************************************************************************************
359 * These two structure are used by the gettimeofday() function.
360 ******************************************************************************************/
361
362struct timeval
363{
364    unsigned int tv_sec;                    /*! seconds since Jan. 1, 1970                */
365    unsigned int tv_usec;                   /*! and microseconds                          */
366};
367
368struct timezone
369{
370    int          tz_minuteswest;            /*8 of Greenwich                              */
371    int          tz_dsttime;                /*! type of dst correction to apply           */
372};
373
374
375
376#endif  // _SHARED_SYSCALLS_H_
Note: See TracBrowser for help on using the repository browser.