Commit fad23810 authored by Anton Burtsev's avatar Anton Burtsev Committed by Vikram Narayanan

Ping-pong code to test IPC

parent f9875eab
......@@ -202,4 +202,6 @@ source "drivers/hwtracing/intel_th/Kconfig"
source "drivers/fpga/Kconfig"
source "drivers/lcd/Kconfig"
endmenu
#
# LCD modules configuration
#
config LCD_PING_PONG_RECEIVER
tristate "LCD ping-pong IPC test (receiver)"
depends on LCD_PING_PONG_SENDER
default m
---help---
Receiver for the ping-pong LCD IPC test
config LCD_PING_PONG_SENDER
tristate "LCD ping-pong IPC test (sender)"
default m
---help---
Sender for the ping-pong LCD IPC test
# Disable temporarely while code is broken
#obj-y += ping-pong/
obj-y += ipc-ping-pong/
obj-m += receiver.o sender.o
/**
* sender.c - sender for the IPC ping-pong test
*
*
* Authors: Anton Burtsev <aburtsev@flux.utah.edu>
* Copyright: University of Utah
*/
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/miscdevice.h>
#include <linux/compat.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <linux/kthread.h>
#include <lcd/lcd.h>
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("LCD ping-pong test receiver");
extern int lcd_ping_pong_init_receiver(void);
int module_execution_loop(void) {
return 0;
};
int module_thread(void *p) {
int ret;
ret = lcd_ping_pong_init_receiver();
if (ret) {
printk(KERN_ERR "sender failed to initialize ping-pong environtment\n");
return -EINVAL;
}
return module_execution_loop();
};
int module_thread_init(void) {
struct task_struct *t;
t = kthread_create(module_thread, NULL, "pp-sender");
if (!t) {
printk(KERN_ERR "Failed to create module thread\n");
return -EINVAL;
};
wake_up_process(t);
return 0;
}
static int __init receiver_init(void)
{
printk(KERN_ERR "IPC ping-pong, sender module loaded\n");
return module_thread_init();
}
static void __exit receiver_exit(void)
{
}
module_init(receiver_init);
module_exit(receiver_exit);
/**
* sender.c - sender for the IPC ping-pong test
*
*
* Authors: Anton Burtsev <aburtsev@flux.utah.edu>
* Copyright: University of Utah
*/
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/miscdevice.h>
#include <linux/compat.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <linux/kthread.h>
#include <lcd/lcd.h>
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("LCD ping-pong IPC test (sender)");
struct sync_ipc *rvp;
int lcd_ping_pong_init_sender(void) {
int ret;
capability_t rvp_cap;
ret = lcd_enter();
if (ret) {
printk(KERN_ERR "Failed to enter LCD environment\n");
return ret;
};
rvp = alloc_sync_ipc();
if(!rvp) {
printk(KERN_ERR "Failed to allocate memory\n");
return -ENOMEM;
};
rvp_cap = lcd_cap_create_capability(&current->cspace, (void*)rvp, 0);
if(rvp_cap == 0) {
printk(KERN_ERR "Failed to create capability\n");
kfree(rvp);
return -ENOMEM;
};
current->utcb->boot_info.boot_rvp = rvp_cap;
return 0;
};
int lcd_ping_pong_init_receiver(void)
{
int ret;
struct sync_ipc *rvp;
capability_t rvp_cap;
ret = lcd_enter();
if (ret) {
printk(KERN_ERR "Failed to enter LCD environment\n");
return ret;
};
BUG_ON(rvp == NULL);
rvp_cap = lcd_cap_create_capability(&current->cspace, (void*)rvp, 0);
if(rvp_cap == 0) {
printk(KERN_ERR "Failed to create capability\n");
kfree(rvp);
return -ENOMEM;
};
current->utcb->boot_info.boot_rvp = rvp_cap;
return 0;
};
EXPORT_SYMBOL(lcd_ping_pong_init_receiver);
int module_execution_loop(void) {
return 0;
};
int module_thread(void *p) {
int ret;
ret = lcd_ping_pong_init_sender();
if (ret) {
printk(KERN_ERR "sender failed to initialize ping-pong environtment\n");
return -EINVAL;
}
return module_execution_loop();
};
int module_thread_init(void) {
struct task_struct *t;
t = kthread_create(module_thread, NULL, "pp-sender");
if (!t) {
printk(KERN_ERR "Failed to create module thread\n");
return -EINVAL;
};
wake_up_process(t);
return 0;
}
static int __init sender_init(void)
{
printk(KERN_ERR "IPC ping-pong, sender module loaded\n");
return module_thread_init();
}
static void __exit sender_exit(void)
{
}
module_init(sender_init);
module_exit(sender_exit);
......@@ -18,6 +18,8 @@ union utcb_union {
};
struct sync_ipc * alloc_sync_ipc(void);
int ipc_send(capability_t cap, struct message_info *msg);
int ipc_recv(capability_t rvp_cap, struct message_info *msg);
......
......@@ -105,5 +105,7 @@ int lcd_find_hva_by_gpa(struct lcd *lcd, u64 gpa, u64 *hva);
int lcd_run(struct lcd *lcd);
const char* lcd_exit_reason(int exit_code);
int lcd_enter(void);
#endif /* LCD_LCD_H */
......@@ -17,8 +17,13 @@ struct message_info {
u8 valid_cap_regs;
};
struct boot_info {
capability_t boot_rvp;
};
struct utcb {
struct message_info msg_info;
struct boot_info boot_info;
};
#endif
......@@ -7,6 +7,20 @@
#include <lcd/cap.h>
#include <lcd/lcd.h>
struct sync_ipc * alloc_sync_ipc() {
struct sync_ipc *rvp;
rvp = (struct sync_ipc*) kmalloc(sizeof(struct sync_ipc), GFP_KERNEL);
if(!rvp) {
printk(KERN_ERR "Failed to allocate memory\n");
return NULL;
};
spin_lock_init(&rvp->lock);
return rvp;
};
EXPORT_SYMBOL(alloc_sync_ipc);
int ipc_send(capability_t rvp_cap, struct message_info *msg)
{
struct task_struct *recv_task;
......
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