This commit is contained in:
2025-03-16 05:52:09 +08:00
parent 41d4a30610
commit be5045fde1
28 changed files with 738 additions and 76 deletions

View File

@@ -2,6 +2,7 @@ MAKE := make
ARCH := aarch64
GNU := $(ARCH)-linux-gnu
GDB := $(GNU)-gdb
QEMU := qemu-system-$(ARCH)
QEMUFLAGS += -M raspi3b -display none -serial null -serial pty
@@ -9,9 +10,9 @@ QEMUFLAGS += -M raspi3b -display none -serial null -serial pty
CC := $(GNU)-gcc
CCFLAGS += -Wall -Wextra -O0 \
-nostdinc -nostdlib -nostartfiles -nodefaultlibs \
-Wno-unused-parameter -Wno-main -g
-Wno-unused-parameter -Wno-unused-value -Wno-main -g
LD := $(GNU)-ld
LDFLAGS += -g -nostdlib
LDFLAGS += -g -nostdlib -no-pie
OBJCOPY := $(GNU)-objcopy
#TARGET := kernel8
@@ -23,7 +24,7 @@ LD_SCRIPT := $(TARGET_DIR)/linker.ld
INCLUDE += -Iinclude
LIB_DIR := ./lib
MISC_DIR := ./misc
#QEMUFLAGS += -dtb $(MISC_DIR)/bcm2710-rpi-3-b-plus.dtb
QEMUFLAGS += -dtb $(MISC_DIR)/bcm2710-rpi-3-b-plus.dtb
BOOTLOADER_DIR := ./bootloader
ROOTFS_DIR := ./rootfs
@@ -35,7 +36,7 @@ SRCS := $(shell find $(TARGET_DIR) -name '*.[cS]') \
$(shell find $(LIB_DIR) -name '*.c')
OBJS := $(SRCS:%=%.o)
.PHONY: all build clean clean_target run
.PHONY: all build clean clean_target run kernel debug gdb
all:
$(MAKE) build TARGET_DIR=./kernel TARGET=kernel8
@@ -69,4 +70,14 @@ clean_target:
run: all $(CPIO)
$(QEMU) -kernel bootloader.img $(QEMUFLAGS)
#$(QEMU) -kernel kernel8.img $(QEMUFLAGS)
kernel: all $(CPIO)
-killall screen
$(QEMU) -kernel kernel8.img $(QEMUFLAGS)
debug: all $(CPIO)
-killall screen
$(QEMU) -kernel kernel8.img $(QEMUFLAGS) -S -s
gdb:
$(GDB)