[258] | 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 |
---|
[267] | 33 | #define SYSCALL_THREAD_ID 0x12 |
---|
| 34 | #define SYSCALL_TTY_LOCK 0x13 |
---|
[258] | 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 |
---|
[259] | 50 | #define SYSCALL_FAT_WRITE 0x22 |
---|
| 51 | #define SYSCALL_FAT_LSEEK 0x23 |
---|
[260] | 52 | #define SYSCALL_FAT_FSTAT 0x24 |
---|
| 53 | #define SYSCALL_FAT_CLOSE 0x25 |
---|
[258] | 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 | ////////////////////////////////////////////////////////////////////////////////// |
---|
| 60 | static 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 | |
---|
| 104 | extern int giet_procid(); |
---|
| 105 | |
---|
| 106 | extern int giet_proctime(); |
---|
| 107 | |
---|
| 108 | ////////////////////////////////////////////////////////////////////////// |
---|
| 109 | // TTY device related system calls |
---|
| 110 | ////////////////////////////////////////////////////////////////////////// |
---|
| 111 | |
---|
| 112 | extern int giet_tty_putc(char byte); |
---|
| 113 | |
---|
| 114 | extern int giet_tty_puts(char* buf); |
---|
| 115 | |
---|
| 116 | extern int giet_tty_putw(unsigned int val); |
---|
| 117 | |
---|
| 118 | extern int giet_tty_getc_no_irq(char* byte); |
---|
| 119 | |
---|
| 120 | extern int giet_tty_getc(char* byte); |
---|
| 121 | |
---|
| 122 | extern int giet_tty_gets(char* buf, unsigned int bufsize); |
---|
| 123 | |
---|
| 124 | extern int giet_tty_getw(unsigned int* val); |
---|
| 125 | |
---|
| 126 | extern int giet_tty_printf(char* format,...); |
---|
| 127 | |
---|
| 128 | ////////////////////////////////////////////////////////////////////////// |
---|
| 129 | // TIMER device related system calls |
---|
| 130 | ////////////////////////////////////////////////////////////////////////// |
---|
| 131 | |
---|
| 132 | extern int giet_timer_start(); |
---|
| 133 | |
---|
| 134 | extern int giet_timer_stop(); |
---|
| 135 | |
---|
| 136 | ////////////////////////////////////////////////////////////////////////// |
---|
| 137 | // Frame buffer device related system calls |
---|
| 138 | ////////////////////////////////////////////////////////////////////////// |
---|
| 139 | |
---|
| 140 | extern int giet_fb_sync_read( unsigned int offset, |
---|
| 141 | void* buffer, |
---|
| 142 | unsigned int length ); |
---|
| 143 | |
---|
| 144 | extern int giet_fb_sync_write(unsigned int offset, |
---|
| 145 | void* buffer, |
---|
| 146 | unsigned int length); |
---|
| 147 | |
---|
| 148 | extern int giet_fb_cma_init( void* buf0, |
---|
| 149 | void* buf1, |
---|
| 150 | unsigned int length); |
---|
| 151 | |
---|
| 152 | extern int giet_fb_cma_write(unsigned int buf_id); |
---|
| 153 | |
---|
| 154 | extern int giet_fb_cma_stop(); |
---|
| 155 | |
---|
| 156 | ////////////////////////////////////////////////////////////////////////// |
---|
| 157 | // Network controller related system calls |
---|
| 158 | ////////////////////////////////////////////////////////////////////////// |
---|
| 159 | |
---|
| 160 | extern int giet_nic_cma_start(); |
---|
| 161 | |
---|
| 162 | extern int giet_nic_cma_stop(); |
---|
| 163 | |
---|
| 164 | ////////////////////////////////////////////////////////////////////////// |
---|
| 165 | // FAT related system calls |
---|
| 166 | ////////////////////////////////////////////////////////////////////////// |
---|
| 167 | |
---|
| 168 | extern int giet_fat_open( const char* pathname, |
---|
| 169 | unsigned int flags ); |
---|
| 170 | |
---|
| 171 | extern int giet_fat_read( unsigned int fd, |
---|
| 172 | void* buffer, |
---|
| 173 | unsigned int count, |
---|
| 174 | unsigned int offset ); |
---|
| 175 | |
---|
| 176 | extern int giet_fat_write( unsigned int fd, |
---|
| 177 | void* buffer, |
---|
| 178 | unsigned int count, |
---|
| 179 | unsigned int offset ); |
---|
| 180 | |
---|
| 181 | extern int giet_fat_lseek( unsigned int fd, |
---|
| 182 | unsigned int offset, |
---|
| 183 | unsigned int whence ); |
---|
| 184 | |
---|
[260] | 185 | extern int giet_fat_fstat( unsigned int fd ); |
---|
| 186 | |
---|
[258] | 187 | extern int giet_fat_close( unsigned int fd ); |
---|
| 188 | |
---|
| 189 | ////////////////////////////////////////////////////////////////////////// |
---|
| 190 | // Miscelaneous system calls |
---|
| 191 | ////////////////////////////////////////////////////////////////////////// |
---|
| 192 | |
---|
| 193 | extern int giet_vobj_get_vbase( char* vspace_name, |
---|
| 194 | char* vobj_name, |
---|
| 195 | unsigned int vobj_type, |
---|
| 196 | unsigned int* vobj_vaddr); |
---|
| 197 | |
---|
| 198 | extern int giet_procnumber(); |
---|
| 199 | |
---|
| 200 | extern void giet_exit(); |
---|
| 201 | |
---|
| 202 | extern int giet_context_switch(); |
---|
| 203 | |
---|
| 204 | extern int giet_proc_task_id(); |
---|
| 205 | |
---|
| 206 | extern int giet_heap_info( unsigned int* vaddr, |
---|
| 207 | unsigned int* size ); |
---|
| 208 | |
---|
| 209 | extern int giet_global_task_id(); |
---|
| 210 | |
---|
[267] | 211 | extern int giet_thread_id(); |
---|
| 212 | |
---|
[258] | 213 | extern void giet_assert( unsigned int, |
---|
| 214 | char* string ); |
---|
| 215 | |
---|
| 216 | extern 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 | |
---|