Commit 06a58b9b authored by Muktesh Khole's avatar Muktesh Khole Committed by Vikram Narayanan
Browse files

Moving lcd_lookup_capability to external interface

parent 4fc91fcf
......@@ -173,17 +173,21 @@ free_kfifo:
}
// does not lock the cspace caller responsbile for the same.
struct cte * lcd_lookup_capability(struct cap_space *cspace, cap_id cid)
struct cte * lcd_lookup_capability(struct task_struct *tcb, cap_id cid)
{
struct cte *cap = NULL, *cnode = NULL;
struct cap_space *cspace;
cap_id id = cid;
int index = 0;
int mask = (~0);
mask = mask << (CNODE_INDEX_BITS);
mask = ~mask;
if (tcb == NULL || cid == 0)
return NULL;
cspace = tcb->cspace;
// check if input is valid
if (cspace == NULL || cid == 0 || cspace->root_cnode.cnode.table == NULL)
if (cspace == NULL || cspace->root_cnode.cnode.table == NULL)
return NULL;
cnode = cspace->root_cnode.cnode.table;
......@@ -562,7 +566,7 @@ cap_id lcd_cap_grant(void *src_tcb, cap_id src_cid, void * dst_tcb, lcd_cap_righ
if (down_trylock(&(dtcb_cspace->sem_cspace)) == 0)
{
// Lookup the source TCB and get a pointer to capability.
src_cte = lcd_lookup_capability(stcb_cspace, src_cid);
src_cte = lcd_lookup_capability(stcb, src_cid);
// get a free slot in destination.
cid = lcd_lookup_free_slot(dtcb_cspace, &dst_cte);
if (cid != 0 && src_cte != NULL && dst_cte != NULL)
......@@ -620,7 +624,7 @@ uint32_t lcd_cap_delete(void * ptcb, cap_id cid)
return -1;
}
cap_cte = lcd_lookup_capability(tcb_cspace, cid);
cap_cte = lcd_lookup_capability(tcb, cid);
if (cap_cte == NULL || cap_cte->cap.cdt_node == NULL)
{
up(&(tcb_cspace->sem_cspace));
......@@ -654,7 +658,7 @@ uint32_t lcd_cap_revoke(void * ptcb, cap_id cid)
kfifo_free(&cdt_q);
return -1;
}
cap = lcd_lookup_capability(tcb_cspace, cid);
cap = lcd_lookup_capability(tcb, cid);
up(&(tcb_cspace->sem_cspace));
if (cap == NULL)
......@@ -773,7 +777,7 @@ uint32_t lcd_get_cap_rights(void * ptcb, cap_id cid, lcd_cap_rights *rights)
if (down_interruptible(&(tcb_cspace->sem_cspace)))
return -1;
cap = lcd_lookup_capability(tcb_cspace, cid);
cap = lcd_lookup_capability(tcb, cid);
if (cap == NULL || cap->ctetype != lcd_type_capability)
{
up(&(tcb_cspace->sem_cspace));
......
......@@ -175,8 +175,6 @@ void lcd_initialize_freelist(struct cte *cnode, bool bFirstCNode);
// empty cnode.
cap_id lcd_lookup_free_slot(struct cap_space *cspace, struct cte **cap);
struct cte * lcd_lookup_capability(struct cap_space *cspace, cap_id cid);
void lcd_update_cdt(void *ptcb);
uint32_t lcd_cap_delete_internal(struct cte *cap_cte);
......@@ -199,6 +197,8 @@ uint32_t lcd_cap_delete_internal(struct cte *cap_cte);
struct cap_space * lcd_create_cspace(void *objects[], lcd_cap_rights rights[]);
struct cte * lcd_lookup_capability(struct task_struct *tcb, cap_id cid);
// creates a new capability, inserts it into cspace of caller and
// returns the capability identifier.
// it is unclear who will have the right to perform this operation.
......
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