Changeset 709 for soft/giet_vm/giet_libs/stdio.c
- Timestamp:
- Oct 1, 2015, 4:20:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_libs/stdio.c
r689 r709 11 11 12 12 ////////////////////////////////////////////////////////////////////////////// 13 // /////////////////// MIPS32 related system calls ///////////////////////13 // MIPS32 related system calls 14 14 ////////////////////////////////////////////////////////////////////////////// 15 15 … … 49 49 50 50 ////////////////////////////////////////////////////////////////////////////// 51 // /////////////////// Task related system calls /////////////////////////////51 // Threads related system calls 52 52 ////////////////////////////////////////////////////////////////////////////// 53 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 void giet_exit( char* string ) 77 { 78 sys_call( SYSCALL_EXIT, 54 #define THREAD_CMD_PAUSE 0 55 #define THREAD_CMD_RESUME 1 56 #define THREAD_CMD_CONTEXT 2 57 58 ////////////////////////////////////////////////////////// 59 int giet_pthread_create( pthread_t* buffer, 60 pthread_attr_t* attr, 61 void* function, 62 void* arg ) 63 { 64 return sys_call( SYSCALL_PTHREAD_CREATE, 65 (unsigned int)buffer, 66 (unsigned int)attr, 67 (unsigned int)function, 68 (unsigned int)arg ); 69 } 70 71 ////////////////////////////////////// 72 void giet_pthread_exit( void* string ) 73 { 74 sys_call( SYSCALL_PTHREAD_EXIT, 79 75 (unsigned int)string, 80 76 0, 0, 0 ); 81 77 } 82 78 83 ///////////////////////////////////////// 84 void giet_assert( unsigned int condition, 85 char* string ) 86 { 87 if ( condition == 0 ) giet_exit( string ); 88 } 89 90 ////////////////////////// 91 void giet_context_switch() 92 { 93 sys_call( SYSCALL_CTX_SWITCH, 79 //////////////////////////////////////// 80 int giet_pthread_join( pthread_t trdid, 81 void** ptr ) 82 { 83 return sys_call( SYSCALL_PTHREAD_JOIN, 84 trdid, 85 (unsigned int)ptr, 86 0, 0 ); 87 } 88 89 /////////////////////////////////////// 90 int giet_pthread_kill( pthread_t trdid, 91 int signal ) 92 { 93 return sys_call( SYSCALL_PTHREAD_KILL, 94 trdid, 95 signal, 96 0, 0 ); 97 } 98 99 ///////////////////////// 100 void giet_pthread_yield() 101 { 102 sys_call( SYSCALL_PTHREAD_YIELD, 94 103 0, 0, 0, 0 ); 95 104 } 96 105 97 //////////////////////// 98 void giet_tasks_status() 99 { 100 sys_call( SYSCALL_TASKS_STATUS, 101 0, 0, 0, 0 ); 102 } 106 ///////////////////////////////////////////////// 107 void giet_pthread_assert( unsigned int condition, 108 char* string ) 109 { 110 if ( condition == 0 ) giet_pthread_exit( string ); 111 } 112 113 ////////////////////////////////////////////// 114 int giet_pthread_pause( char* vspace_name, 115 char* thread_name ) 116 { 117 return sys_call( SYSCALL_PTHREAD_CONTROL, 118 THREAD_CMD_PAUSE, 119 (unsigned int) vspace_name, 120 (unsigned int) thread_name, 121 0 ); 122 } 123 124 /////////////////////////////////////////////// 125 int giet_pthread_resume( char* vspace_name, 126 char* thread_name ) 127 { 128 return sys_call( SYSCALL_PTHREAD_CONTROL, 129 THREAD_CMD_RESUME, 130 (unsigned int) vspace_name, 131 (unsigned int) thread_name, 132 0 ); 133 } 134 135 /////////////////////////////////////////////// 136 int giet_pthread_context( char* vspace_name, 137 char* thread_name ) 138 { 139 return sys_call( SYSCALL_PTHREAD_CONTROL, 140 THREAD_CMD_CONTEXT, 141 (unsigned int) vspace_name, 142 (unsigned int) thread_name, 143 0 ); 144 } 145 103 146 104 147 ////////////////////////////////////////////////////////////////////////////// 105 // /////////////////// Applications system calls /////////////////////////////148 // Applications related system calls 106 149 ////////////////////////////////////////////////////////////////////////////// 107 150 … … 122 165 } 123 166 167 /////////////////////////////// 168 void giet_applications_status() 169 { 170 sys_call( SYSCALL_APPS_STATUS, 171 0, 0, 0, 0 ); 172 } 173 124 174 ////////////////////////////////////////////////////////////////////////////// 125 // /////////////////// Coprocessors system calls ////////////////////////////175 // Coprocessors related system calls 126 176 ////////////////////////////////////////////////////////////////////////////// 127 177 … … 134 184 (unsigned int)coproc_info, 135 185 0, 0 ) ) 136 giet_ exit("error in giet_coproc_alloc()");186 giet_pthread_exit("error in giet_coproc_alloc()"); 137 187 } 138 188 … … 143 193 coproc_reg_index, 144 194 0, 0, 0 ) ) 145 giet_ exit("error in giet_coproc_release()");195 giet_pthread_exit("error in giet_coproc_release()"); 146 196 } 147 197 … … 154 204 (unsigned int)desc, 155 205 0, 0 ) ) 156 giet_ exit("error in giet_coproc_channel_init()");206 giet_pthread_exit("error in giet_coproc_channel_init()"); 157 207 } 158 208 … … 163 213 coproc_reg_index, 164 214 0, 0, 0 ) ) 165 giet_ exit("error in giet_coproc_run()");215 giet_pthread_exit("error in giet_coproc_run()"); 166 216 } 167 217 … … 171 221 if ( sys_call( SYSCALL_COPROC_COMPLETED, 172 222 0, 0, 0, 0 ) ) 173 giet_ exit("error in giet_coproc_completed");223 giet_pthread_exit("error in giet_coproc_completed"); 174 224 } 175 225 176 226 177 227 ////////////////////////////////////////////////////////////////////////////// 178 // /////////////////// TTY device related system calls ///////////////////////228 // TTY device related system calls 179 229 ////////////////////////////////////////////////////////////////////////////// 180 230 … … 184 234 if ( sys_call( SYSCALL_TTY_ALLOC, 185 235 shared, 186 0, 0, 0 ) ) giet_ exit("error in giet_tty_alloc()");236 0, 0, 0 ) ) giet_pthread_exit("error in giet_tty_alloc()"); 187 237 } 188 238 … … 516 566 if (ret) 517 567 { 518 giet_ exit("ERRORin giet_tty_printf()");568 giet_pthread_exit("error in giet_tty_printf()"); 519 569 } 520 570 } // end giet_tty_printf() … … 532 582 0xFFFFFFFF, // channel index from task context 533 583 0); 534 if ( ret < 0 ) giet_ exit("error in giet_tty_getc()");584 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getc()"); 535 585 } 536 586 while (ret != 1); … … 556 606 0xFFFFFFFF, // channel index from task context 557 607 0); 558 if ( ret < 0 ) giet_ exit("error in giet_tty_gets()");608 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_gets()"); 559 609 } 560 610 while (ret != 1); … … 578 628 0XFFFFFFFF, // channel index from task context 579 629 0 ); 580 if ( ret < 0 ) giet_ exit("error in giet_tty_gets()");630 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_gets()"); 581 631 } 582 632 } … … 595 645 0XFFFFFFFF, // channel index from task context 596 646 0 ); 597 if ( ret < 0 ) giet_ exit("error in giet_tty_gets()");647 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_gets()"); 598 648 599 649 } … … 628 678 0xFFFFFFFF, // channel index from task context 629 679 0); 630 if ( ret < 0 ) giet_ exit("error in giet_tty_getw()");680 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getw()"); 631 681 } 632 682 while (ret != 1); … … 644 694 0xFFFFFFFF, // channel index from task context 645 695 0 ); 646 if ( ret < 0 ) giet_ exit("error in giet_tty_getw()");696 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getw()"); 647 697 } 648 698 else if (string_byte == 0x0A) // LF character … … 662 712 0xFFFFFFFF, // channel index from task context 663 713 0 ); 664 if ( ret < 0 ) giet_ exit("error in giet_tty_getw()");714 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getw()"); 665 715 } 666 716 } … … 701 751 0xFFFFFFFF, // channel index from task context 702 752 0 ); 703 if ( ret < 0 ) giet_ exit("error in giet_tty_getw()");753 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getw()"); 704 754 } 705 755 // echo character '0' … … 710 760 0xFFFFFFFF, // channel index from task context 711 761 0 ); 712 if ( ret < 0 ) giet_ exit("error in giet_tty_getw()");762 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getw()"); 713 763 714 764 // return 0 value … … 719 769 720 770 ////////////////////////////////////////////////////////////////////////////////// 721 // /////////////////// TIMER related system calls ////////////////////////////////771 // TIMER related system calls 722 772 ////////////////////////////////////////////////////////////////////////////////// 723 773 … … 726 776 { 727 777 if ( sys_call( SYSCALL_TIM_ALLOC, 728 0, 0, 0, 0 ) ) giet_ exit("error in giet_timer_alloc()");778 0, 0, 0, 0 ) ) giet_pthread_exit("error in giet_timer_alloc()"); 729 779 } 730 780 … … 734 784 if ( sys_call( SYSCALL_TIM_START, 735 785 period, 736 0, 0, 0 ) ) giet_ exit("error in giet_timer_start()");786 0, 0, 0 ) ) giet_pthread_exit("error in giet_timer_start()"); 737 787 } 738 788 … … 741 791 { 742 792 if ( sys_call( SYSCALL_TIM_STOP, 743 0, 0, 0, 0 ) ) giet_ exit("error in giet_timer_stop()");793 0, 0, 0, 0 ) ) giet_pthread_exit("error in giet_timer_stop()"); 744 794 } 745 795 746 796 747 797 ////////////////////////////////////////////////////////////////////////////////// 748 // ///////////// Frame buffer device related system calls ///////////////////////798 // Frame buffer related system calls 749 799 ////////////////////////////////////////////////////////////////////////////////// 750 800 … … 753 803 { 754 804 if ( sys_call( SYSCALL_FBF_CMA_ALLOC, 755 0, 0, 0, 0 ) ) giet_ exit("error in giet_fbf_cma_alloc()");805 0, 0, 0, 0 ) ) giet_pthread_exit("error in giet_fbf_cma_alloc()"); 756 806 } 757 807 … … 766 816 (unsigned int)buf1_vbase, 767 817 (unsigned int)sts0_vaddr, 768 (unsigned int)sts1_vaddr ) ) giet_ exit("error in giet_fbf_cma_init_buf()");818 (unsigned int)sts1_vaddr ) ) giet_pthread_exit("error in giet_fbf_cma_init_buf()"); 769 819 } 770 820 … … 774 824 if ( sys_call( SYSCALL_FBF_CMA_START, 775 825 length, 776 0, 0, 0 ) ) giet_ exit("error in giet_fbf_cma_start()");826 0, 0, 0 ) ) giet_pthread_exit("error in giet_fbf_cma_start()"); 777 827 } 778 828 … … 782 832 if ( sys_call( SYSCALL_FBF_CMA_DISPLAY, 783 833 buffer, 784 0, 0, 0 ) ) giet_ exit("error in giet_fbf_cma_display()");834 0, 0, 0 ) ) giet_pthread_exit("error in giet_fbf_cma_display()"); 785 835 } 786 836 … … 789 839 { 790 840 if ( sys_call( SYSCALL_FBF_CMA_STOP, 791 0, 0, 0, 0 ) ) giet_ exit("error in giet_fbf_cma_stop()");841 0, 0, 0, 0 ) ) giet_pthread_exit("error in giet_fbf_cma_stop()"); 792 842 } 793 843 … … 801 851 (unsigned int)buffer, 802 852 length, 803 0 ) ) giet_ exit("error in giet_fbf_sync_write()");853 0 ) ) giet_pthread_exit("error in giet_fbf_sync_write()"); 804 854 } 805 855 … … 813 863 (unsigned int)buffer, 814 864 length, 815 0 ) ) giet_ exit("error in giet_fbf_sync_read()");865 0 ) ) giet_pthread_exit("error in giet_fbf_sync_read()"); 816 866 } 817 867 818 868 819 869 ////////////////////////////////////////////////////////////////////////////////// 820 // ///////////////////// NIC related system calls /////////////////////////////////870 // NIC related system calls 821 871 ////////////////////////////////////////////////////////////////////////////////// 822 872 823 //////////////////////////////////////////////////// 824 unsigned int giet_nic_rx_alloc( unsigned int xmax, 825 unsigned int ymax ) 826 { 827 int channel = sys_call( SYSCALL_NIC_ALLOC, 828 1, 829 xmax, 830 ymax, 831 0 ); 832 if ( channel < 0 ) giet_exit("error in giet_nic_rx_alloc()"); 833 834 return (unsigned int)channel; 835 } 836 837 //////////////////////////////////////////////////// 838 unsigned int giet_nic_tx_alloc( unsigned int xmax, 839 unsigned int ymax ) 840 { 841 int channel = sys_call( SYSCALL_NIC_ALLOC, 842 0, 843 xmax, 844 ymax, 845 0 ); 846 if ( channel < 0 ) giet_exit("error in giet_nic_tx_alloc()"); 847 848 return (unsigned int)channel; 849 } 850 851 ////////////////////////////////////////////// 852 void giet_nic_rx_start( unsigned int channel ) 873 ////////////////////////////////////////// 874 void giet_nic_rx_alloc( unsigned int xmax, 875 unsigned int ymax ) 876 { 877 if ( sys_call( SYSCALL_NIC_ALLOC, 878 1, // RX 879 xmax, 880 ymax, 881 0 ) ) giet_pthread_exit("error in giet_nic_rx_alloc()"); 882 } 883 884 ////////////////////////////////////////// 885 void giet_nic_tx_alloc( unsigned int xmax, 886 unsigned int ymax ) 887 { 888 if ( sys_call( SYSCALL_NIC_ALLOC, 889 0, // TX 890 xmax, 891 ymax, 892 0 ) ) giet_pthread_exit("error in giet_nic_tx_alloc()"); 893 } 894 895 //////////////////////// 896 void giet_nic_rx_start() 853 897 { 854 898 if ( sys_call( SYSCALL_NIC_START, 855 1, 856 channel, 857 0, 0 ) ) giet_exit("error in giet_nic_rx_start()"); 858 } 859 860 ////////////////////////////////////////////// 861 void giet_nic_tx_start( unsigned int channel ) 899 1, // RX 900 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_rx_start()"); 901 } 902 903 //////////////////////// 904 void giet_nic_tx_start() 862 905 { 863 906 if ( sys_call( SYSCALL_NIC_START, 864 0, 865 channel, 866 0, 0 ) ) giet_exit("error in giet_nic_tx_start()"); 867 } 868 869 /////////////////////////////////////////////////////////// 870 void giet_nic_rx_move( unsigned int channel, void* buffer ) 907 0, // TX 908 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_tx_start()"); 909 } 910 911 ///////////////////////////////////// 912 void giet_nic_rx_move( void* buffer ) 871 913 { 872 914 if ( sys_call( SYSCALL_NIC_MOVE, 873 1, 874 channel, 915 1, // RX 875 916 (unsigned int)buffer, 876 0 ) ) giet_exit("error in giet_nic_rx_move()");877 } 878 879 ///////////////////////////////////// //////////////////////880 void giet_nic_tx_move( unsigned int channel,void* buffer )917 0, 0 ) ) giet_pthread_exit("error in giet_nic_rx_move()"); 918 } 919 920 ///////////////////////////////////// 921 void giet_nic_tx_move( void* buffer ) 881 922 { 882 923 if ( sys_call( SYSCALL_NIC_MOVE, 883 0, 884 channel, 924 0, // TX 885 925 (unsigned int)buffer, 886 0 ) ) giet_exit("error in giet_nic_tx_move()");887 } 888 889 /////////////////////// //////////////////////890 void giet_nic_rx_stop( unsigned int channel)926 0, 0 ) ) giet_pthread_exit("error in giet_nic_tx_move()"); 927 } 928 929 /////////////////////// 930 void giet_nic_rx_stop() 891 931 { 892 932 if ( sys_call( SYSCALL_NIC_STOP, 893 1, 894 channel, 895 0, 0 ) ) giet_exit("error in giet_nic_rx_stop()"); 896 } 897 898 ///////////////////////////////////////////// 899 void giet_nic_tx_stop( unsigned int channel ) 933 1, // RX 934 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_rx_stop()"); 935 } 936 937 /////////////////////// 938 void giet_nic_tx_stop() 900 939 { 901 940 if ( sys_call( SYSCALL_NIC_STOP, 902 0, 903 channel, 904 0, 0 ) ) giet_exit("error in giet_nic_tx_stop()"); 905 } 906 907 ////////////////////////////////////////////// 908 void giet_nic_rx_stats( unsigned int channel ) 941 0, // TX 942 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_tx_stop()"); 943 } 944 945 //////////////////////// 946 void giet_nic_rx_stats() 909 947 { 910 948 if ( sys_call( SYSCALL_NIC_STATS, 911 1, 912 channel, 913 0, 0 ) ) giet_exit("error in giet_nic_rx_stats()"); 914 } 915 916 ////////////////////////////////////////////// 917 void giet_nic_tx_stats( unsigned int channel ) 949 1, // RX 950 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_rx_stats()"); 951 } 952 953 //////////////////////// 954 void giet_nic_tx_stats() 918 955 { 919 956 if ( sys_call( SYSCALL_NIC_STATS, 920 0, 921 channel, 922 0, 0 ) ) giet_exit("error in giet_nic_tx_stats()"); 923 } 924 925 ////////////////////////////////////////////// 926 void giet_nic_rx_clear( unsigned int channel ) 957 0, // TX 958 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_tx_stats()"); 959 } 960 961 //////////////////////// 962 void giet_nic_rx_clear() 927 963 { 928 964 if ( sys_call( SYSCALL_NIC_CLEAR, 929 1, 930 channel, 931 0, 0 ) ) giet_exit("error in giet_nic_rx_clear()"); 932 } 933 934 ////////////////////////////////////////////// 935 void giet_nic_tx_clear( unsigned int channel ) 965 1, // RX 966 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_rx_clear()"); 967 } 968 969 //////////////////////// 970 void giet_nic_tx_clear() 936 971 { 937 972 if ( sys_call( SYSCALL_NIC_CLEAR, 938 0, 939 channel, 940 0, 0 ) ) giet_exit("error in giet_nic_tx_clear()"); 973 0, // TX 974 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_tx_clear()"); 941 975 } 942 976 … … 944 978 945 979 /////////////////////////////////////////////////////////////////////////////////// 946 // /////////////////// FAT related system calls ////////////////////////////////////980 // FAT related system calls 947 981 /////////////////////////////////////////////////////////////////////////////////// 948 982 … … 984 1018 (unsigned int)buffer, 985 1019 count, 986 0 ); 1020 0 ); // no physical addressing required 987 1021 } 988 1022 … … 996 1030 (unsigned int)buffer, 997 1031 count, 998 0 ); 1032 0 ); // no physical addressing required 999 1033 } 1000 1034 … … 1068 1102 1069 1103 ////////////////////////////////////////////////////////////////////////////////// 1070 // /////////////////// Miscellaneous system calls /////////////////////////////////1104 // Miscellaneous system calls 1071 1105 ////////////////////////////////////////////////////////////////////////////////// 1072 1106 … … 1080 1114 (unsigned int)y_size, 1081 1115 (unsigned int)nprocs, 1082 0 ) ) giet_ exit("ERRORin giet_procs_number()");1116 0 ) ) giet_pthread_exit("error in giet_procs_number()"); 1083 1117 } 1084 1118 … … 1092 1126 (unsigned int) vobj_name, 1093 1127 (unsigned int) vbase, 1094 0 ) ) giet_ exit("ERRORin giet_vobj_get_vbase()");1128 0 ) ) giet_pthread_exit("error in giet_vobj_get_vbase()"); 1095 1129 } 1096 1130 … … 1104 1138 (unsigned int) vobj_name, 1105 1139 (unsigned int) length, 1106 0 ) ) giet_ exit("ERRORin giet_vobj_get_length()");1140 0 ) ) giet_pthread_exit("error in giet_vobj_get_length()"); 1107 1141 } 1108 1142 … … 1113 1147 unsigned int y ) 1114 1148 { 1115 if (sys_call( SYSCALL_HEAP_INFO,1116 1117 1118 1119 y ) ) giet_exit("ERROR in giet_heap_info()");1149 sys_call( SYSCALL_HEAP_INFO, 1150 (unsigned int)vaddr, 1151 (unsigned int)length, 1152 x, 1153 y ); 1120 1154 } 1121 1155 … … 1129 1163 (unsigned int)px, 1130 1164 (unsigned int)py, 1131 0 ) ) giet_ exit("ERRORin giet_get_xy()");1165 0 ) ) giet_pthread_exit("error in giet_get_xy()"); 1132 1166 } 1133 1167
Note: See TracChangeset
for help on using the changeset viewer.