process.hh (10929:b2bbfec74eca) | process.hh (10930:ddc3d96d6313) |
---|---|
1/* 2 * Copyright (c) 2014 Advanced Micro Devices, Inc. 3 * Copyright (c) 2001-2005 The Regents of The University of Michigan 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 19 unchanged lines hidden (view full) --- 28 * 29 * Authors: Nathan Binkert 30 * Steve Reinhardt 31 */ 32 33#ifndef __PROCESS_HH__ 34#define __PROCESS_HH__ 35 | 1/* 2 * Copyright (c) 2014 Advanced Micro Devices, Inc. 3 * Copyright (c) 2001-2005 The Regents of The University of Michigan 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 19 unchanged lines hidden (view full) --- 28 * 29 * Authors: Nathan Binkert 30 * Steve Reinhardt 31 */ 32 33#ifndef __PROCESS_HH__ 34#define __PROCESS_HH__ 35 |
36#include <array> |
|
36#include <string> 37#include <vector> 38 39#include "arch/registers.hh" 40#include "base/statistics.hh" 41#include "base/types.hh" 42#include "config/the_isa.hh" 43#include "mem/se_translating_port_proxy.hh" | 37#include <string> 38#include <vector> 39 40#include "arch/registers.hh" 41#include "base/statistics.hh" 42#include "base/types.hh" 43#include "config/the_isa.hh" 44#include "mem/se_translating_port_proxy.hh" |
45#include "sim/fd_entry.hh" |
|
44#include "sim/sim_object.hh" 45#include "sim/syscallreturn.hh" 46 47class PageTable; 48struct ProcessParams; 49struct LiveProcessParams; 50class SyscallDesc; 51class System; --- 78 unchanged lines hidden (view full) --- 130 131 // flag for using architecture specific page table 132 bool useArchPT; 133 // running KvmCPU in SE mode requires special initialization 134 bool kvmInSE; 135 136 PageTableBase* pTable; 137 | 46#include "sim/sim_object.hh" 47#include "sim/syscallreturn.hh" 48 49class PageTable; 50struct ProcessParams; 51struct LiveProcessParams; 52class SyscallDesc; 53class System; --- 78 unchanged lines hidden (view full) --- 132 133 // flag for using architecture specific page table 134 bool useArchPT; 135 // running KvmCPU in SE mode requires special initialization 136 bool kvmInSE; 137 138 PageTableBase* pTable; 139 |
138 class FdMap : public Serializable 139 { 140 public: 141 int fd; 142 std::string filename; 143 int mode; 144 int flags; 145 bool isPipe; 146 int readPipeSource; 147 uint64_t fileOffset; 148 EmulatedDriver *driver; 149 150 FdMap() 151 : fd(-1), filename("NULL"), mode(0), flags(0), 152 isPipe(false), readPipeSource(0), fileOffset(0), driver(NULL) 153 { } 154 155 void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE; 156 void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE; 157 }; 158 | |
159 protected: 160 /// Memory proxy for initialization (image loading) 161 SETranslatingPortProxy initVirtMem; 162 163 private: 164 static const int NUM_FDS = 1024; 165 166 // File descriptor remapping support. | 140 protected: 141 /// Memory proxy for initialization (image loading) 142 SETranslatingPortProxy initVirtMem; 143 144 private: 145 static const int NUM_FDS = 1024; 146 147 // File descriptor remapping support. |
167 FdMap *fd_map; | 148 std::shared_ptr<std::array<FDEntry, NUM_FDS>> fd_array; |
168 | 149 |
150 // Standard file descriptor options for initialization and checkpoints. 151 std::map<std::string, int> imap; 152 std::map<std::string, int> oemap; 153 |
|
169 public: | 154 public: |
170 // static helper functions to generate file descriptors for constructor 171 static int openInputFile(const std::string &filename); 172 static int openOutputFile(const std::string &filename); | 155 // inherit file descriptor map from another process (necessary for clone) 156 void inheritFdArray(Process *p); |
173 174 // override of virtual SimObject method: register statistics 175 virtual void regStats(); 176 177 // After getting registered with system object, tell process which 178 // system-wide context id it is assigned. 179 void assignThreadContext(int context_id) 180 { --- 6 unchanged lines hidden (view full) --- 187 // provide program name for debug messages 188 virtual const char *progName() const { return "<unknown>"; } 189 190 // generate new target fd for sim_fd 191 int alloc_fd(int sim_fd, const std::string& filename, int flags, int mode, 192 bool pipe); 193 194 // disassociate target fd with simulator fd and cleanup subsidiary fields | 157 158 // override of virtual SimObject method: register statistics 159 virtual void regStats(); 160 161 // After getting registered with system object, tell process which 162 // system-wide context id it is assigned. 163 void assignThreadContext(int context_id) 164 { --- 6 unchanged lines hidden (view full) --- 171 // provide program name for debug messages 172 virtual const char *progName() const { return "<unknown>"; } 173 174 // generate new target fd for sim_fd 175 int alloc_fd(int sim_fd, const std::string& filename, int flags, int mode, 176 bool pipe); 177 178 // disassociate target fd with simulator fd and cleanup subsidiary fields |
195 void free_fdmap_entry(int tgt_fd); | 179 void reset_fd_entry(int tgt_fd); |
196 197 // look up simulator fd for given target fd 198 int sim_fd(int tgt_fd); 199 | 180 181 // look up simulator fd for given target fd 182 int sim_fd(int tgt_fd); 183 |
200 // look up simulator fd_map object for a given target fd 201 FdMap *sim_fd_obj(int tgt_fd); | 184 // look up fd entry for a given target fd 185 FDEntry *get_fd_entry(int tgt_fd); |
202 203 // look up target fd for given host fd 204 // Assumes a 1:1 mapping between target file descriptor and host file 205 // descriptor. Given the current API, this must be true given that it's 206 // not possible to map multiple target file descriptors to the same host 207 // file descriptor 208 int tgt_fd(int sim_fd); 209 --- 148 unchanged lines hidden --- | 186 187 // look up target fd for given host fd 188 // Assumes a 1:1 mapping between target file descriptor and host file 189 // descriptor. Given the current API, this must be true given that it's 190 // not possible to map multiple target file descriptors to the same host 191 // file descriptor 192 int tgt_fd(int sim_fd); 193 --- 148 unchanged lines hidden --- |