2021-05-02 19:23:50 +00:00
|
|
|
|
|
|
|
EMULATOR = qemu-system-i386
|
|
|
|
AS = ${HOME}/opt/cross/bin/i686-elf-as
|
|
|
|
CC = ${HOME}/opt/cross/bin/i686-elf-gcc
|
2021-05-10 20:33:25 +00:00
|
|
|
CPP = ${HOME}/opt/cross/bin/i686-elf-g++
|
2022-08-17 23:26:49 +00:00
|
|
|
CFLAGS = -ffreestanding -Og -ggdb -Wall -Wextra
|
2021-05-02 19:23:50 +00:00
|
|
|
|
2023-02-17 15:27:36 +00:00
|
|
|
OFILES =$(BUILD_DIR)/boot.o $(BUILD_DIR)/kterm.o $(BUILD_DIR)/kernel.o $(BUILD_DIR)/memory.o $(BUILD_DIR)/paging.o $(BUILD_DIR)/pit.o $(BUILD_DIR)/time.o $(BUILD_DIR)/keyboard.o $(BUILD_DIR)/io.o $(BUILD_DIR)/processor.o $(BUILD_DIR)/gdtc.o $(BUILD_DIR)/idt.o $(BUILD_DIR)/pic.o $(BUILD_DIR)/sv-terminal.o $(BUILD_DIR)/string.o $(BUILD_DIR)/prekernel.o $(BUILD_DIR)/cpu.o $(BUILD_DIR)/KHeap.o $(BUILD_DIR)/pci.o $(BUILD_DIR)/pcidevice.o $(BUILD_DIR)/atapiDevice.o $(BUILD_DIR)/ataDevice.o $(BUILD_DIR)/rsdp.o $(BUILD_DIR)/acpi.o
|
2021-05-02 19:23:50 +00:00
|
|
|
|
2022-08-21 19:18:53 +00:00
|
|
|
SRC_DIR = source
|
2021-05-02 19:23:50 +00:00
|
|
|
BUILD_DIR = build
|
|
|
|
|
|
|
|
CRTBEGIN_OBJ = $(shell $(CC) $(CFLAGS) -print-file-name=crtbegin.o)
|
|
|
|
CRTEND_OBJ = $(shell $(CC) $(CFLAGS) -print-file-name=crtend.o)
|
|
|
|
|
|
|
|
CRTI_OBJ = $(BUILD_DIR)/crti.o
|
|
|
|
CRTN_OBJ = $(BUILD_DIR)/crtn.o
|
|
|
|
OBJ_LINK_LIST = $(CRTI_OBJ) $(CRTBEGIN_OBJ) $(OFILES) $(CRTEND_OBJ) $(CRTN_OBJ)
|
|
|
|
INTERNAL_OBJS = $(CRTI_OBJ) $(OFILES) $(CRTN_OBJ)
|
|
|
|
|
|
|
|
|
2021-11-22 19:01:12 +00:00
|
|
|
all: clean build
|
2021-05-02 19:23:50 +00:00
|
|
|
|
2021-11-22 19:01:12 +00:00
|
|
|
build: build_kernel iso
|
2021-05-02 19:23:50 +00:00
|
|
|
|
2021-10-23 11:26:15 +00:00
|
|
|
clean_iso:
|
2021-11-22 19:01:12 +00:00
|
|
|
if [[ -a isodir/boot ]] ; then rm root/boot -rd ; fi
|
|
|
|
if [ -f build/barinkOS.iso ] ; then rm build/barinkOS.iso ; fi
|
2021-10-23 11:26:15 +00:00
|
|
|
|
2021-11-22 19:01:12 +00:00
|
|
|
iso: clean_iso clean build
|
|
|
|
mkdir -p root/boot/grub
|
|
|
|
cp build/myos.bin root/boot/myos.bin
|
2022-08-22 19:16:34 +00:00
|
|
|
cp source/grub.cfg root/boot/grub/grub.cfg
|
2021-11-22 19:01:12 +00:00
|
|
|
grub-mkrescue -o build/barinkOS.iso root
|
2021-12-29 15:15:18 +00:00
|
|
|
run: all
|
2021-12-27 18:35:24 +00:00
|
|
|
virtualboxvm --startvm "BarinkOS_test"
|
2022-08-17 23:26:49 +00:00
|
|
|
debug: all
|
2022-08-18 22:44:52 +00:00
|
|
|
objcopy --only-keep-debug build/myos.bin kernel.sym
|
2023-02-08 13:07:44 +00:00
|
|
|
$(EMULATOR) -cdrom build/barinkOS.iso -serial stdio -vga std -display gtk -m 2G -cpu core2duo -s -d int -no-shutdown -no-reboot
|
2021-10-23 11:26:15 +00:00
|
|
|
test:
|
2023-02-08 13:07:44 +00:00
|
|
|
$(EMULATOR) -kernel $(BUILD_DIR)/myos.bin -serial stdio -vga std -display gtk -m 2G -cpu core2duo -d int -no-shutdown -no-reboot
|
2021-11-28 22:06:21 +00:00
|
|
|
|
|
|
|
test_iso:
|
2023-02-08 13:07:44 +00:00
|
|
|
$(EMULATOR) -boot d -cdrom $(BUILD_DIR)/barinkOS.iso -serial stdio -vga std -display gtk -m 2G -cpu core2duo -d int -no-reboot -no-shutdown
|
2023-02-02 13:59:42 +00:00
|
|
|
test_disk:
|
2023-02-03 20:47:05 +00:00
|
|
|
$(EMULATOR) -boot d -drive format=raw,file=build/disk.img -serial stdio -vga std -display gtk -m 2G -cpu core2duo
|
2023-02-02 13:59:42 +00:00
|
|
|
|
2021-05-10 20:33:25 +00:00
|
|
|
|
2021-05-02 19:23:50 +00:00
|
|
|
build_kernel: $(OBJ_LINK_LIST)
|
2021-11-16 12:57:15 +00:00
|
|
|
$(CC) -T $(SRC_DIR)/kernel//linker.ld -o $(BUILD_DIR)/myos.bin \
|
2022-08-17 23:26:49 +00:00
|
|
|
-ffreestanding -ggdb -Og -nostdlib $(OBJ_LINK_LIST) -lgcc
|
2021-05-02 19:23:50 +00:00
|
|
|
|
|
|
|
build_x86_64:
|
|
|
|
$(AS) $(SRC_DIR)/cgc/x86_64/crti.s -o $(BUILD_DIR)/crti_64.o
|
|
|
|
$(AS) $(SRC_DIR)/cgc/x86_64/crtn.s -o $(BUILD_DIR)/crtn.o
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(BUILD_DIR)/myos.bin $(INTERNAL_OBJS)
|
|
|
|
|
2022-09-02 19:09:51 +00:00
|
|
|
# C++ definition -> Object files
|
2021-05-02 19:23:50 +00:00
|
|
|
$(BUILD_DIR)/kernel.o:
|
2021-05-10 20:33:25 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/kernel.cpp -o $(BUILD_DIR)/kernel.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-05-02 19:23:50 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/kterm.o:
|
2022-09-01 18:16:16 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/terminal/kterm.cpp -o $(BUILD_DIR)/kterm.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-05-02 19:23:50 +00:00
|
|
|
|
2021-05-10 20:33:25 +00:00
|
|
|
$(BUILD_DIR)/io.o:
|
2023-02-03 20:47:05 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/drivers/io/io.cpp -o $(BUILD_DIR)/io.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-05-16 14:53:14 +00:00
|
|
|
|
2021-05-12 22:03:00 +00:00
|
|
|
$(BUILD_DIR)/idt.o:
|
2023-02-11 11:22:45 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/interrupts/idt.cpp -o $(BUILD_DIR)/idt.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-05-16 14:53:14 +00:00
|
|
|
|
2021-11-06 20:56:42 +00:00
|
|
|
$(BUILD_DIR)/gdtc.o:
|
2022-09-01 18:16:16 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/memory/gdt/gdtc.cpp -o $(BUILD_DIR)/gdtc.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-11-06 20:56:42 +00:00
|
|
|
|
2021-05-16 14:53:14 +00:00
|
|
|
$(BUILD_DIR)/pic.o:
|
2022-09-01 18:16:16 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/drivers/pic/pic.cpp -o $(BUILD_DIR)/pic.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-11-02 20:03:11 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/string.o:
|
2023-02-03 19:01:31 +00:00
|
|
|
$(CC) -c $(SRC_DIR)/lib/include/string.c -o $(BUILD_DIR)/string.o $(CFLAGS) -std=gnu99
|
2021-11-03 19:03:38 +00:00
|
|
|
|
2021-11-06 15:27:13 +00:00
|
|
|
$(BUILD_DIR)/PhysicalMemoryManager.o:
|
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/memory/PhysicalMemoryManager.cpp -o $(BUILD_DIR)/PhysicalMemoryManager.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-11-25 21:05:16 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/pci.o:
|
2023-02-03 20:47:05 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/drivers/pci/pci.cpp -o $(BUILD_DIR)/pci.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-11-28 15:46:16 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/pcidevice.o:
|
2023-02-03 19:01:31 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/drivers/pci/pciDevice.cpp -o $(BUILD_DIR)/pcidevice.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-11-30 23:00:45 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/atapiDevice.o:
|
2023-02-03 20:47:05 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/drivers/atapi/atapiDevice.cpp -o $(BUILD_DIR)/atapiDevice.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-12-24 19:08:18 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/ataDevice.o:
|
2023-02-03 20:47:05 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/drivers/ata/ataDevice.cpp -o $(BUILD_DIR)/ataDevice.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-12-24 19:08:18 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/rsdp.o:
|
2023-02-03 20:47:05 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/drivers/acpi/rsdp.cpp -o $(BUILD_DIR)/rsdp.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-12-20 20:53:57 +00:00
|
|
|
|
2023-02-08 13:07:44 +00:00
|
|
|
$(BUILD_DIR)/acpi.o:
|
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/drivers/acpi/acpi.cpp -o $(BUILD_DIR)/acpi.o $(CFLAGS) -fno-exceptions -fno-rtti
|
|
|
|
|
2021-12-20 20:53:57 +00:00
|
|
|
$(BUILD_DIR)/pit.o:
|
2022-09-01 18:16:16 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/drivers/pit/pit.cpp -o $(BUILD_DIR)/pit.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-12-28 18:47:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
$(BUILD_DIR)/keyboard.o:
|
2022-09-01 18:16:16 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/drivers/ps-2/keyboard.cpp -o $(BUILD_DIR)/keyboard.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2021-12-29 15:15:18 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/time.o:
|
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/time.cpp -o $(BUILD_DIR)/time.o $(CFLAGS) -fno-exceptions -fno-rtti
|
|
|
|
|
|
|
|
$(BUILD_DIR)/sv-terminal.o:
|
2022-09-01 18:16:16 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/supervisorterminal/superVisorTerminal.cpp -o $(BUILD_DIR)/sv-terminal.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2022-02-26 19:44:16 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/memory.o:
|
2022-09-01 18:16:16 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/memory/PhysicalMemoryManager.cpp -o $(BUILD_DIR)/memory.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2022-03-18 21:09:04 +00:00
|
|
|
|
|
|
|
$(BUILD_DIR)/paging.o:
|
2022-09-01 18:16:16 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/memory/VirtualMemoryManager.cpp -o $(BUILD_DIR)/paging.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2022-08-21 19:15:15 +00:00
|
|
|
|
2022-09-02 19:09:51 +00:00
|
|
|
$(BUILD_DIR)/KHeap.o:
|
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/memory/KernelHeap.cpp -o $(BUILD_DIR)/KHeap.o $(CFLAGS) -fno-exceptions -fno-rtti
|
|
|
|
|
2022-08-22 19:16:34 +00:00
|
|
|
$(BUILD_DIR)/prekernel.o:
|
2022-09-01 18:16:16 +00:00
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/prekernel/prekernel.cpp -o $(BUILD_DIR)/prekernel.o $(CFLAGS) -fno-exceptions -fno-rtti
|
|
|
|
|
|
|
|
$(BUILD_DIR)/cpu.o:
|
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/cpu.cpp -o $(BUILD_DIR)/cpu.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2022-09-02 19:09:51 +00:00
|
|
|
|
2023-02-17 15:27:36 +00:00
|
|
|
$(BUILD_DIR)/processor.o:
|
|
|
|
$(CPP) -c $(SRC_DIR)/kernel/i386/processor.cpp -o $(BUILD_DIR)/processor.o $(CFLAGS) -fno-exceptions -fno-rtti
|
2022-09-02 19:09:51 +00:00
|
|
|
|
2023-02-08 13:07:44 +00:00
|
|
|
|
2022-09-02 19:09:51 +00:00
|
|
|
# Assembly -> Object files
|
|
|
|
$(BUILD_DIR)/boot.o:
|
|
|
|
$(AS) $(SRC_DIR)/kernel/boot/boot.s -o $(BUILD_DIR)/boot.o
|
|
|
|
|
|
|
|
$(BUILD_DIR)/crti.o:
|
|
|
|
$(AS) $(SRC_DIR)/kernel/crti.s -o $(BUILD_DIR)/crti.o
|
|
|
|
|
|
|
|
$(BUILD_DIR)/crtn.o:
|
|
|
|
$(AS) $(SRC_DIR)/kernel/crtn.s -o $(BUILD_DIR)/crtn.o
|