[519] | 1 | /////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 2 | // File : sys_handler.h |
---|
| 3 | // Date : 01/04/2012 |
---|
[519] | 4 | // Author : alain greiner |
---|
[258] | 5 | // Copyright (c) UPMC-LIP6 |
---|
[519] | 6 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 7 | // The sys_handler.c and sys_handler.h files are part of the GIET-VM kernel. |
---|
[440] | 8 | // It define the syscall_vector[] (at the end of this file), as well as the |
---|
| 9 | // associated syscall handlers. |
---|
[519] | 10 | /////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 11 | |
---|
| 12 | #ifndef _SYS_HANDLER_H |
---|
| 13 | #define _SYS_HANDLER_H |
---|
| 14 | |
---|
[459] | 15 | #include "giet_config.h" |
---|
[494] | 16 | #include "kernel_locks.h" |
---|
[519] | 17 | #include "stdio.h" |
---|
[440] | 18 | |
---|
[505] | 19 | /////////////////////////////////////////////////////////////////////////////// |
---|
[709] | 20 | // Define the possible command values for the giet_pthread_control() syscall |
---|
[714] | 21 | // These define must be synchronized with values in the stdio.c file |
---|
[709] | 22 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 23 | |
---|
| 24 | #define THREAD_CMD_PAUSE 0 |
---|
| 25 | #define THREAD_CMD_RESUME 1 |
---|
| 26 | #define THREAD_CMD_CONTEXT 2 |
---|
| 27 | |
---|
| 28 | /////////////////////////////////////////////////////////////////////////////// |
---|
[714] | 29 | // Define the error codes for the syscall handlers |
---|
| 30 | // These define must be synchronized with values in the stdio.c file |
---|
[709] | 31 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 32 | |
---|
[714] | 33 | #define SYSCALL_OK ( 0 ) |
---|
| 34 | #define SYSCALL_VSPACE_NOT_FOUND (-1 ) |
---|
| 35 | #define SYSCALL_THREAD_NOT_FOUND (-2 ) |
---|
| 36 | #define SYSCALL_NOT_IN_SAME_VSPACE (-3 ) |
---|
| 37 | #define SYSCALL_UNCOHERENT_THREAD_CONTEXT (-4 ) |
---|
| 38 | #define SYSCALL_ILLEGAL_THREAD_COMMAND_TYPE (-5 ) |
---|
| 39 | #define SYSCALL_CANNOT_LOAD_DATA_SEGMENT (-6 ) |
---|
| 40 | #define SYSCALL_THREAD_ALREADY_ACTIVE (-7 ) |
---|
| 41 | #define SYSCALL_MAIN_NOT_FOUND (-8 ) |
---|
| 42 | #define SYSCALL_APPLI_CANNOT_BE_KILLED (-9 ) |
---|
| 43 | #define SYSCALL_PTHREAD_ARGUMENT_NOT_SUPPORTED (-10) |
---|
| 44 | #define SYSCALL_ILLEGAL_CLUSTER_COORDINATES (-11) |
---|
| 45 | #define SYSCALL_VSEG_NOT_FOUND (-12) |
---|
| 46 | #define SYSCALL_UNDEFINED_SYSTEM_CALL (-13) |
---|
| 47 | #define SYSCALL_COPROCESSOR_NOT_FOUND (-14) |
---|
| 48 | #define SYSCALL_COPROCESSOR_ILLEGAL_MODE (-15) |
---|
| 49 | #define SYSCALL_COPROCESSOR_NON_ALLOCATED (-16) |
---|
| 50 | #define SYSCALL_CHANNEL_ALREADY_ALLOCATED (-17) |
---|
| 51 | #define SYSCALL_NO_CHANNEL_AVAILABLE (-18) |
---|
| 52 | #define SYSCALL_CHANNEL_NON_ALLOCATED (-19) |
---|
[725] | 53 | #define SYSCALL_ILLEGAL_ARGUMENT (-20) |
---|
[714] | 54 | #define SYSCALL_OUT_OF_KERNEL_HEAP_MEMORY (-21) |
---|
| 55 | #define SYSCALL_ADDRESS_NON_ALIGNED (-22) |
---|
| 56 | #define SYSCALL_ADDRESS_NON_USER_ACCESSIBLE (-23) |
---|
| 57 | #define SYSCALL_MISSING_INITIALISATION (-24) |
---|
[709] | 58 | |
---|
| 59 | /////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 60 | // Syscall Vector Table (indexed by syscall index) |
---|
[505] | 61 | /////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 62 | |
---|
| 63 | extern const void * _syscall_vector[64]; |
---|
| 64 | |
---|
[505] | 65 | /////////////////////////////////////////////////////////////////////////////// |
---|
[725] | 66 | // This structure is used by the CMA component to move a stream of images |
---|
| 67 | // from a set of user buffers to the frame buffer in kernel space. |
---|
[459] | 68 | // It contains two chbuf arrays: |
---|
[725] | 69 | // - The SRC chbuf contains <nbufs> buffer descriptors, in user space, |
---|
| 70 | // that can be distributed (one buffer per cluster) or not. |
---|
| 71 | // - The DST cbuf contains one single buffer, that is the frame buffer. |
---|
[614] | 72 | // Each buffer is described with a 64 bits buffer descriptor: |
---|
[725] | 73 | // - the 26 LSB bits contain bits[31:6] of the status physical address. |
---|
| 74 | // - the 26 following bits contain bits[31:6] of the buffer physical address. |
---|
| 75 | // - the 12 MSB bits contain the common address extension. |
---|
| 76 | // The actual number of user buffers cannot be larger than 256 (at most |
---|
| 77 | // one user buffer per cluster for a 16*16 mesh). |
---|
| 78 | // NB: The user buffers are mapped in user space, but the chbuf descriptor |
---|
| 79 | // contained in this structure is a protected kernel variable. |
---|
[494] | 80 | // This structure must be 64 bytes aligned. |
---|
[505] | 81 | /////////////////////////////////////////////////////////////////////////////// |
---|
[440] | 82 | |
---|
| 83 | typedef struct fbf_chbuf_s |
---|
| 84 | { |
---|
[725] | 85 | unsigned long long fbf_desc; // frame buffer descriptor |
---|
| 86 | unsigned long long usr_desc[256]; // user chbuf descriptor |
---|
| 87 | unsigned int nbufs; // number of user buffers |
---|
[440] | 88 | } fbf_chbuf_t; |
---|
| 89 | |
---|
[505] | 90 | /////////////////////////////////////////////////////////////////////////////// |
---|
[478] | 91 | // This structure is used by the CMA component to move a stream of containers |
---|
| 92 | // between the NIC chbuf containing 2 buffers, and a kernel chbuf |
---|
[494] | 93 | // containing up to (X_SIZE * Y_SIZE) buffers (one buffer per cluster). |
---|
[449] | 94 | // The same structure is used for both TX or RX transfers. |
---|
[494] | 95 | // The number of distributed containers can be smaller than (X_SIZE * YSIZE). |
---|
| 96 | // The actual number of buffers used in the chbuf is defined by (xmax * ymax). |
---|
[614] | 97 | // Each buffer is described with a 64 bits buffer descriptor: |
---|
[725] | 98 | // - the 26 LSB bits contain bits[31:6] of the status physical address. |
---|
| 99 | // - the 26 following bits contain bits[31:6] of the buffer physical address. |
---|
| 100 | // - the 12 MSB bits contain the common address extension. |
---|
| 101 | // The <xmax> and <ymax> fields define the actual mesh size. |
---|
[494] | 102 | // This structure must be 64 bytes aligned. |
---|
[505] | 103 | /////////////////////////////////////////////////////////////////////////////// |
---|
[449] | 104 | |
---|
[725] | 105 | typedef struct nic_chbuf_s |
---|
[449] | 106 | { |
---|
[760] | 107 | unsigned long long buf_desc[X_SIZE*Y_SIZE]; // kernel chbuf descriptor |
---|
| 108 | unsigned int xmax; // nb clusters in a row |
---|
| 109 | unsigned int ymax; // nb clusters in a column |
---|
[725] | 110 | } nic_chbuf_t; |
---|
[449] | 111 | |
---|
[519] | 112 | |
---|
[709] | 113 | ////////////////////////////////////////////////////////////////////////////// |
---|
[760] | 114 | // File system related syscall handlers |
---|
| 115 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 116 | |
---|
| 117 | extern int _sys_fat_read( unsigned int fd_id, // file descriptor index |
---|
| 118 | unsigned int vaddr, // buffer vbase |
---|
| 119 | unsigned int count ); // number of bytes |
---|
| 120 | |
---|
| 121 | extern int _sys_fat_pread(unsigned int fd_id, // file descriptor index |
---|
| 122 | unsigned int vaddr, // buffer vbase |
---|
| 123 | unsigned int count, // number of bytes |
---|
| 124 | unsigned int offset ); // bytes to skip in file |
---|
| 125 | |
---|
| 126 | extern int _sys_fat_write( unsigned int fd_id, // file descriptor index |
---|
| 127 | unsigned int vaddr, // buffer vbase |
---|
| 128 | unsigned int count ); // number of bytes |
---|
| 129 | |
---|
| 130 | extern int _sys_fat_mmap( unsigned int fd_id, // file descriptor index |
---|
| 131 | unsigned int count, // number of pages |
---|
| 132 | unsigned int offset, // pages to skip in file |
---|
| 133 | unsigned int prot ); // protection modes |
---|
| 134 | |
---|
| 135 | extern int _sys_fat_munmap( unsigned int vaddr, // buffer vbase |
---|
| 136 | unsigned int count ); // number of pages |
---|
| 137 | |
---|
[774] | 138 | extern int _sys_fat_dump( unsigned int type, // BS/FS/FAT/FILE/DIR |
---|
| 139 | char* pathname, // file/dir pathname |
---|
| 140 | unsigned int block_id ); // block index in file/dir/fat |
---|
[760] | 141 | |
---|
[774] | 142 | |
---|
[760] | 143 | ////////////////////////////////////////////////////////////////////////////// |
---|
[709] | 144 | // Applications related syscall handlers |
---|
| 145 | ////////////////////////////////////////////////////////////////////////////// |
---|
[519] | 146 | |
---|
[709] | 147 | extern int _sys_kill_application( char* name ); |
---|
[519] | 148 | |
---|
[709] | 149 | extern int _sys_exec_application( char* name ); |
---|
[519] | 150 | |
---|
[714] | 151 | extern int _sys_applications_status( char* name ); |
---|
[670] | 152 | |
---|
[709] | 153 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 154 | // Threads related syscall handlers |
---|
| 155 | ///////////////////////////////////////////////////////////////////////////// |
---|
[670] | 156 | |
---|
[709] | 157 | extern int _sys_pthread_create( unsigned int* buffer, |
---|
| 158 | void* attr, |
---|
| 159 | void* function, |
---|
| 160 | void* arg ); |
---|
[519] | 161 | |
---|
[709] | 162 | extern int _sys_pthread_join( unsigned int trdid, |
---|
| 163 | void* ptr ); |
---|
[519] | 164 | |
---|
[709] | 165 | extern int _sys_pthread_kill( unsigned int trdid, |
---|
| 166 | int signal ); |
---|
[519] | 167 | |
---|
[709] | 168 | extern int _sys_pthread_exit( void* string); |
---|
[519] | 169 | |
---|
[709] | 170 | extern int _sys_pthread_yield(); |
---|
[519] | 171 | |
---|
[709] | 172 | extern int _sys_pthread_control( unsigned int command, |
---|
| 173 | char* vspace_name, |
---|
| 174 | char* thread_name ); |
---|
| 175 | |
---|
[519] | 176 | /////////////////////////////////////////////////////////////////////////////// |
---|
[709] | 177 | // Coprocessors related syscall handlers |
---|
| 178 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 179 | |
---|
[733] | 180 | extern int _sys_coproc_alloc( unsigned int cluster_xy, |
---|
| 181 | unsigned int coproc_type, |
---|
| 182 | unsigned int* return_info ); |
---|
[709] | 183 | |
---|
[733] | 184 | extern int _sys_coproc_release( unsigned int cluster_xy, |
---|
| 185 | unsigned int coproc_type ); |
---|
[709] | 186 | |
---|
[733] | 187 | extern int _sys_coproc_channel_init( unsigned int cluster_xy, |
---|
| 188 | unsigned int coproc_type, |
---|
| 189 | unsigned int channel, |
---|
[709] | 190 | giet_coproc_channel_t* desc ); |
---|
| 191 | |
---|
[733] | 192 | extern int _sys_coproc_run( unsigned int cluster_xy, |
---|
| 193 | unsigned int coproc_type ); |
---|
[709] | 194 | |
---|
[733] | 195 | extern int _sys_coproc_completed( unsigned int cluster_xy, |
---|
| 196 | unsigned int coproc_type ); |
---|
[709] | 197 | |
---|
| 198 | /////////////////////////////////////////////////////////////////////////////// |
---|
[440] | 199 | // TTY related syscall handlers |
---|
[505] | 200 | /////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 201 | |
---|
[709] | 202 | extern int _sys_tty_alloc( unsigned int shared ); |
---|
[294] | 203 | |
---|
[709] | 204 | extern int _sys_tty_release(); |
---|
[695] | 205 | |
---|
[709] | 206 | extern int _sys_tty_write( const char* buffer, |
---|
[440] | 207 | unsigned int length, |
---|
| 208 | unsigned int channel ); |
---|
[428] | 209 | |
---|
[709] | 210 | extern int _sys_tty_read( char* buffer, |
---|
[440] | 211 | unsigned int length, |
---|
| 212 | unsigned int channel ); |
---|
[294] | 213 | |
---|
[440] | 214 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 215 | // TIM related syscall handlers |
---|
| 216 | ////////////////////////////////////////////////////////////////////////////// |
---|
[294] | 217 | |
---|
[709] | 218 | extern int _sys_tim_alloc(); |
---|
[258] | 219 | |
---|
[709] | 220 | extern int _sys_tim_release(); |
---|
[695] | 221 | |
---|
[709] | 222 | extern int _sys_tim_start( unsigned int period ); |
---|
[258] | 223 | |
---|
[709] | 224 | extern int _sys_tim_stop(); |
---|
[258] | 225 | |
---|
[440] | 226 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 227 | // NIC related syscall handlers |
---|
| 228 | ////////////////////////////////////////////////////////////////////////////// |
---|
[294] | 229 | |
---|
[709] | 230 | extern int _sys_nic_alloc( unsigned int is_rx, |
---|
| 231 | unsigned int xmax, |
---|
| 232 | unsigned int ymax ); |
---|
[396] | 233 | |
---|
[709] | 234 | extern int _sys_nic_release( unsigned int is_rx ); |
---|
[494] | 235 | |
---|
[709] | 236 | extern int _sys_nic_start( unsigned int is_rx ); |
---|
[396] | 237 | |
---|
[709] | 238 | extern int _sys_nic_move( unsigned int is_rx, |
---|
| 239 | void* buffer ); |
---|
[440] | 240 | |
---|
[709] | 241 | extern int _sys_nic_stop( unsigned int is_rx ); |
---|
[449] | 242 | |
---|
[709] | 243 | extern int _sys_nic_clear( unsigned int is_rx ); |
---|
[459] | 244 | |
---|
[709] | 245 | extern int _sys_nic_stats( unsigned int is_rx ); |
---|
[459] | 246 | |
---|
[440] | 247 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 248 | // FBF related syscall handlers |
---|
| 249 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 250 | |
---|
[714] | 251 | extern int _sys_fbf_size( unsigned int* width, |
---|
| 252 | unsigned int* height ); |
---|
| 253 | |
---|
| 254 | extern int _sys_fbf_alloc(); |
---|
| 255 | |
---|
| 256 | extern int _sys_fbf_release(); |
---|
| 257 | |
---|
[709] | 258 | extern int _sys_fbf_sync_write( unsigned int offset, |
---|
[725] | 259 | void* buffer, |
---|
| 260 | unsigned int length ); |
---|
[440] | 261 | |
---|
[709] | 262 | extern int _sys_fbf_sync_read( unsigned int offset, |
---|
[725] | 263 | void* buffer, |
---|
| 264 | unsigned int length ); |
---|
[440] | 265 | |
---|
[725] | 266 | extern int _sys_fbf_cma_alloc( unsigned int nbufs ); |
---|
[440] | 267 | |
---|
[709] | 268 | extern int _sys_fbf_cma_release(); |
---|
[700] | 269 | |
---|
[725] | 270 | extern int _sys_fbf_cma_init_buf( unsigned int index, |
---|
| 271 | void* buf_vaddr, |
---|
| 272 | void* sts_vaddr ); |
---|
[440] | 273 | |
---|
[725] | 274 | extern int _sys_fbf_cma_start(); |
---|
[614] | 275 | |
---|
[725] | 276 | extern int _sys_fbf_cma_display( unsigned int index ); |
---|
[440] | 277 | |
---|
[725] | 278 | extern int _sys_fbf_cma_check( unsigned int index ); |
---|
| 279 | |
---|
[709] | 280 | extern int _sys_fbf_cma_stop(); |
---|
[440] | 281 | |
---|
| 282 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 283 | // Miscelaneous syscall handlers |
---|
| 284 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 285 | |
---|
[709] | 286 | extern int _sys_ukn(); |
---|
[440] | 287 | |
---|
[709] | 288 | extern int _sys_proc_xyp( unsigned int* x, |
---|
[725] | 289 | unsigned int* y, |
---|
| 290 | unsigned int* p ); |
---|
[440] | 291 | |
---|
[709] | 292 | extern int _sys_procs_number( unsigned int* x_size, |
---|
[725] | 293 | unsigned int* y_size, |
---|
| 294 | unsigned int* nprocs ); |
---|
[440] | 295 | |
---|
[709] | 296 | extern int _sys_vseg_get_vbase( char* vspace_name, |
---|
[725] | 297 | char* vseg_name, |
---|
| 298 | unsigned int* vbase ); |
---|
[440] | 299 | |
---|
[709] | 300 | extern int _sys_vseg_get_length( char* vspace_name, |
---|
[725] | 301 | char* vseg_name, |
---|
| 302 | unsigned int* length ); |
---|
[440] | 303 | |
---|
[709] | 304 | extern int _sys_xy_from_ptr( void* ptr, |
---|
[725] | 305 | unsigned int* x, |
---|
| 306 | unsigned int* y ); |
---|
[440] | 307 | |
---|
[709] | 308 | extern int _sys_heap_info( unsigned int* vaddr, |
---|
[725] | 309 | unsigned int* length, |
---|
| 310 | unsigned int x, |
---|
| 311 | unsigned int y ); |
---|
[440] | 312 | |
---|
[258] | 313 | #endif |
---|
| 314 | |
---|
| 315 | // Local Variables: |
---|
| 316 | // tab-width: 4 |
---|
| 317 | // c-basic-offset: 4 |
---|
| 318 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 319 | // indent-tabs-mode: nil |
---|
| 320 | // End: |
---|
| 321 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 322 | |
---|