- Timestamp:
- Jun 25, 2014, 2:19:37 PM (10 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/Makefile
r339 r345 118 118 build/libs/barrier.o 119 119 120 CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 120 CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -O2 121 121 122 122 GIET_INCLUDE = -Igiet_boot \ … … 497 497 rm -rf build/transpose/* 498 498 rm -rf build/convol/* 499 500 distclean: clean 499 501 rm -rf hdd/virt_hdd.dmg -
soft/giet_vm/convol/main.c
r334 r345 259 259 if ( INITIAL_DISPLAY_ENABLE ) 260 260 { 261 date = giet_proctime(); 261 262 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] starts initial display at cycle %d\n", 262 263 x, y, lpid, date); … … 279 280 } 280 281 282 date = giet_proctime(); 281 283 giet_shr_printf( "\n[CONVOL] task[%d,%d,%d] completes initial display at cycle %d\n", 282 284 x, y, lpid, date); -
soft/giet_vm/giet_boot/boot.c
r342 r345 2013 2013 else 2014 2014 { 2015 _memcpy( (char*)seg_vaddr,2016 2017 2015 memcpy( (char*)seg_vaddr, 2016 (char*)src_vaddr, 2017 seg_filesz ); 2018 2018 } 2019 2019 } -
soft/giet_vm/giet_common/io.h
r289 r345 40 40 { 41 41 *(volatile unsigned int *) addr = value; 42 asm volatile("sync" );42 asm volatile("sync" ::: "memory"); 43 43 } 44 44 … … 49 49 { 50 50 *(volatile unsigned short *) addr = value; 51 asm volatile("sync" );51 asm volatile("sync" ::: "memory"); 52 52 } 53 53 … … 58 58 { 59 59 *(volatile unsigned char *) addr = value; 60 asm volatile("sync" );60 asm volatile("sync" ::: "memory"); 61 61 } 62 62 -
soft/giet_vm/giet_common/utils.c
r344 r345 44 44 // Code taken from MutekH. 45 45 /////////////////////////////////////////////////////////////////////////////////// 46 inline void* _memcpy( void* dest, // dest buffer vbase47 48 46 inline void* memcpy( void* dest, // dest buffer vbase 47 const void* source, // source buffer vbase 48 unsigned int size ) // bytes 49 49 { 50 50 unsigned int* idst = (unsigned int*)dest; … … 74 74 // Fill a byte string with a byte value. 75 75 ////////////////////////////////////////////////////////////////////////////////// 76 inline void * _memset( void* dest,77 78 76 inline void * memset( void* dest, 77 int value, 78 unsigned int count ) 79 79 { 80 80 // word-by-word copy … … 119 119 // Processor suicide: infinite loop 120 120 ////////////////////////////////////////////////////////////////////////////////// 121 __attribute__((noreturn)) 121 122 inline void _exit() 122 123 { … … 251 252 inline void _it_disable( unsigned int * save_sr_ptr) 252 253 { 253 unsigned int sr ;254 unsigned int sr = 0; 254 255 asm volatile( "li $3, 0xFFFFFFFE \n" 255 256 "mfc0 %0, $12 \n" 256 257 "and $3, $3, %0 \n" 257 258 "mtc0 $3, $12 \n" 258 : " =r"(sr)259 : "+r"(sr) 259 260 : 260 : "$3" , "memory");261 : "$3" ); 261 262 *save_sr_ptr = sr; 262 263 } … … 292 293 asm volatile ( "mtc2 %0, $0 \n" 293 294 : 294 :"r" (val) ); 295 :"r" (val) 296 :"memory" ); 295 297 } 296 298 ////////////////////////////////////////////////////////////////////////////// … … 301 303 asm volatile ( "mtc2 %0, $1 \n" 302 304 : 303 :"r" (val) ); 305 :"r" (val) 306 :"memory" ); 304 307 } 305 308 ////////////////////////////////////////////////////////////////////////////// … … 369 372 370 373 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 374 "sync \n" 371 375 : 372 376 : "r" (value), "r" (lsb), "r" (msb) … … 516 520 : 517 521 :"r"(plock), "r"(delay) 518 :"$2", "$3", "$4" );522 :"$2", "$3", "$4", "memory"); 519 523 #else 520 524 … … 532 536 : 533 537 :"r"(plock) 534 :"$2", "$3" );538 :"$2", "$3", "memory"); 535 539 #endif 536 540 -
soft/giet_vm/giet_common/utils.h
r344 r345 62 62 /////////////////////////////////////////////////////////////////////////////////// 63 63 64 extern void* _memcpy( void* _dst,65 66 67 68 extern void* _memset( void* dst,69 70 64 extern void* memcpy( void* _dst, 65 const void* _src, 66 unsigned int size ); 67 68 extern void* memset( void* dst, 69 int s, 70 unsigned int count ); 71 71 72 72 /////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/giet_common/vmem.c
r295 r345 95 95 unsigned long long pte2_paddr; 96 96 97 registerunsigned int pte2_msb;98 registerunsigned int pte2_lsb;99 registerunsigned int flags_value;100 registerunsigned int ppn_value;97 volatile unsigned int pte2_msb; 98 volatile unsigned int pte2_lsb; 99 unsigned int flags_value; 100 unsigned int ppn_value; 101 101 102 102 unsigned int ix1 = vpn >> 9; 103 103 unsigned int ix2 = vpn & 0x1FF; 104 105 unsigned int save_sr; 104 106 105 107 // get PTE1 … … 110 112 111 113 // get physical addresses of pte2 (two 32 bits words) 112 ptba = (unsigned long long) (pt ->pt1[ix1]& 0x0FFFFFFF) << 12;114 ptba = (unsigned long long) (pte1 & 0x0FFFFFFF) << 12; 113 115 pte2_paddr = ptba + 8*ix2; 114 116 pte2_lsb = (unsigned int) pte2_paddr; 115 117 pte2_msb = (unsigned int) (pte2_paddr >> 32); 116 118 119 // disable interrupts and save status register 120 _it_disable( &save_sr ); 121 117 122 // gets ppn_value and flags_value, after temporary DTLB desactivation 118 123 asm volatile ( 119 "li $2, 0xFFFFFFFE \n" /* Mask for IE bits */ 120 "mfc0 $4, $12 \n" /* $4 <= SR */ 121 "and $2, $2, $4 \n" 122 "mtc0 $2, $12 \n" /* disable Interrupts */ 123 124 "li $3, 0xB \n" 125 "mtc2 $3, $1 \n" /* DTLB unactivated */ 124 "mfc2 $2, $1 \n" /* $2 <= MMU_MODE */ 125 "andi $3, $2, 0xb \n" 126 "mtc2 $3, $1 \n" /* DTLB off */ 126 127 127 128 "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ … … 130 131 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 131 132 132 "li $3, 0xF \n" 133 "mtc2 $3, $1 \n" /* DTLB activated */ 133 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 134 : "=r" (flags_value), "=r" (ppn_value) 135 : "r" (pte2_msb) , "r" (pte2_lsb) 136 : "$2", "$3"); 134 137 135 "mtc0 $4, $12 \n" /* restore SR */ 136 : "=r" (flags_value), "=r" (ppn_value) 137 : "r" (pte2_msb), "r" (pte2_lsb) 138 : "$2","$3","$4"); 138 // restore saved status register 139 _it_restore( &save_sr ); 139 140 140 141 // check PTE2 mapping … … 142 143 143 144 // set return values 144 *ppn = ppn_value;145 *ppn = ppn_value; 145 146 *flags = flags_value; 147 146 148 return 0; 147 149 } // end _v2p_translate() -
soft/giet_vm/giet_drivers/dma_driver.c
r343 r345 32 32 #include <vmem.h> 33 33 #include <utils.h> 34 #include <io.h> 34 35 35 36 #if !defined(X_SIZE) … … 61 62 #endif 62 63 63 extern unsigned int _ptabs_vaddr[]; 64 extern volatile unsigned int _ptabs_vaddr[]; 65 66 /////////////////////////////////////////////////////////////////////////////// 67 // This low level function returns the value contained in register "index" 68 // in the DMA component contained in cluster "cluster_xy" 69 /////////////////////////////////////////////////////////////////////////////// 70 static 71 unsigned int _dma_get_register( unsigned int cluster_xy, // cluster index 72 unsigned int channel_id, // channel index 73 unsigned int index ) // register index 74 { 75 unsigned int vaddr = 76 SEG_DMA_BASE + 77 (cluster_xy * PERI_CLUSTER_INCREMENT) + 78 (channel_id * DMA_SPAN) + 79 (index << 2); 80 81 return ioread32( (void*)vaddr ); 82 } 83 84 /////////////////////////////////////////////////////////////////////////////// 85 // This low level function sets a new value in register "index" 86 // in the DMA component contained in cluster "cluster_xy" 87 /////////////////////////////////////////////////////////////////////////////// 88 static 89 void _dma_set_register( unsigned int cluster_xy, // cluster index 90 unsigned int channel_id, // channel index 91 unsigned int index, // register index 92 unsigned int value ) // value to be written 93 { 94 unsigned int vaddr = 95 SEG_DMA_BASE + 96 (cluster_xy * PERI_CLUSTER_INCREMENT) + 97 (channel_id * DMA_SPAN) + 98 (index << 2); 99 100 iowrite32( (void*)vaddr, value ); 101 } 64 102 65 103 ////////////////////////////////////////////////////////////////////////////////// … … 81 119 if (channel_id >= NB_DMA_CHANNELS) return 1; 82 120 83 // compute DMA base address84 unsigned int* dma_address = (unsigned int*) ( SEG_DMA_BASE +85 (cluster_xy * PERI_CLUSTER_INCREMENT) );86 87 121 // disable interrupt for selected channel 88 dma_address[channel_id * DMA_SPAN + DMA_IRQ_DISABLE] = 1;122 _dma_set_register(cluster_xy, channel_id, DMA_IRQ_DISABLE, 1); 89 123 return 0; 90 124 #else … … 109 143 if (channel_id >= NB_DMA_CHANNELS) return 1; 110 144 111 // compute DMA base address112 unsigned int* dma_address = (unsigned int*) ( SEG_DMA_BASE +113 (cluster_xy * PERI_CLUSTER_INCREMENT) );114 115 145 // reset selected channel 116 dma_address[channel_id * DMA_SPAN + DMA_RESET] = 0;146 _dma_set_register(cluster_xy, channel_id, DMA_RESET, 0); 117 147 return 0; 118 148 #else … … 136 166 if (channel_id >= NB_DMA_CHANNELS) return 1; 137 167 138 // compute DMA base address139 unsigned int * dma_address = (unsigned int *) ( SEG_DMA_BASE +140 (cluster_xy * PERI_CLUSTER_INCREMENT) );141 142 168 // get selected channel status 143 return dma_address[channel_id * DMA_SPAN + DMA_LEN];169 return _dma_get_register(cluster_xy, channel_id, DMA_LEN); 144 170 #else 145 171 return DMA_IDLE; … … 160 186 #if NB_DMA_CHANNELS > 0 161 187 162 // compute DMA base address163 unsigned int * dma_address = (unsigned int *) ( SEG_DMA_BASE +164 (cluster_xy * PERI_CLUSTER_INCREMENT) );165 166 188 // selected channel configuration and lauching 167 dma_address[channel_id * DMA_SPAN + DMA_SRC] = (unsigned int)(src_paddr); 168 dma_address[channel_id * DMA_SPAN + DMA_SRC_EXT] = (unsigned int)(src_paddr>>32); 169 dma_address[channel_id * DMA_SPAN + DMA_DST] = (unsigned int)(dst_paddr); 170 dma_address[channel_id * DMA_SPAN + DMA_DST_EXT] = (unsigned int)(dst_paddr>>32); 171 dma_address[channel_id * DMA_SPAN + DMA_LEN] = (unsigned int)size; 189 _dma_set_register(cluster_xy, channel_id, DMA_SRC, 190 (unsigned int)(src_paddr)); 191 _dma_set_register(cluster_xy, channel_id, DMA_SRC_EXT, 192 (unsigned int)(src_paddr>>32)); 193 _dma_set_register(cluster_xy, channel_id, DMA_DST, 194 (unsigned int)(dst_paddr)); 195 _dma_set_register(cluster_xy, channel_id, DMA_DST_EXT, 196 (unsigned int)(dst_paddr>>32)); 197 _dma_set_register(cluster_xy, channel_id, DMA_LEN, 198 (unsigned int)size); 172 199 173 200 #endif … … 312 339 313 340 // get vspace page table pointer 314 unsigned int pt = 341 unsigned int pt = _ptabs_vaddr[vspace_id]; 315 342 316 343 // get src_paddr buffer physical addresse -
soft/giet_vm/giet_drivers/fbf_driver.c
r320 r345 64 64 char* fbf_address = (char *)SEG_FBF_BASE + offset; 65 65 66 _memcpy( fbf_address, buffer, length);66 memcpy( fbf_address, buffer, length); 67 67 68 68 return 0; … … 81 81 char* fbf_address = (char *)SEG_FBF_BASE + offset; 82 82 83 _memcpy( buffer, fbf_address, length);83 memcpy( buffer, fbf_address, length); 84 84 85 85 return 0; -
soft/giet_vm/giet_drivers/mmc_driver.c
r333 r345 21 21 #include <tty_driver.h> 22 22 #include <utils.h> 23 #include <io.h> 23 24 24 25 #if !defined(X_SIZE) … … 46 47 #endif 47 48 49 /////////////////////////////////////////////////////////////////////////////// 50 // This low level function returns the value contained in register "index" 51 // in the MMC component contained in cluster "cluster_xy" 52 /////////////////////////////////////////////////////////////////////////////// 53 static 54 unsigned int _mmc_get_register( unsigned int cluster_xy, // cluster index 55 unsigned int func, // function index 56 unsigned int index ) // register index 57 { 58 unsigned int vaddr = 59 SEG_MMC_BASE + 60 (cluster_xy * PERI_CLUSTER_INCREMENT) + 61 (MMC_REG(func, index) << 2); 62 63 return ioread32( (void*)vaddr ); 64 } 65 66 /////////////////////////////////////////////////////////////////////////////// 67 // This low level function sets a new value in register "index" 68 // in the MMC component contained in cluster "cluster_xy" 69 /////////////////////////////////////////////////////////////////////////////// 70 static 71 void _mmc_set_register( unsigned int cluster_xy, // cluster index 72 unsigned int func, // func index 73 unsigned int index, // register index 74 unsigned int value ) // value to be written 75 { 76 unsigned int vaddr = 77 SEG_MMC_BASE + 78 (cluster_xy * PERI_CLUSTER_INCREMENT) + 79 (MMC_REG(func, index) << 2); 80 81 iowrite32( (void*)vaddr, value ); 82 } 83 48 84 /////////////////////////////////////////////////////////////////////////////////// 49 85 // This function invalidates all cache lines covering a memory buffer defined … … 67 103 } 68 104 69 unsigned int* mmc_address = (unsigned int*)( SEG_MMC_BASE +70 (cluster_xy * PERI_CLUSTER_INCREMENT) );71 72 105 // get the hard lock protecting exclusive access to MEMC 73 while ( mmc_address[MEMC_LOCK] ) { asm volatile("nop"); }106 while ( _mmc_get_register(cluster_xy, 0, MEMC_LOCK) ); 74 107 75 108 // write inval arguments 76 mmc_address[MEMC_ADDR_LO] = (unsigned int)buf_paddr;77 mmc_address[MEMC_ADDR_HI] = (unsigned int)(buf_paddr>>32);78 mmc_address[MEMC_BUF_LENGTH] = buf_length;79 mmc_address[MEMC_CMD_TYPE] = MEMC_CMD_INVAL;109 _mmc_set_register(cluster_xy, 0, MEMC_ADDR_LO , (unsigned int)buf_paddr); 110 _mmc_set_register(cluster_xy, 0, MEMC_ADDR_HI , (unsigned int)(buf_paddr>>32)); 111 _mmc_set_register(cluster_xy, 0, MEMC_BUF_LENGTH, buf_length); 112 _mmc_set_register(cluster_xy, 0, MEMC_CMD_TYPE , MEMC_CMD_INVAL); 80 113 81 114 // release the lock 82 mmc_address[MEMC_LOCK] = 0;115 _mmc_set_register(cluster_xy, 0, MEMC_LOCK, 0); 83 116 } 84 117 /////////////////////////////////////////////////////////////////////////////////// … … 103 136 } 104 137 105 unsigned int* mmc_address = (unsigned int*)( SEG_MMC_BASE +106 (cluster_xy * PERI_CLUSTER_INCREMENT) );107 108 138 // get the hard lock protecting exclusive access to MEMC 109 while ( mmc_address[MEMC_LOCK] ) { asm volatile("nop"); }139 while ( _mmc_get_register(cluster_xy, 0, MEMC_LOCK) ); 110 140 111 141 // write inval arguments 112 mmc_address[MEMC_ADDR_LO] = (unsigned int)buf_paddr;113 mmc_address[MEMC_ADDR_HI] = (unsigned int)(buf_paddr>>32);114 mmc_address[MEMC_BUF_LENGTH] = buf_length;115 mmc_address[MEMC_CMD_TYPE] = MEMC_CMD_SYNC;142 _mmc_set_register(cluster_xy, 0, MEMC_ADDR_LO , (unsigned int)buf_paddr); 143 _mmc_set_register(cluster_xy, 0, MEMC_ADDR_HI , (unsigned int)(buf_paddr>>32)); 144 _mmc_set_register(cluster_xy, 0, MEMC_BUF_LENGTH, buf_length); 145 _mmc_set_register(cluster_xy, 0, MEMC_CMD_TYPE , MEMC_CMD_SYNC); 116 146 117 // release the lock protecting MEMC118 mmc_address[MEMC_LOCK] = 0;147 // release the lock 148 _mmc_set_register(cluster_xy, 0, MEMC_LOCK, 0); 119 149 } 120 150 -
soft/giet_vm/giet_drivers/mmc_driver.h
r297 r345 29 29 }; 30 30 31 #define MMC_REG(func,idx) ((func<<7)|idx) 32 31 33 /////////////////////////////////////////////////////////////////////////////////// 32 34 // MEMC access functions (for TSAR architecture) -
soft/giet_vm/giet_drivers/sim_driver.c
r320 r345 33 33 unsigned int * retval) 34 34 { 35 unsigned int* sim_helper_address = (unsigned int*)&seg_sim_base;35 volatile unsigned int* sim_helper_address = (unsigned int*)&seg_sim_base; 36 36 37 37 if (register_index == SIMHELPER_SC_STOP || -
soft/giet_vm/giet_drivers/tty_driver.c
r333 r345 53 53 54 54 in_unckdata volatile unsigned int _tty_rx_full[NB_TTY_CHANNELS] 55 56 57 in_ kdata unsigned int _tty_lock[NB_TTY_CHANNELS]58 55 = { [0 ... NB_TTY_CHANNELS - 1] = 0 }; 56 57 in_unckdata unsigned int _tty_lock[NB_TTY_CHANNELS] 58 = { [0 ... NB_TTY_CHANNELS - 1] = 0 }; 59 59 60 60 ////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/giet_drivers/xcu_driver.c
r333 r345 16 16 #include <mapping_info.h> 17 17 #include <utils.h> 18 #include <io.h> 18 19 19 20 #if !defined(X_SIZE) … … 49 50 #endif 50 51 52 /////////////////////////////////////////////////////////////////////////////// 53 // This low level function returns the value contained in register "index" 54 // in the XCU component contained in cluster "cluster_xy" 55 /////////////////////////////////////////////////////////////////////////////// 56 static 57 unsigned int _xcu_get_register( unsigned int cluster_xy, // cluster index 58 unsigned int func, // function index 59 unsigned int index ) // register index 60 { 61 unsigned int vaddr = 62 SEG_XCU_BASE + 63 (cluster_xy * PERI_CLUSTER_INCREMENT) + 64 (XCU_REG(func, index) << 2); 65 66 return ioread32( (void*)vaddr ); 67 } 68 69 /////////////////////////////////////////////////////////////////////////////// 70 // This low level function sets a new value in register "index" 71 // in the XCU component contained in cluster "cluster_xy" 72 /////////////////////////////////////////////////////////////////////////////// 73 static 74 void _xcu_set_register( unsigned int cluster_xy, // cluster index 75 unsigned int func, // func index 76 unsigned int index, // register index 77 unsigned int value ) // value to be written 78 { 79 unsigned int vaddr = 80 SEG_XCU_BASE + 81 (cluster_xy * PERI_CLUSTER_INCREMENT) + 82 (XCU_REG(func, index) << 2); 83 84 iowrite32( (void*)vaddr, value ); 85 } 51 86 52 87 //////////////////////////////////////////////////////////////////////////////// … … 68 103 if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit(); 69 104 70 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 71 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 72 73 unsigned int func; 105 unsigned int func = 0; 74 106 if (irq_type == IRQ_TYPE_PTI) func = XCU_MSK_PTI_ENABLE; 75 107 else if (irq_type == IRQ_TYPE_WTI) func = XCU_MSK_WTI_ENABLE; … … 81 113 } 82 114 83 xcu_address[XCU_REG(func,channel)] = value;115 _xcu_set_register(cluster_xy, func, channel, value); 84 116 85 117 #else … … 110 142 if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit(); 111 143 112 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 113 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 114 115 unsigned int prio = xcu_address[XCU_REG(XCU_PRIO,channel)]; 144 unsigned int prio = _xcu_get_register(cluster_xy, XCU_PRIO, channel); 116 145 unsigned int pti_ok = (prio & 0x00000001); 117 146 unsigned int hwi_ok = (prio & 0x00000002); … … 162 191 if (wti_index >= 32) _exit(); 163 192 164 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 165 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 166 167 xcu_address[XCU_REG(XCU_WTI_REG,wti_index)] = wdata; 193 _xcu_set_register(cluster_xy, XCU_WTI_REG, wti_index, wdata); 168 194 169 195 #else … … 191 217 if (wti_index >= 32) _exit(); 192 218 193 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 194 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 195 196 *value = xcu_address[XCU_REG(XCU_WTI_REG, wti_index)]; 219 *value = _xcu_get_register(cluster_xy, XCU_WTI_REG, wti_index); 197 220 198 221 #else … … 215 238 if (wti_index >= 32) _exit(); 216 239 217 unsigned int xcu_address = (unsigned int)SEG_XCU_BASE; 218 *address = xcu_address + (XCU_REG(XCU_WTI_REG, wti_index)<<2); 240 *address = SEG_XCU_BASE + (XCU_REG(XCU_WTI_REG, wti_index)<<2); 219 241 220 242 #else … … 239 261 if (y >= Y_SIZE) _exit(); 240 262 241 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 242 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 243 244 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period; 263 _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, period); 245 264 246 265 #else … … 264 283 if (y >= Y_SIZE) _exit(); 265 284 266 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 267 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 268 269 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0; 285 _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, 0); 270 286 271 287 #else … … 291 307 if (y >= Y_SIZE) _exit(); 292 308 293 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +294 (cluster_xy * PERI_CLUSTER_INCREMENT) );295 296 309 // This return value is not used / avoid a compilation warning. 297 return xcu_address[XCU_REG(XCU_PTI_ACK, pti_index)];310 return _xcu_get_register(cluster_xy, XCU_PTI_ACK, pti_index); 298 311 299 312 #else … … 322 335 if (y >= Y_SIZE) _exit(); 323 336 324 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 325 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 326 327 unsigned int period = xcu_address[XCU_REG(XCU_PTI_PER, pti_index)]; 337 unsigned int per = _xcu_get_register(cluster_xy, XCU_PTI_PER, pti_index); 328 338 329 339 // we write 0 first because if the timer is currently running, 330 340 // the corresponding timer counter is not reset 331 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0;332 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period;341 _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, 0); 342 _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, per); 333 343 334 344 #else -
soft/giet_vm/giet_fat32/fat32.c
r337 r345 533 533 (ord != NO_MORE_ENTRY ) ) // SFN entry : checked 534 534 { 535 _memcpy( dir_entry, fat.fat_cache + offset, DIR_ENTRY_SIZE );535 memcpy( dir_entry, fat.fat_cache + offset, DIR_ENTRY_SIZE ); 536 536 } 537 537 else if (ord == NO_MORE_ENTRY ) // end of directory : return … … 552 552 (ord != NO_MORE_ENTRY) ) // LFN entry : checked 553 553 { 554 _memcpy( dir_entry, fat.fat_cache + offset, DIR_ENTRY_SIZE );554 memcpy( dir_entry, fat.fat_cache + offset, DIR_ENTRY_SIZE ); 555 555 } 556 556 else if ( (attr != ATTR_LONG_NAME_MASK) && … … 910 910 (ord != NO_MORE_ENTRY ) ) // SFN entry : checked 911 911 { 912 _memcpy( dir_entry, fat.fat_cache + offset, DIR_ENTRY_SIZE );912 memcpy( dir_entry, fat.fat_cache + offset, DIR_ENTRY_SIZE ); 913 913 offset = offset + DIR_ENTRY_SIZE; 914 914 } … … 929 929 (ord != NO_MORE_ENTRY) ) // LFN entry : checked 930 930 { 931 _memcpy( dir_entry, fat.fat_cache + offset, DIR_ENTRY_SIZE );931 memcpy( dir_entry, fat.fat_cache + offset, DIR_ENTRY_SIZE ); 932 932 offset = offset + DIR_ENTRY_SIZE; 933 933 } … … 980 980 else // file found 981 981 { 982 _memcpy( dir_entry, fat.fat_cache + offset, DIR_ENTRY_SIZE );982 memcpy( dir_entry, fat.fat_cache + offset, DIR_ENTRY_SIZE ); 983 983 offset = offset + DIR_ENTRY_SIZE; 984 984 *file_size = read_entry( DIR_FILE_SIZE, dir_entry, 1 ); -
soft/giet_vm/giet_kernel/kernel_init.c
r330 r345 116 116 117 117 __attribute__((section (".kdata"))) 118 unsigned int _ptabs_vaddr[GIET_NB_VSPACE_MAX]; // virtual addresses118 volatile unsigned int _ptabs_vaddr[GIET_NB_VSPACE_MAX]; // virtual addresses 119 119 120 120 __attribute__((section (".kdata"))) 121 unsigned int _ptabs_ptprs[GIET_NB_VSPACE_MAX]; // physical addresses >> 13121 volatile unsigned int _ptabs_ptprs[GIET_NB_VSPACE_MAX]; // physical addresses >> 13 122 122 123 123 /////////////////////////////////////////////////////////////////////////////////// … … 126 126 127 127 __attribute__((section (".kdata"))) 128 static_scheduler_t* _schedulers[NB_PROCS_MAX<<(X_WIDTH+Y_WIDTH)]; // virtual addresses128 volatile static_scheduler_t* _schedulers[NB_PROCS_MAX<<(X_WIDTH+Y_WIDTH)]; // virtual addresses 129 129 130 130 //////////////////////////////////////////////////////////////////////////////////// … … 133 133 134 134 __attribute__((section (".kdata"))) 135 unsigned int _idle_stack[X_SIZE * Y_SIZE * NB_PROCS_MAX * 128 ];135 volatile unsigned int _idle_stack[X_SIZE * Y_SIZE * NB_PROCS_MAX * 128 ]; 136 136 137 137 //////////////////////////////////////////////////////////////////////////////////// … … 140 140 141 141 __attribute__((section (".kdata"))) 142 unsigned int _init_barrier = 0;142 volatile unsigned int _init_barrier = 0; 143 143 144 144 /////////////////////////////////////////////////////////////////////////////////// … … 340 340 341 341 // busy waiting until all processors synchronized 342 while ( _init_barrier != NB_TOTAL_PROCS ) asm volatile ("nop");342 while ( _init_barrier != NB_TOTAL_PROCS ); 343 343 344 344 // set registers and jump to user code … … 351 351 : 352 352 : "r"(sp_value), "r"(sr_value), "r"(ptpr_value), "r"(epc_value) 353 : "$29" );353 : "$29", "memory" ); 354 354 355 355 } // end kernel_init() -
soft/giet_vm/giet_libs/barrier.c
r295 r345 20 20 unsigned int value ) 21 21 { 22 barrier->init = value; 23 barrier->count = value; 22 barrier->init = (volatile unsigned int)value; 23 barrier->count = (volatile unsigned int)value; 24 asm volatile ("sync" ::: "memory"); 24 25 } 25 26 … … 31 32 void barrier_wait( giet_barrier_t* barrier ) 32 33 { 33 unsigned int * pcount= (unsigned int *) &barrier->count;34 unsigned int maxcount = barrier->init;35 unsigned int count;34 volatile unsigned int * pcount = (unsigned int *) &barrier->count; 35 volatile unsigned int maxcount = barrier->init; 36 volatile unsigned int count; 36 37 37 38 // parallel decrement barrier counter using atomic instructions LL/SC 38 39 // - input : pointer on the barrier counter 39 40 // - output : counter value 40 asm volatile ("_barrier_decrement: \n" 41 "ll %0, 0(%1) \n" 42 "addi $3, %0, -1 \n" 43 "sc $3, 0(%1) \n" 44 "beqz $3, _barrier_decrement \n" 45 : "=&r"(count) 41 asm volatile ( 42 "_barrier_decrement: \n" 43 "ll %0, 0(%1) \n" 44 "addi $3, %0, -1 \n" 45 "sc $3, 0(%1) \n" 46 "beqz $3, _barrier_decrement \n" 47 : "+r"(count) 46 48 : "r"(pcount) 47 : "$ 2", "$3");49 : "$3", "memory"); 48 50 49 51 // the last task re-initializes the barrier counter to the max value, … … 57 59 else { 58 60 // other tasks busy-wait 59 while (*pcount != maxcount) asm volatile ("nop");61 while (*pcount != maxcount); 60 62 } 63 64 asm volatile ("sync" ::: "memory"); 61 65 } 62 66 -
soft/giet_vm/giet_libs/mwmr_channel.c
r258 r345 43 43 register unsigned int delay = 100; 44 44 asm volatile ( 45 " mwmr_lock_try:\n"45 "1: \n" 46 46 "ll $2, 0(%0) \n" /* $2 <= lock current value */ 47 "bnez $2, mwmr_lock_delay\n" /* retry after delay if lock busy */47 "bnez $2, 2f \n" /* retry after delay if lock busy */ 48 48 "li $3, 1 \n" /* $3 <= argument for sc */ 49 49 "sc $3, 0(%0) \n" /* try to get lock */ 50 "bnez $3, mwmr_lock_ok\n" /* exit if atomic */51 " mwmr_lock_delay:\n"52 "move $4, %1 \n" /* $4 <= delay */53 " mwmr_lock_loop:\n"54 "beqz $4, mwmr_lock_loop\n" /* test end delay */55 "addi $4, $4, -1 \n" /* $4 <= $4 - 1 */56 "j mwmr_lock_try\n" /* retry ll */57 "nop \n"58 " mwmr_lock_ok:\n"50 "bnez $3, 3f \n" /* exit if atomic */ 51 "2: \n" 52 "move $4, %1 \n" /* $4 <= delay */ 53 "4: \n" 54 "beqz $4, 4b \n" /* test end delay */ 55 "addi $4, $4, -1 \n" /* $4 <= $4 - 1 */ 56 "j 1b \n" /* retry ll */ 57 "nop \n" 58 "3: \n" 59 59 : 60 60 :"r"(plock), "r"(delay) -
soft/giet_vm/giet_libs/stdio.c
r331 r345 23 23 24 24 //////////////////////////////////////// 25 void giet_tty_printf( char* format, ...) 26 { 27 va_list args; 28 va_start( args, format ); 29 30 int ret; // return value from the syscalls 31 unsigned int channel = 0xFFFFFFFF; // channel defined in task context 25 static int __printf( char* format, unsigned int channel, va_list* args) 26 { 27 int ret; // return value from the syscalls 32 28 33 29 printf_text: … … 56 52 } 57 53 58 va_end( args ); 59 return; 54 return 0; 60 55 61 56 printf_arguments: … … 72 67 case ('c'): /* char conversion */ 73 68 { 74 int val = va_arg( args, int );69 int val = va_arg( *args, int ); 75 70 len = 1; 76 71 buf[0] = val; … … 80 75 case ('d'): /* 32 bits decimal signed integer */ 81 76 { 82 int val = va_arg( args, int );77 int val = va_arg( *args, int ); 83 78 if (val < 0) 84 79 { … … 102 97 case ('u'): /* 32 bits decimal unsigned integer */ 103 98 { 104 unsigned int val = va_arg( args, unsigned int );99 unsigned int val = va_arg( *args, unsigned int ); 105 100 for(i = 0; i < 10; i++) 106 101 { … … 114 109 case ('x'): /* 32 bits hexadecimal integer */ 115 110 { 116 unsigned int val = va_arg( args, unsigned int );111 unsigned int val = va_arg( *args, unsigned int ); 117 112 ret = sys_call(SYSCALL_TTY_WRITE, 118 113 (unsigned int)"0x", … … 132 127 case ('l'): /* 64 bits hexadecimal unsigned */ 133 128 { 134 unsigned long long val = va_arg( args, unsigned long long );129 unsigned long long val = va_arg( *args, unsigned long long ); 135 130 ret = sys_call(SYSCALL_TTY_WRITE, 136 131 (unsigned int)"0x", … … 150 145 case ('s'): /* string */ 151 146 { 152 char* str = va_arg( args, char* );147 char* str = va_arg( *args, char* ); 153 148 while (str[len]) 154 149 { … … 173 168 174 169 return_error: 175 170 return 1; 171 } // end __printf() 172 173 174 //////////////////////////////////////// 175 void giet_tty_printf( char* format, ...) 176 { 177 va_list args; 178 179 va_start( args, format ); 180 int ret = __printf(format, 0xFFFFFFFF, &args); 176 181 va_end( args ); 177 giet_exit("error in giet_tty_printf()"); 182 183 if (ret) 184 { 185 giet_exit("error in giet_tty_printf()"); 186 } 178 187 } // end giet_tty_printf() 179 188 … … 182 191 { 183 192 va_list args; 184 va_start( args, format ); 185 186 int ret; // return value from the syscalls 187 unsigned int channel = 0; 188 unsigned int sr_save; 193 const int channel = 0; 194 volatile unsigned int sr_save; 189 195 190 196 sys_call( SYSCALL_TTY_GET_LOCK, … … 193 199 0, 0 ); 194 200 195 printf_text: 196 197 while (*format) 198 { 199 unsigned int i; 200 for (i = 0 ; format[i] && (format[i] != '%') ; i++); 201 if (i) 202 { 203 ret = sys_call(SYSCALL_TTY_WRITE, 204 (unsigned int)format, 205 i, 206 channel, 207 0); 208 209 if (ret != i) goto return_error; 210 211 format += i; 212 } 213 if (*format == '%') 214 { 215 format++; 216 goto printf_arguments; 217 } 218 } 201 va_start( args, format ); 202 int ret = __printf(format, channel, &args); 203 va_end( args ); 219 204 220 205 sys_call( SYSCALL_TTY_RELEASE_LOCK, … … 222 207 (unsigned int)&sr_save, 223 208 0, 0 ); 224 225 va_end( args ); 226 return; 227 228 printf_arguments: 229 230 { 231 char buf[20]; 232 char * pbuf; 233 unsigned int len = 0; 234 static const char HexaTab[] = "0123456789ABCDEF"; 235 unsigned int i; 236 237 switch (*format++) 238 { 239 case ('c'): /* char conversion */ 240 { 241 int val = va_arg( args, int ); 242 len = 1; 243 buf[0] = val; 244 pbuf = &buf[0]; 245 break; 246 } 247 case ('d'): /* 32 bits decimal signed integer */ 248 { 249 int val = va_arg( args, int ); 250 if (val < 0) 251 { 252 val = -val; 253 ret = sys_call(SYSCALL_TTY_WRITE, 254 (unsigned int)"-", 255 1, 256 channel, 257 0); 258 if (ret != 1) goto return_error; 259 } 260 for(i = 0; i < 10; i++) 261 { 262 buf[9 - i] = HexaTab[val % 10]; 263 if (!(val /= 10)) break; 264 } 265 len = i + 1; 266 pbuf = &buf[9 - i]; 267 break; 268 } 269 case ('u'): /* 32 bits decimal unsigned integer */ 270 { 271 unsigned int val = va_arg( args, unsigned int ); 272 for(i = 0; i < 10; i++) 273 { 274 buf[9 - i] = HexaTab[val % 10]; 275 if (!(val /= 10)) break; 276 } 277 len = i + 1; 278 pbuf = &buf[9 - i]; 279 break; 280 } 281 case ('x'): /* 32 bits hexadecimal integer */ 282 { 283 unsigned int val = va_arg( args, unsigned int ); 284 ret = sys_call(SYSCALL_TTY_WRITE, 285 (unsigned int)"0x", 286 2, 287 channel, 288 0); 289 if (ret != 2) goto return_error; 290 for(i = 0; i < 8; i++) 291 { 292 buf[7 - i] = HexaTab[val % 16]; 293 if (!(val /= 16)) break; 294 } 295 len = i + 1; 296 pbuf = &buf[7 - i]; 297 break; 298 } 299 case ('l'): /* 64 bits hexadecimal unsigned */ 300 { 301 unsigned long long val = va_arg( args, unsigned long long ); 302 ret = sys_call(SYSCALL_TTY_WRITE, 303 (unsigned int)"0x", 304 2, 305 channel, 306 0); 307 if (ret != 2) goto return_error; 308 for(i = 0; i < 16; i++) 309 { 310 buf[15 - i] = HexaTab[val % 16]; 311 if (!(val /= 16)) break; 312 } 313 len = i + 1; 314 pbuf = &buf[15 - i]; 315 break; 316 } 317 case ('s'): /* string */ 318 { 319 char* str = va_arg( args, char* ); 320 while (str[len]) 321 { 322 len++; 323 } 324 pbuf = str; 325 break; 326 } 327 default: 328 goto return_error; 329 } 330 331 ret = sys_call(SYSCALL_TTY_WRITE, 332 (unsigned int)pbuf, 333 len, 334 channel, 335 0); 336 if (ret != len) goto return_error; 337 338 goto printf_text; 339 } 340 341 return_error: 342 343 sys_call( SYSCALL_TTY_RELEASE_LOCK, 344 channel, 345 (unsigned int)&sr_save, 346 0, 0 ); 347 348 va_end( args ); 349 giet_exit("error in giet_shr_printf()"); 350 } // end giet_shr_printf() 351 209 210 if (ret) 211 { 212 giet_exit("error in giet_shr_printf()"); 213 } 214 } // end giet_shr_printf() 352 215 353 216 ///////////////////////////////// -
soft/giet_vm/giet_libs/stdio.h
r295 r345 72 72 asm volatile( 73 73 "syscall" 74 : "=r" (reg_no_and_output) /* output argument */ 75 : "r" (reg_a0), /* input arguments */ 76 "r" (reg_a1), 77 "r" (reg_a2), 78 "r" (reg_a3), 79 "r" (reg_no_and_output) 74 : "+r" (reg_no_and_output), /* input/output argument */ 75 "+r" (reg_a0), 76 "+r" (reg_a1), 77 "+r" (reg_a2), 78 "+r" (reg_a3), 79 "+r" (reg_no_and_output) 80 : /* input arguments */ 80 81 : "memory", 81 82 /* These persistant registers will be saved on the stack by the … … 95 96 "t9" 96 97 ); 97 return reg_no_and_output;98 return (volatile int)reg_no_and_output; 98 99 } 99 100 -
soft/giet_vm/router/main.c
r295 r345 3 3 #include "mapping_info.h" 4 4 #include "hard_config.h" 5 6 #if NB_TTY_CHANNELS == 1 7 # define printf(...) giet_shr_printf(__VA_ARGS__) 8 #else 9 # define printf(...) giet_tty_printf(__VA_ARGS__) 10 #endif 5 11 6 12 #define NMAX 50 … … 20 26 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 21 27 22 giet_tty_printf( "*** Starting task producer on processor[%d,%d,%d] at cycle %d\n\n",23 28 printf( "*** Starting task producer on processor[%d,%d,%d] at cycle %d\n\n", 29 x, y, lpid, giet_proctime() ); 24 30 25 31 giet_vobj_get_vbase( "router" , … … 32 38 buf = n; 33 39 mwmr_write( mwmr, &buf , 1 ); 34 giet_tty_printf( "transmitted value : %d\n", buf);40 printf( "transmitted value : %d\n", buf); 35 41 } 36 42 … … 52 58 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 53 59 54 giet_tty_printf( "*** Starting task consumer on processor[%d,%d,%d] at cycle %d\n\n",55 60 printf( "*** Starting task consumer on processor[%d,%d,%d] at cycle %d\n\n", 61 x, y, lpid, giet_proctime() ); 56 62 57 63 giet_vobj_get_vbase( "router" , … … 63 69 { 64 70 mwmr_read( mwmr, &buf , 1 ); 65 giet_tty_printf( "received token %d / value = %d\n", n , buf);71 printf( "received token %d / value = %d\n", n , buf); 66 72 } 67 73 … … 85 91 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 86 92 87 giet_tty_printf( "*** Starting task router on processor[%d,%d,%d] at cycle %d\n\n",88 93 printf( "*** Starting task router on processor[%d,%d,%d] at cycle %d\n\n", 94 x, y, lpid, giet_proctime() ); 89 95 90 96 giet_vobj_get_vbase( "router" , … … 101 107 tempo = giet_rand() >> 6; 102 108 for ( n = 0 ; n < tempo ; n++ ) asm volatile (""); 103 giet_tty_printf( "token value : %d / temporisation = %d\n", buf, tempo);109 printf( "token value : %d / temporisation = %d\n", buf, tempo); 104 110 mwmr_write( mwmr_out, &buf , 1 ); 105 111 } -
soft/giet_vm/sort/main.c
r318 r345 58 58 int array1[ARRAY_LENGTH]; 59 59 60 int init_ok = 0;60 volatile int init_ok = 0; 61 61 62 62 void bubbleSort( … … 95 95 (unsigned int*)&nb_thread ); 96 96 97 task0_printf("\n[ Thread 0 ] Starting sort application with % dthreads "98 "at cycle % d\n", *nb_thread, time_start);97 task0_printf("\n[ Thread 0 ] Starting sort application with %u threads " 98 "at cycle %u\n", *nb_thread, time_start); 99 99 100 100 /////////////////////////// … … 134 134 for (i = 0; i < __builtin_ctz(*nb_thread); i++) 135 135 { 136 asm volatile ("sync");137 136 barrier_wait(&barrier[i]); 138 137 … … 171 170 ////////////////////////////// 172 171 // Verify the resulting array 173 174 if(thread_id == 0) 175 { 176 success = 1; 177 178 for(i=0; i<(ARRAY_LENGTH-1); i++) 179 { 180 if(dst_array[i] > dst_array[i+1]) 181 { 182 183 success = 0; 184 failure_index = i; 185 break; 186 } 187 } 188 189 time_end = giet_proctime(); 190 191 printf("[ Thread 0 ] Finishing sort application at cycle %d\n" 192 "[ Thread 0 ] Time elapsed = %d\n", 193 time_end, (time_end - time_start) ); 194 195 if (success) 196 { 197 exit("!!! Success !!!"); 198 } 199 else 200 { 201 printf("[ Thread 0 ] Failure!! Incorrect element: %d\n\r", 202 failure_index); 203 for(i=0; i<ARRAY_LENGTH; i++) 204 { 205 printf("array[%d] = %d\n", i, dst_array[i]); 206 } 207 exit("!!! Failure !!!"); 208 } 209 } 172 173 if(thread_id != 0) 174 { 175 exit("error: only thread 0 should get here"); 176 } 177 178 success = 1; 179 for(i=0; i<(ARRAY_LENGTH-1); i++) 180 { 181 if(dst_array[i] > dst_array[i+1]) 182 { 183 184 success = 0; 185 failure_index = i; 186 break; 187 } 188 } 189 190 time_end = giet_proctime(); 191 192 printf("[ Thread 0 ] Finishing sort application at cycle %d\n" 193 "[ Thread 0 ] Time elapsed = %d\n", 194 time_end, (time_end - time_start) ); 195 196 if (success) 197 { 198 exit("!!! Success !!!"); 199 } 200 else 201 { 202 printf("[ Thread 0 ] Failure!! Incorrect element: %d\n\r", 203 failure_index); 204 for(i=0; i<ARRAY_LENGTH; i++) 205 { 206 printf("array[%d] = %d\n", i, dst_array[i]); 207 } 208 exit("!!! Failure !!!"); 209 } 210 210 211 exit("Completed"); 211 212 } -
soft/giet_vm/transpose/main.c
r336 r345 25 25 #define FILE_PATHNAME "misc/images.raw" // file pathname on disk 26 26 27 #define INSTRUMENTATION_OK 0// display statistics on TTY when non zero27 #define INSTRUMENTATION_OK 1 // display statistics on TTY when non zero 28 28 29 29 ///////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.