-Process::Process(ProcessParams * params)
- : SimObject(params), system(params->system),
- brk_point(0), stack_base(0), stack_size(0), stack_min(0),
- max_stack_size(params->max_stack_size),
- next_thread_stack_base(0),
- M5_pid(system->allocatePID()),
- useArchPT(params->useArchPT),
- kvmInSE(params->kvmInSE),
- pTable(useArchPT ?
- static_cast<PageTableBase *>(new ArchPageTable(name(), M5_pid, system)) :
- static_cast<PageTableBase *>(new FuncPageTable(name(), M5_pid)) ),
- initVirtMem(system->getSystemPort(), this,
- SETranslatingPortProxy::Always),
- fd_array(make_shared<array<FDEntry, NUM_FDS>>()),
- imap {{"", -1},
- {"cin", STDIN_FILENO},
- {"stdin", STDIN_FILENO}},
- oemap{{"", -1},
- {"cout", STDOUT_FILENO},
- {"stdout", STDOUT_FILENO},
- {"cerr", STDERR_FILENO},
- {"stderr", STDERR_FILENO}}
-{
- int sim_fd;
- std::map<string,int>::iterator it;
-
- // Search through the input options and set fd if match is found;
- // otherwise, open an input file and seek to location.
- FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
- if ((it = imap.find(params->input)) != imap.end())
- sim_fd = it->second;
- else
- sim_fd = openInputFile(params->input);
- fde_stdin->set(sim_fd, params->input, O_RDONLY, -1, false);
-
- // Search through the output/error options and set fd if match is found;
- // otherwise, open an output file and seek to location.
- FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
- if ((it = oemap.find(params->output)) != oemap.end())
- sim_fd = it->second;
- else
- sim_fd = openOutputFile(params->output);
- fde_stdout->set(sim_fd, params->output, O_WRONLY | O_CREAT | O_TRUNC,
- 0664, false);
-
- FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
- if (params->output == params->errout)
- // Reuse the same file descriptor if these match.
- sim_fd = fde_stdout->fd;
- else if ((it = oemap.find(params->errout)) != oemap.end())
- sim_fd = it->second;
- else
- sim_fd = openOutputFile(params->errout);
- fde_stderr->set(sim_fd, params->errout, O_WRONLY | O_CREAT | O_TRUNC,
- 0664, false);
-
- mmap_end = 0;
- nxm_start = nxm_end = 0;
- // other parameters will be initialized when the program is loaded
-}