aboutsummaryrefslogtreecommitdiff
path: root/kernel/features
diff options
context:
space:
mode:
authorMarvin Borner2020-08-09 21:55:42 +0200
committerMarvin Borner2020-08-09 21:55:42 +0200
commitf163a5d5f6802f63092229f0f9326e5fb44b7908 (patch)
treef24ccfe1b9bd340875d534e1aa19ef8676fd4d7b /kernel/features
parentb6d3d341c19440f8447d8d6c6567b7ff78db3174 (diff)
Added malloc/free syscall
Diffstat (limited to 'kernel/features')
-rw-r--r--kernel/features/load.c4
-rw-r--r--kernel/features/proc.c1
-rw-r--r--kernel/features/syscall.c12
3 files changed, 12 insertions, 5 deletions
diff --git a/kernel/features/load.c b/kernel/features/load.c
index cc1a094..14a3086 100644
--- a/kernel/features/load.c
+++ b/kernel/features/load.c
@@ -2,10 +2,9 @@
#include <def.h>
#include <fs.h>
-#include <load.h>
#include <mem.h>
-#include <print.h>
#include <proc.h>
+#include <str.h>
void bin_load(char *path, struct proc *proc)
{
@@ -16,4 +15,5 @@ void bin_load(char *path, struct proc *proc)
proc->regs.esp = (u32)stack;
proc->regs.useresp = (u32)stack;
proc->regs.eip = (u32)data;
+ strcpy(proc->name, path + 1);
}
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index a14aaea..64a4ac1 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -95,7 +95,6 @@ void proc_init()
root = proc_make();
bin_load("/init", root);
- strcpy(root->name, "root");
proc_print();
_eip = root->regs.eip;
diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c
index 1a43b9e..eaa09b3 100644
--- a/kernel/features/syscall.c
+++ b/kernel/features/syscall.c
@@ -3,6 +3,7 @@
#include <cpu.h>
#include <interrupts.h>
#include <load.h>
+#include <mem.h>
#include <print.h>
#include <proc.h>
#include <str.h>
@@ -15,15 +16,22 @@ void syscall_handler(struct regs *r)
printf("[SYSCALL] %d\n", num);
switch (num) {
- case SYS_HALT: {
+ case SYS_LOOP: {
loop();
break;
}
+ case SYS_MALLOC: {
+ r->eax = (u32)malloc(r->eax);
+ break;
+ }
+ case SYS_FREE: {
+ free(r->eax);
+ break;
+ }
case SYS_EXEC: {
char *path = (char *)r->ebx;
struct proc *proc = proc_make();
bin_load(path, proc);
- strcpy(proc->name, path);
proc_print();
break;
}