Add pmap_mapdev_attr for arm64

This is needed for efifb.
arm and ricv pmap (the two arch with arm64 that uses subr_devmap) have very
different implementation so for now only add this for arm64.

Tested with efifb on Pine64 with a few other patches.

Reviewed by:	cognet
Differential Revision:	https://reviews.freebsd.org/D15294
This commit is contained in:
Emmanuel Vadot 2018-06-20 16:07:35 +00:00
parent a2d7053188
commit 78442297f5
3 changed files with 34 additions and 1 deletions

View File

@ -1142,7 +1142,7 @@ pmap_kextract(vm_offset_t va)
* Low level mapping routines.....
***************************************************/
static void
void
pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode)
{
pd_entry_t *pde;

View File

@ -140,10 +140,12 @@ extern vm_offset_t virtual_end;
((((va) | (pa)) & L1_OFFSET) == 0 && (size) >= L1_SIZE)
void pmap_bootstrap(vm_offset_t, vm_offset_t, vm_paddr_t, vm_size_t);
void pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t pa, int mode);
void pmap_kenter_device(vm_offset_t, vm_size_t, vm_paddr_t);
vm_paddr_t pmap_kextract(vm_offset_t va);
void pmap_kremove(vm_offset_t);
void pmap_kremove_device(vm_offset_t, vm_size_t);
void *pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t ma);
void *pmap_mapdev(vm_offset_t, vm_size_t);
void *pmap_mapbios(vm_paddr_t, vm_size_t);

View File

@ -287,6 +287,37 @@ pmap_mapdev(vm_offset_t pa, vm_size_t size)
return ((void *)(va + offset));
}
#if defined(__aarch64__)
void *
pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t ma)
{
vm_offset_t va, offset;
void * rva;
/* First look in the static mapping table. */
if ((rva = devmap_ptov(pa, size)) != NULL)
return (rva);
offset = pa & PAGE_MASK;
pa = trunc_page(pa);
size = round_page(size + offset);
if (early_boot) {
akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - size);
va = akva_devmap_vaddr;
KASSERT(va >= VM_MAX_KERNEL_ADDRESS - L2_SIZE,
("Too many early devmap mappings"));
} else
va = kva_alloc(size);
if (!va)
panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
pmap_kenter(va, size, pa, ma);
return ((void *)(va + offset));
}
#endif
/*
* Unmap device memory and free the kva space.
*/