summaryrefslogtreecommitdiffstats
path: root/include/tasking.h
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2024-05-22 13:00:41 -0400
committerJon Santmyer <jon@jonsantmyer.com>2024-05-22 13:00:41 -0400
commitace65b453151845bc361f21f3e5b651c35f9f126 (patch)
tree262ebd29b0ca1d8584f0b6f1efa7a00d9f4f3e43 /include/tasking.h
parentf004c1ade8d617a82cea2fe249434cccb47a2358 (diff)
downloadjove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.tar.gz
jove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.tar.bz2
jove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.zip
massive refactor for mp and organizationHEADmaster
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