|
|
@ -8,13 +8,16 @@
|
|
|
|
# make clean Clean
|
|
|
|
# make clean Clean
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Options:
|
|
|
|
# Options:
|
|
|
|
# arch = x86_64 | riscv32
|
|
|
|
# arch = x86_64 | riscv32 | aarch64
|
|
|
|
# d = int | in_asm | ... QEMU debug info
|
|
|
|
# d = int | in_asm | ... QEMU debug info
|
|
|
|
# mode = debug | release
|
|
|
|
# mode = debug | release
|
|
|
|
# LOG = off | error | warn | info | debug | trace
|
|
|
|
# LOG = off | error | warn | info | debug | trace
|
|
|
|
# board Only available on riscv32, build without bbl, run on board
|
|
|
|
# board = fpga Only available on riscv32, build without bbl, run on board
|
|
|
|
|
|
|
|
# | raspi3 Only available on aarch64, run on Raspberry Pi 3 Model B/B+
|
|
|
|
|
|
|
|
|
|
|
|
arch ?= riscv32
|
|
|
|
arch ?= aarch64
|
|
|
|
|
|
|
|
board ?= raspi3
|
|
|
|
|
|
|
|
prefix ?= $(arch)-none-elf
|
|
|
|
mode ?= debug
|
|
|
|
mode ?= debug
|
|
|
|
LOG ?= debug
|
|
|
|
LOG ?= debug
|
|
|
|
|
|
|
|
|
|
|
@ -27,21 +30,41 @@ user_bin_path := ../user/target/$(arch)-ucore/debug
|
|
|
|
user_bins := $(patsubst $(user_bin_path)/%.d, $(user_bin_path)/%, $(wildcard $(user_bin_path)/*.d))
|
|
|
|
user_bins := $(patsubst $(user_bin_path)/%.d, $(user_bin_path)/%, $(wildcard $(user_bin_path)/*.d))
|
|
|
|
user_obj := build/$(arch)/user.o
|
|
|
|
user_obj := build/$(arch)/user.o
|
|
|
|
SFSIMG := ../user/ucore32.img
|
|
|
|
SFSIMG := ../user/ucore32.img
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### qemu options ###
|
|
|
|
ifeq ($(arch), x86_64)
|
|
|
|
ifeq ($(arch), x86_64)
|
|
|
|
qemu_opts := \
|
|
|
|
qemu_opts := \
|
|
|
|
-drive format=raw,file=$(bootimage) \
|
|
|
|
-drive format=raw,file=$(bootimage) \
|
|
|
|
-drive format=raw,file=$(SFSIMG),media=disk,cache=writeback \
|
|
|
|
-drive format=raw,file=$(SFSIMG),media=disk,cache=writeback \
|
|
|
|
-smp 4 \
|
|
|
|
-smp 4 \
|
|
|
|
-serial mon:stdio \
|
|
|
|
-serial mon:stdio \
|
|
|
|
-device isa-debug-exit
|
|
|
|
-device isa-debug-exit \
|
|
|
|
|
|
|
|
-nographic
|
|
|
|
|
|
|
|
else ifeq ($(arch), riscv32)
|
|
|
|
|
|
|
|
qemu_opts := \
|
|
|
|
|
|
|
|
-machine virt \
|
|
|
|
|
|
|
|
-nographic \
|
|
|
|
|
|
|
|
-kernel $(bin)
|
|
|
|
|
|
|
|
else ifeq ($(arch), aarch64)
|
|
|
|
|
|
|
|
qemu_opts := \
|
|
|
|
|
|
|
|
-machine $(board) \
|
|
|
|
|
|
|
|
-serial null -serial mon:stdio \
|
|
|
|
|
|
|
|
-nographic \
|
|
|
|
|
|
|
|
-kernel $(bin)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifeq ($(arch), riscv32)
|
|
|
|
|
|
|
|
qemu_opts := -machine virt -kernel $(bin) -nographic
|
|
|
|
ifdef d
|
|
|
|
|
|
|
|
qemu_opts := $(qemu_opts) -d $(d)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
ifdef board
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### build args ###
|
|
|
|
|
|
|
|
ifeq ($(arch), riscv32)
|
|
|
|
|
|
|
|
ifeq ($(board), fpga)
|
|
|
|
features := $(features) no_bbl
|
|
|
|
features := $(features) no_bbl
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
# Link user binaries at ../user
|
|
|
|
# Link user binaries at ../user
|
|
|
|
ifdef link_user
|
|
|
|
ifdef link_user
|
|
|
@ -49,37 +72,25 @@ features := $(features) link_user_program
|
|
|
|
assembly_object_files := $(assembly_object_files) $(user_obj)
|
|
|
|
assembly_object_files := $(assembly_object_files) $(user_obj)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
ifdef d
|
|
|
|
features := $(features) board_$(board)
|
|
|
|
qemu_opts := $(qemu_opts) -d $(d)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build_args := --target $(target).json --features "$(features)"
|
|
|
|
build_args := --target $(target).json --features "$(features)"
|
|
|
|
|
|
|
|
|
|
|
|
ifeq ($(mode), release)
|
|
|
|
ifeq ($(mode), release)
|
|
|
|
build_args := $(build_args) --release
|
|
|
|
build_args := $(build_args) --release
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
|
|
|
|
uname := Win32
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
uname := $(shell uname)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ifeq ($(uname), Darwin)
|
|
|
|
|
|
|
|
prefix := x86_64-elf-
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(arch), riscv32)
|
|
|
|
|
|
|
|
prefix := riscv64-unknown-elf-
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ld := $(prefix)ld
|
|
|
|
### prefix ###
|
|
|
|
objdump := $(prefix)objdump
|
|
|
|
ld := $(prefix)-ld
|
|
|
|
cc := $(prefix)gcc
|
|
|
|
objdump := $(prefix)-objdump
|
|
|
|
as := $(prefix)as
|
|
|
|
objcopy := $(prefix)-objcopy
|
|
|
|
|
|
|
|
cc := $(prefix)-gcc
|
|
|
|
|
|
|
|
as := $(prefix)-as
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: all clean run build asm doc justrun kernel
|
|
|
|
.PHONY: all clean run build asm doc justrun kernel
|
|
|
|
|
|
|
|
|
|
|
|
all: $(kernel)
|
|
|
|
all: kernel
|
|
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
clean:
|
|
|
|
@cargo clean
|
|
|
|
@cargo clean
|
|
|
@ -108,20 +119,24 @@ elf-h:
|
|
|
|
@$(objdump) -h $(kernel)
|
|
|
|
@$(objdump) -h $(kernel)
|
|
|
|
|
|
|
|
|
|
|
|
$(bin): kernel
|
|
|
|
$(bin): kernel
|
|
|
|
ifdef board
|
|
|
|
ifeq ($(arch), riscv32)
|
|
|
|
|
|
|
|
ifeq ($(board), fpga)
|
|
|
|
@cp $(kernel) $@
|
|
|
|
@cp $(kernel) $@
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@cd ../riscv-pk && \
|
|
|
|
@cd ../riscv-pk && \
|
|
|
|
mkdir -p build && \
|
|
|
|
mkdir -p build && \
|
|
|
|
cd build && \
|
|
|
|
cd build && \
|
|
|
|
../configure \
|
|
|
|
../configure \
|
|
|
|
--enable-32bit \
|
|
|
|
--enable-32bit \
|
|
|
|
--enable-logo \
|
|
|
|
--enable-logo \
|
|
|
|
--disable-fp-emulation \
|
|
|
|
--disable-fp-emulation \
|
|
|
|
--host=riscv64-unknown-elf \
|
|
|
|
--host=riscv64-unknown-elf \
|
|
|
|
--with-payload=$(abspath $(kernel)) && \
|
|
|
|
--with-payload=$(abspath $(kernel)) && \
|
|
|
|
make && \
|
|
|
|
make && \
|
|
|
|
cp bbl ../../kernel/$@
|
|
|
|
cp bbl ../../kernel/$@
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
else ifeq ($(arch), aarch64)
|
|
|
|
|
|
|
|
$(objcopy) $(kernel) -O binary $@
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
kernel:
|
|
|
|
kernel:
|
|
|
|