source: branches/minix3-book/kernel/system/do_newmap.c@ 4

Last change on this file since 4 was 4, checked in by Mattia Monga, 13 years ago

Importazione sorgenti libro

File size: 1.7 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_PROC_NR (install new map for this process)
6 * m1_p1: PR_MEM_PTR (pointer to the new memory map)
7 */
8#include "../system.h"
9
10#if USE_NEWMAP
11
12/*===========================================================================*
13 * do_newmap *
14 *===========================================================================*/
15PUBLIC int do_newmap(m_ptr)
16message *m_ptr; /* pointer to request message */
17{
18/* Handle sys_newmap(). Fetch the memory map from PM. */
19 register struct proc *rp; /* process whose map is to be loaded */
20 int caller; /* whose space has the new map (usually PM) */
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
25 /* Extract message parameters and copy new memory map from PM. */
26 caller = m_ptr->m_source;
27 map_ptr = (struct mem_map *) m_ptr->PR_MEM_PTR;
28 if (! isokprocn(m_ptr->PR_PROC_NR)) return(EINVAL);
29 if (iskerneln(m_ptr->PR_PROC_NR)) return(EPERM);
30 rp = proc_addr(m_ptr->PR_PROC_NR);
31
32 /* Copy the map from PM. */
33 src_phys = umap_local(proc_addr(caller), D, (vir_bytes) map_ptr,
34 sizeof(rp->p_memmap));
35 if (src_phys == 0) return(EFAULT);
36 phys_copy(src_phys,vir2phys(rp->p_memmap),(phys_bytes)sizeof(rp->p_memmap));
37
38#if (CHIP != M68000)
39 alloc_segments(rp);
40#else
41 pmmu_init_proc(rp);
42#endif
43 old_flags = rp->p_rts_flags; /* save the previous value of the flags */
44 rp->p_rts_flags &= ~NO_MAP;
45 if (old_flags != 0 && rp->p_rts_flags == 0) lock_enqueue(rp);
46
47 return(OK);
48}
49#endif /* USE_NEWMAP */
50
Note: See TracBrowser for help on using the repository browser.