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

Last change on this file since 259 was 259, checked in by devigne, 11 years ago

giet_fat32/fat32.c :
Added _fat_write function. At the moment it does not support the creation of a
new file (the writing must exist in the disk image) and does not support the
allocation of additional cluster from the original file.

create_dmg :
Bug fix for support Linux (The tree files were not consistent with the
pathnames in boot.c).

giet_libs/stdlib.c and stdlib.h :
Added stdlib file. At the moment they only contain the atoi function.

giet_libs/stdio.h :
Bug fix in SYSCALL DEFINE. SYSCALL_FAT_READ, WRITE, CLOSE, LSEEK had the same
value.

Makefile :
Added compilation line for stdlib.o

  • Property svn:executable set to *
File size: 7.1 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
8#ifndef _STDIO_H
9#define _STDIO_H
10
11// These define must be synchronised with
12// the _syscall_vector defined in file sys_handler.c
13
14#define SYSCALL_PROCID            0x00
15#define SYSCALL_PROCTIME          0x01
16#define SYSCALL_TTY_WRITE         0x02
17#define SYSCALL_TTY_READ          0x03
18#define SYSCALL_TIMER_START       0x04
19#define SYSCALL_TIMER_STOP        0x05
20#define SYSCALL_FREE_06           0x06
21#define SYSCALL_FREE_07           0x07
22#define SYSCALL_HEAP_INFO         0x08
23#define SYSCALL_LOCAL_TASK_ID     0x09
24#define SYSCALL_GLOBAL_TASK_ID    0x0A
25#define SYSCALL_FB_CMA_INIT       0x0B
26#define SYSCALL_FB_CMA_WRITE      0x0C
27#define SYSCALL_FB_CMA_STOP       0x0D
28#define SYSCALL_EXIT              0x0E
29#define SYSCALL_PROC_NUMBER       0x0F
30
31#define SYSCALL_FB_SYNC_WRITE     0x10
32#define SYSCALL_FB_SYNC_READ      0x11
33#define SYSCALL_FREE_12           0x12
34#define SYSCALL_FREE_13           0x13
35#define SYSCALL_FREE_14           0x14
36#define SYSCALL_FREE_15           0x15
37#define SYSCALL_FREE_16           0x16
38#define SYSCALL_FREE_17           0x17
39#define SYSCALL_FREE_18           0x18
40#define SYSCALL_CTX_SWITCH        0x19
41#define SYSCALL_VOBJ_GET_VBASE    0x1A
42#define SYSCALL_FREE_1B           0x1B
43#define SYSCALL_NIC_CMA_START     0x1C
44#define SYSCALL_NIC_CMA_STOP      0x1D
45#define SYSCALL_NIC_SYNC_READ     0x1E
46#define SYSCALL_NIC_SYNC_WRITE    0x1F
47
48#define SYSCALL_FAT_OPEN          0x20
49#define SYSCALL_FAT_READ          0x21
50#define SYSCALL_FAT_WRITE         0x22
51#define SYSCALL_FAT_LSEEK         0x23
52#define SYSCALL_FAT_CLOSE         0x24
53
54//////////////////////////////////////////////////////////////////////////////////
55// This generic C function is used to implement all system calls.
56// It writes the system call arguments in the proper registers,
57// and tells GCC what has been modified by system call execution.
58//////////////////////////////////////////////////////////////////////////////////
59static inline int sys_call( int call_no,
60                            int arg_0, 
61                            int arg_1, 
62                            int arg_2, 
63                            int arg_3 ) 
64{
65    register int reg_no_and_output asm("v0") = call_no;
66    register int reg_a0 asm("a0") = arg_0;
67    register int reg_a1 asm("a1") = arg_1;
68    register int reg_a2 asm("a2") = arg_2;
69    register int reg_a3 asm("a3") = arg_3;
70
71    asm volatile(
72            "syscall"
73            : "=r" (reg_no_and_output)  /* output argument */
74            : "r" (reg_a0),             /* input arguments */
75            "r" (reg_a1),
76            "r" (reg_a2),
77            "r" (reg_a3),
78            "r" (reg_no_and_output)
79            : "memory",
80            /* These persistant registers will be saved on the stack by the
81             * compiler only if they contain relevant data. */
82            "at",
83            "v1",
84            "ra",
85            "t0",
86            "t1",
87            "t2",
88            "t3",
89            "t4",
90            "t5",
91            "t6",
92            "t7",
93            "t8",
94            "t9"
95               );
96    return reg_no_and_output;
97}
98
99//////////////////////////////////////////////////////////////////////////
100// MIPS32 related system calls
101//////////////////////////////////////////////////////////////////////////
102
103extern int giet_procid();
104
105extern int giet_proctime();
106
107//////////////////////////////////////////////////////////////////////////
108// TTY device related system calls
109//////////////////////////////////////////////////////////////////////////
110
111extern int giet_tty_putc(char byte);
112
113extern int giet_tty_puts(char* buf);
114
115extern int giet_tty_putw(unsigned int val);
116
117extern int giet_tty_getc_no_irq(char* byte);
118
119extern int giet_tty_getc(char* byte);
120
121extern int giet_tty_gets(char* buf, unsigned int bufsize);
122
123extern int giet_tty_getw(unsigned int* val);
124
125extern int giet_tty_printf(char* format,...);
126
127//////////////////////////////////////////////////////////////////////////
128// TIMER device related system calls
129//////////////////////////////////////////////////////////////////////////
130
131extern int giet_timer_start();
132
133extern int giet_timer_stop();
134 
135//////////////////////////////////////////////////////////////////////////
136// Frame buffer device related system calls
137//////////////////////////////////////////////////////////////////////////
138
139extern int giet_fb_sync_read( unsigned int offset, 
140                              void*        buffer, 
141                              unsigned int length );
142
143extern int giet_fb_sync_write(unsigned int offset, 
144                              void*        buffer, 
145                              unsigned int length);
146
147extern int giet_fb_cma_init(  void*        buf0, 
148                              void*        buf1,
149                              unsigned int length);
150
151extern int giet_fb_cma_write(unsigned int buf_id);
152
153extern int giet_fb_cma_stop();
154
155//////////////////////////////////////////////////////////////////////////
156// Network controller related system calls
157//////////////////////////////////////////////////////////////////////////
158
159extern int giet_nic_cma_start();
160
161extern int giet_nic_cma_stop();
162
163//////////////////////////////////////////////////////////////////////////
164// FAT related system calls
165//////////////////////////////////////////////////////////////////////////
166
167extern int giet_fat_open(  const char*  pathname,
168                           unsigned int flags );
169
170extern int giet_fat_read(  unsigned int fd,
171                           void*        buffer,
172                           unsigned int count,
173                           unsigned int offset );
174
175extern int giet_fat_write( unsigned int fd,
176                           void*        buffer,
177                           unsigned int count,
178                           unsigned int offset );
179
180extern int giet_fat_lseek( unsigned int fd,
181                           unsigned int offset,
182                           unsigned int whence );
183
184extern int giet_fat_close( unsigned int fd );
185
186//////////////////////////////////////////////////////////////////////////
187// Miscelaneous system calls
188//////////////////////////////////////////////////////////////////////////
189
190extern int giet_vobj_get_vbase( char*         vspace_name, 
191                                char*         vobj_name, 
192                                unsigned int  vobj_type, 
193                                unsigned int* vobj_vaddr);
194
195extern int giet_procnumber();
196
197extern void giet_exit();
198
199extern int giet_context_switch();
200
201extern int giet_proc_task_id();
202
203extern int giet_heap_info( unsigned int* vaddr, 
204                           unsigned int* size );
205
206extern int giet_global_task_id();
207
208extern void giet_assert( unsigned int, 
209                         char* string );
210
211extern int giet_rand();
212
213#endif
214
215// Local Variables:
216// tab-width: 4
217// c-basic-offset: 4
218// c-file-offsets:((innamespace . 0)(inline-open . 0))
219// indent-tabs-mode: nil
220// End:
221// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
222
Note: See TracBrowser for help on using the repository browser.