forked from nuttx/nuttx-update
kmm_map: Add function to map a single page of kernel memory
Mapping a physical page to a kernel virtual page is very simple and does not need the kernel vma list, just get the kernel addressable virtual address for the page.
This commit is contained in:
parent
04bfaf3a55
commit
7c893ddfc2
1 changed files with 28 additions and 0 deletions
|
@ -192,6 +192,27 @@ static FAR void *map_single_user_page(uintptr_t vaddr)
|
|||
return (FAR void *)vaddr;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: map_single_page
|
||||
*
|
||||
* Description:
|
||||
* Map (find) a single page from the kernel addressable virtual memory
|
||||
* pool.
|
||||
*
|
||||
* Input Parameters:
|
||||
* page - The physical page.
|
||||
*
|
||||
* Returned Value:
|
||||
* The kernel virtual address for the page, or NULL if page is not kernel
|
||||
* addressable.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR void *map_single_page(uintptr_t page)
|
||||
{
|
||||
return (FAR void *)up_addrenv_page_vaddr(page);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: is_kmap_vaddr
|
||||
*
|
||||
|
@ -290,6 +311,13 @@ FAR void *kmm_map(FAR void **pages, size_t npages, int prot)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* A single page can be addressed directly, if it is a kernel page */
|
||||
|
||||
if (npages == 1)
|
||||
{
|
||||
return map_single_page((uintptr_t)pages[0]);
|
||||
}
|
||||
|
||||
/* Attempt to map the pages */
|
||||
|
||||
vaddr = (uintptr_t)map_pages(pages, npages, prot);
|
||||
|
|
Loading…
Reference in a new issue