| 1 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // File : stdio.c |
|---|
| 3 | // Date : 01/04/2010 |
|---|
| 4 | // Author : alain greiner & Joel Porquet |
|---|
| 5 | // Copyright (c) UPMC-LIP6 |
|---|
| 6 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 7 | |
|---|
| 8 | #include <stdarg.h> |
|---|
| 9 | #include <stdio.h> |
|---|
| 10 | #include <giet_config.h> |
|---|
| 11 | |
|---|
| 12 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 13 | ///////////////////// MIPS32 related system calls /////////////////////// |
|---|
| 14 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 15 | |
|---|
| 16 | //////////////////////////////////////////// |
|---|
| 17 | void giet_proc_xyp( unsigned int* cluster_x, |
|---|
| 18 | unsigned int* cluster_y, |
|---|
| 19 | unsigned int* lpid ) |
|---|
| 20 | { |
|---|
| 21 | sys_call( SYSCALL_PROC_XYP, |
|---|
| 22 | (unsigned int)cluster_x, |
|---|
| 23 | (unsigned int)cluster_y, |
|---|
| 24 | (unsigned int)lpid, |
|---|
| 25 | 0 ); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | //////////////////////////// |
|---|
| 29 | unsigned int giet_proctime() |
|---|
| 30 | { |
|---|
| 31 | return (unsigned int)sys_call( SYSCALL_PROC_TIME, |
|---|
| 32 | 0, 0, 0, 0 ); |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | //////////////////////// |
|---|
| 36 | unsigned int giet_rand() |
|---|
| 37 | { |
|---|
| 38 | unsigned int x = (unsigned int)sys_call( SYSCALL_PROC_TIME, |
|---|
| 39 | 0, 0, 0, 0); |
|---|
| 40 | if ((x & 0xF) > 7) |
|---|
| 41 | { |
|---|
| 42 | return (x*x & 0xFFFF); |
|---|
| 43 | } |
|---|
| 44 | else |
|---|
| 45 | { |
|---|
| 46 | return (x*x*x & 0xFFFF); |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 51 | ///////////////////// Task context system calls ///////////////////////////// |
|---|
| 52 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 53 | |
|---|
| 54 | //////////////////////////////// |
|---|
| 55 | unsigned int giet_proc_task_id() |
|---|
| 56 | { |
|---|
| 57 | return (unsigned int)sys_call( SYSCALL_LOCAL_TASK_ID, |
|---|
| 58 | 0, 0, 0, 0 ); |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | ////////////////////////////////// |
|---|
| 62 | unsigned int giet_global_task_id() |
|---|
| 63 | { |
|---|
| 64 | return (unsigned int)sys_call( SYSCALL_GLOBAL_TASK_ID, |
|---|
| 65 | 0, 0, 0, 0 ); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | ///////////////////////////// |
|---|
| 69 | unsigned int giet_thread_id() |
|---|
| 70 | { |
|---|
| 71 | return (unsigned int)sys_call( SYSCALL_THREAD_ID, |
|---|
| 72 | 0, 0, 0, 0 ); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 77 | ///////////////////// Coprocessors system calls //////////////////////////// |
|---|
| 78 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 79 | |
|---|
| 80 | /////////////////////////////////////////////////// |
|---|
| 81 | void giet_coproc_alloc( unsigned int coproc_type, |
|---|
| 82 | unsigned int* coproc_info ) |
|---|
| 83 | { |
|---|
| 84 | if ( sys_call( SYSCALL_COPROC_ALLOC, |
|---|
| 85 | coproc_type, |
|---|
| 86 | (unsigned int)coproc_info, |
|---|
| 87 | 0, 0 ) ) |
|---|
| 88 | giet_exit("error in giet_coproc_alloc()"); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | ///////////////////////////////////////////////////////// |
|---|
| 92 | void giet_coproc_release( unsigned int coproc_reg_index ) |
|---|
| 93 | { |
|---|
| 94 | if ( sys_call( SYSCALL_COPROC_RELEASE, |
|---|
| 95 | coproc_reg_index, |
|---|
| 96 | 0, 0, 0 ) ) |
|---|
| 97 | giet_exit("error in giet_coproc_release()"); |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | ////////////////////////////////////////////////////////////////// |
|---|
| 101 | void giet_coproc_channel_init( unsigned int channel, |
|---|
| 102 | giet_coproc_channel_t* desc ) |
|---|
| 103 | { |
|---|
| 104 | if ( sys_call( SYSCALL_COPROC_CHANNEL_INIT, |
|---|
| 105 | channel, |
|---|
| 106 | (unsigned int)desc, |
|---|
| 107 | 0, 0 ) ) |
|---|
| 108 | giet_exit("error in giet_coproc_channel_init()"); |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | ///////////////////////////////////////////////////// |
|---|
| 112 | void giet_coproc_run( unsigned int coproc_reg_index ) |
|---|
| 113 | { |
|---|
| 114 | if ( sys_call( SYSCALL_COPROC_RUN, |
|---|
| 115 | coproc_reg_index, |
|---|
| 116 | 0, 0, 0 ) ) |
|---|
| 117 | giet_exit("error in giet_coproc_run()"); |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | //////////////////////////// |
|---|
| 121 | void giet_coproc_completed() |
|---|
| 122 | { |
|---|
| 123 | if ( sys_call( SYSCALL_COPROC_COMPLETED, |
|---|
| 124 | 0, 0, 0, 0 ) ) |
|---|
| 125 | giet_exit("error in giet_coproc_completed"); |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 130 | ///////////////////// TTY device related system calls /////////////////////// |
|---|
| 131 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 132 | |
|---|
| 133 | ///////////////////// |
|---|
| 134 | void giet_tty_alloc() |
|---|
| 135 | { |
|---|
| 136 | if ( sys_call( SYSCALL_TTY_ALLOC, |
|---|
| 137 | 0, 0, 0, 0 ) ) giet_exit("error in giet_tty_alloc()"); |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | //////////////////////////////////////////////////////////////////////// |
|---|
| 141 | static int __printf( char* format, unsigned int channel, va_list* args) |
|---|
| 142 | { |
|---|
| 143 | int ret; // return value from the syscall |
|---|
| 144 | enum TModifiers {NO_MOD, L_MOD, LL_MOD} modifiers; |
|---|
| 145 | |
|---|
| 146 | printf_text: |
|---|
| 147 | |
|---|
| 148 | while (*format) |
|---|
| 149 | { |
|---|
| 150 | unsigned int i; |
|---|
| 151 | for (i = 0 ; format[i] && (format[i] != '%') ; i++); |
|---|
| 152 | if (i) |
|---|
| 153 | { |
|---|
| 154 | ret = sys_call(SYSCALL_TTY_WRITE, |
|---|
| 155 | (unsigned int)format, |
|---|
| 156 | i, |
|---|
| 157 | channel, |
|---|
| 158 | 0); |
|---|
| 159 | |
|---|
| 160 | if (ret != i) goto return_error; |
|---|
| 161 | |
|---|
| 162 | format += i; |
|---|
| 163 | } |
|---|
| 164 | if (*format == '%') |
|---|
| 165 | { |
|---|
| 166 | format++; |
|---|
| 167 | modifiers = NO_MOD; |
|---|
| 168 | goto printf_arguments; |
|---|
| 169 | } |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | return 0; |
|---|
| 173 | |
|---|
| 174 | printf_arguments: |
|---|
| 175 | |
|---|
| 176 | { |
|---|
| 177 | char buf[30]; |
|---|
| 178 | char * pbuf; |
|---|
| 179 | unsigned int len = 0; |
|---|
| 180 | static const char HexaTab[] = "0123456789ABCDEF"; |
|---|
| 181 | unsigned int i; |
|---|
| 182 | |
|---|
| 183 | /* Ignored fields : width and precision */ |
|---|
| 184 | for (; *format >= '0' && *format <= '9'; format++); |
|---|
| 185 | |
|---|
| 186 | switch (*format++) |
|---|
| 187 | { |
|---|
| 188 | case ('%'): |
|---|
| 189 | case ('c'): /* char conversion */ |
|---|
| 190 | { |
|---|
| 191 | int val = va_arg( *args, int ); |
|---|
| 192 | if (modifiers != NO_MOD) goto return_error; // Modifiers have no meaning |
|---|
| 193 | |
|---|
| 194 | len = 1; |
|---|
| 195 | buf[0] = val; |
|---|
| 196 | pbuf = &buf[0]; |
|---|
| 197 | break; |
|---|
| 198 | } |
|---|
| 199 | case ('d'): /* decimal signed integer */ |
|---|
| 200 | { |
|---|
| 201 | int val = va_arg( *args, int ); |
|---|
| 202 | |
|---|
| 203 | if (modifiers == LL_MOD) goto return_error; // 64 bits not supported |
|---|
| 204 | |
|---|
| 205 | if (val < 0) |
|---|
| 206 | { |
|---|
| 207 | val = -val; |
|---|
| 208 | ret = sys_call(SYSCALL_TTY_WRITE, |
|---|
| 209 | (unsigned int)"-", |
|---|
| 210 | 1, |
|---|
| 211 | channel, |
|---|
| 212 | 0); |
|---|
| 213 | if (ret != 1) goto return_error; |
|---|
| 214 | } |
|---|
| 215 | for(i = 0; i < 10; i++) |
|---|
| 216 | { |
|---|
| 217 | buf[9 - i] = HexaTab[val % 10]; |
|---|
| 218 | if (!(val /= 10)) break; |
|---|
| 219 | } |
|---|
| 220 | len = i + 1; |
|---|
| 221 | pbuf = &buf[9 - i]; |
|---|
| 222 | break; |
|---|
| 223 | } |
|---|
| 224 | case ('u'): /* decimal unsigned integer */ |
|---|
| 225 | { |
|---|
| 226 | if (modifiers != LL_MOD) //32 bits integer |
|---|
| 227 | { |
|---|
| 228 | unsigned int val = va_arg( *args, unsigned int ); |
|---|
| 229 | for(i = 0; i < 10; i++) |
|---|
| 230 | { |
|---|
| 231 | buf[9 - i] = HexaTab[val % 10]; |
|---|
| 232 | if (!(val /= 10)) break; |
|---|
| 233 | } |
|---|
| 234 | len = i + 1; |
|---|
| 235 | pbuf = &buf[9 - i]; |
|---|
| 236 | break; |
|---|
| 237 | } |
|---|
| 238 | //64 bits : base 10 unsupported : continue to hexa |
|---|
| 239 | } |
|---|
| 240 | case ('x'): |
|---|
| 241 | case ('X'): /* hexadecimal integer */ |
|---|
| 242 | { |
|---|
| 243 | unsigned long long val; |
|---|
| 244 | int imax; |
|---|
| 245 | |
|---|
| 246 | if (modifiers == LL_MOD) //64 bits |
|---|
| 247 | { |
|---|
| 248 | val = va_arg( *args, unsigned long long); |
|---|
| 249 | |
|---|
| 250 | if (*(format-1) == 'u' && (!(val & 0xFFFFFFFF00000000))) //if asked to print in base 10, can do only if it fits in 32 bits |
|---|
| 251 | { |
|---|
| 252 | unsigned int uintv = (unsigned int) val; |
|---|
| 253 | |
|---|
| 254 | for(i = 0; i < 10; i++) |
|---|
| 255 | { |
|---|
| 256 | buf[9 - i] = HexaTab[uintv % 10]; |
|---|
| 257 | if (!(uintv /= 10)) break; |
|---|
| 258 | } |
|---|
| 259 | len = i + 1; |
|---|
| 260 | pbuf = &buf[9 - i]; |
|---|
| 261 | break; |
|---|
| 262 | } |
|---|
| 263 | |
|---|
| 264 | imax = 16; |
|---|
| 265 | } |
|---|
| 266 | else //32 bits |
|---|
| 267 | { |
|---|
| 268 | val = va_arg( *args, unsigned int); |
|---|
| 269 | imax = 8; |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | ret = sys_call(SYSCALL_TTY_WRITE, |
|---|
| 273 | (unsigned int)"0x", |
|---|
| 274 | 2, |
|---|
| 275 | channel, |
|---|
| 276 | 0); |
|---|
| 277 | if (ret != 2) goto return_error; |
|---|
| 278 | |
|---|
| 279 | for(i = 0; i < imax; i++) |
|---|
| 280 | { |
|---|
| 281 | buf[(imax-1) - i] = HexaTab[val % 16]; |
|---|
| 282 | if (!(val /= 16)) break; |
|---|
| 283 | } |
|---|
| 284 | len = i + 1; |
|---|
| 285 | pbuf = &buf[(imax-1) - i]; |
|---|
| 286 | break; |
|---|
| 287 | } |
|---|
| 288 | case ('s'): /* string */ |
|---|
| 289 | { |
|---|
| 290 | char* str = va_arg( *args, char* ); |
|---|
| 291 | |
|---|
| 292 | if (modifiers != NO_MOD) goto return_error; // Modifiers have no meaning |
|---|
| 293 | |
|---|
| 294 | while (str[len]) |
|---|
| 295 | { |
|---|
| 296 | len++; |
|---|
| 297 | } |
|---|
| 298 | pbuf = str; |
|---|
| 299 | break; |
|---|
| 300 | } |
|---|
| 301 | case ('e'): |
|---|
| 302 | case ('f'): |
|---|
| 303 | case ('g'): /* IEEE754 64 bits */ |
|---|
| 304 | { |
|---|
| 305 | |
|---|
| 306 | double vald = va_arg( *args, double); |
|---|
| 307 | |
|---|
| 308 | unsigned long long |
|---|
| 309 | val = *(unsigned long long*)&vald, //get ieee754 without conversion |
|---|
| 310 | digits = val & 0xFFFFFFFFFFFFF; //get mantissa |
|---|
| 311 | |
|---|
| 312 | unsigned int |
|---|
| 313 | base = (unsigned int)((val & 0x7FF0000000000000) >> 52), //get exposant |
|---|
| 314 | intp = (unsigned int)vald, //get integer part of the float |
|---|
| 315 | decp; |
|---|
| 316 | |
|---|
| 317 | int isvalue = 0; |
|---|
| 318 | |
|---|
| 319 | if (base == 0x7FF) //special value |
|---|
| 320 | { |
|---|
| 321 | if (digits & 0xFFFFFFFFFFFFF) |
|---|
| 322 | { |
|---|
| 323 | /* Not a Number */ |
|---|
| 324 | buf[0] = 'N'; |
|---|
| 325 | buf[1] = 'a'; |
|---|
| 326 | buf[2] = 'N'; |
|---|
| 327 | len = 3; |
|---|
| 328 | pbuf = buf; |
|---|
| 329 | } |
|---|
| 330 | else |
|---|
| 331 | { |
|---|
| 332 | /* inf */ |
|---|
| 333 | buf[0] = (val & 0x8000000000000000) ? '-' : '+'; |
|---|
| 334 | buf[1] = 'i'; |
|---|
| 335 | buf[2] = 'n'; |
|---|
| 336 | buf[3] = 'f'; |
|---|
| 337 | len = 4; |
|---|
| 338 | pbuf = buf; |
|---|
| 339 | } |
|---|
| 340 | break; |
|---|
| 341 | } |
|---|
| 342 | |
|---|
| 343 | if (val & 0x8000000000000000) |
|---|
| 344 | { |
|---|
| 345 | /* negative */ |
|---|
| 346 | ret = sys_call(SYSCALL_TTY_WRITE, |
|---|
| 347 | (unsigned int)"-", |
|---|
| 348 | 1, |
|---|
| 349 | channel, |
|---|
| 350 | 0); |
|---|
| 351 | if (ret != 1) goto return_error; |
|---|
| 352 | vald = vald * -1; |
|---|
| 353 | } |
|---|
| 354 | else |
|---|
| 355 | { |
|---|
| 356 | /* positive */ |
|---|
| 357 | ret = sys_call(SYSCALL_TTY_WRITE, |
|---|
| 358 | (unsigned int)"+", |
|---|
| 359 | 1, |
|---|
| 360 | channel, |
|---|
| 361 | 0); |
|---|
| 362 | if (ret != 1) goto return_error; |
|---|
| 363 | } |
|---|
| 364 | |
|---|
| 365 | if (vald > 0xFFFFFFFF) |
|---|
| 366 | { |
|---|
| 367 | /* overflow */ |
|---|
| 368 | buf[0] = 'B'; |
|---|
| 369 | buf[1] = 'I'; |
|---|
| 370 | buf[2] = 'G'; |
|---|
| 371 | len = 3; |
|---|
| 372 | pbuf = buf; |
|---|
| 373 | break; |
|---|
| 374 | } |
|---|
| 375 | |
|---|
| 376 | vald -= (double)intp; |
|---|
| 377 | decp = (unsigned int)(vald * 1000000000); |
|---|
| 378 | |
|---|
| 379 | for(i = 0; i < 10; i++) |
|---|
| 380 | { |
|---|
| 381 | if ((!isvalue) && (intp % 10)) isvalue = 1; |
|---|
| 382 | buf[9 - i] = HexaTab[intp % 10]; |
|---|
| 383 | if (!(intp /= 10)) break; |
|---|
| 384 | } |
|---|
| 385 | pbuf = &buf[9 - i]; |
|---|
| 386 | len = i+11; |
|---|
| 387 | buf[10] = '.'; |
|---|
| 388 | |
|---|
| 389 | for(i = 0; i < 9; i++) |
|---|
| 390 | { |
|---|
| 391 | if ((!isvalue) && (decp % 10)) isvalue = 1; |
|---|
| 392 | buf[19 - i] = HexaTab[decp % 10]; |
|---|
| 393 | decp /= 10; |
|---|
| 394 | } |
|---|
| 395 | |
|---|
| 396 | if (!isvalue) |
|---|
| 397 | { |
|---|
| 398 | if (vald != 0) |
|---|
| 399 | { |
|---|
| 400 | /* underflow */ |
|---|
| 401 | buf[0] = 'T'; |
|---|
| 402 | buf[1] = 'I'; |
|---|
| 403 | buf[2] = 'N'; |
|---|
| 404 | buf[3] = 'Y'; |
|---|
| 405 | len = 4; |
|---|
| 406 | pbuf = buf; |
|---|
| 407 | } |
|---|
| 408 | } |
|---|
| 409 | |
|---|
| 410 | break; |
|---|
| 411 | } |
|---|
| 412 | case ('l'): |
|---|
| 413 | switch (modifiers) |
|---|
| 414 | { |
|---|
| 415 | case NO_MOD: |
|---|
| 416 | modifiers = L_MOD; |
|---|
| 417 | goto printf_arguments; |
|---|
| 418 | |
|---|
| 419 | case L_MOD: |
|---|
| 420 | modifiers = LL_MOD; |
|---|
| 421 | goto printf_arguments; |
|---|
| 422 | |
|---|
| 423 | default: |
|---|
| 424 | goto return_error; |
|---|
| 425 | } |
|---|
| 426 | |
|---|
| 427 | /* Ignored fields : width and precision */ |
|---|
| 428 | case ('.'): goto printf_arguments; |
|---|
| 429 | |
|---|
| 430 | default: |
|---|
| 431 | goto return_error; |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | ret = sys_call(SYSCALL_TTY_WRITE, |
|---|
| 435 | (unsigned int)pbuf, |
|---|
| 436 | len, |
|---|
| 437 | channel, |
|---|
| 438 | 0); |
|---|
| 439 | if (ret != len) goto return_error; |
|---|
| 440 | |
|---|
| 441 | goto printf_text; |
|---|
| 442 | } |
|---|
| 443 | |
|---|
| 444 | return_error: |
|---|
| 445 | return 1; |
|---|
| 446 | } // end __printf() |
|---|
| 447 | |
|---|
| 448 | |
|---|
| 449 | //////////////////////////////////////// |
|---|
| 450 | void giet_tty_printf( char* format, ...) |
|---|
| 451 | { |
|---|
| 452 | va_list args; |
|---|
| 453 | |
|---|
| 454 | va_start( args, format ); |
|---|
| 455 | int ret = __printf(format, 0xFFFFFFFF, &args); |
|---|
| 456 | va_end( args ); |
|---|
| 457 | |
|---|
| 458 | if (ret) |
|---|
| 459 | { |
|---|
| 460 | giet_exit("ERROR in giet_tty_printf()"); |
|---|
| 461 | } |
|---|
| 462 | } // end giet_tty_printf() |
|---|
| 463 | |
|---|
| 464 | //////////////////////////////////////// |
|---|
| 465 | void giet_shr_printf( char* format, ...) |
|---|
| 466 | { |
|---|
| 467 | va_list args; |
|---|
| 468 | volatile unsigned int sr_save; |
|---|
| 469 | |
|---|
| 470 | sys_call( SYSCALL_TTY_GET_LOCK, |
|---|
| 471 | 0, |
|---|
| 472 | (unsigned int)&sr_save, |
|---|
| 473 | 0, 0 ); |
|---|
| 474 | |
|---|
| 475 | va_start( args, format ); |
|---|
| 476 | int ret = __printf(format, 0, &args); |
|---|
| 477 | va_end( args ); |
|---|
| 478 | |
|---|
| 479 | sys_call( SYSCALL_TTY_RELEASE_LOCK, |
|---|
| 480 | 0, |
|---|
| 481 | (unsigned int)&sr_save, |
|---|
| 482 | 0, 0 ); |
|---|
| 483 | |
|---|
| 484 | if (ret) |
|---|
| 485 | { |
|---|
| 486 | giet_exit("error in giet_shr_printf()"); |
|---|
| 487 | } |
|---|
| 488 | } // end giet_shr_printf() |
|---|
| 489 | |
|---|
| 490 | ///////////////////////////////// |
|---|
| 491 | void giet_tty_getc( char * byte ) |
|---|
| 492 | { |
|---|
| 493 | int ret; |
|---|
| 494 | |
|---|
| 495 | do |
|---|
| 496 | { |
|---|
| 497 | ret = sys_call(SYSCALL_TTY_READ, |
|---|
| 498 | (unsigned int)byte, // buffer address |
|---|
| 499 | 1, // number of characters |
|---|
| 500 | 0xFFFFFFFF, // channel index from task context |
|---|
| 501 | 0); |
|---|
| 502 | if ( ret < 0 ) giet_exit("error in giet_tty_getc()"); |
|---|
| 503 | } |
|---|
| 504 | while (ret != 1); |
|---|
| 505 | } |
|---|
| 506 | |
|---|
| 507 | ///////////////////////////////////// |
|---|
| 508 | void giet_tty_gets( char* buf, |
|---|
| 509 | unsigned int bufsize ) |
|---|
| 510 | { |
|---|
| 511 | int ret; |
|---|
| 512 | unsigned char byte; |
|---|
| 513 | unsigned int index = 0; |
|---|
| 514 | |
|---|
| 515 | while (index < (bufsize - 1)) |
|---|
| 516 | { |
|---|
| 517 | do |
|---|
| 518 | { |
|---|
| 519 | ret = sys_call(SYSCALL_TTY_READ, |
|---|
| 520 | (unsigned int)(&byte), |
|---|
| 521 | 1, |
|---|
| 522 | 0xFFFFFFFF, |
|---|
| 523 | 0); |
|---|
| 524 | if ( ret < 0 ) giet_exit("error in giet_tty_gets()"); |
|---|
| 525 | } |
|---|
| 526 | while (ret != 1); |
|---|
| 527 | |
|---|
| 528 | if (byte == 0x0A) /* LF */ |
|---|
| 529 | { |
|---|
| 530 | break; |
|---|
| 531 | } |
|---|
| 532 | else if ((byte == 0x7F) && (index > 0)) /* DEL */ |
|---|
| 533 | { |
|---|
| 534 | index--; |
|---|
| 535 | } |
|---|
| 536 | else |
|---|
| 537 | { |
|---|
| 538 | buf[index] = byte; |
|---|
| 539 | index++; |
|---|
| 540 | } |
|---|
| 541 | } |
|---|
| 542 | buf[index] = 0; |
|---|
| 543 | } |
|---|
| 544 | |
|---|
| 545 | /////////////////////////////////////// |
|---|
| 546 | void giet_tty_getw( unsigned int* val ) |
|---|
| 547 | { |
|---|
| 548 | unsigned char buf[32]; |
|---|
| 549 | unsigned int string_byte = 0x00000000; // string containing one single byte |
|---|
| 550 | unsigned int string_cancel = 0x00082008; // string containing BS/SPACE/BS |
|---|
| 551 | unsigned int save = 0; |
|---|
| 552 | unsigned int dec = 0; |
|---|
| 553 | unsigned int done = 0; |
|---|
| 554 | unsigned int overflow = 0; |
|---|
| 555 | unsigned int length = 0; |
|---|
| 556 | unsigned int i; |
|---|
| 557 | unsigned int channel = 0xFFFFFFFF; |
|---|
| 558 | int ret; // return value from syscalls |
|---|
| 559 | |
|---|
| 560 | // get characters |
|---|
| 561 | while (done == 0) |
|---|
| 562 | { |
|---|
| 563 | // read one character |
|---|
| 564 | do |
|---|
| 565 | { |
|---|
| 566 | ret = sys_call( SYSCALL_TTY_READ, |
|---|
| 567 | (unsigned int)(&string_byte), |
|---|
| 568 | 1, |
|---|
| 569 | channel, |
|---|
| 570 | 0); |
|---|
| 571 | if ( ret < 0 ) giet_exit("error in giet_tty_getw()"); |
|---|
| 572 | } |
|---|
| 573 | while (ret != 1); |
|---|
| 574 | |
|---|
| 575 | // analyse character |
|---|
| 576 | if ((string_byte > 0x2F) && (string_byte < 0x3A)) /* decimal character */ |
|---|
| 577 | { |
|---|
| 578 | buf[length] = (unsigned char)string_byte; |
|---|
| 579 | length++; |
|---|
| 580 | |
|---|
| 581 | // echo |
|---|
| 582 | ret = sys_call( SYSCALL_TTY_WRITE, |
|---|
| 583 | (unsigned int)(&string_byte), |
|---|
| 584 | 1, |
|---|
| 585 | channel, |
|---|
| 586 | 0 ); |
|---|
| 587 | if ( ret < 0 ) giet_exit("error in giet_tty_gets()"); |
|---|
| 588 | } |
|---|
| 589 | else if (string_byte == 0x0A) /* LF character */ |
|---|
| 590 | { |
|---|
| 591 | done = 1; |
|---|
| 592 | } |
|---|
| 593 | else if ( (string_byte == 0x7F) || /* DEL character */ |
|---|
| 594 | (string_byte == 0x08) ) /* BS character */ |
|---|
| 595 | { |
|---|
| 596 | if ( length > 0 ) |
|---|
| 597 | { |
|---|
| 598 | length--; // cancel the character |
|---|
| 599 | |
|---|
| 600 | ret = sys_call( SYSCALL_TTY_WRITE, |
|---|
| 601 | (unsigned int)(&string_cancel), |
|---|
| 602 | 3, |
|---|
| 603 | channel, |
|---|
| 604 | 0 ); |
|---|
| 605 | if ( ret < 0 ) giet_exit("error in giet_tty_getw()"); |
|---|
| 606 | } |
|---|
| 607 | } |
|---|
| 608 | |
|---|
| 609 | // test buffer overflow |
|---|
| 610 | if ( length >= 32 ) |
|---|
| 611 | { |
|---|
| 612 | overflow = 1; |
|---|
| 613 | done = 1; |
|---|
| 614 | } |
|---|
| 615 | } // end while characters |
|---|
| 616 | |
|---|
| 617 | // string to int conversion with overflow detection |
|---|
| 618 | if ( overflow == 0 ) |
|---|
| 619 | { |
|---|
| 620 | for (i = 0; (i < length) && (overflow == 0) ; i++) |
|---|
| 621 | { |
|---|
| 622 | dec = dec * 10 + (buf[i] - 0x30); |
|---|
| 623 | if (dec < save) overflow = 1; |
|---|
| 624 | save = dec; |
|---|
| 625 | } |
|---|
| 626 | } |
|---|
| 627 | |
|---|
| 628 | // final evaluation |
|---|
| 629 | if ( overflow == 0 ) |
|---|
| 630 | { |
|---|
| 631 | // return value |
|---|
| 632 | *val = dec; |
|---|
| 633 | } |
|---|
| 634 | else |
|---|
| 635 | { |
|---|
| 636 | // cancel all echo characters |
|---|
| 637 | for (i = 0; i < length ; i++) |
|---|
| 638 | { |
|---|
| 639 | ret = sys_call( SYSCALL_TTY_WRITE, |
|---|
| 640 | (unsigned int)(&string_cancel), |
|---|
| 641 | 3, |
|---|
| 642 | channel, |
|---|
| 643 | 0 ); |
|---|
| 644 | if ( ret < 0 ) giet_exit("error in giet_tty_getw()"); |
|---|
| 645 | } |
|---|
| 646 | // echo character '0' |
|---|
| 647 | string_byte = 0x30; |
|---|
| 648 | ret = sys_call( SYSCALL_TTY_WRITE, |
|---|
| 649 | (unsigned int)(&string_byte), |
|---|
| 650 | 1, |
|---|
| 651 | channel, |
|---|
| 652 | 0 ); |
|---|
| 653 | if ( ret < 0 ) giet_exit("error in giet_tty_getw()"); |
|---|
| 654 | |
|---|
| 655 | // return 0 value |
|---|
| 656 | *val = 0; |
|---|
| 657 | } |
|---|
| 658 | } |
|---|
| 659 | |
|---|
| 660 | |
|---|
| 661 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| 662 | ///////////////////// TIMER related system calls //////////////////////////////// |
|---|
| 663 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| 664 | |
|---|
| 665 | /////////////////////// |
|---|
| 666 | void giet_timer_alloc() |
|---|
| 667 | { |
|---|
| 668 | if ( sys_call( SYSCALL_TIM_ALLOC, |
|---|
| 669 | 0, 0, 0, 0 ) ) giet_exit("error in giet_timer_alloc()"); |
|---|
| 670 | } |
|---|
| 671 | |
|---|
| 672 | //////////////////////////////////////////// |
|---|
| 673 | void giet_timer_start( unsigned int period ) |
|---|
| 674 | { |
|---|
| 675 | if ( sys_call( SYSCALL_TIM_START, |
|---|
| 676 | period, |
|---|
| 677 | 0, 0, 0 ) ) giet_exit("error in giet_timer_start()"); |
|---|
| 678 | } |
|---|
| 679 | |
|---|
| 680 | ////////////////////// |
|---|
| 681 | void giet_timer_stop() |
|---|
| 682 | { |
|---|
| 683 | if ( sys_call( SYSCALL_TIM_STOP, |
|---|
| 684 | 0, 0, 0, 0 ) ) giet_exit("error in giet_timer_stop()"); |
|---|
| 685 | } |
|---|
| 686 | |
|---|
| 687 | |
|---|
| 688 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| 689 | /////////////// Frame buffer device related system calls /////////////////////// |
|---|
| 690 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| 691 | |
|---|
| 692 | ///////////////////////// |
|---|
| 693 | void giet_fbf_cma_alloc() |
|---|
| 694 | { |
|---|
| 695 | if ( sys_call( SYSCALL_FBF_CMA_ALLOC, |
|---|
| 696 | 0, 0, 0, 0 ) ) giet_exit("error in giet_fbf_cma_alloc()"); |
|---|
| 697 | } |
|---|
| 698 | |
|---|
| 699 | /////////////////////////////////////////// |
|---|
| 700 | void giet_fbf_cma_start( void * buf0, |
|---|
| 701 | void * buf1, |
|---|
| 702 | unsigned int length ) |
|---|
| 703 | { |
|---|
| 704 | if ( sys_call( SYSCALL_FBF_CMA_START, |
|---|
| 705 | (unsigned int)buf0, |
|---|
| 706 | (unsigned int)buf1, |
|---|
| 707 | length, |
|---|
| 708 | 0 ) ) giet_exit("error in giet_fbf_cma_start()"); |
|---|
| 709 | } |
|---|
| 710 | |
|---|
| 711 | //////////////////////////////////////////////// |
|---|
| 712 | void giet_fbf_cma_display( unsigned int buffer ) |
|---|
| 713 | { |
|---|
| 714 | if ( sys_call( SYSCALL_FBF_CMA_DISPLAY, |
|---|
| 715 | buffer, |
|---|
| 716 | 0, 0, 0 ) ) giet_exit("error in giet_fbf_cma_display()"); |
|---|
| 717 | } |
|---|
| 718 | |
|---|
| 719 | //////////////////////// |
|---|
| 720 | void giet_fbf_cma_stop() |
|---|
| 721 | { |
|---|
| 722 | if ( sys_call( SYSCALL_FBF_CMA_STOP, |
|---|
| 723 | 0, 0, 0, 0 ) ) giet_exit("error in giet_fbf_cma_stop()"); |
|---|
| 724 | } |
|---|
| 725 | |
|---|
| 726 | ////////////////////////////////////////////// |
|---|
| 727 | void giet_fbf_sync_write( unsigned int offset, |
|---|
| 728 | void * buffer, |
|---|
| 729 | unsigned int length ) |
|---|
| 730 | { |
|---|
| 731 | if ( sys_call( SYSCALL_FBF_SYNC_WRITE, |
|---|
| 732 | offset, |
|---|
| 733 | (unsigned int)buffer, |
|---|
| 734 | length, |
|---|
| 735 | 0 ) ) giet_exit("error in giet_fbf_sync_write()"); |
|---|
| 736 | } |
|---|
| 737 | |
|---|
| 738 | ///////////////////////////////////////////// |
|---|
| 739 | void giet_fbf_sync_read( unsigned int offset, |
|---|
| 740 | void * buffer, |
|---|
| 741 | unsigned int length ) |
|---|
| 742 | { |
|---|
| 743 | if ( sys_call( SYSCALL_FBF_SYNC_READ, |
|---|
| 744 | offset, |
|---|
| 745 | (unsigned int)buffer, |
|---|
| 746 | length, |
|---|
| 747 | 0 ) ) giet_exit("error in giet_fbf_sync_read()"); |
|---|
| 748 | } |
|---|
| 749 | |
|---|
| 750 | |
|---|
| 751 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| 752 | /////////////////////// NIC related system calls ///////////////////////////////// |
|---|
| 753 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| 754 | |
|---|
| 755 | //////////////////////////////////////////////////// |
|---|
| 756 | unsigned int giet_nic_rx_alloc( unsigned int xmax, |
|---|
| 757 | unsigned int ymax ) |
|---|
| 758 | { |
|---|
| 759 | int channel = sys_call( SYSCALL_NIC_ALLOC, |
|---|
| 760 | 1, |
|---|
| 761 | xmax, |
|---|
| 762 | ymax, |
|---|
| 763 | 0 ); |
|---|
| 764 | if ( channel < 0 ) giet_exit("error in giet_nic_rx_alloc()"); |
|---|
| 765 | |
|---|
| 766 | return (unsigned int)channel; |
|---|
| 767 | } |
|---|
| 768 | |
|---|
| 769 | //////////////////////////////////////////////////// |
|---|
| 770 | unsigned int giet_nic_tx_alloc( unsigned int xmax, |
|---|
| 771 | unsigned int ymax ) |
|---|
| 772 | { |
|---|
| 773 | int channel = sys_call( SYSCALL_NIC_ALLOC, |
|---|
| 774 | 0, |
|---|
| 775 | xmax, |
|---|
| 776 | ymax, |
|---|
| 777 | 0 ); |
|---|
| 778 | if ( channel < 0 ) giet_exit("error in giet_nic_tx_alloc()"); |
|---|
| 779 | |
|---|
| 780 | return (unsigned int)channel; |
|---|
| 781 | } |
|---|
| 782 | |
|---|
| 783 | ////////////////////////////////////////////// |
|---|
| 784 | void giet_nic_rx_start( unsigned int channel ) |
|---|
| 785 | { |
|---|
| 786 | if ( sys_call( SYSCALL_NIC_START, |
|---|
| 787 | 1, |
|---|
| 788 | channel, |
|---|
| 789 | 0, 0 ) ) giet_exit("error in giet_nic_rx_start()"); |
|---|
| 790 | } |
|---|
| 791 | |
|---|
| 792 | ////////////////////////////////////////////// |
|---|
| 793 | void giet_nic_tx_start( unsigned int channel ) |
|---|
| 794 | { |
|---|
| 795 | if ( sys_call( SYSCALL_NIC_START, |
|---|
| 796 | 0, |
|---|
| 797 | channel, |
|---|
| 798 | 0, 0 ) ) giet_exit("error in giet_nic_tx_start()"); |
|---|
| 799 | } |
|---|
| 800 | |
|---|
| 801 | /////////////////////////////////////////////////////////// |
|---|
| 802 | void giet_nic_rx_move( unsigned int channel, void* buffer ) |
|---|
| 803 | { |
|---|
| 804 | if ( sys_call( SYSCALL_NIC_MOVE, |
|---|
| 805 | 1, |
|---|
| 806 | channel, |
|---|
| 807 | (unsigned int)buffer, |
|---|
| 808 | 0 ) ) giet_exit("error in giet_nic_rx_move()"); |
|---|
| 809 | } |
|---|
| 810 | |
|---|
| 811 | /////////////////////////////////////////////////////////// |
|---|
| 812 | void giet_nic_tx_move( unsigned int channel, void* buffer ) |
|---|
| 813 | { |
|---|
| 814 | if ( sys_call( SYSCALL_NIC_MOVE, |
|---|
| 815 | 0, |
|---|
| 816 | channel, |
|---|
| 817 | (unsigned int)buffer, |
|---|
| 818 | 0 ) ) giet_exit("error in giet_nic_tx_move()"); |
|---|
| 819 | } |
|---|
| 820 | |
|---|
| 821 | ///////////////////////////////////////////// |
|---|
| 822 | void giet_nic_rx_stop( unsigned int channel ) |
|---|
| 823 | { |
|---|
| 824 | if ( sys_call( SYSCALL_NIC_STOP, |
|---|
| 825 | 1, |
|---|
| 826 | channel, |
|---|
| 827 | 0, 0 ) ) giet_exit("error in giet_nic_rx_stop()"); |
|---|
| 828 | } |
|---|
| 829 | |
|---|
| 830 | ///////////////////////////////////////////// |
|---|
| 831 | void giet_nic_tx_stop( unsigned int channel ) |
|---|
| 832 | { |
|---|
| 833 | if ( sys_call( SYSCALL_NIC_STOP, |
|---|
| 834 | 0, |
|---|
| 835 | channel, |
|---|
| 836 | 0, 0 ) ) giet_exit("error in giet_nic_tx_stop()"); |
|---|
| 837 | } |
|---|
| 838 | |
|---|
| 839 | ////////////////////////////////////////////// |
|---|
| 840 | void giet_nic_rx_stats( unsigned int channel ) |
|---|
| 841 | { |
|---|
| 842 | if ( sys_call( SYSCALL_NIC_STATS, |
|---|
| 843 | 1, |
|---|
| 844 | channel, |
|---|
| 845 | 0, 0 ) ) giet_exit("error in giet_nic_rx_stats()"); |
|---|
| 846 | } |
|---|
| 847 | |
|---|
| 848 | ////////////////////////////////////////////// |
|---|
| 849 | void giet_nic_tx_stats( unsigned int channel ) |
|---|
| 850 | { |
|---|
| 851 | if ( sys_call( SYSCALL_NIC_STATS, |
|---|
| 852 | 0, |
|---|
| 853 | channel, |
|---|
| 854 | 0, 0 ) ) giet_exit("error in giet_nic_tx_stats()"); |
|---|
| 855 | } |
|---|
| 856 | |
|---|
| 857 | ////////////////////////////////////////////// |
|---|
| 858 | void giet_nic_rx_clear( unsigned int channel ) |
|---|
| 859 | { |
|---|
| 860 | if ( sys_call( SYSCALL_NIC_CLEAR, |
|---|
| 861 | 1, |
|---|
| 862 | channel, |
|---|
| 863 | 0, 0 ) ) giet_exit("error in giet_nic_rx_clear()"); |
|---|
| 864 | } |
|---|
| 865 | |
|---|
| 866 | ////////////////////////////////////////////// |
|---|
| 867 | void giet_nic_tx_clear( unsigned int channel ) |
|---|
| 868 | { |
|---|
| 869 | if ( sys_call( SYSCALL_NIC_CLEAR, |
|---|
| 870 | 0, |
|---|
| 871 | channel, |
|---|
| 872 | 0, 0 ) ) giet_exit("error in giet_nic_tx_clear()"); |
|---|
| 873 | } |
|---|
| 874 | |
|---|
| 875 | |
|---|
| 876 | |
|---|
| 877 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 878 | ///////////////////// FAT related system calls //////////////////////////////////// |
|---|
| 879 | /////////////////////////////////////////////////////////////////////////////////// |
|---|
| 880 | |
|---|
| 881 | ///////////////////////////////////////// |
|---|
| 882 | int giet_fat_open( char* pathname, |
|---|
| 883 | unsigned int flags ) |
|---|
| 884 | { |
|---|
| 885 | return sys_call( SYSCALL_FAT_OPEN, |
|---|
| 886 | (unsigned int)pathname, |
|---|
| 887 | flags, |
|---|
| 888 | 0, 0 ); |
|---|
| 889 | } |
|---|
| 890 | |
|---|
| 891 | ///////////////////////////////////////// |
|---|
| 892 | int giet_fat_close( unsigned int fd_id ) |
|---|
| 893 | { |
|---|
| 894 | return sys_call( SYSCALL_FAT_CLOSE, |
|---|
| 895 | fd_id, |
|---|
| 896 | 0, 0, 0 ); |
|---|
| 897 | } |
|---|
| 898 | |
|---|
| 899 | ///////////////////////////////////////////// |
|---|
| 900 | int giet_fat_file_info( unsigned int fd_id, |
|---|
| 901 | unsigned int* size, |
|---|
| 902 | unsigned int* offset ) |
|---|
| 903 | { |
|---|
| 904 | return sys_call( SYSCALL_FAT_FINFO, |
|---|
| 905 | fd_id, |
|---|
| 906 | (unsigned int)size, |
|---|
| 907 | (unsigned int)offset, |
|---|
| 908 | 0 ); |
|---|
| 909 | } |
|---|
| 910 | |
|---|
| 911 | /////////////////////////////////////// |
|---|
| 912 | int giet_fat_read( unsigned int fd_id, |
|---|
| 913 | void* buffer, |
|---|
| 914 | unsigned int count ) |
|---|
| 915 | { |
|---|
| 916 | return sys_call( SYSCALL_FAT_READ, |
|---|
| 917 | fd_id, |
|---|
| 918 | (unsigned int)buffer, |
|---|
| 919 | count, |
|---|
| 920 | 0 ); |
|---|
| 921 | } |
|---|
| 922 | |
|---|
| 923 | //////////////////////////////////////// |
|---|
| 924 | int giet_fat_write( unsigned int fd_id, |
|---|
| 925 | void* buffer, |
|---|
| 926 | unsigned int count ) |
|---|
| 927 | { |
|---|
| 928 | return sys_call( SYSCALL_FAT_WRITE, |
|---|
| 929 | fd_id, |
|---|
| 930 | (unsigned int)buffer, |
|---|
| 931 | count, |
|---|
| 932 | 0 ); |
|---|
| 933 | } |
|---|
| 934 | |
|---|
| 935 | //////////////////////////////////////// |
|---|
| 936 | int giet_fat_lseek( unsigned int fd_id, |
|---|
| 937 | unsigned int offset, |
|---|
| 938 | unsigned int whence ) |
|---|
| 939 | { |
|---|
| 940 | return sys_call( SYSCALL_FAT_LSEEK, |
|---|
| 941 | fd_id, |
|---|
| 942 | offset, |
|---|
| 943 | whence, |
|---|
| 944 | 0 ); |
|---|
| 945 | } |
|---|
| 946 | |
|---|
| 947 | //////////////////////////////////////////// |
|---|
| 948 | int giet_fat_remove( char* pathname, |
|---|
| 949 | unsigned int should_be_dir ) |
|---|
| 950 | { |
|---|
| 951 | return sys_call( SYSCALL_FAT_REMOVE, |
|---|
| 952 | (unsigned int)pathname, |
|---|
| 953 | should_be_dir, |
|---|
| 954 | 0, 0 ); |
|---|
| 955 | } |
|---|
| 956 | |
|---|
| 957 | ///////////////////////////////////// |
|---|
| 958 | int giet_fat_rename( char* old_path, |
|---|
| 959 | char* new_path ) |
|---|
| 960 | { |
|---|
| 961 | return sys_call( SYSCALL_FAT_RENAME, |
|---|
| 962 | (unsigned int)old_path, |
|---|
| 963 | (unsigned int)new_path, |
|---|
| 964 | 0, 0 ); |
|---|
| 965 | } |
|---|
| 966 | |
|---|
| 967 | //////////////////////////////////// |
|---|
| 968 | int giet_fat_mkdir( char* pathname ) |
|---|
| 969 | { |
|---|
| 970 | return sys_call( SYSCALL_FAT_MKDIR, |
|---|
| 971 | (unsigned int)pathname, |
|---|
| 972 | 0, 0, 0 ); |
|---|
| 973 | } |
|---|
| 974 | |
|---|
| 975 | ///////////////////////////////////// |
|---|
| 976 | int giet_fat_list( char* pathname ) |
|---|
| 977 | { |
|---|
| 978 | return sys_call( SYSCALL_FAT_LIST, |
|---|
| 979 | (unsigned int)pathname, |
|---|
| 980 | 0, 0, 0 ); |
|---|
| 981 | } |
|---|
| 982 | |
|---|
| 983 | |
|---|
| 984 | |
|---|
| 985 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| 986 | ///////////////////// Miscellaneous system calls ///////////////////////////////// |
|---|
| 987 | ////////////////////////////////////////////////////////////////////////////////// |
|---|
| 988 | |
|---|
| 989 | ////////////////////////////// |
|---|
| 990 | void giet_exit( char* string ) |
|---|
| 991 | { |
|---|
| 992 | sys_call( SYSCALL_EXIT, |
|---|
| 993 | (unsigned int)string, |
|---|
| 994 | 0, 0, 0 ); |
|---|
| 995 | } |
|---|
| 996 | |
|---|
| 997 | ///////////////////////////////////////// |
|---|
| 998 | void giet_assert( unsigned int condition, |
|---|
| 999 | char* string ) |
|---|
| 1000 | { |
|---|
| 1001 | if ( condition == 0 ) giet_exit( string ); |
|---|
| 1002 | } |
|---|
| 1003 | |
|---|
| 1004 | ////////////////////////// |
|---|
| 1005 | void giet_context_switch() |
|---|
| 1006 | { |
|---|
| 1007 | sys_call( SYSCALL_CTX_SWITCH, |
|---|
| 1008 | 0, 0, 0, 0 ); |
|---|
| 1009 | } |
|---|
| 1010 | |
|---|
| 1011 | ///////////////////////////////////////////////// |
|---|
| 1012 | void giet_procs_number( unsigned int* x_size, |
|---|
| 1013 | unsigned int* y_size, |
|---|
| 1014 | unsigned int* nprocs ) |
|---|
| 1015 | { |
|---|
| 1016 | if ( sys_call( SYSCALL_PROCS_NUMBER, |
|---|
| 1017 | (unsigned int)x_size, |
|---|
| 1018 | (unsigned int)y_size, |
|---|
| 1019 | (unsigned int)nprocs, |
|---|
| 1020 | 0 ) ) giet_exit("ERROR in giet_procs_number()"); |
|---|
| 1021 | } |
|---|
| 1022 | |
|---|
| 1023 | //////////////////////////////////////////////////// |
|---|
| 1024 | void giet_vobj_get_vbase( char* vspace_name, |
|---|
| 1025 | char* vobj_name, |
|---|
| 1026 | unsigned int* vbase ) |
|---|
| 1027 | { |
|---|
| 1028 | if ( sys_call( SYSCALL_VOBJ_GET_VBASE, |
|---|
| 1029 | (unsigned int) vspace_name, |
|---|
| 1030 | (unsigned int) vobj_name, |
|---|
| 1031 | (unsigned int) vbase, |
|---|
| 1032 | 0 ) ) giet_exit("ERROR in giet_vobj_get_vbase()"); |
|---|
| 1033 | } |
|---|
| 1034 | |
|---|
| 1035 | //////////////////////////////////////////////////// |
|---|
| 1036 | void giet_vobj_get_length( char* vspace_name, |
|---|
| 1037 | char* vobj_name, |
|---|
| 1038 | unsigned int* length ) |
|---|
| 1039 | { |
|---|
| 1040 | if ( sys_call( SYSCALL_VOBJ_GET_LENGTH, |
|---|
| 1041 | (unsigned int) vspace_name, |
|---|
| 1042 | (unsigned int) vobj_name, |
|---|
| 1043 | (unsigned int) length, |
|---|
| 1044 | 0 ) ) giet_exit("ERROR in giet_vobj_get_length()"); |
|---|
| 1045 | } |
|---|
| 1046 | |
|---|
| 1047 | ///////////////////////////////////////// |
|---|
| 1048 | void giet_heap_info( unsigned int* vaddr, |
|---|
| 1049 | unsigned int* length, |
|---|
| 1050 | unsigned int x, |
|---|
| 1051 | unsigned int y ) |
|---|
| 1052 | { |
|---|
| 1053 | if ( sys_call( SYSCALL_HEAP_INFO, |
|---|
| 1054 | (unsigned int)vaddr, |
|---|
| 1055 | (unsigned int)length, |
|---|
| 1056 | x, |
|---|
| 1057 | y ) ) giet_exit("ERROR in giet_heap_info()"); |
|---|
| 1058 | } |
|---|
| 1059 | |
|---|
| 1060 | ///////////////////////////////////////// |
|---|
| 1061 | void giet_get_xy( void* ptr, |
|---|
| 1062 | unsigned int* px, |
|---|
| 1063 | unsigned int* py ) |
|---|
| 1064 | { |
|---|
| 1065 | if ( sys_call( SYSCALL_GET_XY, |
|---|
| 1066 | (unsigned int)ptr, |
|---|
| 1067 | (unsigned int)px, |
|---|
| 1068 | (unsigned int)py, |
|---|
| 1069 | 0 ) ) giet_exit("ERROR in giet_get_xy()"); |
|---|
| 1070 | } |
|---|
| 1071 | |
|---|
| 1072 | // Local Variables: |
|---|
| 1073 | // tab-width: 4 |
|---|
| 1074 | // c-basic-offset: 4 |
|---|
| 1075 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
|---|
| 1076 | // indent-tabs-mode: nil |
|---|
| 1077 | // End: |
|---|
| 1078 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
|---|
| 1079 | |
|---|