xref: /minix3/minix/kernel/system/do_umap.c (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc /* The kernel call implemented in this file:
2*433d6423SLionel Sambuc  *   m_type:	SYS_UMAP
3*433d6423SLionel Sambuc  *
4*433d6423SLionel Sambuc  * The parameters for this kernel call are:
5*433d6423SLionel Sambuc  *   m_lsys_krn_sys_umap.src_endpt	(process number)
6*433d6423SLionel Sambuc  *   m_lsys_krn_sys_umap.segment	(segment where address is: T, D, or S)
7*433d6423SLionel Sambuc  *   m_lsys_krn_sys_umap.src_addr	(virtual address)
8*433d6423SLionel Sambuc  *   m_krn_lsys_sys_umap.dst_addr	(returns physical address)
9*433d6423SLionel Sambuc  *   m_lsys_krn_sys_umap.nr_bytes	(size of datastructure)
10*433d6423SLionel Sambuc  */
11*433d6423SLionel Sambuc 
12*433d6423SLionel Sambuc #include "kernel/system.h"
13*433d6423SLionel Sambuc 
14*433d6423SLionel Sambuc #include <minix/endpoint.h>
15*433d6423SLionel Sambuc 
16*433d6423SLionel Sambuc #if USE_UMAP
17*433d6423SLionel Sambuc 
18*433d6423SLionel Sambuc #if ! USE_UMAP_REMOTE
19*433d6423SLionel Sambuc #undef do_umap_remote
20*433d6423SLionel Sambuc #endif
21*433d6423SLionel Sambuc 
22*433d6423SLionel Sambuc /*==========================================================================*
23*433d6423SLionel Sambuc  *				do_umap					    *
24*433d6423SLionel Sambuc  *==========================================================================*/
do_umap(struct proc * caller,message * m_ptr)25*433d6423SLionel Sambuc int do_umap(struct proc * caller, message * m_ptr)
26*433d6423SLionel Sambuc {
27*433d6423SLionel Sambuc   int seg_index = m_ptr->m_lsys_krn_sys_umap.segment & SEGMENT_INDEX;
28*433d6423SLionel Sambuc   int endpt = m_ptr->m_lsys_krn_sys_umap.src_endpt;
29*433d6423SLionel Sambuc 
30*433d6423SLionel Sambuc   /* This call is a subset of umap_remote, it allows mapping virtual addresses
31*433d6423SLionel Sambuc    * in the caller's address space and grants where the caller is specified as
32*433d6423SLionel Sambuc    * grantee; after the security check we simply invoke do_umap_remote
33*433d6423SLionel Sambuc    */
34*433d6423SLionel Sambuc   if (seg_index != MEM_GRANT && endpt != SELF) return EPERM;
35*433d6423SLionel Sambuc   m_ptr->m_lsys_krn_sys_umap.dst_endpt = SELF;
36*433d6423SLionel Sambuc   return do_umap_remote(caller, m_ptr);
37*433d6423SLionel Sambuc }
38*433d6423SLionel Sambuc 
39*433d6423SLionel Sambuc #endif /* USE_UMAP */
40