Changeset 253 for soft/giet_vm/libs/stdio.c
- Timestamp:
- Aug 14, 2013, 11:19:29 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/libs/stdio.c
r238 r253 13 13 #include <stdio.h> 14 14 15 #define SYSCALL_PROCID 0x00 16 #define SYSCALL_PROCTIME 0x01 17 #define SYSCALL_TTY_WRITE 0x02 18 #define SYSCALL_TTY_READ 0x03 19 #define SYSCALL_TIMER_START 0x04 20 #define SYSCALL_TIMER_STOP 0x05 21 #define SYSCALL_GCD_WRITE 0x06 22 #define SYSCALL_GCD_READ 0x07 23 #define SYSCALL_HEAP_INFO 0x08 24 #define SYSCALL_PROC_TASK_ID 0x09 25 #define SYSCALL_GLOBAL_TASK_ID 0x0A 26 #define SYSCALL_CTX_SWITCH 0x0D 27 #define SYSCALL_EXIT 0x0E 28 #define SYSCALL_PROC_NUMBER 0x0F 29 #define SYSCALL_FB_SYNC_WRITE 0x10 30 #define SYSCALL_FB_SYNC_READ 0x11 31 #define SYSCALL_FB_WRITE 0x12 32 #define SYSCALL_FB_READ 0x13 33 #define SYSCALL_FB_COMPLETED 0x14 34 #define SYSCALL_IOC_WRITE 0x15 35 #define SYSCALL_IOC_READ 0x16 36 #define SYSCALL_IOC_COMPLETED 0x17 37 #define SYSCALL_IOC_BLOCK_SIZE 0x18 38 #define SYSCALL_VOBJ_GET_VBASE 0x1A 39 #define SYSCALL_NIC_WRITE 0x1B 40 #define SYSCALL_NIC_READ 0x1C 41 #define SYSCALL_NIC_COMPLETED 0x1D 15 #define SYSCALL_PROCID 0x00 16 #define SYSCALL_PROCTIME 0x01 17 #define SYSCALL_TTY_WRITE 0x02 18 #define SYSCALL_TTY_READ 0x03 19 #define SYSCALL_TIMER_START 0x04 20 #define SYSCALL_TIMER_STOP 0x05 21 #define SYSCALL_GCD_WRITE 0x06 22 #define SYSCALL_GCD_READ 0x07 23 #define SYSCALL_HEAP_INFO 0x08 24 #define SYSCALL_LOCAL_TASK_ID 0x09 25 #define SYSCALL_GLOBAL_TASK_ID 0x0A 26 #define SYSCALL_FB_CMA_INIT 0x0B 27 #define SYSCALL_FB_CMA_WRITE 0x0C 28 #define SYSCALL_FB_CMA_STOP 0x0D 29 #define SYSCALL_EXIT 0x0E 30 #define SYSCALL_PROC_NUMBER 0x0F 31 #define SYSCALL_FB_SYNC_WRITE 0x10 32 #define SYSCALL_FB_SYNC_READ 0x11 33 #define SYSCALL_FB_DMA_WRITE 0x12 34 #define SYSCALL_FB_DMA_READ 0x13 35 #define SYSCALL_FB_DMA_COMPLETED 0x14 36 #define SYSCALL_IOC_WRITE 0x15 37 #define SYSCALL_IOC_READ 0x16 38 #define SYSCALL_IOC_COMPLETED 0x17 39 #define SYSCALL_IOC_BLOCK_SIZE 0x18 40 #define SYSCALL_CTX_SWITCH 0x19 41 #define SYSCALL_VOBJ_GET_VBASE 0x1A 42 #define SYSCALL_NIC_CMA_RX_INIT 0x1B 43 #define SYSCALL_NIC_CMA_TX_INIT 0x1C 44 #define SYSCALL_NIC_CMA_STOP 0x1D 45 #define SYSCALL_NIC_SYNC_READ 0x1E 46 #define SYSCALL_NIC_SYNC_WRITE 0x1F 42 47 43 48 ////////////////////////////////////////////////////////////////////////////////// … … 47 52 // and tells GCC what has been modified by system call execution. 48 53 ////////////////////////////////////////////////////////////////////////////////// 49 static inline unsigned int sys_call(unsigned int call_no, 50 unsigned int arg_0, 51 unsigned int arg_1, 52 unsigned int arg_2, 53 unsigned int arg_3) { 54 static inline unsigned int sys_call( unsigned int call_no, 55 unsigned int arg_0, 56 unsigned int arg_1, 57 unsigned int arg_2, 58 unsigned int arg_3 ) 59 { 54 60 register unsigned int reg_no_and_output asm("v0") = call_no; 55 61 register unsigned int reg_a0 asm("a0") = arg_0; … … 109 115 110 116 111 ////// 117 ////// TTY device related system calls ///// 112 118 113 119 //////////////////////////////////////////////////////////////////////////////////// … … 123 129 return sys_call(SYSCALL_TTY_WRITE, (unsigned int) (&byte), 1, 0, 0); 124 130 } 125 126 127 131 //////////////////////////////////////////////////////////////////////////////////// 128 132 // giet_tty_puts() … … 140 144 return sys_call(SYSCALL_TTY_WRITE, (unsigned int) buf, length, 0, 0); 141 145 } 142 143 144 146 //////////////////////////////////////////////////////////////////////////////////// 145 147 // giet_tty_putw() … … 161 163 return sys_call(SYSCALL_TTY_WRITE, (unsigned int) buf, 10, 0, 0); 162 164 } 163 164 165 165 //////////////////////////////////////////////////////////////////////////////////// 166 166 // giet_tty_getc() … … 180 180 return 0; 181 181 } 182 183 184 182 //////////////////////////////////////////////////////////////////////////////////// 185 183 // giet_tty_gets() … … 226 224 return 0; 227 225 } 228 229 230 226 //////////////////////////////////////////////////////////////////////////////////// 231 227 // giet_tty_getw() … … 325 321 return 0; 326 322 } 327 328 329 323 //////////////////////////////////////////////////////////////////////////////////// 330 324 // giet_tty_printf() … … 448 442 // - Returns 0 if success, > 0 if error. 449 443 ////////////////////////////////////////////////////////////////////////////////// 450 unsigned int giet_timer_start() { 444 unsigned int giet_timer_start() 445 { 451 446 return sys_call(SYSCALL_TIMER_START, 0, 0, 0, 0); 452 447 } 453 454 455 448 ////////////////////////////////////////////////////////////////////////////////// 456 449 // giet_timer_stop() … … 459 452 // - Returns 0 if success, > 0 if error. 460 453 ////////////////////////////////////////////////////////////////////////////////// 461 unsigned int giet_timer_stop() { 454 unsigned int giet_timer_stop() 455 { 462 456 return sys_call(SYSCALL_TIMER_STOP, 0, 0, 0, 0); 463 457 } … … 477 471 // - Returns 0 if success, > 0 if error. 478 472 ////////////////////////////////////////////////////////////////////////////////// 479 unsigned int giet_gcd_set_opa(unsigned int val) { 473 unsigned int giet_gcd_set_opa(unsigned int val) 474 { 480 475 return sys_call(SYSCALL_GCD_WRITE, GCD_OPA, val, 0, 0); 481 476 } 482 483 484 477 ////////////////////////////////////////////////////////////////////////////////// 485 478 // giet_gcd_set_opb() … … 488 481 // - Returns 0 if success, > 0 if error. 489 482 ////////////////////////////////////////////////////////////////////////////////// 490 unsigned int giet_gcd_set_opb(unsigned int val) { 483 unsigned int giet_gcd_set_opb(unsigned int val) 484 { 491 485 return sys_call(SYSCALL_GCD_WRITE, GCD_OPB, val, 0, 0); 492 486 } 493 494 495 487 ////////////////////////////////////////////////////////////////////////////////// 496 488 // giet_gcd_start() … … 499 491 // - Returns 0 if success, > 0 if error. 500 492 ////////////////////////////////////////////////////////////////////////////////// 501 unsigned int giet_gcd_start() { 493 unsigned int giet_gcd_start() 494 { 502 495 return sys_call(SYSCALL_GCD_WRITE, GCD_START, 0, 0, 0); 503 496 } 504 505 506 497 ////////////////////////////////////////////////////////////////////////////////// 507 498 // giet_gcd_get_status() … … 510 501 // - The value is 0 when the coprocessor is idle (computation completed). 511 502 ////////////////////////////////////////////////////////////////////////////////// 512 unsigned int giet_gcd_get_status(unsigned int * val) { 503 unsigned int giet_gcd_get_status(unsigned int * val) 504 { 513 505 return sys_call(SYSCALL_GCD_READ, GCD_STATUS, (unsigned int) val, 0, 0); 514 506 } 515 516 517 507 ////////////////////////////////////////////////////////////////////////////////// 518 508 // giet_gcd_get_result() … … 520 510 // This function gets the result of the computation from the GCD coprocessor. 521 511 ////////////////////////////////////////////////////////////////////////////////// 522 unsigned int giet_gcd_get_result(unsigned int * val) { 512 unsigned int giet_gcd_get_result(unsigned int * val) 513 { 523 514 return sys_call(SYSCALL_GCD_READ, GCD_OPA, (unsigned int) val, 0, 0); 524 515 } … … 536 527 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 537 528 ////////////////////////////////////////////////////////////////////////////////// 538 unsigned int giet_ioc_write( unsigned int lba, void * buffer, unsigned int count) { 529 unsigned int giet_ioc_write( unsigned int lba, 530 void * buffer, 531 unsigned int count) 532 { 539 533 return sys_call(SYSCALL_IOC_WRITE, lba, (unsigned int) buffer, count, 0); 540 534 } 541 542 543 535 ////////////////////////////////////////////////////////////////////////////////// 544 536 // giet_ioc_read() … … 550 542 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 551 543 ////////////////////////////////////////////////////////////////////////////////// 552 unsigned int giet_ioc_read(unsigned int lba, void * buffer, unsigned int count) { 544 unsigned int giet_ioc_read( unsigned int lba, 545 void * buffer, 546 unsigned int count ) 547 { 553 548 return sys_call(SYSCALL_IOC_READ, lba, (unsigned int) buffer, count, 0); 554 549 } 555 556 557 550 ////////////////////////////////////////////////////////////////////////////////// 558 551 // giet_ioc_completed() … … 561 554 // successfully completed, and returns 1 if an address error has been detected. 562 555 ////////////////////////////////////////////////////////////////////////////////// 563 unsigned int giet_ioc_completed() { 556 unsigned int giet_ioc_completed() 557 { 564 558 return sys_call(SYSCALL_IOC_COMPLETED, 0, 0, 0, 0); 565 559 } 566 567 568 560 ////////////////////////////////////////////////////////////////////////////////// 569 561 // giet_ioc_block_size() … … 571 563 // This blocking function returns the block_size (in bytes) of the block device 572 564 ////////////////////////////////////////////////////////////////////////////////// 573 unsigned int giet_ioc_block_size() { 565 unsigned int giet_ioc_block_size() 566 { 574 567 return sys_call(SYSCALL_IOC_BLOCK_SIZE, 0, 0, 0, 0); 575 568 } … … 588 581 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 589 582 ////////////////////////////////////////////////////////////////////////////////// 590 unsigned int giet_fb_sync_write(unsigned int offset, void * buffer, unsigned int length) { 583 unsigned int giet_fb_sync_write( unsigned int offset, 584 void * buffer, 585 unsigned int length ) 586 { 591 587 return sys_call(SYSCALL_FB_SYNC_WRITE, offset, (unsigned int) buffer, length, 0); 592 588 } 593 594 595 589 ////////////////////////////////////////////////////////////////////////////////// 596 590 // giet_fb_sync_read() … … 603 597 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 604 598 ////////////////////////////////////////////////////////////////////////////////// 605 unsigned int giet_fb_sync_read(unsigned int offset, void * buffer, unsigned int length) { 599 unsigned int giet_fb_sync_read( unsigned int offset, 600 void * buffer, 601 unsigned int length ) 602 { 606 603 return sys_call(SYSCALL_FB_SYNC_READ, offset, (unsigned int) buffer, length, 0); 607 604 } 608 609 610 ////////////////////////////////////////////////////////////////////////////////// 611 // giet_fb_write() 605 ////////////////////////////////////////////////////////////////////////////////// 606 // giet_fb_dma_write() 612 607 ////////////////////////////////////////////////////////////////////////////////// 613 608 // This non-blocking function use the DMA coprocessor to transfer data from a … … 620 615 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 621 616 ////////////////////////////////////////////////////////////////////////////////// 622 unsigned int giet_fb_write(unsigned int offset, void * buffer, unsigned int length) { 623 return sys_call(SYSCALL_FB_WRITE, offset, (unsigned int) buffer, length, 0); 624 } 625 626 627 ////////////////////////////////////////////////////////////////////////////////// 628 // giet_fb_read() 617 unsigned int giet_fb_dma_write( unsigned int offset, 618 void * buffer, 619 unsigned int length ) 620 { 621 return sys_call(SYSCALL_FB_DMA_WRITE, offset, (unsigned int) buffer, length, 0); 622 } 623 ////////////////////////////////////////////////////////////////////////////////// 624 // giet_fb_dma_read() 629 625 ////////////////////////////////////////////////////////////////////////////////// 630 626 // This non-blocking function use the DMA coprocessor to transfer data from the … … 637 633 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 638 634 ////////////////////////////////////////////////////////////////////////////////// 639 unsigned int giet_fb_read(unsigned int offset, void * buffer, unsigned int length) { 640 return sys_call(SYSCALL_FB_READ, offset, (unsigned int) buffer, length, 0); 641 } 642 643 644 ////////////////////////////////////////////////////////////////////////////////// 645 // giet_fb_completed() 635 unsigned int giet_fb_dma_read( unsigned int offset, 636 void * buffer, 637 unsigned int length ) 638 { 639 return sys_call(SYSCALL_FB_DMA_READ, offset, (unsigned int) buffer, length, 0); 640 } 641 ////////////////////////////////////////////////////////////////////////////////// 642 // giet_fb_dma_completed() 646 643 ////////////////////////////////////////////////////////////////////////////////// 647 644 // This blocking function returns when the transfer is completed. 648 645 // - Returns 0 if success, > 0 if error. 649 646 ////////////////////////////////////////////////////////////////////////////////// 650 unsigned int giet_fb_completed() { 651 return sys_call(SYSCALL_FB_COMPLETED, 0, 0, 0, 0); 652 } 653 654 655 ////////////////////////////////////////////////////////////////////////////////// 656 // giet_nic_write() 657 ////////////////////////////////////////////////////////////////////////////////// 658 // This non-blocking function use the DMA coprocessor to transfer data from the 659 // NIC device to an user buffer. 660 // - offset : offset (in bytes) in the NIC 661 // - buffer : base address of the memory buffer 662 // - length : number of bytes to be transfered 663 // The transfer completion is signaled by an IRQ, and must be tested by the 664 // nic_completed() function. 647 unsigned int giet_fb_dma_completed() 648 { 649 return sys_call(SYSCALL_FB_DMA_COMPLETED, 0, 0, 0, 0); 650 } 651 ////////////////////////////////////////////////////////////////////////////////// 652 // giet_fb_cma_init() 653 ////////////////////////////////////////////////////////////////////////////////// 654 // This function initializes the two chbuf SRC an DST used by the CMA controller 655 // and activates the CMA channel allocated to the calling task. 656 // - buf0 : first user buffer virtual address 657 // - buf0 : second user buffer virtual address 658 // - length : buffer size (bytes) 659 // - Returns 0 if success, > 0 if error. 660 ////////////////////////////////////////////////////////////////////////////////// 661 unsigned int giet_fb_cma_init( void * buf0, 662 void * buf1, 663 unsigned int length ) 664 { 665 return sys_call(SYSCALL_FB_CMA_INIT, (unsigned int)buf0, (unsigned int)buf1, length, 0); 666 } 667 ////////////////////////////////////////////////////////////////////////////////// 668 // giet_fb_cma_write() 669 ////////////////////////////////////////////////////////////////////////////////// 670 // This function set the valid status for one of the SRC user buffer. 671 // and reset the valid status for the DST frame buffer. 672 // - bufffer_id : 0 => buf0 valid is set / not 0 => buf1 valid is set 673 // - Returns 0 if success, > 0 if error. 674 ////////////////////////////////////////////////////////////////////////////////// 675 unsigned int giet_fb_cma_write( unsigned int buffer_id ) 676 { 677 return sys_call(SYSCALL_FB_CMA_WRITE, buffer_id, 0, 0, 0); 678 } 679 ////////////////////////////////////////////////////////////////////////////////// 680 // giet_fb_cma_stop() 681 ////////////////////////////////////////////////////////////////////////////////// 682 // This function desactivates the CMA channel allocated to the calling task. 683 // - Returns 0 if success, > 0 if error. 684 ////////////////////////////////////////////////////////////////////////////////// 685 unsigned int giet_fb_cma_stop( ) 686 { 687 return sys_call(SYSCALL_FB_CMA_STOP, 0, 0, 0, 0); 688 } 689 690 691 //////// NIC related system calls //////// 692 693 ////////////////////////////////////////////////////////////////////////////////// 694 // giet_nic_cma_rx_init() 695 ////////////////////////////////////////////////////////////////////////////////// 696 // This function initializes the two chbuf SRC an DST used by the CMA controller 697 // and activates the NIC RX channel allocated to the calling task, and the 698 // CMA channel used for RX transfer. 699 // - buf0 : first user buffer virtual address 700 // - buf0 : second user buffer virtual address 701 // - length : buffer size (bytes) 665 702 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 666 703 ////////////////////////////////////////////////////////////////////////////////// 667 668 unsigned int giet_nic_write(unsigned int offset, void * buffer, unsigned int length) { 669 return sys_call(SYSCALL_NIC_WRITE, offset, (unsigned int) buffer, length, 0); 670 } 671 672 673 ////////////////////////////////////////////////////////////////////////////////// 674 // giet_nic_read() 675 ////////////////////////////////////////////////////////////////////////////////// 676 // This non-blocking function use the DMA coprocessor to transfer data from the 677 // NIC device to an user buffer. 678 // - offset : offset (in bytes) in the NIC 679 // - buffer : base address of the memory buffer 680 // - length : number of bytes to be transfered 681 // The transfer completion is signaled by an IRQ, and must be tested by the 682 // nic_completed() function. 704 unsigned int giet_nic_cma_rx_init( void * buf0, 705 void * buf1, 706 unsigned int length ) 707 { 708 return sys_call(SYSCALL_NIC_CMA_RX_INIT, (unsigned int)buf0, (unsigned int)buf1, length, 0); 709 } 710 ////////////////////////////////////////////////////////////////////////////////// 711 // giet_nic_cma_tx_init() 712 ////////////////////////////////////////////////////////////////////////////////// 713 // This function initializes the two chbuf SRC an DST used by the CMA controller 714 // and activates the NIC TX channel allocated to the calling task, and the two 715 // CMA channel used for TX transfer. 716 // - buf0 : first user buffer virtual address 717 // - buf0 : second user buffer virtual address 718 // - length : buffer size (bytes) 683 719 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 684 720 ////////////////////////////////////////////////////////////////////////////////// 685 686 unsigned int giet_nic_read(unsigned int offset, void * buffer, unsigned int length) { 687 return sys_call(SYSCALL_NIC_READ, offset, (unsigned int) buffer, length, 0); 688 } 689 690 691 ////////////////////////////////////////////////////////////////////////////////// 692 // giet_nic_completed() 693 ////////////////////////////////////////////////////////////////////////////////// 694 // This blocking function returns when the transfer is completed. 695 // - Returns 0 if success, > 0 if error. 696 ////////////////////////////////////////////////////////////////////////////////// 697 unsigned int giet_nic_completed() { 698 return sys_call(SYSCALL_NIC_COMPLETED, 0, 0, 0, 0); 699 } 700 701 702 ///// Miscellaneous related system calls ///// 721 unsigned int giet_nic_cma_tx_init( void * buf0, 722 void * buf1, 723 unsigned int length ) 724 { 725 return sys_call(SYSCALL_NIC_CMA_TX_INIT, (unsigned int)buf0, (unsigned int)buf1, length, 0); 726 } 727 ////////////////////////////////////////////////////////////////////////////////// 728 // giet_nic_cma_stop() 729 ////////////////////////////////////////////////////////////////////////////////// 730 // This function desactivates the NIC channel and the two CMA channels 731 // allocated to the calling task. 732 // - Returns 0 if success, > 0 if error. 733 ////////////////////////////////////////////////////////////////////////////////// 734 unsigned int giet_nic_cma_stop( ) 735 { 736 return sys_call(SYSCALL_NIC_CMA_STOP, 0, 0, 0, 0); 737 } 738 739 740 ///// Miscellaneous system calls ///// 703 741 704 742 ////////////////////////////////////////////////////////////////////////////////// … … 711 749 // - Returns the address if success, 0 if error ( not defined or wrong type ) 712 750 ////////////////////////////////////////////////////////////////////////////////// 713 unsigned int giet_vobj_get_vbase(char * vspace_name, char * vobj_name, unsigned int vobj_type, unsigned int * vobj_vaddr) { 751 unsigned int giet_vobj_get_vbase( char* vspace_name, 752 char* vobj_name, 753 unsigned int vobj_type, 754 unsigned int* vobj_vaddr ) 755 { 714 756 return sys_call(SYSCALL_VOBJ_GET_VBASE, 715 757 (unsigned int) vspace_name, … … 718 760 (unsigned int) vobj_vaddr); 719 761 } 720 721 722 762 //////////////////////////////////////////////////////////////////////////////////// 723 763 // giet_proc_number() … … 727 767 // - Returns 0 if success, > 0 if error ( cluster index too large ) 728 768 //////////////////////////////////////////////////////////////////////////////////// 729 unsigned int giet_proc_number(unsigned int cluster_id, unsigned int * buffer) { 769 unsigned int giet_proc_number( unsigned int cluster_id, 770 unsigned int* buffer ) 771 { 730 772 return sys_call(SYSCALL_PROC_NUMBER, cluster_id, (unsigned int) buffer, 0, 0); 731 773 } 732 733 734 ///// Miscellaneous system calls ///// 735 736 ////////////////////////////////////////////////////////////////////////////////// 737 // giet_task_exit() 774 ////////////////////////////////////////////////////////////////////////////////// 775 // giet_exit() 738 776 ////////////////////////////////////////////////////////////////////////////////// 739 777 // This function stops execution of the calling task with a TTY message, 740 // and enter an infinite loop. 741 // The task is blocked, but it still consume processor cycles ... 742 ////////////////////////////////////////////////////////////////////////////////// 743 void giet_exit() { 778 // and the task is descheduled and becomes not runable. 779 // It does not consume processor cycles anymore. 780 ////////////////////////////////////////////////////////////////////////////////// 781 void giet_exit() 782 { 744 783 sys_call(SYSCALL_EXIT, 0, 0, 0, 0); 745 784 } 746 785 ////////////////////////////////////////////////////////////////////////////////// 786 // giet_context_switch() 787 // The user task calling this function is descheduled and 788 // the processor is allocated to another task. 789 ////////////////////////////////////////////////////////////////////////////////// 790 unsigned int giet_context_switch() 791 { 792 return sys_call(SYSCALL_CTX_SWITCH, 0, 0, 0, 0); 793 } 794 ////////////////////////////////////////////////////////////////////////////////// 795 // giet_proc_task_id() 796 // This functions returns the local task id, i.e. the processor task id (ranging 797 // from 0 to n-1(p) for each processor if p has n tasks) 798 ////////////////////////////////////////////////////////////////////////////////// 799 unsigned int giet_proc_task_id() 800 { 801 return sys_call(SYSCALL_LOCAL_TASK_ID, 0, 0, 0, 0); 802 } 803 ////////////////////////////////////////////////////////////////////////////////// 804 // giet_heap_info() 805 // This function returns the base address and size of the current task's heap 806 ////////////////////////////////////////////////////////////////////////////////// 807 unsigned int giet_heap_info( unsigned int* vaddr, 808 unsigned int* length) 809 { 810 return sys_call(SYSCALL_HEAP_INFO, (unsigned int)vaddr, (unsigned int)length, 0, 0); 811 } 812 ////////////////////////////////////////////////////////////////////////////////// 813 // giet_global_task_id() 814 // This functions returns the global task id, which is unique in all the giet. 815 ////////////////////////////////////////////////////////////////////////////////// 816 unsigned int giet_global_task_id() 817 { 818 return sys_call(SYSCALL_GLOBAL_TASK_ID, 0, 0, 0, 0); 819 } 820 /////////////////////////////////////////////////////////////////////////////////// 821 // giet_assert() 822 // This function 823 /////////////////////////////////////////////////////////////////////////////////// 824 void giet_assert( unsigned int condition, 825 char* string ) 826 { 827 if ( condition == 0 ) 828 { 829 giet_tty_puts( string ); 830 giet_exit(); 831 } 832 } 833 834 ////// Pseudo system calls (no syscall instruction) /////// 747 835 748 836 /////////////////////////////////////////////////////////////////////////////////// … … 751 839 // count. This value is comprised between 0 & 65535. 752 840 /////////////////////////////////////////////////////////////////////////////////// 753 unsigned int giet_rand() { 841 unsigned int giet_rand() 842 { 754 843 unsigned int x = sys_call(SYSCALL_PROCTIME, 0, 0, 0, 0); 755 844 if ((x & 0xF) > 7) { … … 761 850 } 762 851 763 764 //////////////////////////////////////////////////////////////////////////////////765 // giet_context_switch()766 // The user task calling this function is descheduled and767 // the processor is allocated to another task.768 //////////////////////////////////////////////////////////////////////////////////769 unsigned int giet_context_switch() {770 return sys_call(SYSCALL_CTX_SWITCH, 0, 0, 0, 0);771 }772 773 //////////////////////////////////////////////////////////////////////////////////774 // giet_proc_task_id()775 // This functions returns the local task id, i.e. the processor task id (ranging776 // from 0 to n-1(p) for each processor if p has n tasks)777 //////////////////////////////////////////////////////////////////////////////////778 unsigned int giet_proc_task_id() {779 return sys_call(SYSCALL_PROC_TASK_ID, 0, 0, 0, 0);780 }781 782 //////////////////////////////////////////////////////////////////////////////////783 // giet_heap_info()784 // This function returns the base address and size of the current task's heap785 //////////////////////////////////////////////////////////////////////////////////786 unsigned int giet_heap_info(unsigned int * vaddr, unsigned int * length) {787 return sys_call(SYSCALL_HEAP_INFO, (unsigned int) vaddr, (unsigned int) length, 0, 0);788 }789 790 791 //////////////////////////////////////////////////////////////////////////////////792 // giet_global_task_id()793 // This functions returns the global task id, which is unique in all the giet794 //////////////////////////////////////////////////////////////////////////////////795 unsigned int giet_global_task_id() {796 return sys_call(SYSCALL_GLOBAL_TASK_ID, 0, 0, 0, 0);797 }798 852 799 853 // Local Variables:
Note: See TracChangeset
for help on using the changeset viewer.