Commit 65fc6485 authored by Anton Burtsev's avatar Anton Burtsev Committed by Vikram Narayanan

Basic ping pong

parent b2788f9f
......@@ -26,6 +26,24 @@ extern int lcd_ping_pong_init_receiver(void);
int module_execution_loop(void) {
int ret;
capability_t rvp_cap = current->utcb->boot_info.boot_rvp;
struct message_info *msg = &current->utcb->msg_info;
msg->valid_regs = 6;
ret = ipc_recv(rvp_cap, msg);
if (ret) {
printk(KERN_ERR "receiver failed:%d\n", ret);
return ret;
};
// printk(KERN_INFO "Receiver: %c%c%c%c%c%c", (char) msg->regs[0], (char) msg->regs[1],
// (char) msg->regs[2], (char) msg->regs[3], (char) msg->regs[4], (char) msg->regs[5]);
printk(KERN_INFO "Receiver: %d%d%d%d%d%d", msg->regs[0], msg->regs[1],
msg->regs[2], msg->regs[3], msg->regs[4], msg->regs[5]);
return 0;
};
......
......@@ -91,6 +91,33 @@ EXPORT_SYMBOL(lcd_ping_pong_init_receiver);
int module_execution_loop(void) {
int ret;
capability_t rvp_cap = current->utcb->boot_info.boot_rvp;
struct message_info *msg = &current->utcb->msg_info;
msg->regs[0] = 1;
msg->regs[1] = 2;
msg->regs[2] = 3;
msg->regs[3] = 4;
msg->regs[4] = 5;
msg->regs[5] = 6;
#if 0
msg->regs[0] = (uint64_t)"H";
msg->regs[1] = (uint64_t)"e";
msg->regs[2] = (uint64_t)"l";
msg->regs[3] = (uint64_t)"l";
msg->regs[4] = (uint64_t)"o";
msg->regs[5] = (uint64_t)"\n";
#endif
msg->valid_regs = 6;
ret = ipc_send(rvp_cap, msg);
if (ret) {
printk(KERN_ERR "sender failed:%d\n", ret);
return ret;
};
return 0;
};
......
......@@ -34,6 +34,9 @@ struct sync_ipc * alloc_sync_ipc() {
return NULL;
};
INIT_LIST_HEAD(&rvp->senders);
INIT_LIST_HEAD(&rvp->receivers);
spin_lock_init(&rvp->lock);
return rvp;
};
......@@ -45,6 +48,20 @@ void free_sync_ipc(struct sync_ipc *rvp) {
};
EXPORT_SYMBOL(free_sync_ipc);
inline void transfer_msg(struct task_struct *to, struct task_struct *from) {
printk(KERN_INFO "Sending %d registers (recv ready to take %d)\n",
from->utcb->msg_info.valid_regs, to->utcb->msg_info.valid_regs);
// copy the message registers
// XXX: BU: maybe MIN(of valid_regs)?
memcpy(&to->utcb->msg_info.regs,
&from->utcb->msg_info.regs,
sizeof(uint64_t)*to->utcb->msg_info.valid_regs);
// BU: TODO: transfer capabilities
return;
}
int ipc_send(capability_t rvp_cap, struct message_info *msg)
{
struct task_struct *recv_task;
......@@ -78,7 +95,7 @@ int ipc_send(capability_t rvp_cap, struct message_info *msg)
spin_unlock_irqrestore(&sync_ipc->lock, flags);
schedule();
printk(KERN_ERR "ipc_send: somone woke me up\n");
printk(KERN_ERR "ipc_send: someone woke me up\n");
return 0;
}
......@@ -92,13 +109,7 @@ int ipc_send(capability_t rvp_cap, struct message_info *msg)
printk(KERN_ERR "ipc_send: found other end %s\n", recv_task->comm);
// copy the message registers
// XXX: BU: maybe MIN(of valid_regs)?
memcpy(recv_task->utcb->msg_info.regs,
current->utcb->msg_info.regs,
sizeof(uint64_t)*recv_task->utcb->msg_info.valid_regs);
// BU: TODO: transfer capabilities
transfer_msg(recv_task, current);
wake_up_process(recv_task);
printk(KERN_ERR "ipc_send: finished\n");
......@@ -140,7 +151,7 @@ int ipc_recv(capability_t rvp_cap, struct message_info *msg)
spin_unlock_irqrestore(&sync_ipc->lock, flags);
schedule();
printk(KERN_ERR "ipc_recv: somone woke me up\n");
printk(KERN_ERR "ipc_recv: someone woke me up\n");
return 0;
}
......@@ -152,15 +163,9 @@ int ipc_recv(capability_t rvp_cap, struct message_info *msg)
spin_unlock_irqrestore(&sync_ipc->lock, flags);
printk(KERN_ERR "ipc_send: other end %s\n", send_task->comm);
// copy the message registers
// XXX: BU: maybe MIN(of valid_regs)?
memcpy(current->utcb->msg_info.regs,
send_task->utcb->msg_info.regs,
sizeof(uint64_t)*send_task->utcb->msg_info.valid_regs);
// BU: TODO: transfer capabilities
transfer_msg(current, send_task);
wake_up_process(send_task);
printk(KERN_ERR "ipc_recv: finished\n");
return 0;
......
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