2 #ifndef _MINIX_SAFECOPIES_H
3 #define _MINIX_SAFECOPIES_H 1
5 #include <minix/sys_config.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. */
60 #define CPF_TRY 0x000010 /* Fail fast on unmapped memory. */
63 #define CPF_USED 0x000100 /* Grant slot in use. */
64 #define CPF_DIRECT 0x000200 /* Grant from this process to another. */
65 #define CPF_INDIRECT 0x000400 /* Grant from grant to another. */
66 #define CPF_MAGIC 0x000800 /* Grant from any to any. */
67 #define CPF_VALID 0x001000 /* Grant slot contains valid grant. */
69 /* Prototypes for functions in libsys. */
70 cp_grant_id_t
cpf_grant_direct(endpoint_t
, vir_bytes
, size_t, int);
71 cp_grant_id_t
cpf_grant_indirect(endpoint_t
, endpoint_t
, cp_grant_id_t
);
72 cp_grant_id_t
cpf_grant_magic(endpoint_t
, endpoint_t
, vir_bytes
, size_t,
74 int cpf_revoke(cp_grant_id_t grant_id
);
75 int cpf_lookup(cp_grant_id_t g
, endpoint_t
*ep
, endpoint_t
*ep2
);
77 int cpf_getgrants(cp_grant_id_t
*grant_ids
, int n
);
78 int cpf_setgrant_direct(cp_grant_id_t g
, endpoint_t who
, vir_bytes addr
,
79 size_t size
, int access
);
80 int cpf_setgrant_indirect(cp_grant_id_t g
, endpoint_t who_to
, endpoint_t
81 who_from
, cp_grant_id_t his_g
);
82 int cpf_setgrant_magic(cp_grant_id_t g
, endpoint_t who_to
, endpoint_t
83 who_from
, vir_bytes addr
, size_t bytes
, int access
);
84 int cpf_setgrant_disable(cp_grant_id_t grant_id
);
85 void cpf_reload(void);
87 /* Set a process' grant table location and size (in-kernel only). */
88 #define _K_SET_GRANT_TABLE(rp, ptr, entries) \
89 priv(rp)->s_grant_table= (ptr); \
90 priv(rp)->s_grant_entries= (entries);
92 #endif /* _MINIX_SAFECOPIES_H */