summaryrefslogtreecommitdiffstats
path: root/include/tasking.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/tasking.h')
-rw-r--r--include/tasking.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/include/tasking.h b/include/tasking.h
new file mode 100644
index 0000000..04118a9
--- /dev/null
+++ b/include/tasking.h
@@ -0,0 +1,44 @@
+#ifndef _JOVE_TASKING_H
+#define _JOVE_TASKING_H 1
+
+#include "arch/page.h"
+#include <stddef.h>
+#include <stdbool.h>
+
+#define KERNEL_STACKW 4096
+
+typedef intmax_t tcbid_t;
+
+typedef enum
+{
+ TCB_RUNNING,
+ TCB_PAUSED,
+ TCB_DEAD
+} tcb_state_t;
+
+typedef struct task_control_block
+{
+ tcbid_t id;
+ void *stack;
+ uintptr_t sp, ksp;
+ page_directory_t *pd;
+ tcb_state_t state;
+
+ int exit_code;
+} tcb_t;
+
+void tasking_setup(void);
+
+tcb_t *tcb_new(void *ip, page_directory_t *pd);
+void tcb_prepare(tcb_t *tcb, void *ip);
+void tcb_kill(tcb_t *tcb, int code);
+
+void tcb_switch(tcb_t *to);
+
+void tcb_stack_push(tcb_t *tcb, void *data, size_t len);
+
+void kexec(void *ip, int kargc, char **kargv, int kenvc, char **kenvp);
+
+void *umode_stack_new(void);
+
+#endif