HV: extract functions from code to improve code reuse and readability

Create 2 functions from code:
 pci_base_from_size_mask
 vdev_pt_remap_mem_vbar

Use vbar in place of vdev->bar[idx] by setting vbar to &vdev->bar[idx]

Change base to uint64_t to accommodate 64-bit MMIO bar size masking in
subsequent commits

Tracked-On: #3241
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
dongshen
2019-06-25 12:42:21 -07:00
committed by ACRN System Integration
parent 84e09a2246
commit ae996250c1
2 changed files with 39 additions and 14 deletions

View File

@@ -266,6 +266,19 @@ static inline enum pci_bar_type pci_get_bar_type(uint32_t val)
return type;
}
/**
* Given bar size and raw bar value, return bar base address by masking off its lower flag bits
* size/val: all in 64-bit values to accommodate 64-bit MMIO bar size masking
*/
static inline uint64_t pci_base_from_size_mask(uint64_t size, uint64_t val)
{
uint64_t mask;
mask = ~(size - 1UL);
return (mask & val);
}
static inline uint8_t pci_bus(uint16_t bdf)
{
return (uint8_t)((bdf >> 8U) & 0xFFU);