Changeset 344 for soft/giet_vm/giet_common
- Timestamp:
- Jun 24, 2014, 4:45:30 PM (11 years ago)
- Location:
- soft/giet_vm/giet_common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_common/utils.c
r332 r344 330 330 331 331 _it_disable(&sr); 332 asm volatile( 333 "mfc2 $2, $1 \n" /* $2 <= MMU_MODE */ 334 "andi $3, $2, 0xb \n" 335 "mtc2 $3, $1 \n" /* DTLB off */ 336 337 "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ 338 "lw %0, 0(%1) \n" /* value <= *paddr */ 339 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 340 341 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 342 : "=r" (value) 343 : "r" (lsb), "r" (msb) 344 : "$2", "$3"); 332 333 asm volatile( "mfc2 $2, $1 \n" /* $2 <= MMU_MODE */ 334 "andi $3, $2, 0xb \n" 335 "mtc2 $3, $1 \n" /* DTLB off */ 336 337 "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ 338 "lw %0, 0(%1) \n" /* value <= *paddr */ 339 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 340 341 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 342 : "=r" (value) 343 : "r" (lsb), "r" (msb) 344 : "$2", "$3" ); 345 345 346 _it_restore(&sr); 346 347 return value; … … 358 359 359 360 _it_disable(&sr); 360 asm volatile( 361 "mfc2 $2, $1 \n" /* $2 <= MMU_MODE */ 362 "andi $3, $2, 0xb \n" 363 "mtc2 $3, $1 \n" /* DTLB off */ 364 365 "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ 366 "sw %0, 0(%1) \n" /* *paddr <= value */ 367 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 368 369 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 370 : 371 : "r" (value), "r" (lsb), "r" (msb) 372 : "$2", "$3"); 361 362 asm volatile( "mfc2 $2, $1 \n" /* $2 <= MMU_MODE */ 363 "andi $3, $2, 0xb \n" 364 "mtc2 $3, $1 \n" /* DTLB off */ 365 366 "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ 367 "sw %0, 0(%1) \n" /* *paddr <= value */ 368 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 369 370 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 371 : 372 : "r" (value), "r" (lsb), "r" (msb) 373 : "$2", "$3" ); 374 375 _it_restore(&sr); 376 } 377 378 /////////////////////////////////////////////////////////////////////////////////// 379 // This function makes a memcpy from a source buffer to a destination buffer 380 // using physical addresses, after a temporary DTLB de-activation. 381 // source and destination buffers must be aligned, and size must be 382 // multiple of 4 bytes. 383 /////////////////////////////////////////////////////////////////////////////////// 384 inline void _physical_memcpy( unsigned long long dst_paddr, // dest buffer paddr 385 unsigned long long src_paddr, // source buffer paddr 386 unsigned int size ) // bytes 387 { 388 // check alignment constraints 389 if ( (dst_paddr & 3) || (src_paddr & 3) || (size & 3) ) 390 { 391 _printf("\n[GIET ERROR] in _physical_memcpy() : buffer unaligned\n"); 392 _exit(); 393 } 394 395 unsigned int src_lsb = (unsigned int)src_paddr; 396 unsigned int src_msb = (unsigned int)(src_paddr >> 32); 397 unsigned int dst_lsb = (unsigned int)dst_paddr; 398 unsigned int dst_msb = (unsigned int)(dst_paddr >> 32); 399 unsigned int iter = size>>2; 400 unsigned int data; 401 unsigned int sr; 402 403 _it_disable(&sr); 404 405 asm volatile( "mfc2 $2, $1 \n" /* $2 <= current MMU_MODE */ 406 "andi $3, $2, 0xb \n" /* $3 <= new MMU_MODE */ 407 "mtc2 $3, $1 \n" /* DTLB off */ 408 409 "move $4, %5 \n" /* $4 < iter */ 410 "move $5, %1 \n" /* $5 < src_lsb */ 411 "move $6, %3 \n" /* $6 < src_lsb */ 412 413 "ph_memcpy_loop: \n" 414 "mtc2 %2, $24 \n" /* PADDR_EXT <= src_msb */ 415 "lw %0, 0($5) \n" /* data <= *src_paddr */ 416 "mtc2 %4, $24 \n" /* PADDR_EXT <= dst_msb */ 417 "sw %0, 0($6) \n" /* *dst_paddr <= data */ 418 419 "addi $4, $4, -1 \n" /* iter = iter - 1 */ 420 "addi $5, $5, 4 \n" /* src_lsb += 4 */ 421 "addi $6, $6, 4 \n" /* dst_lsb += 4 */ 422 "bne $4, $0, ph_memcpy_loop \n" 423 "nop \n" 424 425 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 426 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 427 : "=r" (data) 428 : "r" (src_lsb), "r" (src_msb), "r" (dst_lsb), "r"(dst_msb), "r"(iter) 429 : "$2", "$3", "$4", "$5", "$6" ); 430 373 431 _it_restore(&sr); 374 432 } -
soft/giet_vm/giet_common/utils.h
r324 r344 120 120 extern void _physical_write( unsigned long long paddr, 121 121 unsigned int value ); 122 123 extern void _physical_memcpy( unsigned long long dst_paddr, 124 unsigned long long src_paddr, 125 unsigned int size ); 122 126 123 127 extern unsigned int _io_extended_read( unsigned int* vaddr );
Note: See TracChangeset
for help on using the changeset viewer.