aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMarvin Borner2021-01-21 16:14:56 +0100
committerMarvin Borner2021-01-21 16:14:56 +0100
commitef407d1e965674c5278daeb25a72acf446ec3223 (patch)
tree941d61b0fff4682bba57e056fcee93059a9cd4b8 /kernel
parent7442dc40a12bd61d6a77fafbc1ea031a2b51937a (diff)
Fixed some dumb bugs
Diffstat (limited to 'kernel')
-rw-r--r--kernel/features/fs.c1
-rw-r--r--kernel/features/load.c4
-rw-r--r--kernel/features/proc.c22
-rw-r--r--kernel/inc/proc.h1
4 files changed, 17 insertions, 11 deletions
diff --git a/kernel/features/fs.c b/kernel/features/fs.c
index 9918983..48e736a 100644
--- a/kernel/features/fs.c
+++ b/kernel/features/fs.c
@@ -1,7 +1,6 @@
// MIT License, Copyright (c) 2020 Marvin Borner
#include <assert.h>
-#include <cpu.h>
#include <def.h>
#include <fs.h>
#include <ide.h>
diff --git a/kernel/features/load.c b/kernel/features/load.c
index 743c009..3e1ea8e 100644
--- a/kernel/features/load.c
+++ b/kernel/features/load.c
@@ -21,10 +21,10 @@ int bin_load(char *path, struct proc *proc)
vfs_stat(path, &s);
char *data = malloc(s.size);
if (!vfs_read(path, data, 0, s.size))
- return 0;
+ return 1;
strcpy(proc->name, path);
proc_load(proc, data);
- return 1;
+ return 0;
}
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 9af1ce4..5e918b2 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -99,6 +99,11 @@ struct proc *proc_from_pid(u32 pid)
return NULL;
}
+void proc_clear_quantum()
+{
+ quantum = 0;
+}
+
void proc_exit(struct proc *proc, int status)
{
assert(proc);
@@ -120,19 +125,14 @@ void proc_exit(struct proc *proc, int status)
if (res)
printf("Process %s exited with status %d\n", proc->name, status);
- quantum = 0; // TODO: Add quantum to each process struct?
+ proc_clear_quantum(); // TODO: Add quantum to each process struct?
sti();
hlt();
}
-void proc_clear_quantum()
-{
- quantum = 0;
-}
-
void proc_yield(struct regs *r)
{
- proc_clear_quantum();
+ //proc_clear_quantum();
scheduler(r);
}
@@ -245,6 +245,13 @@ u32 procfs_read(const char *path, void *buf, u32 offset, u32 count, struct devic
return 0;
}
+u32 procfs_ready(const char *path, struct device *dev)
+{
+ (void)path;
+ (void)dev;
+ return 1;
+}
+
extern void proc_jump_userspace(void);
u32 _esp, _eip;
@@ -262,6 +269,7 @@ void proc_init(void)
vfs->type = VFS_PROCFS;
vfs->read = procfs_read;
vfs->write = procfs_write;
+ vfs->ready = procfs_ready;
struct device *dev = malloc(sizeof(*dev));
dev->name = "proc";
dev->type = DEV_CHAR;
diff --git a/kernel/inc/proc.h b/kernel/inc/proc.h
index 30af5b1..d87ebef 100644
--- a/kernel/inc/proc.h
+++ b/kernel/inc/proc.h
@@ -28,7 +28,6 @@ struct proc {
u32 pid;
char name[32];
struct regs regs;
- struct regs regs_backup;
struct proc_wait wait; // dev_id
enum proc_state state;
struct stack *messages;