Skip to content

Commit

Permalink
kmm_map: Add function to map a single page of kernel memory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pussuw committed Oct 11, 2023
1 parent 054ebd1 commit 24b31cc
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions mm/kmap/kmm_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 24b31cc

Please sign in to comment.