aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/panic.c5
-rw-r--r--src/tcb.c17
-rw-r--r--src/uapi/ipc.c2
-rw-r--r--src/vmem.c15
4 files changed, 34 insertions, 5 deletions
diff --git a/src/panic.c b/src/panic.c
index afb598e..69247de 100644
--- a/src/panic.c
+++ b/src/panic.c
@@ -29,8 +29,9 @@ void kernel_panic(void *pc, void *addr, long cause)
void unhandled_panic(void *pc, void *addr, long cause)
{
/* could be useful to print out register values as well? */
- error("thread %d unhandled panic at pc: %p with address %p and cause %lx\n",
- cur_tcb()->cpu_id, pc, addr, cause);
+ error(
+ "thread %d unhandled panic at pc: %p with address %p and cause %lx\n",
+ cur_tcb()->cpu_id, pc, addr, cause);
info("attempting to reboot\n");
diff --git a/src/tcb.c b/src/tcb.c
index 1281da2..818d4e7 100644
--- a/src/tcb.c
+++ b/src/tcb.c
@@ -90,6 +90,13 @@ static id_t __alloc_tid(struct tcb *t)
return ERR_NF;
}
+/**
+ * Initialize thread that isn't bound to any parent process, i.e. it will become
+ * a process in itself.
+ *
+ * @param t Partially constructed tcb to construct further.
+ * @return OK/ERR_OOMEM.
+ */
static stat_t __init_free_thread(struct tcb *t)
{
if (!(t->proc.vmem = create_vmem()))
@@ -102,7 +109,7 @@ static stat_t __init_free_thread(struct tcb *t)
if (!(t->rpc.vmem = create_vmem())) {
destroy_vmem(t->proc.vmem);
- return NULL;
+ return ERR_OOMEM;
}
if (setup_rpc_stack(t)) {
@@ -120,6 +127,13 @@ static stat_t __init_free_thread(struct tcb *t)
return OK;
}
+/**
+ * Initialize thread that is bound to some parent process.
+ *
+ * @param p Parent tcb.
+ * @param t Partially constructed tcb to construct further.
+ * @return OK/ERR_OOMEM.
+ */
static stat_t __init_owned_thread(struct tcb *p, struct tcb *t)
{
t->eid = p->rid;
@@ -220,7 +234,6 @@ struct tcb *create_proc(struct tcb *p)
* Destroy data associated with thread.
*
* @param t Thread whose data to destroy.
- * @return \ref OK.
*/
static void __destroy_thread_data(struct tcb *t)
{
diff --git a/src/uapi/ipc.c b/src/uapi/ipc.c
index 6e33165..6f6862e 100644
--- a/src/uapi/ipc.c
+++ b/src/uapi/ipc.c
@@ -71,7 +71,7 @@ static inline vm_t enter_rpc(struct tcb *t, struct sys_ret a,
{
/* reuse current rpc stack location if we're being kicked */
vm_t rpc_stack = (is_set(flags, IPC_TAIL) && is_rpc(t))
- ? t->rpc_stack : rpc_position(t);
+ ? t->rpc_stack : rpc_position(t);
struct call_ctx *ctx = (struct call_ctx *)(rpc_stack) - 1;
t->regs = (vm_t)ctx;
diff --git a/src/vmem.c b/src/vmem.c
index bd0cd7c..0404202 100644
--- a/src/vmem.c
+++ b/src/vmem.c
@@ -64,6 +64,14 @@ static stat_t __copy_mapped_region(struct tcb *d, struct tcb *s,
return res;
}
+/**
+ * Reference shared memory, creating a link between the referrer and owner.
+ *
+ * @param d 'Owner' of \p orig.
+ * @param s Referrer of \p ref.
+ * @param ref Address of shared memory reference in \p s.
+ * @param orig Address of shared memory in \p d.
+ */
static void reference_mem(struct tcb *d, struct tcb *s, vm_t ref, vm_t orig)
{
struct mem_region *src = find_used_region(&s->uvmem.region, orig);
@@ -81,6 +89,13 @@ static void reference_mem(struct tcb *d, struct tcb *s, vm_t ref, vm_t orig)
static void __free_mapping(struct tcb *t, struct mem_region *m);
+/**
+ * Unreference memory region at address \p addr.
+ * Also unreferences owning process.
+ *
+ * @param s Reference holder of \p addr.
+ * @param addr Address to unreference. Or would dereference be better?
+ */
static void unreference_mem(struct tcb *s, vm_t addr)
{
struct mem_region *src = find_used_region(&s->uvmem.region, addr);