* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Nathan Binkert
- * Steve Reinhardt
- * Brandon Potter
*/
#ifndef __PROCESS_HH__
#include <vector>
#include "arch/registers.hh"
+#include "base/loader/memory_image.hh"
#include "base/statistics.hh"
#include "base/types.hh"
#include "config/the_isa.hh"
class Process : public SimObject
{
+ protected:
+ void doSyscall(int64_t callnum, ThreadContext *tc, Fault *fault);
+
public:
Process(ProcessParams *params, EmulationPageTable *pTable,
ObjectFile *obj_file);
void serialize(CheckpointOut &cp) const override;
void unserialize(CheckpointIn &cp) override;
+ void init() override;
void initState() override;
DrainState drain() override;
- virtual void syscall(int64_t callnum, ThreadContext *tc, Fault *fault);
- virtual RegVal getSyscallArg(ThreadContext *tc, int &i) = 0;
- virtual RegVal getSyscallArg(ThreadContext *tc, int &i, int width);
- virtual void setSyscallArg(ThreadContext *tc, int i, RegVal val) = 0;
+ virtual void syscall(ThreadContext *tc, Fault *fault) = 0;
virtual void setSyscallReturn(ThreadContext *tc,
SyscallReturn return_value) = 0;
virtual SyscallDesc *getDesc(int callnum) = 0;
contextIds.push_back(context_id);
}
- // Find a free context to use
- ThreadContext *findFreeContext();
-
/**
* After delegating a thread context to a child process
* no longer should relate to the ThreadContext
SETranslatingPortProxy initVirtMem; // memory proxy for initial image load
+ /**
+ * Each instance of a Loader subclass will have a chance to try to load
+ * an object file when tryLoaders is called. If they can't because they
+ * aren't compatible with it (wrong arch, wrong OS, etc), then they
+ * silently fail by returning nullptr so other loaders can try.
+ */
+ class Loader
+ {
+ public:
+ Loader();
+
+ /* Loader instances are singletons. */
+ Loader(const Loader &) = delete;
+ void operator=(const Loader &) = delete;
+
+ virtual ~Loader() {}
+
+ /**
+ * Each subclass needs to implement this method. If the loader is
+ * compatible with the passed in object file, it should return the
+ * created Process object corresponding to it. If not, it should fail
+ * silently and return nullptr. If there's a non-compatibliity related
+ * error like file IO errors, etc., those should fail non-silently
+ * with a panic or fail as normal.
+ */
+ virtual Process *load(ProcessParams *params, ObjectFile *obj_file) = 0;
+ };
+
+ // Try all the Loader instance's "load" methods one by one until one is
+ // successful. If none are, complain and fail.
+ static Process *tryLoaders(ProcessParams *params, ObjectFile *obj_file);
+
ObjectFile *objFile;
+ MemoryImage image;
+ MemoryImage interpImage;
std::vector<std::string> argv;
std::vector<std::string> envp;
std::string executable;