FMV.X.S/FMV.S.X -> FMV.X.W/FMV.W.X
[riscv-isa-sim.git] / spike_main / spike.cc
index 8896bc770c822525b40ef46e83a3903d57d9c9af..dde6f5a5b902e458c9b3b7f9a0ffd7aefc188590 100644 (file)
@@ -3,7 +3,6 @@
 #include "sim.h"
 #include "mmu.h"
 #include "gdbserver.h"
-#include "htif.h"
 #include "cachesim.h"
 #include "extension.h"
 #include <dlfcn.h>
@@ -31,7 +30,8 @@ static void help()
   fprintf(stderr, "  --l2=<S>:<W>:<B>        B both powers of 2).\n");
   fprintf(stderr, "  --extension=<name>    Specify RoCC Extension\n");
   fprintf(stderr, "  --extlib=<name>       Shared library to load\n");
-  fprintf(stderr, "  --dump-config-string  Print platform configuration string and exit\n");
+  fprintf(stderr, "  --gdb-port=<port>  Listen on <port> for gdb to connect\n");
+  fprintf(stderr, "  --dump-dts  Print device tree string and exit\n");
   exit(1);
 }
 
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
   bool halted = false;
   bool histogram = false;
   bool log = false;
-  bool dump_config_string = false;
+  bool dump_dts = false;
   size_t nprocs = 1;
   size_t mem_mb = 0;
   std::unique_ptr<icache_sim_t> ic;
@@ -49,6 +49,7 @@ int main(int argc, char** argv)
   std::unique_ptr<cache_sim_t> l2;
   std::function<extension_t*()> extension;
   const char* isa = DEFAULT_ISA;
+  uint16_t gdb_port = 0;
 
   option_parser_t parser;
   parser.help(&help);
@@ -58,12 +59,15 @@ int main(int argc, char** argv)
   parser.option('l', 0, 0, [&](const char* s){log = true;});
   parser.option('p', 0, 1, [&](const char* s){nprocs = atoi(s);});
   parser.option('m', 0, 1, [&](const char* s){mem_mb = atoi(s);});
+  // I wanted to use --halted, but for some reason that doesn't work.
+  parser.option('H', 0, 0, [&](const char* s){halted = true;});
+  parser.option(0, "gdb-port", 1, [&](const char* s){gdb_port = atoi(s);});
   parser.option(0, "ic", 1, [&](const char* s){ic.reset(new icache_sim_t(s));});
   parser.option(0, "dc", 1, [&](const char* s){dc.reset(new dcache_sim_t(s));});
   parser.option(0, "l2", 1, [&](const char* s){l2.reset(cache_sim_t::construct(s, "L2$"));});
   parser.option(0, "isa", 1, [&](const char* s){isa = s;});
   parser.option(0, "extension", 1, [&](const char* s){extension = find_extension(s);});
-  parser.option(0, "dump-config-string", 0, [&](const char *s){dump_config_string = true;});
+  parser.option(0, "dump-dts", 0, [&](const char *s){dump_dts = true;});
   parser.option(0, "extlib", 1, [&](const char *s){
     void *lib = dlopen(s, RTLD_NOW | RTLD_GLOBAL);
     if (lib == NULL) {
@@ -71,17 +75,18 @@ int main(int argc, char** argv)
       exit(-1);
     }
   });
-  // I wanted to use --halted, but for some reason that doesn't work.
-  parser.option('H', 0, 0, [&](const char* s){halted = true;});
 
   auto argv1 = parser.parse(argv);
   std::vector<std::string> htif_args(argv1, (const char*const*)argv + argc);
   sim_t s(isa, nprocs, mem_mb, halted, htif_args);
-  gdbserver_t gdbserver(9824, &s);
-  s.set_gdbserver(&gdbserver);
+  std::unique_ptr<gdbserver_t> gdbserver;
+  if (gdb_port) {
+    gdbserver = std::unique_ptr<gdbserver_t>(new gdbserver_t(gdb_port, &s));
+    s.set_gdbserver(&(*gdbserver));
+  }
 
-  if (dump_config_string) {
-    printf("%s", s.get_config_string());
+  if (dump_dts) {
+    printf("%s", s.get_dts());
     return 0;
   }