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
)
48 if(vm_cachecall(&m
, VM_MAPCACHEPAGE
, NULL
, dev
, dev_offset
,
49 ino
, ino_offset
, flags
, blocksize
) != OK
)
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
)
60 return vm_cachecall(&m
, VM_SETCACHEPAGE
, block
, dev
, dev_offset
,
61 ino
, ino_offset
, flags
, blocksize
);