aboutsummaryrefslogtreecommitdiff
path: root/riscv/riscv-isa-run.cc
blob: 098e68b86a3a80fb36fdbbdf0df6c362aae467d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <unistd.h>
#include <fcntl.h>
#include "common.h"
#include "sim.h"
#include "applink.h"

int main(int argc, char** argv)
{
  bool debug = false;
  int nprocs = 1;
  int fromhost_fd = -1, tohost_fd = -1;

  for(int c; (c = getopt(argc,argv,"dpf:t:")) != -1; )
  {
    switch(c)
    {
      case 'd':
        debug = true;
        break;
      case 'p':
        nprocs = atoi(optarg);
        break;
      case 'f':
        fromhost_fd = atoi(optarg);
        break;
      case 't':
        tohost_fd = atoi(optarg);
        break;
    }
  }

  demand(fcntl(fromhost_fd,F_GETFD) >= 0, "fromhost file not open");
  demand(fcntl(tohost_fd,F_GETFD) >= 0, "tohost file not open");

  appserver_link_t applink(tohost_fd,fromhost_fd);

  sim_t s(nprocs,MEMSIZE,&applink);
  s.run(debug);
}