| [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 |
|---|
| [295] | 20 | #define SYSCALL_TTY_GET_LOCK 0x06 |
|---|
| 21 | #define SYSCALL_TTY_RELEASE_LOCK 0x07 |
|---|
| [258] | 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 |
|---|
| [295] | 34 | #define SYSCALL_FREE_13 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 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| [368] | 56 | // NULL pointer definition |
|---|
| 57 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| 58 | |
|---|
| 59 | #define NULL (void *)0 |
|---|
| 60 | |
|---|
| 61 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| [258] | 62 | // This generic C function is used to implement all system calls. |
|---|
| 63 | // It writes the system call arguments in the proper registers, |
|---|
| 64 | // and tells GCC what has been modified by system call execution. |
|---|
| 65 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| 66 | static inline int sys_call( int call_no, |
|---|
| 67 | int arg_0, |
|---|
| 68 | int arg_1, |
|---|
| 69 | int arg_2, |
|---|
| 70 | int arg_3 ) |
|---|
| 71 | { |
|---|
| 72 | register int reg_no_and_output asm("v0") = call_no; |
|---|
| 73 | register int reg_a0 asm("a0") = arg_0; |
|---|
| 74 | register int reg_a1 asm("a1") = arg_1; |
|---|
| 75 | register int reg_a2 asm("a2") = arg_2; |
|---|
| 76 | register int reg_a3 asm("a3") = arg_3; |
|---|
| 77 | |
|---|
| 78 | asm volatile( |
|---|
| 79 | "syscall" |
|---|
| [345] | 80 | : "+r" (reg_no_and_output), /* input/output argument */ |
|---|
| 81 | "+r" (reg_a0), |
|---|
| 82 | "+r" (reg_a1), |
|---|
| 83 | "+r" (reg_a2), |
|---|
| 84 | "+r" (reg_a3), |
|---|
| 85 | "+r" (reg_no_and_output) |
|---|
| 86 | : /* input arguments */ |
|---|
| [258] | 87 | : "memory", |
|---|
| 88 | /* These persistant registers will be saved on the stack by the |
|---|
| 89 | * compiler only if they contain relevant data. */ |
|---|
| 90 | "at", |
|---|
| 91 | "v1", |
|---|
| 92 | "ra", |
|---|
| 93 | "t0", |
|---|
| 94 | "t1", |
|---|
| 95 | "t2", |
|---|
| 96 | "t3", |
|---|
| 97 | "t4", |
|---|
| 98 | "t5", |
|---|
| 99 | "t6", |
|---|
| 100 | "t7", |
|---|
| 101 | "t8", |
|---|
| 102 | "t9" |
|---|
| 103 | ); |
|---|
| [345] | 104 | return (volatile int)reg_no_and_output; |
|---|
| [258] | 105 | } |
|---|
| 106 | |
|---|
| 107 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 108 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [295] | 109 | // MIPS32 related system calls |
|---|
| 110 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 111 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [258] | 112 | |
|---|
| [295] | 113 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [382] | 114 | // This function returns the processor identifier. |
|---|
| [295] | 115 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [382] | 116 | extern int giet_procid(); |
|---|
| 117 | |
|---|
| 118 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 119 | // This function returns the local processor time. |
|---|
| 120 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 121 | extern int giet_proctime(); |
|---|
| 122 | |
|---|
| 123 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 124 | // This function returns a pseudo-random value derived from the processor |
|---|
| 125 | // cycle count. This value is comprised between 0 & 65535. |
|---|
| 126 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 127 | extern int giet_rand(); |
|---|
| 128 | |
|---|
| 129 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 130 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [295] | 131 | // TTY device related system calls |
|---|
| 132 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 133 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [258] | 134 | |
|---|
| [295] | 135 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 136 | // This function is a modified version of the mutek_printf(). |
|---|
| 137 | // It uses a private terminal allocated to the calling task in the boot. |
|---|
| 138 | // ("use_tty" argument in xml mapping), and does not take the TTY lock. |
|---|
| 139 | // It calls several times the _tty_write system function. |
|---|
| 140 | // Only a limited number of formats are supported: |
|---|
| 141 | // - %d : signed decimal |
|---|
| 142 | // - %u : unsigned decimal |
|---|
| 143 | // - %x : 32 bits hexadecimal |
|---|
| 144 | // - %l : 64 bits hexadecimal |
|---|
| 145 | // - %c : char |
|---|
| 146 | // - %s : string |
|---|
| 147 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 148 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 149 | extern void giet_tty_printf( char* format, ... ); |
|---|
| [258] | 150 | |
|---|
| 151 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [295] | 152 | // This function is a modified version of the mutek_printf(). |
|---|
| 153 | // It uses the kernel TTY0 as a shared terminal, and it takes the |
|---|
| 154 | // TTY lock to get exclusive access during the format display. |
|---|
| 155 | // It calls several times the _tty_write system function. |
|---|
| 156 | // Only a limited number of formats are supported: |
|---|
| 157 | // - %d : signed decimal |
|---|
| 158 | // - %u : unsigned decimal |
|---|
| 159 | // - %x : 32 bits hexadecimal |
|---|
| 160 | // - %l : 64 bits hexadecimal |
|---|
| 161 | // - %c : char |
|---|
| 162 | // - %s : string |
|---|
| 163 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| [258] | 164 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [295] | 165 | extern void giet_shr_printf( char* format, ... ); |
|---|
| [258] | 166 | |
|---|
| [295] | 167 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 168 | // This blocking function fetches a single character from the private |
|---|
| 169 | // terminal allocated to the calling task in the boot. |
|---|
| 170 | // It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer. |
|---|
| 171 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 172 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 173 | extern void giet_tty_getc( char* byte ); |
|---|
| [258] | 174 | |
|---|
| [295] | 175 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 176 | // This blocking function fetches a string from the private terminal |
|---|
| 177 | // allocated to the calling task to a fixed length buffer. |
|---|
| 178 | // The terminal index must be defined in the task context in the boot. |
|---|
| 179 | // It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer. |
|---|
| 180 | // - Up to (bufsize - 1) characters (including the non printable characters) |
|---|
| 181 | // are copied into buffer, and the string is completed by a NUL character. |
|---|
| 182 | // - The <LF> character is interpreted, and the function close the string |
|---|
| 183 | // with a NUL character if <LF> is read. |
|---|
| 184 | // - The <DEL> character is interpreted, and the corresponding character(s) |
|---|
| 185 | // are removed from the target buffer. |
|---|
| 186 | // - It does not provide an echo. |
|---|
| 187 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 188 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 189 | extern void giet_tty_gets( char* buf, unsigned int bufsize ); |
|---|
| [258] | 190 | |
|---|
| [295] | 191 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 192 | // This blocking function fetches a string of decimal characters (most |
|---|
| 193 | // significant digit first) to build a 32-bit unsigned integer from |
|---|
| 194 | // the private TTY terminal allocated to the calling task. |
|---|
| 195 | // The terminal index must be defined in the task context in the boot. |
|---|
| 196 | // It uses the TTY_RX_IRQ interrupt, and the associated kernel buffer. |
|---|
| 197 | // - The non-blocking system function _tty_read is called several times, |
|---|
| 198 | // and the decimal characters are written in a 32 characters buffer |
|---|
| 199 | // until a <LF> character is read. |
|---|
| 200 | // - It ignores non-decimal characters, and displays an echo |
|---|
| 201 | // system function) for each decimal character. |
|---|
| 202 | // - The <DEL> character is interpreted, and previous characters can be cancelled. |
|---|
| 203 | // - When the <LF> character is received, the string is converted to an |
|---|
| 204 | // unsigned int value. If the number of decimal digit is too large for the 32 |
|---|
| 205 | // bits range, the zero value is returned. |
|---|
| 206 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 207 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 208 | extern void giet_tty_getw( unsigned int* val ); |
|---|
| [258] | 209 | |
|---|
| [295] | 210 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 211 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 212 | // TIMER device related system calls |
|---|
| 213 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 214 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [258] | 215 | |
|---|
| [295] | 216 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 217 | // This function activates the private user timer allocated |
|---|
| 218 | // to the calling task in the boot phase. |
|---|
| 219 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 220 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 221 | extern void giet_timer_start(); |
|---|
| [258] | 222 | |
|---|
| 223 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [295] | 224 | // This function stops the private user timer allocated |
|---|
| 225 | // to the calling task. |
|---|
| 226 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| [258] | 227 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [295] | 228 | extern void giet_timer_stop(); |
|---|
| [258] | 229 | |
|---|
| 230 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 231 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [295] | 232 | // Frame buffer device related system calls |
|---|
| 233 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 234 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [258] | 235 | |
|---|
| [295] | 236 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 237 | // This blocking function use a memory copy strategy to transfer data |
|---|
| 238 | // from the frame buffer device in kernel space to an user buffer. |
|---|
| 239 | // offset : offset (in bytes) in the frame buffer |
|---|
| 240 | // buffer : base address of the user buffer |
|---|
| 241 | // length : number of bytes to be transfered |
|---|
| 242 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 243 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 244 | extern void giet_fb_sync_read( unsigned int offset, |
|---|
| 245 | void* buffer, |
|---|
| 246 | unsigned int length ); |
|---|
| [258] | 247 | |
|---|
| [295] | 248 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 249 | // This blocking function use a memory copy strategy to transfer data |
|---|
| 250 | // from a user buffer to the frame buffer device in kernel space. |
|---|
| 251 | // offset : offset (in bytes) in the frame buffer |
|---|
| 252 | // buffer : base address of the memory buffer |
|---|
| 253 | // length : number of bytes to be transfered |
|---|
| 254 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 255 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 256 | extern void giet_fb_sync_write( unsigned int offset, |
|---|
| 257 | void* buffer, |
|---|
| 258 | unsigned int length ); |
|---|
| [258] | 259 | |
|---|
| [295] | 260 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 261 | // This function initializes the two chbuf SRC an DST used by the CMA |
|---|
| 262 | // controller and activates the CMA channel allocated to the calling task. |
|---|
| 263 | // - buf0 : first user buffer virtual address |
|---|
| 264 | // - buf1 : second user buffer virtual address |
|---|
| 265 | // - length : buffer size (bytes) |
|---|
| 266 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 267 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 268 | extern void giet_fb_cma_init( void* buf0, |
|---|
| [258] | 269 | void* buf1, |
|---|
| [295] | 270 | unsigned int length ); |
|---|
| [258] | 271 | |
|---|
| [295] | 272 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 273 | // This function initializes the two chbuf SRC an DST used by the CMA |
|---|
| 274 | // controller and activates the CMA channel allocated to the calling task. |
|---|
| 275 | // - buf0 : first user buffer virtual address |
|---|
| 276 | // - buf0 : second user buffer virtual address |
|---|
| 277 | // - length : buffer size (bytes) |
|---|
| 278 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 279 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 280 | extern void giet_fb_cma_write( unsigned int buf_id ); |
|---|
| [258] | 281 | |
|---|
| [295] | 282 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 283 | // This function desactivates the CMA channel allocated to the task. |
|---|
| 284 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 285 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 286 | extern void giet_fb_cma_stop(); |
|---|
| [258] | 287 | |
|---|
| 288 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 289 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [295] | 290 | // NIC related system calls |
|---|
| 291 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 292 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [258] | 293 | |
|---|
| [295] | 294 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 295 | // This function initializes the memory chbuf used by the CMA controller, |
|---|
| 296 | // activates the NIC channel allocated to the calling task, |
|---|
| 297 | // and activates the two CMA channels. |
|---|
| 298 | // - tx : RX channel if 0 / TX channel if non 0 |
|---|
| 299 | // - buf0 : first user buffer virtual address |
|---|
| 300 | // - buf1 : second user buffer virtual address |
|---|
| 301 | // - length : buffer size (bytes) |
|---|
| 302 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 303 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 304 | extern void giet_nic_cma_start(); |
|---|
| [258] | 305 | |
|---|
| [295] | 306 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 307 | // This function desactivates the NIC channel and the two CMA channels |
|---|
| 308 | // allocated to the calling task. |
|---|
| 309 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 310 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 311 | extern void giet_nic_cma_stop(); |
|---|
| [258] | 312 | |
|---|
| 313 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 314 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [295] | 315 | // FAT related system calls |
|---|
| 316 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 317 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [258] | 318 | |
|---|
| [295] | 319 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 320 | // Open a file identified by a pathname, and contained in the system FAT. |
|---|
| 321 | // The read/write flags are not supported yet: no effect. |
|---|
| 322 | // Return -1 in case or error. |
|---|
| 323 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [258] | 324 | extern int giet_fat_open( const char* pathname, |
|---|
| 325 | unsigned int flags ); |
|---|
| 326 | |
|---|
| [295] | 327 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 328 | // Read "count" sectors from a file identified by "fd", skipping "offset" |
|---|
| 329 | // sectors in file, and writing into the user "buffer". |
|---|
| 330 | // The user buffer base address shoulb be 64 bytes aligned. |
|---|
| 331 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 332 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 333 | extern void giet_fat_read( unsigned int fd, |
|---|
| 334 | void* buffer, |
|---|
| 335 | unsigned int count, |
|---|
| 336 | unsigned int offset ); |
|---|
| [258] | 337 | |
|---|
| [295] | 338 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 339 | // Write "count" sectors from a file identified by "fd", skipping "offset" |
|---|
| 340 | // sectors in file, and reading from the user "buffer". |
|---|
| 341 | // The user buffer base address shoulb be 64 bytes aligned. |
|---|
| 342 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 343 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 344 | extern void giet_fat_write( unsigned int fd, |
|---|
| 345 | void* buffer, |
|---|
| 346 | unsigned int count, |
|---|
| 347 | unsigned int offset ); |
|---|
| [258] | 348 | |
|---|
| [295] | 349 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 350 | // Change the lseek file pointer value for a file identified by "fd". |
|---|
| 351 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 352 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 353 | extern void giet_fat_lseek( unsigned int fd, |
|---|
| 354 | unsigned int offset, |
|---|
| 355 | unsigned int whence ); |
|---|
| [258] | 356 | |
|---|
| [295] | 357 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 358 | // Returns general informations of a file identified by "fd". |
|---|
| 359 | // (Only the file_size in sectors for this moment) |
|---|
| 360 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 361 | extern void giet_fat_fstat( unsigned int fd ); |
|---|
| [260] | 362 | |
|---|
| [295] | 363 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 364 | // Close a file identified by "fd". |
|---|
| 365 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 366 | extern void giet_fat_close( unsigned int fd ); |
|---|
| [258] | 367 | |
|---|
| 368 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 369 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [382] | 370 | // Task context system calls |
|---|
| [295] | 371 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 372 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [258] | 373 | |
|---|
| [295] | 374 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 375 | // This functions returns the local task id. |
|---|
| 376 | // If processor has n tasks the local task index is ranging from 0 to n-1 |
|---|
| 377 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 378 | extern int giet_proc_task_id(); |
|---|
| [258] | 379 | |
|---|
| [295] | 380 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 381 | // This functions returns the global task id, (unique in the system). |
|---|
| 382 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 383 | extern int giet_global_task_id(); |
|---|
| [258] | 384 | |
|---|
| [295] | 385 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 386 | // This functions returns the thread index of the task in its vspace. |
|---|
| 387 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 388 | extern int giet_thread_id(); |
|---|
| [258] | 389 | |
|---|
| [295] | 390 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [382] | 391 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 392 | // Miscelaneous system calls |
|---|
| 393 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 394 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [258] | 395 | |
|---|
| [295] | 396 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 397 | // This function stops execution of the calling task with a TTY message, |
|---|
| 398 | // the user task is descheduled and becomes not runable. |
|---|
| 399 | // It does not consume processor cycles anymore. |
|---|
| 400 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [382] | 401 | extern void giet_exit( char* string ); |
|---|
| [258] | 402 | |
|---|
| [295] | 403 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 404 | // This function uses the giet_exit() system call |
|---|
| 405 | // and kill the calling task if the condition is false. |
|---|
| 406 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [258] | 407 | extern void giet_assert( unsigned int, |
|---|
| 408 | char* string ); |
|---|
| 409 | |
|---|
| [295] | 410 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 411 | // This function writes in argument "vobj_vaddr" the virtual base address |
|---|
| 412 | // of a vobj (defined in the mapping_info data structure), identified by |
|---|
| 413 | // the two arguments "vspace_name" and "vobj_name". |
|---|
| 414 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 415 | // ( vobj not defined or wrong vspace ) |
|---|
| 416 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 417 | extern void giet_vobj_get_vbase( char* vspace_name, |
|---|
| 418 | char* vobj_name, |
|---|
| 419 | unsigned int* vobj_vaddr); |
|---|
| [258] | 420 | |
|---|
| [295] | 421 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 422 | // This function returns in the "buffer" argument the number of processors |
|---|
| 423 | // in the cluster specified by the "cluster_xy" argument. |
|---|
| 424 | // In case or error returned by syscall, it makes a giet_exit(). |
|---|
| 425 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 426 | extern void giet_procnumber( unsigned int cluster_xy, |
|---|
| 427 | unsigned int buffer ); |
|---|
| 428 | |
|---|
| 429 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 430 | // The user task calling this function is descheduled and |
|---|
| 431 | // the processor is allocated to another task. |
|---|
| 432 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 433 | extern void giet_context_switch(); |
|---|
| 434 | |
|---|
| 435 | ////////////////////////////////////////////////////////////////////////// |
|---|
| [368] | 436 | // This function supports access to the task's heap or to a remote heap: |
|---|
| 437 | // - If (x < X_SIZE) and (y < Y_SIZE), this function returns the base |
|---|
| 438 | // address and length of the heap associated to any task running |
|---|
| 439 | // on cluster(x,y) => remote heap |
|---|
| 440 | // - Else, this function returns the base address and length of the |
|---|
| 441 | // heap associated to the calling task => local heap |
|---|
| [295] | 442 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 443 | extern void giet_heap_info( unsigned int* vaddr, |
|---|
| [368] | 444 | unsigned int* length, |
|---|
| 445 | unsigned int x, |
|---|
| 446 | unsigned int y ); |
|---|
| [295] | 447 | |
|---|
| [258] | 448 | #endif |
|---|
| 449 | |
|---|
| 450 | // Local Variables: |
|---|
| 451 | // tab-width: 4 |
|---|
| 452 | // c-basic-offset: 4 |
|---|
| 453 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
|---|
| 454 | // indent-tabs-mode: nil |
|---|
| 455 | // End: |
|---|
| 456 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
|---|
| 457 | |
|---|