aboutsummaryrefslogtreecommitdiff
path: root/src/features
diff options
context:
space:
mode:
authorMarvin Borner2020-08-06 20:41:07 +0200
committerMarvin Borner2020-08-06 20:41:07 +0200
commit8c5fef6e00b0afe7a4f72fe9f8c72ade1ce4c673 (patch)
tree30c0f549b24afc456e1f0b028cecfee7796ccf2b /src/features
parent9dbf8131d6aaff1617ef2bc7ebf54838f808688d (diff)
Some context switch fixes.
I'm quite tired actually and I don't seem to find my mistakes...
Diffstat (limited to 'src/features')
-rw-r--r--src/features/load.c7
-rw-r--r--src/features/proc.c15
-rw-r--r--src/features/syscall.c8
3 files changed, 18 insertions, 12 deletions
diff --git a/src/features/load.c b/src/features/load.c
index 36548bb..5382c77 100644
--- a/src/features/load.c
+++ b/src/features/load.c
@@ -15,11 +15,4 @@ void bin_load(char *path, struct proc *proc)
proc->regs.ebp = (u32)stack;
proc->regs.esp = (u32)stack;
proc->regs.eip = (u32)data;
-
- proc->regs.ds = GDT_DATA_OFFSET;
- proc->regs.es = GDT_DATA_OFFSET;
- proc->regs.fs = GDT_DATA_OFFSET;
- proc->regs.gs = GDT_DATA_OFFSET;
- proc->regs.cs = GDT_CODE_OFFSET;
- proc->regs.eflags = EFLAGS_ALWAYS | EFLAGS_INTERRUPTS;
}
diff --git a/src/features/proc.c b/src/features/proc.c
index 594e9ec..46b55fb 100644
--- a/src/features/proc.c
+++ b/src/features/proc.c
@@ -6,6 +6,7 @@
#include <mem.h>
#include <print.h>
#include <proc.h>
+#include <str.h>
#include <timer.h>
u32 pid = 0;
@@ -42,8 +43,8 @@ void proc_print()
printf("\n");
while (proc) {
- printf("Process %d [%s]\n", proc->pid,
- proc->state == PROC_RUNNING ? "running" : "sleeping");
+ printf("Process %d [%s]: %s\n", proc->pid,
+ proc->state == PROC_RUNNING ? "running" : "sleeping", proc->name);
proc = proc->next;
}
printf("\n");
@@ -68,6 +69,15 @@ struct proc *proc_make()
struct proc *proc = malloc(sizeof(*proc));
proc->pid = pid++;
proc->state = PROC_RUNNING;
+
+ // Configure registers (default data)
+ proc->regs.ds = GDT_DATA_OFFSET;
+ proc->regs.es = GDT_DATA_OFFSET;
+ proc->regs.fs = GDT_DATA_OFFSET;
+ proc->regs.gs = GDT_DATA_OFFSET;
+ proc->regs.cs = GDT_CODE_OFFSET;
+ proc->regs.eflags = EFLAGS_ALWAYS | EFLAGS_INTERRUPTS;
+
if (current)
proc_attach(proc);
last = proc;
@@ -81,6 +91,7 @@ void proc_init()
root = proc_make();
bin_load("/init", root);
+ strcpy(root->name, "root");
proc_print();
sti();
hlt();
diff --git a/src/features/syscall.c b/src/features/syscall.c
index 2279429..3d012cf 100644
--- a/src/features/syscall.c
+++ b/src/features/syscall.c
@@ -5,15 +5,17 @@
#include <load.h>
#include <print.h>
#include <proc.h>
+#include <str.h>
+int i = 0;
void syscall_handler(struct regs *r)
{
printf("[SYSCALL] %d\n", r->eax);
struct proc *a = proc_make();
- bin_load("/a", a);
- sti();
- hlt();
+ bin_load(++i ? "/a" : "/b", a);
+ strcpy(a->name, "a");
+ proc_print();
}
void syscall_init()