Commit f69072d9 authored by Charlie Jacobsen's avatar Charlie Jacobsen Committed by Vikram Narayanan

Stubbed out microkernel, starting lcd loader.

parent 62815dba
/*
* Look up the cnode at c in cspace. No locking required by caller.
* Returns non-zero on error.
*/
int lcd_cnode_lookup(struct cspace *cspace, cptr_t c, struct cnode **out);
/*
* Confirms src_cptr and dest_cptr point at valid slots. Confirms src
* has grant rights to cap at src_cptr. Transfers cap to dest_cptr, updates
* cdt. No locking required by caller. Returns non-zero on error.
*/
int lcd_cnode_grant(struct cspace *src, struct cspace *dest,
cptr_t src_cptr, cptr_t dest_cptr, unsigned int rights);
This diff is collapsed.
/*
* Author: Charles Jacobsen <charlesj@cs.utah.edu>
* Copyright: University of Utah
*
*/
#ifndef LCD_PROTOTYPE_LCD_MSG_H
#define LCD_PROTOTYPE_LCD_MSG_H
#define LCD_ERR(fmt, args...) __lcd_err(__FILE__, __LINE__, fmt "\n" , ##args)
static inline void __lcd_err(char *file, int lineno, char *fmt, ...)
{
va_list args;
pr_err("lcd-proto: %s:%d: error: ", file, lineno);
va_start(args, fmt);
vprintk(fmt, args);
va_end(args);
}
#define LCD_MSG(fmt, args...) __lcd_msg(__FILE__, __LINE__, fmt "\n" , ##args)
static inline void __lcd_msg(char *file, int lineno, char *fmt, ...)
{
va_list args;
pr_info("lcd-proto: %s:%d: note: ", file, lineno);
va_start(args, fmt);
vprintk(fmt, args);
va_end(args);
}
#define LCD_WARN(fmt, args...) __lcd_warn(__FILE__, __LINE__, fmt "\n" , ##args)
static inline void __lcd_warn(char *file, int lineno, char *fmt, ...)
{
va_list args;
pr_warn("lcd-proto: %s:%d: warning: ", file, lineno);
va_start(args, fmt);
vprintk(fmt, args);
va_end(args);
}
#endif /* LCD_PROTOTYPE_LCD_MSG_H */
......@@ -60,6 +60,7 @@
#include <linux/sched.h>
#include <linux/types.h>
#include <lcd-prototype/lcd-tcb.h>
#include <linux/mutex.h>
#define LCD_NUM_MACHINE_REGS 8
#define LCD_NUM_MESSAGE_REGS 8
......@@ -82,16 +83,26 @@ struct lcd_tcb {
};
struct lcd_thread {
struct *task_struct;
struct *lcd_tcb;
struct *lcd;
struct list_head threads;
struct list_head rvp_queue;
struct task_struct *thread; /* host thread */
struct lcd_tcb *tcb; /* this thread's registers, etc. */
struct lcd *lcd; /* containing lcd */
cptr_t call_cptr; /* cptr to rvp temp granted during call */
cptr_t reply_cptr; /* cptr to rvp that a reply will go thru */
struct list_head threads; /* list of lcd_threads inside an lcd */
struct list_head rvp_queue; /* list of lcd_threads in an rvp queue */
int is_calling; /* non-zero if thread is sending and send */
/* was part of a call */
};
struct lcd {
struct cspace *cspace;
struct list_head threads;
struct cspace *cspace; /* lcd's cspace, shared by all threads */
struct list_head threads; /* list of all contained threads */
struct list_head all_list; /* list of all lcds */
};
/* MACHINE REGISTERS ---------------------------------------- */
......@@ -111,18 +122,26 @@ static inline void lcd_update_max_r(struct lcd_tcb *tcb, unsigned int idx)
lcd_set_max_r(tcb, idx + 1);
}
#define LCD_MK_MACHINE_REG_ACCESS(idx) \
static inline u64 lcd_r##idx(void) \
static inline u64 __lcd_r##idx(struct lcd_thread *t) \
{ \
struct lcd_tcb *tcb = current->lcd_thread->tcb; \
struct lcd_tcb *tcb = t->tcb; \
BUILD_BUG_ON(idx >= LCD_NUM_MACHINE_REGS); \
return tcb->r[idx]; \
} \
static inline void lcd_set_r##idx(u64 val) \
static inline void __lcd_set_r##idx(struct lcd_thread *t, u64 val) \
{ \
struct lcd_tcb *tcb = current->lcd_thread->tcb; \
struct lcd_tcb *tcb = t->tcb; \
BUILD_BUG_ON(idx >= LCD_NUM_MACHINE_REGS); \
lcd_update_max_r(tcb, idx); \
tcb->r[idx] = val; \
} \
static inline u64 lcd_r##idx(void) \
{ \
return __lcd_r##idx(current->lcd_thread); \
} \
static inline void lcd_set_r##idx(u64 val) \
{ \
__lcd_set_r##idx(current->lcd_thread, val); \
}
LCD_MK_MACHINE_REG_ACCESS(0);
LCD_MK_MACHINE_REG_ACCESS(1);
......@@ -150,18 +169,26 @@ static inline void lcd_update_max_m(struct lcd_tcb *tcb, unsigned int idx)
lcd_set_max_m(tcb, idx + 1);
}
#define LCD_MK_MESSAGE_REG_ACCESS(idx) \
static inline u64 lcd_m##idx(void) \
static inline u64 __lcd_m##idx(struct lcd_thread *t) \
{ \
struct lcd_tcb *tcb = current->lcd_thread->tcb; \
struct lcd_tcb *tcb = t->tcb; \
BUILD_BUG_ON(idx >= LCD_NUM_MESSAGE_REGS); \
return tcb->m[idx]; \
} \
static inline void lcd_set_m##idx(u64 val) \
static inline void __lcd_set_m##idx(struct lcd_thread *t, u64 val) \
{ \
struct lcd_tcb *tcb = current->lcd_thread->tcb; \
struct lcd_tcb *tcb = t->tcb; \
BUILD_BUG_ON(idx >= LCD_NUM_MESSAGE_REGS); \
lcd_update_max_m(tcb, idx); \
tcb->m[idx] = val; \
} \
static inline u64 lcd_m##idx(void) \
{ \
return __lcd_m##idx(current->lcd_thread); \
} \
static inline void lcd_set_m##idx(u64 val) \
{ \
__lcd_set_m##idx(current->lcd_thread, val); \
}
LCD_MK_MESSAGE_REG_ACCESS(0);
LCD_MK_MESSAGE_REG_ACCESS(1);
......@@ -189,25 +216,38 @@ static inline void lcd_update_max_oc(struct lcd_tcb *tcb, unsigned int idx)
lcd_set_max_oc(tcb, idx + 1);
}
#define LCD_MK_OUT_CAP_REG_ACCESS(idx) \
static inline cptr_t lcd_oc##idx(void) \
static inline cptr_t __lcd_oc##idx(struct lcd_thread *t) \
{ \
struct lcd_tcb *tcb = current->lcd_thread->tcb; \
struct lcd_tcb *tcb = t->tcb; \
BUILD_BUG_ON(idx >= LCD_NUM_OUT_CAP_REGS); \
return tcb->oc[idx]; \
} \
static inline unsigned int lcd_oc_rights##idx(void) \
static inline unsigned int __lcd_oc_rights##idx(struct lcd_thread *t) \
{ \
struct lcd_tcb *tcb = current->lcd_thread->tcb; \
struct lcd_tcb *tcb = t->tcb; \
BUILD_BUG_ON(idx >= LCD_NUM_OUT_CAP_REGS); \
return tcb->oc_rights[idx]; \
} \
static inline void lcd_set_oc##idx(cptr_t cptr, unsigned int rights) \
static inline void __lcd_set_oc##idx(struct lcd_thread *t, cptr_t c, \
unsigned int rights) \
{ \
struct lcd_tcb *tcb = current->lcd_thread->tcb; \
struct lcd_tcb *tcb = t->tcb; \
BUILD_BUG_ON(idx >= LCD_NUM_OUT_CAP_REGS); \
lcd_update_max_oc(tcb, idx); \
tcb->oc[idx] = cptr; \
tcb->oc_rights[idx] = rights; \
} \
static inline u64 lcd_oc##idx(void) \
{ \
return __lcd_oc##idx(current->lcd_thread); \
} \
static inline u64 lcd_oc_rights##idx(void) \
{ \
return __lcd_oc_rights##idx(current->lcd_thread); \
} \
static inline void lcd_set_oc##idx(u64 val) \
{ \
__lcd_set_oc##idx(current->lcd_thread, val); \
}
LCD_MK_OUT_CAP_REG_ACCESS(0);
LCD_MK_OUT_CAP_REG_ACCESS(1);
......@@ -235,18 +275,26 @@ static inline void lcd_update_max_ic(struct lcd_tcb *tcb, unsigned int idx)
lcd_set_max_ic(tcb, idx + 1);
}
#define LCD_MK_IN_CAP_REG_ACCESS(idx) \
static inline cptr_t lcd_ic##idx(void) \
static inline u64 __lcd_ic##idx(struct lcd_thread *t) \
{ \
struct lcd_tcb *tcb = current->lcd_thread->tcb; \
struct lcd_tcb *tcb = t->tcb; \
BUILD_BUG_ON(idx >= LCD_NUM_IN_CAP_REGS); \
return tcb->ic[idx]; \
} \
static inline void lcd_set_ic##idx(cptr_t cptr) \
static inline void __lcd_set_ic##idx(struct lcd_thread *t, cptr_t c) \
{ \
struct lcd_tcb *tcb = current->lcd_thread->tcb; \
struct lcd_tcb *tcb = t->tcb; \
BUILD_BUG_ON(idx >= LCD_NUM_IN_CAP_REGS); \
lcd_update_max_ic(tcb, idx); \
tcb->ic[idx] = cptr; \
tcb->ic[idx] = c; \
} \
static inline u64 lcd_ic##idx(void) \
{ \
return __lcd_ic##idx(current->lcd_thread); \
} \
static inline void lcd_set_ic##idx(cptr_t c) \
{ \
__lcd_set_ic##idx(current->lcd_thread, c); \
}
LCD_MK_IN_CAP_REG_ACCESS(0);
LCD_MK_IN_CAP_REG_ACCESS(1);
......@@ -257,4 +305,27 @@ LCD_MK_IN_CAP_REG_ACCESS(5);
LCD_MK_IN_CAP_REG_ACCESS(6);
LCD_MK_IN_CAP_REG_ACCESS(7);
/* SYSTEM CALLS ---------------------------------------- */
#define LCD_SYSCALL_SEND 0
#define LCD_SYSCALL_RECV 1
#define LCD_SYSCALL_CALL 2
#define LCD_SYSCALL_REPLY 3
/* API CPTR ---------------------------------------- */
#define LCD_API_CPTR 1
/* ERROR CODES ---------------------------------------- */
#define LCD_EINVAL ((u64)-EINVAL)
#define LCD_EINTR ((u64)-EINTR)
#define LCD_EIO ((u64)-EIO)
/* GLUE MAIN DECLARATION MACRO ---------------------------------------- */
#define set_gmain(fn) \
static int __##fn##(int argc, cptr_t *cptrs[]) \
__attribute__((__section__(".gmain"))) = fn
#endif /* LCD_LCD_H */
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