aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/apos/ipi.h37
-rw-r--r--include/apos/tcb.h19
-rw-r--r--include/apos/uapi.h10
-rw-r--r--include/arch/cpu.h7
-rw-r--r--include/arch/proc.h21
5 files changed, 90 insertions, 4 deletions
diff --git a/include/apos/ipi.h b/include/apos/ipi.h
new file mode 100644
index 0000000..c895d58
--- /dev/null
+++ b/include/apos/ipi.h
@@ -0,0 +1,37 @@
+#ifndef APOS_IPI_H
+#define APOS_IPI_H
+
+/**
+ * @file ipi.h
+ *
+ * IPI function definitions.
+ */
+
+#include <apos/types.h>
+#include <apos/uapi.h>
+#include <apos/tcb.h>
+
+/**
+ * Clear potential IPI in \p t, and return its value.
+ *
+ * @param t \ref tcb to clear possible IPI status of.
+ * @return \ref true if \p was interrupted by IPI, \ref false otherwise.
+ */
+bool clear_ipi(struct tcb *t);
+
+/**
+ * Send IPI to \p t. Assumes \c running(t).
+ *
+ * @param t \ref tcb to send IPI to.
+ */
+void send_ipi(struct tcb *t);
+
+/**
+ * Handle IPI.
+ *
+ * @param t Thread who was interrupted by IPI.
+ * @return Possible arguments to IPI.
+ */
+struct sys_ret handle_ipi(struct tcb *t);
+
+#endif /* APOS_IPI_H */
diff --git a/include/apos/tcb.h b/include/apos/tcb.h
index b92cd10..0368957 100644
--- a/include/apos/tcb.h
+++ b/include/apos/tcb.h
@@ -146,6 +146,9 @@ struct tcb {
/** Notifcation state of thread. */
enum tcb_notify notify_state;
+
+ /** Whether thread has gotten an IPI */
+ bool ipi;
};
/**
@@ -266,6 +269,14 @@ stat_t detach_proc(struct tcb *r, struct tcb *t);
struct tcb *cur_tcb();
/**
+ * Get thread currently running on cpu \p cpu_id.
+ *
+ * @param cpu_id CPU whose currently running thread to get.
+ * @return \ref tcb running on cpu.
+ */
+struct tcb *cpu_tcb(id_t cpu_id);
+
+/**
* Get currently executing process.
*
* @return Effective process \ref tcb.
@@ -337,4 +348,12 @@ stat_t alloc_stacks(struct tcb *t);
*/
void set_return(struct tcb *t, vm_t r);
+/**
+ * Check whether \p t is currently running on some cpu.
+ *
+ * @param t \ref tcb to check.
+ * @return \c true if it is running, \c false otherwise.
+ */
+bool running(struct tcb *t);
+
#endif /* APOS_TCB_H */
diff --git a/include/apos/uapi.h b/include/apos/uapi.h
index 084c1fa..83de7eb 100644
--- a/include/apos/uapi.h
+++ b/include/apos/uapi.h
@@ -500,13 +500,13 @@ SYSCALL_DECLARE4(ipc_resp, d0, d1, d2, d3);
* Notify thread syscall.
*
* @param tid Thread ID to notify.
- * @param swap Whether to immediately swap.
+ * @param b Unused.
* @param c Unused.
* @param d Unused.
* @param e Unused.
* @return \ref OK and 0.
*/
-SYSCALL_DECLARE2(ipc_notify, tid, swap);
+SYSCALL_DECLARE1(ipc_notify, tid);
/** @} */
/** @name Process handling syscalls. */
@@ -683,6 +683,7 @@ SYSCALL_DECLARE1(poweroff, type);
/**
* Dispatch to correct syscall handler.
*
+ * @param t Thread to do syscall on.
* @param syscall Syscall number.
* @param a Syscall argument 0.
* @param b Syscall argument 1.
@@ -691,8 +692,9 @@ SYSCALL_DECLARE1(poweroff, type);
* @param e Syscall argument 4.
* @return Whatever the specified syscall returns.
*/
-struct sys_ret syscall_dispatch(sys_arg_t syscall, sys_arg_t a, sys_arg_t b,
- sys_arg_t c, sys_arg_t d, sys_arg_t e);
+struct sys_ret handle_syscall(struct tcb *t,
+ sys_arg_t syscall, sys_arg_t a, sys_arg_t b,
+ sys_arg_t c, sys_arg_t d, sys_arg_t e);
/** \todo Should I add variable names as well, to make the documentation a bit
* more readable? */
diff --git a/include/arch/cpu.h b/include/arch/cpu.h
index 66d5d45..c5a83d5 100644
--- a/include/arch/cpu.h
+++ b/include/arch/cpu.h
@@ -36,4 +36,11 @@ id_t cpu_id();
*/
void cpu_assign(struct tcb *t);
+/**
+ * Send inter-processor interrupt to cpu \p cpu_id.
+ *
+ * @param cpu_id CPU to send ipi to.
+ */
+void cpu_send_ipi(id_t cpu_id);
+
#endif /* APOS_CPU_H */
diff --git a/include/arch/proc.h b/include/arch/proc.h
index 5047eab..d01674d 100644
--- a/include/arch/proc.h
+++ b/include/arch/proc.h
@@ -49,6 +49,27 @@ struct sys_ret get_args(struct tcb *t);
void set_thread(struct tcb *t);
/**
+ * Copy registers from tcb save area to address \p p.
+ * Intended to be used for copying thread state to rpc stack.
+ *
+ * @param t Thread whose registers to save.
+ * @param p Address to save to.
+ */
+void save_regs(struct tcb *t, void *p);
+
+/**
+ * Copy registers from address \p p to tcb save registers.
+ * Intended to be used for copying thread state from rpc stack.
+ *
+ * @param p Address to load from.
+ * @param t Thread whose registers to load.
+ */
+void load_regs(void *p, struct tcb *t);
+
+void adjust_ipi(struct tcb *t);
+void adjust_syscall(struct tcb *t);
+
+/**
* Run \c init program.
*
* @param t Thread that \c init is attached to.