[258] | 1 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 2 | // File : sys_handler.h |
---|
| 3 | // Date : 01/04/2012 |
---|
| 4 | // Author : alain greiner and joel porquet |
---|
| 5 | // Copyright (c) UPMC-LIP6 |
---|
| 6 | /////////////////////////////////////////////////////////////////////////////////// |
---|
[440] | 7 | // The sys_handler.c and sys_handler.h files are part of the GIET-VM nano-kernel. |
---|
| 8 | // It define the syscall_vector[] (at the end of this file), as well as the |
---|
| 9 | // associated syscall handlers. |
---|
| 10 | /////////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 11 | |
---|
| 12 | #ifndef _SYS_HANDLER_H |
---|
| 13 | #define _SYS_HANDLER_H |
---|
| 14 | |
---|
[459] | 15 | #include "giet_config.h" |
---|
| 16 | #include "locks.h" |
---|
[440] | 17 | |
---|
[459] | 18 | #if !defined ( GIET_NIC_NBUFS ) |
---|
| 19 | # error: You must define GIET_NIC_NBUFS in the giet_config.h file |
---|
| 20 | #endif |
---|
| 21 | |
---|
| 22 | #if !defined ( GIET_NIC_NFAKE ) |
---|
| 23 | # error: You must define GIET_NIC_NFAKE in the giet_config.h file |
---|
| 24 | #endif |
---|
| 25 | |
---|
| 26 | #if !defined ( GIET_NIC_BUFSIZE ) |
---|
| 27 | # error: You must define GIET_NIC_BUFSIZE in the giet_config.h file |
---|
| 28 | #endif |
---|
| 29 | |
---|
| 30 | #if !defined ( GIET_NIC_TIMEOUT ) |
---|
| 31 | # error: You must define GIET_NIC_TIMEOUT in the giet_config.h file |
---|
| 32 | #endif |
---|
| 33 | |
---|
| 34 | #if !defined ( GIET_NIC_MAC4 ) |
---|
| 35 | # error: You must define GIET_NIC_MAC4 in the giet_config.h file |
---|
| 36 | #endif |
---|
| 37 | |
---|
| 38 | #if !defined ( GIET_NIC_MAC2 ) |
---|
| 39 | # error: You must define GIET_NIC_MAC2 in the giet_config.h file |
---|
| 40 | #endif |
---|
| 41 | |
---|
| 42 | #if ( (GIET_NIC_NBUFS + GIET_NIC_NFAKE) % 8 ) |
---|
| 43 | #error: GIET_NIC_NBUFS + GIET_NIC_NFAKE must be multiple of 8 for alignment |
---|
| 44 | #endif |
---|
| 45 | |
---|
[440] | 46 | /////////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 47 | // Syscall Vector Table (indexed by syscall index) |
---|
[440] | 48 | /////////////////////////////////////////////////////////////////////////////////// |
---|
[258] | 49 | |
---|
| 50 | extern const void * _syscall_vector[64]; |
---|
| 51 | |
---|
[440] | 52 | /////////////////////////////////////////////////////////////////////////////////// |
---|
[459] | 53 | // This structure is used by the CMA component to move a stream |
---|
[440] | 54 | // of images from two buffers in user space to the frame buffer in kernel space. |
---|
[459] | 55 | // it must be 64 bytes aligned. |
---|
| 56 | // It contains two chbuf arrays: |
---|
[440] | 57 | // - The SRC chbuf contains two buffers (buf0 & buf1), that can be in user space. |
---|
| 58 | // - The DST cbuf contains one single buffer (fbf), that is the frame buffer. |
---|
[459] | 59 | // - The length field define the buffer size (bytes) |
---|
[440] | 60 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 61 | |
---|
| 62 | typedef struct fbf_chbuf_s |
---|
| 63 | { |
---|
[459] | 64 | unsigned long long buf0; // physical address + status for user buffer 0 |
---|
| 65 | unsigned long long buf1; // physical address + status for user buffer 1 |
---|
| 66 | unsigned long long fbf; // physical address + status for user buffer 0 |
---|
| 67 | unsigned int length; // buffer length (bytes) |
---|
[467] | 68 | unsigned int padding[9]; // padding for 64 bytes alignment |
---|
[440] | 69 | } fbf_chbuf_t; |
---|
| 70 | |
---|
[258] | 71 | ////////////////////////////////////////////////////////////////////////////////// |
---|
[459] | 72 | // This structure is used by the CMA component to move a stream |
---|
| 73 | // of packet containers between the NIC component an a chbuf containing |
---|
| 74 | // a variable number of buffers in kernel space. |
---|
[449] | 75 | // The same structure is used for both TX or RX transfers. |
---|
[459] | 76 | // It must be 64 bytes aligned. |
---|
[449] | 77 | // The single buffer size and the number of buffers must be defined by the |
---|
[459] | 78 | // GIET_NIC_BUFSIZE and GIET_NIC_NBUFS parameters in giet_config.h. |
---|
| 79 | // - The buffer array implements the chbuf, and is concurently accessed |
---|
| 80 | // by the CMA component and by the kernel code. |
---|
| 81 | // - The lock must be taken by the kernel code, because several user tasks |
---|
| 82 | // can concurently try to consume buffers in the chbuf. |
---|
| 83 | // - The index is only used by the kernel, and define the currently pointed |
---|
[449] | 84 | // buffer for read (RX transfer) or write (TX transfer). |
---|
| 85 | ////////////////////////////////////////////////////////////////////////////////// |
---|
| 86 | |
---|
| 87 | typedef struct nic_chbuf_s |
---|
| 88 | { |
---|
[467] | 89 | unsigned long long buffer[GIET_NIC_NBUFS]; // Kernel chbuf |
---|
[459] | 90 | unsigned long long unused[GIET_NIC_NFAKE]; // padding for 64 bytes alignment |
---|
| 91 | unsigned int index; // current buffer index |
---|
| 92 | unsigned int padding[15]; // padding for 64 bytes alignment |
---|
[449] | 93 | } nic_chbuf_t; |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | ////////////////////////////////////////////////////////////////////////////////// |
---|
[440] | 97 | // TTY related syscall handlers |
---|
[258] | 98 | ////////////////////////////////////////////////////////////////////////////////// |
---|
| 99 | |
---|
[440] | 100 | int _sys_tty_alloc(); |
---|
[294] | 101 | |
---|
[440] | 102 | int _sys_tty_write( const char* buffer, |
---|
| 103 | unsigned int length, |
---|
| 104 | unsigned int channel ); |
---|
[428] | 105 | |
---|
[440] | 106 | int _sys_tty_read( char* buffer, |
---|
| 107 | unsigned int length, |
---|
| 108 | unsigned int channel ); |
---|
[294] | 109 | |
---|
[440] | 110 | int _sys_tty_get_lock( unsigned int channel, |
---|
| 111 | unsigned int * save_sr_ptr ); |
---|
[294] | 112 | |
---|
[440] | 113 | int _sys_tty_release_lock( unsigned int channel, |
---|
| 114 | unsigned int * save_sr_ptr ); |
---|
[294] | 115 | |
---|
[440] | 116 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 117 | // TIM related syscall handlers |
---|
| 118 | ////////////////////////////////////////////////////////////////////////////// |
---|
[294] | 119 | |
---|
[440] | 120 | int _sys_tim_alloc(); |
---|
[258] | 121 | |
---|
[440] | 122 | int _sys_tim_start( unsigned int period ); |
---|
[258] | 123 | |
---|
[440] | 124 | int _sys_tim_stop(); |
---|
[258] | 125 | |
---|
[440] | 126 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 127 | // NIC related syscall handlers |
---|
| 128 | ////////////////////////////////////////////////////////////////////////////// |
---|
[294] | 129 | |
---|
[449] | 130 | int _sys_nic_alloc( unsigned int is_rx ); |
---|
[396] | 131 | |
---|
[459] | 132 | int _sys_nic_start( unsigned int is_rx ); |
---|
[396] | 133 | |
---|
[449] | 134 | int _sys_nic_move( unsigned int is_rx, |
---|
[459] | 135 | unsigned int nic_channel, |
---|
[449] | 136 | void* buffer ); |
---|
[440] | 137 | |
---|
[449] | 138 | int _sys_nic_stop( unsigned int is_rx ); |
---|
| 139 | |
---|
[459] | 140 | int _sys_nic_clear( unsigned int is_rx ); |
---|
| 141 | |
---|
| 142 | int _sys_nic_stats( unsigned int is_rx ); |
---|
| 143 | |
---|
[440] | 144 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 145 | // FBF related syscall handlers |
---|
| 146 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 147 | |
---|
| 148 | int _sys_fbf_sync_write( unsigned int offset, |
---|
| 149 | void* buffer, |
---|
| 150 | unsigned int length ); |
---|
| 151 | |
---|
| 152 | int _sys_fbf_sync_read( unsigned int offset, |
---|
| 153 | void* buffer, |
---|
| 154 | unsigned int length ); |
---|
| 155 | |
---|
| 156 | int _sys_fbf_cma_alloc(); |
---|
| 157 | |
---|
| 158 | int _sys_fbf_cma_start( void* vbase0, |
---|
| 159 | void* vbase1, |
---|
| 160 | unsigned int length ); |
---|
| 161 | |
---|
| 162 | int _sys_fbf_cma_display( unsigned int buffer_index ); |
---|
| 163 | |
---|
| 164 | int _sys_fbf_cma_stop(); |
---|
| 165 | |
---|
| 166 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 167 | // Miscelaneous syscall handlers |
---|
| 168 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 169 | |
---|
| 170 | int _sys_ukn(); |
---|
| 171 | |
---|
| 172 | int _sys_proc_xyp( unsigned int* x, |
---|
| 173 | unsigned int* y, |
---|
| 174 | unsigned int* p ); |
---|
| 175 | |
---|
| 176 | int _sys_task_exit( char* string ); |
---|
| 177 | |
---|
| 178 | int _context_switch(); |
---|
| 179 | |
---|
| 180 | int _sys_local_task_id(); |
---|
| 181 | |
---|
| 182 | int _sys_global_task_id(); |
---|
| 183 | |
---|
| 184 | int _sys_thread_id(); |
---|
| 185 | |
---|
| 186 | int _sys_procs_number( unsigned int x, |
---|
| 187 | unsigned int y, |
---|
| 188 | unsigned int* number ); |
---|
| 189 | |
---|
| 190 | int _sys_vobj_get_vbase( char* vspace_name, |
---|
| 191 | char* vobj_name, |
---|
| 192 | unsigned int* vbase ); |
---|
| 193 | |
---|
| 194 | int _sys_vobj_get_length( char* vspace_name, |
---|
| 195 | char* vobj_name, |
---|
| 196 | unsigned int* length ); |
---|
| 197 | |
---|
| 198 | int _sys_xy_from_ptr( void* ptr, |
---|
| 199 | unsigned int* x, |
---|
| 200 | unsigned int* y ); |
---|
| 201 | |
---|
| 202 | int _sys_heap_info( unsigned int* vaddr, |
---|
| 203 | unsigned int* length, |
---|
| 204 | unsigned int x, |
---|
| 205 | unsigned int y ); |
---|
| 206 | |
---|
[258] | 207 | #endif |
---|
| 208 | |
---|
| 209 | // Local Variables: |
---|
| 210 | // tab-width: 4 |
---|
| 211 | // c-basic-offset: 4 |
---|
| 212 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 213 | // indent-tabs-mode: nil |
---|
| 214 | // End: |
---|
| 215 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 216 | |
---|