Commit c0ed1e16 authored by Charles Jacobsen's avatar Charles Jacobsen Committed by Vikram Narayanan

Fixed build errors for ipc first draft.

parent fff03177
......@@ -8,6 +8,9 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/completion.h>
#include <linux/kthread.h>
#include "../include/common.h"
#include "defs.h"
......@@ -32,7 +35,7 @@ static inline int test_check_cnode(struct cspace *cspace, cptr_t cptr,
int rights)
{
struct cnode *cnode;
int ret;
if (lcd_cap_lock())
return -1;
if (__lcd_cnode_lookup(cspace, cptr, &cnode)) {
......@@ -91,7 +94,6 @@ static inline void test_rm_lcd(struct lcd *lcd)
static int test01(void)
{
struct cspace *cspace;
int ret;
if (lcd_mk_cspace(&cspace))
LCD_FAIL("mk cspace");
......@@ -478,7 +480,7 @@ static int test06_thread1(void *__info)
out:
info->ret_val = ret;
complete(info->done);
complete(&info->done);
return 0;
}
......@@ -505,7 +507,7 @@ static int test06_thread2(void *__info)
out:
info->ret_val = ret;
complete(info->done);
complete(&info->done);
return 0;
}
......@@ -606,8 +608,8 @@ static int test06(void)
ret = -1;
goto clean4;
}
if (lcd1->regs[0] != 12345) {
LCD_ERR("lcd1 reg 0 is %u", lcd1->regs[0]);
if (lcd1->utcb.regs[0] != 12345) {
LCD_ERR("lcd1 reg 0 is %u", lcd1->utcb.regs[0]);
ret = -1;
goto clean4;
}
......
......@@ -16,8 +16,8 @@
static void copy_msg_regs(struct lcd *from, struct lcd *to)
{
int i;
for (i = 0; i < from->max_valid_reg_idx; i++)
to->regs[i] = from->regs[i];
for (i = 0; i < from->utcb.max_valid_reg_idx; i++)
to->utcb.regs[i] = from->utcb.regs[i];
}
static void copy_msg_cap(struct lcd *from, struct lcd *to,
......@@ -26,7 +26,7 @@ static void copy_msg_cap(struct lcd *from, struct lcd *to,
int ret;
ret = lcd_cnode_grant(from->cspace, to->cspace, from_ptr, to_ptr,
LCD_CAP_ALL_RIGHTS);
LCD_CAP_RIGHT_ALL);
if (ret) {
LCD_ERR("failed to transfer cap @ %d in lcd %p to slot @ %d in lcd %p",
from_ptr, from, to_ptr, to);
......@@ -36,10 +36,10 @@ static void copy_msg_cap(struct lcd *from, struct lcd *to,
static void copy_msg_caps(struct lcd *from, struct lcd *to)
{
int i;
for (i = 0; i < from->max_valid_out_cap_reg_idx &&
i < to->max_valid_in_cap_reg_idx; i++)
copy_msg_cap(from, to, from->out_cap_regs[i],
to->in_cap_regs[i]);
for (i = 0; i < from->utcb.max_valid_out_cap_reg_idx &&
i < to->utcb.max_valid_in_cap_reg_idx; i++)
copy_msg_cap(from, to, from->utcb.out_cap_regs[i],
to->utcb.in_cap_regs[i]);
}
static void copy_call_endpoint(struct lcd *from, struct lcd *to)
......@@ -70,11 +70,12 @@ static int lcd_do_send(struct lcd *from, cptr_t c, int making_call)
int ret;
struct lcd *to;
struct cnode *cnode;
struct sync_endpoint *e;
/*
* Lookup cnode
*/
ret = __lcd_lookup_cnode(from->cspace, c, &cnode);
ret = __lcd_cnode_lookup(from->cspace, c, &cnode);
if (ret)
goto fail1;
/*
......@@ -113,7 +114,7 @@ static int lcd_do_send(struct lcd *from, cptr_t c, int making_call)
* IMPORTANT: Must unlock cap and e's lock before going to
* sleep.
*/
mutex_unlock(&e->unlock());
mutex_unlock(&e->lock);
lcd_cap_unlock();
set_current_state(TASK_INTERRUPTIBLE);
......@@ -166,7 +167,7 @@ int __lcd_send(struct lcd *lcd, cptr_t c)
if (ret)
return ret;
ret = lcd_do_send(lcd, c);
ret = lcd_do_send(lcd, c, 0);
/*
* UNLOCK cap
......@@ -186,7 +187,7 @@ static int lcd_do_recv(struct lcd *to, cptr_t c)
/*
* Lookup cnode
*/
ret = __lcd_lookup_cnode(to->cspace, c, &cnode);
ret = __lcd_cnode_lookup(to->cspace, c, &cnode);
if (ret)
goto fail1;
/*
......@@ -223,7 +224,7 @@ static int lcd_do_recv(struct lcd *to, cptr_t c)
*
* IMPORTANT: Must unlock cap before going to sleep.
*/
mutex_unlock(&e->unlock());
mutex_unlock(&e->lock);
lcd_cap_unlock();
set_current_state(TASK_INTERRUPTIBLE);
......@@ -299,7 +300,13 @@ int __lcd_call(struct lcd *lcd, cptr_t c)
*/
lcd_cap_unlock();
return ret;
if (ret)
return ret;
/*
* Receive on my special end point
*/
return __lcd_recv(lcd, lcd->utcb.call_endpoint_cap);
}
int __lcd_reply(struct lcd *lcd)
......@@ -312,7 +319,7 @@ int __lcd_reply(struct lcd *lcd)
if (ret)
return ret;
ret = lcd_do_send(lcd, lcd->reply_endpoint_cap, 0);
ret = lcd_do_send(lcd, lcd->utcb.reply_endpoint_cap, 0);
/*
* UNLOCK cap
......@@ -325,8 +332,6 @@ int __lcd_reply(struct lcd *lcd)
int lcd_mk_sync_endpoint(struct lcd *lcd, cptr_t c)
{
struct sync_endpoint *e;
struct sync_endpoint_proxy *proxy;
struct cnode *cnode;
int ret = -EINVAL;
/*
* Allocate end point
......@@ -341,101 +346,42 @@ int lcd_mk_sync_endpoint(struct lcd *lcd, cptr_t c)
*/
INIT_LIST_HEAD(&e->senders);
INIT_LIST_HEAD(&e->receivers);
INIT_LIST_HEAD(&e->proxies);
mutex_init(&e->lock);
/*
* Allocate end point proxy
* Insert endpoint into cspace at c
*/
proxy = kmalloc(sizeof(*proxy), GFP_KERNEL);
if (!proxy) {
ret = -ENOMEM;
goto fail2;
}
/*
* Initialize proxy
*/
INIT_LIST_HEAD(&proxy->lcd_proxy_list);
INIT_LIST_HEAD(&proxy->endpoint_proxy_list);
INIT_LIST_HEAD(&proxy->proxies);
proxy->parent = lcd;
proxy->ep = e;
/*
* Add proxy to end point
*/
list_add(&proxy->proxies, &e->proxies);
/*
* Insert endpoint proxy into cspace at c
*/
ret = lcd_cnode_insert(lcd->cspace, c, proxy, LCD_CAP_TYPE_SYNC_EP,
ret = lcd_cnode_insert(lcd->cspace, c, e, LCD_CAP_TYPE_SYNC_EP,
LCD_CAP_RIGHT_ALL);
if (ret) {
LCD_ERR("insert endpoint");
goto fail3;
goto fail2;
}
return 0;
fail3:
kfree(proxy);
fail2:
kfree(e);
fail1:
return ret;
}
static void __cleanup_sync_endpoint_proxies(struct sync_endpoint *e)
{
struct list_head *ptr;
struct list_head *n;
struct sync_endpoint_proxy *proxy;
list_for_each_safe(ptr, n, &e->proxies) {
proxy = list_entry(ptr, struct sync_endpoint_proxy, proxies);
/*
* Remove proxy from parent lcd's list (send or recv)
*/
list_del(&proxy->lcd_active_list);
/*
* Remove proxy from end point's list (send or recv)
*/
list_del(&proxy->endpoint_active_list);
/*
* Remove proxy from all of end point's proxies
* (active/inactive)
*/
list_del(&proxy->proxies);
/*
* Free mem
*/
kfree(proxy);
}
}
static int __cleanup_sync_endpoint(struct cnode *cnode)
{
struct sync_endpoint_proxy *proxy;
struct sync_endpoint *e;
/*
* Check that cnode contains sync ep (proxy), and lcd is owner
* Check that cnode contains sync ep, and lcd is owner
*/
if (!__lcd_cnode_is_sync_ep(cnode))
return -EINVAL;
if (!__lcd_cnode_is_owner(cnode))
return -EINVAL;
proxy = __lcd_cnode_object(cnode);
e = proxy->endpoint;
e = __lcd_cnode_object(cnode);
/*
* Remove from cspaces first, so no one can refer to sync ep (via
* a proxy)
* Remove from cspaces first, so no one can refer to sync ep
*/
__lcd_cnode_free(cnode);
/*
* Remove all proxies (proxy var invalid after this point!)
*/
__cleanup_sync_endpoint_proxies(e);
/*
* Free end point
*/
......@@ -447,12 +393,13 @@ static int __cleanup_sync_endpoint(struct cnode *cnode)
static int __lcd_rm_sync_endpoint(struct lcd *lcd, cptr_t cptr)
{
int ret;
struct cnode *cnode;
/*
* Look up cnode
*/
ret = __lcd_cnode_lookup(lcd->cspace, c, &cnode);
ret = __lcd_cnode_lookup(lcd->cspace, cptr, &cnode);
if (ret) {
LCD_ERR("cnode lookup at %lld", c);
LCD_ERR("cnode lookup at %lld", cptr);
return ret;
}
/*
......@@ -464,7 +411,6 @@ static int __lcd_rm_sync_endpoint(struct lcd *lcd, cptr_t cptr)
int lcd_rm_sync_endpoint(struct lcd *lcd, cptr_t cptr)
{
struct cnode *cnode;
int ret;
/*
* LOCK cap
......
......@@ -22,35 +22,39 @@
*/
/**
* Send data in from's lcd->utcb to first receiver in line for the
* endpoint identified by c in t's cspace. The receiver will get
* a copy of from's registers (up to max valid) and out capabilities
* Send data in lcd->utcb to first receiver in line for the
* endpoint identified by c in lcd's cspace. The receiver will get
* a copy of lcd's registers (up to max valid) and out capabilities
* will be copied and inserted into the receiver's cspace, using
* the in cap registers.
*
* If a receiver is not waiting, from is placed in the end point's
* sender wait list, and from is put to sleep.
* If a receiver is not waiting, lcd is placed in the end point's
* sender wait list and put to sleep.
*/
int __lcd_send(struct task_struct *from, cptr_t c);
int __lcd_send(struct lcd *lcd, cptr_t c);
/**
* Other side of send (see above).
*
* If a sender is not waiting, to is placed in wait list and put to
* If a sender is not waiting, lcd is placed in wait list and put to
* sleep.
*/
int __lcd_recv(struct task_struct *to, cptr_t c);
int __lcd_recv(struct lcd *lcd, cptr_t c);
/**
* Like a send, but does a matching receive call on a capability just
* for this purpose. The receiver gets a copy of this capability that
* it can use once for a return call.
*/
int __lcd_call(struct task_struct *from, cptr_t c);
int __lcd_call(struct lcd *lcd, cptr_t c);
/**
* Other side of a lcd call.
*/
int __lcd_reply(struct lcd *lcd);
/**
* Places from on receive queue for all end points identified by the
* cptr's cs. When a matching send is received, idx points to the
* cptr in cs on which the receive happened.
*/
int __lcd_select(struct task_struct *from, cptr_t *cs, int cs_count,
int __lcd_select(struct lcd *from, cptr_t *cs, int cs_count,
cptr_t *c_out);
#endif /* LCD_PROTOTYPE_API_INTERNAL_H */
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