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

Last change on this file since 718 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
RevLine 
[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///////////////////////////////////////////////////////////////////////////////
[709]20// Define the possible command values for the giet_pthread_control() syscall
[714]21// These define must be synchronized with values in the stdio.c file
[709]22///////////////////////////////////////////////////////////////////////////////
23
24#define THREAD_CMD_PAUSE        0
25#define THREAD_CMD_RESUME       1
26#define THREAD_CMD_CONTEXT      2
27
28///////////////////////////////////////////////////////////////////////////////
[714]29// Define the error codes for the syscall handlers
30// These define must be synchronized with values in the stdio.c file
[709]31///////////////////////////////////////////////////////////////////////////////
32
[714]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)
[709]58
59///////////////////////////////////////////////////////////////////////////////
[258]60//     Syscall Vector Table (indexed by syscall index)
[505]61///////////////////////////////////////////////////////////////////////////////
[258]62
63extern const void * _syscall_vector[64];
64
[505]65///////////////////////////////////////////////////////////////////////////////
[614]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
[478]70// the software L2/L3 cache coherence when the IO bridge is used.
[505]71///////////////////////////////////////////////////////////////////////////////
[478]72
[614]73typedef struct buffer_status_s
[478]74{
[614]75    unsigned int status;
76    unsigned int padding[15];
77} buffer_status_t;
78
[505]79///////////////////////////////////////////////////////////////////////////////
[459]80// This structure is used by the CMA component to move a stream
[478]81// of images from two user buffers to the frame buffer in kernel space.
[459]82// It contains two chbuf arrays:
[478]83// - The SRC chbuf contains two buffers (buf0 & buf1), in user space.
[440]84// - The DST cbuf contains one single buffer (fbf), that is the frame buffer.
[614]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)
[494]92// This structure must be 64 bytes aligned.
[505]93///////////////////////////////////////////////////////////////////////////////
[440]94
95typedef struct fbf_chbuf_s
96{
[614]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
[440]102} fbf_chbuf_t;   
103
[505]104///////////////////////////////////////////////////////////////////////////////
[478]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
[494]107// containing up to (X_SIZE * Y_SIZE) buffers (one buffer per cluster).
[449]108// The same structure is used for both TX or RX transfers.
[494]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).
[614]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
[494]117// This structure must be 64 bytes aligned.
[505]118///////////////////////////////////////////////////////////////////////////////
[449]119
[614]120typedef struct ker_chbuf_s
[449]121{
[614]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;
[449]126
[519]127
[709]128//////////////////////////////////////////////////////////////////////////////
129//           Applications related syscall handlers
130//////////////////////////////////////////////////////////////////////////////
[519]131
[709]132extern int _sys_kill_application( char* name );
[519]133
[709]134extern int _sys_exec_application( char* name );
[519]135
[714]136extern int _sys_applications_status( char* name );
[670]137
[709]138/////////////////////////////////////////////////////////////////////////////
139//          Threads related syscall handlers
140/////////////////////////////////////////////////////////////////////////////
[670]141
[709]142extern int _sys_pthread_create( unsigned int*  buffer,
143                                void*          attr,
144                                void*          function,
145                                void*          arg );
[519]146
[709]147extern int _sys_pthread_join( unsigned int  trdid,
148                              void*         ptr );
[519]149
[709]150extern int _sys_pthread_kill( unsigned int  trdid,
151                              int           signal );
[519]152
[709]153extern int _sys_pthread_exit( void* string);
[519]154
[709]155extern int _sys_pthread_yield();
[519]156
[709]157extern int _sys_pthread_control( unsigned int  command,
158                                 char*         vspace_name,
159                                 char*         thread_name );
160
[519]161///////////////////////////////////////////////////////////////////////////////
[709]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///////////////////////////////////////////////////////////////////////////////
[440]178//    TTY related syscall handlers
[505]179///////////////////////////////////////////////////////////////////////////////
[258]180
[709]181extern int _sys_tty_alloc( unsigned int shared );
[294]182
[709]183extern int _sys_tty_release();
[695]184
[709]185extern int _sys_tty_write( const char*  buffer,
[440]186                    unsigned int length,
187                    unsigned int channel );
[428]188
[709]189extern int _sys_tty_read(  char*        buffer,
[440]190                    unsigned int length,
191                    unsigned int channel );
[294]192
[440]193//////////////////////////////////////////////////////////////////////////////
194//    TIM related syscall handlers
195//////////////////////////////////////////////////////////////////////////////
[294]196
[709]197extern int _sys_tim_alloc();
[258]198
[709]199extern int _sys_tim_release();
[695]200
[709]201extern int _sys_tim_start( unsigned int period );
[258]202
[709]203extern int _sys_tim_stop();
[258]204
[440]205//////////////////////////////////////////////////////////////////////////////
206//    NIC related syscall handlers
207//////////////////////////////////////////////////////////////////////////////
[294]208
[709]209extern int _sys_nic_alloc( unsigned int is_rx,
210                           unsigned int xmax,
211                           unsigned int ymax );
[396]212
[709]213extern int _sys_nic_release( unsigned int is_rx );
[494]214
[709]215extern int _sys_nic_start( unsigned int is_rx );
[396]216
[709]217extern int _sys_nic_move( unsigned int is_rx,
218                          void*        buffer );
[440]219
[709]220extern int _sys_nic_stop( unsigned int is_rx );
[449]221
[709]222extern int _sys_nic_clear( unsigned int is_rx );
[459]223
[709]224extern int _sys_nic_stats( unsigned int is_rx );
[459]225
[440]226//////////////////////////////////////////////////////////////////////////////
227//    FBF related syscall handlers
228//////////////////////////////////////////////////////////////////////////////
229
[714]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
[709]237extern int _sys_fbf_sync_write( unsigned int offset,
[440]238                         void*        buffer,
239                         unsigned int length );
240
[709]241extern int _sys_fbf_sync_read(  unsigned int offset,
[440]242                         void*        buffer,
243                         unsigned int length );
244
[709]245extern int _sys_fbf_cma_alloc();
[440]246
[709]247extern int _sys_fbf_cma_release();
[700]248
[709]249extern int _sys_fbf_cma_init_buf(void*        buf0_vbase, 
[714]250                                 void*        buf1_vbase, 
251                                 void*        sts0_vaddr,
252                                 void*        sts1_vaddr );
[440]253
[709]254extern int _sys_fbf_cma_start( unsigned int length );
[614]255
[709]256extern int _sys_fbf_cma_display( unsigned int buffer_index );
[440]257
[709]258extern int _sys_fbf_cma_stop();
[440]259
260//////////////////////////////////////////////////////////////////////////////
261//    Miscelaneous syscall handlers
262//////////////////////////////////////////////////////////////////////////////
263
[709]264extern int _sys_ukn();
[440]265
[709]266extern int _sys_proc_xyp( unsigned int* x,
[440]267                   unsigned int* y,
268                   unsigned int* p );
269
[709]270extern int _sys_procs_number( unsigned int* x_size,
[494]271                       unsigned int* y_size, 
272                       unsigned int* nprocs );
[440]273
[709]274extern int _sys_vseg_get_vbase( char*         vspace_name,
[516]275                         char*         vseg_name,
[440]276                         unsigned int* vbase );
277
[709]278extern int _sys_vseg_get_length( char*         vspace_name, 
[516]279                          char*         vseg_name,
[440]280                          unsigned int* length );
281
[709]282extern int _sys_xy_from_ptr( void*          ptr,
[440]283                      unsigned int*  x,
284                      unsigned int*  y );
285
[709]286extern int _sys_heap_info( unsigned int* vaddr, 
[440]287                    unsigned int* length,
288                    unsigned int  x,
289                    unsigned int  y ); 
290
[258]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.