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