From 4e5595a089c815febd7a0d42ab62940bf13f73ac Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 29 Dec 2021 18:47:16 +0200 Subject: Preparations for refactoring --- include/apos/cpu.h | 4 +++- include/apos/irq.h | 7 +++++++ include/apos/lock.h | 3 +++ include/apos/proc.h | 3 +++ include/apos/tcb.h | 5 ++++- 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 include/apos/irq.h (limited to 'include/apos') 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 + +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 +#include typedef atomic_int spinlock_t; #include 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 +#include + 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; }; -- cgit v1.3