aboutsummaryrefslogtreecommitdiff
path: root/include/apos
diff options
context:
space:
mode:
Diffstat (limited to 'include/apos')
-rw-r--r--include/apos/tcb.h19
-rw-r--r--include/apos/types.h2
-rw-r--r--include/apos/utils.h8
3 files changed, 25 insertions, 4 deletions
diff --git a/include/apos/tcb.h b/include/apos/tcb.h
index b2e38a0..7ed07c5 100644
--- a/include/apos/tcb.h
+++ b/include/apos/tcb.h
@@ -6,24 +6,35 @@
#include <tcb.h> /* arch-specific data */
struct tcb {
- struct sp_node sp_n;
- struct mem_region_root sp_r;
struct arch_tcbd tcbd;
- id_t pid;
+ /* mapping data
+ * TODO: should mem_region_root be renamed mem_root or something? feels
+ * kind of clunky */
+ struct mem_region_root sp_r;
+
id_t tid;
vm_t callback;
vm_t proc_stack;
vm_t call_stack;
+ /* entry point */
vm_t entry;
+ /* vm root branch */
struct vm_branch *b_r;
};
-stat_t threads_insert(struct tcb *t);
+void init_tcbs();
+void destroy_tcbs();
+
+struct tcb *new_thread();
+void destroy_thread(struct tcb *);
+
struct tcb *cur_tcb();
+void use_tcb(struct tcb *);
+
struct tcb *get_tcb(id_t tid);
#endif /* APOS_TCB_H */
diff --git a/include/apos/types.h b/include/apos/types.h
index 48972da..2f06ec4 100644
--- a/include/apos/types.h
+++ b/include/apos/types.h
@@ -184,6 +184,8 @@ typedef uint_fast16_t vmflags_t;
/* negative error codes are reserved for general usage, positive error codes are
* allowed to be function-specific. */
enum {
+ ERR_NOINIT = -7, /* not initialized */
+ ERR_INVAL = -6, /* invalid value */
ERR_EXT = -5, /* already exists */
ERR_OOMEM = -4, /* out of memory */
ERR_ADDR = -3, /* illegal address */
diff --git a/include/apos/utils.h b/include/apos/utils.h
index e060c44..af0534a 100644
--- a/include/apos/utils.h
+++ b/include/apos/utils.h
@@ -31,6 +31,14 @@
#define offsetof(type, member) ((size_t) & ((type *)0)->member)
#endif
+#if __has_builtin(__builtin_expect)
+#define likely(x) __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#else
+#define likely(x) (x)
+#define unlikely(x) (x)
+#endif
+
#define container_of(ptr, type, member) \
((type *)((char *)(ptr)-offsetof(type, member)))