Changeset 95 for trunk/hal/tsar_mips32
- Timestamp:
- Jun 29, 2017, 1:40:15 PM (7 years ago)
- Location:
- trunk/hal/tsar_mips32/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_remote.c
r92 r95 154 154 } 155 155 156 ////////////////////////////////////////157 uint32_t hal_remote_lw_unc( xptr_t xp )158 {159 uint32_t data;160 uint32_t ptr = (uint32_t)GET_PTR( xp );161 uint32_t cxy = (uint32_t)GET_CXY( xp );162 163 asm volatile(164 ".set noreorder \n"165 "mfc2 $15, $24 \n" /* $15 <= PADDR_EXT */166 "mtc2 %2, $24 \n" /* PADDR_EXT <= cxy */167 "ll %0, 0(%1) \n" /* data <= *paddr */168 "mtc2 $15, $24 \n" /* PADDR_EXT <= $15 */169 ".set reorder \n"170 : "=r" (data) : "r" (ptr), "r" (cxy) : "$15" );171 172 return ( data );173 }174 175 156 /////////////////////////////////////////// 176 157 bool_t hal_remote_atomic_cas( xptr_t xp, -
trunk/hal/tsar_mips32/core/hal_special.c
r62 r95 42 42 43 43 ///////////////////////// 44 uint32_t hal_time_stamp() 45 { 46 uint32_t cycles; 47 48 asm volatile ("mfc0 %0, $9 " : "=&r" (cycles)); 49 44 uint64_t hal_get_cycles() 45 { 46 uint64_t cycles; // absolute time to be returned 47 uint32_t last_count; // last registered cycles count 48 uint32_t current_count; // current cycles count 49 uint32_t elapsed; 50 51 core_t * core = CURRENT_THREAD->core; 52 53 // get last registered time stamp 54 last_count = core->time_stamp; 55 56 // get current time stamp from hardware register 57 asm volatile ("mfc0 %0, $9 " : "=&r" (current_count)); 58 59 // compute number of elapsed cycles, taking into account 32 bits register wrap 60 if(current_count < last_count) elapsed = (0xFFFFFFFF - last_count) + current_count; 61 else elapsed = current_count - last_count; 62 63 // compute absolute time 64 cycles = core->cycles + elapsed; 65 66 // update core time 67 core->time_stamp = current_count; 68 core->cycles = cycles; 69 70 hal_wbflush(); 71 50 72 return cycles; 51 73 }
Note: See TracChangeset
for help on using the changeset viewer.