83bb28637922f0393eeae6b63f0f3009146b0a1d
[riscv-isa-sim.git] / riscv / riscv-isa-run.cc
1 #include <unistd.h>
2 #include <fcntl.h>
3 #include "common.h"
4 #include "sim.h"
5 #include "applink.h"
6
7 int main(int argc, char** argv)
8 {
9 bool debug = false;
10 int nprocs = 1;
11 int fromhost_fd = -1, tohost_fd = -1;
12
13 for(int c; (c = getopt(argc,argv,"dpf:t:")) != -1; )
14 {
15 switch(c)
16 {
17 case 'd':
18 debug = true;
19 break;
20 case 'p':
21 nprocs = atoi(optarg);
22 break;
23 case 'f':
24 fromhost_fd = atoi(optarg);
25 break;
26 case 't':
27 tohost_fd = atoi(optarg);
28 break;
29 }
30 }
31
32 demand(fcntl(fromhost_fd,F_GETFD) >= 0, "fromhost file not open");
33 demand(fcntl(tohost_fd,F_GETFD) >= 0, "tohost file not open");
34
35 appserver_link_t applink(tohost_fd,fromhost_fd);
36
37 sim_t s(nprocs,MEMSIZE,&applink);
38 try
39 {
40 s.run(debug);
41 }
42 catch(quit_sim&)
43 {
44 }
45 }