can be reserved (USED), while toggling VALID on and off.
#define CPF_DIRECT 0x000200 /* Grant from this process to another. */
#define CPF_INDIRECT 0x000400 /* Grant from grant to another. */
#define CPF_MAGIC 0x000800 /* Grant from any to any. */
+#define CPF_VALID 0x001000 /* Grant slot contains valid grant. */
/* Prototypes for functions in libsys. */
_PROTOTYPE( cp_grant_id_t cpf_grant_direct, (endpoint_t, vir_bytes, size_t, int));
endpoint_t who_from, cp_grant_id_t his_g));
_PROTOTYPE( int cpf_setgrant_magic, (cp_grant_id_t g, endpoint_t who_to,
endpoint_t who_from, vir_bytes addr, size_t bytes, int access));
+_PROTOTYPE( int cpf_setgrant_disable, (cp_grant_id_t grant_id));
/* Set a process' grant table location and size (in-kernel only). */
#define _K_SET_GRANT_TABLE(rp, ptr, entries) \
phys_copy(phys_grant, vir2phys(&g), sizeof(g));
/* Check validity. */
- if(!(g.cp_flags & CPF_USED)) {
- kprintf("grant verify failed: invalid\n");
+ if((g.cp_flags & (CPF_USED | CPF_VALID)) != (CPF_USED | CPF_VALID)) {
+ kprintf("grant verify failed: unused or invalid\n");
return EPERM;
}
GID_CHECK(gid);
ACCESS_CHECK(access);
- grants[gid].cp_flags = access | CPF_DIRECT | CPF_USED;
+ grants[gid].cp_flags = access | CPF_DIRECT | CPF_USED | CPF_VALID;
grants[gid].cp_u.cp_direct.cp_who_to = who;
grants[gid].cp_u.cp_direct.cp_start = addr;
grants[gid].cp_u.cp_direct.cp_len = bytes;
GID_CHECK(gid);
/* Fill in new slot data. */
- grants[gid].cp_flags = CPF_USED | CPF_INDIRECT;
+ grants[gid].cp_flags = CPF_USED | CPF_INDIRECT | CPF_VALID;
grants[gid].cp_u.cp_indirect.cp_who_to = who_to;
grants[gid].cp_u.cp_indirect.cp_who_from = who_from;
grants[gid].cp_u.cp_indirect.cp_grant = his_gid;
ACCESS_CHECK(access);
/* Fill in new slot data. */
- grants[gid].cp_flags = CPF_USED | CPF_MAGIC | access;
+ grants[gid].cp_flags = CPF_USED | CPF_MAGIC | CPF_VALID | access;
grants[gid].cp_u.cp_magic.cp_who_to = who_to;
grants[gid].cp_u.cp_magic.cp_who_from = who_from;
grants[gid].cp_u.cp_magic.cp_start = addr;
return 0;
}
+PUBLIC int
+cpf_setgrant_disable(gid)
+cp_grant_id_t gid;
+{
+ GID_CHECK(gid);
+
+ /* Grant is now no longer valid, but still in use. */
+ grants[gid].cp_flags = CPF_USED;
+
+ return 0;
+}
+