xref: /minix3/minix/lib/libsys/sys_safecopy.c (revision 685aa79304a3b43efa0194233b5d70cfb6df335e)
1433d6423SLionel Sambuc 
2433d6423SLionel Sambuc #include "syslib.h"
3433d6423SLionel Sambuc 
4433d6423SLionel Sambuc #include <minix/safecopies.h>
5433d6423SLionel Sambuc 
sys_safecopyfrom(endpoint_t src_e,cp_grant_id_t gr_id,vir_bytes offset,vir_bytes address,size_t bytes)6433d6423SLionel Sambuc int sys_safecopyfrom(endpoint_t src_e,
7433d6423SLionel Sambuc 	cp_grant_id_t gr_id, vir_bytes offset,
8433d6423SLionel Sambuc 	vir_bytes address, size_t bytes)
9433d6423SLionel Sambuc {
10433d6423SLionel Sambuc /* Transfer a block of data for which the other process has previously
11433d6423SLionel Sambuc  * given permission.
12433d6423SLionel Sambuc  */
13433d6423SLionel Sambuc 
14433d6423SLionel Sambuc   message copy_mess;
15433d6423SLionel Sambuc 
16433d6423SLionel Sambuc   copy_mess.m_lsys_kern_safecopy.from_to = src_e;
17433d6423SLionel Sambuc   copy_mess.m_lsys_kern_safecopy.gid = gr_id;
18433d6423SLionel Sambuc   copy_mess.m_lsys_kern_safecopy.offset = offset;
19*685aa793SDavid van Moolenbroek   copy_mess.m_lsys_kern_safecopy.address = (void *)address;
20433d6423SLionel Sambuc   copy_mess.m_lsys_kern_safecopy.bytes = bytes;
21433d6423SLionel Sambuc 
22433d6423SLionel Sambuc   return(_kernel_call(SYS_SAFECOPYFROM, &copy_mess));
23433d6423SLionel Sambuc 
24433d6423SLionel Sambuc }
25433d6423SLionel Sambuc 
sys_safecopyto(endpoint_t dst_e,cp_grant_id_t gr_id,vir_bytes offset,vir_bytes address,size_t bytes)26433d6423SLionel Sambuc int sys_safecopyto(endpoint_t dst_e,
27433d6423SLionel Sambuc 	cp_grant_id_t gr_id, vir_bytes offset,
28433d6423SLionel Sambuc 	vir_bytes address, size_t bytes)
29433d6423SLionel Sambuc {
30433d6423SLionel Sambuc /* Transfer a block of data for which the other process has previously
31433d6423SLionel Sambuc  * given permission.
32433d6423SLionel Sambuc  */
33433d6423SLionel Sambuc 
34433d6423SLionel Sambuc   message copy_mess;
35433d6423SLionel Sambuc 
36433d6423SLionel Sambuc   copy_mess.m_lsys_kern_safecopy.from_to = dst_e;
37433d6423SLionel Sambuc   copy_mess.m_lsys_kern_safecopy.gid = gr_id;
38433d6423SLionel Sambuc   copy_mess.m_lsys_kern_safecopy.offset = offset;
39*685aa793SDavid van Moolenbroek   copy_mess.m_lsys_kern_safecopy.address = (void *)address;
40433d6423SLionel Sambuc   copy_mess.m_lsys_kern_safecopy.bytes = bytes;
41433d6423SLionel Sambuc 
42433d6423SLionel Sambuc   return(_kernel_call(SYS_SAFECOPYTO, &copy_mess));
43433d6423SLionel Sambuc 
44433d6423SLionel Sambuc }
45