aboutsummaryrefslogtreecommitdiff
path: root/riscv
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2020-06-22 08:38:44 +0530
committerAnup Patel <anup@brainfault.org>2020-07-09 23:04:23 +0530
commit2cb19ac699b51d38fba57f4acb1ce02f06e7548f (patch)
tree5fef42799cb4cc024905ca5d0d08f79bfb3b4117 /riscv
parent564ed97f618321b8499a3e8837c36f622ee8a893 (diff)
downloadspike-2cb19ac699b51d38fba57f4acb1ce02f06e7548f.zip
spike-2cb19ac699b51d38fba57f4acb1ce02f06e7548f.tar.gz
spike-2cb19ac699b51d38fba57f4acb1ce02f06e7548f.tar.bz2
Add bootargs command-line option to Spike
We add bootargs command-line option to Spike which allows us to provide custom kernel parameters to Linux and Xvisor. Signed-off-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'riscv')
-rw-r--r--riscv/dts.cc17
-rw-r--r--riscv/dts.h1
-rw-r--r--riscv/sim.cc7
-rw-r--r--riscv/sim.h3
4 files changed, 21 insertions, 7 deletions
diff --git a/riscv/dts.cc b/riscv/dts.cc
index 6a38ba0..56b76e6 100644
--- a/riscv/dts.cc
+++ b/riscv/dts.cc
@@ -11,6 +11,7 @@
std::string make_dts(size_t insns_per_rtc_tick, size_t cpu_hz,
reg_t initrd_start, reg_t initrd_end,
+ const char* bootargs,
std::vector<processor_t*> procs,
std::vector<std::pair<reg_t, mem_t*>> mems)
{
@@ -25,12 +26,22 @@ std::string make_dts(size_t insns_per_rtc_tick, size_t cpu_hz,
" model = \"ucbbar,spike-bare\";\n"
" chosen {\n";
if (initrd_start < initrd_end) {
- s << " bootargs = \"root=/dev/ram console=hvc0 earlycon=sbi\";\n"
- " linux,initrd-start = <" << (size_t)initrd_start << ">;\n"
+ s << " linux,initrd-start = <" << (size_t)initrd_start << ">;\n"
" linux,initrd-end = <" << (size_t)initrd_end << ">;\n";
+ if (!bootargs)
+ bootargs = "root=/dev/ram console=hvc0 earlycon=sbi";
} else {
- s << " bootargs = \"console=hvc0 earlycon=sbi\";\n";
+ if (!bootargs)
+ bootargs = "console=hvc0 earlycon=sbi";
}
+ s << " bootargs = \"";
+ for (size_t i = 0; i < strlen(bootargs); i++) {
+ if (bootargs[i] == '"')
+ s << '\\' << bootargs[i];
+ else
+ s << bootargs[i];
+ }
+ s << "\";\n";
s << " };\n"
" cpus {\n"
" #address-cells = <1>;\n"
diff --git a/riscv/dts.h b/riscv/dts.h
index 1c3f701..1f01e0f 100644
--- a/riscv/dts.h
+++ b/riscv/dts.h
@@ -8,6 +8,7 @@
std::string make_dts(size_t insns_per_rtc_tick, size_t cpu_hz,
reg_t initrd_start, reg_t initrd_end,
+ const char* bootargs,
std::vector<processor_t*> procs,
std::vector<std::pair<reg_t, mem_t*>> mems);
diff --git a/riscv/sim.cc b/riscv/sim.cc
index b25d79e..2aced1b 100644
--- a/riscv/sim.cc
+++ b/riscv/sim.cc
@@ -28,7 +28,7 @@ static void handle_signal(int sig)
sim_t::sim_t(const char* isa, const char* priv, const char* varch,
size_t nprocs, bool halted, bool real_time_clint,
- reg_t initrd_start, reg_t initrd_end,
+ reg_t initrd_start, reg_t initrd_end, const char* bootargs,
reg_t start_pc, std::vector<std::pair<reg_t, mem_t*>> mems,
std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices,
const std::vector<std::string>& args,
@@ -42,6 +42,7 @@ sim_t::sim_t(const char* isa, const char* priv, const char* varch,
procs(std::max(nprocs, size_t(1))),
initrd_start(initrd_start),
initrd_end(initrd_end),
+ bootargs(bootargs),
start_pc(start_pc),
dtb_file(dtb_file ? dtb_file : ""),
dtb_enabled(dtb_enabled),
@@ -230,7 +231,7 @@ void sim_t::make_dtb()
dtb = strstream.str();
} else {
- dts = make_dts(INSNS_PER_RTC_TICK, CPU_HZ, initrd_start, initrd_end, procs, mems);
+ dts = make_dts(INSNS_PER_RTC_TICK, CPU_HZ, initrd_start, initrd_end, bootargs, procs, mems);
dtb = dts_compile(dts);
}
}
@@ -271,7 +272,7 @@ void sim_t::set_rom()
dtb = strstream.str();
} else {
- dts = make_dts(INSNS_PER_RTC_TICK, CPU_HZ, initrd_start, initrd_end, procs, mems);
+ dts = make_dts(INSNS_PER_RTC_TICK, CPU_HZ, initrd_start, initrd_end, bootargs, procs, mems);
dtb = dts_compile(dts);
}
diff --git a/riscv/sim.h b/riscv/sim.h
index 7cf83d6..c6e5582 100644
--- a/riscv/sim.h
+++ b/riscv/sim.h
@@ -25,7 +25,7 @@ class sim_t : public htif_t, public simif_t
public:
sim_t(const char* isa, const char* priv, const char* varch, size_t _nprocs,
bool halted, bool real_time_clint,
- reg_t initrd_start, reg_t initrd_end,
+ reg_t initrd_start, reg_t initrd_end, const char* bootargs,
reg_t start_pc, std::vector<std::pair<reg_t, mem_t*>> mems,
std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices,
const std::vector<std::string>& args, const std::vector<int> hartids,
@@ -64,6 +64,7 @@ private:
std::vector<processor_t*> procs;
reg_t initrd_start;
reg_t initrd_end;
+ const char* bootargs;
reg_t start_pc;
std::string dts;
std::string dtb;