minix/lib/libsys/vm_cache.c
Lionel Sambuc 84d9c625bf Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)
- Fix for possible unset uid/gid in toproto
 - Fix for default mtree style
 - Update libelf
 - Importing libexecinfo
 - Resynchronize GCC, mpc, gmp, mpfr
 - build.sh: Replace params with show-params.
     This has been done as the make target has been renamed in the same
     way, while a new target named params has been added. This new
     target generates a file containing all the parameters, instead of
     printing it on the console.
 - Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
     get getservbyport() out of the inner loop

Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
2014-07-28 17:05:06 +02:00

79 lines
1.8 KiB
C

#include "syslib.h"
#include <string.h>
#include <assert.h>
#include <sys/mman.h>
#include <minix/vm.h>
#include <minix/sysutil.h>
#include <machine/param.h>
#include <machine/vmparam.h>
int vm_cachecall(message *m, int call, void *addr, dev_t dev, off_t dev_offset,
ino_t ino, off_t ino_offset, u32_t *flags, int blocksize)
{
if(blocksize % PAGE_SIZE)
panic("blocksize %d should be a multiple of pagesize %d\n",
blocksize, PAGE_SIZE);
if(ino_offset % PAGE_SIZE)
panic("inode offset %lld should be a multiple of pagesize %d\n",
ino_offset, PAGE_SIZE);
if(dev_offset % PAGE_SIZE)
panic("dev offset offset %lld should be a multiple of pagesize %d\n",
dev_offset, PAGE_SIZE);
memset(m, 0, sizeof(*m));
assert(dev != NO_DEV);
m->m_vmmcp.dev_offset = dev_offset;
m->m_vmmcp.ino_offset = ino_offset;
m->m_vmmcp.ino = ino;
m->m_vmmcp.block = addr;
m->m_vmmcp.flags_ptr = flags;
m->m_vmmcp.dev = dev;
m->m_vmmcp.pages = blocksize / PAGE_SIZE;
m->m_vmmcp.flags = 0;
return _taskcall(VM_PROC_NR, call, m);
}
void *vm_map_cacheblock(dev_t dev, off_t dev_offset,
ino_t ino, off_t ino_offset, u32_t *flags, int blocksize)
{
message m;
if(vm_cachecall(&m, VM_MAPCACHEPAGE, NULL, dev, dev_offset,
ino, ino_offset, flags, blocksize) != OK)
return MAP_FAILED;
return m.m_vmmcp_reply.addr;
}
int vm_set_cacheblock(void *block, dev_t dev, off_t dev_offset,
ino_t ino, off_t ino_offset, u32_t *flags, int blocksize)
{
message m;
return vm_cachecall(&m, VM_SETCACHEPAGE, block, dev, dev_offset,
ino, ino_offset, flags, blocksize);
}
int
vm_clear_cache(dev_t dev)
{
message m;
assert(dev != NO_DEV);
memset(&m, 0, sizeof(m));
m.m_vmmcp.dev = dev;
return _taskcall(VM_PROC_NR, VM_CLEARCACHE, &m);
}