aboutsummaryrefslogtreecommitdiff
path: root/include/apos
diff options
context:
space:
mode:
Diffstat (limited to 'include/apos')
-rw-r--r--include/apos/cpu.h4
-rw-r--r--include/apos/irq.h7
-rw-r--r--include/apos/lock.h3
-rw-r--r--include/apos/proc.h3
-rw-r--r--include/apos/tcb.h5
5 files changed, 20 insertions, 2 deletions
diff --git a/include/apos/cpu.h b/include/apos/cpu.h
index a55fbad..81fb07e 100644
--- a/include/apos/cpu.h
+++ b/include/apos/cpu.h
@@ -1,7 +1,9 @@
#ifndef APOS_CPU_H
#define APOS_CPU_H
-unsigned cpu_id();
+#include <apos/tcb.h>
+
+id_t cpu_id();
/* TODO: add more cpu handling functions */
#endif /* APOS_CPU_H */
diff --git a/include/apos/irq.h b/include/apos/irq.h
new file mode 100644
index 0000000..958b25f
--- /dev/null
+++ b/include/apos/irq.h
@@ -0,0 +1,7 @@
+#ifndef APOS_IRQ_H
+#define APOS_IRQ_H
+
+void enable_irq();
+void disable_irq();
+
+#endif /* APOS_IRQ_H */
diff --git a/include/apos/lock.h b/include/apos/lock.h
index b8983fa..178140b 100644
--- a/include/apos/lock.h
+++ b/include/apos/lock.h
@@ -2,12 +2,14 @@
#define LOCK_H
#include <apos/atomic.h>
+#include <apos/irq.h>
typedef atomic_int spinlock_t;
#include <lock.h>
static inline void spin_lock(spinlock_t *lck)
{
+ disable_irq();
do {
while (atomic_load_explicit(lck, memory_order_acquire))
optional_pause();
@@ -18,6 +20,7 @@ static inline void spin_lock(spinlock_t *lck)
static inline void spin_unlock(spinlock_t *lck)
{
atomic_store_explicit(lck, 0, memory_order_release);
+ enable_irq();
}
#endif /* LOCK_H */
diff --git a/include/apos/proc.h b/include/apos/proc.h
index 8071dda..6f272b1 100644
--- a/include/apos/proc.h
+++ b/include/apos/proc.h
@@ -2,6 +2,9 @@
#define APOS_PROC_H
#include <apos/tcb.h>
+#include <apos/vmem.h>
+
void jump_to_userspace(struct tcb *t, vm_t bin, int argc, char **argv);
+vm_t setup_call_stack(struct tcb *t, vm_t start, size_t bytes);
#endif /* APOS_PROC_H */
diff --git a/include/apos/tcb.h b/include/apos/tcb.h
index 714d750..1d85e8b 100644
--- a/include/apos/tcb.h
+++ b/include/apos/tcb.h
@@ -26,7 +26,10 @@ struct tcb {
id_t tid;
vm_t callback;
- vm_t stack;
+ vm_t proc_stack;
+ vm_t call_stack;
+
+ vm_t entry;
struct vm_branch_t *b_r;
};