blob: bf51a3f0335740ce0e09daa8e843dd2e1ea329d1 [file] [log] [blame]
swissChilid98781b2021-07-25 21:04:17 -07001# -*- mode:makefile -*-
2
swissChili2b5acc82021-03-13 17:06:42 -08003init(kernel, kernel.elf)
4
5preset(freestanding)
swissChilib7ef65d2021-07-17 12:51:52 -07006# This makes debugging hard :(
7# preset(optimize)
swissChili2b5acc82021-03-13 17:06:42 -08008preset(debug)
9preset(32)
10preset(warn)
11preset(nasm)
12
13archetype(c)
14archetype(asm)
15
swissChili52a03d82021-07-18 15:22:14 -070016depends(sys, $(ROOT)/src/libsys, libsys.a)
swissChili2b5acc82021-03-13 17:06:42 -080017depends(initrd, $(ROOT)/boot/initrd, initrd.img)
swissChili1a3f07f2021-04-05 20:01:55 -070018depends(ata_pio, dri/ata_pio, ata_pio.a)
swissChilie8491742021-04-08 20:38:06 -070019depends(pci, dri/pci, pci.a)
swissChili5fe85a12021-05-31 08:10:27 -070020depends(ide, dri/ide, ide.a)
swissChili4418ca52021-06-14 17:36:00 -070021depends(ext2, dri/fs/ext2, ext2.a)
swissChilie8491742021-04-08 20:38:06 -070022# AHCI not yet implemented
23# depends(ahci, dri/ahci, ahci.a)
swissChili1a3f07f2021-04-05 20:01:55 -070024
swissChili402a3832021-05-29 21:41:31 -070025TEST ?=
26test_defines = $(TEST:%=-DTEST_%)
27
swissChili4418ca52021-06-14 17:36:00 -070028FS ?= ext2
29
swissChilid98781b2021-07-25 21:04:17 -070030CFLAGS += -I$(ROOT)/include/kernel $(test_defines) -O0
swissChili2b5acc82021-03-13 17:06:42 -080031
swissChili64228692021-03-16 08:19:23 -070032LDFLAGS += -Tlink.ld -melf_i386
swissChili7be32742021-04-03 21:17:24 -070033ASMFLAGS += -felf -Fdwarf
swissChili36ed5d72021-07-23 14:56:36 -070034QEMUFLAGS = -drive file=hd0_ext2.img,format=raw
swissChili2b5acc82021-03-13 17:06:42 -080035
36OBJECTS = boot.o \
37 main.o \
38 descriptor_tables.o \
39 io.o \
40 vga.o \
41 gdt_flush.o \
swissChili1e8b7562021-12-22 21:22:57 -080042 tss_flush.o \
swissChili2b5acc82021-03-13 17:06:42 -080043 idt.o \
44 log.o \
45 irq.o \
46 pic.o \
47 timer.o \
48 paging.o \
49 switch_table.o \
50 scan_codes.o \
51 kheap.o \
52 alloc.o \
53 vfs.o \
54 multiboot.o \
swissChili64228692021-03-16 08:19:23 -070055 vfs_initrd.o \
swissChilie20b79b2021-03-17 21:20:13 -070056 syscall.o \
swissChilicfd3c3c2021-04-03 15:04:24 -070057 task.o \
swissChili1a3f07f2021-04-05 20:01:55 -070058 task_api.o \
swissChiliaed6ff32021-05-29 17:51:04 -070059 faults.o \
swissChili52a03d82021-07-18 15:22:14 -070060 sync.o \
swissChili4418ca52021-06-14 17:36:00 -070061 lib(ext2) \
swissChilie5adca52021-06-16 21:00:31 -070062 lib(ide) \
swissChilie8491742021-04-08 20:38:06 -070063 lib(ata_pio) \
swissChili52a03d82021-07-18 15:22:14 -070064 lib(pci) \
65 lib(sys)
swissChili2b5acc82021-03-13 17:06:42 -080066
67type(custom_link)
68
swissChilicfd3c3c2021-04-03 15:04:24 -070069debug-wait: kernel.elf
swissChilib7ef65d2021-07-17 12:51:52 -070070 qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf
swissChilicfd3c3c2021-04-03 15:04:24 -070071
swissChili2b5acc82021-03-13 17:06:42 -080072debug: kernel.elf
swissChili9bd74de2021-06-15 20:30:48 -070073 qemu-system-i386 -s -S $(QEMUFLAGS) -kernel kernel.elf &
swissChili2b5acc82021-03-13 17:06:42 -080074 @echo run "target remote localhost:1234" to connect to qemu
swissChilicfd3c3c2021-04-03 15:04:24 -070075 gdb $<
swissChili2b5acc82021-03-13 17:06:42 -080076 @pkill qemu-system-i38
77
swissChili4418ca52021-06-14 17:36:00 -070078hd0_%.img:
swissChilief829f32021-06-13 20:00:54 -070079 status_log(MKFS, $@)
80 @dd bs=4M count=8 if=/dev/zero of=$@
swissChili4418ca52021-06-14 17:36:00 -070081 @$(patsubst hd0_%.img,mkfs.%,$@) $@
swissChilief829f32021-06-13 20:00:54 -070082
swissChilicaa24782021-07-19 14:29:58 -070083fs-info: hd0_$(FS).img
84 tune2fs -l $< | grep -i inode
85
swissChili36ed5d72021-07-23 14:56:36 -070086reset-fs:
87 @rm hd0_ext2.img
88 @$(MAKE) hd0_ext2.img
89 @sudo $(MAKE) mount
90 @echo 'hi' | sudo tee $(ROOT)/mnt/hello.txt
91 @sudo $(MAKE) umount
92 @$(MAKE) qemu
93
swissChili4418ca52021-06-14 17:36:00 -070094qemu: kernel.elf hd0_$(FS).img
swissChili9bd74de2021-06-15 20:30:48 -070095 qemu-system-i386 $(QEMUFLAGS) -d cpu_reset -monitor stdio -kernel kernel.elf -no-reboot
swissChili2b5acc82021-03-13 17:06:42 -080096
97qemu-iso: install
98 qemu-system-i386 $(QEMUFLAGS) -monitor stdio $(ROOT)/bin/bluejay.iso
99
100scan_codes.c: gen_scan_codes.py scan_codes.tsv
101 python3 $< > $@
102
swissChili4418ca52021-06-14 17:36:00 -0700103mount: hd0_$(FS).img
swissChilief829f32021-06-13 20:00:54 -0700104 status_log(MOUNT, $^ $(ROOT)/mnt)
105 @mkdir -p $(ROOT)/mnt
swissChili9bd74de2021-06-15 20:30:48 -0700106 @mount $^ $(ROOT)/mnt
swissChilief829f32021-06-13 20:00:54 -0700107
108umount:
109 status_log(UMOUNT, $(ROOT)/mnt)
110 @umount $(ROOT)/mnt
111
swissChili2b5acc82021-03-13 17:06:42 -0800112install: kernel.elf lib(initrd)
113 cp kernel.elf $(ROOT)/boot/
114 rm -f $(ROOT)/bin/bluejay.iso
115 grub-mkrescue -o $(ROOT)/bin/bluejay.iso $(ROOT)
116
117finish