hv: pgtable: fix 'Use of function like macro'

Convert HPA2HVA, HVA2HPA, GPA2HVA and HVA2GPA to inline functions.

v1 -> v2:
 * Modify the following statement.
   rsdp = biosacpi_search_rsdp((char *)hpa2hva((uint64_t)(*addr << 4)),
                                                                0x400);
   Instead of "(uint64_t)(*addr << 4)", "(uint64_t)(*addr) << 4U" would
   be clearer.

Tracked-On: #861
Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Shiqing Gao
2018-09-06 13:50:10 +08:00
committed by lijinxia
parent 6ee9321bd8
commit 97aeb7f4ff
24 changed files with 142 additions and 116 deletions

View File

@@ -10,8 +10,15 @@
#include <pgtable_types.h>
/* hpa <--> hva, now it is 1:1 mapping */
#define HPA2HVA(x) ((void *)(x))
#define HVA2HPA(x) ((uint64_t)(x))
static inline void *hpa2hva(uint64_t x)
{
return (void *)x;
}
static inline uint64_t hva2hpa(void *x)
{
return (uint64_t)x;
}
static inline uint64_t pml4e_index(uint64_t address)
{
@@ -35,17 +42,17 @@ static inline uint64_t pte_index(uint64_t address)
static inline uint64_t *pml4e_page_vaddr(uint64_t pml4e)
{
return HPA2HVA(pml4e & PML4E_PFN_MASK);
return hpa2hva(pml4e & PML4E_PFN_MASK);
}
static inline uint64_t *pdpte_page_vaddr(uint64_t pdpte)
{
return HPA2HVA(pdpte & PDPTE_PFN_MASK);
return hpa2hva(pdpte & PDPTE_PFN_MASK);
}
static inline uint64_t *pde_page_vaddr(uint64_t pde)
{
return HPA2HVA(pde & PDE_PFN_MASK);
return hpa2hva(pde & PDE_PFN_MASK);
}
static inline uint64_t *pml4e_offset(uint64_t *pml4_page, uint64_t addr)