source: trunk/minix/kernel/system/do_newmap.c@ 20

Last change on this file since 20 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.6 KB
Line 
1/* The kernel call implemented in this file:
2 * m_type: SYS_NEWMAP
3 *
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)
7 */
8#include "../system.h"
9#include <minix/endpoint.h>
10
11#if USE_NEWMAP
12
13/*===========================================================================*
14 * do_newmap *
15 *===========================================================================*/
16PUBLIC int do_newmap(m_ptr)
17message *m_ptr; /* pointer to request message */
18{
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 */
23 int old_flags; /* value of flags before modification */
24 int proc;
25
26 map_ptr = (struct mem_map *) m_ptr->PR_MEM_PTR;
27 if (! isokendpt(m_ptr->PR_ENDPT, &proc)) return(EINVAL);
28 if (iskerneln(proc)) return(EPERM);
29 rp = proc_addr(proc);
30
31 /* Copy the map from PM. */
32 src_phys = umap_local(proc_addr(who_p), D, (vir_bytes) map_ptr,
33 sizeof(rp->p_memmap));
34 if (src_phys == 0) return(EFAULT);
35 phys_copy(src_phys,vir2phys(rp->p_memmap),(phys_bytes)sizeof(rp->p_memmap));
36
37#if (CHIP != M68000)
38 alloc_segments(rp);
39#else
40 pmmu_init_proc(rp);
41#endif
42 old_flags = rp->p_rts_flags; /* save the previous value of the flags */
43 rp->p_rts_flags &= ~NO_MAP;
44 if (old_flags != 0 && rp->p_rts_flags == 0) lock_enqueue(rp);
45
46 return(OK);
47}
48#endif /* USE_NEWMAP */
49
Note: See TracBrowser for help on using the repository browser.