source: soft/giet_vm/giet_libs/stdio.h @ 661

Last change on this file since 661 was 661, checked in by guerin, 9 years ago

remove deprecated giet_fat_list()

  • Property svn:executable set to *
File size: 13.4 KB
Line 
1/////////////////////////////////////////////////////////////////////////////
2// File     : stdio.h         
3// Date     : 01/04/2010
4// Author   : alain greiner & Joel Porquet
5// Copyright (c) UPMC-LIP6
6/////////////////////////////////////////////////////////////////////////////
7// The stdio.c and stdio.h files are part of the GIET_VM nano-kernel.
8// This library contains all user-level functions that contain a system call
9// to access protected or shared ressources.
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _STDIO_H
13#define _STDIO_H
14
15// These define must be synchronised with
16// the _syscall_vector defined in file sys_handler.c
17
18#define SYSCALL_PROC_XYP             0x00
19#define SYSCALL_PROC_TIME            0x01
20#define SYSCALL_TTY_WRITE            0x02
21#define SYSCALL_TTY_READ             0x03
22#define SYSCALL_TTY_ALLOC            0x04
23#define SYSCALL_TTY_GET_LOCK         0x05
24#define SYSCALL_TTY_RELEASE_LOCK     0x06
25#define SYSCALL_HEAP_INFO            0x07
26#define SYSCALL_LOCAL_TASK_ID        0x08
27#define SYSCALL_GLOBAL_TASK_ID       0x09
28#define SYSCALL_FBF_CMA_ALLOC        0x0A
29#define SYSCALL_FBF_CMA_INIT_BUF     0x0B
30#define SYSCALL_FBF_CMA_START        0x0C
31#define SYSCALL_FBF_CMA_DISPLAY      0x0D
32#define SYSCALL_FBF_CMA_STOP         0x0E
33#define SYSCALL_EXIT                 0x0F
34
35#define SYSCALL_PROCS_NUMBER         0x10
36#define SYSCALL_FBF_SYNC_WRITE       0x11
37#define SYSCALL_FBF_SYNC_READ        0x12
38#define SYSCALL_THREAD_ID            0x13
39#define SYSCALL_TIM_ALLOC            0x14
40#define SYSCALL_TIM_START            0x15
41#define SYSCALL_TIM_STOP             0x16
42#define SYSCALL_KILL_APP             0x17
43#define SYSCALL_EXEC_APP             0x18
44#define SYSCALL_CTX_SWITCH           0x19
45#define SYSCALL_VOBJ_GET_VBASE       0x1A
46#define SYSCALL_VOBJ_GET_LENGTH      0x1B
47#define SYSCALL_GET_XY               0x1C
48//                                   0x1D
49//                                   0x1E
50//                                   0x1F
51
52#define SYSCALL_FAT_OPEN             0x20
53#define SYSCALL_FAT_READ             0x21
54#define SYSCALL_FAT_WRITE            0x22
55#define SYSCALL_FAT_LSEEK            0x23
56#define SYSCALL_FAT_FINFO            0x24
57#define SYSCALL_FAT_CLOSE            0x25
58#define SYSCALL_FAT_REMOVE           0x26
59#define SYSCALL_FAT_RENAME           0x27
60#define SYSCALL_FAT_MKDIR            0x28
61#define SYSCALL_FAT_OPENDIR          0x29
62#define SYSCALL_FAT_CLOSEDIR         0x2A
63#define SYSCALL_FAT_READDIR          0x2B
64//                                   0x2C
65//                                   0x2D
66//                                   0x2E
67//                                   0x2F
68
69#define SYSCALL_NIC_ALLOC            0x30
70#define SYSCALL_NIC_START            0x31
71#define SYSCALL_NIC_MOVE             0x32
72#define SYSCALL_NIC_STOP             0x33
73#define SYSCALL_NIC_STATS            0x34
74#define SYSCALL_NIC_CLEAR            0x35
75//                                   0x36
76//                                   0x37
77//                                   0x38
78//                                   0x39
79//                                   0x3A
80#define SYSCALL_COPROC_COMPLETED     0x3B
81#define SYSCALL_COPROC_ALLOC         0x3C
82#define SYSCALL_COPROC_CHANNEL_INIT  0x3D
83#define SYSCALL_COPROC_RUN           0x3E
84#define SYSCALL_COPROC_RELEASE       0x3F
85
86////////////////////////////////////////////////////////////////////////////
87// These define must be synchronised vith values defined in fat32.h
88////////////////////////////////////////////////////////////////////////////
89
90#ifndef _FAT32_SHARED
91#define _FAT32_SHARED
92typedef struct fat_file_info_s
93{
94    unsigned int size;
95    unsigned int offset;
96    unsigned int is_dir;
97}   fat_file_info_t;
98
99typedef struct fat_dirent_s
100{
101    unsigned int cluster;
102    unsigned int size;
103    unsigned int is_dir;
104    char name[36];
105}   fat_dirent_t;
106
107#define SEEK_SET            0          // argument for giet_fat_lseek()
108#define SEEK_CUR            1          // argument for giet_fat_lseek
109
110#define O_RDONLY            0x01       // argument for giet_fat_open()
111#define O_TRUNC             0x10       // argument for giet_fat_open()
112#define O_CREATE            0x20       // argument for giet_fat_open()
113#endif // _FAT32_SHARED
114
115////////////////////////////////////////////////////////////////////////////
116// NULL pointer definition
117////////////////////////////////////////////////////////////////////////////
118
119#define NULL (void *)0
120
121////////////////////////////////////////////////////////////////////////////
122// This generic C function is used to implement all system calls.
123// It writes the system call arguments in the proper registers,
124// and tells GCC what has been modified by system call execution.
125// Returns -1 to signal an error.
126////////////////////////////////////////////////////////////////////////////
127static inline int sys_call( int call_no,
128                            int arg_0, 
129                            int arg_1, 
130                            int arg_2, 
131                            int arg_3 ) 
132{
133    register int reg_no_and_output asm("v0") = call_no;
134    register int reg_a0 asm("a0") = arg_0;
135    register int reg_a1 asm("a1") = arg_1;
136    register int reg_a2 asm("a2") = arg_2;
137    register int reg_a3 asm("a3") = arg_3;
138
139    asm volatile(
140            "syscall"
141            : "+r" (reg_no_and_output), /* input/output argument */
142              "+r" (reg_a0),             
143              "+r" (reg_a1),
144              "+r" (reg_a2),
145              "+r" (reg_a3),
146              "+r" (reg_no_and_output)
147            : /* input arguments */
148            : "memory",
149            /* These persistant registers will be saved on the stack by the
150             * compiler only if they contain relevant data. */
151            "at",
152            "v1",
153            "ra",
154            "t0",
155            "t1",
156            "t2",
157            "t3",
158            "t4",
159            "t5",
160            "t6",
161            "t7",
162            "t8",
163            "t9"
164               );
165    return (volatile int)reg_no_and_output;
166}
167
168//////////////////////////////////////////////////////////////////////////
169//               MIPS32 related system calls
170//////////////////////////////////////////////////////////////////////////
171
172extern void giet_proc_xyp( unsigned int* cluster_x,
173                           unsigned int* cluster_y,
174                           unsigned int* lpid );
175
176extern unsigned int giet_proctime();
177
178extern unsigned int giet_rand();
179
180//////////////////////////////////////////////////////////////////////////
181//              Task related system calls
182//////////////////////////////////////////////////////////////////////////
183
184extern unsigned int giet_proc_task_id();
185
186extern unsigned int giet_global_task_id(); 
187
188extern unsigned int giet_thread_id(); 
189
190extern void giet_exit( char* string );
191
192extern void giet_assert( unsigned int condition, 
193                         char*        string );
194
195extern void giet_context_switch();
196
197//////////////////////////////////////////////////////////////////////////
198//               Application related system calls
199//////////////////////////////////////////////////////////////////////////
200
201extern int giet_kill_application( char* name );
202
203extern int giet_exec_application( char* name );
204
205//////////////////////////////////////////////////////////////////////////
206//             Coprocessors related system calls
207//////////////////////////////////////////////////////////////////////////
208
209// this structure is used by the giet_coproc_channel_init()
210// system call to specify the communication channel parameters.
211typedef struct giet_coproc_channel
212{
213    unsigned int  channel_mode;    // MWMR / DMA_IRQ / DMA_NO_IRQ
214    unsigned int  buffer_size;     // memory buffer size
215    unsigned int  buffer_vaddr;    // memory buffer virtual address
216    unsigned int  mwmr_vaddr;      // MWMR descriptor virtual address
217    unsigned int  lock_vaddr;      // lock for MWMR virtual address
218} giet_coproc_channel_t;
219
220extern void giet_coproc_alloc( unsigned int   coproc_type,
221                               unsigned int*  coproc_info );
222
223extern void giet_coproc_release( unsigned int coproc_reg_index );
224
225extern void giet_coproc_channel_init( unsigned int            channel,
226                                      giet_coproc_channel_t*  desc );
227
228extern void giet_coproc_run( unsigned int coproc_reg_index );
229
230extern void giet_coproc_completed();
231
232//////////////////////////////////////////////////////////////////////////
233//             TTY device related system calls
234//////////////////////////////////////////////////////////////////////////
235
236extern void giet_tty_alloc();
237
238extern void giet_tty_printf( char* format, ... );
239
240extern void giet_shr_printf( char* format, ... );
241
242extern void giet_tty_getc( char* byte );
243
244extern void giet_tty_gets( char* buf, unsigned int bufsize );
245
246extern void giet_tty_getw( unsigned int* val );
247
248//////////////////////////////////////////////////////////////////////////
249//                TIMER device related system calls
250//////////////////////////////////////////////////////////////////////////
251
252extern void giet_timer_alloc();
253
254extern void giet_timer_start( unsigned int period );
255
256extern void giet_timer_stop();
257 
258//////////////////////////////////////////////////////////////////////////
259//                Frame buffer device related system calls
260//////////////////////////////////////////////////////////////////////////
261
262extern void giet_fbf_cma_alloc();
263
264extern void giet_fbf_cma_init_buf( void* buf0_vbase, 
265                                   void* buf1_vbase,
266                                   void* sts0_vaddr,
267                                   void* sts1_vaddr );
268
269extern void giet_fbf_cma_start( unsigned int length );
270
271extern void giet_fbf_cma_display( unsigned int buffer );
272
273extern void giet_fbf_cma_stop();
274
275extern void giet_fbf_sync_read( unsigned int offset, 
276                                void*        buffer, 
277                                unsigned int length );
278
279extern void giet_fbf_sync_write( unsigned int offset, 
280                                 void*        buffer, 
281                                 unsigned int length );
282
283//////////////////////////////////////////////////////////////////////////
284//                  NIC related system calls
285//////////////////////////////////////////////////////////////////////////
286
287extern unsigned int giet_nic_rx_alloc( unsigned int xmax, unsigned int ymax );
288
289extern unsigned int giet_nic_tx_alloc( unsigned int xmax, unsigned int ymax );
290
291extern void giet_nic_rx_start( unsigned int channel );
292
293extern void giet_nic_tx_start( unsigned int channel );
294
295extern void giet_nic_rx_move( unsigned int channel, void* buffer );
296
297extern void giet_nic_tx_move( unsigned int channel, void* buffer );
298
299extern void giet_nic_rx_stop( unsigned int channel );
300
301extern void giet_nic_tx_stop( unsigned int channel );
302
303extern void giet_nic_rx_stats( unsigned int channel );
304
305extern void giet_nic_tx_stats( unsigned int channel );
306
307extern void giet_nic_rx_clear( unsigned int channel );
308
309extern void giet_nic_tx_clear( unsigned int channel );
310
311//////////////////////////////////////////////////////////////////////////
312//               FAT related system calls
313//////////////////////////////////////////////////////////////////////////
314
315extern int giet_fat_open( char*        pathname,
316                          unsigned int flags );
317
318extern int giet_fat_close( unsigned int fd_id );
319
320extern int giet_fat_file_info( unsigned int     fd_id,
321                               fat_file_info_t* info );
322
323extern int giet_fat_read( unsigned int fd_id,
324                          void*        buffer,
325                          unsigned int count );
326
327extern int giet_fat_write( unsigned int fd,
328                           void*        buffer,
329                           unsigned int count );
330
331extern int giet_fat_lseek( unsigned int fd,
332                           unsigned int offset,
333                           unsigned int whence );
334
335extern int giet_fat_remove( char*        pathname,
336                            unsigned int should_be_dir );
337
338extern int giet_fat_rename( char*  old_path,
339                            char*  new_path ); 
340
341extern int giet_fat_mkdir( char* pathname );
342
343extern int giet_fat_opendir( char* pathname );
344
345extern int giet_fat_closedir( unsigned int fd_id );
346
347extern int giet_fat_readdir( unsigned int  fd_id,
348                             fat_dirent_t* entry );
349
350//////////////////////////////////////////////////////////////////////////
351//                    Miscelaneous system calls
352//////////////////////////////////////////////////////////////////////////
353
354extern void giet_procs_number( unsigned int* x_size,
355                               unsigned int* y_size,
356                               unsigned int* nprocs );
357
358extern void giet_vobj_get_vbase( char*         vspace_name, 
359                                 char*         vobj_name, 
360                                 unsigned int* vobj_vaddr);
361
362extern void giet_vobj_get_length( char*         vspace_name, 
363                                  char*         vobj_name, 
364                                  unsigned int* vobj_vaddr);
365
366extern void giet_heap_info( unsigned int* vaddr, 
367                            unsigned int* length,
368                            unsigned int  x,
369                            unsigned int  y );
370
371extern void giet_get_xy( void*          ptr, 
372                         unsigned int*  px,
373                         unsigned int*  py );
374
375#endif
376
377// Local Variables:
378// tab-width: 4
379// c-basic-offset: 4
380// c-file-offsets:((innamespace . 0)(inline-open . 0))
381// indent-tabs-mode: nil
382// End:
383// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
384
Note: See TracBrowser for help on using the repository browser.