Commit 4dc67372 authored by Charlie Jacobsen's avatar Charlie Jacobsen Committed by Vikram Narayanan

Fixed ipc call/reply to alloc endpoint.

parent 6a641548
......@@ -658,9 +658,7 @@ static int test07(void)
struct test07_info info1;
struct test07_info info2;
cptr_t cptr1a;
cptr_t cptr1b;
cptr_t cptr2a;
cptr_t cptr2b;
int ret;
lcd1 = test_mk_lcd();
......@@ -703,28 +701,6 @@ static int test07(void)
lcd2->utcb.max_valid_out_cap_reg_idx = 0;
lcd2->utcb.max_valid_in_cap_reg_idx = 0;
/*
* Set up reply end point
*/
ret = lcd_cnode_alloc(lcd2->cspace, &cptr2b);
if (ret)
goto clean4;
ret = __lcd_mk_sync_endpoint(lcd2, cptr2b);
if (ret) {
LCD_ERR("mk lcd2 reply sync endpoint");
goto clean5;
}
lcd2->utcb.call_endpoint_cap = cptr2b;
/*
* Allocate slot for lcd1 for reply endpoint
*/
ret = lcd_cnode_alloc(lcd1->cspace, &cptr1b);
if (ret)
goto clean5;
lcd1->utcb.reply_endpoint_cap = cptr1b;
/*
* Spawn threads ...
*/
......@@ -736,7 +712,7 @@ static int test07(void)
lcd1_task = kthread_create(test07_thread1, &info1, "test07_thread1");
if (!lcd1_task) {
LCD_ERR("spawning lcd1 task");
goto clean5;
goto clean4;
}
info2.lcd = lcd2;
......@@ -749,7 +725,7 @@ static int test07(void)
/* cancel thread1 (before it even starts) */
kthread_stop(lcd1_task);
goto clean5;
goto clean4;
}
/* set tasks' lcds */
......@@ -769,29 +745,27 @@ static int test07(void)
if (info1.ret_val != 0) {
LCD_ERR("lcd1 non-zero ret_val = %d", info1.ret_val);
ret = -1;
goto clean5;
goto clean4;
}
if (info2.ret_val != 0) {
LCD_ERR("lcd2 non-zero ret_val = %d", info2.ret_val);
ret = -1;
goto clean5;
goto clean4;
}
if (lcd1->utcb.regs[0] != 5778) {
LCD_ERR("lcd1 reg 0 is %u", lcd1->utcb.regs[0]);
ret = -1;
goto clean5;
goto clean4;
}
if (lcd2->utcb.regs[0] != 5778) {
LCD_ERR("lcd2 reg 0 is %u", lcd2->utcb.regs[0]);
ret = -1;
goto clean5;
goto clean4;
}
ret = 0;
goto clean5;
goto clean4;
clean5:
__lcd_rm_sync_endpoint(lcd2, cptr2b);
clean4:
__lcd_rm_sync_endpoint(lcd1, cptr1a);
clean3:
......
......@@ -295,15 +295,39 @@ int __lcd_recv(struct lcd *lcd, cptr_t c)
}
EXPORT_SYMBOL(__lcd_recv);
static int lcd_call_alloc(struct lcd *lcd)
{
int ret;
cptr_t call_cptr;
ret = lcd_cnode_alloc(lcd->cspace, &call_cptr);
if (ret)
return ret;
ret = __lcd_mk_sync_endpoint(lcd, call_cptr);
if (ret)
return ret;
lcd->utcb.call_endpoint_cap = call_cptr;
return 0;
}
int __lcd_call(struct lcd *lcd, cptr_t c)
{
int ret;
/*
* Alloc special call endpoint
*/
ret = lcd_call_alloc(lcd);
if (ret)
return ret;
/*
* LOCK cap
*/
ret = lcd_cap_lock();
if (ret)
return ret;
goto out;
ret = lcd_do_send(lcd, c, 1);
......@@ -312,19 +336,52 @@ int __lcd_call(struct lcd *lcd, cptr_t c)
*/
lcd_cap_unlock();
if (ret)
return ret;
if (ret) {
LCD_ERR("send of call failed");
goto out;
}
/*
* Receive on my special end point
*/
return __lcd_recv(lcd, lcd->utcb.call_endpoint_cap);
ret = __lcd_recv(lcd, lcd->utcb.call_endpoint_cap);
if (ret) {
LCD_ERR("recv of call failed");
goto out;
}
ret = 0;
goto out;
out:
__lcd_rm_sync_endpoint(lcd, lcd->utcb.call_endpoint_cap);
return ret;
}
EXPORT_SYMBOL(__lcd_call);
static int lcd_reply_alloc(struct lcd *lcd)
{
cptr_t reply_cap;
int ret;
ret = lcd_cnode_alloc(lcd->cspace, &reply_cap);
if (ret)
return ret;
lcd->utcb.reply_endpoint_cap = reply_cap;
return 0;
}
int __lcd_reply(struct lcd *lcd)
{
int ret;
/*
* Alloc slot for reply endpoint
*/
ret = lcd_reply_alloc(lcd);
if (ret)
return ret;
/*
* LOCK cap
*/
......
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