source: branches/minix3-book/kernel/system/do_umap.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.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 proc_nr = (int) m_ptr->CP_SRC_PROC_NR;
28 phys_bytes phys_addr;
29
30 /* Verify process number. */
31 if (proc_nr == SELF) proc_nr = m_ptr->m_source;
32 if (! isokprocn(proc_nr)) return(EINVAL);
33
34 /* See which mapping should be made. */
35 switch(seg_type) {
36 case LOCAL_SEG:
37 phys_addr = umap_local(proc_addr(proc_nr), seg_index, offset, count);
38 break;
39 case REMOTE_SEG:
40 phys_addr = umap_remote(proc_addr(proc_nr), seg_index, offset, count);
41 break;
42 case BIOS_SEG:
43 phys_addr = umap_bios(proc_addr(proc_nr), offset, count);
44 break;
45 default:
46 return(EINVAL);
47 }
48 m_ptr->CP_DST_ADDR = phys_addr;
49 return (phys_addr == 0) ? EFAULT: OK;
50}
51
52#endif /* USE_UMAP */
Note: See TracBrowser for help on using the repository browser.