diff options
Diffstat (limited to 'include/apos')
| -rw-r--r-- | include/apos/debug.h | 8 | ||||
| -rw-r--r-- | include/apos/tcb.h | 49 | ||||
| -rw-r--r-- | include/apos/utils.h | 1 |
3 files changed, 33 insertions, 25 deletions
diff --git a/include/apos/debug.h b/include/apos/debug.h index 6d49f12..88668ff 100644 --- a/include/apos/debug.h +++ b/include/apos/debug.h @@ -148,11 +148,11 @@ struct dbg_info dbg_from_fdt(const void *fdt); #define COMMON_FORMAT "[%s] %s:%d\n\t" #define COMMON_ARGS(s) s, __FILE__, __LINE__ -#define bug(fmt, ...) dbg(COMMON_FORMAT fmt, COMMON_ARGS("BUG"), __VA_ARGS__) -#define warn(fmt, ...) dbg(COMMON_FORMAT fmt, COMMON_ARGS("WARN"), __VA_ARGS__) -#define info(fmt, ...) dbg(COMMON_FORMAT fmt, COMMON_ARGS("INFO"), __VA_ARGS__) +#define bug(fmt, ...) dbg(COMMON_FORMAT fmt, COMMON_ARGS("BUG"),##__VA_ARGS__) +#define warn(fmt, ...) dbg(COMMON_FORMAT fmt, COMMON_ARGS("WARN"),##__VA_ARGS__) +#define info(fmt, ...) dbg(COMMON_FORMAT fmt, COMMON_ARGS("INFO"),##__VA_ARGS__) #define error(fmt, ...) \ - dbg(COMMON_FORMAT fmt, COMMON_ARGS("ERROR"), __VA_ARGS__) + dbg(COMMON_FORMAT fmt, COMMON_ARGS("ERROR"),##__VA_ARGS__) #else diff --git a/include/apos/tcb.h b/include/apos/tcb.h index 2b602f6..7abd432 100644 --- a/include/apos/tcb.h +++ b/include/apos/tcb.h @@ -11,23 +11,31 @@ #include <arch/tcb.h> /* arch-specific data */ /* process(/main) threads don't have any previous threads */ -#define is_proc(t) (!t->prev) +#define is_proc(t) (t->rid == t->tid) +#define is_rpc(t) (t->rid == t->pid) + +#define get_proc(t) (get_tcb(t->eid)) +#define get_rproc(t) (get_tcb(t->rid)) + +/* forward declaration */ +struct tcb; + +struct tcb_ctx { + struct vmem *vmem; + struct tcb *next; + struct tcb *prev; +}; struct tcb { struct arch_tcbd tcbd; - /* mapping data - * TODO: should mem_region_root be renamed mem_root or something? feels - * kind of clunky */ - union { - /* if we're the main thread, we control the memory regions */ - struct mem_region_root sp_r; - /* if we're not the main thread, we have a pointer to the main - * thread */ - struct tcb *proc; - }; + /* mapping data */ + struct mem_region_root sp_r; + id_t eid; id_t pid; + + id_t rid; id_t tid; vm_t callback; @@ -35,15 +43,8 @@ struct tcb { vm_t thread_stack; vm_t thread_stack_top; - vm_t call_stack; - vm_t call_stack_top; - - /* vm root branch */ - struct vmem *b_r; - - /* linked list of threads in this process */ - struct tcb *next; - struct tcb *prev; + struct tcb_ctx proc; + struct tcb_ctx rpc; }; void init_tcbs(); @@ -54,12 +55,18 @@ struct tcb *create_proc(struct tcb *p); stat_t destroy_thread(struct tcb *t); stat_t destroy_proc(struct tcb *p); +stat_t attach_rpc(struct tcb *r, struct tcb *t); +stat_t detach_rpc(struct tcb *r, struct tcb *t); +stat_t attach_proc(struct tcb *r, struct tcb *t); +stat_t detach_proc(struct tcb *r, struct tcb *t); + struct tcb *cur_tcb(); void use_tcb(struct tcb *); struct tcb *get_tcb(id_t tid); -stat_t clone_tcb_maps(struct tcb *); +stat_t clone_proc_maps(struct tcb *); +stat_t clone_rpc_maps(struct tcb *); stat_t alloc_stacks(struct tcb *); #endif /* APOS_TCB_H */ diff --git a/include/apos/utils.h b/include/apos/utils.h index 03bb801..c4a83be 100644 --- a/include/apos/utils.h +++ b/include/apos/utils.h @@ -27,6 +27,7 @@ #define QUOTE(x) QUOTE2(x) #define UNUSED(x) ((void)(x)) +#define MAYBE_UNUSED(x) UNUSED(x) #include <apos/builtin.h> |
