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

Meaningful approach for creating and connecting LCDs

parent 3b7f2791
......@@ -16,3 +16,26 @@ config LCD_PING_PONG_SENDER
default m
---help---
Sender for the ping-pong LCD IPC test
config LCD_CS_INIT
tristate "LCD client-server test (init module)"
depends on LCD_CS_CLIENT
depends on LCD_CS_SERVER
depends on LCD
default m
---help---
Init code to start the LCD client-server test
config LCD_CS_CLIENT
tristate "LCD client-server test (client)"
depends on LCD
default m
---help---
Client module for the LCD client-server test
config LCD_CS_SERVER
tristate "LCD client-server test (server)"
depends on LCD
default m
---help---
Server module for the LCD client-server test
obj-m += client.o server.o
obj-m += client.o server.o cs-init.o
......@@ -5,6 +5,9 @@
/* Caller stubs */
/* Generate a global capability variable */
client_t client;
struct cap_space module_cspace;
int __register_server_caller(capability_t client, struct server_interface *server) {
int ret;
......@@ -44,6 +47,8 @@ int register_server_callee(struct message_info *msg, capability_t reply_cap) {
};
ret = register_server(server);
......@@ -72,7 +77,7 @@ int execution_loop(void) {
struct message_info *msg = &current->utcb->msg_info;
ret = lcd_alloc_cap(&current->cap_cache, &server_interface);
ret = lcd_alloc_cap(&current->cap_cache, &server_interface);
if(ret) {
printk(KERN_ERR "Failed to allocate free capability\n");
return -ENOSPC;
......@@ -108,7 +113,7 @@ int execution_loop(void) {
struct sync_ipc *client_server_rvp;
int accept_client_introduction(void) {
return lcd_accept_introduction(&client_server_rvp,
return lcd_accept_introduction(&client_server_rvp,
&client);
};
......@@ -123,6 +128,12 @@ int execution_loop_thread(void *p) {
return -EINVAL;
}
ret = lcd_init_cspace(&module_cspace);
if (ret) {
printk(KERN_ERR "Failed to init global cspace for this module:%d\n", ret);
return ret;
};
/* Introduction code */
ret = lcd_prepare_introduction(lcd_api_cap(),
lcd_api_reply_cap(),
......@@ -133,6 +144,9 @@ int execution_loop_thread(void *p) {
return -EINVAL;
}
/* Record the clients session */
lcd_cap_make_cspace(&module_cspace, &module_cap_cache, *
return execution_loop();
};
......
/**
* client-server-idl.c - Module that launches client and server
*
*
* 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 <linux/slab.h>
#include <lcd/lcd.h>
#include <lcd/api.h>
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("LCD client-server test launcher");
static int __init cslaunch_init(void)
{
capability_t shared_rvp = 2;
capability_t client_lcd_cap = 3;
capability_t server_lcd_cap = 4;
ret = lcd_init_current();
if (ret) {
printk(KERN_ERR "Failed to init current thread with LCD:%d\n", ret);
return -EINVAL;
}
ret = lcd_api_create_sync_endpoint(shared_rvp);
if(ret) {
printk(KERN_ERR "Failed to create sync endpoint\n");
return -ENOSPC;
};
ret = lcd_api_create_lcd("cs-client", &shared_rvp, 1, client_lcd_cap);
if(ret) {
printk(KERN_ERR "Failed to create client LCD\n");
return -ENOSPC;
};
ret = lcd_api_create_lcd("cs-server", &shared_rvp, 1, server_lcd_cap);
if(ret) {
printk(KERN_ERR "Failed to create server LCD\n");
return -ENOSPC;
};
return;
}
static void __exit cslaunch_exit(void)
{
}
module_init(cslaunch_init);
module_exit(cslaunch_exit);
......@@ -10,11 +10,14 @@
enum lcd_api_calls {
LCD_CREATE_SYNC_ENDPOINT = 1,
LCD_CREATE_LCD = 1,
};
struct utcb *utcb(void);
capability_t lcd_api_cap(void);
capability_t lcd_api_reply_cap(void);
static inline int lcd_api_create_sync_endpoint(capability_t cap, capability_t reply_cap, capability_t ep_cap) {
static inline int __lcd_api_create_sync_endpoint(capability_t cap, capability_t reply_cap, capability_t ep_cap) {
struct message_info *msg = &utcb()->msg_info;
......@@ -29,4 +32,44 @@ static inline int lcd_api_create_sync_endpoint(capability_t cap, capability_t re
};
static inline int lcd_api_create_sync_endpoint(capability_t ep_cap) {
return __lcd_api_create_sync_endpoint(lcd_api_cap(), lcd_api_reply_cap(), ep_cap);
};
static inline int __lcd_api_create_lcd(capability_t cap,
capability_t reply_cap,
char *module_name,
capability_t *boot_caps,
unsigned long boot_caps_size,
capability_t lcd_cap)
{
unsigned short str_regs;
unsigned short cap_regs;
struct message_info *msg = &utcb()->msg_info;
msg->regs[0] = LCD_CREATE_LCD;
str_regs = lcd_cap_marshal_string(&msg->regs[1], module_name, LCD_MAX_REGS - 1);
msg->valid_regs = 1 + str_regs;
cap_regs = lcd_cap_marshal_cap_array(&msg->cap_regs[0], boot_caps, boot_caps_size, LCD_MAX_CAP_REGS - 2);
msg->cap_regs[cap_regs] = lcd_cap;
msg->cap_regs[cap_regs + 1] = reply_cap;
msg->valid_cap_regs = cap_regs + 2;
return ipc_call(cap, msg);
};
static inline int lcd_api_create_sync_endpoint(char *module_name,
capability_t *boot_caps, unsigned long boot_caps_size,
capability_t lcd_cap)
{
return __lcd_api_create_sync_endpoint(lcd_api_cap(),
lcd_api_reply_cap(),
module_name, boot_caps,
boot_caps_size,
lcd_cap);
};
#endif
......@@ -10,9 +10,12 @@
#include <linux/lcd-cap.h>
#define LCD_MAX_REGS 64
#define LCD_MAX_CAP_REGS 8
struct message_info {
u64 regs[8];
capability_t cap_regs[8];
u64 regs[LCD_MAX_REGS];
capability_t cap_regs[LCD_MAX_CAP_REGS];
u8 valid_regs;
u8 valid_cap_regs;
u8 err;
......
......@@ -16,20 +16,12 @@ int lcd_cap_init(void){
return -ENOMEM;
};
//cdtnode_cache = KMEM_CACHE(cap_derivation_tree, 0);
//if(!cdt_cache){
// printk(KERN_ERR "Failed to allocate cte slab\n");
// return -ENOMEM;
//};
return 0;
};
int lcd_cap_exit(void) {
if (cnode_cache)
kmem_cache_destroy(cnode_cache);
//if (cdt_cache)
// kmem_cache_destroy(cdt_cache);
return 0;
}
......@@ -51,7 +43,8 @@ int lcd_cap_insert_object(struct cspace *cspace, capability_t cap,
return 0;
}
struct sync_ipc * lcd_cap_make_sync_endpoint(struct cspace *cspace, struct cap_cache *cache, capability_t *cap) {
struct sync_ipc * lcd_cap_make_sync_endpoint(struct cspace *cspace,
struct cap_cache *cache, capability_t *cap) {
struct sync_ipc *rvp;
rvp = alloc_sync_ipc();
......
......@@ -22,7 +22,7 @@ int lcd_prepare_introduction(capability_t api_cap, capabiity_t reply_cap, sync_i
};
cnode = lcd_cnode_lookup(&current->cspace, server);
cnode = lcd_cnode_lookup(&current->cspace, *rvp_cap);
if(cnode == NULL || cnode->type != LCD_TYPE_SYNC_EP) {
printk(KERN_ERR "Failed to create capability\n");
return -ENOMEM;
......
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