2019-10-07 06:20:39 +04:00
|
|
|
#####
|
|
|
|
## BUILD
|
|
|
|
#####
|
2019-10-10 02:21:20 +04:00
|
|
|
CC=riscv64-unknown-linux-gnu-gcc
|
|
|
|
CFLAGS=-Wall -Wextra -pedantic -Wextra -O0 -g
|
2019-10-07 06:20:39 +04:00
|
|
|
CFLAGS+=-static -ffreestanding -nostdlib -fno-rtti -fno-exceptions
|
|
|
|
CFLAGS+=-march=rv64gc -mabi=lp64
|
|
|
|
INCLUDES=
|
|
|
|
LINKER_SCRIPT=-Tsrc/lds/virt.lds
|
|
|
|
TYPE=debug
|
|
|
|
RUST_TARGET=./target/riscv64gc-unknown-none-elf/$(TYPE)
|
|
|
|
LIBS=-L$(RUST_TARGET)
|
|
|
|
SOURCES_ASM=$(wildcard src/asm/*.S)
|
|
|
|
LIB=-lsos -lgcc
|
|
|
|
OUT=os.elf
|
|
|
|
|
|
|
|
#####
|
|
|
|
## QEMU
|
|
|
|
#####
|
|
|
|
QEMU=qemu-system-riscv64
|
|
|
|
MACH=virt
|
|
|
|
CPU=rv64
|
|
|
|
CPUS=4
|
|
|
|
MEM=128M
|
2019-10-10 03:41:47 +04:00
|
|
|
DISK=hdd.dsk
|
|
|
|
# DRIVE= -drive if=none,format=raw,file=$(DISK),id=foo -device virtio-blk-device,scsi=off,drive=foo
|
|
|
|
DRIVE=
|
|
|
|
|
2019-10-07 06:20:39 +04:00
|
|
|
|
|
|
|
all:
|
|
|
|
cargo build
|
|
|
|
$(CC) $(CFLAGS) $(LINKER_SCRIPT) $(INCLUDES) -o $(OUT) $(SOURCES_ASM) $(LIBS) $(LIB)
|
|
|
|
|
|
|
|
run: all
|
2019-10-10 03:41:47 +04:00
|
|
|
$(QEMU) -machine $(MACH) -cpu $(CPU) -smp $(CPUS) -m $(MEM) $(DRIVE) -nographic -serial mon:stdio -bios none -kernel $(OUT)
|
2019-10-07 06:20:39 +04:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
cargo clean
|
|
|
|
rm -f $(OUT)
|