[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 | /////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 20 | // Syscall Vector Table (indexed by syscall index) |
---|
[505] | 21 | /////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 22 | |
---|
| 23 | extern const void * _syscall_vector[64]; |
---|
| 24 | |
---|
[505] | 25 | /////////////////////////////////////////////////////////////////////////////// |
---|
[614] | 26 | // This structure is used by the CMA component to store the status of the |
---|
| 27 | // frame buffer (full or empty). The useful information is contained in the |
---|
| 28 | // "status" integer (1 for full and 0 for empty). |
---|
| 29 | // This structure must be aligned on a cache line (64 bytes) to simplify |
---|
[478] | 30 | // the software L2/L3 cache coherence when the IO bridge is used. |
---|
[505] | 31 | /////////////////////////////////////////////////////////////////////////////// |
---|
[478] | 32 | |
---|
[614] | 33 | typedef struct buffer_status_s |
---|
[478] | 34 | { |
---|
[614] | 35 | unsigned int status; |
---|
| 36 | unsigned int padding[15]; |
---|
| 37 | } buffer_status_t; |
---|
| 38 | |
---|
[505] | 39 | /////////////////////////////////////////////////////////////////////////////// |
---|
[459] | 40 | // This structure is used by the CMA component to move a stream |
---|
[478] | 41 | // of images from two user buffers to the frame buffer in kernel space. |
---|
[459] | 42 | // It contains two chbuf arrays: |
---|
[478] | 43 | // - The SRC chbuf contains two buffers (buf0 & buf1), in user space. |
---|
[440] | 44 | // - The DST cbuf contains one single buffer (fbf), that is the frame buffer. |
---|
[614] | 45 | // Each buffer is described with a 64 bits buffer descriptor: |
---|
| 46 | // - the 26 LSB bits contain bits[6:31] of the buffer physical address |
---|
| 47 | // - the 26 following bits contain bits[6:31] of the physical address where the |
---|
| 48 | // buffer status is located |
---|
| 49 | // - the 12 MSB bits contain the common address extension of the buffer and its |
---|
| 50 | // status |
---|
| 51 | // The length field define the buffer size (bytes) |
---|
[494] | 52 | // This structure must be 64 bytes aligned. |
---|
[505] | 53 | /////////////////////////////////////////////////////////////////////////////// |
---|
[440] | 54 | |
---|
| 55 | typedef struct fbf_chbuf_s |
---|
| 56 | { |
---|
[614] | 57 | unsigned long long buf0_desc; // first user buffer descriptor |
---|
| 58 | unsigned long long buf1_desc; // second user buffer descriptor |
---|
| 59 | unsigned long long fbf_desc; // frame buffer descriptor |
---|
| 60 | unsigned int length; // buffer length (bytes) |
---|
| 61 | unsigned int padding[9]; // padding for 64 bytes alignment |
---|
[440] | 62 | } fbf_chbuf_t; |
---|
| 63 | |
---|
[505] | 64 | /////////////////////////////////////////////////////////////////////////////// |
---|
[478] | 65 | // This structure is used by the CMA component to move a stream of containers |
---|
| 66 | // between the NIC chbuf containing 2 buffers, and a kernel chbuf |
---|
[494] | 67 | // containing up to (X_SIZE * Y_SIZE) buffers (one buffer per cluster). |
---|
[449] | 68 | // The same structure is used for both TX or RX transfers. |
---|
[494] | 69 | // The number of distributed containers can be smaller than (X_SIZE * YSIZE). |
---|
| 70 | // The actual number of buffers used in the chbuf is defined by (xmax * ymax). |
---|
[614] | 71 | // Each buffer is described with a 64 bits buffer descriptor: |
---|
| 72 | // - the 26 LSB bits contain bits[6:31] of the buffer physical address |
---|
| 73 | // - the 26 following bits contain bits[6:31] of the physical address where the |
---|
| 74 | // buffer status is located |
---|
| 75 | // - the 12 MSB bits contain the common address extension of the buffer and its |
---|
| 76 | // status |
---|
[494] | 77 | // This structure must be 64 bytes aligned. |
---|
[505] | 78 | /////////////////////////////////////////////////////////////////////////////// |
---|
[449] | 79 | |
---|
[614] | 80 | typedef struct ker_chbuf_s |
---|
[449] | 81 | { |
---|
[614] | 82 | unsigned long long buf_desc[X_SIZE*Y_SIZE]; // kernel chbuf descriptor |
---|
| 83 | unsigned int xmax; // nb clusters in a row |
---|
| 84 | unsigned int ymax; // nb clusters in a column |
---|
| 85 | } ker_chbuf_t; |
---|
[449] | 86 | |
---|
[519] | 87 | |
---|
| 88 | |
---|
| 89 | |
---|
[505] | 90 | /////////////////////////////////////////////////////////////////////////////// |
---|
[519] | 91 | // Coprocessors related syscall handlers |
---|
| 92 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 93 | |
---|
[670] | 94 | int _sys_coproc_register_set( unsigned int cluster_xy, |
---|
| 95 | unsigned int reg_index, |
---|
| 96 | unsigned int value ); |
---|
| 97 | |
---|
| 98 | int _sys_coproc_register_get( unsigned int cluster_xy, |
---|
| 99 | unsigned int reg_index, |
---|
| 100 | unsigned int* buffer ); |
---|
| 101 | |
---|
[519] | 102 | int _sys_coproc_alloc( unsigned int coproc_type, |
---|
[556] | 103 | unsigned int* coproc_info ); |
---|
[519] | 104 | |
---|
[556] | 105 | int _sys_coproc_release( unsigned int coproc_reg_index ); |
---|
[519] | 106 | |
---|
[556] | 107 | int _sys_coproc_channel_init( unsigned int channel, |
---|
[519] | 108 | giet_coproc_channel_t* desc ); |
---|
| 109 | |
---|
[556] | 110 | int _sys_coproc_run( unsigned int coproc_reg_index ); |
---|
[519] | 111 | |
---|
[556] | 112 | int _sys_coproc_completed(); |
---|
[519] | 113 | |
---|
| 114 | /////////////////////////////////////////////////////////////////////////////// |
---|
[440] | 115 | // TTY related syscall handlers |
---|
[505] | 116 | /////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 117 | |
---|
[670] | 118 | int _sys_tty_alloc( unsigned int shared ); |
---|
[294] | 119 | |
---|
[695] | 120 | int _sys_tty_release(); |
---|
| 121 | |
---|
[440] | 122 | int _sys_tty_write( const char* buffer, |
---|
| 123 | unsigned int length, |
---|
| 124 | unsigned int channel ); |
---|
[428] | 125 | |
---|
[440] | 126 | int _sys_tty_read( char* buffer, |
---|
| 127 | unsigned int length, |
---|
| 128 | unsigned int channel ); |
---|
[294] | 129 | |
---|
[440] | 130 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 131 | // TIM related syscall handlers |
---|
| 132 | ////////////////////////////////////////////////////////////////////////////// |
---|
[294] | 133 | |
---|
[440] | 134 | int _sys_tim_alloc(); |
---|
[258] | 135 | |
---|
[695] | 136 | int _sys_tim_release(); |
---|
| 137 | |
---|
[440] | 138 | int _sys_tim_start( unsigned int period ); |
---|
[258] | 139 | |
---|
[440] | 140 | int _sys_tim_stop(); |
---|
[258] | 141 | |
---|
[440] | 142 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 143 | // NIC related syscall handlers |
---|
| 144 | ////////////////////////////////////////////////////////////////////////////// |
---|
[294] | 145 | |
---|
[494] | 146 | int _sys_nic_alloc( unsigned int is_rx, |
---|
| 147 | unsigned int xmax, |
---|
| 148 | unsigned int ymax ); |
---|
[396] | 149 | |
---|
[695] | 150 | int _sys_nic_release( unsigned int is_rx ); |
---|
[494] | 151 | |
---|
[489] | 152 | int _sys_nic_start( unsigned int is_rx, |
---|
| 153 | unsigned int channel ); |
---|
[396] | 154 | |
---|
[449] | 155 | int _sys_nic_move( unsigned int is_rx, |
---|
[489] | 156 | unsigned int channel, |
---|
[449] | 157 | void* buffer ); |
---|
[440] | 158 | |
---|
[489] | 159 | int _sys_nic_stop( unsigned int is_rx, |
---|
| 160 | unsigned int channel ); |
---|
[449] | 161 | |
---|
[489] | 162 | int _sys_nic_clear( unsigned int is_rx, |
---|
| 163 | unsigned int channel ); |
---|
[459] | 164 | |
---|
[489] | 165 | int _sys_nic_stats( unsigned int is_rx, |
---|
| 166 | unsigned int channel ); |
---|
[459] | 167 | |
---|
[440] | 168 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 169 | // FBF related syscall handlers |
---|
| 170 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 171 | |
---|
| 172 | int _sys_fbf_sync_write( unsigned int offset, |
---|
| 173 | void* buffer, |
---|
| 174 | unsigned int length ); |
---|
| 175 | |
---|
| 176 | int _sys_fbf_sync_read( unsigned int offset, |
---|
| 177 | void* buffer, |
---|
| 178 | unsigned int length ); |
---|
| 179 | |
---|
| 180 | int _sys_fbf_cma_alloc(); |
---|
| 181 | |
---|
[700] | 182 | int _sys_fbf_cma_release(); |
---|
| 183 | |
---|
[614] | 184 | int _sys_fbf_cma_init_buf(void* buf0_vbase, |
---|
| 185 | void* buf1_vbase, |
---|
| 186 | void* sts0_vaddr, |
---|
| 187 | void* sts1_vaddr ); |
---|
[440] | 188 | |
---|
[614] | 189 | int _sys_fbf_cma_start( unsigned int length ); |
---|
| 190 | |
---|
[440] | 191 | int _sys_fbf_cma_display( unsigned int buffer_index ); |
---|
| 192 | |
---|
| 193 | int _sys_fbf_cma_stop(); |
---|
| 194 | |
---|
| 195 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 196 | // Miscelaneous syscall handlers |
---|
| 197 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 198 | |
---|
| 199 | int _sys_ukn(); |
---|
| 200 | |
---|
| 201 | int _sys_proc_xyp( unsigned int* x, |
---|
| 202 | unsigned int* y, |
---|
| 203 | unsigned int* p ); |
---|
| 204 | |
---|
| 205 | int _sys_task_exit( char* string ); |
---|
| 206 | |
---|
[629] | 207 | int _sys_kill_application( char* name ); |
---|
| 208 | |
---|
| 209 | int _sys_exec_application( char* name ); |
---|
| 210 | |
---|
[528] | 211 | int _sys_context_switch(); |
---|
[440] | 212 | |
---|
| 213 | int _sys_local_task_id(); |
---|
| 214 | |
---|
| 215 | int _sys_global_task_id(); |
---|
| 216 | |
---|
| 217 | int _sys_thread_id(); |
---|
| 218 | |
---|
[494] | 219 | int _sys_procs_number( unsigned int* x_size, |
---|
| 220 | unsigned int* y_size, |
---|
| 221 | unsigned int* nprocs ); |
---|
[440] | 222 | |
---|
[516] | 223 | int _sys_vseg_get_vbase( char* vspace_name, |
---|
| 224 | char* vseg_name, |
---|
[440] | 225 | unsigned int* vbase ); |
---|
| 226 | |
---|
[516] | 227 | int _sys_vseg_get_length( char* vspace_name, |
---|
| 228 | char* vseg_name, |
---|
[440] | 229 | unsigned int* length ); |
---|
| 230 | |
---|
| 231 | int _sys_xy_from_ptr( void* ptr, |
---|
| 232 | unsigned int* x, |
---|
| 233 | unsigned int* y ); |
---|
| 234 | |
---|
| 235 | int _sys_heap_info( unsigned int* vaddr, |
---|
| 236 | unsigned int* length, |
---|
| 237 | unsigned int x, |
---|
| 238 | unsigned int y ); |
---|
| 239 | |
---|
[688] | 240 | int _sys_tasks_status(); |
---|
| 241 | |
---|
[707] | 242 | int _sys_fat_read( unsigned int fd_id, |
---|
| 243 | unsigned int buffer, |
---|
| 244 | unsigned int count ); |
---|
| 245 | |
---|
[258] | 246 | #endif |
---|
| 247 | |
---|
| 248 | // Local Variables: |
---|
| 249 | // tab-width: 4 |
---|
| 250 | // c-basic-offset: 4 |
---|
| 251 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 252 | // indent-tabs-mode: nil |
---|
| 253 | // End: |
---|
| 254 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 255 | |
---|