retire 64-bit conversion functions
[minix3.git] / lib / libsys / vm_cache.c
blobce844acf0cae6ae54c61f02bd0e7c22e25a109bd
2 #include "syslib.h"
4 #include <string.h>
5 #include <assert.h>
7 #include <sys/mman.h>
8 #include <minix/vm.h>
9 #include <minix/sysutil.h>
10 #include <machine/vmparam.h>
12 int vm_cachecall(message *m, int call, void *addr, u32_t dev, u64_t dev_offset,
13 u64_t ino, u64_t ino_offset, u32_t *flags, int blocksize)
15 if(blocksize % PAGE_SIZE)
16 panic("blocksize %d should be a multiple of pagesize %d\n",
17 blocksize, PAGE_SIZE);
19 if(ino_offset % PAGE_SIZE)
20 panic("inode offset %lld should be a multiple of pagesize %d\n",
21 ino_offset, PAGE_SIZE);
23 if(dev_offset % PAGE_SIZE)
24 panic("dev offset offset %lld should be a multiple of pagesize %d\n",
25 dev_offset, PAGE_SIZE);
27 memset(m, 0, sizeof(*m));
29 assert(dev != NO_DEV);
31 m->m_u.m_vmmcp.dev_offset_pages = dev_offset/PAGE_SIZE;
32 m->m_u.m_vmmcp.ino_offset_pages = ino_offset/PAGE_SIZE;
33 m->m_u.m_vmmcp.ino = ino;
34 m->m_u.m_vmmcp.block = addr;
35 m->m_u.m_vmmcp.flags_ptr = flags;
36 m->m_u.m_vmmcp.dev = dev;
37 m->m_u.m_vmmcp.pages = blocksize / PAGE_SIZE;
38 m->m_u.m_vmmcp.flags = 0;
40 return _taskcall(VM_PROC_NR, call, m);
43 void *vm_map_cacheblock(u32_t dev, u64_t dev_offset,
44 u64_t ino, u64_t ino_offset, u32_t *flags, int blocksize)
46 message m;
48 if(vm_cachecall(&m, VM_MAPCACHEPAGE, NULL, dev, dev_offset,
49 ino, ino_offset, flags, blocksize) != OK)
50 return MAP_FAILED;
52 return m.m_u.m_vmmcp_reply.addr;
55 int vm_set_cacheblock(void *block, u32_t dev, u64_t dev_offset,
56 u64_t ino, u64_t ino_offset, u32_t *flags, int blocksize)
58 message m;
60 return vm_cachecall(&m, VM_SETCACHEPAGE, block, dev, dev_offset,
61 ino, ino_offset, flags, blocksize);