-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (56 loc) · 1.63 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
SHELL := /bin/bash
FS_IMG:= mount.img
ifeq ($(NVME), on)
QEMU_EXEC += -drive file=$(FS_IMG),if=none,id=nvm \
-device nvme,serial=deadbeef,drive=nvm
else
QEMU_EXEC += -drive file=$(FS_IMG),if=none,format=raw,id=x0
QEMU_EXEC += -device virtio-blk-$(BUS),drive=x0
endif
ifeq ($(NET), on)
QEMU_EXEC += -netdev user,id=net0,hostfwd=tcp::6379-:6379 \
-object filter-dump,id=net0,netdev=net0,file=packets.pcap \
-device virtio-net-$(BUS),netdev=net0
endif
all: build
TESTCASE := testcase-$(ARCH)
fs-img:
@echo "TESTCASE: $(TESTCASE)"
@echo "ROOT_FS: $(ROOT_FS)"
rm -f $(FS_IMG)
dd if=/dev/zero of=$(FS_IMG) bs=1M count=128
sync
ifeq ($(ROOT_FS), fat32)
mkfs.vfat -F 32 $(FS_IMG)
mkdir mount/ -p
sudo mount $(FS_IMG) mount/ -o uid=1000,gid=1000
sudo rm -rf mount/*
else
mkfs.ext4 -F -O ^metadata_csum_seed $(FS_IMG)
mkdir mount/ -p
sudo mount $(FS_IMG) mount/
endif
# sudo cp -rf resources/$(TESTCASE)/* mount/
sync
sudo umount $(FS_IMG)
build:
./quados build
justbuild: fs-img build
run: fs-img build
time $(QEMU_EXEC)
fdt:
@qemu-system-riscv64 -M 128m -machine virt,dumpdtb=virt.out
fdtdump virt.out
debug: fs-img build
@tmux new-session -d \
"./quados qemu -l debug -d && echo 'Press any key to continue' && read -n 1" && \
tmux split-window -h "gdb target/riscv64gc-unknown-none-elf/release/quados -ex 'target remote localhost:1234' -ex 'disp /16i $$pc' " && \
tmux -2 attach-session -d
clean:
rm -rf target/
iso: build
cp $(KERNEL_ELF) resources/iso/example
grub-mkrescue -o bootable.iso resources/iso
boot-iso: iso
qemu-system-x86_64 -cdrom bootable.iso -serial stdio
.PHONY: all run build clean gdb justbuild iso boot-iso