Commit bcdcbac3 authored by Josh Kunz's avatar Josh Kunz

Add callback payload wiring.

parent 88d7b8c9
Pipeline #1218 skipped
This diff is collapsed.
......@@ -374,7 +374,9 @@ struct cap_type_system* cap_cspace_get_type_system(struct cspace *cspace);
*
* If the slot is already occupied, or @c is invalid, returns non-zero.
*/
int cap_insert(struct cspace *cspace, cptr_t c, void *object, cap_type_t type, void *metadata);
int cap_insert(struct cspace *cspace, cptr_t c,
void *object, cap_type_t type,
void *callback_payload);
/**
* cap_delete -- Deletes object data from cspace at cnode pointed at by c
* @cspace: the cspace to delete capability from
......@@ -391,7 +393,7 @@ int cap_insert(struct cspace *cspace, cptr_t c, void *object, cap_type_t type, v
* If this is the last cnode that refers to the object, the
* delete callback for the capability's type will be invoked.
*/
void cap_delete(struct cspace *cspace, cptr_t c);
void cap_delete(struct cspace *cspace, cptr_t c, void * callback_payload);
/**
* Add the cnode 'c_dest' in 'cspacedest' to the cnode 'c_src's CDT. This is
......@@ -399,7 +401,8 @@ void cap_delete(struct cspace *cspace, cptr_t c);
* c_src's authority.
*/
int cap_derive(struct cspace *cspacesrc, cptr_t c_src,
struct cspace *cspacedest, cptr_t c_dest);
struct cspace *cspacedest, cptr_t c_dest,
void * callback_payload);
/**
* cap_grant -- Grant capability from source to destination cspace
......@@ -418,7 +421,7 @@ int cap_derive(struct cspace *cspacesrc, cptr_t c_src,
*/
int cap_grant(struct cspace *cspacesrc, cptr_t c_src,
struct cspace *cspacedst, cptr_t c_dst,
void *dst_metadata,
void *callback_payload,
cap_type_t *type);
/**
......@@ -437,7 +440,7 @@ int cap_grant(struct cspace *cspacesrc, cptr_t c_src,
* will be NULL'd out (so that when the slot is re-used in the future,
* the metadata field will start out as NULL).
*/
int cap_revoke(struct cspace *cspace, cptr_t c);
int cap_revoke(struct cspace *cspace, cptr_t c, void * callback_payload);
typedef bool (*cap_revoke_till_f)(struct cnode *);
......@@ -445,7 +448,8 @@ typedef bool (*cap_revoke_till_f)(struct cnode *);
* we reach a leaf node of the CDT. This allows for partial, revoke-like edits
* to the CDT. Calling cap_revoke_till with a function that allways returns
* false is equivalent to calling `cap_revoke` */
int cap_revoke_till(struct cspace *cspace, cptr_t c, cap_revoke_till_f func);
int cap_revoke_till(struct cspace *cspace, cptr_t c, cap_revoke_till_f func,
void * callback_payload);
/**
* cap_cnode_get -- Return the cnode that this cptr points to in cspace
......
......@@ -76,29 +76,29 @@ struct cap_type_ops {
/* invoked when a new object is inserted into a c-space. The operation
* can be aborted by returning a negative exit status. That status will
* be returned from the cap_X call. Be careful not to overlap exit codes */
int (*insert)(struct cnode *cnode);
int (*insert)(struct cnode *cnode, void * payload);
/* Invoked when a cnode is deleted. The cptr, cspace, and object associated
* with this cnode can obtained using the cnode accessor functions.
* The operation can be aborted by returning a negative exit status which
* will be returned from the cap_X call.
* XXX: Be careful not to overlap exit codes. */
int (*delete)(struct cnode *cnode);
int (*delete)(struct cnode *cnode, void * payload);
/* Invoked when a cnode is involed in a grant operation. 'src' corresponds
* to the 'src' cptr, and 'dst' corresponds to the 'dst' cptr. See the
* delete callback for interface. */
int (*grant)(struct cnode *src, struct cnode *dst);
int (*grant)(struct cnode *src, struct cnode *dst, void * payload);
/* This callback is invoked for the 'src' cnode when that cnode is involved
* in a 'derive' operation. The 'src' corresponds to the 'src' cptr, and
* the 'dst' corresponds to the 'dst' cptr. See delete callback for
* interface. */
int (*derive_src)(struct cnode *src, struct cnode *dst);
int (*derive_src)(struct cnode *src, struct cnode *dst, void * payload);
/* This callback is invoked for the 'dst' cnode (because its type may be
* different from the 'src' cnode and therefore it may have a different
* handler) when it is the 'dst' cptr of a 'derive' operation. Note: even
* though this callback is invoked on the dst node, the 'src' and 'dst' cnodes
* are still semantically related to the 'src' and 'dst' cnodes passed
* in the 'cap_derive' call. See the delete callback for interface. */
int (*derive_dst)(struct cnode *src, struct cnode *dst);
int (*derive_dst)(struct cnode *src, struct cnode *dst, void * payload);
};
/* CAP TYPE SYSTEMS -------------------------------------------------- */
......
......@@ -5,12 +5,12 @@
#include "libcap_internal.h"
#include "libcap_types.h"
int stringobj_delete(struct cnode *cnode)
int stringobj_delete(struct cnode *cnode, void * payload)
{
CAP_DEBUG(0, "object = '%s'\n", (char *)cap_cnode_object(cnode));
}
int stringobj_bin(struct cnode *src, struct cnode *cnode)
int stringobj_bin(struct cnode *src, struct cnode *cnode, void * payload)
{
CAP_DEBUG(0, "object_a = '%s', object_b = '%s'\n",
(char *)cap_cnode_object(src), (char *) cap_cnode_object(src));
......@@ -102,7 +102,7 @@ int testcase1()
/* Capability deletion from cspace.
*/
printf("\nTestCase : Delete Capability from Cspace.\n");
cap_delete(csp, slot_out);
cap_delete(csp, slot_out, NULL);
/*Lookup after deleting capability. It should Fail!!
*/
......@@ -314,7 +314,7 @@ int get_cnode(struct cspace *csp, cptr_t sslot) {
int do_revoke(struct cspace *csp, cptr_t sslot, struct cptr_cache *scache) {
int ret = 0;
ret = cap_revoke(csp, sslot);
ret = cap_revoke(csp, sslot, NULL);
if (ret < 0)
printf("Revoke failed\n");
cptr_free(scache, sslot);
......
......@@ -35,12 +35,12 @@
#include "libcap_internal.h"
#include "libcap_types.h"
int stringobj_delete(struct cnode *cnode)
int stringobj_delete(struct cnode *cnode, void * payload)
{
CAP_DEBUG(0, "object = '%s'\n", (char *)cap_cnode_object(cnode));
}
int stringobj_bin(struct cnode *src, struct cnode *cnode)
int stringobj_bin(struct cnode *src, struct cnode *cnode, void * payload)
{
CAP_DEBUG(0, "object_a = '%s', object_b = '%s'\n",
(char *)cap_cnode_object(src), (char *) cap_cnode_object(src));
......@@ -165,10 +165,10 @@ void *thread_revoke(void* arg)
printf("Thread Revoke : unstalled cptr slot %i (0x%lx,0x%lx)\n",
i,cptr_val(sslot_arr[i]),cptr_val(dslot_arr[i]));
}
ret = cap_revoke(scsp, sslot_arr[i]);
ret = cap_revoke(scsp, sslot_arr[i], NULL);
if (ret < 0)
printf("Revoke failed\n");
cap_delete(scsp, sslot_arr[i]);
cap_delete(scsp, sslot_arr[i], NULL);
cptr_free(scache, sslot_arr[i]);
sslot_arr[i] = CAP_CPTR_NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment