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

Last change on this file since 271 was 267, checked in by cfuguet, 10 years ago
  • Adding new task context information: THREAD INDEX.

This value can be accessed by USER applications to get the
thread index of the current task. This thread index
corresponds to the index in a vspace.

The value of this index can be forced in the vspace part
of the XML description file using the trdid field in the
task description. When this value is missing, for each
task, a value from 0 to N-1 will be assigned, where N is
the number of task in the vspace.

The user application access this value through the
giet_thread_id() function defined in the stdio library
which uses the SYSCALL_THREAD_ID to access the task
context information.

  • Supporting mono TTY platforms

When the GIET_MONO_TTY constant defined in the giet_config
file, contains a value different than 0, all tasks will
share the TTY[0]. If this is the case, in the stdio
library, the giet_tty_printf() function will take the TTY
hardware lock before writing

  • Property svn:executable set to *
File size: 7.2 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_THREAD_ID         0x12
34#define SYSCALL_TTY_LOCK          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_FSTAT         0x24
53#define SYSCALL_FAT_CLOSE         0x25
54
55//////////////////////////////////////////////////////////////////////////////////
56// This generic C function is used to implement all system calls.
57// It writes the system call arguments in the proper registers,
58// and tells GCC what has been modified by system call execution.
59//////////////////////////////////////////////////////////////////////////////////
60static inline int sys_call( int call_no,
61                            int arg_0, 
62                            int arg_1, 
63                            int arg_2, 
64                            int arg_3 ) 
65{
66    register int reg_no_and_output asm("v0") = call_no;
67    register int reg_a0 asm("a0") = arg_0;
68    register int reg_a1 asm("a1") = arg_1;
69    register int reg_a2 asm("a2") = arg_2;
70    register int reg_a3 asm("a3") = arg_3;
71
72    asm volatile(
73            "syscall"
74            : "=r" (reg_no_and_output)  /* output argument */
75            : "r" (reg_a0),             /* input arguments */
76            "r" (reg_a1),
77            "r" (reg_a2),
78            "r" (reg_a3),
79            "r" (reg_no_and_output)
80            : "memory",
81            /* These persistant registers will be saved on the stack by the
82             * compiler only if they contain relevant data. */
83            "at",
84            "v1",
85            "ra",
86            "t0",
87            "t1",
88            "t2",
89            "t3",
90            "t4",
91            "t5",
92            "t6",
93            "t7",
94            "t8",
95            "t9"
96               );
97    return reg_no_and_output;
98}
99
100//////////////////////////////////////////////////////////////////////////
101// MIPS32 related system calls
102//////////////////////////////////////////////////////////////////////////
103
104extern int giet_procid();
105
106extern int giet_proctime();
107
108//////////////////////////////////////////////////////////////////////////
109// TTY device related system calls
110//////////////////////////////////////////////////////////////////////////
111
112extern int giet_tty_putc(char byte);
113
114extern int giet_tty_puts(char* buf);
115
116extern int giet_tty_putw(unsigned int val);
117
118extern int giet_tty_getc_no_irq(char* byte);
119
120extern int giet_tty_getc(char* byte);
121
122extern int giet_tty_gets(char* buf, unsigned int bufsize);
123
124extern int giet_tty_getw(unsigned int* val);
125
126extern int giet_tty_printf(char* format,...);
127
128//////////////////////////////////////////////////////////////////////////
129// TIMER device related system calls
130//////////////////////////////////////////////////////////////////////////
131
132extern int giet_timer_start();
133
134extern int giet_timer_stop();
135 
136//////////////////////////////////////////////////////////////////////////
137// Frame buffer device related system calls
138//////////////////////////////////////////////////////////////////////////
139
140extern int giet_fb_sync_read( unsigned int offset, 
141                              void*        buffer, 
142                              unsigned int length );
143
144extern int giet_fb_sync_write(unsigned int offset, 
145                              void*        buffer, 
146                              unsigned int length);
147
148extern int giet_fb_cma_init(  void*        buf0, 
149                              void*        buf1,
150                              unsigned int length);
151
152extern int giet_fb_cma_write(unsigned int buf_id);
153
154extern int giet_fb_cma_stop();
155
156//////////////////////////////////////////////////////////////////////////
157// Network controller related system calls
158//////////////////////////////////////////////////////////////////////////
159
160extern int giet_nic_cma_start();
161
162extern int giet_nic_cma_stop();
163
164//////////////////////////////////////////////////////////////////////////
165// FAT related system calls
166//////////////////////////////////////////////////////////////////////////
167
168extern int giet_fat_open(  const char*  pathname,
169                           unsigned int flags );
170
171extern int giet_fat_read(  unsigned int fd,
172                           void*        buffer,
173                           unsigned int count,
174                           unsigned int offset );
175
176extern int giet_fat_write( unsigned int fd,
177                           void*        buffer,
178                           unsigned int count,
179                           unsigned int offset );
180
181extern int giet_fat_lseek( unsigned int fd,
182                           unsigned int offset,
183                           unsigned int whence );
184
185extern int giet_fat_fstat( unsigned int fd );
186
187extern int giet_fat_close( unsigned int fd );
188
189//////////////////////////////////////////////////////////////////////////
190// Miscelaneous system calls
191//////////////////////////////////////////////////////////////////////////
192
193extern int giet_vobj_get_vbase( char*         vspace_name, 
194                                char*         vobj_name, 
195                                unsigned int  vobj_type, 
196                                unsigned int* vobj_vaddr);
197
198extern int giet_procnumber();
199
200extern void giet_exit();
201
202extern int giet_context_switch();
203
204extern int giet_proc_task_id();
205
206extern int giet_heap_info( unsigned int* vaddr, 
207                           unsigned int* size );
208
209extern int giet_global_task_id();
210
211extern int giet_thread_id();
212
213extern void giet_assert( unsigned int, 
214                         char* string );
215
216extern int giet_rand();
217
218#endif
219
220// Local Variables:
221// tab-width: 4
222// c-basic-offset: 4
223// c-file-offsets:((innamespace . 0)(inline-open . 0))
224// indent-tabs-mode: nil
225// End:
226// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
227
Note: See TracBrowser for help on using the repository browser.