Changeset 505 for soft/giet_vm
- Timestamp:
- Feb 10, 2015, 5:39:42 PM (10 years ago)
- Location:
- soft/giet_vm/giet_kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_kernel/sys_handler.c
r494 r505 198 198 // get a new TTY terminal index 199 199 unsigned int channel = _atomic_increment( &_tty_channel_allocator, 1 ); 200 unsigned int thread = _get_context_slot( CTX_TRDID_ID );201 unsigned int vspace = _get_context_slot( CTX_VSID_ID );202 200 203 201 if ( channel >= NB_TTY_CHANNELS ) … … 208 206 else 209 207 { 210 _printf("\n[GIET WARNING] TTY channel %d allocated "211 " to thread %d in vspace %d\n", channel, thread, vspace );212 208 _set_context_slot( CTX_TTY_ID, channel ); 213 209 return 0; … … 298 294 // get a new timer index 299 295 unsigned int channel = _atomic_increment( &_tim_channel_allocator, 1 ); 300 unsigned int thread = _get_context_slot( CTX_TRDID_ID );301 unsigned int vspace = _get_context_slot( CTX_VSID_ID );302 296 303 297 if ( channel >= NB_TIM_CHANNELS ) … … 308 302 else 309 303 { 310 _printf("\n[GIET WARNING] TIM channel %d allocated "311 " to thread %d in vspace %d\n", channel, thread, vspace );312 304 _set_context_slot( CTX_TIM_ID, channel ); 313 305 return 0; … … 577 569 // start CMA transfer 578 570 _cma_set_register( cma_channel, CHBUF_BUF_SIZE , NIC_CONTAINER_SIZE ); 579 _cma_set_register( cma_channel, CHBUF_PERIOD , 0 ); // OUT_OF_ORDER mode571 _cma_set_register( cma_channel, CHBUF_PERIOD , 0 ); // OUT_OF_ORDER 580 572 _cma_set_register( cma_channel, CHBUF_RUN , 1 ); 581 573 … … 589 581 590 582 return 0; 591 } // end sys_nic_start()583 } // end _sys_nic_start() 592 584 593 585 … … 790 782 791 783 // desactivates the CMA channel 792 _cma_ channel_stop( cma_channel);784 _cma_set_register( cma_channel, CHBUF_RUN , 0 ); 793 785 794 786 return 0; … … 938 930 // get a new CMA channel index 939 931 unsigned int channel = _atomic_increment( &_cma_channel_allocator, 1 ); 940 unsigned int thread = _get_context_slot( CTX_TRDID_ID );941 unsigned int vspace = _get_context_slot( CTX_VSID_ID );942 932 943 933 if ( channel >= NB_CMA_CHANNELS ) … … 948 938 else 949 939 { 950 _printf("\n[GIET WARNING] FBF_CMA channel %d allocated "951 " to thread %d in vspace %d\n", channel, thread, vspace );952 940 _set_context_slot( CTX_CMA_FB_ID, channel ); 953 941 return 0; … … 966 954 unsigned int flags; // protection flags 967 955 unsigned int ppn; // physical page number 968 unsigned long long chbuf_paddr; // physical address of source chbuf descriptor969 956 970 957 // get channel index … … 1039 1026 _fbf_chbuf[channel].length = length; 1040 1027 1041 // Compute and register physical adress of the chbuf descriptor1028 // Compute and register physical adress of the fbf_chbuf descriptor 1042 1029 vaddr = (unsigned int)(&_fbf_chbuf[channel]); 1043 1030 _v2p_translate( (page_table_t*) ptab, … … 1046 1033 &flags ); 1047 1034 1048 chbuf_paddr = (((paddr_t)ppn) << 12) | (vaddr & 0x00000FFF); 1049 1050 _fbf_chbuf_paddr[channel] = chbuf_paddr; 1051 1035 _fbf_chbuf_paddr[channel] = (((paddr_t)ppn) << 12) | (vaddr & 0x00000FFF); 1052 1036 1053 1037 if ( USE_IOB ) 1054 1038 { 1055 // SYNC request for channeldescriptor1056 _mmc_sync( chbuf_paddr, 32);1039 // SYNC request for fbf_chbuf descriptor 1040 _mmc_sync( _fbf_chbuf_paddr[channel] , sizeof( fbf_chbuf_t ) ); 1057 1041 } 1058 1042 … … 1065 1049 _fbf_chbuf[channel].buf0.desc, 1066 1050 _fbf_chbuf[channel].buf1.desc, 1067 chbuf_paddr ); 1068 #endif 1069 1070 // call CMA driver to start transfer 1071 _cma_channel_start( channel, 1072 chbuf_paddr, 1073 2, 1074 chbuf_paddr + 128, 1075 1, 1076 length ); 1051 _fbf_chbuf_paddr[channel] ); 1052 #endif 1053 1054 // start CMA transfer 1055 unsigned long long paddr = _fbf_chbuf_paddr[channel]; 1056 unsigned int src_chbuf_paddr_lsb = (unsigned int)(paddr & 0xFFFFFFFF); 1057 unsigned int src_chbuf_paddr_ext = (unsigned int)(paddr >> 32); 1058 unsigned int dst_chbuf_paddr_lsb = src_chbuf_paddr_lsb + 128; 1059 unsigned int dst_chbuf_paddr_ext = src_chbuf_paddr_ext; 1060 1061 _cma_set_register( channel, CHBUF_SRC_DESC , src_chbuf_paddr_lsb ); 1062 _cma_set_register( channel, CHBUF_SRC_EXT , src_chbuf_paddr_ext ); 1063 _cma_set_register( channel, CHBUF_SRC_NBUFS, 2 ); 1064 _cma_set_register( channel, CHBUF_DST_DESC , dst_chbuf_paddr_lsb ); 1065 _cma_set_register( channel, CHBUF_DST_EXT , dst_chbuf_paddr_ext ); 1066 _cma_set_register( channel, CHBUF_DST_NBUFS, 1 ); 1067 _cma_set_register( channel, CHBUF_BUF_SIZE , length ); 1068 _cma_set_register( channel, CHBUF_PERIOD , 300 ); 1069 _cma_set_register( channel, CHBUF_RUN , 1 ); 1070 1077 1071 return 0; 1078 1072 … … 1090 1084 #if NB_CMA_CHANNELS > 0 1091 1085 1092 volatile unsigned int long long user_buffer_desc; 1093 volatile unsigned int full = 1; 1086 volatile unsigned int full = 1; 1094 1087 1095 1088 // get channel index … … 1098 1091 if ( channel >= NB_CMA_CHANNELS ) 1099 1092 { 1100 _printf("\n[GIET ERROR] in _sys_fbf_cma_display() : CMA channel index too large\n"); 1101 return -1; 1102 } 1093 _printf("\n[GIET ERROR] in _sys_fbf_cma_display() : " 1094 "CMA channel index too large\n"); 1095 return -1; 1096 } 1097 1098 // get fbf_chbuf descriptor pointer 1099 fbf_chbuf_t* pdesc = &_fbf_chbuf[channel]; 1103 1100 1104 1101 #if GIET_DEBUG_FBF_CMA 1105 1102 _printf("\n[FBF_CMA DEBUG] enters _sys_fb_cma_display()\n" 1106 " - channel = %d\n" 1107 " - buffer = %d\n", 1108 channel, buffer_index ); 1103 " - cma channel = %d\n" 1104 " - buffer index = %d\n" 1105 " - buf0_desc value = %l\n" 1106 " - buf1_desc value = %l\n" 1107 " - fbf_desc value = %l\n", 1108 channel , buffer_index, 1109 _fbf_chbuf[channel].buf0.desc, 1110 _fbf_chbuf[channel].buf1.desc, 1111 _fbf_chbuf[channel].fbf.desc ); 1109 1112 #endif 1110 1113 1111 1114 if ( buffer_index == 0 ) // user buffer 0 1112 1115 { 1116 // INVAL L1 and L2 cache copies of user buffer descriptor, 1117 // because it has been modified in RAM by the CMA component 1118 _dcache_buf_invalidate( (unsigned int)pdesc , sizeof(buffer_descriptor_t) ); 1119 _mmc_inval( _fbf_chbuf_paddr[channel] , sizeof(buffer_descriptor_t) ); 1120 1113 1121 // waiting user buffer released by the CMA component) 1114 1122 while ( full ) 1115 1123 { 1116 // INVAL L1 and L2 cache copies of user buffer descriptor, because 1117 // it has been modified in RAM by the CMA component 1118 _dcache_buf_invalidate( (unsigned int)&_fbf_chbuf[channel].buf0.desc , 8 ); 1119 _mmc_inval( _fbf_chbuf_paddr[channel] , 8 ); 1120 1121 // get user buffer descriptor 1122 user_buffer_desc = _fbf_chbuf[channel].buf0.desc; 1123 1124 // get user buffer descriptor status 1125 full = ( (unsigned int)(user_buffer_desc>>63) ); 1124 full = (unsigned int)(pdesc->buf0.desc >> 63); 1126 1125 } 1127 1126 1128 1127 // SYNC request for the user buffer, because 1129 1128 // it will be read from XRAM by the CMA component 1130 _mmc_sync( user_buffer_desc, _fbf_chbuf[channel].length );1131 1132 // set user buffer status , and SYNC request, because this buffer1133 // descriptor will be read from XRAM by the CMA component1134 _fbf_chbuf[channel].buf0.desc = user_buffer_desc | 0x8000000000000000ULL; 1135 _mmc_sync( _fbf_chbuf_paddr[channel] , 8 );1136 1137 // reset fbf buffer status, and SYNC request, because this buffer 1138 // descriptor will be read from XRAM by the CMA component1139 _fbf_chbuf[channel].fbf.desc = _fbf_chbuf[channel].fbf.desc & 0x7FFFFFFFFFFFFFFFULL;1140 _mmc_sync( _fbf_chbuf_paddr[channel] + 128 , 8);1129 _mmc_sync( pdesc->buf0.desc , pdesc->length ); 1130 1131 // set user buffer status 1132 pdesc->buf0.desc = pdesc->buf0.desc | 0x8000000000000000ULL; 1133 1134 // reset fbf buffer status 1135 pdesc->fbf.desc = pdesc->fbf.desc & 0x7FFFFFFFFFFFFFFFULL; 1136 1137 // SYNC request, because these buffer descriptors 1138 // will be read from XRAM by the CMA component 1139 _mmc_sync( _fbf_chbuf_paddr[channel] , sizeof(fbf_chbuf_t) ); 1141 1140 } 1142 1141 else // user buffer 1 1143 1142 { 1143 // INVAL L1 and L2 cache copies of user buffer descriptor, 1144 // because it has been modified in RAM by the CMA component 1145 _dcache_buf_invalidate( (unsigned int)pdesc + 64, sizeof(buffer_descriptor_t) ); 1146 _mmc_inval( _fbf_chbuf_paddr[channel] + 64, sizeof(buffer_descriptor_t) ); 1147 1144 1148 // waiting user buffer released by the CMA component) 1145 1149 while ( full ) 1146 1150 { 1147 // INVAL L1 and L2 cache copies of user buffer descriptor, because 1148 // it has been modified in RAM by the CMA component 1149 _dcache_buf_invalidate( (unsigned int)&_fbf_chbuf[channel].buf1.desc , 8 ); 1150 _mmc_inval( _fbf_chbuf_paddr[channel] + 64 , 8 ); 1151 1152 // get user buffer descriptor 1153 user_buffer_desc = _fbf_chbuf[channel].buf1.desc; 1154 1155 // get user buffer descriptor status 1156 full = ( (unsigned int)(user_buffer_desc>>63) ); 1151 full = (unsigned int)(pdesc->buf1.desc >> 63); 1157 1152 } 1158 1153 1159 1154 // SYNC request for the user buffer, because 1160 1155 // it will be read from XRAM by the CMA component 1161 _mmc_sync( user_buffer_desc, _fbf_chbuf[channel].length );1162 1163 // set user buffer status , and SYNC request, because this buffer1164 // descriptor will be read from XRAM by the CMA component1165 _fbf_chbuf[channel].buf1.desc = user_buffer_desc | 0x8000000000000000ULL; 1166 _mmc_sync( _fbf_chbuf_paddr[channel] , 8 );1167 1168 // reset fbf buffer status, and SYNC request, because this buffer 1169 // descriptor will be read from XRAM by the CMA component1170 _fbf_chbuf[channel].fbf.desc = _fbf_chbuf[channel].fbf.desc & 0x7FFFFFFFFFFFFFFFULL;1171 _mmc_sync( _fbf_chbuf_paddr[channel] + 128 , 8);1156 _mmc_sync( pdesc->buf1.desc , pdesc->length ); 1157 1158 // set user buffer status 1159 pdesc->buf1.desc = pdesc->buf1.desc | 0x8000000000000000ULL; 1160 1161 // reset fbf buffer status 1162 pdesc->fbf.desc = pdesc->fbf.desc & 0x7FFFFFFFFFFFFFFFULL; 1163 1164 // SYNC request, because these buffer descriptors 1165 // will be read from XRAM by the CMA component 1166 _mmc_sync( _fbf_chbuf_paddr[channel] , sizeof(fbf_chbuf_t) ); 1172 1167 } 1173 1168 1174 1169 #if GIET_DEBUG_FBF_CMA 1175 _printf(" - fbf desc = %l\n"1176 " - buf0 desc= %l\n"1177 " - buf1 desc = %l\n",1178 _fbf_chbuf[channel].fbf.desc,1170 _printf("\n[FBF_CMA DEBUG] exit _sys_fb_cma_display()\n" 1171 " - buf0_desc value = %l\n" 1172 " - buf1_desc value = %l\n" 1173 " - fbf_desc value = %l\n", 1179 1174 _fbf_chbuf[channel].buf0.desc, 1180 _fbf_chbuf[channel].buf1.desc ); 1175 _fbf_chbuf[channel].buf1.desc, 1176 _fbf_chbuf[channel].fbf.desc ); 1181 1177 #endif 1182 1178 … … 1207 1203 1208 1204 // Desactivate CMA channel 1209 _cma_ channel_stop( channel);1205 _cma_set_register( channel, CHBUF_RUN, 0 ); 1210 1206 1211 1207 return 0; -
soft/giet_vm/giet_kernel/sys_handler.h
r494 r505 16 16 #include "kernel_locks.h" 17 17 18 /////////////////////////////////////////////////////////////////////////////// ////18 /////////////////////////////////////////////////////////////////////////////// 19 19 // Syscall Vector Table (indexed by syscall index) 20 /////////////////////////////////////////////////////////////////////////////// ////20 /////////////////////////////////////////////////////////////////////////////// 21 21 22 22 extern const void * _syscall_vector[64]; 23 23 24 /////////////////////////////////////////////////////////////////////////////// ////24 /////////////////////////////////////////////////////////////////////////////// 25 25 // This structure is used by the nic_chbuf_t and fbf_chbuf_t structures. 26 // It describes a single buffer descriptor. The useful information is contained27 // in one single 64 bits word (desc field):26 // It describes a single buffer descriptor. The useful information is 27 // contained in one single 64 bits word (desc field): 28 28 // - the 48 LSB bits contain the buffer physical address 29 29 // - the MSB bit 63 indicates the buffer state (empty if 0) 30 30 // This descriptor must be aligned on a cache line (64 bytes) to simplify 31 31 // the software L2/L3 cache coherence when the IO bridge is used. 32 /////////////////////////////////////////////////////////////////////////////// ////32 /////////////////////////////////////////////////////////////////////////////// 33 33 34 34 typedef struct buffer_descriptor_s … … 38 38 } buffer_descriptor_t; 39 39 40 /////////////////////////////////////////////////////////////////////////////// ////40 /////////////////////////////////////////////////////////////////////////////// 41 41 // This structure is used by the CMA component to move a stream 42 42 // of images from two user buffers to the frame buffer in kernel space. … … 46 46 // - The length field define the buffer size (bytes) 47 47 // This structure must be 64 bytes aligned. 48 /////////////////////////////////////////////////////////////////////////////// ////48 /////////////////////////////////////////////////////////////////////////////// 49 49 50 50 typedef struct fbf_chbuf_s … … 57 57 } fbf_chbuf_t; 58 58 59 /////////////////////////////////////////////////////////////////////////////// ///59 /////////////////////////////////////////////////////////////////////////////// 60 60 // This structure is used by the CMA component to move a stream of containers 61 61 // between the NIC chbuf containing 2 buffers, and a kernel chbuf … … 65 65 // The actual number of buffers used in the chbuf is defined by (xmax * ymax). 66 66 // This structure must be 64 bytes aligned. 67 /////////////////////////////////////////////////////////////////////////////// ///67 /////////////////////////////////////////////////////////////////////////////// 68 68 69 69 typedef struct nic_chbuf_s … … 74 74 } nic_chbuf_t; 75 75 76 /////////////////////////////////////////////////////////////////////////////// ///76 /////////////////////////////////////////////////////////////////////////////// 77 77 // TTY related syscall handlers 78 /////////////////////////////////////////////////////////////////////////////// ///78 /////////////////////////////////////////////////////////////////////////////// 79 79 80 80 int _sys_tty_alloc();
Note: See TracChangeset
for help on using the changeset viewer.