Changeset 315 for trunk/kernel/mm/ppm.c
- Timestamp:
- Aug 3, 2017, 10:15:18 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/ppm.c
r313 r315 47 47 48 48 49 49 50 ///////////////////////////////////////////// 50 inline void * ppm_page2vaddr( page_t * page ) 51 { 52 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 53 return ppm->vaddr_base + ((page - ppm->pages_tbl) << CONFIG_PPM_PAGE_SHIFT); 54 } 55 56 ////////////////////////////////////////////// 57 inline page_t * ppm_vaddr2page( void * vaddr ) 58 { 59 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 60 return ppm->pages_tbl + (vaddr - ppm->vaddr_base); 61 } 51 inline xptr_t ppm_page2base( xptr_t page_xp ) 52 { 53 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 54 55 cxy_t page_cxy = GET_CXY( page_xp ); 56 page_t * page_ptr = (page_t *)GET_PTR( page_xp ); 57 58 void * base_ptr = ppm->vaddr_base + 59 ((page_ptr - ppm->pages_tbl)<<CONFIG_PPM_PAGE_SHIFT); 60 61 return XPTR( page_cxy , base_ptr ); 62 63 } // end ppm_page2base() 64 65 ///////////////////////////////////////////// 66 inline xptr_t ppm_base2page( xptr_t base_xp ) 67 { 68 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 69 70 cxy_t base_cxy = GET_CXY( base_xp ); 71 void * base_ptr = (void *)GET_PTR( base_xp ); 72 73 page_t * page_ptr = ppm->pages_tbl + 74 ((base_ptr - ppm->vaddr_base)>>CONFIG_PPM_PAGE_SHIFT); 75 76 return XPTR( base_cxy , page_ptr ); 77 78 } // end ppm_base2page() 79 80 81 82 /////////////////////////////////////////// 83 inline ppn_t ppm_page2ppn( xptr_t page_xp ) 84 { 85 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 86 87 cxy_t page_cxy = GET_CXY( page_xp ); 88 page_t * page_ptr = (page_t *)GET_PTR( page_xp ); 89 90 paddr_t paddr = PADDR( page_cxy , (page_ptr - ppm->pages_tbl)<<CONFIG_PPM_PAGE_SHIFT ); 91 92 return paddr >> CONFIG_PPM_PAGE_SHIFT; 93 94 } // end hal_page2ppn() 95 96 /////////////////////////////////////// 97 inline xptr_t ppm_ppn2page( ppn_t ppn ) 98 { 99 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 100 101 paddr_t paddr = ppn << CONFIG_PPM_PAGE_SHIFT; 102 103 cxy_t page_cxy = CXY_FROM_PADDR( paddr ); 104 lpa_t page_lpa = LPA_FROM_PADDR( paddr ); 105 106 return XPTR( page_cxy , &ppm->pages_tbl[page_lpa>>CONFIG_PPM_PAGE_SHIFT] ); 107 108 } // end hal_ppn2page 109 110 111 112 /////////////////////////////////////// 113 inline xptr_t ppm_ppn2base( ppn_t ppn ) 114 { 115 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 116 117 paddr_t paddr = ppn << CONFIG_PPM_PAGE_SHIFT; 118 119 cxy_t page_cxy = CXY_FROM_PADDR( paddr ); 120 lpa_t page_lpa = LPA_FROM_PADDR( paddr ); 121 122 void * base_ptr = (void *)ppm->vaddr_base + (page_lpa & ~CONFIG_PPM_PAGE_SHIFT); 123 124 return XPTR( page_cxy , base_ptr ); 125 126 } // end ppm_ppn2base() 127 128 /////////////////////////////////////////// 129 inline ppn_t ppm_base2ppn( xptr_t base_xp ) 130 { 131 ppm_t * ppm = &LOCAL_CLUSTER->ppm; 132 133 cxy_t base_cxy = GET_CXY( base_xp ); 134 void * base_ptr = (void *)GET_PTR( base_xp ); 135 136 paddr_t paddr = PADDR( base_cxy , (base_ptr - ppm->vaddr_base) ); 137 138 return paddr >> CONFIG_PPM_PAGE_SHIFT; 139 140 } // end ppm_base2ppn() 141 142 62 143 63 144 ///////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.