diff options
author | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-03-31 00:41:33 -0700 |
---|---|---|
committer | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-04-27 21:16:43 -0700 |
commit | 65f42ac88a871a5464a63a83cec6987f17aa599e (patch) | |
tree | fb9deaf28a8ce5c6f948e8894b81ed126f7a72af /riscv/sim.cc | |
parent | 4541ccba51c479021a2d3442dbde8bccddcb282a (diff) | |
download | riscv-isa-sim-65f42ac88a871a5464a63a83cec6987f17aa599e.zip riscv-isa-sim-65f42ac88a871a5464a63a83cec6987f17aa599e.tar.gz riscv-isa-sim-65f42ac88a871a5464a63a83cec6987f17aa599e.tar.bz2 |
fdt: option: add --dtb option to specify dtb binary file
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Diffstat (limited to 'riscv/sim.cc')
-rw-r--r-- | riscv/sim.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/riscv/sim.cc b/riscv/sim.cc index 0b29720..ac527a8 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -5,6 +5,7 @@ #include "dts.h" #include "remote_bitbang.h" #include "byteorder.h" +#include <fstream> #include <map> #include <iostream> #include <sstream> @@ -211,8 +212,22 @@ void sim_t::make_dtb() std::vector<char> rom((char*)reset_vec, (char*)reset_vec + sizeof(reset_vec)); - dts = make_dts(INSNS_PER_RTC_TICK, CPU_HZ, initrd_start, initrd_end, procs, mems); - std::string dtb = dts_compile(dts); + std::string dtb; + if (!dtb_file.empty()) { + std::ifstream fin(dtb_file.c_str(), std::ios::binary); + if (!fin.good()) { + std::cerr << "can't find dtb file: " << dtb_file << std::endl; + exit(-1); + } + + std::stringstream strstream; + strstream << fin.rdbuf(); + + dtb = strstream.str(); + } else { + dts = make_dts(INSNS_PER_RTC_TICK, CPU_HZ, initrd_start, initrd_end, procs, mems); + dtb = dts_compile(dts); + } rom.insert(rom.end(), dtb.begin(), dtb.end()); const int align = 0x1000; |