aboutsummaryrefslogtreecommitdiff
path: root/include/apos/tcb.h
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-11-12 16:41:36 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2022-11-12 16:41:36 +0200
commit41ead8de77963bae907375c1bb115dad3315f46b (patch)
tree4b364db137bd3bea69853f15329292af7662897d /include/apos/tcb.h
parent1d37792fb7a47135f0e7b7fc245e83bb1d8fc496 (diff)
downloadkmi-41ead8de77963bae907375c1bb115dad3315f46b.tar.gz
kmi-41ead8de77963bae907375c1bb115dad3315f46b.zip
initial rpc implementations
Diffstat (limited to 'include/apos/tcb.h')
-rw-r--r--include/apos/tcb.h29
1 files changed, 23 insertions, 6 deletions
diff --git a/include/apos/tcb.h b/include/apos/tcb.h
index 0368957..9ed916f 100644
--- a/include/apos/tcb.h
+++ b/include/apos/tcb.h
@@ -28,7 +28,7 @@
* @param t Thread to check.
* @return \c true if thread is in RPC, \c false otherwise.
*/
-#define is_rpc(t) (t->rid == t->pid)
+#define is_rpc(t) (t->rid != t->pid)
/**
* Get the process thread of current thread.
@@ -63,14 +63,14 @@ struct tcb_ctx {
/** Enum for notification states. */
enum tcb_notify {
+ /** Thread is free to be notified. */
+ NOTIFY_WAITING = 0,
+
/** Thread has notifcations queued. */
NOTIFY_QUEUED,
/** Thread is running notification handler. */
NOTIFY_RUNNING,
-
- /** Thread is free to be notified. */
- NOTIFY_WAITING
};
/** Thread control block. Main way to handle threads. */
@@ -133,6 +133,9 @@ struct tcb {
/** Address of this thread's stack top. */
vm_t thread_stack_top;
+ /** Current address of usable rpc stack. */
+ vm_t rpc_stack;
+
/** \todo Check if each thread should be allowed more than just one
* region of thread local storage. */
/** Possible thread local storage. */
@@ -171,7 +174,7 @@ void destroy_tcbs();
* and the \ref tcb structure itself with a unique thread ID. If in a new
* process context, a new process address space is created as well.
*
- * Userspace stack is allocated with \ref alloc_stacks().
+ * Userspace stack is allocated with \ref alloc_stack().
*
* \todo Thread local storage?
*
@@ -338,7 +341,7 @@ stat_t clone_rpc_maps(struct tcb *r);
* @param t Thread whose stacks to allocate.
* @return \ref OK on success, \ref ERR_OOMEM if out of memory.
*/
-stat_t alloc_stacks(struct tcb *t);
+stat_t alloc_stack(struct tcb *t);
/**
* Set address to jump to when returning to userspace.
@@ -356,4 +359,18 @@ void set_return(struct tcb *t, vm_t r);
*/
bool running(struct tcb *t);
+/**
+ * Save thread context for rpc call.
+ *
+ * @param t Thread whose context to save.
+ */
+void save_context(struct tcb *t);
+
+/**
+ * Load thread context from rpc call.
+ *
+ * @param t Thread whose context to restore.
+ */
+void load_context(struct tcb *t);
+
#endif /* APOS_TCB_H */