Fix multitasking, threads work!
diff --git a/src/kernel/io.c b/src/kernel/io.c
index 0b300b5..4f7d3d3 100644
--- a/src/kernel/io.c
+++ b/src/kernel/io.c
@@ -78,11 +78,6 @@
return 0;
}
-void io_wait()
-{
- asm volatile("outb %0, $0x80" ::"a"(0));
-}
-
uchar kbd_scan_code()
{
return inb(KBD_DATA_PORT);
diff --git a/src/kernel/io.h b/src/kernel/io.h
index a7c1d8b..85f2e8c 100644
--- a/src/kernel/io.h
+++ b/src/kernel/io.h
@@ -26,8 +26,6 @@
int strcmp(char *a, char *b);
uint strlen(char *a);
-void io_wait();
-
uchar kbd_scan_code();
void kbd_handle_input(struct registers *registers);
void init_kbd();
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 1c654bd..1aebed6 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -78,6 +78,7 @@
kprintf("\ndone initializing tasks\n");
greet();
+ kprintf("other_thread = 0x%x\n", &other_thread);
spawn_thread(other_thread);
kprintf("thread spawned\n");
diff --git a/src/kernel/task.c b/src/kernel/task.c
index 82ad5ef..b460f25 100644
--- a/src/kernel/task.c
+++ b/src/kernel/task.c
@@ -73,10 +73,11 @@
// Virtual address of page directory (in kernel memory)
uint *dir_v = PHYS_TO_VIRT(proc->page_directory_p);
// Virtual location of new stack
- uint new_stack_base_v = proc->last_stack_pos = proc->last_stack_pos - 0x1000;
+ uint new_stack_base_v = proc->last_stack_pos - sizeof(uint);
+ proc->last_stack_pos -= 0x1000;
// Alloc a new page in the current process mapping to the new stack
- alloc_page(dir_v, (void *)new_stack_base_v);
+ alloc_page(dir_v, (void *)proc->last_stack_pos);
// <TEST>: see if we can assign to the new stack memory (ie: did mapping succeed)
uint *base = (uint *)new_stack_base_v;
diff --git a/src/kernel/timer.c b/src/kernel/timer.c
index d17025c..bafd06c 100644
--- a/src/kernel/timer.c
+++ b/src/kernel/timer.c
@@ -18,11 +18,8 @@
uint divisor = TIMER_FREQ / hz;
outb(0x43, 0x36);
- io_wait();
uchar l = divisor & 0xff, h = (divisor >> 8) & 0xff;
outb(0x40, l);
- io_wait();
outb(0x40, h);
- io_wait();
}
diff --git a/src/kernel/vga.c b/src/kernel/vga.c
index 1748116..49c2701 100644
--- a/src/kernel/vga.c
+++ b/src/kernel/vga.c
@@ -18,8 +18,6 @@
outb(0x3d5, pos >> 8);
outb(0x3d4, 0x0f);
outb(0x3d5, pos & 0xff);
-
- io_wait();
}
static void scroll()