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 | // Define the possible command values for the giet_pthread_control() syscall |
---|
21 | // These define must be synchronized with values in the stdio.c file |
---|
22 | /////////////////////////////////////////////////////////////////////////////// |
---|
23 | |
---|
24 | #define THREAD_CMD_PAUSE 0 |
---|
25 | #define THREAD_CMD_RESUME 1 |
---|
26 | #define THREAD_CMD_CONTEXT 2 |
---|
27 | |
---|
28 | /////////////////////////////////////////////////////////////////////////////// |
---|
29 | // Define the error codes for the syscall handlers |
---|
30 | // These define must be synchronized with values in the stdio.c file |
---|
31 | /////////////////////////////////////////////////////////////////////////////// |
---|
32 | |
---|
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) |
---|
53 | #define SYSCALL_ILLEGAL_ARGUMENT (-20) |
---|
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) |
---|
58 | |
---|
59 | /////////////////////////////////////////////////////////////////////////////// |
---|
60 | // Syscall Vector Table (indexed by syscall index) |
---|
61 | /////////////////////////////////////////////////////////////////////////////// |
---|
62 | |
---|
63 | extern const void * _syscall_vector[64]; |
---|
64 | |
---|
65 | /////////////////////////////////////////////////////////////////////////////// |
---|
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. |
---|
68 | // It contains two chbuf arrays: |
---|
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. |
---|
72 | // Each buffer is described with a 64 bits buffer descriptor: |
---|
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. |
---|
80 | // This structure must be 64 bytes aligned. |
---|
81 | /////////////////////////////////////////////////////////////////////////////// |
---|
82 | |
---|
83 | typedef struct fbf_chbuf_s |
---|
84 | { |
---|
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 |
---|
88 | } fbf_chbuf_t; |
---|
89 | |
---|
90 | /////////////////////////////////////////////////////////////////////////////// |
---|
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 |
---|
93 | // containing up to (X_SIZE * Y_SIZE) buffers (one buffer per cluster). |
---|
94 | // The same structure is used for both TX or RX transfers. |
---|
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). |
---|
97 | // Each buffer is described with a 64 bits buffer descriptor: |
---|
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. |
---|
102 | // This structure must be 64 bytes aligned. |
---|
103 | /////////////////////////////////////////////////////////////////////////////// |
---|
104 | |
---|
105 | typedef struct nic_chbuf_s |
---|
106 | { |
---|
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 |
---|
110 | } nic_chbuf_t; |
---|
111 | |
---|
112 | |
---|
113 | ////////////////////////////////////////////////////////////////////////////// |
---|
114 | // Applications related syscall handlers |
---|
115 | ////////////////////////////////////////////////////////////////////////////// |
---|
116 | |
---|
117 | extern int _sys_kill_application( char* name ); |
---|
118 | |
---|
119 | extern int _sys_exec_application( char* name ); |
---|
120 | |
---|
121 | extern int _sys_applications_status( char* name ); |
---|
122 | |
---|
123 | ///////////////////////////////////////////////////////////////////////////// |
---|
124 | // Threads related syscall handlers |
---|
125 | ///////////////////////////////////////////////////////////////////////////// |
---|
126 | |
---|
127 | extern int _sys_pthread_create( unsigned int* buffer, |
---|
128 | void* attr, |
---|
129 | void* function, |
---|
130 | void* arg ); |
---|
131 | |
---|
132 | extern int _sys_pthread_join( unsigned int trdid, |
---|
133 | void* ptr ); |
---|
134 | |
---|
135 | extern int _sys_pthread_kill( unsigned int trdid, |
---|
136 | int signal ); |
---|
137 | |
---|
138 | extern int _sys_pthread_exit( void* string); |
---|
139 | |
---|
140 | extern int _sys_pthread_yield(); |
---|
141 | |
---|
142 | extern int _sys_pthread_control( unsigned int command, |
---|
143 | char* vspace_name, |
---|
144 | char* thread_name ); |
---|
145 | |
---|
146 | /////////////////////////////////////////////////////////////////////////////// |
---|
147 | // Coprocessors related syscall handlers |
---|
148 | /////////////////////////////////////////////////////////////////////////////// |
---|
149 | |
---|
150 | extern int _sys_coproc_alloc( unsigned int coproc_type, |
---|
151 | unsigned int* coproc_info ); |
---|
152 | |
---|
153 | extern int _sys_coproc_release( unsigned int coproc_reg_index ); |
---|
154 | |
---|
155 | extern int _sys_coproc_channel_init( unsigned int channel, |
---|
156 | giet_coproc_channel_t* desc ); |
---|
157 | |
---|
158 | extern int _sys_coproc_run( unsigned int coproc_reg_index ); |
---|
159 | |
---|
160 | extern int _sys_coproc_completed(); |
---|
161 | |
---|
162 | /////////////////////////////////////////////////////////////////////////////// |
---|
163 | // TTY related syscall handlers |
---|
164 | /////////////////////////////////////////////////////////////////////////////// |
---|
165 | |
---|
166 | extern int _sys_tty_alloc( unsigned int shared ); |
---|
167 | |
---|
168 | extern int _sys_tty_release(); |
---|
169 | |
---|
170 | extern int _sys_tty_write( const char* buffer, |
---|
171 | unsigned int length, |
---|
172 | unsigned int channel ); |
---|
173 | |
---|
174 | extern int _sys_tty_read( char* buffer, |
---|
175 | unsigned int length, |
---|
176 | unsigned int channel ); |
---|
177 | |
---|
178 | ////////////////////////////////////////////////////////////////////////////// |
---|
179 | // TIM related syscall handlers |
---|
180 | ////////////////////////////////////////////////////////////////////////////// |
---|
181 | |
---|
182 | extern int _sys_tim_alloc(); |
---|
183 | |
---|
184 | extern int _sys_tim_release(); |
---|
185 | |
---|
186 | extern int _sys_tim_start( unsigned int period ); |
---|
187 | |
---|
188 | extern int _sys_tim_stop(); |
---|
189 | |
---|
190 | ////////////////////////////////////////////////////////////////////////////// |
---|
191 | // NIC related syscall handlers |
---|
192 | ////////////////////////////////////////////////////////////////////////////// |
---|
193 | |
---|
194 | extern int _sys_nic_alloc( unsigned int is_rx, |
---|
195 | unsigned int xmax, |
---|
196 | unsigned int ymax ); |
---|
197 | |
---|
198 | extern int _sys_nic_release( unsigned int is_rx ); |
---|
199 | |
---|
200 | extern int _sys_nic_start( unsigned int is_rx ); |
---|
201 | |
---|
202 | extern int _sys_nic_move( unsigned int is_rx, |
---|
203 | void* buffer ); |
---|
204 | |
---|
205 | extern int _sys_nic_stop( unsigned int is_rx ); |
---|
206 | |
---|
207 | extern int _sys_nic_clear( unsigned int is_rx ); |
---|
208 | |
---|
209 | extern int _sys_nic_stats( unsigned int is_rx ); |
---|
210 | |
---|
211 | ////////////////////////////////////////////////////////////////////////////// |
---|
212 | // FBF related syscall handlers |
---|
213 | ////////////////////////////////////////////////////////////////////////////// |
---|
214 | |
---|
215 | extern int _sys_fbf_size( unsigned int* width, |
---|
216 | unsigned int* height ); |
---|
217 | |
---|
218 | extern int _sys_fbf_alloc(); |
---|
219 | |
---|
220 | extern int _sys_fbf_release(); |
---|
221 | |
---|
222 | extern int _sys_fbf_sync_write( unsigned int offset, |
---|
223 | void* buffer, |
---|
224 | unsigned int length ); |
---|
225 | |
---|
226 | extern int _sys_fbf_sync_read( unsigned int offset, |
---|
227 | void* buffer, |
---|
228 | unsigned int length ); |
---|
229 | |
---|
230 | extern int _sys_fbf_cma_alloc( unsigned int nbufs ); |
---|
231 | |
---|
232 | extern int _sys_fbf_cma_release(); |
---|
233 | |
---|
234 | extern int _sys_fbf_cma_init_buf( unsigned int index, |
---|
235 | void* buf_vaddr, |
---|
236 | void* sts_vaddr ); |
---|
237 | |
---|
238 | extern int _sys_fbf_cma_start(); |
---|
239 | |
---|
240 | extern int _sys_fbf_cma_display( unsigned int index ); |
---|
241 | |
---|
242 | extern int _sys_fbf_cma_check( unsigned int index ); |
---|
243 | |
---|
244 | extern int _sys_fbf_cma_stop(); |
---|
245 | |
---|
246 | ////////////////////////////////////////////////////////////////////////////// |
---|
247 | // Miscelaneous syscall handlers |
---|
248 | ////////////////////////////////////////////////////////////////////////////// |
---|
249 | |
---|
250 | extern int _sys_ukn(); |
---|
251 | |
---|
252 | extern int _sys_proc_xyp( unsigned int* x, |
---|
253 | unsigned int* y, |
---|
254 | unsigned int* p ); |
---|
255 | |
---|
256 | extern int _sys_procs_number( unsigned int* x_size, |
---|
257 | unsigned int* y_size, |
---|
258 | unsigned int* nprocs ); |
---|
259 | |
---|
260 | extern int _sys_vseg_get_vbase( char* vspace_name, |
---|
261 | char* vseg_name, |
---|
262 | unsigned int* vbase ); |
---|
263 | |
---|
264 | extern int _sys_vseg_get_length( char* vspace_name, |
---|
265 | char* vseg_name, |
---|
266 | unsigned int* length ); |
---|
267 | |
---|
268 | extern int _sys_xy_from_ptr( void* ptr, |
---|
269 | unsigned int* x, |
---|
270 | unsigned int* y ); |
---|
271 | |
---|
272 | extern int _sys_heap_info( unsigned int* vaddr, |
---|
273 | unsigned int* length, |
---|
274 | unsigned int x, |
---|
275 | unsigned int y ); |
---|
276 | |
---|
277 | #endif |
---|
278 | |
---|
279 | // Local Variables: |
---|
280 | // tab-width: 4 |
---|
281 | // c-basic-offset: 4 |
---|
282 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
283 | // indent-tabs-mode: nil |
---|
284 | // End: |
---|
285 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
286 | |
---|