aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMarvin Borner2020-08-15 17:42:36 +0200
committerMarvin Borner2020-08-15 17:42:36 +0200
commit9f16b032d38613ca95e321e1d1e652c43129c68b (patch)
tree33f71a84f60b496ed31a128ec542c5341c754b0d /kernel
parent32b8722128dfb4ca9e814940a23c2b22a283bb12 (diff)
Added libgui
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Makefile2
-rw-r--r--kernel/drivers/keyboard.c2
-rw-r--r--kernel/drivers/vesa.c2
-rw-r--r--kernel/features/proc.asm7
-rw-r--r--kernel/features/proc.c13
5 files changed, 21 insertions, 5 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index fa6d790..8544be4 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -22,7 +22,7 @@ AS = nasm
# Flags to make the binary smaller TODO: Remove after indirect pointer support!
CSFLAGS = -mpreferred-stack-boundary=2 -fno-asynchronous-unwind-tables -Os
-CFLAGS = $(CSFLAGS) -Wall -Wextra -nostdlib -nostdinc -ffreestanding -fno-builtin -mgeneral-regs-only -std=c99 -m32 -pedantic-errors -Wl,-ekernel_main -I../lib/inc/ -Iinc/ -Dkernel
+CFLAGS = $(CSFLAGS) -Wall -Wextra -nostdlib -nostdinc -ffreestanding -fno-builtin -mgeneral-regs-only -std=c99 -m32 -pedantic-errors -Wl,-ekernel_main -I../libc/inc/ -Iinc/ -Dkernel
ASFLAGS = -f elf32 -O3
diff --git a/kernel/drivers/keyboard.c b/kernel/drivers/keyboard.c
index 38ff1f7..d9ac5bb 100644
--- a/kernel/drivers/keyboard.c
+++ b/kernel/drivers/keyboard.c
@@ -1,3 +1,5 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
#include <cpu.h>
#include <def.h>
#include <gui.h>
diff --git a/kernel/drivers/vesa.c b/kernel/drivers/vesa.c
index 9402664..2d3e107 100644
--- a/kernel/drivers/vesa.c
+++ b/kernel/drivers/vesa.c
@@ -1,3 +1,5 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
#include <def.h>
#include <vesa.h>
diff --git a/kernel/features/proc.asm b/kernel/features/proc.asm
index 3d6bbc4..1a2ba65 100644
--- a/kernel/features/proc.asm
+++ b/kernel/features/proc.asm
@@ -1,11 +1,14 @@
%define USER_CODE_SEGMENT 0x18
%define USER_DATA_SEGMENT 0x20
%define RING3_MASK 0b11
+%define INTERRUPT_FLAG 0x200
global proc_jump_userspace
extern _esp
extern _eip
proc_jump_userspace:
+ cli
+
mov ax, USER_DATA_SEGMENT | RING3_MASK
mov ds, ax
mov es, ax
@@ -17,7 +20,9 @@ proc_jump_userspace:
push eax
pushf
- sti
+ pop eax
+ or eax, INTERRUPT_FLAG
+ push eax
push USER_CODE_SEGMENT | RING3_MASK
push dword [_eip]
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 40a52f8..76ec16e 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -1,5 +1,6 @@
// MIT License, Copyright (c) 2020 Marvin Borner
+#include <assert.h>
#include <cpu.h>
#include <interrupts.h>
#include <load.h>
@@ -8,6 +9,7 @@
#include <proc.h>
#include <str.h>
#include <timer.h>
+#include <vesa.h>
u32 pid = 0;
struct proc *root;
@@ -26,11 +28,14 @@ void scheduler(struct regs *regs)
else
current = root;
- while (current->state == PROC_ASLEEP)
- if (!current->next)
+ while (current->state == PROC_ASLEEP) {
+ if (!current->next) {
+ assert(root->state == PROC_RUNNING || pid > 1);
current = root;
- else
+ } else {
current = current->next;
+ }
+ }
/* proc_print(); */
memcpy(regs, &current->regs, sizeof(struct regs));
@@ -104,5 +109,7 @@ void proc_init()
_eip = root->regs.eip;
_esp = root->regs.esp;
+ ((u32 *)_esp)[1] = (u32)vbe; // First argument
+
proc_jump_userspace();
}