etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libsys / vm_map_phys.c
blob0a2131388ac65db00751efff75be777664c744b6
1 #include "syslib.h"
3 #include <sys/mman.h>
4 #include <minix/vm.h>
5 #include <stdarg.h>
6 #include <string.h>
8 void *
9 vm_map_phys(endpoint_t who, void *phaddr, size_t len)
11 message m;
12 int r;
14 memset(&m, 0, sizeof(m));
15 m.m_lsys_vm_map_phys.ep = who;
16 m.m_lsys_vm_map_phys.phaddr = (phys_bytes)phaddr;
17 m.m_lsys_vm_map_phys.len = len;
19 r = _taskcall(VM_PROC_NR, VM_MAP_PHYS, &m);
21 if (r != OK) return MAP_FAILED;
23 r = sef_llvm_add_special_mem_region(m.m_lsys_vm_map_phys.reply,
24 len, NULL);
25 if(r < 0) {
26 printf("vm_map_phys: add_special_mem_region failed: %d\n", r);
29 return m.m_lsys_vm_map_phys.reply;
32 int
33 vm_unmap_phys(endpoint_t who, void *vaddr, size_t len)
35 message m;
36 int r;
38 memset(&m, 0, sizeof(m));
39 m.m_lsys_vm_unmap_phys.ep = who;
40 m.m_lsys_vm_unmap_phys.vaddr = vaddr;
42 r = _taskcall(VM_PROC_NR, VM_UNMAP_PHYS, &m);
44 if(r != OK) return r;
46 r = sef_llvm_del_special_mem_region_by_addr(vaddr);
47 if(r < 0) {
48 printf("vm_map_phys: del_special_mem_region failed: %d\n", r);
51 return OK;