From 4af62bb53676b7f721b46cabee78cac3a557e924 Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Wed, 5 Aug 2020 18:28:26 +0200
Subject: Some proc things

---
 src/features/fs.c      | 2 +-
 src/features/load.c    | 4 ++--
 src/features/proc.c    | 4 +++-
 src/features/syscall.c | 2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)

(limited to 'src/features')

diff --git a/src/features/fs.c b/src/features/fs.c
index 1eec30e..ab2a6eb 100644
--- a/src/features/fs.c
+++ b/src/features/fs.c
@@ -97,8 +97,8 @@ void *read_file(char *path)
 	path++;
 	u32 current_inode = EXT2_ROOT;
 
+	int i;
 	while (1) {
-		int i;
 		for (i = 0; path[i] != '/' && path[i] != '\0'; i++)
 			;
 
diff --git a/src/features/load.c b/src/features/load.c
index 62da8b4..bc56235 100644
--- a/src/features/load.c
+++ b/src/features/load.c
@@ -11,7 +11,7 @@ void bin_load(char *path, struct proc *proc)
 	char *data = read_file(path);
 	u32 stack = (u32)malloc(0x1000) + 0x1000;
 
-	proc->regs.ebp = stack;
-	proc->regs.esp = stack;
+	proc->regs.ebp = (u32)stack;
+	proc->regs.esp = (u32)stack;
 	proc->regs.eip = (u32)data;
 }
diff --git a/src/features/proc.c b/src/features/proc.c
index fbf1b5a..7acbf03 100644
--- a/src/features/proc.c
+++ b/src/features/proc.c
@@ -70,8 +70,9 @@ struct proc *proc_make()
 
 void proc_init()
 {
+	__asm__ volatile("cli");
 	current = root = proc_make();
-	bin_load("/root", root);
+	bin_load("/init", root);
 	irq_install_handler(0, scheduler);
 	proc_print();
 
@@ -80,5 +81,6 @@ void proc_init()
 	*(void **)(&entry) = (u32 *)root->regs.eip;
 	__asm__ volatile("movl %%eax, %%ebp" ::"a"(root->regs.ebp));
 	__asm__ volatile("movl %%eax, %%esp" ::"a"(root->regs.esp));
+	__asm__ volatile("sti");
 	entry();
 }
diff --git a/src/features/syscall.c b/src/features/syscall.c
index ab1849c..c3a758a 100644
--- a/src/features/syscall.c
+++ b/src/features/syscall.c
@@ -13,7 +13,7 @@ void syscall_handler(struct regs *r)
 	bin_load("/a", a);
 }
 
-void syscall_install()
+void syscall_init()
 {
 	isr_install_handler(0x80, syscall_handler);
 }
-- 
cgit v1.2.3