diff --git a/include/nuttx/mm/kmap.h b/include/nuttx/mm/kmap.h index 1f93f35b42..040b1e3fb0 100644 --- a/include/nuttx/mm/kmap.h +++ b/include/nuttx/mm/kmap.h @@ -23,6 +23,16 @@ #ifndef __INCLUDE_NUTTX_MM_KMAP_H #define __INCLUDE_NUTTX_MM_KMAP_H +/**************************************************************************** + * Public Type Definitions + ****************************************************************************/ + +struct tcb_s; /* Forward reference to TCB */ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + /**************************************************************************** * Name: kmm_map_initialize * @@ -81,6 +91,8 @@ void kmm_unmap(FAR void *kaddr); * a continuous virtual memory area. * * Input Parameters: + * tcb - The tcb of the task whose address environment the mapping + * belongs to. * uaddr - The user virtual address where mapping begins. * size - Size of the region. * @@ -89,7 +101,7 @@ void kmm_unmap(FAR void *kaddr); * ****************************************************************************/ -FAR void *kmm_map_user(FAR void *uaddr, size_t size); +FAR void *kmm_map_user(FAR struct tcb_s *tcb, FAR void *uaddr, size_t size); /**************************************************************************** * Name: kmm_map_user_page @@ -99,6 +111,8 @@ FAR void *kmm_map_user(FAR void *uaddr, size_t size); * returns the kernel addressable page pool virtual address. * * Input Parameters: + * tcb - The tcb of the task whose address environment the mapping + * belongs to. * uaddr - The virtual address of the user page. * * Returned Value: @@ -106,6 +120,6 @@ FAR void *kmm_map_user(FAR void *uaddr, size_t size); * ****************************************************************************/ -FAR void *kmm_map_user_page(FAR void *uaddr); +FAR void *kmm_map_user_page(FAR struct tcb_s *tcb, FAR void *uaddr); #endif /* __INCLUDE_NUTTX_MM_KMAP_H */ diff --git a/mm/kmap/kmm_map.c b/mm/kmap/kmm_map.c index adb9293524..372f77fbdc 100644 --- a/mm/kmap/kmm_map.c +++ b/mm/kmap/kmm_map.c @@ -76,11 +76,11 @@ static struct mm_map_s g_kmm_map; * ****************************************************************************/ -static int get_user_pages(FAR void **pages, size_t npages, uintptr_t vaddr) +static int get_user_pages(FAR struct tcb_s *tcb, FAR void **pages, + size_t npages, uintptr_t vaddr) { - FAR struct tcb_s *tcb = this_task(); - uintptr_t page; - int i; + uintptr_t page; + int i; /* Find the pages associated with the user virtual address space */ @@ -170,19 +170,18 @@ errout_with_vaddr: * Map a single user page into kernel memory. * * Input Parameters: - * pages - Pointer to buffer that contains the physical page addresses. - * npages - Amount of pages. - * prot - Access right flags. + * tcb - The tcb of the task whose address environment the mapping + * belongs to. + * vaddr - The virtual address of the page to map. * * Returned Value: * Pointer to the mapped virtual memory on success; NULL on failure * ****************************************************************************/ -static FAR void *map_single_user_page(uintptr_t vaddr) +static FAR void *map_single_user_page(FAR struct tcb_s *tcb, uintptr_t vaddr) { - FAR struct tcb_s *tcb = this_task(); - uintptr_t page; + uintptr_t page; /* Find the page associated with this virtual address */ @@ -405,6 +404,8 @@ void kmm_unmap(FAR void *kaddr) * a continuous virtual memory area. * * Input Parameters: + * tcb - The tcb of the task whose address environment the mapping + * belongs to. * uaddr - The user virtual address where mapping begins. * size - Size of the region. * @@ -413,7 +414,7 @@ void kmm_unmap(FAR void *kaddr) * ****************************************************************************/ -FAR void *kmm_map_user(FAR void *uaddr, size_t size) +FAR void *kmm_map_user(FAR struct tcb_s *tcb, FAR void *uaddr, size_t size) { FAR void **pages; uintptr_t vaddr; @@ -446,7 +447,7 @@ FAR void *kmm_map_user(FAR void *uaddr, size_t size) { /* Yes, can simply return the kernel addressable virtual address */ - vaddr = (uintptr_t)map_single_user_page(vaddr); + vaddr = (uintptr_t)map_single_user_page(tcb, vaddr); return (FAR void *)(vaddr + offset); } @@ -460,7 +461,7 @@ FAR void *kmm_map_user(FAR void *uaddr, size_t size) /* Fetch the physical pages for the user virtual address range */ - ret = get_user_pages(pages, npages, vaddr); + ret = get_user_pages(tcb, pages, npages, vaddr); if (ret < 0) { goto errout_with_pages; @@ -492,6 +493,8 @@ errout_with_pages: * returns the kernel addressable page pool virtual address. * * Input Parameters: + * tcb - The tcb of the task whose address environment the mapping + * belongs to. * uaddr - The virtual address of the user page. * * Returned Value: @@ -499,7 +502,7 @@ errout_with_pages: * ****************************************************************************/ -FAR void *kmm_map_user_page(FAR void *uaddr) +FAR void *kmm_map_user_page(FAR struct tcb_s *tcb, FAR void *uaddr) { uintptr_t vaddr; uintptr_t offset; @@ -522,7 +525,7 @@ FAR void *kmm_map_user_page(FAR void *uaddr) offset = vaddr & MM_PGMASK; vaddr = MM_PGALIGNDOWN(vaddr); - vaddr = (uintptr_t)map_single_user_page(vaddr); + vaddr = (uintptr_t)map_single_user_page(tcb, vaddr); if (!vaddr) { return NULL;