1 /* The kernel call implemented in this file:
4 * The parameters for this kernel call are:
5 * m1_i1: PR_ENDPT (install new map for this process)
6 * m1_p1: PR_MEM_PTR (pointer to the new memory map)
9 #include <minix/endpoint.h>
13 /*===========================================================================*
15 *===========================================================================*/
16 PUBLIC
int do_newmap(m_ptr
)
17 message
*m_ptr
; /* pointer to request message */
19 /* Handle sys_newmap(). Fetch the memory map from PM. */
20 register struct proc
*rp
; /* process whose map is to be loaded */
21 struct mem_map
*map_ptr
; /* virtual address of map inside caller (PM) */
22 phys_bytes src_phys
; /* physical address of map at the PM */
25 map_ptr
= (struct mem_map
*) m_ptr
->PR_MEM_PTR
;
26 if (! isokendpt(m_ptr
->PR_ENDPT
, &proc
)) return(EINVAL
);
27 if (iskerneln(proc
)) return(EPERM
);
30 return newmap(rp
, map_ptr
);
34 /*===========================================================================*
36 *===========================================================================*/
37 PUBLIC
int newmap(rp
, map_ptr
)
38 struct proc
*rp
; /* process whose map is to be loaded */
39 struct mem_map
*map_ptr
; /* virtual address of map inside caller (PM) */
41 /* Fetch the memory map from PM. */
42 phys_bytes src_phys
; /* physical address of map at the PM */
45 /* Copy the map from PM. */
46 src_phys
= umap_local(proc_addr(who_p
), D
, (vir_bytes
) map_ptr
,
47 sizeof(rp
->p_memmap
));
48 if (src_phys
== 0) return(EFAULT
);
49 phys_copy(src_phys
,vir2phys(rp
->p_memmap
),
50 (phys_bytes
)sizeof(rp
->p_memmap
));
56 #endif /* USE_NEWMAP */