Add "make qemu", which runs a QEMU-based system

This currently has support for a virtio disk, and the Makefiles will
create an empty one for you.
This commit is contained in:
Palmer Dabbelt 2017-12-11 13:30:24 -08:00
parent 3765145708
commit 86de0ac05a
3 changed files with 29 additions and 2 deletions

View File

@ -40,6 +40,12 @@ spike_srcdir := $(srcdir)/riscv-isa-sim
spike_wrkdir := $(wrkdir)/riscv-isa-sim spike_wrkdir := $(wrkdir)/riscv-isa-sim
spike := $(spike_wrkdir)/prefix/bin/spike spike := $(spike_wrkdir)/prefix/bin/spike
qemu_srcdir := $(srcdir)/riscv-qemu
qemu_wrkdir := $(wrkdir)/riscv-qemu
qemu := $(qemu_wrkdir)/prefix/bin/qemu-system-riscv64
rootfs := $(wrkdir)/rootfs.bin
target := riscv64-unknown-linux-gnu target := riscv64-unknown-linux-gnu
.PHONY: all .PHONY: all
@ -110,7 +116,7 @@ $(bbl): $(pk_srcdir) $(vmlinux_stripped)
cd $(pk_wrkdir) && $</configure \ cd $(pk_wrkdir) && $</configure \
--host=$(target) \ --host=$(target) \
--with-payload=$(vmlinux_stripped) \ --with-payload=$(vmlinux_stripped) \
--enable-logo \ --enable-logo --enable-print-device-tree \
--with-logo=$(abspath conf/sifive_logo.txt) --with-logo=$(abspath conf/sifive_logo.txt)
CFLAGS="-mabi=$(ABI) -march=$(ISA)" $(MAKE) -C $(pk_wrkdir) CFLAGS="-mabi=$(ABI) -march=$(ISA)" $(MAKE) -C $(pk_wrkdir)
@ -141,6 +147,21 @@ $(spike): $(spike_srcdir) $(libfesvr)
$(MAKE) -C $(spike_wrkdir) install $(MAKE) -C $(spike_wrkdir) install
touch -c $@ touch -c $@
$(qemu): $(qemu_srcdir)
rm -rf $(qemu_wrkdir)
mkdir -p $(qemu_wrkdir)
mkdir -p $(dir $@)
cd $(qemu_wrkdir) && $</configure \
--prefix=$(dir $(abspath $(dir $@))) \
--target-list=riscv64-softmmu
$(MAKE) -C $(qemu_wrkdir)
$(MAKE) -C $(qemu_wrkdir) install
touch -c $@
$(rootfs):
truncate --size=1G $@
mkfs.ext4 $@
.PHONY: sysroot vmlinux bbl .PHONY: sysroot vmlinux bbl
sysroot: $(sysroot) sysroot: $(sysroot)
vmlinux: $(vmlinux) vmlinux: $(vmlinux)
@ -153,3 +174,7 @@ clean:
.PHONY: sim .PHONY: sim
sim: $(spike) $(bbl) sim: $(spike) $(bbl)
$(spike) --isa=$(ISA) -p4 $(bbl) $(spike) --isa=$(ISA) -p4 $(bbl)
.PHONY: qemu
qemu: $(qemu) $(bbl) $(rootfs)
$(qemu) -nographic -machine virt -kernel $(bbl) -drive file=$(rootfs),format=raw,id=hd0 -device virtio-blk-device,drive=hd0

View File

@ -30,6 +30,7 @@ CONFIG_INET=y
CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y CONFIG_DEVTMPFS_MOUNT=y
# CONFIG_FIRMWARE_IN_KERNEL is not set # CONFIG_FIRMWARE_IN_KERNEL is not set
CONFIG_VIRTIO_BLK=y
CONFIG_BLK_DEV_SD=y CONFIG_BLK_DEV_SD=y
CONFIG_ATA=y CONFIG_ATA=y
CONFIG_SATA_AHCI=y CONFIG_SATA_AHCI=y
@ -46,6 +47,7 @@ CONFIG_USB=y
CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_HCD=y
CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y CONFIG_USB_STORAGE=y
CONFIG_VIRTIO_MMIO=y
# CONFIG_IOMMU_SUPPORT is not set # CONFIG_IOMMU_SUPPORT is not set
CONFIG_EXT3_FS=y CONFIG_EXT3_FS=y
# CONFIG_FILE_LOCKING is not set # CONFIG_FILE_LOCKING is not set

@ -1 +1 @@
Subproject commit 2ab905517f367c4ac60603080c4d9abec658a647 Subproject commit cd2c21d70361f6887e265860c4f0dbb49ad323ca