mirror of
https://github.com/rcore-os/rCore.git
synced 2025-01-18 08:57:05 +04:00
Makefile and Cargo.toml changes
This commit is contained in:
parent
c753f9a1e9
commit
42e2063728
68
kernel/Cargo.lock
generated
68
kernel/Cargo.lock
generated
@ -50,7 +50,7 @@ source = "git+https://github.com/rcore-os/apic-rs?rev=fb86bd7#fb86bd7c798608a18c
|
||||
dependencies = [
|
||||
"bit_field 0.10.1",
|
||||
"bitflags",
|
||||
"x86",
|
||||
"x86 0.33.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -114,7 +114,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
[[package]]
|
||||
name = "bitmap-allocator"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/bitmap-allocator#03bd9909d0dc85e99f5559b97a163ab81073df83"
|
||||
source = "git+https://github.com/rcore-os/bitmap-allocator?rev=03bd990#03bd9909d0dc85e99f5559b97a163ab81073df83"
|
||||
dependencies = [
|
||||
"bit_field 0.9.0",
|
||||
]
|
||||
@ -456,6 +456,15 @@ dependencies = [
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raw-cpuid"
|
||||
version = "9.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c27cb5785b85bd05d4eb171556c9a1a514552e26123aeae6bb7d811353148026"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rboot"
|
||||
version = "0.1.3"
|
||||
@ -463,7 +472,7 @@ dependencies = [
|
||||
"log",
|
||||
"rlibc",
|
||||
"uefi",
|
||||
"x86_64",
|
||||
"x86_64 0.11.7",
|
||||
"xmas-elf",
|
||||
]
|
||||
|
||||
@ -495,7 +504,7 @@ dependencies = [
|
||||
"paste",
|
||||
"pc-keyboard",
|
||||
"pci",
|
||||
"raw-cpuid",
|
||||
"raw-cpuid 8.0.0",
|
||||
"rboot",
|
||||
"rcore-console",
|
||||
"rcore-fs",
|
||||
@ -514,7 +523,7 @@ dependencies = [
|
||||
"virtio-drivers",
|
||||
"volatile",
|
||||
"woke",
|
||||
"x86_64",
|
||||
"x86_64 0.11.7",
|
||||
"xmas-elf",
|
||||
]
|
||||
|
||||
@ -530,6 +539,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rcore-fs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=517af47#517af47ff3f632f05b91b9ea73a047aa8df363f3"
|
||||
dependencies = [
|
||||
"filetime",
|
||||
"spin",
|
||||
@ -539,6 +549,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rcore-fs-devfs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=517af47#517af47ff3f632f05b91b9ea73a047aa8df363f3"
|
||||
dependencies = [
|
||||
"log",
|
||||
"rcore-fs",
|
||||
@ -548,6 +559,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rcore-fs-mountfs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=517af47#517af47ff3f632f05b91b9ea73a047aa8df363f3"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
@ -558,6 +570,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rcore-fs-ramfs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=517af47#517af47ff3f632f05b91b9ea73a047aa8df363f3"
|
||||
dependencies = [
|
||||
"log",
|
||||
"rcore-fs",
|
||||
@ -567,6 +580,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rcore-fs-sfs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs?rev=517af47#517af47ff3f632f05b91b9ea73a047aa8df363f3"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"log",
|
||||
@ -619,6 +633,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "riscv"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/rcore-riscv-hypervisor-dev/riscv.git?rev=3f5efb1#3f5efb1b8d4ceb12e291ef3d7b27120ea038eb83"
|
||||
dependencies = [
|
||||
"bare-metal",
|
||||
"bit_field 0.10.1",
|
||||
@ -665,26 +680,28 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rvm"
|
||||
version = "1.0.1"
|
||||
version = "1.2.0"
|
||||
source = "git+https://github.com/rcore-riscv-hypervisor-dev/RVM?rev=fa31039#fa310395b771590df3c6fc354798037c0ae0e9df"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"bit_field 0.10.1",
|
||||
"bitflags",
|
||||
"bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)",
|
||||
"bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator?rev=03bd990)",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"numeric-enum-macro",
|
||||
"raw-cpuid",
|
||||
"raw-cpuid 9.0.0",
|
||||
"riscv",
|
||||
"rvm_macros",
|
||||
"spin",
|
||||
"x86",
|
||||
"x86_64",
|
||||
"x86 0.36.0",
|
||||
"x86_64 0.13.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rvm_macros"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-riscv-hypervisor-dev/RVM?rev=fa31039#fa310395b771590df3c6fc354798037c0ae0e9df"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
@ -759,8 +776,8 @@ name = "trapframe"
|
||||
version = "0.4.3"
|
||||
source = "git+https://github.com/rcore-os/trapframe-rs?rev=bdfe5aa#bdfe5aaebcdd64636c8831c2b8c17e4fede40c0b"
|
||||
dependencies = [
|
||||
"raw-cpuid",
|
||||
"x86_64",
|
||||
"raw-cpuid 8.0.0",
|
||||
"x86_64 0.11.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -776,7 +793,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e58fc40dc1712664fc9b0a7bd8ca2f21ab49960924fb245a80a05e1e92f3dfe9"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"x86_64",
|
||||
"x86_64 0.11.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -838,7 +855,7 @@ checksum = "88dfeb711b61ce620c0cb6fd9f8e3e678622f0c971da2a63c4b3e25e88ed012f"
|
||||
[[package]]
|
||||
name = "virtio-drivers"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/virtio-drivers?rev=dfa70e14#dfa70e1425c9eac1b30e671be61b557a3ce56e7e"
|
||||
source = "git+https://github.com/rcore-riscv-hypervisor-dev/virtio-drivers?rev=1201a0b#1201a0b40c016301c8135e564439e40a769facc8"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"log",
|
||||
@ -896,7 +913,18 @@ checksum = "2786ac694ed572ab5d2bbcd9e188805dba26b3501973dd69718914fb3d4a5a69"
|
||||
dependencies = [
|
||||
"bit_field 0.10.1",
|
||||
"bitflags",
|
||||
"raw-cpuid",
|
||||
"raw-cpuid 8.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x86"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "268696f47813d5744c80c868e014485e27b30d40eaeeff2f7685b10b70215e5c"
|
||||
dependencies = [
|
||||
"bit_field 0.10.1",
|
||||
"bitflags",
|
||||
"raw-cpuid 9.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -909,6 +937,16 @@ dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x86_64"
|
||||
version = "0.13.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "021b49a4cb0a0d9490265cc169ca816014cbf61d3f3b75424815912977b81871"
|
||||
dependencies = [
|
||||
"bit_field 0.9.0",
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xmas-elf"
|
||||
version = "0.7.0"
|
||||
|
@ -22,6 +22,7 @@ authors = [
|
||||
default = []
|
||||
board_qemu = []
|
||||
board_u540 = ["link_user"]
|
||||
board_rcore_vmm_guest = ["link_user"]
|
||||
# (for aarch64 RaspberryPi3)
|
||||
nographic = []
|
||||
consolegraphic = []
|
||||
@ -63,20 +64,20 @@ pci = { git = "https://github.com/rcore-os/pci-rs", rev = "a4e7cea6" }
|
||||
pc-keyboard = "0.5"
|
||||
rcore-console = { git = "https://github.com/rcore-os/rcore-console", rev = "b7bacf9", default-features = false }
|
||||
rcore-memory = { path = "../crate/memory" }
|
||||
rcore-fs = { path = "../submodules/rcore-fs/rcore-fs" }
|
||||
rcore-fs-sfs = { path = "../submodules/rcore-fs/rcore-fs-sfs" }
|
||||
rcore-fs-ramfs = { path = "../submodules/rcore-fs/rcore-fs-ramfs" }
|
||||
rcore-fs-mountfs = { path = "../submodules/rcore-fs/rcore-fs-mountfs" }
|
||||
rcore-fs-devfs = { path = "../submodules/rcore-fs/rcore-fs-devfs" }
|
||||
rcore-fs = { git = "https://github.com/rcore-os/rcore-fs", rev = "517af47" }
|
||||
rcore-fs-sfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "517af47" }
|
||||
rcore-fs-ramfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "517af47" }
|
||||
rcore-fs-mountfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "517af47" }
|
||||
rcore-fs-devfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "517af47" }
|
||||
rlibc = "1.0"
|
||||
smoltcp = { git = "https://github.com/rcore-os/smoltcp", rev = "5bd87c7c", default-features = false, features = ["alloc", "log", "ethernet", "proto-ipv4", "proto-igmp", "socket-icmp", "socket-udp", "socket-tcp", "socket-raw"] }
|
||||
spin = "0.5"
|
||||
trapframe = { git = "https://github.com/rcore-os/trapframe-rs", rev = "bdfe5aa" }
|
||||
virtio-drivers = { git = "https://github.com/rcore-os/virtio-drivers", rev = "dfa70e14" }
|
||||
virtio-drivers = { git = "https://github.com/rcore-riscv-hypervisor-dev/virtio-drivers", rev = "1201a0b" }
|
||||
volatile = "0.2"
|
||||
woke = "0.0.2"
|
||||
xmas-elf = "0.7"
|
||||
rvm = { path = "../submodules/RVM", optional = true }
|
||||
rvm = { git = "https://github.com/rcore-riscv-hypervisor-dev/RVM", rev = "fa31039", optional = true }
|
||||
|
||||
[target.'cfg(target_arch = "x86_64")'.dependencies]
|
||||
apic = { git = "https://github.com/rcore-os/apic-rs", rev = "fb86bd7" }
|
||||
@ -88,7 +89,7 @@ uart_16550 = "0.2.7"
|
||||
x86_64 = "0.11"
|
||||
|
||||
[target.'cfg(any(target_arch = "riscv32", target_arch = "riscv64"))'.dependencies]
|
||||
riscv = { path = "../submodules/riscv" , features = ["inline-asm", "hypervisor"] }
|
||||
riscv = { git = "https://github.com/rcore-riscv-hypervisor-dev/riscv" , rev = "3f5efb1", features = ["inline-asm", "hypervisor"] }
|
||||
|
||||
[target.'cfg(target_arch = "aarch64")'.dependencies]
|
||||
aarch64 = { git = "https://github.com/rcore-os/aarch64", version = "3.0.1" }
|
||||
|
@ -22,12 +22,15 @@
|
||||
# | pc [ x86_64 only] Run on real pc
|
||||
# | u540 [riscv64 only] Run on HiFive U540, use Sv39
|
||||
# | raspi3 [aarch64 only] Run on Raspberry Pi 3 Model B/B+
|
||||
# | rcore_vmm_guest [riscv64 only] Run on rust-rvm-vmm/RVM. Requires variable GUEST_USER_IMG to be specified.
|
||||
# NET = on | off [ x86_64 only] Enable NIC
|
||||
# PCI_PASSTHRU = 0000:00:00.1 [ x86_64 only] Passthrough the specified PCI device
|
||||
# INIT = /bin/ls [riscv64 only] Run specified program instead of user shell
|
||||
# EXTRA_NIC = on | off [ x86_64 only] Add an additional e1000 nic
|
||||
# ACCEL = on | off [ x86_64 only] Enable/disable kvm/hvf acceleration
|
||||
# HYPERVISOR = on | off [ x86_64 only] Enable/disable the RVM hypervisor, and set ACCEL to on
|
||||
# HYPERVISOR = on | off [ x86_64 and riscv64 only] Enable/disable the RVM hypervisor, and set ACCEL to on under x86_64
|
||||
# UART2 = on | off [riscv64 only] Add an extra virtio-driven UART port on unix domain socket /tmp/rcore_uart2
|
||||
# GUEST_USER_IMG = <sfsimg> Image path of user programs. Specially taken out to allow out-of-tree user image.
|
||||
# FEATURES = profile | ... Add additional features
|
||||
|
||||
ARCH ?= riscv64
|
||||
@ -40,6 +43,7 @@ INIT ?=
|
||||
EXTRA_NIC ?= off
|
||||
ACCEL ?= off
|
||||
HYPERVISOR ?= off
|
||||
UART2 ?= off
|
||||
|
||||
qemu := qemu-system-$(ARCH)
|
||||
target := $(ARCH)
|
||||
@ -53,7 +57,14 @@ user_dir := ../user
|
||||
|
||||
### export environments ###
|
||||
|
||||
ifeq ($(BOARD), rcore_vmm_guest)
|
||||
ifeq ($(GUEST_USER_IMG), )
|
||||
$(error For building guest rCore image you have to specify the variable GUEST_USER_IMG .)
|
||||
endif
|
||||
export USER_IMG = $(GUEST_USER_IMG)
|
||||
else
|
||||
export USER_IMG = $(user_dir)/build/$(ARCH).img
|
||||
endif
|
||||
export USER_QCOW2 = $(user_dir)/build/$(ARCH).qcow2
|
||||
|
||||
ifeq ($(ARCH), aarch64)
|
||||
@ -124,11 +135,27 @@ qemu_opts += \
|
||||
-serial mon:stdio \
|
||||
-bios ../tools/opensbi/fu540.elf \
|
||||
-device loader,addr=0x80200000,file=$(kernel_img)
|
||||
else
|
||||
else ifeq ($(BOARD), rcore_vmm_guest)
|
||||
qemu_opts += \
|
||||
-machine virt \
|
||||
-cpu rv64,x-h=true \
|
||||
-serial mon:stdio \
|
||||
-bios ../tools/opensbi/fw_jump.elf \
|
||||
-m 2G\
|
||||
-kernel $(kernel_img)
|
||||
else
|
||||
qemu_opts += \
|
||||
-machine virt \
|
||||
-cpu rv64,x-h=true \
|
||||
-m 1G \
|
||||
-serial mon:stdio
|
||||
ifeq ($(UART2), on)
|
||||
qemu_opts += \
|
||||
-chardev socket,path=/tmp/rcore_uart2,server=on,wait=off,id=uart2 \
|
||||
-device virtio-serial-device,id=uart2-bus \
|
||||
-device virtconsole,chardev=uart2
|
||||
endif
|
||||
qemu_opts += \
|
||||
-bios ../tools/opensbi/fw_jump.elf \
|
||||
-device loader,addr=0x80200000,file=$(kernel_img) \
|
||||
-drive file=$(USER_QCOW2),format=qcow2,id=sfs \
|
||||
@ -174,8 +201,10 @@ endif
|
||||
|
||||
ifeq ($(HYPERVISOR), on)
|
||||
FEATURES += hypervisor
|
||||
ifeq ($(ARCH), x86_64)
|
||||
ACCEL = on
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(ACCEL), on)
|
||||
ifeq ($(shell uname), Darwin)
|
||||
@ -350,4 +379,4 @@ endif
|
||||
|
||||
.PHONY:
|
||||
addr2line:
|
||||
@python3.7 ../tools/addr2line.py $(prefix)addr2line $(ARCH) $(MODE)
|
||||
@python3 ../tools/addr2line.py $(prefix)addr2line $(ARCH) $(MODE)
|
||||
|
@ -1,363 +0,0 @@
|
||||
# Commands:
|
||||
# make build Build
|
||||
# make run Build and run in QEMU
|
||||
# make justrun Run the last build
|
||||
# make test Build and run in QEMU with specified program
|
||||
# make justtest Run the last build with specified program
|
||||
# make doc Generate docs
|
||||
# make asm Open the deassemble file of the last build
|
||||
# make header Open 'objdump -h' of the last build
|
||||
# make addr2line Use addr2line to recover line info in backtrace
|
||||
# make clean Clean
|
||||
#
|
||||
# Options:
|
||||
# ARCH = x86_64 | riscv32 | riscv64 | aarch64 | mipsel
|
||||
# D = int | in_asm | ... QEMU debug info
|
||||
# MODE = debug | release
|
||||
# LOG = off | error | warn | info | debug | trace
|
||||
# USER_IMG = <sfsimg> Image path of user programs
|
||||
# SMP = 1 | 2 | ... SMP core number
|
||||
# GRAPHIC = on | off | console Enable/disable qemu graphical output, or print console to graphic output
|
||||
# BOARD = qemu Run on QEMU
|
||||
# | pc [ x86_64 only] Run on real pc
|
||||
# | u540 [riscv64 only] Run on HiFive U540, use Sv39
|
||||
# | raspi3 [aarch64 only] Run on Raspberry Pi 3 Model B/B+
|
||||
# NET = on | off [ x86_64 only] Enable NIC
|
||||
# PCI_PASSTHRU = 0000:00:00.1 [ x86_64 only] Passthrough the specified PCI device
|
||||
# INIT = /bin/ls [riscv64 only] Run specified program instead of user shell
|
||||
# EXTRA_NIC = on | off [ x86_64 only] Add an additional e1000 nic
|
||||
# ACCEL = on | off [ x86_64 only] Enable/disable kvm/hvf acceleration
|
||||
# HYPERVISOR = on | off [ x86_64/riscv64 only] Enable/disable the RVM hypervisor, and set ACCEL to on
|
||||
# FEATURES = profile | ... Add additional features
|
||||
|
||||
ARCH ?= riscv64
|
||||
MODE ?= release
|
||||
LOG ?=
|
||||
GRAPHIC ?= off
|
||||
SMP ?= 4
|
||||
PCI_PASSTHRU ?=
|
||||
INIT ?=
|
||||
EXTRA_NIC ?= off
|
||||
ACCEL ?= off
|
||||
HYPERVISOR ?= off
|
||||
|
||||
qemu := qemu-system-$(ARCH)
|
||||
target := $(ARCH)
|
||||
build_path := target/$(target)/$(MODE)
|
||||
kernel := $(build_path)/rcore
|
||||
kernel_img := $(build_path)/kernel.img
|
||||
ESP := $(build_path)/esp
|
||||
OVMF := ../rboot/OVMF.fd
|
||||
user_dir := ../user
|
||||
|
||||
|
||||
### export environments ###
|
||||
|
||||
export USER_IMG = $(user_dir)/build/$(ARCH).img
|
||||
export USER_QCOW2 = $(user_dir)/build/$(ARCH).qcow2
|
||||
|
||||
ifeq ($(ARCH), aarch64)
|
||||
BOARD ?= raspi3
|
||||
else ifeq ($(ARCH), mipsel)
|
||||
BOARD ?= malta
|
||||
else
|
||||
BOARD ?= qemu
|
||||
endif
|
||||
|
||||
# currently only mipsel architecture need DTB linked to the kernel
|
||||
ifeq ($(ARCH), mipsel)
|
||||
DTB := src/arch/$(ARCH)/board/$(BOARD)/device.dtb
|
||||
endif
|
||||
|
||||
### qemu options ###
|
||||
qemu_opts := \
|
||||
-smp cores=$(SMP)
|
||||
qemu_net_opts :=
|
||||
|
||||
ifeq ($(ARCH), x86_64)
|
||||
qemu_opts += \
|
||||
-drive if=pflash,format=raw,readonly,file=$(OVMF) \
|
||||
-drive format=raw,file=fat:rw:$(ESP) \
|
||||
-serial mon:stdio \
|
||||
-m 4G \
|
||||
-device isa-debug-exit
|
||||
ifeq ($(BOARD), qemu)
|
||||
qemu_opts += \
|
||||
-drive format=qcow2,file=$(USER_QCOW2),media=disk,cache=writeback,id=sfsimg,if=none \
|
||||
-device ahci,id=ahci0 \
|
||||
-device ide-hd,drive=sfsimg,bus=ahci0.0
|
||||
endif
|
||||
ifeq ($(PCI_PASSTHRU), )
|
||||
qemu_net_opts += \
|
||||
-netdev type=tap,id=net0,script=no,downscript=no \
|
||||
-device e1000e,netdev=net0
|
||||
else
|
||||
qemu_net_opts += \
|
||||
-device vfio-pci,host=$(PCI_PASSTHRU)
|
||||
qemu_ui_opts += \
|
||||
-vga std
|
||||
endif
|
||||
ifeq ($(EXTRA_NIC), on)
|
||||
qemu_net_opts += \
|
||||
-netdev type=tap,id=net1,script=no,downscript=no \
|
||||
-device e1000e,netdev=net1
|
||||
endif
|
||||
|
||||
else ifeq ($(ARCH), riscv32)
|
||||
qemu_opts += \
|
||||
-machine virt \
|
||||
-serial mon:stdio \
|
||||
-bios default \
|
||||
-device loader,addr=0x80400000,file=$(kernel_img) \
|
||||
-drive file=$(USER_QCOW2),format=qcow2,id=sfs \
|
||||
-device virtio-blk-device,drive=sfs \
|
||||
-device virtio-gpu-device \
|
||||
-device virtio-mouse-device
|
||||
qemu_net_opts += \
|
||||
-netdev type=tap,id=net0,script=no,downscript=no \
|
||||
-device virtio-net-device,netdev=net0
|
||||
|
||||
else ifeq ($(ARCH), riscv64)
|
||||
ifeq ($(BOARD), u540)
|
||||
qemu_opts += \
|
||||
-machine virt \
|
||||
-serial mon:stdio \
|
||||
-bios ../tools/opensbi/fu540.elf \
|
||||
-device loader,addr=0x80200000,file=$(kernel_img)
|
||||
else
|
||||
qemu_opts += \
|
||||
-machine virt \
|
||||
-serial mon:stdio \
|
||||
-bios ../tools/opensbi/fw_jump.elf \
|
||||
-device loader,addr=0x80200000,file=$(kernel_img) \
|
||||
-drive file=$(USER_QCOW2),format=qcow2,id=sfs \
|
||||
-device virtio-blk-device,drive=sfs \
|
||||
-device virtio-gpu-device \
|
||||
-device virtio-mouse-device
|
||||
endif
|
||||
qemu_net_opts += \
|
||||
-netdev type=tap,id=net0,script=no,downscript=no \
|
||||
-device virtio-net-device,netdev=net0
|
||||
|
||||
else ifeq ($(ARCH), aarch64)
|
||||
# raspi must have at least 4 cpus
|
||||
qemu_opts += \
|
||||
-machine $(BOARD) \
|
||||
-smp 4 \
|
||||
-serial null -serial mon:stdio \
|
||||
-kernel $(kernel_img) \
|
||||
-drive file=$(USER_QCOW2),if=sd,format=qcow2,id=sfs
|
||||
|
||||
else ifeq ($(ARCH), mipsel)
|
||||
ifeq ($(BOARD), malta)
|
||||
qemu_opts += \
|
||||
-machine $(BOARD) -device VGA \
|
||||
-hda $(USER_QCOW2) \
|
||||
-serial null -serial null -serial mon:stdio \
|
||||
-kernel $(kernel_img)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef D
|
||||
qemu_opts += -d $(D)
|
||||
endif
|
||||
|
||||
ifeq ($(GRAPHIC), off)
|
||||
qemu_opts += -nographic
|
||||
endif
|
||||
|
||||
ifeq ($(NET), on)
|
||||
qemu_opts += $(qemu_net_opts)
|
||||
qemu := sudo $(qemu)
|
||||
endif
|
||||
|
||||
ifeq ($(HYPERVISOR), on)
|
||||
ifeq ($(ARCH), x86_64)
|
||||
FEATURES += hypervisor
|
||||
ACCEL = on
|
||||
endif
|
||||
ifeq ($(ARCH), riscv64)
|
||||
qemu_opts += -cpu rv64,x-h=true
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(ACCEL), on)
|
||||
ifeq ($(shell uname), Darwin)
|
||||
qemu_opts += -accel hvf
|
||||
else
|
||||
qemu_opts += -accel kvm -cpu host
|
||||
endif
|
||||
endif
|
||||
|
||||
### build args ###
|
||||
ifeq ($(GRAPHIC), off)
|
||||
FEATURES += nographic
|
||||
endif
|
||||
|
||||
ifeq ($(GRAPHIC), console)
|
||||
FEATURES += consolegraphic
|
||||
endif
|
||||
|
||||
ifneq ($(INIT), )
|
||||
FEATURES += run_cmdline
|
||||
endif
|
||||
|
||||
FEATURES += board_$(BOARD)
|
||||
|
||||
build_args := \
|
||||
-Z build-std=core,alloc \
|
||||
--target targets/$(target).json \
|
||||
--features "$(FEATURES)"
|
||||
|
||||
ifeq ($(MODE), release)
|
||||
build_args += --release
|
||||
endif
|
||||
|
||||
### prefix ###
|
||||
ifeq ($(ARCH), x86_64)
|
||||
ifeq ($(shell uname), Darwin)
|
||||
prefix := x86_64-linux-musl-
|
||||
endif
|
||||
else ifeq ($(ARCH), riscv32)
|
||||
prefix := riscv64-linux-musl-
|
||||
else ifeq ($(ARCH), riscv64)
|
||||
prefix := riscv64-unknown-linux-musl-
|
||||
else ifeq ($(ARCH), mipsel)
|
||||
prefix ?= mipsel-linux-musln32-
|
||||
else ifeq ($(ARCH), aarch64)
|
||||
prefix ?= aarch64-linux-musl-
|
||||
endif
|
||||
|
||||
gdb := riscv64-unknown-linux-musl-gdb
|
||||
sysroot := $(shell rustc --print sysroot)
|
||||
objdump := $(shell find $(sysroot) -name llvm-objdump) -print-imm-hex
|
||||
objcopy := $(shell find $(sysroot) -name llvm-objcopy)
|
||||
strip := $(shell find $(sysroot) -name llvm-strip)
|
||||
dtc := dtc
|
||||
hostcc := gcc
|
||||
|
||||
.PHONY: all clean build asm doc debug kernel sfsimg install run justrun test justtest
|
||||
|
||||
all: kernel
|
||||
|
||||
clean:
|
||||
@cargo clean
|
||||
@cd $(user_dir) && make clean
|
||||
|
||||
doc:
|
||||
@cargo doc $(build_args) --no-deps --document-private-items
|
||||
|
||||
run: build justrun
|
||||
test: build justtest
|
||||
|
||||
dryrun:
|
||||
@echo $(qemu) $(qemu_opts)
|
||||
|
||||
justrun:
|
||||
@$(qemu) $(qemu_opts)
|
||||
|
||||
justtest:
|
||||
# unavailable now
|
||||
@#$(qemu) $(filter-out -serial mon:stdio, $(qemu_opts)) --append $(INIT) -serial file:../tests/stdout -monitor null
|
||||
|
||||
|
||||
debug: $(kernel) $(kernel_img)
|
||||
@$(qemu) $(qemu_opts) -s -S &
|
||||
@sleep 1
|
||||
@$(gdb) $(kernel) -x ../tools/gdbinit
|
||||
debugserver: $(kernel) $(kernel_img)
|
||||
@$(qemu) $(qemu_opts) -s -S
|
||||
debugclient: $(kernel) $(kernel_img)
|
||||
@$(gdb) $(kernel) -x ../tools/gdbinit
|
||||
|
||||
build: $(kernel_img)
|
||||
|
||||
asm:
|
||||
@$(objdump) -d $(kernel) | less
|
||||
|
||||
header:
|
||||
@$(objdump) -h $(kernel)
|
||||
|
||||
sym:
|
||||
@$(objdump) -t $(kernel) | less
|
||||
|
||||
### device tree process ###
|
||||
|
||||
%.dtb: %.dts
|
||||
@echo Generating device tree file $@
|
||||
@$(dtc) -I dts -O dtb -o $@ $<
|
||||
@rm -rf src/arch/${arch}/boot/dtb.gen.s
|
||||
|
||||
### bootloader and kernel image ###
|
||||
|
||||
bootloader: $(kernel)
|
||||
ifeq ($(ARCH), x86_64)
|
||||
@cd ../rboot && make build
|
||||
endif
|
||||
|
||||
$(kernel_img): kernel bootloader
|
||||
ifeq ($(ARCH), x86_64)
|
||||
mkdir -p $(ESP)/EFI/rCore $(ESP)/EFI/Boot
|
||||
@cp ../rboot/target/x86_64-unknown-uefi/$(MODE)/rboot.efi $(ESP)/EFI/Boot/BootX64.efi
|
||||
@cp ../rboot/rboot.conf $(ESP)/EFI/Boot/rboot.conf
|
||||
@cp $(kernel) $(ESP)/EFI/rCore/kernel.elf
|
||||
else ifeq ($(ARCH), $(filter $(ARCH), riscv32 riscv64))
|
||||
@$(objcopy) $(kernel) --strip-all -O binary $@
|
||||
else ifeq ($(ARCH), aarch64)
|
||||
@$(objcopy) $(kernel) --strip-all -O binary $@
|
||||
else ifeq ($(ARCH), mipsel)
|
||||
# qemu-system-mipsel accepts ELF file only, so objcopy is not needed
|
||||
@$(strip) $(kernel) -o $@
|
||||
endif
|
||||
|
||||
kernel: $(DTB)
|
||||
@echo Building $(ARCH) kernel
|
||||
ifeq ($(ARCH), $(filter $(ARCH), riscv32 riscv64))
|
||||
@cp src/arch/riscv/board/u540/linker.ld src/arch/riscv/boot/linker64.ld
|
||||
@-patch -p0 -N -b \
|
||||
$(sysroot)/lib/rustlib/src/rust/src/libcore/sync/atomic.rs \
|
||||
src/arch/riscv/atomic.patch
|
||||
else ifeq ($(ARCH), mipsel)
|
||||
@for file in entry ; do \
|
||||
$(hostcc) -Dboard_$(BOARD) -E src/arch/$(ARCH)/boot/$${file}.S -o src/arch/$(ARCH)/boot/$${file}.gen.s ; \
|
||||
done
|
||||
$(hostcc) -Dboard_$(BOARD) -E src/arch/$(ARCH)/boot/linker.ld.S -o src/arch/$(ARCH)/boot/linker.ld
|
||||
endif
|
||||
@cargo build $(build_args)
|
||||
|
||||
|
||||
### user programs ###
|
||||
sfsimg:
|
||||
@cd $(user_dir) && make sfsimg
|
||||
|
||||
|
||||
### install ###
|
||||
ifeq ($(BOARD), raspi3)
|
||||
sd_card ?=
|
||||
|
||||
ifeq ($(shell uname), Darwin)
|
||||
sd_card := /Volumes/boot
|
||||
else ifeq ($(shell uname), Linux)
|
||||
sd_card := /media/$(shell whoami)/boot
|
||||
endif
|
||||
|
||||
ifdef sd_card
|
||||
.PHONY:
|
||||
install: $(kernel_img)
|
||||
cp $(kernel_img) $(sd_card)/kernel8.img
|
||||
sudo umount $(sd_card)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(BOARD), u540)
|
||||
.PHONY:
|
||||
install: $(kernel_img)
|
||||
@$(objcopy) -S -O binary ../tools/opensbi/fu540.elf $(build_path)/bin
|
||||
@dd if=$< of=$(build_path)/bin bs=0x20000 seek=16
|
||||
@../tools/u540/mkimg.sh $(build_path)/bin $(build_path)/u540.img
|
||||
endif
|
||||
|
||||
.PHONY:
|
||||
addr2line:
|
||||
@python3 ../tools/addr2line.py $(prefix)addr2line $(ARCH) $(MODE)
|
Loading…
Reference in New Issue
Block a user