- Timestamp:
- Oct 9, 2011, 12:31:39 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/softs/giet_tsar/drivers.c
r176 r178 591 591 // I/O BLOCK_DEVICE 592 592 // The three functions below use the three variables _ioc_lock _ioc_done, 593 // and _ioc_status for synchron sation.593 // and _ioc_status for synchronisation. 594 594 // - As the IOC component can be used by several programs running in parallel, 595 595 // the _ioc_lock variable guaranties exclusive access to the device. … … 614 614 in_drivers void _ioc_get_lock() 615 615 { 616 register unsigned int delay = (_proctime() & 0xF) << 4;617 616 register unsigned int* plock = (unsigned int*)&_ioc_lock; 618 617 619 asm volatile ("_ioc_llsc: 618 asm volatile ("_ioc_llsc: \n" 620 619 "ll $2, 0(%0) \n" // $2 <= _ioc_lock 621 "bnez $2, _ioc_ delay \n" // random delayif busy622 "li $3, 1 620 "bnez $2, _ioc_llsc \n" // retry if busy 621 "li $3, 1 \n" // prepare argument for sc 623 622 "sc $3, 0(%0) \n" // try to set _ioc_busy 624 "bnez $3, _ioc_ok \n" // exit if atomic 625 "_ioc_delay: \n" 626 "move $4, %1 \n" // $4 <= delay 627 "_ioc_loop: \n" 628 "addi $4, $4, -1 \n" // $4 <= $4 - 1 629 "beqz $4, _ioc_loop \n" // test end delay 630 "j _ioc_llsc \n" // retry 631 "_ioc_ok: \n" 632 ::"r"(plock),"r"(delay):"$2","$3","$4"); 623 "beqz $3, _ioc_llsc \n" // retry if not atomic 624 ::"r"(plock):"$2","$3"); 633 625 } 634 626 ////////////////////////////////////////////////////////////////////////////////////// … … 924 916 // output : count = _barrier_count[index] (before decrementation) 925 917 asm volatile ("_barrier_decrement: \n" 926 "or $2, %1, $0 \n" 927 "ll %0, 0($2) \n" 918 "ll %0, 0(%1) \n" 928 919 "addi $3, %0, -1 \n" 929 "sc $3, 0( $2) \n"920 "sc $3, 0(%1) \n" 930 921 "beqz $3, _barrier_decrement \n" 931 :"=r"(count):"r"(pcount):"$2","$3"); 922 :"=&r"(count) 923 :"r"(pcount) 924 :"$2","$3"); 932 925 933 926 // the last task re-initializes the barrier_ count variable
Note: See TracChangeset
for help on using the changeset viewer.