From 81bccf87465e0e7db0061c6c7aecfe0e0f5ef4c9 Mon Sep 17 00:00:00 2001 From: Julien Grall Date: Mon, 19 May 2014 17:23:58 +0100 Subject: [PATCH] xen: iommu: Define PAGE_{SHIFT, SIZE, ALIGN, MASK)_64K Also add IOMMU_PAGE_* helper macros to help creating PAGE_* defines. Signed-off-by: Julien Grall Acked-by: Jan Beulich --- xen/include/xen/iommu.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 2ec7834eee..8eb764a001 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -35,10 +35,19 @@ extern bool_t iommu_hap_pt_share; extern bool_t iommu_debug; extern bool_t amd_iommu_perdev_intremap; +#define IOMMU_PAGE_SIZE(sz) (1UL << PAGE_SHIFT_##sz) +#define IOMMU_PAGE_MASK(sz) (~(u64)0 << PAGE_SHIFT_##sz) +#define IOMMU_PAGE_ALIGN(sz, addr) (((addr) + ~PAGE_MASK_##sz) & PAGE_MASK_##sz) + #define PAGE_SHIFT_4K (12) -#define PAGE_SIZE_4K (1UL << PAGE_SHIFT_4K) -#define PAGE_MASK_4K (((u64)-1) << PAGE_SHIFT_4K) -#define PAGE_ALIGN_4K(addr) (((addr) + PAGE_SIZE_4K - 1) & PAGE_MASK_4K) +#define PAGE_SIZE_4K IOMMU_PAGE_SIZE(4K) +#define PAGE_MASK_4K IOMMU_PAGE_MASK(4K) +#define PAGE_ALIGN_4K(addr) IOMMU_PAGE_ALIGN(4K, addr) + +#define PAGE_SHIFT_64K (16) +#define PAGE_SIZE_64K IOMMU_PAGE_SIZE(64K) +#define PAGE_MASK_64K IOMMU_PAGE_MASK(64K) +#define PAGE_ALIGN_64K(addr) IOMMU_PAGE_ALIGN(64K, addr) int iommu_setup(void); -- 2.30.2