-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathMakefile
87 lines (71 loc) · 2.12 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
arch ?= riscv64
target := $(arch)imac-unknown-none-elf
mode := release
kernel := target/$(target)/$(mode)/riscv
img := target/$(target)/$(mode)/img
tcp ?= on
sysroot := $(shell rustc --print sysroot)
objdump := $(shell find $(sysroot) -name llvm-objdump) --arch-name=$(arch)
objcopy := $(shell find $(sysroot) -name llvm-objcopy)
BUILD_ARGS += --target $(target)
ifeq ($(mode), release)
BUILD_ARGS += --release
endif
ifeq ($(tcp), on)
BUILD_ARGS += --features tcp
else
BUILD_ARGS += --no-default-features
endif
.PHONY: kernel build clean qemu run env
build: $(bin)
env:
rustup component add llvm-tools-preview rustfmt
rustup target add $(target)
kernel:
cargo build $(BUILD_ARGS)
asm:
$(objdump) -d $(kernel) | less
sym:
$(objdump) -t $(kernel) | less
header:
$(objdump) -x $(kernel) | less
clean:
cargo clean
qemu-legacy: kernel $(img)
# Wait a few seconds, then try to open a connection to the VM so it can test its networking.
( sleep 4 && echo "hello" | nc localhost 5555 -N -v) &
qemu-system-$(arch) \
$(QEMU_ARGS) \
-machine virt \
-serial mon:stdio \
-bios default \
-kernel $(kernel) \
-drive file=$(img),if=none,format=raw,id=x0 \
-device virtio-blk-device,drive=x0 \
-device virtio-gpu-device \
-device virtio-mouse-device \
-device virtio-net-device,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::5555-:5555\
-device virtio-sound-device,audiodev=audio0 \
-audiodev alsa,id=audio0
qemu: kernel $(img)
# Wait a few seconds, then try to open a connection to the VM so it can test its networking.
( sleep 4 && echo "hello" | nc localhost 5555 -N -v) &
qemu-system-$(arch) \
$(QEMU_ARGS) \
-machine virt \
-serial mon:stdio \
-bios default \
-kernel $(kernel) \
-global virtio-mmio.force-legacy=false \
-drive file=$(img),if=none,format=raw,id=x0 \
-device virtio-blk-device,drive=x0 \
-device virtio-gpu-device \
-device virtio-mouse-device \
-device virtio-net-device,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::5555-:5555\
-device virtio-sound-device,audiodev=audio0 \
-audiodev alsa,id=audio0
$(img):
dd if=/dev/zero of=$@ bs=512 count=32
run: build qemu-legacy qemu