blob: 4b78fbb272d93aaf2b79227468ecac7afe2e8d8e [file] [log] [blame]
swissChili2b5acc82021-03-13 17:06:42 -08001init(kernel, kernel.elf)
2
3preset(freestanding)
swissChilib7ef65d2021-07-17 12:51:52 -07004# This makes debugging hard :(
5# preset(optimize)
swissChili2b5acc82021-03-13 17:06:42 -08006preset(debug)
7preset(32)
8preset(warn)
9preset(nasm)
10
11archetype(c)
12archetype(asm)
13
swissChili52a03d82021-07-18 15:22:14 -070014depends(sys, $(ROOT)/src/libsys, libsys.a)
swissChili2b5acc82021-03-13 17:06:42 -080015depends(initrd, $(ROOT)/boot/initrd, initrd.img)
swissChili1a3f07f2021-04-05 20:01:55 -070016depends(ata_pio, dri/ata_pio, ata_pio.a)
swissChilie8491742021-04-08 20:38:06 -070017depends(pci, dri/pci, pci.a)
swissChili5fe85a12021-05-31 08:10:27 -070018depends(ide, dri/ide, ide.a)
swissChili4418ca52021-06-14 17:36:00 -070019depends(ext2, dri/fs/ext2, ext2.a)
swissChilie8491742021-04-08 20:38:06 -070020# AHCI not yet implemented
21# depends(ahci, dri/ahci, ahci.a)
swissChili1a3f07f2021-04-05 20:01:55 -070022
swissChili402a3832021-05-29 21:41:31 -070023TEST ?=
24test_defines = $(TEST:%=-DTEST_%)
25
swissChili4418ca52021-06-14 17:36:00 -070026FS ?= ext2
27
swissChilicbd43632021-07-17 16:19:44 -070028CFLAGS += -I $(ROOT)/include/kernel $(test_defines) -O0
swissChili2b5acc82021-03-13 17:06:42 -080029
swissChili64228692021-03-16 08:19:23 -070030LDFLAGS += -Tlink.ld -melf_i386
swissChili7be32742021-04-03 21:17:24 -070031ASMFLAGS += -felf -Fdwarf
swissChili36ed5d72021-07-23 14:56:36 -070032QEMUFLAGS = -drive file=hd0_ext2.img,format=raw
swissChili2b5acc82021-03-13 17:06:42 -080033
34OBJECTS = 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 \
swissChili64228692021-03-16 08:19:23 -070052 vfs_initrd.o \
swissChilie20b79b2021-03-17 21:20:13 -070053 syscall.o \
swissChilicfd3c3c2021-04-03 15:04:24 -070054 task.o \
swissChili1a3f07f2021-04-05 20:01:55 -070055 task_api.o \
swissChiliaed6ff32021-05-29 17:51:04 -070056 faults.o \
swissChili52a03d82021-07-18 15:22:14 -070057 sync.o \
swissChili4418ca52021-06-14 17:36:00 -070058 lib(ext2) \
swissChilie5adca52021-06-16 21:00:31 -070059 lib(ide) \
swissChilie8491742021-04-08 20:38:06 -070060 lib(ata_pio) \
swissChili52a03d82021-07-18 15:22:14 -070061 lib(pci) \
62 lib(sys)
swissChili2b5acc82021-03-13 17:06:42 -080063
64type(custom_link)
65
swissChilicfd3c3c2021-04-03 15:04:24 -070066debug-wait: kernel.elf
swissChilib7ef65d2021-07-17 12:51:52 -070067 qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf
swissChilicfd3c3c2021-04-03 15:04:24 -070068
swissChili2b5acc82021-03-13 17:06:42 -080069debug: kernel.elf
swissChili9bd74de2021-06-15 20:30:48 -070070 qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf &
swissChili2b5acc82021-03-13 17:06:42 -080071 @echo run "target remote localhost:1234" to connect to qemu
swissChilicfd3c3c2021-04-03 15:04:24 -070072 gdb $<
swissChili2b5acc82021-03-13 17:06:42 -080073 @pkill qemu-system-i38
74
swissChili4418ca52021-06-14 17:36:00 -070075hd0_%.img:
swissChilief829f32021-06-13 20:00:54 -070076 status_log(MKFS, $@)
77 @dd bs=4M count=8 if=/dev/zero of=$@
swissChili4418ca52021-06-14 17:36:00 -070078 @$(patsubst hd0_%.img,mkfs.%,$@) $@
swissChilief829f32021-06-13 20:00:54 -070079
swissChilicaa24782021-07-19 14:29:58 -070080fs-info: hd0_$(FS).img
81 tune2fs -l $< | grep -i inode
82
swissChili36ed5d72021-07-23 14:56:36 -070083reset-fs:
84 @rm hd0_ext2.img
85 @$(MAKE) hd0_ext2.img
86 @sudo $(MAKE) mount
87 @echo 'hi' | sudo tee $(ROOT)/mnt/hello.txt
88 @sudo $(MAKE) umount
89 @$(MAKE) qemu
90
swissChili4418ca52021-06-14 17:36:00 -070091qemu: kernel.elf hd0_$(FS).img
swissChili9bd74de2021-06-15 20:30:48 -070092 qemu-system-i386 $(QEMUFLAGS) -d cpu_reset -monitor stdio -kernel kernel.elf -no-reboot
swissChili2b5acc82021-03-13 17:06:42 -080093
94qemu-iso: install
95 qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso
96
97scan_codes.c: gen_scan_codes.py scan_codes.tsv
98 python3 $< > $@
99
swissChili4418ca52021-06-14 17:36:00 -0700100mount: hd0_$(FS).img
swissChilief829f32021-06-13 20:00:54 -0700101 status_log(MOUNT, $^ $(ROOT)/mnt)
102 @mkdir -p $(ROOT)/mnt
swissChili9bd74de2021-06-15 20:30:48 -0700103 @mount $^ $(ROOT)/mnt
swissChilief829f32021-06-13 20:00:54 -0700104
105umount:
106 status_log(UMOUNT, $(ROOT)/mnt)
107 @umount $(ROOT)/mnt
108
swissChili2b5acc82021-03-13 17:06:42 -0800109install: kernel.elf lib(initrd)
110 cp kernel.elf $(ROOT)/boot/
111 rm -f $(ROOT)/bin/bluejay.iso
112 grub-mkrescue -o $(ROOT)/bin/bluejay.iso $(ROOT)
113
114finish