Changeset 207 for soft/giet_vm/sys
- Timestamp:
- Aug 16, 2012, 6:36:16 PM (13 years ago)
- Location:
- soft/giet_vm/sys
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/sys/common.c
r199 r207 13 13 #include <ctx_handler.h> 14 14 #include <drivers.h> 15 #include <hwr_mapping.h> 15 16 #include <stdarg.h> 16 17 … … 153 154 //////////////////////////////////////////////////////////////////////////// 154 155 // _puts() 155 // display a string on TTY0 / used for system code debugand log 156 //////////////////////////////////////////////////////////////////////////// 157 void _puts(char *buffer) 158 { 159 unsigned int* tty_address = (unsigned int*)&seg_tty_base; 156 // display a string on TTY0 / used for system code debug and log 157 //////////////////////////////////////////////////////////////////////////// 158 void _puts(char* buffer) 159 { 160 unsigned int* tty_address = (unsigned int*)( (char*)&seg_tty_base + 161 (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) ); 160 162 unsigned int n; 161 163 … … 163 165 { 164 166 if (buffer[n] == 0) break; 165 tty_address[ 0] = (unsigned int)buffer[n];167 tty_address[TTY_WRITE] = (unsigned int)buffer[n]; 166 168 } 167 169 } 168 170 //////////////////////////////////////////////////////////////////////////// 169 // _put w()171 // _putx() 170 172 // display an int (hexa) on TTY0 / used for system code debug and log 171 173 //////////////////////////////////////////////////////////////////////////// 172 void _put w(unsigned int val)174 void _putx(unsigned int val) 173 175 { 174 176 static const char HexaTab[] = "0123456789ABCDEF"; -
soft/giet_vm/sys/common.h
r203 r207 33 33 34 34 void _puts(char *string); 35 void _put w(unsigned int val);35 void _putx(unsigned int val); 36 36 void _putd(unsigned int val); 37 37 -
soft/giet_vm/sys/drivers.c
r205 r207 231 231 _get_lock(&_tty_put_lock); 232 232 _puts("\n[GIET ERROR] TTY index too large for task "); 233 _put w( task_id );233 _putd( task_id ); 234 234 _puts(" on processor "); 235 _put w( proc_id );235 _putd( proc_id ); 236 236 _puts("\n"); 237 237 _release_lock(&_tty_put_lock); … … 316 316 //////////////////////////////////////////////////////////////////////////////// 317 317 unsigned int _tty_get_char( unsigned int tty_id, 318 char*buffer )318 unsigned char* buffer ) 319 319 { 320 320 // checking argument … … 731 731 ////////////////////////////////////////////////////////////////////////////////// 732 732 unsigned int _dma_reset_irq( unsigned int cluster_id, 733 unsigned int local_id )733 unsigned int channel_id ) 734 734 { 735 735 // parameters checking 736 736 if ( cluster_id >= NB_CLUSTERS ) return 1; 737 if ( local_id >= NB_DMAS_MAX )return 1;737 if ( channel_id >= NB_DMAS_MAX ) return 1; 738 738 739 739 // compute DMA base address … … 741 741 (cluster_id * (unsigned)CLUSTER_SIZE) ); 742 742 743 dma_address[ local_id*DMA_SPAN + DMA_RESET] = 0;743 dma_address[channel_id*DMA_SPAN + DMA_RESET] = 0; 744 744 return 0; 745 745 } … … 748 748 ////////////////////////////////////////////////////////////////////////////////// 749 749 unsigned int _dma_get_status( unsigned int cluster_id, 750 unsigned int local_id,750 unsigned int channel_id, 751 751 unsigned int* status ) 752 752 { 753 753 // parameters checking 754 754 if ( cluster_id >= NB_CLUSTERS ) return 1; 755 if ( local_id >= NB_DMAS_MAX )return 1;755 if ( channel_id >= NB_DMAS_MAX ) return 1; 756 756 757 757 // compute DMA base address 758 758 unsigned int* dma_address = (unsigned int*)( (char*)&seg_dma_base + 759 759 (cluster_id * (unsigned)CLUSTER_SIZE) ); 760 761 *status = dma_address[ local_id*DMA_SPAN + DMA_LEN];760 761 *status = dma_address[channel_id*DMA_SPAN + DMA_LEN]; 762 762 return 0; 763 763 } … … 839 839 // - user_vaddr : virtual base address of the memory buffer. 840 840 // - length : number of bytes to be transfered. 841 // The memorybuffer must be mapped in user address space and word-aligned.841 // The user buffer must be mapped in user address space and word-aligned. 842 842 // The user buffer length must be multiple of 4 bytes. 843 843 // Me must compute the physical base addresses for both the frame buffer 844 844 // and the user buffer before programming the DMA transfer. 845 // The GIET being fully static, we don't need to split the transfer in 4 Kbytes845 // The GIET being fully static, we don't need to split the transfer in 4 Kbytes 846 846 // pages, because the user buffer is contiguous in physical space. 847 847 // Returns 0 if success, > 0 if error. … … 871 871 { 872 872 _get_lock(&_tty_put_lock); 873 _puts(" [GIET ERROR] in _fbdma_access() : user buffer not word aligned\n");873 _puts("\n[GIET ERROR] in _fbdma_access() : user buffer not word aligned\n"); 874 874 _release_lock(&_tty_put_lock); 875 875 return 1; … … 880 880 881 881 // compute frame buffer pbase address 882 unsigned int fb_vaddr = (unsigned int)&seg_fbf_base + offset; 882 unsigned int fb_vaddr = (unsigned int)&seg_fbf_base + 883 (CLUSTER_IO_ID * (unsigned int)CLUSTER_SIZE) + offset; 883 884 884 885 ko = _v2p_translate( (page_table_t*)user_ptab, … … 891 892 { 892 893 _get_lock(&_tty_put_lock); 893 _puts(" [GIET ERROR] in _fbdma_access() : frame buffer unmapped\n");894 _puts("\n[GIET ERROR] in _fbdma_access() : frame buffer unmapped\n"); 894 895 _release_lock(&_tty_put_lock); 895 896 return 2; … … 906 907 { 907 908 _get_lock(&_tty_put_lock); 908 _puts(" [GIET ERROR] in _fbdma_access() : user buffer unmapped\n");909 _puts("\n[GIET ERROR] in _fbdma_access() : user buffer unmapped\n"); 909 910 _release_lock(&_tty_put_lock); 910 911 return 3; … … 920 921 { 921 922 _get_lock(&_tty_put_lock); 922 _puts(" [GIET ERROR] in _fbdma_access() : user buffer not writable\n");923 _puts("\n[GIET ERROR] in _fbdma_access() : user buffer not writable\n"); 923 924 _release_lock(&_tty_put_lock); 924 925 return 5; -
soft/giet_vm/sys/drivers.h
r204 r207 41 41 42 42 unsigned int _tty_get_char( unsigned int tty_id, 43 char*buffer);43 unsigned char* buffer); 44 44 45 45 /////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/sys/exc_handler.c
r199 r207 77 77 _puts( (char*)exc_type[type] ); 78 78 _puts("\n - EPC : "); 79 _put w( _get_epc() );79 _putx( _get_epc() ); 80 80 _puts("\n - BVAR : "); 81 _put w( _get_bvar() );81 _putx( _get_bvar() ); 82 82 _puts("\n"); 83 83 -
soft/giet_vm/sys/irq_handler.c
r204 r207 82 82 // This ISR handles all IRQs generated by the multi-channels DMA controlers. 83 83 // The multi_dma components can be distributed in the clusters. 84 // The channel_id argument is the global DMA channel index.85 // channel_id = cluster_id*NB_DMAS_MAX + loc_id86 // - The ISR saves the transfert status in _dma_status[ channel_id].84 // The channel_id argument is the local DMA channel index. 85 // dma_global_id = cluster_id*NB_DMAS_MAX + channel_id 86 // - The ISR saves the transfert status in _dma_status[dma_global_id]. 87 87 // - It acknowledges the interrupt to reinitialize the DMA controler. 88 // - it resets the synchronisation variable _dma_busy[ channel_id].88 // - it resets the synchronisation variable _dma_busy[dma_global_id]. 89 89 /////////////////////////////////////////////////////////////////////////////////// 90 90 void _isr_dma( unsigned int channel_id ) 91 91 { 92 // compute cluster_id and loc_id 93 unsigned int cluster_id = channel_id / NB_DMAS_MAX; 94 unsigned int local_id = channel_id % NB_DMAS_MAX; 92 // compute cluster_id 93 unsigned int cluster_id = _procid()/NB_PROCS_MAX; 94 95 // compute dma_global_id 96 unsigned int dma_global_id = cluster_id*NB_DMAS_MAX + channel_id; 95 97 96 98 // save DMA channel status 97 if ( _dma_get_status(cluster_id, local_id, &_dma_status[channel_id]) ) 99 if ( _dma_get_status(cluster_id, 100 channel_id, 101 (unsigned int*)&_dma_status[dma_global_id] ) ) 98 102 { 99 103 _get_lock(&_tty_put_lock); … … 104 108 105 109 // reset DMA channel irq 106 if ( _dma_reset_irq(cluster_id, local_id) ) 110 if ( _dma_reset_irq( cluster_id, 111 channel_id) ) 107 112 { 108 113 _get_lock(&_tty_put_lock); … … 113 118 114 119 // release DMA channel 115 _dma_done[ channel_id] = 1;120 _dma_done[dma_global_id] = 1; 116 121 } 117 122 … … 125 130 { 126 131 // save status & reset IRQ 127 if ( _ioc_get_status( &_ioc_status ) )132 if ( _ioc_get_status( (unsigned int*)&_ioc_status ) ) 128 133 { 129 134 _get_lock(&_tty_put_lock); … … 143 148 // These timers are distributed in all clusters, and can be implemented 144 149 // in a vci_multi_timer component, or in a vci_xicu component. 145 // The timer_id argument is a global index: 146 // timer_id = cluster_id*(NB_TIMERS_MAX+NB_PROCS_MAX) + local_id 147 // The user timer local index is (loc_id - NB_PROCS_MAX). 148 // 150 // The timer_id argument is the user timer local index. 151 // timer_globa_id = cluster_id*(NB_TIMERS_MAX) + timer_id 149 152 // The ISR acknowledges the IRQ and registers the event in the proper entry 150 153 // of the _timer_event[] array, and a log message is displayed on kernel terminal. … … 152 155 void _isr_timer(unsigned int timer_id) 153 156 { 154 155 unsigned int cluster_id = timer_id / (NB_TIMERS_MAX + NB_PROCS_MAX); 156 unsigned int local_id = timer_id % (NB_TIMERS_MAX + NB_PROCS_MAX); 157 158 // checking timer type 159 if (local_id < NB_PROCS_MAX ) 160 { 161 _get_lock(&_tty_put_lock); 162 _puts("[GIET ERROR] Strange... User timer ISR for a system timer\n"); 163 _release_lock(&_tty_put_lock); 164 return; 165 } 157 // compute cluster_id 158 unsigned int cluster_id = _procid()/NB_PROCS_MAX; 166 159 167 160 // aknowledge IRQ 168 if ( _timer_reset_irq( cluster_id, local_id ) ) 161 if ( _timer_reset_irq( cluster_id, 162 NB_PROCS_MAX + timer_id ) ) 169 163 { 170 164 _get_lock(&_tty_put_lock); … … 176 170 #if NB_TIMERS_MAX 177 171 // register the event 178 _timer_event[(cluster_id*NB_TIMERS_MAX) + (loc_id - NB_PROCS_MAX)] = 1; 172 unsigned int timer_global_id = cluster_id*NB_TIMERS_MAX + timer_id; 173 _user_timer_event[timer_global_id] = 1; 179 174 #endif 180 175 181 176 // display a message on TTY 0 182 177 _get_lock(&_tty_put_lock); 183 _puts(" [GIET] User Timer IRQ at cycle ");178 _puts("\n[GIET] User Timer IRQ at cycle "); 184 179 _putd( _proctime() ); 185 _puts(" / index = "); 186 _putd(timer_id); 180 _puts("\n - cluster_id = "); 181 _putd( cluster_id ); 182 _puts("\n - timer_id = "); 183 _putd( timer_id ); 187 184 _puts("\n"); 188 185 _release_lock(&_tty_put_lock); … … 194 191 // signaling that a character is available. 195 192 // There is one single multi_tty component controling all TTYs, 196 // and the tty_id //argument is the global TTY index.193 // and the tty_id argument is the global TTY index. 197 194 // There is one communication buffer _tty_buf[tty_id] per terminal. 198 195 // The sychronisation variable _tty_full[tty_id], is set by the ISR, … … 203 200 { 204 201 // save character and reset IRQ 205 if ( _tty_get_char( tty_id, &_tty_get_buf[tty_id] ) ) 202 if ( _tty_get_char( tty_id, 203 (unsigned char*)&_tty_get_buf[tty_id] ) ) 206 204 { 207 205 _get_lock(&_tty_put_lock); -
soft/giet_vm/sys/kernel_init.c
r203 r207 54 54 { 55 55 // compute cluster and local processor index 56 unsigned int proc_id = _procid(); 57 unsigned int cluster_id = proc_id / NB_PROCS_MAX; 58 unsigned int lpid = proc_id % NB_PROCS_MAX; 56 unsigned int global_pid = _procid(); 57 unsigned int cluster_id = global_pid / NB_PROCS_MAX; 58 unsigned int proc_id = global_pid % NB_PROCS_MAX; 59 60 // Step 0 : Compute number of tasks allocated to proc 61 62 unsigned int tasks = _get_tasks_number(); 63 64 #if GIET_DEBUG_INIT 65 _get_lock(&_tty_put_lock); 66 _puts("\n[GIET DEBUG] step 0 for processor "); 67 _putd( global_pid ); 68 _puts(" : tasks = "); 69 _putd( tasks ); 70 _puts("\n"); 71 _release_lock(&_tty_put_lock); 72 #endif 59 73 60 74 // step 1 : Initialise scheduler physical addresses array 61 62 // get scheduler physical address from register 75 // get scheduler physical address (from CP0 register) 76 63 77 static_scheduler_t* psched = (static_scheduler_t*)_get_sched(); 64 _schedulers_paddr[ proc_id]= psched;78 _schedulers_paddr[global_pid] = psched; 65 79 66 80 #if GIET_DEBUG_INIT 67 81 _get_lock(&_tty_put_lock); 68 82 _puts("\n[GIET DEBUG] step 1 for processor "); 69 _putd( proc_id );83 _putd( global_pid ); 70 84 _puts(" / scheduler pbase = "); 71 _putw( (unsigned int)psched ); 72 _puts("\n"); 73 _release_lock(&_tty_put_lock); 74 #endif 75 85 _putx( (unsigned int)psched ); 86 _puts("\n"); 87 _release_lock(&_tty_put_lock); 88 #endif 76 89 77 90 // step 2 : initialise page table addresse arrays … … 80 93 81 94 unsigned int ltid; 82 unsigned int tasks = _get_tasks_number();83 95 84 96 for ( ltid = 0 ; ltid < tasks ; ltid++ ) … … 94 106 _get_lock(&_tty_put_lock); 95 107 _puts("\n[GIET DEBUG] step 2 for processor "); 96 _putd( proc_id );108 _putd( global_pid ); 97 109 _puts(" / vspace "); 98 110 _putd( vspace_id ); 99 111 _puts("\n- ptab vbase = "); 100 _put w( ptab_vaddr );112 _putx( ptab_vaddr ); 101 113 _puts("\n- ptab pbase = "); 102 _put w( ptab_paddr );114 _putx( ptab_paddr ); 103 115 _puts("\n"); 104 116 _release_lock(&_tty_put_lock); … … 129 141 } 130 142 } 131 _icu_set_mask( cluster_id, lpid, hwi_mask, 0 ); // set HWI_MASK132 _icu_set_mask( cluster_id, lpid, pti_mask, 1 ); // set PTI_MASK143 _icu_set_mask( cluster_id, proc_id, hwi_mask, 0 ); // set HWI_MASK 144 _icu_set_mask( cluster_id, proc_id, pti_mask, 1 ); // set PTI_MASK 133 145 134 146 #if GIET_DEBUG_INIT 135 147 _get_lock(&_tty_put_lock); 136 148 _puts("\n[GIET DEBUG] step 3 for processor "); 137 _putd( proc_id );149 _putd( global_pid ); 138 150 _puts("\n - ICU HWI_MASK = "); 139 _put w( hwi_mask );151 _putx( hwi_mask ); 140 152 _puts("\n - ICU PTI_MASK = "); 141 _putw( pti_mask ); 142 _puts("\n"); 143 _release_lock(&_tty_put_lock); 144 #endif 145 153 _putx( pti_mask ); 154 _puts("\n"); 155 _release_lock(&_tty_put_lock); 156 #endif 146 157 147 158 // step 4 : start TICK timer if more than one task … … 155 166 _get_lock(&_tty_put_lock); 156 167 _puts("\n[GIET DEBUG] Step 4 for processor "); 157 _putd( proc_id );168 _putd( global_pid ); 158 169 _puts(" / context switch activated\n"); 159 170 _release_lock(&_tty_put_lock); … … 169 180 _set_context_slot( IDLE_TASK_INDEX, CTX_RUN_ID, 1 ); 170 181 _set_context_slot( IDLE_TASK_INDEX, CTX_SR_ID, 0xFF03 ); 171 _set_context_slot( IDLE_TASK_INDEX, CTX_SP_ID, (unsigned int)&_idle_stack[ proc_id] + 64 );182 _set_context_slot( IDLE_TASK_INDEX, CTX_SP_ID, (unsigned int)&_idle_stack[global_pid] + 64 ); 172 183 _set_context_slot( IDLE_TASK_INDEX, CTX_RA_ID, (unsigned int)&_ctx_eret ); 173 184 _set_context_slot( IDLE_TASK_INDEX, CTX_EPC_ID, (unsigned int)&_ctx_idle ); … … 178 189 _get_lock(&_tty_put_lock); 179 190 _puts("\n[GIET DEBUG] Step 5 for processor "); 180 _putd( proc_id );191 _putd( global_pid ); 181 192 _puts(" / idle task context set\n"); 182 193 _release_lock(&_tty_put_lock); … … 195 206 _get_lock( &_tty_put_lock ); 196 207 _puts("\n [GIET WARNING] No task allocated to processor "); 197 _put w( proc_id );208 _putd( global_pid ); 198 209 _puts(" => idle\n"); 199 210 _release_lock ( &_tty_put_lock ); … … 212 223 _get_lock(&_tty_put_lock); 213 224 _puts("\n[GIET DEBUG] step 6 for processor "); 214 _putd( proc_id );225 _putd( global_pid ); 215 226 _puts(" / registers initialised \n"); 216 227 _puts("- sp = "); 217 _put w( sp_value );228 _putx( sp_value ); 218 229 _puts("\n"); 219 230 _puts("- sr = "); 220 _put w( sr_value );231 _putx( sr_value ); 221 232 _puts("\n"); 222 233 _puts("- ptpr = "); 223 _put w( ptpr_value<<13 );234 _putx( ptpr_value<<13 ); 224 235 _puts("\n"); 225 236 _puts("- epc = "); 226 _put w( epc_value );237 _putx( epc_value ); 227 238 _puts("\n"); 228 239 _release_lock(&_tty_put_lock); -
soft/giet_vm/sys/sys_handler.c
r204 r207 66 66 _puts("\n\n!!! Undefined System Call !!!\n"); 67 67 _puts("\nEPC = "); 68 _put w( epc );68 _putx( epc ); 69 69 _exit(); 70 70 } -
soft/giet_vm/sys/vm_handler.c
r189 r207 45 45 _puts("\n[GIET ERROR] in iommu_add_pte2 function\n"); 46 46 _puts("the IOMMU PT1 entry is not mapped / ix1 = "); 47 _put w( ix1 );47 _putx( ix1 ); 48 48 _puts("\n"); 49 49 _exit(); … … 76 76 _puts("\n[GIET ERROR] in iommu_inval_pte2 function\n"); 77 77 _puts("the IOMMU PT1 entry is not mapped / ix1 = "); 78 _put w( ix1 );78 _putx( ix1 ); 79 79 _puts("\n"); 80 80 _exit(); … … 105 105 unsigned int ix1 = vpn >> 9; 106 106 unsigned int ix2 = vpn & 0x1FF; 107 107 /* 108 _puts("\n\n********************** entering v2p_translate"); 109 _puts("\n - pt = "); 110 _putx( (unsigned int)pt ); 111 _puts("\n - vpn = "); 112 _putx( vpn << 12 ); 113 _puts("\n - ptba = "); 114 _putx( pt->pt1[ix1] << 12 ) ; 115 _puts("\n - &pte2 = "); 116 _putx( (pt->pt1[ix1] << 12) + 8*ix2 ); 117 _puts("\n - flags = "); 118 _putx( *(unsigned int*)((pt->pt1[ix1] << 12) + 8*ix2) ); 119 _puts("\n"); 120 */ 108 121 // check PTE1 mapping 109 122 if ( (pt->pt1[ix1] & PTE_V) == 0 )
Note: See TracChangeset
for help on using the changeset viewer.