10 #include <minix/sysutil.h>
12 #include <machine/param.h>
13 #include <machine/vmparam.h>
15 static int vm_cachecall(message
*m
, int call
, void *addr
, dev_t dev
,
16 off_t dev_offset
, ino_t ino
, off_t ino_offset
, u32_t
*flags
,
17 int blocksize
, int setflags
)
19 if(blocksize
% PAGE_SIZE
)
20 panic("blocksize %d should be a multiple of pagesize %d\n",
21 blocksize
, PAGE_SIZE
);
23 if(ino_offset
% PAGE_SIZE
)
24 panic("inode offset %lld should be a multiple of pagesize %d\n",
25 ino_offset
, PAGE_SIZE
);
27 if(dev_offset
% PAGE_SIZE
)
28 panic("dev offset offset %lld should be a multiple of pagesize %d\n",
29 dev_offset
, PAGE_SIZE
);
31 memset(m
, 0, sizeof(*m
));
33 assert(dev
!= NO_DEV
);
35 m
->m_vmmcp
.dev_offset
= dev_offset
;
36 m
->m_vmmcp
.ino_offset
= ino_offset
;
38 m
->m_vmmcp
.block
= addr
;
39 m
->m_vmmcp
.flags_ptr
= flags
;
41 m
->m_vmmcp
.pages
= blocksize
/ PAGE_SIZE
;
42 m
->m_vmmcp
.flags
= setflags
;
44 return _taskcall(VM_PROC_NR
, call
, m
);
47 void *vm_map_cacheblock(dev_t dev
, off_t dev_offset
,
48 ino_t ino
, off_t ino_offset
, u32_t
*flags
, int blocksize
)
52 if(vm_cachecall(&m
, VM_MAPCACHEPAGE
, NULL
, dev
, dev_offset
,
53 ino
, ino_offset
, flags
, blocksize
, 0) != OK
)
56 return m
.m_vmmcp_reply
.addr
;
59 int vm_set_cacheblock(void *block
, dev_t dev
, off_t dev_offset
,
60 ino_t ino
, off_t ino_offset
, u32_t
*flags
, int blocksize
, int setflags
)
64 return vm_cachecall(&m
, VM_SETCACHEPAGE
, block
, dev
, dev_offset
,
65 ino
, ino_offset
, flags
, blocksize
, setflags
);
68 int vm_forget_cacheblock(dev_t dev
, off_t dev_offset
, int blocksize
)
72 return vm_cachecall(&m
, VM_FORGETCACHEPAGE
, NULL
, dev
, dev_offset
,
73 VMC_NO_INODE
, 0, 0, blocksize
, 0);
77 vm_clear_cache(dev_t dev
)
81 assert(dev
!= NO_DEV
);
83 memset(&m
, 0, sizeof(m
));
87 return _taskcall(VM_PROC_NR
, VM_CLEARCACHE
, &m
);