Changeset 121 for trunk/hal/tsar_mips32/core
- Timestamp:
- Jul 3, 2017, 2:17:20 PM (7 years ago)
- Location:
- trunk/hal/tsar_mips32/core
- Files:
-
- 3 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_kentry.S
r62 r121 42 42 # - In both cases, when the handler returns: 43 43 # . we restore the context 44 # . we reactivate the MMU ??? 44 # . we reactivate the MMU ??? TODO 45 45 #--------------------------------------------------------------------------------- 46 46 -
trunk/hal/tsar_mips32/core/hal_kentry.h
r62 r121 1 1 /* 2 * cpu-regs.h - mips register map2 * hal_kentry.h - MIPS32 registers mnemonics 3 3 * 4 4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless … … 23 23 #ifndef _HAL_KENTRY_H_ 24 24 #define _HAL_KENTRY_H_ 25 26 /*************************************************************************************** 27 * This file ... TODO 28 **************************************************************************************/ 25 29 26 30 #define KSP 0 … … 66 70 #define CPU_IN_KERNEL 1 67 71 68 #endif /* _HAL_ ENTRY_H_ */72 #endif /* _HAL_KENTRY_H_ */ -
trunk/hal/tsar_mips32/core/hal_remote.c
r95 r121 29 29 uint8_t data ) 30 30 { 31 uint32_t ptr = (uint32_t)GET_PTR( xp ); 32 uint32_t cxy = (uint32_t)GET_CXY( xp ); 31 uint32_t save_sr; 32 uint32_t ptr = (uint32_t)GET_PTR( xp ); 33 uint32_t cxy = (uint32_t)GET_CXY( xp ); 34 35 hal_disable_irq( &save_sr ); 33 36 34 37 asm volatile( … … 41 44 ".set reorder \n" 42 45 : : "r" (data), "r" (ptr), "r" (cxy) : "$15" ); 46 47 hal_restore_irq( save_sr ); 48 43 49 } 44 50 … … 47 53 uint32_t data ) 48 54 { 49 uint32_t ptr = (uint32_t)GET_PTR( xp ); 50 uint32_t cxy = (uint32_t)GET_CXY( xp ); 55 uint32_t save_sr; 56 uint32_t ptr = (uint32_t)GET_PTR( xp ); 57 uint32_t cxy = (uint32_t)GET_CXY( xp ); 58 59 hal_disable_irq( &save_sr ); 51 60 52 61 asm volatile( "mfc2 $15, $24 \n" /* $15 <= PADDR_EXT */ … … 58 67 ".set reorder \n" 59 68 : : "r" (data), "r" (ptr), "r" (cxy) : "$15" ); 69 70 hal_restore_irq( save_sr ); 71 60 72 } 61 73 … … 64 76 uint64_t data ) 65 77 { 78 uint32_t save_sr; 66 79 uint32_t ptr = (uint32_t)GET_PTR( xp ); 67 80 uint32_t cxy = (uint32_t)GET_CXY( xp ); … … 69 82 uint32_t data_lsb = (uint32_t)data; 70 83 uint32_t data_msb = (uint32_t)(data>>32); 84 85 hal_disable_irq( &save_sr ); 71 86 72 87 asm volatile( … … 80 95 ".set reorder \n" 81 96 : : "r" (data_lsb), "r" (data_msb), "r" (ptr), "r" (cxy) : "$15" ); 97 98 hal_restore_irq( save_sr ); 99 82 100 } 83 101 … … 92 110 uint8_t hal_remote_lb( xptr_t xp ) 93 111 { 112 uint32_t save_sr; 94 113 char data; 95 114 uint32_t ptr = (uint32_t)GET_PTR( xp ); 96 115 uint32_t cxy = (uint32_t)GET_CXY( xp ); 116 117 hal_disable_irq( &save_sr ); 97 118 98 119 asm volatile( … … 105 126 : "=r" (data) : "r" (ptr), "r" (cxy) : "$15" ); 106 127 128 hal_restore_irq( save_sr ); 129 107 130 return ( data ); 108 131 } … … 111 134 uint32_t hal_remote_lw( xptr_t xp ) 112 135 { 136 uint32_t save_sr; 113 137 uint32_t data; 114 138 uint32_t ptr = (uint32_t)GET_PTR( xp ); 115 139 uint32_t cxy = (uint32_t)GET_CXY( xp ); 140 141 hal_disable_irq( &save_sr ); 116 142 117 143 asm volatile( … … 124 150 : "=r" (data) : "r" (ptr), "r" (cxy) : "$15" ); 125 151 152 hal_restore_irq( save_sr ); 153 126 154 return ( data ); 127 155 } … … 130 158 uint64_t hal_remote_lwd( xptr_t xp ) 131 159 { 160 uint32_t save_sr; 132 161 uint32_t data_lsb; 133 162 uint32_t data_msb; 134 163 uint32_t ptr = (uint32_t)GET_PTR( xp ); 135 164 uint32_t cxy = (uint32_t)GET_CXY( xp ); 165 166 hal_disable_irq( &save_sr ); 136 167 137 168 asm volatile( … … 145 176 : "=r" (data_lsb), "=r"(data_msb) : "r" (ptr), "r" (cxy) : "$15" ); 146 177 178 hal_restore_irq( save_sr ); 179 147 180 return ( (((uint64_t)data_msb)<<32) + (((uint64_t)data_lsb)) ); 181 148 182 } 149 183 … … 159 193 uint32_t new ) 160 194 { 195 uint32_t save_sr; 161 196 bool_t isAtomic; 162 197 uint32_t ptr = (uint32_t)GET_PTR( xp ); 163 198 uint32_t cxy = (uint32_t)GET_CXY( xp ); 199 200 hal_disable_irq( &save_sr ); 164 201 165 202 asm volatile( … … 181 218 : "$3", "$7", "$8", "$15" ); 182 219 220 hal_restore_irq( save_sr ); 221 183 222 return isAtomic; 184 } 223 224 } // end hal_remote_atomic_cas() 185 225 186 226 //////////////////////////////////////////// … … 188 228 uint32_t incr ) 189 229 { 230 uint32_t save_sr; 190 231 uint32_t current; 191 232 uint32_t ptr = (uint32_t)GET_PTR( xp ); 192 233 uint32_t cxy = (uint32_t)GET_CXY( xp ); 234 235 hal_disable_irq( &save_sr ); 193 236 194 237 asm volatile( … … 206 249 : "=&r" (current) : "r" (ptr), "r" (incr), "r" (cxy) : "$3", "$15" ); 207 250 251 hal_restore_irq( save_sr ); 252 208 253 return current; 209 } 254 255 } // end hal_remote_atomic_add() 210 256 211 257 //////////////////////////////////////////// … … 213 259 uint32_t mask ) 214 260 { 261 uint32_t save_sr; 215 262 uint32_t current; 216 263 uint32_t ptr = (uint32_t)GET_PTR( xp ); 217 264 uint32_t cxy = (uint32_t)GET_CXY( xp ); 265 266 hal_disable_irq( &save_sr ); 218 267 219 268 asm volatile( … … 231 280 : "=&r" (current) : "r" (ptr), "r" (mask), "r" (cxy) : "$3", "$15" ); 232 281 282 hal_restore_irq( save_sr ); 283 233 284 return current; 234 } 285 286 } // end hal_remote_atomic_and() 235 287 236 288 //////////////////////////////////////////// … … 238 290 uint32_t mask ) 239 291 { 292 uint32_t save_sr; 240 293 uint32_t current; 241 294 uint32_t ptr = (uint32_t)GET_PTR( xp ); 242 295 uint32_t cxy = (uint32_t)GET_CXY( xp ); 296 297 hal_disable_irq( &save_sr ); 243 298 244 299 asm volatile( … … 256 311 : "=&r" (current) : "r" (ptr), "r" (mask), "r" (cxy) : "$3", "$15" ); 257 312 313 hal_restore_irq( save_sr ); 314 258 315 return current; 259 } 316 317 } // end hal_remote_atomic_or() 260 318 261 319 ///////////////////////////////////////////////// … … 264 322 uint32_t * old ) 265 323 { 324 uint32_t save_sr; 266 325 uint32_t current; 267 326 error_t error; 268 327 uint32_t ptr = (uint32_t)GET_PTR( xp ); 269 328 uint32_t cxy = (uint32_t)GET_CXY( xp ); 329 330 hal_disable_irq( &save_sr ); 270 331 271 332 asm volatile( … … 277 338 "sc $3, (%2) \n" /* *paddr <= $3 */ 278 339 "beq $3, $0, 1f \n" /* exit if failure */ 279 "ori %1, $0, 1 \n" 280 "and %1, $0, $0 \n" 340 "ori %1, $0, 1 \n" /* fail: ret <= 1 */ 341 "and %1, $0, $0 \n" /* success: ret <= 0 */ 281 342 "1: \n" 282 343 "mtc2 $15, $24 \n" /* PADDR_EXT <= $15 */ … … 284 345 : "=&r" (current), "=&r" (error) : "r" (ptr), "r" (incr), "r" (cxy) : "$3", "$15" ); 285 346 347 hal_restore_irq( save_sr ); 348 286 349 *old = current; 287 350 288 351 return error; 289 } 352 353 } // end hal_remote_atomic_try_add() 290 354 291 355 ///////////////////////////////////// … … 294 358 uint32_t size ) 295 359 { 360 uint32_t save_sr; 296 361 uint32_t i; 297 362 uint32_t wsize; … … 300 365 uint32_t sptr = (uint32_t)GET_PTR( src ); 301 366 uint32_t scxy = (uint32_t)GET_CXY( src ); 367 368 hal_disable_irq( &save_sr ); 302 369 303 370 if( (dptr & 0x3) || (sptr & 0x3) ) wsize = 0; // do it all in bytes … … 331 398 : : "r"(scxy), "r" (sptr+i), "r"(dcxy), "r" (dptr+i) : "$3", "$15" ); 332 399 } 333 } 334 335 400 401 hal_restore_irq( save_sr ); 402 403 } // end hal_remote_memcpy() 404 405 /////////////////////////////////// 406 void hal_remote_strcpy( xptr_t dst, 407 xptr_t src ) 408 { 409 uint32_t save_sr; 410 uint32_t dptr = (uint32_t)GET_PTR( dst ); 411 uint32_t dcxy = (uint32_t)GET_CXY( dst ); 412 uint32_t sptr = (uint32_t)GET_PTR( src ); 413 uint32_t scxy = (uint32_t)GET_CXY( src ); 414 415 hal_disable_irq( &save_sr ); 416 417 // loop on characters while non NUL 418 asm volatile( 419 "mfc2 $15, $24 \n" /* $15 <= PADDR_EXT */ 420 "1: \n" /* loop entry */ 421 "mtc2 %0, $24 \n" /* PADDR_EXT <= scxy */ 422 "lb $13, 0(%1) \n" /* read char from src string */ 423 "mtc2 %2, $24 \n" /* PADDR_EXT <= dcxy */ 424 "sb $13, 0(%3) \n" /* store char to dst string */ 425 "addi %1, %1, 1 \n" /* increment sptr pointer */ 426 "addi %3, %3, 1 \n" /* increment dptr pointer */ 427 "bne $13, $0, 1b \n" /* test NUL */ 428 "nop \n" 429 "mtc2 $15, $24 \n" /* PADDR_EXT <= $15 */ 430 : : "r"(scxy), "r"(sptr), "r"(dcxy), "r"(dptr) : "$13","$15", "memory" ); 431 432 hal_restore_irq( save_sr ); 433 434 } // end hal_remote_strcpy() -
trunk/hal/tsar_mips32/core/hal_special.c
r101 r121 33 33 34 34 35 /////////////////// 36 gid_t hal_get_gid()35 ////////////////////////// 36 inline gid_t hal_get_gid() 37 37 { 38 38 uint32_t proc_id; … … 41 41 42 42 return (proc_id & 0x3FF); // 4/4/2 format for TSAR 43 } 44 45 //////////////////////////////// 46 inline cycle_t hal_time_stamp() 47 { 48 cycle_t count; 49 50 asm volatile ("mfc0 %0, $9 " : "=&r" (count)); 51 52 return count; 43 53 } 44 54 … … 57 67 58 68 // get current time stamp from hardware register 59 asm volatile ("mfc0 %0, $9 " : "=&r" (current_count));69 current_count = hal_time_stamp(); 60 70 61 71 // compute number of elapsed cycles, taking into account 32 bits register wrap … … 75 85 } 76 86 77 ////////////////////////////////////////// 78 struct thread_s * hal_get_current_thread()87 ///////////////////////////////////////////////// 88 inline struct thread_s * hal_get_current_thread() 79 89 { 80 90 void * thread_ptr; -
trunk/hal/tsar_mips32/core/hal_uspace.c
r87 r121 128 128 129 129 ////////////////////////////////////////// 130 void hal_strcpy_from_uspace( char * k_dst, 131 char * u_src ) 132 133 { 130 void hal_strcpy_from_uspace( char * k_dst, 131 char * u_src, 132 uint32_t max_size ) 133 134 { 135 136 // TODO implement the max_size handling 137 134 138 uint32_t save_sr; 135 139 uint32_t src = (uint32_t)u_src; … … 157 161 } // hal_strcpy_from_uspace() 158 162 159 ////////////////////////////////////////// 160 void hal_strcpy_to_uspace( char * u_dst, 161 char * k_src ) 162 163 { 163 //////////////////////////////////////////// 164 void hal_strcpy_to_uspace( char * u_dst, 165 char * k_src, 166 uint32_t max_size ) 167 { 168 169 // TODO implement the max_size handling 170 164 171 uint32_t save_sr; 165 172 uint32_t src = (uint32_t)k_src;
Note: See TracChangeset
for help on using the changeset viewer.