Fix tasking, PCI
diff --git a/src/kernel/Jmk b/src/kernel/Jmk
index 0ae3053..ddbc343 100644
--- a/src/kernel/Jmk
+++ b/src/kernel/Jmk
@@ -16,7 +16,10 @@
# AHCI not yet implemented
# depends(ahci, dri/ahci, ahci.a)
-CFLAGS += -I $(ROOT)/include/kernel
+TEST ?=
+test_defines = $(TEST:%=-DTEST_%)
+
+CFLAGS += -I $(ROOT)/include/kernel $(test_defines)
LDFLAGS += -Tlink.ld -melf_i386
ASMFLAGS += -felf -Fdwarf
diff --git a/src/kernel/dri/pci/pci.c b/src/kernel/dri/pci/pci.c
index 67355a0..f9ebadb 100644
--- a/src/kernel/dri/pci/pci.c
+++ b/src/kernel/dri/pci/pci.c
@@ -49,3 +49,25 @@
start = guess;
}
}
+
+void pci_print_devices()
+{
+ kprintf("Enumerating PCI devices:\n");
+ for (int bus = 0; bus < 0xff; bus++)
+ {
+ for (int slot = 0; slot < 32; slot++)
+ {
+ for (int func = 0; func < 8; func++)
+ {
+ uint vendor;
+
+ struct pci_vendor *v = pci_check_vendor(bus, slot, func, &vendor);
+
+ if (vendor != ~0)
+ {
+ kprintf("%d %d %d --- 0x%x --- %s\n", bus, slot, func, vendor, v->name);
+ }
+ }
+ }
+ }
+}
diff --git a/src/kernel/main.c b/src/kernel/main.c
index fc9ee22..bc40ff8 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -74,46 +74,28 @@
}
#endif
- asm volatile("sti");
+ asm("sti");
kprintf("initializing tasks\n");
init_tasks();
kprintf("\ndone initializing tasks\n");
-//#ifdef TEST_THREADS
+#ifdef TEST_THREADS
spawn_thread(other_thread, NULL);
greet();
-//#endif
+#endif
#ifdef TEST_ATA_PIO
test_ata_pio();
#endif
#ifdef TEST_PCI
- kprintf("Enumerating PCI devices:\n");
- for (int bus = 0; bus < 0xff; bus++)
- {
- for (int slot = 0; slot < 32; slot++)
- {
- for (int func = 0; func < 8; func++)
- {
- uint vendor;
-
- struct pci_vendor *v = pci_check_vendor(bus, slot, func, &vendor);
-
- if (vendor != ~0)
- {
- kprintf("%d %d %d --- 0x%x --- %s\n", bus, slot, func, vendor, v->name);
- }
- }
- }
- }
+ pci_print_devices();
#endif
while (true)
- asm volatile("hlt");
-
+ asm("hlt");
return 0xCAFEBABE;
}
diff --git a/src/kernel/paging.h b/src/kernel/paging.h
index 045b872..20ecce9 100644
--- a/src/kernel/paging.h
+++ b/src/kernel/paging.h
@@ -4,7 +4,7 @@
#include "registers.h"
#define VIRT_TO_PHYS(virt) ((uint)(virt) - 0xC0000000)
-#define PHYS_TO_VIRT(phys) ((void *)(phys) + 0xC0000000)
+#define PHYS_TO_VIRT(phys) ((void *)((phys) + 0xC0000000))
#define KERNEL_VIRTUAL_BASE 0xC0000000
#define KERNEL_PAGE_NUMBER (KERNEL_VIRTUAL_BASE >> 22)
diff --git a/src/kernel/task.c b/src/kernel/task.c
index 564119a..b8ce525 100644
--- a/src/kernel/task.c
+++ b/src/kernel/task.c
@@ -83,7 +83,7 @@
void spawn_thread(void (*function)(void *), void *data)
{
- asm volatile("cli");
+ asm("cli");
struct process *proc = current_task->task.proc;
// Virtual address of page directory (in kernel memory)
@@ -115,12 +115,12 @@
ll_task->prev = last_task;
last_task = ll_task;
- asm volatile("sti");
+ asm("sti");
}
void kill_this_thread()
{
- asm volatile("cli");
+ asm("cli");
if (current_task->prev == NULL && current_task->next == NULL)
{
@@ -152,7 +152,7 @@
switch_to_task(¤t_task->task);
- asm volatile("sti");
+ asm("sti");
}
extern void _switch_to_task(uint page_directory, uint eip, uint ebp, uint esp);
@@ -170,7 +170,7 @@
void _do_switch_task(uint eip, uint ebp, uint esp)
{
// sti is called in switch_to_task
- asm volatile("cli");
+ asm("cli");
// save context for this task
current_task->task.ebp = ebp;
diff --git a/src/lisp/.gitignore b/src/lisp/.gitignore
index ee89f4f..6a43045 100644
--- a/src/lisp/.gitignore
+++ b/src/lisp/.gitignore
@@ -1,2 +1,2 @@
compiler.c
-lisp
\ No newline at end of file
+lisp