aboutsummaryrefslogtreecommitdiff
path: root/riscv/sim.cc
diff options
context:
space:
mode:
authorJerry Zhao <jerryz123@berkeley.edu>2023-02-04 20:57:13 -0800
committerJerry Zhao <jerryz123@berkeley.edu>2023-02-06 10:43:56 -0800
commita5f9165c34938f54c71c09a0713de95d9f758757 (patch)
treedc5c33080a143466e339be13be69270db7be9465 /riscv/sim.cc
parentb52cbbd414d20ac3a43846cf3dcfd33581257e06 (diff)
downloadriscv-isa-sim-a5f9165c34938f54c71c09a0713de95d9f758757.zip
riscv-isa-sim-a5f9165c34938f54c71c09a0713de95d9f758757.tar.gz
riscv-isa-sim-a5f9165c34938f54c71c09a0713de95d9f758757.tar.bz2
Pass dtb_file directly to make_dtb
Diffstat (limited to 'riscv/sim.cc')
-rw-r--r--riscv/sim.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/riscv/sim.cc b/riscv/sim.cc
index 051a483..3154cba 100644
--- a/riscv/sim.cc
+++ b/riscv/sim.cc
@@ -45,7 +45,6 @@ sim_t::sim_t(const cfg_t *cfg, bool halted,
mems(mems),
plugin_devices(plugin_devices),
procs(std::max(cfg->nprocs(), size_t(1))),
- dtb_file(dtb_file ? dtb_file : ""),
dtb_enabled(dtb_enabled),
log_file(log_path),
cmd_file(cmd_file),
@@ -102,7 +101,7 @@ sim_t::sim_t(const cfg_t *cfg, bool halted,
log_file.get(), sout_);
}
- make_dtb();
+ make_dtb(dtb_file);
void *fdt = (void *)dtb.c_str();
@@ -293,10 +292,10 @@ bool sim_t::mmio_store(reg_t paddr, size_t len, const uint8_t* bytes)
return bus.store(paddr, len, bytes);
}
-void sim_t::make_dtb()
+void sim_t::make_dtb(const char* dtb_file)
{
- if (!dtb_file.empty()) {
- std::ifstream fin(dtb_file.c_str(), std::ios::binary);
+ if (dtb_file) {
+ std::ifstream fin(dtb_file, std::ios::binary);
if (!fin.good()) {
std::cerr << "can't find dtb file: " << dtb_file << std::endl;
exit(-1);
@@ -317,7 +316,7 @@ void sim_t::make_dtb()
int fdt_code = fdt_check_header(dtb.c_str());
if (fdt_code) {
std::cerr << "Failed to read DTB from ";
- if (dtb_file.empty()) {
+ if (!dtb_file) {
std::cerr << "auto-generated DTS string";
} else {
std::cerr << "`" << dtb_file << "'";