source: trunk/minix/kernel/system/do_umap.c@ 15

Last change on this file since 15 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_UMAP
3 *
4 * The parameters for this kernel call are:
5 * m5_i1: CP_SRC_PROC_NR (process number)
6 * m5_c1: CP_SRC_SPACE (segment where address is: T, D, or S)
7 * m5_l1: CP_SRC_ADDR (virtual address)
8 * m5_l2: CP_DST_ADDR (returns physical address)
9 * m5_l3: CP_NR_BYTES (size of datastructure)
10 */
11
12#include "../system.h"
13
14#if USE_UMAP
15
16/*==========================================================================*
17 * do_umap *
18 *==========================================================================*/
19PUBLIC int do_umap(m_ptr)
20register message *m_ptr; /* pointer to request message */
21{
22/* Map virtual address to physical, for non-kernel processes. */
23 int seg_type = m_ptr->CP_SRC_SPACE & SEGMENT_TYPE;
24 int seg_index = m_ptr->CP_SRC_SPACE & SEGMENT_INDEX;
25 vir_bytes offset = m_ptr->CP_SRC_ADDR;
26 int count = m_ptr->CP_NR_BYTES;
27 int endpt = (int) m_ptr->CP_SRC_ENDPT;
28 int proc_nr;
29 phys_bytes phys_addr;
30
31 /* Verify process number. */
32 if (endpt == SELF)
33 proc_nr = who_p;
34 else
35 if (! isokendpt(endpt, &proc_nr))
36 return(EINVAL);
37
38 /* See which mapping should be made. */
39 switch(seg_type) {
40 case LOCAL_SEG:
41 phys_addr = umap_local(proc_addr(proc_nr), seg_index, offset, count);
42 break;
43 case REMOTE_SEG:
44 phys_addr = umap_remote(proc_addr(proc_nr), seg_index, offset, count);
45 break;
46 case BIOS_SEG:
47 phys_addr = umap_bios(proc_addr(proc_nr), offset, count);
48 break;
49 default:
50 return(EINVAL);
51 }
52 m_ptr->CP_DST_ADDR = phys_addr;
53 return (phys_addr == 0) ? EFAULT: OK;
54}
55
56#endif /* USE_UMAP */
Note: See TracBrowser for help on using the repository browser.