[410] | 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 | |
---|
| 32 | enum |
---|
| 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 | |
---|
| 93 | typedef enum |
---|
| 94 | { |
---|
| 95 | EXIT_SUCCESS, |
---|
| 96 | EXIT_FAILURE, |
---|
| 97 | } |
---|
| 98 | exit_statut_t; |
---|
| 99 | |
---|
| 100 | /******************************************************************************************* |
---|
| 101 | * These typedef define the POSIX thread related types. |
---|
| 102 | ******************************************************************************************/ |
---|
| 103 | |
---|
| 104 | typedef unsigned int sem_t; |
---|
| 105 | typedef unsigned int pthread_cond_t; |
---|
| 106 | typedef unsigned int pthread_condattr_t; |
---|
| 107 | typedef unsigned int pthread_rwlock_t; |
---|
| 108 | typedef unsigned int pthread_rwlockattr_t; |
---|
| 109 | typedef unsigned int pthread_key_t; |
---|
| 110 | |
---|
| 111 | /******************************************************************************************* |
---|
| 112 | * This structure and enum define the attributes for the "pthread_create" syscall. |
---|
| 113 | ******************************************************************************************/ |
---|
| 114 | |
---|
| 115 | typedef unsigned int pthread_t; |
---|
| 116 | |
---|
| 117 | typedef 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 | } |
---|
| 123 | pthread_attr_t; |
---|
| 124 | |
---|
| 125 | enum |
---|
| 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 | |
---|
| 136 | typedef enum |
---|
| 137 | { |
---|
| 138 | SEM_INIT, |
---|
| 139 | SEM_DESTROY, |
---|
| 140 | SEM_GETVALUE, |
---|
| 141 | SEM_WAIT, |
---|
| 142 | SEM_POST, |
---|
| 143 | } |
---|
| 144 | sem_operation_t; |
---|
| 145 | |
---|
| 146 | /******************************************************************************************* |
---|
| 147 | * This enum defines the operation mnemonics for operations on POSIX condition variables. |
---|
| 148 | ******************************************************************************************/ |
---|
| 149 | |
---|
| 150 | typedef enum |
---|
| 151 | { |
---|
| 152 | CONDVAR_INIT, |
---|
| 153 | CONDVAR_DESTROY, |
---|
| 154 | CONDVAR_WAIT, |
---|
| 155 | CONDVAR_SIGNAL, |
---|
| 156 | CONDVAR_BROADCAST, |
---|
| 157 | } |
---|
| 158 | condvar_operation_t; |
---|
| 159 | |
---|
| 160 | /******************************************************************************************* |
---|
| 161 | * This enum defines the operation mnemonics for operations on POSIX barriers. |
---|
| 162 | ******************************************************************************************/ |
---|
| 163 | |
---|
| 164 | typedef enum |
---|
| 165 | { |
---|
| 166 | BARRIER_INIT, |
---|
| 167 | BARRIER_DESTROY, |
---|
| 168 | BARRIER_WAIT, |
---|
| 169 | } |
---|
| 170 | barrier_operation_t; |
---|
| 171 | |
---|
| 172 | /******************************************************************************************* |
---|
| 173 | * This enum defines the operation mnemonics for operations on POSIX mutex. |
---|
| 174 | ******************************************************************************************/ |
---|
| 175 | |
---|
| 176 | typedef enum |
---|
| 177 | { |
---|
| 178 | MUTEX_INIT, |
---|
| 179 | MUTEX_DESTROY, |
---|
| 180 | MUTEX_LOCK, |
---|
| 181 | MUTEX_UNLOCK, |
---|
| 182 | } |
---|
| 183 | mutex_operation_t; |
---|
| 184 | |
---|
| 185 | /******************************************************************************************* |
---|
| 186 | * This enum defines the attributes bit-vector for an "open" syscall. |
---|
| 187 | ******************************************************************************************/ |
---|
| 188 | |
---|
| 189 | typedef 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 | } |
---|
| 203 | open_attr_t; |
---|
| 204 | |
---|
| 205 | /******************************************************************************************* |
---|
| 206 | * This structure contains the arguments passed to the "mmap" syscall. |
---|
| 207 | ******************************************************************************************/ |
---|
| 208 | |
---|
| 209 | #define MAP_FAILED 0 |
---|
| 210 | |
---|
| 211 | typedef enum |
---|
| 212 | { |
---|
| 213 | PROT_NONE = 0x0, /*! no access */ |
---|
| 214 | PROT_EXEC = 0x1, /*! executable */ |
---|
| 215 | PROT_WRITE = 0x2, /*! writable */ |
---|
| 216 | PROT_READ = 0x4, /*! readable */ |
---|
| 217 | } |
---|
| 218 | mmap_prot_t; |
---|
| 219 | |
---|
| 220 | typedef 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 | } |
---|
| 229 | mmap_flags_t; |
---|
| 230 | |
---|
| 231 | typedef 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 | } |
---|
| 240 | mmap_attr_t; |
---|
| 241 | |
---|
| 242 | /******************************************************************************************* |
---|
| 243 | * This enum defines the operation mnemonics for the "lseek" syscall. |
---|
| 244 | ******************************************************************************************/ |
---|
| 245 | |
---|
| 246 | typedef 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 | } |
---|
| 252 | lseek_operation_t; |
---|
| 253 | |
---|
| 254 | /******************************************************************************************* |
---|
| 255 | * This enum defines the operation mnemonics for the "utls" syscall (Thread Local Storage). |
---|
| 256 | ******************************************************************************************/ |
---|
| 257 | |
---|
| 258 | typedef enum |
---|
| 259 | { |
---|
| 260 | UTLS_SET = 1, |
---|
| 261 | UTLS_GET = 2, |
---|
| 262 | UTLS_GET_ERRNO = 3, |
---|
| 263 | } |
---|
| 264 | utls_operation_t; |
---|
| 265 | |
---|
| 266 | /******************************************************************************************* |
---|
| 267 | * This enum defines the operation mnemonics for the "trace" syscall. |
---|
| 268 | ******************************************************************************************/ |
---|
| 269 | |
---|
| 270 | typedef enum |
---|
| 271 | { |
---|
| 272 | TRACE_ON = 0, |
---|
| 273 | TRACE_OFF = 1, |
---|
| 274 | } |
---|
| 275 | trace_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 | |
---|
| 282 | typedef 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 | } |
---|
| 295 | stat_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 | |
---|
| 307 | struct 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 | |
---|
| 314 | typedef struct user_directory |
---|
| 315 | { |
---|
| 316 | struct dirent entry[DIRENT_MAX_NUMBER]; |
---|
| 317 | unsigned int current; |
---|
| 318 | } |
---|
| 319 | DIR; |
---|
| 320 | |
---|
| 321 | /******************************************************************************************* |
---|
| 322 | * These two structure are used by the gettimeofday() function. |
---|
| 323 | ******************************************************************************************/ |
---|
| 324 | |
---|
| 325 | struct timeval |
---|
| 326 | { |
---|
| 327 | unsigned int tv_sec; /*! seconds since Jan. 1, 1970 */ |
---|
| 328 | unsigned int tv_usec; /*! and microseconds */ |
---|
| 329 | }; |
---|
| 330 | |
---|
| 331 | struct 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_ |
---|