Changeset 351 for soft/giet_vm/giet_common
- Timestamp:
- Jun 29, 2014, 1:07:43 PM (10 years ago)
- Location:
- soft/giet_vm/giet_common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_common/utils.c
r345 r351 494 494 // betwween two successive retry. 495 495 /////////////////////////////////////////////////////////////////////////////////// 496 inline void _get_lock(unsigned int * plock) 497 { 496 inline void _get_lock(giet_lock_t* lock) 497 { 498 register unsigned int* plock = &(lock->value); 499 498 500 #if NO_HARD_CC 499 501 500 register unsigned int delay = ( _get_proctime() ^ _get_procid() << 4) & 0xFF; 501 502 if (delay == 0) delay++; 502 register unsigned int delay = (_get_proctime() ^ _get_procid() << 4) & 0xFF; 503 if (delay == 0) delay = 0x80; 503 504 504 505 asm volatile ( 505 506 "_lock_llsc: \n" 506 " ll $2, 0(%0) \n" /* $2 <= _ioc_lock current value*/507 " bnez $2, _lock_delay \n" /* delay if _ioc_lock already taken*/508 " li $3, 1 \n" /* $3 <= argument for sc*/509 " sc $3, 0(%0) \n" /* try to set _ioc_lock*/510 " bnez $3, _lock_ok \n" /* exit if atomic*/511 " _lock_delay: \n"512 " move $4, %1 \n" /* $4 <= delay*/513 " _lock_loop: \n"514 " addi $4, $4, -1 \n" /* $4 <= $4 - 1*/515 " bnez $4, _lock_loop \n" /* test end delay*/516 " nop \n"517 " j _lock_llsc \n" /* retry*/518 " nop \n"519 " _lock_ok: \n"507 " ll $2, 0(%0) \n" /* $2 <= lock current value */ 508 " bnez $2, _lock_delay \n" /* delay if lock already taken */ 509 " li $3, 1 \n" /* $3 <= argument for sc */ 510 " sc $3, 0(%0) \n" /* try to set lock */ 511 " bnez $3, _lock_ok \n" /* exit if atomic */ 512 " _lock_delay: \n" 513 " move $4, %1 \n" /* $4 <= delay */ 514 " _lock_loop: \n" 515 " addi $4, $4, -1 \n" /* $4 <= $4 - 1 */ 516 " bnez $4, _lock_loop \n" /* test end delay */ 517 " nop \n" 518 " j _lock_llsc \n" /* retry */ 519 " nop \n" 520 " _lock_ok: \n" 520 521 : 521 522 :"r"(plock), "r"(delay) … … 525 526 asm volatile ( 526 527 "_lock_llsc: \n" 527 " lw $2, 0(%0) \n" /* dcache <= _ioc_lock current value*/528 " bnez $2, _lock_llsc \n" /* retry if lock already taken 528 " lw $2, 0(%0) \n" /* $2 <= lock current value */ 529 " bnez $2, _lock_llsc \n" /* retry if lock already taken */ 529 530 " nop \n" 530 " ll $2, 0(%0) \n" /* ll_buffer <= _ioc_lock current value*/531 " bnez $2, _lock_llsc \n" /* retry if _ioc_lock already taken*/532 " li $3, 1 \n" /* $3 <= argument for sc 533 " sc $3, 0(%0) \n" /* try to set _ioc_lock*/534 " beqz $3, _lock_llsc \n" /* retry if sc failure 531 " ll $2, 0(%0) \n" /* ll_buffer <= lock current value */ 532 " bnez $2, _lock_llsc \n" /* retry if lock already taken */ 533 " li $3, 1 \n" /* $3 <= argument for sc */ 534 " sc $3, 0(%0) \n" /* try to set lock */ 535 " beqz $3, _lock_llsc \n" /* retry if sc failure */ 535 536 " nop \n" 536 537 : … … 539 540 #endif 540 541 541 // register unsigned int delay = ( _get_proctime() ^ _get_procid() << 4) & 0xFF;542 543 // if (delay == 0) delay++;544 545 // asm volatile (546 // "_lock_llsc: \n"547 // "ll $2, 0(%0) \n" /* $2 <= _ioc_lock current value */548 // "bnez $2, _lock_delay \n" /* delay if _ioc_lock already taken */549 // "li $3, 1 \n" /* $3 <= argument for sc */550 // "sc $3, 0(%0) \n" /* try to set _ioc_lock */551 // "bnez $3, _lock_ok \n" /* exit if atomic */552 // "_lock_delay: \n"553 // "move $4, %1 \n" /* $4 <= delay */554 // "_lock_loop: \n"555 // "addi $4, $4, -1 \n" /* $4 <= $4 - 1 */556 // "bnez $4, _lock_loop \n" /* test end delay */557 // "nop \n"558 // "j _lock_llsc \n" /* retry */559 // "nop \n"ache560 // "_lock_ok: \n"561 // :562 // :"r"(plock), "r"(delay)563 // :"$2", "$3", "$4");564 565 542 } 566 543 … … 568 545 // Release a previouly taken lock. 569 546 /////////////////////////////////////////////////////////////////////////////////// 570 inline void _release_lock( unsigned int * plock)547 inline void _release_lock(giet_lock_t* lock) 571 548 { 572 549 asm volatile ( "sync\n" ::: "memory" ); 573 550 // sync is necessary because of the TSAR consistency model 574 *plock= 0;551 lock->value = 0; 575 552 } 576 553 … … 653 630 char buf[11]; 654 631 unsigned int i; 655 unsigned int first ;632 unsigned int first = 0; 656 633 657 634 buf[10] = 0; 658 635 659 for (i = 0; i < 10; i++) { 660 if ((val != 0) || (i == 0)) { 636 for (i = 0; i < 10; i++) 637 { 638 if ((val != 0) || (i == 0)) 639 { 661 640 buf[9 - i] = DecTab[val % 10]; 662 641 first = 9 - i; 663 642 } 664 else { 643 else 644 { 665 645 break; 666 646 } -
soft/giet_vm/giet_common/utils.h
r345 r351 24 24 25 25 /////////////////////////////////////////////////////////////////////////////////// 26 // For retrieving base addresses defined in seg.ld file. 26 // This structure is used to have one single lock in a cache line 27 /////////////////////////////////////////////////////////////////////////////////// 28 29 typedef struct giet_lock_s { unsigned int value; 30 unsigned int padding[15]; } giet_lock_t; 31 32 /////////////////////////////////////////////////////////////////////////////////// 33 // To access the virtual addresses defined in the giet_vsegs.ld file. 27 34 /////////////////////////////////////////////////////////////////////////////////// 28 35 29 36 typedef struct _ld_symbol_s _ld_symbol_t; 30 37 31 // boot segments vbase addresses & sizes32 38 extern _ld_symbol_t boot_code_vbase; 33 extern _ld_symbol_t boot_code_size;34 35 39 extern _ld_symbol_t boot_data_vbase; 36 extern _ld_symbol_t boot_data_size; 37 38 extern _ld_symbol_t boot_stack_vbase; 39 extern _ld_symbol_t boot_stack_size; 40 41 extern _ld_symbol_t boot_mapping_vbase; 42 extern _ld_symbol_t boot_mapping_size; 43 44 extern _ld_symbol_t boot_buffer_vbase; 45 extern _ld_symbol_t boot_buffer_size; 46 47 // kernel segments vbase addresses & sizes 40 48 41 extern _ld_symbol_t kernel_code_vbase; 49 extern _ld_symbol_t kernel_code_size;50 51 42 extern _ld_symbol_t kernel_data_vbase; 52 extern _ld_symbol_t kernel_data_size;53 54 43 extern _ld_symbol_t kernel_uncdata_vbase; 55 extern _ld_symbol_t kernel_uncdata_size;56 57 44 extern _ld_symbol_t kernel_init_vbase; 58 extern _ld_symbol_t kernel_init_size;59 45 60 46 /////////////////////////////////////////////////////////////////////////////////// … … 134 120 /////////////////////////////////////////////////////////////////////////////////// 135 121 136 extern void _get_lock( unsigned int* lock);137 extern void _release_lock( unsigned int* lock);122 extern void _get_lock(giet_lock_t* lock); 123 extern void _release_lock(giet_lock_t* lock); 138 124 139 125 /////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/giet_common/vmem.c
r345 r351 95 95 unsigned long long pte2_paddr; 96 96 97 volatileunsigned int pte2_msb;98 volatileunsigned int pte2_lsb;97 unsigned int pte2_msb; 98 unsigned int pte2_lsb; 99 99 unsigned int flags_value; 100 100 unsigned int ppn_value; … … 126 126 "mtc2 $3, $1 \n" /* DTLB off */ 127 127 128 "move $4, %3 \n" /* $4 <= pte_lsb */ 128 129 "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ 129 "lw %0, 0( %3) \n" /* read flags */130 "lw %1, 4( %3) \n" /* read ppn */130 "lw %0, 0($4) \n" /* read flags */ 131 "lw %1, 4($4) \n" /* read ppn */ 131 132 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 132 133 … … 134 135 : "=r" (flags_value), "=r" (ppn_value) 135 136 : "r" (pte2_msb) , "r" (pte2_lsb) 136 : "$2", "$3" );137 : "$2", "$3", "$4" ); 137 138 138 139 // restore saved status register
Note: See TracChangeset
for help on using the changeset viewer.