source: soft/giet_vm/giet_kernel/sys_handler.h @ 716

Last change on this file since 716 was 714, checked in by alain, 9 years ago

Introduce the _sys_fbf_size() function.
Modify the _sys_fbf_alloc() / _sys_fbf_release() functions
to allow all threads of a given vspace to access the frame buffer.
(replace the lock by a multi-threads allocator.

  • Property svn:executable set to *
File size: 11.8 KB
Line 
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_XY_ARGUMENTS             (-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
63extern const void * _syscall_vector[64];
64
65///////////////////////////////////////////////////////////////////////////////
66// This structure is used by the CMA component to store the status of the
67// frame buffer (full or empty). The useful information is contained in the
68// "status" integer (1 for full and 0 for empty).
69// This structure must be aligned on a cache line (64 bytes) to simplify
70// the software L2/L3 cache coherence when the IO bridge is used.
71///////////////////////////////////////////////////////////////////////////////
72
73typedef struct buffer_status_s
74{
75    unsigned int status;
76    unsigned int padding[15];
77} buffer_status_t;
78
79///////////////////////////////////////////////////////////////////////////////
80// This structure is used by the CMA component to move a stream
81// of images from two user buffers to the frame buffer in kernel space.
82// It contains two chbuf arrays:
83// - The SRC chbuf contains two buffers (buf0 & buf1), in user space.
84// - The DST cbuf contains one single buffer (fbf), that is the frame buffer.
85// Each buffer is described with a 64 bits buffer descriptor:
86// - the 26 LSB bits contain bits[6:31] of the buffer physical address
87// - the 26 following bits contain bits[6:31] of the physical address where the
88//   buffer status is located
89// - the 12 MSB bits contain the common address extension of the buffer and its
90//   status
91// The length field define the buffer size (bytes)
92// This structure must be 64 bytes aligned.
93///////////////////////////////////////////////////////////////////////////////
94
95typedef struct fbf_chbuf_s
96{
97    unsigned long long  buf0_desc;     // first user buffer descriptor
98    unsigned long long  buf1_desc;     // second user buffer descriptor
99    unsigned long long  fbf_desc;      // frame buffer descriptor
100    unsigned int        length;        // buffer length (bytes)
101    unsigned int        padding[9];    // padding for 64 bytes alignment
102} fbf_chbuf_t;   
103
104///////////////////////////////////////////////////////////////////////////////
105// This structure is used by the CMA component to move a stream of containers
106// between the NIC chbuf containing 2 buffers, and a kernel chbuf
107// containing up to (X_SIZE * Y_SIZE) buffers (one buffer per cluster).
108// The same structure is used for both TX or RX transfers.
109// The number of distributed containers can be smaller than (X_SIZE * YSIZE).
110// The actual number of buffers used in the chbuf is defined by (xmax * ymax).
111// Each buffer is described with a 64 bits buffer descriptor:
112// - the 26 LSB bits contain bits[6:31] of the buffer physical address
113// - the 26 following bits contain bits[6:31] of the physical address where the
114//   buffer status is located
115// - the 12 MSB bits contain the common address extension of the buffer and its
116//   status
117// This structure must be 64 bytes aligned.
118///////////////////////////////////////////////////////////////////////////////
119
120typedef struct ker_chbuf_s
121{
122    unsigned long long   buf_desc[X_SIZE*Y_SIZE]; // kernel chbuf descriptor
123    unsigned int         xmax;                        // nb clusters in a row
124    unsigned int         ymax;                        // nb clusters in a column
125} ker_chbuf_t;
126
127
128//////////////////////////////////////////////////////////////////////////////
129//           Applications related syscall handlers
130//////////////////////////////////////////////////////////////////////////////
131
132extern int _sys_kill_application( char* name );
133
134extern int _sys_exec_application( char* name );
135
136extern int _sys_applications_status( char* name );
137
138/////////////////////////////////////////////////////////////////////////////
139//          Threads related syscall handlers
140/////////////////////////////////////////////////////////////////////////////
141
142extern int _sys_pthread_create( unsigned int*  buffer,
143                                void*          attr,
144                                void*          function,
145                                void*          arg );
146
147extern int _sys_pthread_join( unsigned int  trdid,
148                              void*         ptr );
149
150extern int _sys_pthread_kill( unsigned int  trdid,
151                              int           signal );
152
153extern int _sys_pthread_exit( void* string);
154
155extern int _sys_pthread_yield();
156
157extern int _sys_pthread_control( unsigned int  command,
158                                 char*         vspace_name,
159                                 char*         thread_name );
160
161///////////////////////////////////////////////////////////////////////////////
162//          Coprocessors related syscall handlers
163///////////////////////////////////////////////////////////////////////////////
164
165extern int _sys_coproc_alloc( unsigned int   coproc_type,
166                              unsigned int*  coproc_info );
167
168extern int _sys_coproc_release( unsigned int coproc_reg_index );
169
170extern int _sys_coproc_channel_init( unsigned int            channel,
171                                     giet_coproc_channel_t*  desc );
172
173extern int _sys_coproc_run( unsigned int coproc_reg_index );
174
175extern int _sys_coproc_completed();
176
177///////////////////////////////////////////////////////////////////////////////
178//    TTY related syscall handlers
179///////////////////////////////////////////////////////////////////////////////
180
181extern int _sys_tty_alloc( unsigned int shared );
182
183extern int _sys_tty_release();
184
185extern int _sys_tty_write( const char*  buffer,
186                    unsigned int length,
187                    unsigned int channel );
188
189extern int _sys_tty_read(  char*        buffer,
190                    unsigned int length,
191                    unsigned int channel );
192
193//////////////////////////////////////////////////////////////////////////////
194//    TIM related syscall handlers
195//////////////////////////////////////////////////////////////////////////////
196
197extern int _sys_tim_alloc();
198
199extern int _sys_tim_release();
200
201extern int _sys_tim_start( unsigned int period );
202
203extern int _sys_tim_stop();
204
205//////////////////////////////////////////////////////////////////////////////
206//    NIC related syscall handlers
207//////////////////////////////////////////////////////////////////////////////
208
209extern int _sys_nic_alloc( unsigned int is_rx,
210                           unsigned int xmax,
211                           unsigned int ymax );
212
213extern int _sys_nic_release( unsigned int is_rx );
214
215extern int _sys_nic_start( unsigned int is_rx );
216
217extern int _sys_nic_move( unsigned int is_rx,
218                          void*        buffer );
219
220extern int _sys_nic_stop( unsigned int is_rx );
221
222extern int _sys_nic_clear( unsigned int is_rx );
223
224extern int _sys_nic_stats( unsigned int is_rx );
225
226//////////////////////////////////////////////////////////////////////////////
227//    FBF related syscall handlers
228//////////////////////////////////////////////////////////////////////////////
229
230extern int _sys_fbf_size( unsigned int* width,
231                          unsigned int* height );
232
233extern int _sys_fbf_alloc();
234
235extern int _sys_fbf_release();
236
237extern int _sys_fbf_sync_write( unsigned int offset,
238                         void*        buffer,
239                         unsigned int length );
240
241extern int _sys_fbf_sync_read(  unsigned int offset,
242                         void*        buffer,
243                         unsigned int length );
244
245extern int _sys_fbf_cma_alloc();
246
247extern int _sys_fbf_cma_release();
248
249extern int _sys_fbf_cma_init_buf(void*        buf0_vbase, 
250                                 void*        buf1_vbase, 
251                                 void*        sts0_vaddr,
252                                 void*        sts1_vaddr );
253
254extern int _sys_fbf_cma_start( unsigned int length );
255
256extern int _sys_fbf_cma_display( unsigned int buffer_index );
257
258extern int _sys_fbf_cma_stop();
259
260//////////////////////////////////////////////////////////////////////////////
261//    Miscelaneous syscall handlers
262//////////////////////////////////////////////////////////////////////////////
263
264extern int _sys_ukn();
265
266extern int _sys_proc_xyp( unsigned int* x,
267                   unsigned int* y,
268                   unsigned int* p );
269
270extern int _sys_procs_number( unsigned int* x_size,
271                       unsigned int* y_size, 
272                       unsigned int* nprocs );
273
274extern int _sys_vseg_get_vbase( char*         vspace_name,
275                         char*         vseg_name,
276                         unsigned int* vbase );
277
278extern int _sys_vseg_get_length( char*         vspace_name, 
279                          char*         vseg_name,
280                          unsigned int* length );
281
282extern int _sys_xy_from_ptr( void*          ptr,
283                      unsigned int*  x,
284                      unsigned int*  y );
285
286extern int _sys_heap_info( unsigned int* vaddr, 
287                    unsigned int* length,
288                    unsigned int  x,
289                    unsigned int  y ); 
290
291#endif
292
293// Local Variables:
294// tab-width: 4
295// c-basic-offset: 4
296// c-file-offsets:((innamespace . 0)(inline-open . 0))
297// indent-tabs-mode: nil
298// End:
299// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
300
Note: See TracBrowser for help on using the repository browser.