| 1 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 2 | // File : sys_handler.h
|
|---|
| 3 | // Date : 01/04/2012
|
|---|
| 4 | // Author : alain greiner
|
|---|
| 5 | // Copyright (c) UPMC-LIP6
|
|---|
| 6 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 7 | // The sys_handler.c and sys_handler.h files are part of the GIET-VM kernel.
|
|---|
| 8 | // It define the syscall_vector[] (at the end of this file), as well as the
|
|---|
| 9 | // associated syscall handlers.
|
|---|
| 10 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 11 |
|
|---|
| 12 | #ifndef _SYS_HANDLER_H
|
|---|
| 13 | #define _SYS_HANDLER_H
|
|---|
| 14 |
|
|---|
| 15 | #include "giet_config.h"
|
|---|
| 16 | #include "kernel_locks.h"
|
|---|
| 17 | #include "stdio.h"
|
|---|
| 18 |
|
|---|
| 19 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 20 | // Syscall Vector Table (indexed by syscall index)
|
|---|
| 21 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 22 |
|
|---|
| 23 | extern const void * _syscall_vector[64];
|
|---|
| 24 |
|
|---|
| 25 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 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
|
|---|
| 30 | // the software L2/L3 cache coherence when the IO bridge is used.
|
|---|
| 31 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 32 |
|
|---|
| 33 | typedef struct buffer_status_s
|
|---|
| 34 | {
|
|---|
| 35 | unsigned int status;
|
|---|
| 36 | unsigned int padding[15];
|
|---|
| 37 | } buffer_status_t;
|
|---|
| 38 |
|
|---|
| 39 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 40 | // This structure is used by the CMA component to move a stream
|
|---|
| 41 | // of images from two user buffers to the frame buffer in kernel space.
|
|---|
| 42 | // It contains two chbuf arrays:
|
|---|
| 43 | // - The SRC chbuf contains two buffers (buf0 & buf1), in user space.
|
|---|
| 44 | // - The DST cbuf contains one single buffer (fbf), that is the frame buffer.
|
|---|
| 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)
|
|---|
| 52 | // This structure must be 64 bytes aligned.
|
|---|
| 53 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 54 |
|
|---|
| 55 | typedef struct fbf_chbuf_s
|
|---|
| 56 | {
|
|---|
| 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
|
|---|
| 62 | } fbf_chbuf_t;
|
|---|
| 63 |
|
|---|
| 64 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 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
|
|---|
| 67 | // containing up to (X_SIZE * Y_SIZE) buffers (one buffer per cluster).
|
|---|
| 68 | // The same structure is used for both TX or RX transfers.
|
|---|
| 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).
|
|---|
| 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
|
|---|
| 77 | // This structure must be 64 bytes aligned.
|
|---|
| 78 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 79 |
|
|---|
| 80 | typedef struct ker_chbuf_s
|
|---|
| 81 | {
|
|---|
| 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;
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 91 | // Coprocessors related syscall handlers
|
|---|
| 92 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 93 |
|
|---|
| 94 | int _sys_coproc_alloc( unsigned int coproc_type,
|
|---|
| 95 | unsigned int* coproc_info );
|
|---|
| 96 |
|
|---|
| 97 | int _sys_coproc_release( unsigned int coproc_reg_index );
|
|---|
| 98 |
|
|---|
| 99 | int _sys_coproc_channel_init( unsigned int channel,
|
|---|
| 100 | giet_coproc_channel_t* desc );
|
|---|
| 101 |
|
|---|
| 102 | int _sys_coproc_run( unsigned int coproc_reg_index );
|
|---|
| 103 |
|
|---|
| 104 | int _sys_coproc_completed();
|
|---|
| 105 |
|
|---|
| 106 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 107 | // TTY related syscall handlers
|
|---|
| 108 | ///////////////////////////////////////////////////////////////////////////////
|
|---|
| 109 |
|
|---|
| 110 | int _sys_tty_alloc();
|
|---|
| 111 |
|
|---|
| 112 | int _sys_tty_write( const char* buffer,
|
|---|
| 113 | unsigned int length,
|
|---|
| 114 | unsigned int channel );
|
|---|
| 115 |
|
|---|
| 116 | int _sys_tty_read( char* buffer,
|
|---|
| 117 | unsigned int length,
|
|---|
| 118 | unsigned int channel );
|
|---|
| 119 |
|
|---|
| 120 | int _sys_tty_get_lock( unsigned int channel,
|
|---|
| 121 | unsigned int * save_sr_ptr );
|
|---|
| 122 |
|
|---|
| 123 | int _sys_tty_release_lock( unsigned int channel,
|
|---|
| 124 | unsigned int * save_sr_ptr );
|
|---|
| 125 |
|
|---|
| 126 | int _sys_coproc_register_set( unsigned int cluster_xy,
|
|---|
| 127 | unsigned int reg_index,
|
|---|
| 128 | unsigned int value );
|
|---|
| 129 |
|
|---|
| 130 | int _sys_coproc_register_get( unsigned int cluster_xy,
|
|---|
| 131 | unsigned int reg_index,
|
|---|
| 132 | unsigned int* buffer );
|
|---|
| 133 |
|
|---|
| 134 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 135 | // TIM related syscall handlers
|
|---|
| 136 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 137 |
|
|---|
| 138 | int _sys_tim_alloc();
|
|---|
| 139 |
|
|---|
| 140 | int _sys_tim_start( unsigned int period );
|
|---|
| 141 |
|
|---|
| 142 | int _sys_tim_stop();
|
|---|
| 143 |
|
|---|
| 144 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 145 | // NIC related syscall handlers
|
|---|
| 146 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 147 |
|
|---|
| 148 | int _sys_nic_alloc( unsigned int is_rx,
|
|---|
| 149 | unsigned int xmax,
|
|---|
| 150 | unsigned int ymax );
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 | int _sys_nic_start( unsigned int is_rx,
|
|---|
| 154 | unsigned int channel );
|
|---|
| 155 |
|
|---|
| 156 | int _sys_nic_move( unsigned int is_rx,
|
|---|
| 157 | unsigned int channel,
|
|---|
| 158 | void* buffer );
|
|---|
| 159 |
|
|---|
| 160 | int _sys_nic_stop( unsigned int is_rx,
|
|---|
| 161 | unsigned int channel );
|
|---|
| 162 |
|
|---|
| 163 | int _sys_nic_clear( unsigned int is_rx,
|
|---|
| 164 | unsigned int channel );
|
|---|
| 165 |
|
|---|
| 166 | int _sys_nic_stats( unsigned int is_rx,
|
|---|
| 167 | unsigned int channel );
|
|---|
| 168 |
|
|---|
| 169 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 170 | // FBF related syscall handlers
|
|---|
| 171 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 172 |
|
|---|
| 173 | int _sys_fbf_sync_write( unsigned int offset,
|
|---|
| 174 | void* buffer,
|
|---|
| 175 | unsigned int length );
|
|---|
| 176 |
|
|---|
| 177 | int _sys_fbf_sync_read( unsigned int offset,
|
|---|
| 178 | void* buffer,
|
|---|
| 179 | unsigned int length );
|
|---|
| 180 |
|
|---|
| 181 | int _sys_fbf_cma_alloc();
|
|---|
| 182 |
|
|---|
| 183 | int _sys_fbf_cma_init_buf(void* buf0_vbase,
|
|---|
| 184 | void* buf1_vbase,
|
|---|
| 185 | void* sts0_vaddr,
|
|---|
| 186 | void* sts1_vaddr );
|
|---|
| 187 |
|
|---|
| 188 | int _sys_fbf_cma_start( unsigned int length );
|
|---|
| 189 |
|
|---|
| 190 | int _sys_fbf_cma_display( unsigned int buffer_index );
|
|---|
| 191 |
|
|---|
| 192 | int _sys_fbf_cma_stop();
|
|---|
| 193 |
|
|---|
| 194 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 195 | // Miscelaneous syscall handlers
|
|---|
| 196 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 197 |
|
|---|
| 198 | int _sys_ukn();
|
|---|
| 199 |
|
|---|
| 200 | int _sys_proc_xyp( unsigned int* x,
|
|---|
| 201 | unsigned int* y,
|
|---|
| 202 | unsigned int* p );
|
|---|
| 203 |
|
|---|
| 204 | int _sys_task_exit( char* string );
|
|---|
| 205 |
|
|---|
| 206 | int _sys_context_switch();
|
|---|
| 207 |
|
|---|
| 208 | int _sys_local_task_id();
|
|---|
| 209 |
|
|---|
| 210 | int _sys_global_task_id();
|
|---|
| 211 |
|
|---|
| 212 | int _sys_thread_id();
|
|---|
| 213 |
|
|---|
| 214 | int _sys_procs_number( unsigned int* x_size,
|
|---|
| 215 | unsigned int* y_size,
|
|---|
| 216 | unsigned int* nprocs );
|
|---|
| 217 |
|
|---|
| 218 | int _sys_vseg_get_vbase( char* vspace_name,
|
|---|
| 219 | char* vseg_name,
|
|---|
| 220 | unsigned int* vbase );
|
|---|
| 221 |
|
|---|
| 222 | int _sys_vseg_get_length( char* vspace_name,
|
|---|
| 223 | char* vseg_name,
|
|---|
| 224 | unsigned int* length );
|
|---|
| 225 |
|
|---|
| 226 | int _sys_xy_from_ptr( void* ptr,
|
|---|
| 227 | unsigned int* x,
|
|---|
| 228 | unsigned int* y );
|
|---|
| 229 |
|
|---|
| 230 | int _sys_heap_info( unsigned int* vaddr,
|
|---|
| 231 | unsigned int* length,
|
|---|
| 232 | unsigned int x,
|
|---|
| 233 | unsigned int y );
|
|---|
| 234 |
|
|---|
| 235 | #endif
|
|---|
| 236 |
|
|---|
| 237 | // Local Variables:
|
|---|
| 238 | // tab-width: 4
|
|---|
| 239 | // c-basic-offset: 4
|
|---|
| 240 | // c-file-offsets:((innamespace . 0)(inline-open . 0))
|
|---|
| 241 | // indent-tabs-mode: nil
|
|---|
| 242 | // End:
|
|---|
| 243 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
|
|---|
| 244 |
|
|---|