/* This function checks if there is a PTE for a given dma address. If there is one, it returns the pointer to it.  */
static u64* fetch_pte(struct protection_domain *domain, unsigned long address, int map_size)
/* This function checks if there is a PTE for a given dma address. If there is one, it returns the pointer to it.  */
static u64* fetch_pte(struct protection_domain *domain, unsigned long address, int map_size)
{
	int level;
	u64 *pte;
	level =  domain->mode - 1;
	pte   = &domain->pt_root[PM_LEVEL_INDEX(level, address)];
	while (level > map_size) {
		if (!IOMMU_PTE_PRESENT(*pte))
			return NULL;
		level -= 1;
		pte = IOMMU_PTE_PAGE(*pte);
		pte = &pte[PM_LEVEL_INDEX(level, address)];
		if ((PM_PTE_LEVEL(*pte) == 0) && level != map_size) {
			pte = NULL;
			break;
		}
	}
	return pte;
}