process.cc (2686:f0d591379ac3) | process.cc (2715:4032e02b525e) |
---|---|
1/* 2 * Copyright (c) 2003-2004 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 18 unchanged lines hidden (view full) --- 27 * 28 * Authors: Gabe Black 29 * Ali Saidi 30 * Korey Sewell 31 */ 32 33#include "arch/mips/isa_traits.hh" 34#include "arch/mips/process.hh" | 1/* 2 * Copyright (c) 2003-2004 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 18 unchanged lines hidden (view full) --- 27 * 28 * Authors: Gabe Black 29 * Ali Saidi 30 * Korey Sewell 31 */ 32 33#include "arch/mips/isa_traits.hh" 34#include "arch/mips/process.hh" |
35#include "arch/mips/linux/process.hh" | |
36#include "base/loader/object_file.hh" 37#include "base/misc.hh" 38#include "cpu/thread_context.hh" | 35#include "base/loader/object_file.hh" 36#include "base/misc.hh" 37#include "cpu/thread_context.hh" |
39#include "sim/builder.hh" | |
40#include "sim/system.hh" 41 42using namespace std; 43using namespace MipsISA; 44 | 38#include "sim/system.hh" 39 40using namespace std; 41using namespace MipsISA; 42 |
45 46MipsLiveProcess * 47MipsLiveProcess::create(const std::string &nm, System *system, int stdin_fd, 48 int stdout_fd, int stderr_fd, std::string executable, 49 std::vector<std::string> &argv, std::vector<std::string> &envp) 50{ 51 MipsLiveProcess *process = NULL; 52 53 ObjectFile *objFile = createObjectFile(executable); 54 if (objFile == NULL) { 55 fatal("Can't load object file %s", executable); 56 } 57 58 59 if (objFile->getArch() != ObjectFile::Mips) 60 fatal("Object file does not match MIPS architecture."); 61 62 switch (objFile->getOpSys()) { 63 case ObjectFile::Linux: 64 process = new MipsLinuxProcess(nm, objFile, system, 65 stdin_fd, stdout_fd, stderr_fd, 66 argv, envp); 67 break; 68 69 default: 70 fatal("Unknown/unsupported operating system."); 71 } 72 73 if (process == NULL) 74 fatal("Unknown error creating process object."); 75 return process; 76} 77 | |
78MipsLiveProcess::MipsLiveProcess(const std::string &nm, ObjectFile *objFile, 79 System *_system, int stdin_fd, int stdout_fd, int stderr_fd, 80 std::vector<std::string> &argv, std::vector<std::string> &envp) 81 : LiveProcess(nm, objFile, _system, stdin_fd, stdout_fd, stderr_fd, 82 argv, envp) 83{ 84 // Set up stack. On MIPS, stack starts at the top of kuseg 85 // user address space. MIPS stack grows down from here --- 10 unchanged lines hidden (view full) --- 96 mmap_start = mmap_end = 0x10000; 97} 98 99void 100MipsLiveProcess::startup() 101{ 102 argsInit(MachineBytes, VMPageSize); 103} | 43MipsLiveProcess::MipsLiveProcess(const std::string &nm, ObjectFile *objFile, 44 System *_system, int stdin_fd, int stdout_fd, int stderr_fd, 45 std::vector<std::string> &argv, std::vector<std::string> &envp) 46 : LiveProcess(nm, objFile, _system, stdin_fd, stdout_fd, stderr_fd, 47 argv, envp) 48{ 49 // Set up stack. On MIPS, stack starts at the top of kuseg 50 // user address space. MIPS stack grows down from here --- 10 unchanged lines hidden (view full) --- 61 mmap_start = mmap_end = 0x10000; 62} 63 64void 65MipsLiveProcess::startup() 66{ 67 argsInit(MachineBytes, VMPageSize); 68} |
104 105 106 107 108BEGIN_DECLARE_SIM_OBJECT_PARAMS(MipsLiveProcess) 109 110 VectorParam<string> cmd; 111 Param<string> executable; 112 Param<string> input; 113 Param<string> output; 114 VectorParam<string> env; 115 SimObjectParam<System *> system; 116 117END_DECLARE_SIM_OBJECT_PARAMS(MipsLiveProcess) 118 119 120BEGIN_INIT_SIM_OBJECT_PARAMS(MipsLiveProcess) 121 122 INIT_PARAM(cmd, "command line (executable plus arguments)"), 123 INIT_PARAM(executable, "executable (overrides cmd[0] if set)"), 124 INIT_PARAM(input, "filename for stdin (dflt: use sim stdin)"), 125 INIT_PARAM(output, "filename for stdout/stderr (dflt: use sim stdout)"), 126 INIT_PARAM(env, "environment settings"), 127 INIT_PARAM(system, "system") 128 129END_INIT_SIM_OBJECT_PARAMS(MipsLiveProcess) 130 131 132CREATE_SIM_OBJECT(MipsLiveProcess) 133{ 134 string in = input; 135 string out = output; 136 137 // initialize file descriptors to default: same as simulator 138 int stdin_fd, stdout_fd, stderr_fd; 139 140 if (in == "stdin" || in == "cin") 141 stdin_fd = STDIN_FILENO; 142 else 143 stdin_fd = Process::openInputFile(input); 144 145 if (out == "stdout" || out == "cout") 146 stdout_fd = STDOUT_FILENO; 147 else if (out == "stderr" || out == "cerr") 148 stdout_fd = STDERR_FILENO; 149 else 150 stdout_fd = Process::openOutputFile(out); 151 152 stderr_fd = (stdout_fd != STDOUT_FILENO) ? stdout_fd : STDERR_FILENO; 153 154 return MipsLiveProcess::create(getInstanceName(), system, 155 stdin_fd, stdout_fd, stderr_fd, 156 (string)executable == "" ? cmd[0] : executable, 157 cmd, env); 158} 159 160 161REGISTER_SIM_OBJECT("MipsLiveProcess", MipsLiveProcess) 162 163 | |