10 #include <minix/sysutil.h>
12 #include <machine/param.h>
13 #include <machine/vmparam.h>
15 int vm_cachecall(message
*m
, int call
, void *addr
, dev_t dev
, off_t dev_offset
,
16 ino_t ino
, off_t ino_offset
, u32_t
*flags
, int blocksize
)
18 if(blocksize
% PAGE_SIZE
)
19 panic("blocksize %d should be a multiple of pagesize %d\n",
20 blocksize
, PAGE_SIZE
);
22 if(ino_offset
% PAGE_SIZE
)
23 panic("inode offset %lld should be a multiple of pagesize %d\n",
24 ino_offset
, PAGE_SIZE
);
26 if(dev_offset
% PAGE_SIZE
)
27 panic("dev offset offset %lld should be a multiple of pagesize %d\n",
28 dev_offset
, PAGE_SIZE
);
30 memset(m
, 0, sizeof(*m
));
32 assert(dev
!= NO_DEV
);
34 m
->m_vmmcp
.dev_offset
= dev_offset
;
35 m
->m_vmmcp
.ino_offset
= ino_offset
;
37 m
->m_vmmcp
.block
= addr
;
38 m
->m_vmmcp
.flags_ptr
= flags
;
40 m
->m_vmmcp
.pages
= blocksize
/ PAGE_SIZE
;
43 return _taskcall(VM_PROC_NR
, call
, m
);
46 void *vm_map_cacheblock(dev_t dev
, off_t dev_offset
,
47 ino_t ino
, off_t ino_offset
, u32_t
*flags
, int blocksize
)
51 if(vm_cachecall(&m
, VM_MAPCACHEPAGE
, NULL
, dev
, dev_offset
,
52 ino
, ino_offset
, flags
, blocksize
) != OK
)
55 return m
.m_vmmcp_reply
.addr
;
58 int vm_set_cacheblock(void *block
, dev_t dev
, off_t dev_offset
,
59 ino_t ino
, off_t ino_offset
, u32_t
*flags
, int blocksize
)
63 return vm_cachecall(&m
, VM_SETCACHEPAGE
, block
, dev
, dev_offset
,
64 ino
, ino_offset
, flags
, blocksize
);
68 vm_clear_cache(dev_t dev
)
72 assert(dev
!= NO_DEV
);
74 memset(&m
, 0, sizeof(m
));
78 return _taskcall(VM_PROC_NR
, VM_CLEARCACHE
, &m
);