aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/kernel/fs/ata.h1
-rw-r--r--src/kernel/kernel.c1
-rw-r--r--src/kernel/syscall/actions/sys_wait.c22
-rw-r--r--src/kernel/system.c4
-rw-r--r--src/kernel/tasks/process.c24
-rw-r--r--src/kernel/tasks/process.h2
-rw-r--r--src/kernel/tasks/userspace.asm6
-rw-r--r--src/kernel/tasks/userspace.c1
-rw-r--r--src/userspace/programs/init.c4
9 files changed, 19 insertions, 46 deletions
diff --git a/src/kernel/fs/ata.h b/src/kernel/fs/ata.h
index 0422fe3..97a1069 100644
--- a/src/kernel/fs/ata.h
+++ b/src/kernel/fs/ata.h
@@ -8,6 +8,7 @@
#define LBA_BITS 28
// Port bases and offsets
+// TODO: Support other emulators/devices by using PCI ATA detection
#define PRIMARY_BASE 0x1F0
#define SECONDARY_BASE 0x170
#define DATA 0
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index 2d98179..f0b19c0 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -65,7 +65,6 @@ void kernel_main(u32 magic, u32 multiboot_address, u32 esp)
set_optimal_resolution();
log("Content of /etc/test: %s", read_file("/etc/test"));
- sti(); // Disabled until now
syscalls_install();
kexec("/bin/init");
diff --git a/src/kernel/syscall/actions/sys_wait.c b/src/kernel/syscall/actions/sys_wait.c
index a252d1f..01deef3 100644
--- a/src/kernel/syscall/actions/sys_wait.c
+++ b/src/kernel/syscall/actions/sys_wait.c
@@ -4,23 +4,7 @@
u32 sys_wait(u32 pid, u32 *status, u32 options)
{
- u32 ret;
-
- if (pid < 0) { // Wait for any process in gid to die
- ret = process_wait_gid(pid * -1, status);
- }
-
- if (pid == -1) { // Wait for any child to be killed
- ret = process_wait_gid(current_proc->pid, status);
- }
-
- if (pid == 0) { // Wait for siblings of this process to die
- ret = process_wait_gid(current_proc->gid, status);
- }
-
- if (pid > 0) { // Wait for pid to die
- ret = process_wait_pid(pid, status);
- }
-
- return ret;
+ if (pid > 0)
+ return process_wait_pid(pid, status);
+ return -1;
} \ No newline at end of file
diff --git a/src/kernel/system.c b/src/kernel/system.c
index 8a27de1..fd9a9b3 100644
--- a/src/kernel/system.c
+++ b/src/kernel/system.c
@@ -66,8 +66,8 @@ void _panic(const char *f, const char *msg)
{
cli();
_log(f, RED "PNC: %s - Halting system!" RES, msg);
- printf("[%s] PNC: %s - Halting system!\n\n", f, msg);
- printf("> %s", random_message[get_time() % 10]);
+ //printf("[%s] PNC: %s - Halting system!\n\n", f, msg);
+ //printf("> %s", random_message[get_time() % 10]);
halt_loop();
}
diff --git a/src/kernel/tasks/process.c b/src/kernel/tasks/process.c
index a5b9c87..45c9937 100644
--- a/src/kernel/tasks/process.c
+++ b/src/kernel/tasks/process.c
@@ -67,7 +67,6 @@ void process_init(struct process *proc)
root = proc;
root->pid = pid++;
root->next = NULL;
- root->thread = PROC_ROOT; // Unkillable
root->state = PROC_RUNNING;
current_proc = root;
@@ -105,23 +104,6 @@ u32 process_spawn(struct process *process)
return process->pid;
}
-u32 process_wait_gid(u32 gid, u32 *status)
-{
- struct process *i = root;
-
- while (i != NULL) {
- if (i->gid == gid)
- if (i->state == PROC_ASLEEP) {
- *status = i->registers.ebx;
- return i->pid;
- }
-
- i = i->next;
- }
-
- return WAIT_OKAY;
-}
-
u32 process_wait_pid(u32 pid, u32 *status)
{
struct process *i = current_proc->next;
@@ -144,6 +126,9 @@ u32 process_wait_pid(u32 pid, u32 *status)
void process_suspend(u32 pid)
{
debug("Suspending process %d", pid);
+ if (pid == 1)
+ panic("Root process died");
+
struct process *proc = process_from_pid(pid);
if (proc == PID_NOT_FOUND) {
@@ -152,6 +137,7 @@ void process_suspend(u32 pid)
}
proc->state = PROC_ASLEEP;
+ process_force_switch();
}
void process_wake(u32 pid)
@@ -163,6 +149,7 @@ void process_wake(u32 pid)
return;
proc->state = PROC_RUNNING;
+ process_force_switch();
}
u32 process_child(struct process *child, u32 pid)
@@ -220,6 +207,7 @@ u32 kexec(char *path)
return -1;
process_init(proc);
+ process_force_switch();
return 0;
}
diff --git a/src/kernel/tasks/process.h b/src/kernel/tasks/process.h
index 32511c0..25b11b2 100644
--- a/src/kernel/tasks/process.h
+++ b/src/kernel/tasks/process.h
@@ -17,11 +17,9 @@ struct process {
struct regs registers;
u32 pid;
- u32 gid;
char name[256];
int state;
- int thread;
u32 brk;
u32 handlers[6];
diff --git a/src/kernel/tasks/userspace.asm b/src/kernel/tasks/userspace.asm
index 4f79d4d..a708184 100644
--- a/src/kernel/tasks/userspace.asm
+++ b/src/kernel/tasks/userspace.asm
@@ -14,6 +14,12 @@ jump_userspace:
push 0x23
push eax
pushf
+
+ ; Enable interrupts
+ pop eax
+ or eax, 0x200
+ push eax
+
push 0x1B
push dword [hl_eip]
diff --git a/src/kernel/tasks/userspace.c b/src/kernel/tasks/userspace.c
index c3fc7e2..e9fd2f0 100644
--- a/src/kernel/tasks/userspace.c
+++ b/src/kernel/tasks/userspace.c
@@ -30,7 +30,6 @@ void userspace_enter(struct process *proc)
current_proc = proc;
debug("Jumping to userspace!");
- //sti(); // TODO: Prevent race conditions in userspace jumping
jump_userspace();
}
diff --git a/src/userspace/programs/init.c b/src/userspace/programs/init.c
index 7a4900b..724d11e 100644
--- a/src/userspace/programs/init.c
+++ b/src/userspace/programs/init.c
@@ -34,9 +34,7 @@ void main()
// TODO: Fix page fault when mallocing
printf("Initializing userspace...\n");
- // TODO: Find out, why processes change pid randomly
- // TODO: Fix occasional race conditions with cli/sti
- // TODO: Fix scheduler turning off at some point
+ // TODO: Fix scheduler turning off after spawn
spawn("/bin/sh");
printf("Looping in init\n");