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

LCD API client and server code

  -- LCD export an API to its domains that is accessible via
  capability invocations (well, syscalls if you like)

  -- Kernel runs a thread that implement this API, e.g. serves
  capability invocations
parent cde8b5ed
......@@ -5,5 +5,5 @@ obj-$(CONFIG_LCD) += lcd-domains.o
#
#obj-m += lcd.o
lcd-domains-y += $(addprefix ../../../virt/lcd/, core.o cap.o \
ipc.o cap-cache.o)
ipc.o cap-cache.o api.o)
lcd-domains-y += lcd-vtx.o utils.o
/*
* Author: Anton Burtsev <aburtsev@flux.utah.edu>
* Copyright: University of Utah
*/
#ifndef _LCD_API_H_
#define _LCD_API_H_
#include <uapi/linux/lcd-api.h>
#include <lcd/cap.h>
#include <lcd/ipc.h>
int lcd_api_init(void);
int lcd_api_exit(void);
#endif
......@@ -34,5 +34,8 @@ void lcd_cnode_release(struct cnode *cnode);
int lcd_init_cspace(struct cspace *cspace);
int lcd_cnode_insert(struct cspace *cspace, capability_t cap, struct cnode *cnode);
struct cnode *lcd_cnode_lookup(struct cspace *cspace, capability_t cap);
void lcd_cap_drop(struct cspace *cspace, capability_t cap);
#define LCD_MAX_CAPS 32
#endif
......@@ -23,7 +23,4 @@ struct sync_ipc * alloc_sync_ipc(void);
int lcd_ipc_init(void);
int lcd_ipc_exit(void);
int ipc_send(capability_t cap, struct message_info *msg);
int ipc_recv(capability_t rvp_cap, struct message_info *msg);
#endif
/*
* Author: Anton Burtsev <aburtsev@flux.utah.edu>
* Copyright: University of Utah
*/
#ifndef _LINUX_PUBLIC_LCD_API_H_
#define _LINUX_PUBLIC_LCD_API_H_
#include <linux/lcd-cap.h>
#include <linux/lcd-ipc.h>
enum lcd_api_calls {
LCD_CREATE_SYNC_ENDPOINT = 1,
};
struct utcb *utcb(void);
static inline int lcd_create_sync_endpoint(capability_t cap, capability_t reply_cap, capability_t ep_cap) {
struct message_info *msg = &utcb()->msg_info;
msg->regs[0] = LCD_CREATE_SYNC_ENDPOINT;
msg->valid_regs = 1;
msg->cap_regs[0] = ep_cap;
msg->cap_regs[1] = reply_cap;
msg->valid_cap_regs = 2;
return ipc_call(cap, msg);
};
#endif
......@@ -8,6 +8,8 @@
#ifndef __LINUX_PUBLIC_LCD_CAP_H__
#define __LINUX_PUBLIC_LCD_CAP_H__
#include <linux/types.h>
typedef uint64_t capability_t;
#endif
......@@ -15,6 +15,7 @@ struct message_info {
capability_t cap_regs[8];
u8 valid_regs;
u8 valid_cap_regs;
u8 err;
};
struct boot_info {
......@@ -26,4 +27,9 @@ struct utcb {
struct boot_info boot_info;
};
int ipc_send(capability_t cap, struct message_info *msg);
int ipc_recv(capability_t rvp_cap, struct message_info *msg);
int ipc_call(capability_t cap, struct message_info *msg);
int ipc_reply(capability_t rvp_cap, struct message_info *msg);
#endif
......@@ -5,7 +5,6 @@
#include <linux/slab.h>
#include <lcd/cap.h>
#define LCD_MAX_CAPS 32
struct kmem_cache *cnode_cache;
struct kmem_cache *cdtnode_cache;
......@@ -78,3 +77,15 @@ struct cnode *lcd_cnode_lookup(struct cspace *cspace, capability_t cap) {
};
EXPORT_SYMBOL(lcd_cnode_lookup);
void lcd_cap_drop(struct cspace *cspace, capability_t cap) {
struct cnode *cnode;
cnode = lcd_cnode_lookup(cspace, cap);
if(!cnode)
return;
cnode->type = LCD_TYPE_FREE;
cnode->object = NULL;
lcd_cnode_release(cnode);
return;
};
......@@ -3,29 +3,21 @@
* Copyright: University of Utah
*/
#include <linux/slab.h>
#include <lcd/api.h>
#include <lcd/cap-cache.h>
#include <lcd/cap.h>
#include <linux/sched.h>
#include <linux/kthread.h>
static inline int lcd_create_sync_endpoint(capability_t cap, capability_t ep_cap) {
struct cap_cache cap_cache;
struct message_info *msg = &current->utcb.message_info;
msg->regs[0] = LCD_CREATE_SYNC_ENDPOINT;
msg->valid_regs = 1;
msg->cap_regs[0] = rvp;
msg->valid_cap_regs = 1;
return ipc_call(cap, msg);
};
int lcd_create_sync_endpoint(struct sync_ipc *otherend) {
int lcd_api_create_sync_endpoint(capability_t reply_cap) {
int ret;
struct sync_ipc *rvp;
capability_t free_cap;
struct cnode *cnode;
struct message_info *msg = &current->utcb->msg_info;
rvp = alloc_sync_ipc();
if(!rvp) {
......@@ -34,7 +26,7 @@ int lcd_create_sync_endpoint(struct sync_ipc *otherend) {
goto err;
};
ret = lcd_alloc_free_cap(cap_cache, &free_cap);
ret = lcd_alloc_cap(&cap_cache, &free_cap);
if(ret) {
printk(KERN_ERR "Failed to allocate free capability\n");
ret = -ENOSPC;
......@@ -57,17 +49,50 @@ int lcd_create_sync_endpoint(struct sync_ipc *otherend) {
msg->cap_regs[0] = free_cap;
msg->valid_cap_regs = 1;
ipc_reply(otherend, msg);
ipc_reply(reply_cap, msg);
lcd_cap_drop(free_cap);
lcd_cap_drop(&current->cspace, free_cap);
lcd_release_free_cap(cap_cache);
lcd_free_cap(&cap_cache, free_cap);
return 0;
err:
msg->err = ret;
ipc_reply(otherend, msg);
ipc_reply(reply_cap, msg);
return ret;
};
int lcd_api_execution_loop(void) {
return 0;
};
int lcd_api_thread(void *p) {
int ret;
return lcd_api_execution_loop();
};
int lcd_api_init(void) {
int ret;
struct task_struct *t;
ret = lcd_init_list_cache(&cap_cache, LCD_MAX_CAPS);
if (ret) {
printk(KERN_ERR "Failed to initialize cap cache:%d\n", ret);
return ret;
}
t = kthread_create(lcd_api_thread, NULL, "lcd-api");
if (!t) {
printk(KERN_ERR "Failed to create LCD API thread\n");
return -EINVAL;
};
wake_up_process(t);
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