Changeset 165 for soft/giet_vm/sys/common.c
- Timestamp:
- Jul 4, 2012, 2:51:18 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/sys/common.c
r160 r165 9 9 /////////////////////////////////////////////////////////////////////////////////// 10 10 11 #include <sys_handler.h> 11 12 #include <common.h> 12 13 #include <drivers.h> 13 14 #include <stdarg.h> 15 16 //////////////////////////////////////////////////////////////////////////// 17 // _get_lock() 18 //////////////////////////////////////////////////////////////////////////// 19 inline void _get_lock( unsigned int* plock ) 20 { 21 register unsigned int delay = (_proctime() & 0xF) << 4; 22 23 asm volatile ( 24 "_lock_llsc: \n" 25 "ll $2, 0(%0) \n" /* $2 <= _ioc_lock current value */ 26 "bnez $2, _lock_delay \n" /* delay if _ioc_lock already taken */ 27 "li $3, 1 \n" /* $3 <= argument for sc */ 28 "sc $3, 0(%0) \n" /* try to set _ioc_lock */ 29 "bnez $3, _lock_ok \n" /* exit if atomic */ 30 "_lock_delay: \n" 31 "move $4, %1 \n" /* $4 <= delay */ 32 "_lock_loop: \n" 33 "addi $4, $4, -1 \n" /* $4 <= $4 - 1 */ 34 "beqz $4, _lock_loop \n" /* test end delay */ 35 "j _lock_llsc \n" /* retry */ 36 "_lock_ok: \n" 37 : 38 :"r"(plock), "r"(delay) 39 :"$2", "$3", "$4"); 40 } 41 42 //////////////////////////////////////////////////////////////////////////// 43 // _release_lock() 44 //////////////////////////////////////////////////////////////////////////// 45 inline void _release_lock( unsigned int* plock ) 46 { 47 *plock = 0; 48 } 14 49 15 50 //////////////////////////////////////////////////////////////////////////// … … 156 191 return ret; 157 192 } 193 158 194 /////////////////////////////////////////////////////////////////////////////////// 159 195 // _it_mask() … … 163 199 { 164 200 asm volatile( 165 "mfc0 $2, $12 \n" 166 "ori $2, $2, 1 \n" 167 "mtc0 $2, $12 \n" 168 ::: "$2" 201 "lui $27, 0xFFFF \n" 202 "ori $27, $27, 0xFFFE \n" 203 "mfc0 $26, $12 \n" 204 "and $26, $26, $27 \n" 205 "mtc0 $26, $12 \n" 206 ::: "$26", "$27" 169 207 ); 170 208 } … … 176 214 { 177 215 asm volatile( 178 "mfc0 $2 , $12\n"179 " addi $2, $2, -1\n"180 "mtc0 $2 , $12\n"181 ::: "$2 "216 "mfc0 $26, $12 \n" 217 "ori $26, $26, 1 \n" 218 "mtc0 $26, $12 \n" 219 ::: "$26" 182 220 ); 183 221 } 222 184 223 ///////////////////////////////////////////////////////////////////////////// 185 224 // access functions to mapping_info data structure
Note: See TracChangeset
for help on using the changeset viewer.