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