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

Last change on this file since 710 was 709, checked in by alain, 9 years ago

Major release: Change the task model to implement the POSIX threads API.

  • The shell "exec" and "kill" commands can be used to activate/de-activate the applications.
  • The "pause", "resume", and "context" commands can be used to stop, restart, a single thtead or to display the thread context.

This version has been tested on the following multi-threaded applications,
that have been modified to use the POSIX threads:

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