kernel: some boottime sanitychecks
[minix.git] / include / minix / safecopies.h
blob5b94cc04d91d49c11e3a841f5e43458cc39b1cf9
2 #ifndef _MINIX_SAFECOPIES_H
3 #define _MINIX_SAFECOPIES_H 1
5 #include <minix/sys_config.h>
6 #include <minix/types.h>
7 #include <minix/vm.h>
8 #include <stdint.h>
10 typedef struct {
11 int cp_flags; /* CPF_* below */
12 union {
13 struct {
14 /* CPF_DIRECT */
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 */
19 } cp_direct;
20 struct {
21 /* CPF_INDIRECT */
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 */
26 } cp_indirect;
27 struct {
28 /* CPF_MAGIC */
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 */
34 } cp_magic;
35 } cp_u;
36 char cp_reserved[8]; /* future use */
37 } cp_grant_t;
39 /* Vectored safecopy. */
40 struct vscp_vec {
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. */
59 /* Internal flags. */
60 #define CPF_USED 0x000100 /* Grant slot in use. */
61 #define CPF_DIRECT 0x000200 /* Grant from this process to another. */
62 #define CPF_INDIRECT 0x000400 /* Grant from grant to another. */
63 #define CPF_MAGIC 0x000800 /* Grant from any to any. */
64 #define CPF_VALID 0x001000 /* Grant slot contains valid grant. */
66 /* Prototypes for functions in libsys. */
67 cp_grant_id_t cpf_grant_direct(endpoint_t, vir_bytes, size_t, int);
68 cp_grant_id_t cpf_grant_indirect(endpoint_t, endpoint_t, cp_grant_id_t);
69 cp_grant_id_t cpf_grant_magic(endpoint_t, endpoint_t, vir_bytes, size_t,
70 int);
71 int cpf_revoke(cp_grant_id_t grant_id);
72 int cpf_lookup(cp_grant_id_t g, endpoint_t *ep, endpoint_t *ep2);
74 int cpf_getgrants(cp_grant_id_t *grant_ids, int n);
75 int cpf_setgrant_direct(cp_grant_id_t g, endpoint_t who, vir_bytes addr,
76 size_t size, int access);
77 int cpf_setgrant_indirect(cp_grant_id_t g, endpoint_t who_to, endpoint_t
78 who_from, cp_grant_id_t his_g);
79 int cpf_setgrant_magic(cp_grant_id_t g, endpoint_t who_to, endpoint_t
80 who_from, vir_bytes addr, size_t bytes, int access);
81 int cpf_setgrant_disable(cp_grant_id_t grant_id);
82 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 */