2 #ifndef _MINIX_SAFECOPIES_H
3 #define _MINIX_SAFECOPIES_H 1
5 #include <minix/sys_config.h>
9 typedef int32_t cp_grant_id_t
;
12 int cp_flags
; /* CPF_* below */
16 endpoint_t cp_who_to
; /* grantee */
17 vir_bytes cp_start
; /* memory */
18 size_t cp_len
; /* size in bytes */
19 char cp_reserved
[8]; /* future use */
23 endpoint_t cp_who_to
; /* grantee */
24 endpoint_t cp_who_from
; /* previous granter */
25 cp_grant_id_t cp_grant
; /* previous grant */
26 char cp_reserved
[8];/* future use */
30 endpoint_t cp_who_from
; /* granter */
31 endpoint_t cp_who_to
; /* grantee */
32 vir_bytes cp_start
; /* memory */
33 size_t cp_len
; /* size in bytes */
34 char cp_reserved
[8]; /* future use */
37 char cp_reserved
[8]; /* future use */
40 /* Vectored safecopy. */
42 /* Exactly one of the following must be SELF. */
43 endpoint_t v_from
; /* source */
44 endpoint_t v_to
; /* destination */
46 cp_grant_id_t v_gid
; /* grant id of other process */
47 size_t v_offset
; /* offset in other grant */
48 vir_bytes v_addr
; /* address in copier's space */
49 size_t v_bytes
; /* no. of bytes */
52 /* Invalid grant number. */
53 #define GRANT_INVALID -1
54 #define GRANT_VALID(g) ((g) > GRANT_INVALID)
56 /* Operations: any combination is ok. */
57 #define CPF_READ 0x000001 /* Granted process may read. */
58 #define CPF_WRITE 0x000002 /* Granted process may write. */
61 #define CPF_USED 0x000100 /* Grant slot in use. */
62 #define CPF_DIRECT 0x000200 /* Grant from this process to another. */
63 #define CPF_INDIRECT 0x000400 /* Grant from grant to another. */
64 #define CPF_MAGIC 0x000800 /* Grant from any to any. */
65 #define CPF_VALID 0x001000 /* Grant slot contains valid grant. */
67 /* Prototypes for functions in libsys. */
68 _PROTOTYPE( cp_grant_id_t cpf_grant_direct
, (endpoint_t
, vir_bytes
, size_t, int));
69 _PROTOTYPE( cp_grant_id_t cpf_grant_indirect
, (endpoint_t
, endpoint_t
, cp_grant_id_t
));
70 _PROTOTYPE( cp_grant_id_t cpf_grant_magic
, (endpoint_t
, endpoint_t
, vir_bytes
, size_t, int));
71 _PROTOTYPE( int cpf_revoke
, (cp_grant_id_t grant_id
));
72 _PROTOTYPE( int cpf_lookup
, (cp_grant_id_t g
, endpoint_t
*ep
, endpoint_t
*ep2
));
74 _PROTOTYPE( int cpf_getgrants
, (cp_grant_id_t
*grant_ids
, int n
));
75 _PROTOTYPE( int cpf_setgrant_direct
, (cp_grant_id_t g
, endpoint_t who
,
76 vir_bytes addr
, size_t size
, int access
));
77 _PROTOTYPE( int cpf_setgrant_indirect
, (cp_grant_id_t g
, endpoint_t who_to
,
78 endpoint_t who_from
, cp_grant_id_t his_g
));
79 _PROTOTYPE( int cpf_setgrant_magic
, (cp_grant_id_t g
, endpoint_t who_to
,
80 endpoint_t who_from
, vir_bytes addr
, size_t bytes
, int access
));
81 _PROTOTYPE( int cpf_setgrant_disable
, (cp_grant_id_t grant_id
));
83 /* Set a process' grant table location and size (in-kernel only). */
84 #define _K_SET_GRANT_TABLE(rp, ptr, entries) \
85 priv(rp)->s_grant_table= (ptr); \
86 priv(rp)->s_grant_entries= (entries);
88 #endif /* _MINIX_SAFECOPIES_H */