Major refactor of codebase
This commit is contained in:
parent
dbc6dc0d7c
commit
f478f8d38b
125 changed files with 195 additions and 29519 deletions
103
Makefile
103
Makefile
|
|
@ -2,6 +2,14 @@ BUILD_DIR=build
|
|||
CC = gcc
|
||||
AS = nasm
|
||||
LD = ld
|
||||
|
||||
SRC_DIR := src build/uACPI/source build
|
||||
C_SOURCES := $(shell find $(SRC_DIR) -type f -name '*.c')
|
||||
C_OBJECTS := $(patsubst %.c,$(BUILD_DIR)/%.o,$(C_SOURCES))
|
||||
|
||||
ASM_SOURCES := $(shell find $(SRC_DIR) -type f -name '*.asm')
|
||||
ASM_OBJECTS := $(patsubst %.asm,$(BUILD_DIR)/%.o,$(ASM_SOURCES))
|
||||
|
||||
CFLAGS += -Wall \
|
||||
-Wextra \
|
||||
-std=gnu11 \
|
||||
|
|
@ -17,11 +25,11 @@ CFLAGS += -Wall \
|
|||
-mno-sse \
|
||||
-mno-sse2 \
|
||||
-mno-red-zone \
|
||||
-I src/include \
|
||||
-O0 \
|
||||
-ggdb3 \
|
||||
-g
|
||||
CDEBUG = -g
|
||||
-I ./include \
|
||||
-O0 \
|
||||
-ggdb3 \
|
||||
-g
|
||||
|
||||
LDFLAGS += -m elf_x86_64 \
|
||||
-nostdlib \
|
||||
-static \
|
||||
|
|
@ -30,76 +38,55 @@ LDFLAGS += -m elf_x86_64 \
|
|||
-z text \
|
||||
-z max-page-size=0x1000 \
|
||||
-T linker.ld
|
||||
|
||||
NASMFLAGS = -f elf64 -g -F dwarf
|
||||
|
||||
all: amd64
|
||||
|
||||
dependencies:
|
||||
# build limine
|
||||
rm -rf limine
|
||||
git clone https://github.com/limine-bootloader/limine.git --branch=v8.x-binary --depth=1
|
||||
make -C limine
|
||||
# clone flanterm
|
||||
rm -rf src/flanterm
|
||||
|
||||
git clone https://codeberg.org/mintsuki/flanterm src/flanterm
|
||||
all:
|
||||
# make build directory
|
||||
mkdir -p $(BUILD_DIR) || true
|
||||
# build & link boot and kernel files
|
||||
$(CC) -c src/main.c -o $(BUILD_DIR)/main.o $(CFLAGS)
|
||||
$(CC) -c src/flanterm/src/flanterm.c -o $(BUILD_DIR)/flanterm.o $(CFLAGS)
|
||||
$(CC) -c src/flanterm/src/flanterm_backends/fb.c -o $(BUILD_DIR)/fb.o $(CFLAGS)
|
||||
$(CC) -c src/lib/string.c -o $(BUILD_DIR)/string.o $(CFLAGS)
|
||||
$(CC) -c src/lib/kprint.c -o $(BUILD_DIR)/kprint.o $(CFLAGS)
|
||||
$(CC) -c src/lib/io.c -o $(BUILD_DIR)/io.o $(CFLAGS)
|
||||
$(CC) -c src/lib/spinlock.c -o $(BUILD_DIR)/spinlock.o $(CFLAGS)
|
||||
rm -rf build/limine
|
||||
git clone https://github.com/limine-bootloader/limine.git --branch=v8.x-binary --depth=1 build/limine
|
||||
make -C build/limine
|
||||
rm -rf build/flanterm
|
||||
git clone https://codeberg.org/mintsuki/flanterm build/flanterm
|
||||
rm -rf build/uACPI
|
||||
rm -rf include/uACPI
|
||||
git clone https://github.com/uACPI/uACPI.git build/uACPI
|
||||
|
||||
$(CC) -c src/hal/gdt.c -o $(BUILD_DIR)/gdt.o $(CFLAGS)
|
||||
$(AS) src/hal/gdt.asm -o $(BUILD_DIR)/gdt_asm.o $(NASMFLAGS)
|
||||
$(CC) -c src/hal/idt.c -o $(BUILD_DIR)/idt.o $(CFLAGS)
|
||||
$(AS) src/hal/idt.asm -o $(BUILD_DIR)/idt_asm.o $(NASMFLAGS)
|
||||
$(CC) -c src/hal/apic.c -o $(BUILD_DIR)/apic.o $(CFLAGS)
|
||||
$(CC) -c src/hal/ioapic.c -o $(BUILD_DIR)/ioapic.o $(CFLAGS)
|
||||
$(CC) -c src/hal/timer.c -o $(BUILD_DIR)/timer.o $(CFLAGS)
|
||||
$(CC) -c src/hal/smp.c -o $(BUILD_DIR)/smp.o $(CFLAGS)
|
||||
$(CC) -c src/hal/tsc.c -o $(BUILD_DIR)/tsc.o $(CFLAGS)
|
||||
$(CC) -c src/sys/rand.c -o $(BUILD_DIR)/rand.o $(CFLAGS)
|
||||
$(CC) -c src/mm/pmm.c -o $(BUILD_DIR)/pmm.o $(CFLAGS)
|
||||
$(CC) -c src/mm/vmm.c -o $(BUILD_DIR)/vmm.o $(CFLAGS)
|
||||
$(CC) -c src/mm/page.c -o $(BUILD_DIR)/page.o $(CFLAGS)
|
||||
$(CC) -c src/mm/slab.c -o $(BUILD_DIR)/slab.o $(CFLAGS)
|
||||
$(CC) -c src/mm/kmalloc.c -o $(BUILD_DIR)/kmalloc.o $(CFLAGS)
|
||||
$(CC) -c src/sys/acpi.c -o $(BUILD_DIR)/acpi.o $(CFLAGS)
|
||||
$(CC) -c src/sys/pci.c -o $(BUILD_DIR)/pci.o $(CFLAGS)
|
||||
mkdir include/uACPI
|
||||
|
||||
$(CC) -c src/drivers/serial.c -o $(BUILD_DIR)/serial.o $(CFLAGS)
|
||||
$(CC) -c src/drivers/pmt.c -o $(BUILD_DIR)/pmt.o $(CFLAGS)
|
||||
$(CC) -c src/drivers/ahci.c -o $(BUILD_DIR)/ahci.o $(CFLAGS)
|
||||
cp -r build/uACPI/include/ include/
|
||||
|
||||
$(CC) -c src/scheduler/sched.c -o $(BUILD_DIR)/sched.o $(CFLAGS)
|
||||
$(AS) src/scheduler/sched.asm -o $(BUILD_DIR)/sched_asm.o $(NASMFLAGS)
|
||||
$(BUILD_DIR)/%.o: %.c
|
||||
mkdir -p $(dir $@)
|
||||
$(CC) -c $< -o $@ $(CFLAGS)
|
||||
|
||||
$(BUILD_DIR)/%.o: %.asm
|
||||
mkdir -p $(dir $@)
|
||||
$(AS) $< -o $@ $(NASMFLAGS)
|
||||
|
||||
|
||||
# link everything to an elf
|
||||
$(LD) -o $(BUILD_DIR)/Neobbo.elf $(BUILD_DIR)/*.o $(LDFLAGS)
|
||||
# Create a directory which will be our ISO root.
|
||||
amd64: $(C_OBJECTS) $(ASM_OBJECTS)
|
||||
$(LD) -o $(BUILD_DIR)/Neobbo.elf $(C_OBJECTS) $(ASM_OBJECTS) $(LDFLAGS)
|
||||
mkdir -p iso_root
|
||||
# Copy the relevant files over.
|
||||
cp -v $(BUILD_DIR)/Neobbo.elf limine.conf limine/limine-bios.sys \
|
||||
limine/limine-bios-cd.bin limine/limine-uefi-cd.bin iso_root/
|
||||
# Create the EFI boot tree and copy Limine's EFI executables over.
|
||||
cp -v $(BUILD_DIR)/Neobbo.elf limine.conf build/limine/limine-bios.sys \
|
||||
build/limine/limine-bios-cd.bin build/limine/limine-uefi-cd.bin iso_root/
|
||||
mkdir -p iso_root/EFI/BOOT
|
||||
cp -v limine/BOOTX64.EFI iso_root/EFI/BOOT/
|
||||
cp -v limine/BOOTIA32.EFI iso_root/EFI/BOOT/
|
||||
# Create the bootable ISO.
|
||||
cp -v build/limine/BOOTX64.EFI iso_root/EFI/BOOT/
|
||||
cp -v build/limine/BOOTIA32.EFI iso_root/EFI/BOOT/
|
||||
xorriso -as mkisofs -b limine-bios-cd.bin \
|
||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
||||
--efi-boot limine-uefi-cd.bin \
|
||||
-efi-boot-part --efi-boot-image --protective-msdos-label \
|
||||
iso_root -o $(BUILD_DIR)/Neobbo.iso
|
||||
# Install Limine stage 1 and 2 for legacy BIOS boot.
|
||||
./limine/limine bios-install $(BUILD_DIR)/Neobbo.iso
|
||||
./build/limine/limine bios-install $(BUILD_DIR)/Neobbo.iso
|
||||
|
||||
disk:
|
||||
dd if=/dev/zero of=disk.img bs=1M count=128
|
||||
|
||||
elftest:
|
||||
$(CC) src/elf/elftest.c -o $(BUILD_DIR)/elftest -ffreestanding -Isrc/include -static -fPIE -nostdlib
|
||||
|
||||
clean:
|
||||
rm -r build/
|
||||
rm -rf build/ iso_root
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue