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

Last change on this file since 712 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
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///////////////////////////////////////////////////////////////////////////////
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///////////////////////////////////////////////////////////////////////////////
49//     Syscall Vector Table (indexed by syscall index)
50///////////////////////////////////////////////////////////////////////////////
51
52extern const void * _syscall_vector[64];
53
54///////////////////////////////////////////////////////////////////////////////
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
59// the software L2/L3 cache coherence when the IO bridge is used.
60///////////////////////////////////////////////////////////////////////////////
61
62typedef struct buffer_status_s
63{
64    unsigned int status;
65    unsigned int padding[15];
66} buffer_status_t;
67
68///////////////////////////////////////////////////////////////////////////////
69// This structure is used by the CMA component to move a stream
70// of images from two user buffers to the frame buffer in kernel space.
71// It contains two chbuf arrays:
72// - The SRC chbuf contains two buffers (buf0 & buf1), in user space.
73// - The DST cbuf contains one single buffer (fbf), that is the frame buffer.
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)
81// This structure must be 64 bytes aligned.
82///////////////////////////////////////////////////////////////////////////////
83
84typedef struct fbf_chbuf_s
85{
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
91} fbf_chbuf_t;   
92
93///////////////////////////////////////////////////////////////////////////////
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
96// containing up to (X_SIZE * Y_SIZE) buffers (one buffer per cluster).
97// The same structure is used for both TX or RX transfers.
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).
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
106// This structure must be 64 bytes aligned.
107///////////////////////////////////////////////////////////////////////////////
108
109typedef struct ker_chbuf_s
110{
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;
115
116
117//////////////////////////////////////////////////////////////////////////////
118//           Applications related syscall handlers
119//////////////////////////////////////////////////////////////////////////////
120
121extern int _sys_kill_application( char* name );
122
123extern int _sys_exec_application( char* name );
124
125extern int _sys_applications_status();
126
127/////////////////////////////////////////////////////////////////////////////
128//          Threads related syscall handlers
129/////////////////////////////////////////////////////////////////////////////
130
131extern int _sys_pthread_create( unsigned int*  buffer,
132                                void*          attr,
133                                void*          function,
134                                void*          arg );
135
136extern int _sys_pthread_join( unsigned int  trdid,
137                              void*         ptr );
138
139extern int _sys_pthread_kill( unsigned int  trdid,
140                              int           signal );
141
142extern int _sys_pthread_exit( void* string);
143
144extern int _sys_pthread_yield();
145
146extern int _sys_pthread_control( unsigned int  command,
147                                 char*         vspace_name,
148                                 char*         thread_name );
149
150///////////////////////////////////////////////////////////////////////////////
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///////////////////////////////////////////////////////////////////////////////
167//    TTY related syscall handlers
168///////////////////////////////////////////////////////////////////////////////
169
170extern int _sys_tty_alloc( unsigned int shared );
171
172extern int _sys_tty_release();
173
174extern int _sys_tty_write( const char*  buffer,
175                    unsigned int length,
176                    unsigned int channel );
177
178extern int _sys_tty_read(  char*        buffer,
179                    unsigned int length,
180                    unsigned int channel );
181
182//////////////////////////////////////////////////////////////////////////////
183//    TIM related syscall handlers
184//////////////////////////////////////////////////////////////////////////////
185
186extern int _sys_tim_alloc();
187
188extern int _sys_tim_release();
189
190extern int _sys_tim_start( unsigned int period );
191
192extern int _sys_tim_stop();
193
194//////////////////////////////////////////////////////////////////////////////
195//    NIC related syscall handlers
196//////////////////////////////////////////////////////////////////////////////
197
198extern int _sys_nic_alloc( unsigned int is_rx,
199                           unsigned int xmax,
200                           unsigned int ymax );
201
202extern int _sys_nic_release( unsigned int is_rx );
203
204extern int _sys_nic_start( unsigned int is_rx );
205
206extern int _sys_nic_move( unsigned int is_rx,
207                          void*        buffer );
208
209extern int _sys_nic_stop( unsigned int is_rx );
210
211extern int _sys_nic_clear( unsigned int is_rx );
212
213extern int _sys_nic_stats( unsigned int is_rx );
214
215//////////////////////////////////////////////////////////////////////////////
216//    FBF related syscall handlers
217//////////////////////////////////////////////////////////////////////////////
218
219extern int _sys_fbf_sync_write( unsigned int offset,
220                         void*        buffer,
221                         unsigned int length );
222
223extern int _sys_fbf_sync_read(  unsigned int offset,
224                         void*        buffer,
225                         unsigned int length );
226
227extern int _sys_fbf_cma_alloc();
228
229extern int _sys_fbf_cma_release();
230
231extern int _sys_fbf_cma_init_buf(void*        buf0_vbase, 
232                          void*        buf1_vbase, 
233                          void*        sts0_vaddr,
234                          void*        sts1_vaddr );
235
236extern int _sys_fbf_cma_start( unsigned int length );
237
238extern int _sys_fbf_cma_display( unsigned int buffer_index );
239
240extern int _sys_fbf_cma_stop();
241
242//////////////////////////////////////////////////////////////////////////////
243//    Miscelaneous syscall handlers
244//////////////////////////////////////////////////////////////////////////////
245
246extern int _sys_ukn();
247
248extern int _sys_proc_xyp( unsigned int* x,
249                   unsigned int* y,
250                   unsigned int* p );
251
252extern int _sys_procs_number( unsigned int* x_size,
253                       unsigned int* y_size, 
254                       unsigned int* nprocs );
255
256extern int _sys_vseg_get_vbase( char*         vspace_name,
257                         char*         vseg_name,
258                         unsigned int* vbase );
259
260extern int _sys_vseg_get_length( char*         vspace_name, 
261                          char*         vseg_name,
262                          unsigned int* length );
263
264extern int _sys_xy_from_ptr( void*          ptr,
265                      unsigned int*  x,
266                      unsigned int*  y );
267
268extern int _sys_heap_info( unsigned int* vaddr, 
269                    unsigned int* length,
270                    unsigned int  x,
271                    unsigned int  y ); 
272
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.