Changeset 430 for soft/giet_vm/giet_common/utils.c
- Timestamp:
- Oct 4, 2014, 3:21:56 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_common/utils.c
r408 r430 20 20 21 21 // This global variable is allocated in the boot.c file or in kernel_init.c file 22 extern static_scheduler_t* _schedulers[ NB_PROCS_MAX<<(X_WIDTH+Y_WIDTH)];22 extern static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX]; 23 23 24 24 /////////////////////////////////////////////////////////////////////////////////// … … 72 72 asm volatile ( "mfc0 %0, $15, 1 \n" 73 73 :"=r" (ret) ); 74 return (ret & 0x 3FF);74 return (ret & 0xFFF); 75 75 } 76 76 //////////////////////////// … … 173 173 174 174 //////////////////////////////////////////////////////////////////////////// 175 // This function makes a physical read access to a 32 bits word in memory,176 // after a temporary DTLB de-activation and paddr extension.177 ////////////////////////////////////////////////////////////////////////////178 175 unsigned int _physical_read( unsigned long long paddr ) 179 176 { … … 202 199 } 203 200 //////////////////////////////////////////////////////////////////////////// 204 // This function makes a physical write access to a 32 bits word in memory,205 // after a temporary DTLB de-activation and paddr extension.206 ////////////////////////////////////////////////////////////////////////////207 201 void _physical_write( unsigned long long paddr, 208 202 unsigned int value ) 209 203 { 210 204 unsigned int lsb = (unsigned int)paddr; … … 212 206 unsigned int sr; 213 207 214 208 _it_disable(&sr); 215 209 216 210 asm volatile( "mfc2 $2, $1 \n" /* $2 <= MMU_MODE */ … … 232 226 233 227 //////////////////////////////////////////////////////////////////////////// 234 // This function makes a physical read access to a 64 bits word in memory,235 // after a temporary DTLB de-activation and paddr extension.236 ////////////////////////////////////////////////////////////////////////////237 228 unsigned long long _physical_read_ull( unsigned long long paddr ) 238 229 { … … 266 257 267 258 //////////////////////////////////////////////////////////////////////////// 268 // This function makes a physical write access to a 64 bits word in memory,269 // after a temporary DTLB de-activation and paddr extension.270 ////////////////////////////////////////////////////////////////////////////271 259 void _physical_write_ull( unsigned long long paddr, 272 260 unsigned long long value ) … … 304 292 // multiple of 4 bytes. 305 293 /////////////////////////////////////////////////////////////////////////////////// 306 void _physical_memcpy( unsigned long long dst_paddr, // dest buffer paddr294 void _physical_memcpy( unsigned long long dst_paddr, // destination buffer paddr 307 295 unsigned long long src_paddr, // source buffer paddr 308 296 unsigned int size ) // bytes … … 352 340 353 341 _it_restore(&sr); 354 } 355 356 /////////////////////////////////////////////////////////////////////////////////// 357 // This function is used by several drivers (_xxx_set_register() function) 358 // If the MMU is not activated, the virtual address is extended using 359 // X_IO and Y_IO to reach the cluster_io. 342 } // end _physical_memcpy() 343 344 ///////////////////////////////////////////////////////////////////////////////// 345 void _physical_memset( unsigned long long paddr, // destination buffer paddr 346 unsigned int size, // bytes 347 unsigned int data ) // written value 348 { 349 // check alignment constraints 350 if ( (paddr & 3) || (size & 3) ) 351 { 352 _printf("\n[GIET ERROR] in _physical_memset() : buffer unaligned\n"); 353 _exit(); 354 } 355 356 unsigned int lsb = (unsigned int)paddr; 357 unsigned int msb = (unsigned int)(paddr >> 32); 358 unsigned int sr; 359 360 _it_disable(&sr); 361 362 asm volatile( "move $4, %0 \n" /* $4 < lsb */ 363 "move $5, %1 \n" /* $5 < msb */ 364 "move $6, %2 \n" /* $6 < size */ 365 "move $7, %3 \n" /* $7 < data */ 366 367 "mfc2 $2, $1 \n" /* $2 <= current MMU_MODE */ 368 "andi $3, $2, 0xb \n" /* $3 <= new MMU_MODE */ 369 "mtc2 $3, $1 \n" /* DTLB off */ 370 "mtc2 $5, $24 \n" /* PADDR_EXT <= msb */ 371 372 "ph_memset_loop: \n" 373 "sw $7, 0($4) \n" /* data <= *src_paddr */ 374 "addi $4, $4, 4 \n" /* iter = iter - 1 */ 375 "bne $4, $6, ph_memcpy_loop \n" 376 "nop \n" 377 378 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 379 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 380 : "=r" (data) 381 : "r" (lsb), "r" (msb), "r" (size), "r"(data) 382 : "$2", "$3", "$4", "$5", "$6", "$7" ); 383 384 _it_restore(&sr); 385 } // _pysical_memset() 386 360 387 /////////////////////////////////////////////////////////////////////////////////// 361 388 void _io_extended_write( unsigned int* vaddr, … … 378 405 379 406 /////////////////////////////////////////////////////////////////////////////////// 380 // This function is used by all drivers (_xxx_get_register() function)381 // If the MMU is not activated, the virtual address is extended using382 // X_IO and Y_IO to reach the cluster_io.383 ///////////////////////////////////////////////////////////////////////////////////384 407 unsigned int _io_extended_read( unsigned int* vaddr ) 385 408 { … … 402 425 /////////////////////////////////////////////////////////////////////////////////// 403 426 404 ///////////////////////////////////////////////////////////////////////////////////405 // Takes a lock with a blocking ll/sc atomic access.406 // When the cache coherence is granted by the hardware,407 // the first read is a standard (cacheable) lw, as the local copy408 // can be polled when the lock is already taken by another task, reducing409 // trafic on the interconnect. When the lock is released by the owner task,410 // the local copy is updated or invalidated by the coherence protocol.411 // If there is no hardware cache coherence a random delay is introduced412 // betwween two successive retry.413 427 /////////////////////////////////////////////////////////////////////////////////// 414 428 void _get_lock(giet_lock_t* lock) … … 460 474 } 461 475 462 ///////////////////////////////////////////////////////////////////////////////////463 // Release a previouly taken lock.464 476 /////////////////////////////////////////////////////////////////////////////////// 465 477 void _release_lock(giet_lock_t* lock) … … 711 723 { 712 724 unsigned int procid = _get_procid(); 713 unsigned int lpid = procid % NB_PROCS_MAX; 714 unsigned int cluster_xy = procid / NB_PROCS_MAX; 715 unsigned int x = cluster_xy >> Y_WIDTH; 716 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 725 unsigned int x = (procid >> (Y_WIDTH + P_WIDTH)) & ((1<<X_WIDTH)-1); 726 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 727 unsigned int lpid = procid & ((1<<P_WIDTH)-1); 717 728 718 729 _puts("\n\n[GIET ERROR] in _printf() for processor["); … … 744 755 745 756 746 ////////////////////////////////////////////////////////////////////////////// 757 //////////////////////////////////////////////////////////////////////////////////// 747 758 // Scheduler and tasks context access functions 748 ////////////////////////////////////////////////////////////////////////////// 749 750 ////////////////////////////////////////////////////////////////////////////// 751 // Returns index of the currently running task from the processor scheduler. 752 ////////////////////////////////////////////////////////////////////////////// 759 //////////////////////////////////////////////////////////////////////////////////// 760 761 762 //////////////////////////////////////////////////////////////////////////////////// 753 763 unsigned int _get_current_task_id() 754 764 { … … 757 767 } 758 768 //////////////////////////////////////////////////////////////////////////////////// 759 // This function returns the content of a context slot 760 // for a task identified by the ltid argument (local task index), 761 // and the gpid argument (global processor index) 762 //////////////////////////////////////////////////////////////////////////////////// 763 unsigned int _get_task_slot( unsigned int gpid, 769 unsigned int _get_task_slot( unsigned int x, 770 unsigned int y, 771 unsigned int p, 764 772 unsigned int ltid, 765 773 unsigned int slot ) 766 774 { 767 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[ gpid];775 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 768 776 return psched->context[ltid][slot]; 769 777 } 770 778 //////////////////////////////////////////////////////////////////////////////////// 771 // This function updates the content of a context slot 772 // for any task identified by the ltid argument (local task index), 773 // and the gpid argument (global processor index) 774 //////////////////////////////////////////////////////////////////////////////////// 775 void _set_task_slot( unsigned int gpid, 779 void _set_task_slot( unsigned int x, 780 unsigned int y, 781 unsigned int p, 776 782 unsigned int ltid, 777 783 unsigned int slot, 778 784 unsigned int value ) 779 785 { 780 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[ gpid];786 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 781 787 psched->context[ltid][slot] = value; 782 788 } 783 ////////////////////////////////////////////////////////////////////////////////////784 // This function returns the content of a context slot785 // for the running task (defined by the scheduler current field).786 789 //////////////////////////////////////////////////////////////////////////////////// 787 790 unsigned int _get_context_slot( unsigned int slot ) … … 791 794 return psched->context[task_id][slot]; 792 795 } 793 ////////////////////////////////////////////////////////////////////////////////////794 // This function updates the content of a context slot for the running task.795 796 //////////////////////////////////////////////////////////////////////////////////// 796 797 void _set_context_slot( unsigned int slot, … … 968 969 { 969 970 unsigned int procid = _get_procid(); 970 unsigned int lpid = procid % NB_PROCS_MAX; 971 unsigned int cluster_xy = procid / NB_PROCS_MAX; 972 unsigned int x = cluster_xy >> Y_WIDTH; 973 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 971 unsigned int x = (procid >> (Y_WIDTH + P_WIDTH)) & ((1<<X_WIDTH)-1); 972 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 973 unsigned int lpid = procid & ((1<<P_WIDTH)-1); 974 974 975 975
Note: See TracChangeset
for help on using the changeset viewer.