Changeset 438 for soft/giet_vm/giet_libs/stdio.h
- Timestamp:
- Nov 3, 2014, 10:54:50 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_libs/stdio.h
r431 r438 16 16 // the _syscall_vector defined in file sys_handler.c 17 17 18 #define SYSCALL_PROC ID0x0019 #define SYSCALL_PROC TIME0x0118 #define SYSCALL_PROC_XYP 0x00 19 #define SYSCALL_PROC_TIME 0x01 20 20 #define SYSCALL_TTY_WRITE 0x02 21 21 #define SYSCALL_TTY_READ 0x03 22 #define SYSCALL_T IMER_START0x0423 #define SYSCALL_T IMER_STOP0x0524 #define SYSCALL_TTY_ GET_LOCK0x0625 #define SYSCALL_ TTY_RELEASE_LOCK0x0726 #define SYSCALL_ HEAP_INFO0x0827 #define SYSCALL_ LOCAL_TASK_ID0x0928 #define SYSCALL_ GLOBAL_TASK_ID0x0A29 #define SYSCALL_FB _CMA_INIT0x0B30 #define SYSCALL_FB _CMA_WRITE0x0C31 #define SYSCALL_FB _CMA_STOP0x0D22 #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_START 0x0B 30 #define SYSCALL_FBF_CMA_DISPLAY 0x0C 31 #define SYSCALL_FBF_CMA_STOP 0x0D 32 32 #define SYSCALL_EXIT 0x0E 33 33 #define SYSCALL_PROC_NUMBER 0x0F 34 34 35 #define SYSCALL_FB _SYNC_WRITE0x1036 #define SYSCALL_FB _SYNC_READ0x1135 #define SYSCALL_FBF_SYNC_WRITE 0x10 36 #define SYSCALL_FBF_SYNC_READ 0x11 37 37 #define SYSCALL_THREAD_ID 0x12 38 #define SYSCALL_FREE_130x1339 #define SYSCALL_ FREE_140x1440 #define SYSCALL_ FREE_150x1541 #define SYSCALL_ FREE_160x1642 #define SYSCALL_FREE_170x1743 #define SYSCALL_FREE_180x1838 // 0x13 39 #define SYSCALL_TIM_ALLOC 0x14 40 #define SYSCALL_TIM_START 0x15 41 #define SYSCALL_TIM_STOP 0x16 42 // 0x17 43 // 0x18 44 44 #define SYSCALL_CTX_SWITCH 0x19 45 45 #define SYSCALL_VOBJ_GET_VBASE 0x1A 46 #define SYSCALL_ GET_XY0x1B47 #define SYSCALL_ NIC_CMA_START0x1C48 #define SYSCALL_NIC_ CMA_STOP0x1D49 #define SYSCALL_NIC_SYNC_ READ 0x1E50 #define SYSCALL_NIC_SYNC_ WRITE0x1F46 #define SYSCALL_VOBJ_GET_LENGTH 0x1B 47 #define SYSCALL_GET_XY 0x1C 48 #define SYSCALL_NIC_ALLOC 0x1D 49 #define SYSCALL_NIC_SYNC_SEND 0x1E 50 #define SYSCALL_NIC_SYNC_RECEIVE 0x1F 51 51 52 52 #define SYSCALL_FAT_OPEN 0x20 … … 56 56 #define SYSCALL_FAT_FSTAT 0x24 57 57 #define SYSCALL_FAT_CLOSE 0x25 58 // 0x26 59 // 0x27 60 // 0x28 61 // 0x29 62 // 0x2A 63 // 0x2B 64 // 0x2C 65 // 0x2D 66 // 0x2E 67 // 0x2F 58 68 59 69 ////////////////////////////////////////////////////////////////////////////////// … … 67 77 // It writes the system call arguments in the proper registers, 68 78 // and tells GCC what has been modified by system call execution. 79 // Returns -1 to signal an error. 69 80 ////////////////////////////////////////////////////////////////////////////////// 70 81 static inline int sys_call( int call_no, … … 110 121 111 122 ////////////////////////////////////////////////////////////////////////// 112 //////////////////////////////////////////////////////////////////////////113 123 // MIPS32 related system calls 114 124 ////////////////////////////////////////////////////////////////////////// 115 ////////////////////////////////////////////////////////////////////////// 116 117 ////////////////////////////////////////////////////////////////////////// 118 // This function returns the processor (x,y,lpid) identifier: 119 // (x,y) are the cluster coordinates / lpid is the local processor index. 125 120 126 ////////////////////////////////////////////////////////////////////////// 121 127 extern void giet_proc_xyp( unsigned int* cluster_x, … … 123 129 unsigned int* lpid ); 124 130 125 ////////////////////////////////////////////////////////////////////////// 126 // This function returns the local processor time. 127 ////////////////////////////////////////////////////////////////////////// 128 extern int giet_proctime(); 129 130 ////////////////////////////////////////////////////////////////////////// 131 // This function returns a pseudo-random value derived from the processor 132 // cycle count. This value is comprised between 0 & 65535. 133 ///////////////////////////////////////////////////////////////////////// 134 extern int giet_rand(); 135 136 ////////////////////////////////////////////////////////////////////////// 131 extern unsigned int giet_proctime(); 132 133 extern unsigned int giet_rand(); 134 135 ////////////////////////////////////////////////////////////////////////// 136 // Task context system calls 137 ////////////////////////////////////////////////////////////////////////// 138 139 extern unsigned int giet_proc_task_id(); 140 141 extern unsigned int giet_global_task_id(); 142 143 extern unsigned int giet_thread_id(); 144 137 145 ////////////////////////////////////////////////////////////////////////// 138 146 // TTY device related system calls 139 147 ////////////////////////////////////////////////////////////////////////// 140 ////////////////////////////////////////////////////////////////////////// 141 142 ////////////////////////////////////////////////////////////////////////// 143 // This function is a modified version of the mutek_printf(). 144 // It uses a private terminal allocated to the calling task in the boot. 145 // ("use_tty" argument in xml mapping), and does not take the TTY lock. 146 // It calls several times the _tty_write system function. 147 // Only a limited number of formats are supported: 148 // - %d : signed decimal 149 // - %u : unsigned decimal 150 // - %x : 32 bits hexadecimal 151 // - %l : 64 bits hexadecimal 152 // - %c : char 153 // - %s : string 154 // In case or error returned by syscall, it makes a giet_exit(). 155 ////////////////////////////////////////////////////////////////////////// 148 149 extern void giet_tty_alloc(); 150 156 151 extern void giet_tty_printf( char* format, ... ); 157 152 158 //////////////////////////////////////////////////////////////////////////159 // This function is a modified version of the mutek_printf().160 // It uses the kernel TTY0 as a shared terminal, and it takes the161 // TTY lock to get exclusive access during the format display.162 // It calls several times the _tty_write system function.163 // Only a limited number of formats are supported:164 // - %d : signed decimal165 // - %u : unsigned decimal166 // - %x : 32 bits hexadecimal167 // - %l : 64 bits hexadecimal168 // - %c : char169 // - %s : string170 // In case or error returned by syscall, it makes a giet_exit().171 //////////////////////////////////////////////////////////////////////////172 153 extern void giet_shr_printf( char* format, ... ); 173 154 174 //////////////////////////////////////////////////////////////////////////175 // This blocking function fetches a single character from the private176 // terminal allocated to the calling task in the boot.177 // It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer.178 // In case or error returned by syscall, it makes a giet_exit().179 //////////////////////////////////////////////////////////////////////////180 155 extern void giet_tty_getc( char* byte ); 181 156 182 //////////////////////////////////////////////////////////////////////////183 // This blocking function fetches a string from the private terminal184 // allocated to the calling task to a fixed length buffer.185 // The terminal index must be defined in the task context in the boot.186 // It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer.187 // - Up to (bufsize - 1) characters (including the non printable characters)188 // are copied into buffer, and the string is completed by a NUL character.189 // - The <LF> character is interpreted, and the function close the string190 // with a NUL character if <LF> is read.191 // - The <DEL> character is interpreted, and the corresponding character(s)192 // are removed from the target buffer.193 // - It does not provide an echo.194 // In case or error returned by syscall, it makes a giet_exit().195 /////////////////////////////////////////////////////////////////////////196 157 extern void giet_tty_gets( char* buf, unsigned int bufsize ); 197 158 198 /////////////////////////////////////////////////////////////////////////199 // This blocking function fetches a string of decimal characters (most200 // significant digit first) to build a 32-bit unsigned integer from201 // the private TTY terminal allocated to the calling task.202 // The terminal index must be defined in the task context in the boot.203 // It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer.204 // - The non-blocking system function _tty_read is called several times,205 // and the decimal characters are written in a 32 characters buffer206 // until a <LF> character is read.207 // - It ignores non-decimal characters, and displays an echo208 // system function) for each decimal character.209 // - The <DEL> character is interpreted, and previous characters can be cancelled.210 // - When the <LF> character is received, the string is converted to an211 // unsigned int value. If the number of decimal digit is too large for the 32212 // bits range, the zero value is returned.213 // In case or error returned by syscall, it makes a giet_exit().214 //////////////////////////////////////////////////////////////////////////215 159 extern void giet_tty_getw( unsigned int* val ); 216 160 217 161 ////////////////////////////////////////////////////////////////////////// 218 //////////////////////////////////////////////////////////////////////////219 162 // TIMER device related system calls 220 163 ////////////////////////////////////////////////////////////////////////// 221 ////////////////////////////////////////////////////////////////////////// 222 223 ////////////////////////////////////////////////////////////////////////// 224 // This function activates the private user timer allocated 225 // to the calling task in the boot phase. 226 // In case or error returned by syscall, it makes a giet_exit(). 227 ////////////////////////////////////////////////////////////////////////// 228 extern void giet_timer_start(); 229 230 ////////////////////////////////////////////////////////////////////////// 231 // This function stops the private user timer allocated 232 // to the calling task. 233 // In case or error returned by syscall, it makes a giet_exit(). 234 ////////////////////////////////////////////////////////////////////////// 164 165 extern void giet_timer_alloc(); 166 167 extern void giet_timer_start( unsigned int period ); 168 235 169 extern void giet_timer_stop(); 236 170 237 171 ////////////////////////////////////////////////////////////////////////// 238 //////////////////////////////////////////////////////////////////////////239 172 // Frame buffer device related system calls 240 173 ////////////////////////////////////////////////////////////////////////// 241 ////////////////////////////////////////////////////////////////////////// 242 243 ////////////////////////////////////////////////////////////////////////// 244 // This blocking function use a memory copy strategy to transfer data 245 // from the frame buffer device in kernel space to an user buffer. 246 // offset : offset (in bytes) in the frame buffer 247 // buffer : base address of the user buffer 248 // length : number of bytes to be transfered 249 // In case or error returned by syscall, it makes a giet_exit(). 250 ////////////////////////////////////////////////////////////////////////// 251 extern void giet_fb_sync_read( unsigned int offset, 252 void* buffer, 253 unsigned int length ); 254 255 ////////////////////////////////////////////////////////////////////////// 256 // This blocking function use a memory copy strategy to transfer data 257 // from a user buffer to the frame buffer device in kernel space. 258 // offset : offset (in bytes) in the frame buffer 259 // buffer : base address of the memory buffer 260 // length : number of bytes to be transfered 261 // In case or error returned by syscall, it makes a giet_exit(). 262 ////////////////////////////////////////////////////////////////////////// 263 extern void giet_fb_sync_write( unsigned int offset, 174 175 extern void giet_fbf_cma_alloc(); 176 177 extern void giet_fbf_cma_start( void* buf0, 178 void* buf1, 179 unsigned int length ); 180 181 extern void giet_fbf_cma_display( unsigned int buffer ); 182 183 extern void giet_fbf_cma_stop(); 184 185 extern void giet_fbf_sync_read( unsigned int offset, 264 186 void* buffer, 265 187 unsigned int length ); 266 188 267 ////////////////////////////////////////////////////////////////////////// 268 // This function initializes the two chbuf SRC an DST used by the CMA 269 // controller and activates the CMA channel allocated to the calling task. 270 // - buf0 : first user buffer virtual address 271 // - buf1 : second user buffer virtual address 272 // - length : buffer size (bytes) 273 // In case or error returned by syscall, it makes a giet_exit(). 274 ////////////////////////////////////////////////////////////////////////// 275 extern void giet_fb_cma_init( void* buf0, 276 void* buf1, 277 unsigned int length ); 278 279 ////////////////////////////////////////////////////////////////////////// 280 // This function initializes the two chbuf SRC an DST used by the CMA 281 // controller and activates the CMA channel allocated to the calling task. 282 // - buf0 : first user buffer virtual address 283 // - buf0 : second user buffer virtual address 284 // - length : buffer size (bytes) 285 // In case or error returned by syscall, it makes a giet_exit(). 286 ////////////////////////////////////////////////////////////////////////// 287 extern void giet_fb_cma_write( unsigned int buf_id ); 288 289 ////////////////////////////////////////////////////////////////////////// 290 // This function desactivates the CMA channel allocated to the task. 291 // In case or error returned by syscall, it makes a giet_exit(). 292 ////////////////////////////////////////////////////////////////////////// 293 extern void giet_fb_cma_stop(); 294 295 ////////////////////////////////////////////////////////////////////////// 189 extern void giet_fbf_sync_write( unsigned int offset, 190 void* buffer, 191 unsigned int length ); 192 296 193 ////////////////////////////////////////////////////////////////////////// 297 194 // NIC related system calls 298 195 ////////////////////////////////////////////////////////////////////////// 299 ////////////////////////////////////////////////////////////////////////// 300 301 ////////////////////////////////////////////////////////////////////////// 302 // This function initializes the memory chbuf used by the CMA controller, 303 // activates the NIC channel allocated to the calling task, 304 // and activates the two CMA channels. 305 // - tx : RX channel if 0 / TX channel if non 0 306 // - buf0 : first user buffer virtual address 307 // - buf1 : second user buffer virtual address 308 // - length : buffer size (bytes) 309 // In case or error returned by syscall, it makes a giet_exit(). 310 ////////////////////////////////////////////////////////////////////////// 311 extern void giet_nic_cma_start(); 312 313 ////////////////////////////////////////////////////////////////////////// 314 // This function desactivates the NIC channel and the two CMA channels 315 // allocated to the calling task. 316 // In case or error returned by syscall, it makes a giet_exit(). 317 ////////////////////////////////////////////////////////////////////////// 318 extern void giet_nic_cma_stop(); 319 320 ////////////////////////////////////////////////////////////////////////// 196 197 extern void giet_nic_alloc(); 198 199 extern void giet_nic_sync_send( void* buffer); 200 201 extern void giet_nic_sync_receive( void* buffer ); 202 321 203 ////////////////////////////////////////////////////////////////////////// 322 204 // FAT related system calls 323 205 ////////////////////////////////////////////////////////////////////////// 324 ////////////////////////////////////////////////////////////////////////// 325 326 ////////////////////////////////////////////////////////////////////////// 327 // Open a file identified by a pathname, and contained in the system FAT. 328 // The read/write flags are not supported yet: no effect. 329 // Return -1 in case or error. 330 ////////////////////////////////////////////////////////////////////////// 206 331 207 extern int giet_fat_open( const char* pathname, 332 208 unsigned int flags ); 333 209 334 ///////////////////////////////////////////////////////////////////////////////////335 // Read "count" sectors from a file identified by "fd", skipping "offset"336 // sectors in file, and writing into the user "buffer".337 // The user buffer base address shoulb be 64 bytes aligned.338 // In case or error returned by syscall, it makes a giet_exit().339 ///////////////////////////////////////////////////////////////////////////////////340 210 extern void giet_fat_read( unsigned int fd, 341 211 void* buffer, … … 343 213 unsigned int offset ); 344 214 345 ///////////////////////////////////////////////////////////////////////////////////346 // Write "count" sectors into a file identified by "fd", skipping "offset"347 // sectors in file, and reading from the user "buffer".348 // The user buffer base address shoulb be 64 bytes aligned.349 // In case or error returned by syscall, it makes a giet_exit().350 ///////////////////////////////////////////////////////////////////////////////////351 215 extern void giet_fat_write( unsigned int fd, 352 216 void* buffer, … … 354 218 unsigned int offset ); 355 219 356 ///////////////////////////////////////////////////////////////////////////////////357 // Change the lseek file pointer value for a file identified by "fd".358 // In case or error returned by syscall, it makes a giet_exit().359 ///////////////////////////////////////////////////////////////////////////////////360 220 extern void giet_fat_lseek( unsigned int fd, 361 221 unsigned int offset, 362 222 unsigned int whence ); 363 223 364 ///////////////////////////////////////////////////////////////////////////////////365 // Returns general informations of a file identified by "fd".366 // (Only the file_size in sectors for this moment)367 ///////////////////////////////////////////////////////////////////////////////////368 224 extern void giet_fat_fstat( unsigned int fd ); 369 225 370 //////////////////////////////////////////////////////////////////////////371 // Close a file identified by "fd".372 //////////////////////////////////////////////////////////////////////////373 226 extern void giet_fat_close( unsigned int fd ); 374 227 375 228 ////////////////////////////////////////////////////////////////////////// 376 //////////////////////////////////////////////////////////////////////////377 // Task context system calls378 //////////////////////////////////////////////////////////////////////////379 //////////////////////////////////////////////////////////////////////////380 381 //////////////////////////////////////////////////////////////////////////382 // This functions returns the local task id.383 // If processor has n tasks the local task index is ranging from 0 to n-1384 //////////////////////////////////////////////////////////////////////////385 extern int giet_proc_task_id();386 387 //////////////////////////////////////////////////////////////////////////388 // This functions returns the global task id, (unique in the system).389 //////////////////////////////////////////////////////////////////////////390 extern int giet_global_task_id();391 392 //////////////////////////////////////////////////////////////////////////393 // This functions returns the thread index of the task in its vspace.394 //////////////////////////////////////////////////////////////////////////395 extern int giet_thread_id();396 397 //////////////////////////////////////////////////////////////////////////398 //////////////////////////////////////////////////////////////////////////399 229 // Miscelaneous system calls 400 230 ////////////////////////////////////////////////////////////////////////// 401 ////////////////////////////////////////////////////////////////////////// 402 403 ////////////////////////////////////////////////////////////////////////// 404 // This function stops execution of the calling task with a TTY message, 405 // the user task is descheduled and becomes not runable. 406 // It does not consume processor cycles anymore. 407 ////////////////////////////////////////////////////////////////////////// 231 408 232 extern void giet_exit( char* string ); 409 233 410 //////////////////////////////////////////////////////////////////////////411 // This function uses the giet_exit() system call412 // and kill the calling task if the condition is false.413 //////////////////////////////////////////////////////////////////////////414 234 extern void giet_assert( unsigned int condition, 415 235 char* string ); 416 236 417 //////////////////////////////////////////////////////////////////////////418 // The user task calling this function is descheduled and419 // the processor is allocated to another task.420 //////////////////////////////////////////////////////////////////////////421 237 extern void giet_context_switch(); 422 238 423 ////////////////////////////////////////////////////////////////////////// 424 // This function writes in argument "vobj_vaddr" the virtual base address 425 // of a vobj (defined in the mapping_info data structure), identified by 426 // the two arguments "vspace_name" and "vobj_name". 427 // In case or error returned by syscall, it makes a giet_exit(). 428 // ( vobj not defined or wrong vspace ) 429 ////////////////////////////////////////////////////////////////////////// 239 extern void giet_procnumber( unsigned int cluster_xy, 240 unsigned int buffer ); 241 430 242 extern void giet_vobj_get_vbase( char* vspace_name, 431 243 char* vobj_name, 432 244 unsigned int* vobj_vaddr); 433 245 434 ////////////////////////////////////////////////////////////////////////// 435 // This function returns in the "buffer" argument the number of processors 436 // in the cluster specified by the "cluster_xy" argument. 437 // In case or error returned by syscall, it makes a giet_exit(). 438 ////////////////////////////////////////////////////////////////////////// 439 extern void giet_procnumber( unsigned int cluster_xy, 440 unsigned int buffer ); 441 442 ////////////////////////////////////////////////////////////////////////// 443 // This function supports access to the task's heap or to a remote heap: 444 // - If (x < X_SIZE) and (y < Y_SIZE), this function returns the base 445 // address and length of the heap associated to any task running 446 // on cluster(x,y) => remote heap 447 // - Else, this function returns the base address and length of the 448 // heap associated to the calling task => local heap 449 ////////////////////////////////////////////////////////////////////////// 246 extern void giet_vobj_get_length( char* vspace_name, 247 char* vobj_name, 248 unsigned int* vobj_vaddr); 249 450 250 extern void giet_heap_info( unsigned int* vaddr, 451 251 unsigned int* length, … … 453 253 unsigned int y ); 454 254 455 //////////////////////////////////////////////////////////////////////////456 // This function takes as input a virtual address (ptr argument),457 // and returns through the (px,py) arguments the coordinates of458 // the cluster containing the physical address associated to ptr.459 // In case of error (unmapped virtual address), it makes a giet_exit().460 //////////////////////////////////////////////////////////////////////////461 255 extern void giet_get_xy( void* ptr, 462 256 unsigned int* px,
Note: See TracChangeset
for help on using the changeset viewer.