Changeset 263 for soft/giet_vm/giet_drivers/dma_driver.c
- Timestamp:
- Dec 19, 2013, 9:36:48 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/dma_driver.c
r258 r263 12 12 // 13 13 // There is (NB_CLUSTERS * NB_DMA_CHANNELS) channels, indexed by a global index: 14 // dma_id = cluster_ id* NB_DMA_CHANNELS + loc_id14 // dma_id = cluster_xy * NB_DMA_CHANNELS + loc_id 15 15 // 16 16 // A DMA channel is a private ressource allocated to a given processor. … … 22 22 // The virtual base address of the segment associated to a channel is: 23 23 // 24 // seg_dma_base + cluster_ id* vseg_cluster_increment + DMA_SPAN * channel_id24 // seg_dma_base + cluster_xy * vseg_cluster_increment + DMA_SPAN * channel_id 25 25 // 26 26 //////////////////////////////////////////////////////////////////////////////////// … … 32 32 #include <vmem.h> 33 33 34 #if !defined( NB_CLUSTERS)35 # error: You must define NB_CLUSTERSin the hard_config.h file36 #endif 37 38 #if (NB_CLUSTERS > 256)39 # error: NB_CLUSTERS cannot be larger than 256!40 #endif 41 42 #if !defined( NB_PROCS_MAX)43 # error: You must define NB_PROCS_MAXin the hard_config.h file44 #endif 45 46 #if (NB_PROCS_MAX > 8)47 # error: NB_PROCS_MAX cannot be larger than 8!48 #endif 49 50 #if (NB_DMA_CHANNELS > 8)51 # error: NB_DMA_CHANNELS cannot be larger than 8!34 #if !defined(X_SIZE) 35 # error: You must define X_SIZE in the hard_config.h file 36 #endif 37 38 #if !defined(Y_SIZE) 39 # error: You must define X_SIZE in the hard_config.h file 40 #endif 41 42 #if !defined(X_WIDTH) 43 # error: You must define X_WIDTH in the hard_config.h file 44 #endif 45 46 #if !defined(Y_WIDTH) 47 # error: You must define X_WIDTH in the hard_config.h file 48 #endif 49 50 #if !defined(NB_DMA_CHANNELS) 51 # error: You must define NB_DMA_CHANNELS in the hard_config.h file 52 52 #endif 53 53 … … 60 60 // Returns 0 if success, returns > 0 if error. 61 61 ////////////////////////////////////////////////////////////////////////////////// 62 unsigned int _dma_init( unsigned int cluster_ id,62 unsigned int _dma_init( unsigned int cluster_xy, 63 63 unsigned int channel_id ) 64 64 { 65 65 #if NB_DMA_CHANNELS > 0 66 66 67 // parameters checking 67 if (cluster_id >= NB_CLUSTERS) return 1; 68 unsigned int x = cluster_xy >> Y_WIDTH; 69 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 70 if (x >= X_SIZE) return 1; 71 if (y >= Y_SIZE) return 1; 68 72 if (channel_id >= NB_DMA_CHANNELS) return 1; 69 73 70 74 // compute DMA base address 71 75 unsigned int* dma_address = (unsigned int*) ((unsigned int)&seg_dma_base + 72 (cluster_ id* (unsigned int)&vseg_cluster_increment));76 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 73 77 74 78 // disable interrupt for selected channel … … 84 88 // completion. It actually forces the channel to return in iDLE state. 85 89 ////////////////////////////////////////////////////////////////////////////////// 86 unsigned int _dma_reset( unsigned int cluster_ id,90 unsigned int _dma_reset( unsigned int cluster_xy, 87 91 unsigned int channel_id ) 88 92 { 89 93 #if NB_DMA_CHANNELS > 0 94 90 95 // parameters checking 91 if (cluster_id >= NB_CLUSTERS) return 1; 96 unsigned int x = cluster_xy >> Y_WIDTH; 97 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 98 if (x >= X_SIZE) return 1; 99 if (y >= Y_SIZE) return 1; 92 100 if (channel_id >= NB_DMA_CHANNELS) return 1; 93 101 94 102 // compute DMA base address 95 103 unsigned int* dma_address = (unsigned int*) ((unsigned int)&seg_dma_base + 96 (cluster_ id* (unsigned int)&vseg_cluster_increment));104 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 97 105 98 106 // reset selected channel … … 107 115 // This function returns the status of a DMA channel in a given cluster 108 116 ////////////////////////////////////////////////////////////////////////////////// 109 unsigned int _dma_get_status( unsigned int cluster_ id,117 unsigned int _dma_get_status( unsigned int cluster_xy, 110 118 unsigned int channel_id ) 111 119 { 112 120 #if NB_DMA_CHANNELS > 0 121 113 122 // parameters checking 114 if (cluster_id >= NB_CLUSTERS) return 1; 123 unsigned int x = cluster_xy >> Y_WIDTH; 124 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 125 if (x >= X_SIZE) return 1; 126 if (y >= Y_SIZE) return 1; 115 127 if (channel_id >= NB_DMA_CHANNELS) return 1; 116 128 117 129 // compute DMA base address 118 130 unsigned int * dma_address = (unsigned int *) ((unsigned int)&seg_dma_base + 119 (cluster_ id* (unsigned int)&vseg_cluster_increment));131 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 120 132 121 133 // get selected channel status … … 131 143 // and sets the transfer size to lauch the transfer. 132 144 ////////////////////////////////////////////////////////////////////////////////// 133 unsigned int _dma_start_transfer( unsigned int cluster_ id,145 unsigned int _dma_start_transfer( unsigned int cluster_xy, 134 146 unsigned int channel_id, 135 147 unsigned long long dst_paddr, // physical address … … 138 150 { 139 151 #if NB_DMA_CHANNELS > 0 152 140 153 // parameters checking 141 if (cluster_id >= NB_CLUSTERS) return 1; 154 unsigned int x = cluster_xy >> Y_WIDTH; 155 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 156 if (x >= X_SIZE) return 1; 157 if (y >= Y_SIZE) return 1; 142 158 if (channel_id >= NB_DMA_CHANNELS) return 1; 143 159 144 160 // compute DMA base address 145 161 unsigned int * dma_address = (unsigned int *) ((unsigned int)&seg_dma_base + 146 (cluster_ id* (unsigned int)&vseg_cluster_increment));162 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 147 163 148 164 // selected channel configuration and lauching … … 179 195 180 196 unsigned int procid = _get_procid(); 181 unsigned int cluster_ id= procid/NB_PROCS_MAX;197 unsigned int cluster_xy = procid/NB_PROCS_MAX; 182 198 unsigned int channel_id = procid%NB_PROCS_MAX; 183 199 … … 192 208 _puts("\n - vspace_id = "); 193 209 _putx( vspace_id ); 194 _puts("\n - cluster_ id= ");195 _putx( cluster_ id);210 _puts("\n - cluster_xy = "); 211 _putx( cluster_xy ); 196 212 _puts("\n - channel_id = "); 197 213 _putx( channel_id ); … … 263 279 264 280 // dma channel configuration & lauching 265 ko = _dma_start_transfer( cluster_ id, channel_id, dst_paddr, src_paddr, size );281 ko = _dma_start_transfer( cluster_xy, channel_id, dst_paddr, src_paddr, size ); 266 282 if ( ko ) 267 283 { … … 273 289 274 290 // scan dma channel status 275 unsigned int status = _dma_get_status( cluster_ id, channel_id );291 unsigned int status = _dma_get_status( cluster_xy, channel_id ); 276 292 while( (status != DMA_SUCCESS) && 277 293 (status != DMA_READ_ERROR) && 278 294 (status != DMA_WRITE_ERROR) ) 279 295 { 280 status = _dma_get_status( cluster_ id, channel_id );296 status = _dma_get_status( cluster_xy, channel_id ); 281 297 282 298 #if GIET_DEBUG_DMA_DRIVER … … 299 315 } 300 316 // reset dma channel 301 _dma_reset( cluster_ id, channel_id );317 _dma_reset( cluster_xy, channel_id ); 302 318 303 319 #if GIET_DEBUG_DMA_DRIVER
Note: See TracChangeset
for help on using the changeset viewer.