swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame] | 1 | init(kernel, kernel.elf) |
| 2 | |
| 3 | preset(freestanding) |
| 4 | preset(optimize) |
| 5 | preset(debug) |
| 6 | preset(32) |
| 7 | preset(warn) |
| 8 | preset(nasm) |
| 9 | |
| 10 | archetype(c) |
| 11 | archetype(asm) |
| 12 | |
| 13 | depends(initrd, $(ROOT)/boot/initrd, initrd.img) |
swissChili | 1a3f07f | 2021-04-05 20:01:55 -0700 | [diff] [blame] | 14 | depends(ata_pio, dri/ata_pio, ata_pio.a) |
swissChili | e849174 | 2021-04-08 20:38:06 -0700 | [diff] [blame] | 15 | depends(pci, dri/pci, pci.a) |
swissChili | 5fe85a1 | 2021-05-31 08:10:27 -0700 | [diff] [blame] | 16 | depends(ide, dri/ide, ide.a) |
swissChili | 4418ca5 | 2021-06-14 17:36:00 -0700 | [diff] [blame] | 17 | depends(ext2, dri/fs/ext2, ext2.a) |
swissChili | e849174 | 2021-04-08 20:38:06 -0700 | [diff] [blame] | 18 | # AHCI not yet implemented |
| 19 | # depends(ahci, dri/ahci, ahci.a) |
swissChili | 1a3f07f | 2021-04-05 20:01:55 -0700 | [diff] [blame] | 20 | |
swissChili | 402a383 | 2021-05-29 21:41:31 -0700 | [diff] [blame] | 21 | TEST ?= |
| 22 | test_defines = $(TEST:%=-DTEST_%) |
| 23 | |
swissChili | 4418ca5 | 2021-06-14 17:36:00 -0700 | [diff] [blame] | 24 | FS ?= ext2 |
| 25 | |
swissChili | 402a383 | 2021-05-29 21:41:31 -0700 | [diff] [blame] | 26 | CFLAGS += -I $(ROOT)/include/kernel $(test_defines) |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame] | 27 | |
swissChili | 6422869 | 2021-03-16 08:19:23 -0700 | [diff] [blame] | 28 | LDFLAGS += -Tlink.ld -melf_i386 |
swissChili | 7be3274 | 2021-04-03 21:17:24 -0700 | [diff] [blame] | 29 | ASMFLAGS += -felf -Fdwarf |
swissChili | 276b8cf | 2021-07-16 13:24:42 -0700 | [diff] [blame^] | 30 | QEMUFLAGS = -hda hd0_ext2.img |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame] | 31 | |
| 32 | OBJECTS = boot.o \ |
| 33 | main.o \ |
| 34 | descriptor_tables.o \ |
| 35 | io.o \ |
| 36 | vga.o \ |
| 37 | gdt_flush.o \ |
| 38 | idt.o \ |
| 39 | log.o \ |
| 40 | irq.o \ |
| 41 | pic.o \ |
| 42 | timer.o \ |
| 43 | paging.o \ |
| 44 | switch_table.o \ |
| 45 | scan_codes.o \ |
| 46 | kheap.o \ |
| 47 | alloc.o \ |
| 48 | vfs.o \ |
| 49 | multiboot.o \ |
swissChili | 6422869 | 2021-03-16 08:19:23 -0700 | [diff] [blame] | 50 | vfs_initrd.o \ |
swissChili | e20b79b | 2021-03-17 21:20:13 -0700 | [diff] [blame] | 51 | syscall.o \ |
swissChili | cfd3c3c | 2021-04-03 15:04:24 -0700 | [diff] [blame] | 52 | task.o \ |
swissChili | 1a3f07f | 2021-04-05 20:01:55 -0700 | [diff] [blame] | 53 | task_api.o \ |
swissChili | aed6ff3 | 2021-05-29 17:51:04 -0700 | [diff] [blame] | 54 | faults.o \ |
swissChili | 4418ca5 | 2021-06-14 17:36:00 -0700 | [diff] [blame] | 55 | lib(ext2) \ |
swissChili | e5adca5 | 2021-06-16 21:00:31 -0700 | [diff] [blame] | 56 | lib(ide) \ |
swissChili | e849174 | 2021-04-08 20:38:06 -0700 | [diff] [blame] | 57 | lib(ata_pio) \ |
swissChili | e5adca5 | 2021-06-16 21:00:31 -0700 | [diff] [blame] | 58 | lib(pci) |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame] | 59 | |
| 60 | type(custom_link) |
| 61 | |
swissChili | cfd3c3c | 2021-04-03 15:04:24 -0700 | [diff] [blame] | 62 | debug-wait: kernel.elf |
| 63 | qemu-system-i386 -s -S -kernel kernel.elf |
| 64 | |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame] | 65 | debug: kernel.elf |
swissChili | 9bd74de | 2021-06-15 20:30:48 -0700 | [diff] [blame] | 66 | qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf & |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame] | 67 | @echo run "target remote localhost:1234" to connect to qemu |
swissChili | cfd3c3c | 2021-04-03 15:04:24 -0700 | [diff] [blame] | 68 | gdb $< |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame] | 69 | @pkill qemu-system-i38 |
| 70 | |
swissChili | 4418ca5 | 2021-06-14 17:36:00 -0700 | [diff] [blame] | 71 | hd0_%.img: |
swissChili | ef829f3 | 2021-06-13 20:00:54 -0700 | [diff] [blame] | 72 | status_log(MKFS, $@) |
| 73 | @dd bs=4M count=8 if=/dev/zero of=$@ |
swissChili | 4418ca5 | 2021-06-14 17:36:00 -0700 | [diff] [blame] | 74 | @$(patsubst hd0_%.img,mkfs.%,$@) $@ |
swissChili | ef829f3 | 2021-06-13 20:00:54 -0700 | [diff] [blame] | 75 | |
swissChili | 4418ca5 | 2021-06-14 17:36:00 -0700 | [diff] [blame] | 76 | qemu: kernel.elf hd0_$(FS).img |
swissChili | 9bd74de | 2021-06-15 20:30:48 -0700 | [diff] [blame] | 77 | qemu-system-i386 $(QEMUFLAGS) -d cpu_reset -monitor stdio -kernel kernel.elf -no-reboot |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame] | 78 | |
| 79 | qemu-iso: install |
| 80 | qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso |
| 81 | |
| 82 | scan_codes.c: gen_scan_codes.py scan_codes.tsv |
| 83 | python3 $< > $@ |
| 84 | |
swissChili | 4418ca5 | 2021-06-14 17:36:00 -0700 | [diff] [blame] | 85 | mount: hd0_$(FS).img |
swissChili | ef829f3 | 2021-06-13 20:00:54 -0700 | [diff] [blame] | 86 | status_log(MOUNT, $^ $(ROOT)/mnt) |
swissChili | 9bd74de | 2021-06-15 20:30:48 -0700 | [diff] [blame] | 87 | @if [ "$(whoami)" = root ]; then echo "DON'T RUN THIS AS ROOT" && exit 1; fi |
swissChili | ef829f3 | 2021-06-13 20:00:54 -0700 | [diff] [blame] | 88 | @mkdir -p $(ROOT)/mnt |
swissChili | 9bd74de | 2021-06-15 20:30:48 -0700 | [diff] [blame] | 89 | @mount $^ $(ROOT)/mnt |
swissChili | ef829f3 | 2021-06-13 20:00:54 -0700 | [diff] [blame] | 90 | |
| 91 | umount: |
| 92 | status_log(UMOUNT, $(ROOT)/mnt) |
| 93 | @umount $(ROOT)/mnt |
| 94 | |
swissChili | 2b5acc8 | 2021-03-13 17:06:42 -0800 | [diff] [blame] | 95 | install: kernel.elf lib(initrd) |
| 96 | cp kernel.elf $(ROOT)/boot/ |
| 97 | rm -f $(ROOT)/bin/bluejay.iso |
| 98 | grub-mkrescue -o $(ROOT)/bin/bluejay.iso $(ROOT) |
| 99 | |
| 100 | finish |