2013-03-20 20:18:52 +01:00
|
|
|
|
|
|
|
#include "syslib.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <minix/vm.h>
|
|
|
|
#include <minix/sysutil.h>
|
|
|
|
#include <machine/vmparam.h>
|
|
|
|
|
2013-11-28 17:51:21 +01:00
|
|
|
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)
|
2013-03-20 20:18:52 +01:00
|
|
|
{
|
|
|
|
if(blocksize % PAGE_SIZE)
|
|
|
|
panic("blocksize %d should be a multiple of pagesize %d\n",
|
|
|
|
blocksize, PAGE_SIZE);
|
|
|
|
|
|
|
|
if(ino_offset % PAGE_SIZE)
|
2013-02-02 01:55:35 +01:00
|
|
|
panic("inode offset %lld should be a multiple of pagesize %d\n",
|
2013-03-20 20:18:52 +01:00
|
|
|
ino_offset, PAGE_SIZE);
|
|
|
|
|
|
|
|
if(dev_offset % PAGE_SIZE)
|
2013-02-02 01:55:35 +01:00
|
|
|
panic("dev offset offset %lld should be a multiple of pagesize %d\n",
|
2013-03-20 20:18:52 +01:00
|
|
|
dev_offset, PAGE_SIZE);
|
|
|
|
|
|
|
|
memset(m, 0, sizeof(*m));
|
|
|
|
|
|
|
|
assert(dev != NO_DEV);
|
|
|
|
|
2013-11-28 18:17:38 +01:00
|
|
|
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;
|
2013-03-20 20:18:52 +01:00
|
|
|
|
|
|
|
return _taskcall(VM_PROC_NR, call, m);
|
|
|
|
}
|
|
|
|
|
2013-11-28 17:51:21 +01:00
|
|
|
void *vm_map_cacheblock(dev_t dev, off_t dev_offset,
|
|
|
|
ino_t ino, off_t ino_offset, u32_t *flags, int blocksize)
|
2013-03-20 20:18:52 +01:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
|
|
|
|
if(vm_cachecall(&m, VM_MAPCACHEPAGE, NULL, dev, dev_offset,
|
|
|
|
ino, ino_offset, flags, blocksize) != OK)
|
|
|
|
return MAP_FAILED;
|
|
|
|
|
2013-11-28 18:17:38 +01:00
|
|
|
return m.m_vmmcp_reply.addr;
|
2013-03-20 20:18:52 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 17:51:21 +01:00
|
|
|
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)
|
2013-03-20 20:18:52 +01:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
|
|
|
|
return vm_cachecall(&m, VM_SETCACHEPAGE, block, dev, dev_offset,
|
|
|
|
ino, ino_offset, flags, blocksize);
|
|
|
|
}
|
2013-09-15 18:55:42 +02:00
|
|
|
|
|
|
|
int
|
2013-11-15 19:01:25 +01:00
|
|
|
vm_clear_cache(dev_t dev)
|
2013-09-15 18:55:42 +02:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
|
|
|
|
assert(dev != NO_DEV);
|
|
|
|
|
|
|
|
memset(&m, 0, sizeof(m));
|
|
|
|
|
2013-11-28 18:17:38 +01:00
|
|
|
m.m_vmmcp.dev = dev;
|
2013-09-15 18:55:42 +02:00
|
|
|
|
|
|
|
return _taskcall(VM_PROC_NR, VM_CLEARCACHE, &m);
|
|
|
|
}
|