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

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

fat32: introduce fat32_shared.h

No need to synchronize fat32.h and stdio.h anymore.

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