.global task_prepare
.global task_switch
+.global task_get_current
+.global task_set_current
task_prepare:
/*
/* pretend that we're returning from an interrupt */
jmp _int_restore
+
+task_get_current:
+ cpuidx %ecx
+ movl $_cpu, %eax
+0: subl $1, %ecx
+ js 1f
+ addl $CPU_SIZE, %eax
+ jmp 0b
+
+1: movl CUR_TASK(%eax), %eax
+ ret
+
+task_set_current:
+ cpuidx %ecx
+ movl $_cpu, %eax
+0: subl $1, %ecx
+ js 1f
+ addl $CPU_SIZE, %eax
+ jmp 0b
+
+1: movl 4(%esp), %ecx
+ movl %ecx, CUR_TASK(%eax)
+ ret
#include <corax/types.h>
+#define TASK_STATE_BROKEN 0
+#define TASK_STATE_RUNNING 1
+#define TASK_STATE_READY 2
+#define TASK_STATE_WAITING 3
+
+typedef struct task task_t;
+
struct task {
u32_t t_sp;
u32_t t_pgdir;
void *t_kstack;
u32_t t_privl;
+
+ u32_t t_tslice;
+ u32_t t_rslice;
+
+ u32_t t_state;
} __attribute__((packed));
int cpu_get_id(void);
int task_prepare(struct task*, u32_t cr3, u32_t eip, u32_t esp0, u32_t esp, u32_t priv);
int task_switch(struct task*);
+task_t* task_get_current(void);
+void task_set_current(task_t*);
+
/*
* Definitions, types, and prototypes related to paging
*/