-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (43 loc) · 1.19 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
TARGET := riscv64gc-unknown-none-elf
MODE := release
KERNEL_ELF := target/$(TARGET)/$(MODE)/os
KERNEL_BIN := $(KERNEL_ELF).bin
DISASM_DIR := disasm
OBJCOPY := llvm-objcopy
GDB := gdb
vi = nvim --noplugin
kernel: $(KERNEL_BIN)
$(KERNEL_BIN): $(KERNEL_ELF)
@$(OBJCOPY) --strip-all $(KERNEL_ELF) -O binary -I elf64-little $(KERNEL_BIN)
$(KERNEL_ELF): os/ user
@cd os && cargo build --$(MODE)
user: user/
@cd user && ./build.py
build: kernel user
run: build
@qemu-system-riscv64 \
-machine virt \
-nographic \
-bios ./bootloader/rustsbi-qemu.bin \
-device loader,file=$(KERNEL_BIN),addr=0x80200000
disasm: build
@mkdir -p $(DISASM_DIR)
@rust-objdump -S $(KERNEL_ELF) 1> $(DISASM_DIR)/os.asm 2> /dev/null
gdbserver: build
@qemu-system-riscv64 \
-machine virt \
-nographic \
-bios ./bootloader/rustsbi-qemu.bin \
-device loader,file=$(KERNEL_BIN),addr=0x80200000 \
-s -S
gdbclient: build env
@$(GDB) \
-ex 'file target/riscv64gc-unknown-none-elf/release/os' \
-ex 'set arch riscv:rv64' \
-ex 'target remote localhost:1234'
clean:
@cargo clean
@rm -f os/src/link_app.S
clippy:
@cargo clippy
.PHONY: user kernel