summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm/system.h5
-rw-r--r--include/kernel/sched.h33
-rw-r--r--include/kernel/sys.h6
-rw-r--r--include/unistd.h9
4 files changed, 42 insertions, 11 deletions
diff --git a/include/asm/system.h b/include/asm/system.h
index 02c2f62..0230f46 100644
--- a/include/asm/system.h
+++ b/include/asm/system.h
@@ -1,3 +1,6 @@
#include <kernel/sched.h>
-volatile void switch_to(struct task_struct*, struct task_state*);
+volatile void switch_to(int n, struct task_struct *task);
+
+void set_tss(unsigned int n, void *tss);
+void clear_tss(unsigned int n);
diff --git a/include/kernel/sched.h b/include/kernel/sched.h
index afced68..a3d95e0 100644
--- a/include/kernel/sched.h
+++ b/include/kernel/sched.h
@@ -2,27 +2,44 @@
#define _SCHED_H
#include <stdint.h>
+#include <unistd.h>
-struct task_state {
- uint32_t ss;
- uint32_t esp;
- uint32_t eflags;
- uint32_t cs;
+struct tss_struct {
+ uint32_t prevt;
+ uint32_t esp0;
+ uint32_t ss0;
+ uint32_t esp1;
+ uint32_t ss1;
+ uint32_t esp2;
+ uint32_t ss2;
+ uint32_t cr3;
uint32_t eip;
+ uint32_t eflags;
uint32_t eax;
uint32_t ecx;
uint32_t edx;
uint32_t ebx;
- uint32_t esp_garbage;
+ uint32_t esp;
uint32_t ebp;
uint32_t esi;
uint32_t edi;
+ uint32_t es;
+ uint32_t cs;
+ uint32_t ss;
+ uint32_t ds;
+ uint32_t fs;
+ uint32_t gs;
+ uint32_t ldt;
+ uint32_t io_map;
} __attribute__((packed));
struct task_struct {
- struct task_state state;
+ pid_t pid;
+ struct tss_struct state;
} __attribute__((packed));
-void userspace_init(void);
+extern struct task_struct *ctask;
+
+void sched_init(void);
#endif
diff --git a/include/kernel/sys.h b/include/kernel/sys.h
index 7c129d2..248a93b 100644
--- a/include/kernel/sys.h
+++ b/include/kernel/sys.h
@@ -2,13 +2,15 @@ typedef int (*syscall_t) (void);
extern int sys_puts(void);
extern int sys_time(void);
+extern int sys_getpid(void);
+extern int sys_getpdir(void);
extern int sys_dummy(void);
syscall_t call_table[256] = {
[0] = &sys_puts,
[1] = &sys_time,
- [2] = &sys_dummy,
- [3] = &sys_dummy,
+ [2] = &sys_getpid,
+ [3] = &sys_getpdir,
[4] = &sys_dummy,
[5] = &sys_dummy,
[6] = &sys_dummy,
diff --git a/include/unistd.h b/include/unistd.h
index ae46b16..6925541 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -1,8 +1,14 @@
#ifndef _UNISTD_H
#define _UNISTD_H
+#include <stdint.h>
+
+typedef uint16_t pid_t;
+
#define __SYS_puts 0
#define __SYS_time 1
+#define __SYS_getpid 2
+#define __SYS_getpdir 3
#define _syscall0(type, name) \
type name(void) { \
@@ -26,4 +32,7 @@
return __res; \
}
+pid_t getpid(void);
+void *getpdir(void);
+
#endif