Changeset 390 for soft/giet_vm/giet_libs/stdio.c
- Timestamp:
- Aug 7, 2014, 4:57:07 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_libs/stdio.c
r382 r390 5 5 // Copyright (c) UPMC-LIP6 6 6 /////////////////////////////////////////////////////////////////////////////////// 7 // The stdio.c and stdio.h files are part of the GIET_VM nano-kernel.8 // This library contains all user-level functions that contain a system call9 // to access protected or shared ressources.10 ///////////////////////////////////////////////////////////////////////////////////11 7 12 8 #include <stdarg.h> 13 9 #include <stdio.h> 14 10 #include <giet_config.h> 11 12 //////////////////////////////////////////////////////////////////////////////////// 13 ///////////////////// MIPS32 related system calls ///////////////////////////// 14 //////////////////////////////////////////////////////////////////////////////////// 15 16 ///////////////// 17 int giet_procid() 18 { 19 return sys_call( SYSCALL_PROCID, 20 0, 0, 0, 0 ); 21 } 22 23 //////////////////// 24 int giet_proctime() 25 { 26 return sys_call( SYSCALL_PROCTIME, 27 0, 0, 0, 0 ); 28 } 29 30 /////////////// 31 int giet_rand() 32 { 33 unsigned int x = sys_call(SYSCALL_PROCTIME, 34 0, 0, 0, 0); 35 if ((x & 0xF) > 7) 36 { 37 return (x*x & 0xFFFF); 38 } 39 else 40 { 41 return (x*x*x & 0xFFFF); 42 } 43 } 15 44 16 45 //////////////////////////////////////////////////////////////////////////////////// … … 498 527 (unsigned int)buffer, 499 528 count, 500 offset ) != count ) giet_exit(" in giet_fat_read()");529 offset ) != count ) giet_exit("ERROR in giet_fat_read()"); 501 530 } 502 531 … … 511 540 (unsigned int)buffer, 512 541 count, 513 offset ) != count ) giet_exit(" in giet_fat_write()");542 offset ) != count ) giet_exit("ERROR in giet_fat_write()"); 514 543 } 515 544 … … 541 570 offset, 542 571 whence, 543 0 ) ) giet_exit(" in giet_fat_lseek()");572 0 ) ) giet_exit("ERROR in giet_fat_lseek()"); 544 573 } 545 574 … … 549 578 if ( sys_call( SYSCALL_FAT_FSTAT, 550 579 fd, 551 0, 0, 0 ) ) giet_exit(" in giet_fat_lseek()");580 0, 0, 0 ) ) giet_exit("ERROR in giet_fat_lseek()"); 552 581 } 553 582 … … 557 586 if ( sys_call( SYSCALL_FAT_CLOSE, 558 587 fd, 559 0, 0, 0 ) ) giet_exit("in giet_fat_close()"); 560 } 561 562 563 ////////////////////////////////////////////////////////////////////////////////// 564 ///////////////////// Miscellaneous system calls ///////////////////////////////// 565 ////////////////////////////////////////////////////////////////////////////////// 566 567 ///////////////// 568 int giet_procid() 569 { 570 return sys_call( SYSCALL_PROCID, 571 0, 0, 0, 0 ); 572 } 573 574 //////////////////// 575 int giet_proctime() 576 { 577 return sys_call( SYSCALL_PROCTIME, 578 0, 0, 0, 0 ); 579 } 588 0, 0, 0 ) ) giet_exit("ERROR in giet_fat_close()"); 589 } 590 591 592 ////////////////////////////////////////////////////////////////////////////////// 593 ///////////////////// Task context system calls ///////////////////////////////// 594 ////////////////////////////////////////////////////////////////////////////////// 580 595 581 596 /////////////////////// … … 600 615 } 601 616 602 /////////////// 603 int giet_rand() 604 { 605 unsigned int x = sys_call(SYSCALL_PROCTIME, 0, 0, 0, 0); 606 if ((x & 0xF) > 7) { 607 return (x*x & 0xFFFF); 608 } 609 else { 610 return (x*x*x & 0xFFFF); 611 } 612 } 617 618 ////////////////////////////////////////////////////////////////////////////////// 619 ///////////////////// Miscellaneous system calls ///////////////////////////////// 620 ////////////////////////////////////////////////////////////////////////////////// 613 621 614 622 ////////////////////////////// … … 625 633 { 626 634 if ( condition == 0 ) giet_exit( string ); 635 } 636 637 ////////////////////////// 638 void giet_context_switch() 639 { 640 sys_call( SYSCALL_CTX_SWITCH, 641 0, 0, 0, 0 ); 627 642 } 628 643 … … 636 651 (unsigned int) vobj_name, 637 652 (unsigned int) vobj_vaddr, 638 0 ) ) giet_exit(" in giet_vobj_get_vbase()");653 0 ) ) giet_exit("ERROR in giet_vobj_get_vbase()"); 639 654 } 640 655 … … 646 661 cluster_id, 647 662 (unsigned int) buffer, 648 0, 0) ) giet_exit("in giet_proc_number()"); 649 } 650 651 ////////////////////////// 652 void giet_context_switch() 653 { 654 sys_call( SYSCALL_CTX_SWITCH, 655 0, 0, 0, 0 ); 663 0, 0) ) giet_exit("ERROR in giet_proc_number()"); 656 664 } 657 665 … … 666 674 (unsigned int)length, 667 675 x, 668 y ) ) giet_exit("in giet_heap_info()"); 676 y ) ) giet_exit("ERROR in giet_heap_info()"); 677 } 678 679 ///////////////////////////////////////// 680 void giet_get_xy( void* ptr, 681 unsigned int* px, 682 unsigned int* py ) 683 { 684 if ( sys_call( SYSCALL_GET_XY, 685 (unsigned int)ptr, 686 (unsigned int)px, 687 (unsigned int)py, 688 0 ) ) giet_exit("ERROR in giet_get_xy()"); 669 689 } 670 690
Note: See TracChangeset
for help on using the changeset viewer.