Changeset 238 for soft/giet_vm/sys/vm_handler.c
- Timestamp:
- May 29, 2013, 1:24:09 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/sys/vm_handler.c
r228 r238 8 8 // They contains the kernel data structures and functions used to dynamically 9 9 // handle the iommu page table. 10 //11 // TODO : We must transfer here the functions used to statically build12 // the page tables associated to the various vspaces (now in boot_handler.c)13 //14 10 /////////////////////////////////////////////////////////////////////////////////// 15 11 … … 18 14 #include <common.h> 19 15 #include <giet_config.h> 16 #include <drivers.h> 20 17 21 18 ///////////////////////////////////////////////////////////////////////////// … … 88 85 // Returns 0 if success, 1 if PTE1 or PTE2 unmapped 89 86 ////////////////////////////////////////////////////////////////////////////// 90 unsigned int _v2p_translate( 91 page_table_t * pt, 92 unsigned int vpn, 93 unsigned int * ppn, 94 unsigned int * flags) { 95 unsigned int ptba; 96 register unsigned int * pte2; 97 register unsigned int flags_value; 98 register unsigned int ppn_value; 87 unsigned int _v2p_translate( page_table_t* pt, 88 unsigned int vpn, 89 unsigned int* ppn, 90 unsigned int* flags ) 91 { 92 paddr_t ptba; 93 paddr_t pte2; 94 95 register unsigned int pte2_msb; 96 register unsigned int pte2_lsb; 97 register unsigned int flags_value; 98 register unsigned int ppn_value; 99 99 100 100 unsigned int ix1 = vpn >> 9; 101 101 unsigned int ix2 = vpn & 0x1FF; 102 /* 103 _puts("\n\n********************** entering v2p_translate"); 104 _puts("\n - pt = "); 105 _putx( (unsigned int)pt ); 106 _puts("\n - vpn = "); 107 _putx( vpn << 12 ); 108 _puts("\n - ptba = "); 109 _putx( pt->pt1[ix1] << 12 ) ; 110 _puts("\n - &pte2 = "); 111 _putx( (pt->pt1[ix1] << 12) + 8*ix2 ); 112 _puts("\n - flags = "); 113 _putx( *(unsigned int*)((pt->pt1[ix1] << 12) + 8*ix2) ); 114 _puts("\n"); 115 */ 102 116 103 // check PTE1 mapping 117 if ((pt->pt1[ix1] & PTE_V) == 0) { 118 return 1; 119 } 120 else { 104 if ((pt->pt1[ix1] & PTE_V) == 0) return 1; 105 else 106 { 121 107 // get physical addresses of pte2 122 ptba = pt->pt1[ix1] << 12; 123 pte2 = (unsigned int *) (ptba + 8 * ix2); 108 ptba = (paddr_t)(pt->pt1[ix1] & 0x0FFFFFFF) << 12; 109 pte2 = ptba + 8*ix2; 110 pte2_lsb = (unsigned int)pte2; 111 pte2_msb = (unsigned int)(pte2 >> 32); 124 112 125 113 // gets ppn_value and flags_value, after temporary DTLB desactivation 126 114 asm volatile ( 127 "li $2 7,0xFFFFFFFE \n" /* Mask for IE bits */128 "mfc0 $ 26, $12 \n" /* save SR*/129 "and $2 7, $26, $27\n"130 "mtc0 $2 7,$12 \n" /* disable Interrupts */115 "li $2, 0xFFFFFFFE \n" /* Mask for IE bits */ 116 "mfc0 $4, $12 \n" /* $4 <= SR */ 117 "and $2, $2, $4 \n" 118 "mtc0 $2, $12 \n" /* disable Interrupts */ 131 119 132 "li $ 27,0xB \n"133 "mtc2 $ 27,$1 \n" /* DTLB unactivated */120 "li $3, 0xB \n" 121 "mtc2 $3, $1 \n" /* DTLB unactivated */ 134 122 135 "move $27, %2 \n" /* $27 <= pte2 */ 136 "lw %0, 0($27) \n" /* read flags */ 137 "lw %1, 4($27) \n" /* read ppn */ 123 "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ 124 "lw %0, 0(%3) \n" /* read flags */ 125 "lw %1, 4(%3) \n" /* read ppn */ 126 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 138 127 139 "li $ 27,0xF \n"140 "mtc2 $ 27,$1 \n" /* DTLB activated */128 "li $3, 0xF \n" 129 "mtc2 $3, $1 \n" /* DTLB activated */ 141 130 142 "mtc0 $ 26,$12 \n" /* restore SR */131 "mtc0 $4, $12 \n" /* restore SR */ 143 132 : "=r" (flags_value), "=r" (ppn_value) 144 : "r" (pte2 )145 : "$2 6","$27","$8");133 : "r" (pte2_msb), "r" (pte2_lsb) 134 : "$2","$3","$4"); 146 135 147 136 // check PTE2 mapping 148 if ((flags_value & PTE_V) == 0) { 149 return 1; 150 } 137 if ((flags_value & PTE_V) == 0) return 1; 151 138 152 139 // set return values
Note: See TracChangeset
for help on using the changeset viewer.