Changeset 534 for soft/giet_vm/giet_common/vmem.c
- Timestamp:
- Mar 27, 2015, 12:24:12 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_common/vmem.c
r495 r534 9 9 #include <utils.h> 10 10 #include <vmem.h> 11 #include <ctx_handler.h> 11 12 #include <giet_config.h> 12 13 13 ///////////////////////////////////////// 14 void _v2p_translate( page_table_t* ptab, 15 unsigned int vpn, 16 unsigned int* ppn, 17 unsigned int* flags ) 14 /////////////////////////////////////////////////////// 15 unsigned long long _v2p_translate( unsigned int vaddr, 16 unsigned int* flags ) 18 17 { 19 18 unsigned long long ptba; … … 25 24 unsigned int ppn_value; 26 25 27 unsigned int ix1 = vpn >> 9; 28 unsigned int ix2 = vpn & 0x1FF; 26 unsigned int save_sr; 27 28 // decode the vaddr fields 29 unsigned int offset = vaddr & 0xFFF; 30 unsigned int ix1 = (vaddr >> 21) & 0x7FF; 31 unsigned int ix2 = (vaddr >> 12) & 0x1FF; 29 32 30 unsigned int save_sr; 33 // get page table vbase address 34 page_table_t* pt = (page_table_t*)_get_context_slot(CTX_PTAB_ID); 31 35 32 36 // get PTE1 33 unsigned int pte1 = pt ab->pt1[ix1];37 unsigned int pte1 = pt->pt1[ix1]; 34 38 35 39 // check PTE1 mapping … … 37 41 { 38 42 _printf("\n[VMEM ERROR] _v2p_translate() : pte1 unmapped\n" 39 " v pn= %x / ptab = %x / pte1_vaddr = %x / pte1_value = %x\n",40 v pn , (unsigned int)ptab, &(ptab->pt1[ix1]) , pte1 );43 " vaddr = %x / ptab = %x / pte1_vaddr = %x / pte1_value = %x\n", 44 vaddr , (unsigned int)pt, &(pt->pt1[ix1]) , pte1 ); 41 45 _exit(); 42 46 } … … 45 49 if ( (pte1 & PTE_T) == 0 ) // big page 46 50 { 47 // set return values48 *ppn = ((pte1 << 9) & 0x0FFFFE00) | (vpn & 0X000001FF);49 51 *flags = pte1 & 0xFFC00000; 52 offset = offset | (ix2<<12); 53 return (((unsigned long long)(pte1 & 0x7FFFF)) << 21) | offset; 50 54 } 51 55 else // small page … … 84 88 _it_restore( &save_sr ); 85 89 86 // set return values87 *ppn = ppn_value & 0x0FFFFFFF;88 *flags = flags_value & 0xFFC00000;89 90 90 // check PTE2 mapping 91 91 if ( (flags_value & PTE_V) == 0 ) 92 92 { 93 93 _printf("\n[VMEM ERROR] _v2p_translate() : pte2 unmapped\n" 94 " v pn= %x / ptab = %x / pte1_value = %x\n"94 " vaddr = %x / ptab = %x / pte1_value = %x\n" 95 95 " pte2_paddr = %l / ppn = %x / flags = %x\n", 96 v pn , ptab, pte1 , pte2_paddr , ppn_value , flags_value );96 vaddr , pt , pte1 , pte2_paddr , ppn_value , flags_value ); 97 97 _exit(); 98 98 } 99 100 *flags = flags_value & 0xFFC00000; 101 return (((unsigned long long)(ppn_value & 0x0FFFFFFF)) << 12) | offset; 99 102 } 100 103 } // end _v2p_translate()
Note: See TracChangeset
for help on using the changeset viewer.