Move kernel sources to platform specific subdirs
diff --git a/src/kernel/Jmk b/src/kernel/Jmk
deleted file mode 100644
index 25898cc..0000000
--- a/src/kernel/Jmk
+++ /dev/null
@@ -1,117 +0,0 @@
-# -*- mode:makefile -*-
-
-init(kernel, kernel.elf)
-
-preset(freestanding)
-# This makes debugging hard :(
-# preset(optimize)
-preset(debug)
-preset(32)
-preset(warn)
-preset(nasm)
-
-archetype(c)
-archetype(asm)
-
-depends(sys, $(ROOT)/src/libsys, libsys.a)
-depends(initrd, $(ROOT)/boot/initrd, initrd.img)
-depends(ata_pio, dri/ata_pio, ata_pio.a)
-depends(pci, dri/pci, pci.a)
-depends(ide, dri/ide, ide.a)
-depends(ext2, dri/fs/ext2, ext2.a)
-# AHCI not yet implemented
-# depends(ahci, dri/ahci, ahci.a)
-
-TEST ?=
-test_defines = $(TEST:%=-DTEST_%)
-
-FS ?= ext2
-
-CFLAGS += -I$(ROOT)/include/kernel $(test_defines) -O0 -Wno-ignored-qualifiers -Wno-sign-compare
-
-LDFLAGS += -Tlink.ld -melf_i386
-ASMFLAGS += -felf -Fdwarf
-QEMUFLAGS = -drive file=hd0_ext2.img,format=raw
-
-OBJECTS = boot.o \
- main.o \
- descriptor_tables.o \
- io.o \
- vga.o \
- gdt_flush.o \
- tss_flush.o \
- idt.o \
- log.o \
- irq.o \
- pic.o \
- timer.o \
- paging.o \
- switch_table.o \
- scan_codes.o \
- kheap.o \
- alloc.o \
- vfs.o \
- multiboot.o \
- vfs_initrd.o \
- syscall.o \
- task.o \
- task_api.o \
- faults.o \
- sync.o \
- lib(ext2) \
- lib(ide) \
- lib(ata_pio) \
- lib(pci) \
- lib(sys)
-
-type(custom_link)
-
-debug-wait: kernel.elf
- qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf
-
-debug: kernel.elf
- qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf &
- @echo run "target remote localhost:1234" to connect to qemu
- gdb $<
- @pkill qemu-system-i38
-
-hd0_%.img:
- status_log(MKFS, $@)
- @dd bs=4M count=8 if=/dev/zero of=$@
- @$(patsubst hd0_%.img,mkfs.%,$@) $@
-
-fs-info: hd0_$(FS).img
- tune2fs -l $< | grep -i inode
-
-reset-fs:
- @rm hd0_ext2.img
- @$(MAKE) hd0_ext2.img
- @sudo $(MAKE) mount
- @echo 'hi' | sudo tee $(ROOT)/mnt/hello.txt
- @sudo $(MAKE) umount
- @$(MAKE) qemu
-
-qemu: kernel.elf hd0_$(FS).img
- qemu-system-i386 $(QEMUFLAGS) -d cpu_reset -monitor stdio -kernel kernel.elf -no-reboot
-
-qemu-iso: install
- qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso
-
-scan_codes.c: gen_scan_codes.py scan_codes.tsv
- python3 $< > $@
-
-mount: hd0_$(FS).img
- status_log(MOUNT, $^ $(ROOT)/mnt)
- @mkdir -p $(ROOT)/mnt
- @mount $^ $(ROOT)/mnt
-
-umount:
- status_log(UMOUNT, $(ROOT)/mnt)
- @umount $(ROOT)/mnt
-
-install: kernel.elf lib(initrd)
- cp kernel.elf $(ROOT)/boot/
- rm -f $(ROOT)/bin/bluejay.iso
- grub-mkrescue -o $(ROOT)/bin/bluejay.iso $(ROOT)
-
-finish
diff --git a/src/kernel/Jmk2 b/src/kernel/Jmk2
index 21b7ebe..38e44b9 100644
--- a/src/kernel/Jmk2
+++ b/src/kernel/Jmk2
@@ -4,69 +4,15 @@
presets freestanding debug 32 warn nasm
-cflags -I$root/include/kernel -I$root/include -O0 -Wno-ignored-qualifiers -Wno-sign-compare
+cflags -I$root/include/kernel -I$root/include -I[pwd] -O0 -Wno-ignored-qualifiers -Wno-unused-params -Wno-sign-compare
-ldflags -Tlink.ld -melf_i386
-asmflags -felf -Fdwarf
-set qemuflags "-drive file=hd0_ext2.img,format=raw"
+# Sources are mostly platform dependent (for now ;D )
+enable_multiplat
-depends sys $root/src/libsys libsys.a
-depends initrd $root/boot/initrd initrd.img
-depends ata_pio dri/ata_pio ata_pio.a
-depends pci dri/pci pci.a
-depends ide dri/ide ide.a
-depends ext2 dri/fs/ext2 ext2.a
-
-option FS ext2
-
-srcs boot.s \
- main.c \
- descriptor_tables.c \
- io.c \
- vga.c \
- gdt_flush.s \
- tss_flush.s \
- idt.s \
- log.c \
- irq.c \
- pic.c \
- timer.c \
- paging.c \
- switch_table.s \
- scan_codes.c \
- kheap.c \
- alloc.c \
- vfs.c \
- multiboot.c \
- vfs_initrd.c \
- syscall.c \
- task.c \
- task_api.s \
- faults.c \
- sync.c
-
-objs [lib ext2] \
- [lib ide] \
- [lib ata_pio] \
- [lib pci] \
- [lib sys]
-
-type custom_link
-
-rule debug-wait kernel.elf {
- shell "qemu-system-i386 -s -S $::qemuflags -kernel kernel.efl"
-}
-rule debug kernel.elf {
- shell "qemu-system-i386 -s -S $::qemuflags -kernel kernel.efl"
- shell "echo run target remote localhost:1234 to connect to qemu"
- shell "gdb $::first_src"
- shell "pkill qemu-system-i386"
-}
-
-rule qemu "kernel.elf hd0_$::options(FS).img" {
- shell "qemu-system-i386 $::qemuflags -d cpu_reset -monitor stdio -kernel kernel.elf -no-reboot"
-}
+srcs scan_codes.c
rule scan_codes.c "gen_scan_codes.py scan_codes.tsv" {
shell "python3 $::first_src > $::target"
}
+
+type custom_link
diff --git a/src/kernel/srcmap.txt b/src/kernel/srcmap.txt
deleted file mode 100644
index c9219a7..0000000
--- a/src/kernel/srcmap.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-+------------+
-| Source map |
-+------------+
-
-
-Source File Description
-----------------------------------------------------------------
-io.c low level memory management stuff, io utils
-log.c logging, panics, assert, etc
-vga.c vga drivers
-timer.c sets up interrupt timer
-descriptor_tables.c sets up IDT and GDT
-paging.c sets up paging
-pic.c IRQ handler
-interrupts.c ISR handler
-boot.s calls kmain
-main.c entry point
diff --git a/src/kernel/.gdbinit b/src/kernel/x86_32/.gdbinit
similarity index 100%
rename from src/kernel/.gdbinit
rename to src/kernel/x86_32/.gdbinit
diff --git a/src/kernel/alloc.c b/src/kernel/x86_32/alloc.c
similarity index 100%
rename from src/kernel/alloc.c
rename to src/kernel/x86_32/alloc.c
diff --git a/src/kernel/bf.c b/src/kernel/x86_32/bf.c
similarity index 100%
rename from src/kernel/bf.c
rename to src/kernel/x86_32/bf.c
diff --git a/src/kernel/boot.s b/src/kernel/x86_32/boot.s
similarity index 100%
rename from src/kernel/boot.s
rename to src/kernel/x86_32/boot.s
diff --git a/src/kernel/descriptor_tables.c b/src/kernel/x86_32/descriptor_tables.c
similarity index 100%
rename from src/kernel/descriptor_tables.c
rename to src/kernel/x86_32/descriptor_tables.c
diff --git a/src/kernel/descriptor_tables.h b/src/kernel/x86_32/descriptor_tables.h
similarity index 100%
rename from src/kernel/descriptor_tables.h
rename to src/kernel/x86_32/descriptor_tables.h
diff --git a/src/kernel/faults.c b/src/kernel/x86_32/faults.c
similarity index 100%
rename from src/kernel/faults.c
rename to src/kernel/x86_32/faults.c
diff --git a/src/kernel/faults.h b/src/kernel/x86_32/faults.h
similarity index 100%
rename from src/kernel/faults.h
rename to src/kernel/x86_32/faults.h
diff --git a/src/kernel/gdt_flush.s b/src/kernel/x86_32/gdt_flush.s
similarity index 100%
rename from src/kernel/gdt_flush.s
rename to src/kernel/x86_32/gdt_flush.s
diff --git a/src/kernel/idt.s b/src/kernel/x86_32/idt.s
similarity index 100%
rename from src/kernel/idt.s
rename to src/kernel/x86_32/idt.s
diff --git a/src/kernel/io.c b/src/kernel/x86_32/io.c
similarity index 100%
rename from src/kernel/io.c
rename to src/kernel/x86_32/io.c
diff --git a/src/kernel/irq.s b/src/kernel/x86_32/irq.s
similarity index 100%
rename from src/kernel/irq.s
rename to src/kernel/x86_32/irq.s
diff --git a/src/kernel/kheap.c b/src/kernel/x86_32/kheap.c
similarity index 100%
rename from src/kernel/kheap.c
rename to src/kernel/x86_32/kheap.c
diff --git a/src/kernel/kheap.h b/src/kernel/x86_32/kheap.h
similarity index 100%
rename from src/kernel/kheap.h
rename to src/kernel/x86_32/kheap.h
diff --git a/src/kernel/link.ld b/src/kernel/x86_32/link.ld
similarity index 100%
rename from src/kernel/link.ld
rename to src/kernel/x86_32/link.ld
diff --git a/src/kernel/log.c b/src/kernel/x86_32/log.c
similarity index 100%
rename from src/kernel/log.c
rename to src/kernel/x86_32/log.c
diff --git a/src/kernel/main.c b/src/kernel/x86_32/main.c
similarity index 100%
rename from src/kernel/main.c
rename to src/kernel/x86_32/main.c
diff --git a/src/kernel/multiboot.c b/src/kernel/x86_32/multiboot.c
similarity index 100%
rename from src/kernel/multiboot.c
rename to src/kernel/x86_32/multiboot.c
diff --git a/src/kernel/multiboot.h b/src/kernel/x86_32/multiboot.h
similarity index 100%
rename from src/kernel/multiboot.h
rename to src/kernel/x86_32/multiboot.h
diff --git a/src/kernel/paging.c b/src/kernel/x86_32/paging.c
similarity index 100%
rename from src/kernel/paging.c
rename to src/kernel/x86_32/paging.c
diff --git a/src/kernel/paging.h b/src/kernel/x86_32/paging.h
similarity index 100%
rename from src/kernel/paging.h
rename to src/kernel/x86_32/paging.h
diff --git a/src/kernel/pic.c b/src/kernel/x86_32/pic.c
similarity index 100%
rename from src/kernel/pic.c
rename to src/kernel/x86_32/pic.c
diff --git a/src/kernel/stdarg.h b/src/kernel/x86_32/stdarg.h
similarity index 100%
rename from src/kernel/stdarg.h
rename to src/kernel/x86_32/stdarg.h
diff --git a/src/kernel/switch_table.s b/src/kernel/x86_32/switch_table.s
similarity index 100%
rename from src/kernel/switch_table.s
rename to src/kernel/x86_32/switch_table.s
diff --git a/src/kernel/sync.c b/src/kernel/x86_32/sync.c
similarity index 100%
rename from src/kernel/sync.c
rename to src/kernel/x86_32/sync.c
diff --git a/src/kernel/syscall.c b/src/kernel/x86_32/syscall.c
similarity index 100%
rename from src/kernel/syscall.c
rename to src/kernel/x86_32/syscall.c
diff --git a/src/kernel/syscall.h b/src/kernel/x86_32/syscall.h
similarity index 100%
rename from src/kernel/syscall.h
rename to src/kernel/x86_32/syscall.h
diff --git a/src/kernel/task.c b/src/kernel/x86_32/task.c
similarity index 100%
rename from src/kernel/task.c
rename to src/kernel/x86_32/task.c
diff --git a/src/kernel/task_api.s b/src/kernel/x86_32/task_api.s
similarity index 100%
rename from src/kernel/task_api.s
rename to src/kernel/x86_32/task_api.s
diff --git a/src/kernel/timer.c b/src/kernel/x86_32/timer.c
similarity index 100%
rename from src/kernel/timer.c
rename to src/kernel/x86_32/timer.c
diff --git a/src/kernel/timer.h b/src/kernel/x86_32/timer.h
similarity index 100%
rename from src/kernel/timer.h
rename to src/kernel/x86_32/timer.h
diff --git a/src/kernel/tss_flush.s b/src/kernel/x86_32/tss_flush.s
similarity index 100%
rename from src/kernel/tss_flush.s
rename to src/kernel/x86_32/tss_flush.s
diff --git a/src/kernel/vfs.c b/src/kernel/x86_32/vfs.c
similarity index 100%
rename from src/kernel/vfs.c
rename to src/kernel/x86_32/vfs.c
diff --git a/src/kernel/vfs_initrd.c b/src/kernel/x86_32/vfs_initrd.c
similarity index 100%
rename from src/kernel/vfs_initrd.c
rename to src/kernel/x86_32/vfs_initrd.c
diff --git a/src/kernel/vfs_initrd.h b/src/kernel/x86_32/vfs_initrd.h
similarity index 100%
rename from src/kernel/vfs_initrd.h
rename to src/kernel/x86_32/vfs_initrd.h
diff --git a/src/kernel/vga.c b/src/kernel/x86_32/vga.c
similarity index 100%
rename from src/kernel/vga.c
rename to src/kernel/x86_32/vga.c
diff --git a/src/kernel/vga.h b/src/kernel/x86_32/vga.h
similarity index 100%
rename from src/kernel/vga.h
rename to src/kernel/x86_32/vga.h
diff --git a/src/kernel/x86_32/x86_32.jmk b/src/kernel/x86_32/x86_32.jmk
new file mode 100644
index 0000000..875331c
--- /dev/null
+++ b/src/kernel/x86_32/x86_32.jmk
@@ -0,0 +1,59 @@
+# -*- tcl -*-
+
+ldflags -T[pwd]/link.ld -melf_i386
+asmflags -felf -Fdwarf
+set qemuflags "-drive file=hd0_ext2.img,format=raw"
+
+depends sys $root/src/libsys libsys.a
+depends initrd $root/boot/initrd initrd.img
+depends ata_pio dri/ata_pio ata_pio.a
+depends pci dri/pci pci.a
+depends ide dri/ide ide.a
+depends ext2 dri/fs/ext2 ext2.a
+
+option FS ext2
+
+srcs boot.s \
+ main.c \
+ descriptor_tables.c \
+ io.c \
+ vga.c \
+ gdt_flush.s \
+ tss_flush.s \
+ idt.s \
+ log.c \
+ irq.c \
+ pic.c \
+ timer.c \
+ paging.c \
+ switch_table.s \
+ kheap.c \
+ alloc.c \
+ vfs.c \
+ multiboot.c \
+ vfs_initrd.c \
+ syscall.c \
+ task.c \
+ task_api.s \
+ faults.c \
+ sync.c
+
+objs [lib ext2] \
+ [lib ide] \
+ [lib ata_pio] \
+ [lib pci] \
+ [lib sys]
+
+rule debug-wait kernel.elf {
+ shell "qemu-system-i386 -s -S $::qemuflags -kernel kernel.efl"
+}
+rule debug kernel.elf {
+ shell "qemu-system-i386 -s -S $::qemuflags -kernel kernel.efl"
+ shell "echo run target remote localhost:1234 to connect to qemu"
+ shell "gdb $::first_src"
+ shell "pkill qemu-system-i386"
+}
+
+rule qemu "kernel.elf hd0_$::options(FS).img" {
+ shell "qemu-system-i386 $::qemuflags -d cpu_reset -monitor stdio -kernel kernel.elf -no-reboot"
+}