2 #define _MINIX_SYSTEM 1
17 __weak_alias(mmap
, _mmap
)
18 __weak_alias(munmap
, _munmap
)
21 void *minix_mmap_for(endpoint_t forwhom
,
22 void *addr
, size_t len
, int prot
, int flags
, int fd
, off_t offset
)
27 memset(&m
, 0, sizeof(m
));
33 m
.VMM_OFFSET
= offset
;
34 m
.VMM_FORWHOM
= forwhom
;
37 m
.VMM_FLAGS
|= MAP_THIRDPARTY
;
40 r
= _syscall(VM_PROC_NR
, VM_MMAP
, &m
);
49 int minix_vfs_mmap(endpoint_t who
, off_t offset
, size_t len
,
50 dev_t dev
, ino_t ino
, int fd
, u32_t vaddr
, u16_t clearend
,
55 memset(&m
, 0, sizeof(message
));
57 m
.m_vm_vfs_mmap
.who
= who
;
58 m
.m_vm_vfs_mmap
.offset
= offset
;
59 m
.m_vm_vfs_mmap
.dev
= dev
;
60 m
.m_vm_vfs_mmap
.ino
= ino
;
61 m
.m_vm_vfs_mmap
.vaddr
= vaddr
;
62 m
.m_vm_vfs_mmap
.len
= len
;
63 m
.m_vm_vfs_mmap
.fd
= fd
;
64 m
.m_vm_vfs_mmap
.clearend
= clearend
;
65 m
.m_vm_vfs_mmap
.flags
= flags
;
67 return _syscall(VM_PROC_NR
, VM_VFS_MMAP
, &m
);
70 void *mmap(void *addr
, size_t len
, int prot
, int flags
,
73 return minix_mmap_for(SELF
, addr
, len
, prot
, flags
, fd
, offset
);
76 int munmap(void *addr
, size_t len
)
80 memset(&m
, 0, sizeof(m
));
84 return _syscall(VM_PROC_NR
, VM_MUNMAP
, &m
);
88 void *vm_remap(endpoint_t d
,
97 memset(&m
, 0, sizeof(m
));
98 m
.m_lsys_vm_vmremap
.destination
= d
;
99 m
.m_lsys_vm_vmremap
.source
= s
;
100 m
.m_lsys_vm_vmremap
.dest_addr
= da
;
101 m
.m_lsys_vm_vmremap
.src_addr
= sa
;
102 m
.m_lsys_vm_vmremap
.size
= size
;
104 r
= _syscall(VM_PROC_NR
, VM_REMAP
, &m
);
107 return m
.m_lsys_vm_vmremap
.ret_addr
;
110 void *vm_remap_ro(endpoint_t d
,
119 memset(&m
, 0, sizeof(m
));
120 m
.m_lsys_vm_vmremap
.destination
= d
;
121 m
.m_lsys_vm_vmremap
.source
= s
;
122 m
.m_lsys_vm_vmremap
.dest_addr
= da
;
123 m
.m_lsys_vm_vmremap
.src_addr
= sa
;
124 m
.m_lsys_vm_vmremap
.size
= size
;
126 r
= _syscall(VM_PROC_NR
, VM_REMAP_RO
, &m
);
129 return m
.m_lsys_vm_vmremap
.ret_addr
;
132 int vm_unmap(endpoint_t endpt
, void *addr
)
136 memset(&m
, 0, sizeof(m
));
137 m
.m_lc_vm_shm_unmap
.forwhom
= endpt
;
138 m
.m_lc_vm_shm_unmap
.addr
= addr
;
140 return _syscall(VM_PROC_NR
, VM_SHM_UNMAP
, &m
);
143 unsigned long vm_getphys(endpoint_t endpt
, void *addr
)
148 memset(&m
, 0, sizeof(m
));
149 m
.VMPHYS_ENDPT
= endpt
;
150 m
.VMPHYS_ADDR
= (long) addr
;
152 r
= _syscall(VM_PROC_NR
, VM_GETPHYS
, &m
);
155 return m
.VMPHYS_RETA
;
158 u8_t
vm_getrefcount(endpoint_t endpt
, void *addr
)
163 memset(&m
, 0, sizeof(m
));
164 m
.VMREFCNT_ENDPT
= endpt
;
165 m
.VMREFCNT_ADDR
= (long) addr
;
167 r
= _syscall(VM_PROC_NR
, VM_GETREF
, &m
);
170 return (u8_t
) m
.VMREFCNT_RETC
;