Changeset 345 for soft/giet_vm/giet_common
- Timestamp:
- Jun 25, 2014, 2:19:37 PM (10 years ago)
- Location:
- soft/giet_vm/giet_common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_common/io.h
r289 r345 40 40 { 41 41 *(volatile unsigned int *) addr = value; 42 asm volatile("sync" );42 asm volatile("sync" ::: "memory"); 43 43 } 44 44 … … 49 49 { 50 50 *(volatile unsigned short *) addr = value; 51 asm volatile("sync" );51 asm volatile("sync" ::: "memory"); 52 52 } 53 53 … … 58 58 { 59 59 *(volatile unsigned char *) addr = value; 60 asm volatile("sync" );60 asm volatile("sync" ::: "memory"); 61 61 } 62 62 -
soft/giet_vm/giet_common/utils.c
r344 r345 44 44 // Code taken from MutekH. 45 45 /////////////////////////////////////////////////////////////////////////////////// 46 inline void* _memcpy( void* dest, // dest buffer vbase47 48 46 inline void* memcpy( void* dest, // dest buffer vbase 47 const void* source, // source buffer vbase 48 unsigned int size ) // bytes 49 49 { 50 50 unsigned int* idst = (unsigned int*)dest; … … 74 74 // Fill a byte string with a byte value. 75 75 ////////////////////////////////////////////////////////////////////////////////// 76 inline void * _memset( void* dest,77 78 76 inline void * memset( void* dest, 77 int value, 78 unsigned int count ) 79 79 { 80 80 // word-by-word copy … … 119 119 // Processor suicide: infinite loop 120 120 ////////////////////////////////////////////////////////////////////////////////// 121 __attribute__((noreturn)) 121 122 inline void _exit() 122 123 { … … 251 252 inline void _it_disable( unsigned int * save_sr_ptr) 252 253 { 253 unsigned int sr ;254 unsigned int sr = 0; 254 255 asm volatile( "li $3, 0xFFFFFFFE \n" 255 256 "mfc0 %0, $12 \n" 256 257 "and $3, $3, %0 \n" 257 258 "mtc0 $3, $12 \n" 258 : " =r"(sr)259 : "+r"(sr) 259 260 : 260 : "$3" , "memory");261 : "$3" ); 261 262 *save_sr_ptr = sr; 262 263 } … … 292 293 asm volatile ( "mtc2 %0, $0 \n" 293 294 : 294 :"r" (val) ); 295 :"r" (val) 296 :"memory" ); 295 297 } 296 298 ////////////////////////////////////////////////////////////////////////////// … … 301 303 asm volatile ( "mtc2 %0, $1 \n" 302 304 : 303 :"r" (val) ); 305 :"r" (val) 306 :"memory" ); 304 307 } 305 308 ////////////////////////////////////////////////////////////////////////////// … … 369 372 370 373 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 374 "sync \n" 371 375 : 372 376 : "r" (value), "r" (lsb), "r" (msb) … … 516 520 : 517 521 :"r"(plock), "r"(delay) 518 :"$2", "$3", "$4" );522 :"$2", "$3", "$4", "memory"); 519 523 #else 520 524 … … 532 536 : 533 537 :"r"(plock) 534 :"$2", "$3" );538 :"$2", "$3", "memory"); 535 539 #endif 536 540 -
soft/giet_vm/giet_common/utils.h
r344 r345 62 62 /////////////////////////////////////////////////////////////////////////////////// 63 63 64 extern void* _memcpy( void* _dst,65 66 67 68 extern void* _memset( void* dst,69 70 64 extern void* memcpy( void* _dst, 65 const void* _src, 66 unsigned int size ); 67 68 extern void* memset( void* dst, 69 int s, 70 unsigned int count ); 71 71 72 72 /////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/giet_common/vmem.c
r295 r345 95 95 unsigned long long pte2_paddr; 96 96 97 registerunsigned int pte2_msb;98 registerunsigned int pte2_lsb;99 registerunsigned int flags_value;100 registerunsigned int ppn_value;97 volatile unsigned int pte2_msb; 98 volatile unsigned int pte2_lsb; 99 unsigned int flags_value; 100 unsigned int ppn_value; 101 101 102 102 unsigned int ix1 = vpn >> 9; 103 103 unsigned int ix2 = vpn & 0x1FF; 104 105 unsigned int save_sr; 104 106 105 107 // get PTE1 … … 110 112 111 113 // get physical addresses of pte2 (two 32 bits words) 112 ptba = (unsigned long long) (pt ->pt1[ix1]& 0x0FFFFFFF) << 12;114 ptba = (unsigned long long) (pte1 & 0x0FFFFFFF) << 12; 113 115 pte2_paddr = ptba + 8*ix2; 114 116 pte2_lsb = (unsigned int) pte2_paddr; 115 117 pte2_msb = (unsigned int) (pte2_paddr >> 32); 116 118 119 // disable interrupts and save status register 120 _it_disable( &save_sr ); 121 117 122 // gets ppn_value and flags_value, after temporary DTLB desactivation 118 123 asm volatile ( 119 "li $2, 0xFFFFFFFE \n" /* Mask for IE bits */ 120 "mfc0 $4, $12 \n" /* $4 <= SR */ 121 "and $2, $2, $4 \n" 122 "mtc0 $2, $12 \n" /* disable Interrupts */ 123 124 "li $3, 0xB \n" 125 "mtc2 $3, $1 \n" /* DTLB unactivated */ 124 "mfc2 $2, $1 \n" /* $2 <= MMU_MODE */ 125 "andi $3, $2, 0xb \n" 126 "mtc2 $3, $1 \n" /* DTLB off */ 126 127 127 128 "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ … … 130 131 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 131 132 132 "li $3, 0xF \n" 133 "mtc2 $3, $1 \n" /* DTLB activated */ 133 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 134 : "=r" (flags_value), "=r" (ppn_value) 135 : "r" (pte2_msb) , "r" (pte2_lsb) 136 : "$2", "$3"); 134 137 135 "mtc0 $4, $12 \n" /* restore SR */ 136 : "=r" (flags_value), "=r" (ppn_value) 137 : "r" (pte2_msb), "r" (pte2_lsb) 138 : "$2","$3","$4"); 138 // restore saved status register 139 _it_restore( &save_sr ); 139 140 140 141 // check PTE2 mapping … … 142 143 143 144 // set return values 144 *ppn = ppn_value;145 *ppn = ppn_value; 145 146 *flags = flags_value; 147 146 148 return 0; 147 149 } // end _v2p_translate()
Note: See TracChangeset
for help on using the changeset viewer.