panic() cleanup.
[minix.git] / include / minix / safecopies.h
blob0f237844b50d5925981ecd88dd481991cb3794dd
2 #ifndef _MINIX_SAFECOPIES_H
3 #define _MINIX_SAFECOPIES_H 1
5 #include <minix/sys_config.h>
6 #include <minix/types.h>
7 #include <stdint.h>
9 typedef struct {
10 int cp_flags; /* CPF_* below */
11 union {
12 struct {
13 /* CPF_DIRECT */
14 endpoint_t cp_who_to; /* grantee */
15 vir_bytes cp_start; /* memory */
16 size_t cp_len; /* size in bytes */
17 char cp_reserved[8]; /* future use */
18 } cp_direct;
19 struct {
20 /* CPF_INDIRECT */
21 endpoint_t cp_who_to; /* grantee */
22 endpoint_t cp_who_from; /* previous granter */
23 cp_grant_id_t cp_grant; /* previous grant */
24 char cp_reserved[8];/* future use */
25 } cp_indirect;
26 struct {
27 /* CPF_MAGIC */
28 endpoint_t cp_who_from; /* granter */
29 endpoint_t cp_who_to; /* grantee */
30 vir_bytes cp_start; /* memory */
31 size_t cp_len; /* size in bytes */
32 char cp_reserved[8]; /* future use */
33 } cp_magic;
34 } cp_u;
35 char cp_reserved[8]; /* future use */
36 } cp_grant_t;
38 /* Vectored safecopy. */
39 struct vscp_vec {
40 /* Exactly one of the following must be SELF. */
41 endpoint_t v_from; /* source */
42 endpoint_t v_to; /* destination */
44 cp_grant_id_t v_gid; /* grant id of other process */
45 size_t v_offset; /* offset in other grant */
46 vir_bytes v_addr; /* address in copier's space */
47 size_t v_bytes; /* no. of bytes */
50 /* Types on VM invocation. */
51 #define VMPTYPE_NONE 0
52 #define VMPTYPE_CHECK 1
53 #define VMPTYPE_COWMAP 2
54 #define VMPTYPE_SMAP 3
55 #define VMPTYPE_SUNMAP 4
57 /* Invalid grant number. */
58 #define GRANT_INVALID ((cp_grant_id_t) -1)
59 #define GRANT_VALID(g) ((g) > GRANT_INVALID)
61 /* Operations: any combination is ok. */
62 #define CPF_READ 0x000001 /* Granted process may read. */
63 #define CPF_WRITE 0x000002 /* Granted process may write. */
64 #define CPF_MAP 0x000004 /* Granted process may map. */
66 /* Internal flags. */
67 #define CPF_USED 0x000100 /* Grant slot in use. */
68 #define CPF_DIRECT 0x000200 /* Grant from this process to another. */
69 #define CPF_INDIRECT 0x000400 /* Grant from grant to another. */
70 #define CPF_MAGIC 0x000800 /* Grant from any to any. */
71 #define CPF_VALID 0x001000 /* Grant slot contains valid grant. */
73 /* Prototypes for functions in libsys. */
74 _PROTOTYPE( cp_grant_id_t cpf_grant_direct, (endpoint_t, vir_bytes, size_t, int));
75 _PROTOTYPE( cp_grant_id_t cpf_grant_indirect, (endpoint_t, endpoint_t, cp_grant_id_t));
76 _PROTOTYPE( cp_grant_id_t cpf_grant_magic, (endpoint_t, endpoint_t, vir_bytes, size_t, int));
77 _PROTOTYPE( int cpf_revoke, (cp_grant_id_t grant_id));
78 _PROTOTYPE( int cpf_lookup, (cp_grant_id_t g, endpoint_t *ep, endpoint_t *ep2));
80 _PROTOTYPE( int cpf_getgrants, (cp_grant_id_t *grant_ids, int n));
81 _PROTOTYPE( int cpf_setgrant_direct, (cp_grant_id_t g, endpoint_t who,
82 vir_bytes addr, size_t size, int access));
83 _PROTOTYPE( int cpf_setgrant_indirect, (cp_grant_id_t g, endpoint_t who_to,
84 endpoint_t who_from, cp_grant_id_t his_g));
85 _PROTOTYPE( int cpf_setgrant_magic, (cp_grant_id_t g, endpoint_t who_to,
86 endpoint_t who_from, vir_bytes addr, size_t bytes, int access));
87 _PROTOTYPE( int cpf_setgrant_disable, (cp_grant_id_t grant_id));
88 _PROTOTYPE( void cpf_reload, (void));
90 /* Set a process' grant table location and size (in-kernel only). */
91 #define _K_SET_GRANT_TABLE(rp, ptr, entries) \
92 priv(rp)->s_grant_table= (ptr); \
93 priv(rp)->s_grant_entries= (entries);
95 #endif /* _MINIX_SAFECOPIES_H */