Changeset 351 for soft/giet_vm/giet_common/utils.c
- Timestamp:
- Jun 29, 2014, 1:07:43 PM (10 years ago)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.