2 #ifndef _MINIX_SAFECOPIES_H
3 #define _MINIX_SAFECOPIES_H 1
5 #include <minix/sys_config.h>
6 #include <minix/types.h>
11 int cp_flags
; /* CPF_* below */
15 endpoint_t cp_who_to
; /* grantee */
16 vir_bytes cp_start
; /* memory */
17 size_t cp_len
; /* size in bytes */
18 char cp_reserved
[8]; /* future use */
22 endpoint_t cp_who_to
; /* grantee */
23 endpoint_t cp_who_from
; /* previous granter */
24 cp_grant_id_t cp_grant
; /* previous grant */
25 char cp_reserved
[8];/* future use */
29 endpoint_t cp_who_from
; /* granter */
30 endpoint_t cp_who_to
; /* grantee */
31 vir_bytes cp_start
; /* memory */
32 size_t cp_len
; /* size in bytes */
33 char cp_reserved
[8]; /* future use */
36 char cp_reserved
[8]; /* future use */
39 /* Vectored safecopy. */
41 /* Exactly one of the following must be SELF. */
42 endpoint_t v_from
; /* source */
43 endpoint_t v_to
; /* destination */
45 cp_grant_id_t v_gid
; /* grant id of other process */
46 size_t v_offset
; /* offset in other grant */
47 vir_bytes v_addr
; /* address in copier's space */
48 size_t v_bytes
; /* no. of bytes */
51 /* Invalid grant number. */
52 #define GRANT_INVALID ((cp_grant_id_t) -1)
53 #define GRANT_VALID(g) ((g) > GRANT_INVALID)
55 /* Operations: any combination is ok. */
56 #define CPF_READ 0x000001 /* Granted process may read. */
57 #define CPF_WRITE 0x000002 /* Granted process may write. */
58 #define CPF_MAP 0x000004 /* Granted process may map. */
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
));
82 _PROTOTYPE( void cpf_reload
, (void));
84 /* Set a process' grant table location and size (in-kernel only). */
85 #define _K_SET_GRANT_TABLE(rp, ptr, entries) \
86 priv(rp)->s_grant_table= (ptr); \
87 priv(rp)->s_grant_entries= (entries);
89 #endif /* _MINIX_SAFECOPIES_H */