sim: Add a "make sim" target

This allows users without hardware to simulate Linux on Spike.
This commit is contained in:
Palmer Dabbelt 2017-11-03 13:44:17 -07:00
parent deabfb7b14
commit afe67e77ee
4 changed files with 41 additions and 0 deletions

6
.gitmodules vendored
View File

@ -10,3 +10,9 @@
[submodule "riscv-gnu-toolchain"]
path = riscv-gnu-toolchain
url = https://github.com/riscv/riscv-gnu-toolchain.git
[submodule "riscv-isa-sim"]
path = riscv-isa-sim
url = https://github.com/riscv/riscv-isa-sim.git
[submodule "riscv-fesvr"]
path = riscv-fesvr
url = https://github.com/riscv/riscv-fesvr.git

View File

@ -30,6 +30,14 @@ bbl := $(pk_wrkdir)/bbl
bin := $(wrkdir)/bbl.bin
hex := $(wrkdir)/bbl.hex
fesvr_srcdir := $(srcdir)/riscv-fesvr
fesvr_wrkdir := $(wrkdir)/riscv-fesvr
libfesvr := $(fesvr_wrkdir)/prefix/lib/libfesvr.so
spike_srcdir := $(srcdir)/riscv-isa-sim
spike_wrkdir := $(wrkdir)/riscv-isa-sim
spike := $(spike_wrkdir)/prefix/bin/spike
target := riscv64-unknown-linux-gnu
.PHONY: all
@ -91,6 +99,27 @@ $(bin): $(bbl)
$(hex): $(bin)
xxd -c1 -p $< > $@
$(libfesvr): $(fesvr_srcdir)
rm -rf $(fesvr_wrkdir)
mkdir -p $(fesvr_wrkdir)
mkdir -p $(dir $@)
cd $(fesvr_wrkdir) && $</configure \
--prefix=$(dir $(abspath $(dir $@)))
$(MAKE) -C $(fesvr_wrkdir)
$(MAKE) -C $(fesvr_wrkdir) install
touch -c $@
$(spike): $(spike_srcdir) $(libfesvr)
rm -rf $(spike_wrkdir)
mkdir -p $(spike_wrkdir)
mkdir -p $(dir $@)
cd $(spike_wrkdir) && $</configure \
--prefix=$(dir $(abspath $(dir $@))) \
--with-fesvr=$(dir $(abspath $(dir $(libfesvr))))
$(MAKE) -C $(spike_wrkdir)
$(MAKE) -C $(spike_wrkdir) install
touch -c $@
.PHONY: sysroot vmlinux bbl
sysroot: $(sysroot)
vmlinux: $(vmlinux)
@ -99,3 +128,7 @@ bbl: $(bbl)
.PHONY: clean
clean:
rm -rf -- $(wrkdir) $(toolchain_dest)
.PHONY: sim
sim: $(spike) $(bbl)
$(spike) -p4 $(bbl)

1
riscv-fesvr Submodule

@ -0,0 +1 @@
Subproject commit f683e01542acf60e50774d061bcb396b628e3e67

1
riscv-isa-sim Submodule

@ -0,0 +1 @@
Subproject commit a327416eac285f50dcbb04e8ddf89204c66ece02