Deleted Added
sdiff udiff text old ( 11855:c706f4ab5dd7 ) new ( 11856:103e2f92c965 )
full compact
1/*
2 * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
3 * Copyright (c) 2012 ARM Limited
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license

--- 25 unchanged lines hidden (view full) ---

36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Authors: Nathan Binkert
42 * Steve Reinhardt
43 * Ali Saidi
44 * Brandon Potter
45 */
46
47#include "sim/process.hh"
48
49#include <fcntl.h>
50#include <unistd.h>
51
52#include <array>

--- 6 unchanged lines hidden (view full) ---

59#include "base/loader/symtab.hh"
60#include "base/statistics.hh"
61#include "config/the_isa.hh"
62#include "cpu/thread_context.hh"
63#include "mem/page_table.hh"
64#include "mem/se_translating_port_proxy.hh"
65#include "params/Process.hh"
66#include "sim/emul_driver.hh"
67#include "sim/fd_array.hh"
68#include "sim/fd_entry.hh"
69#include "sim/syscall_desc.hh"
70#include "sim/system.hh"
71
72#if THE_ISA == ALPHA_ISA
73#include "arch/alpha/linux/process.hh"
74#elif THE_ISA == SPARC_ISA
75#include "arch/sparc/linux/process.hh"
76#include "arch/sparc/solaris/process.hh"

--- 11 unchanged lines hidden (view full) ---

88#else
89#error "THE_ISA not set"
90#endif
91
92
93using namespace std;
94using namespace TheISA;
95
96Process::Process(ProcessParams * params, ObjectFile * obj_file)
97 : SimObject(params), system(params->system),
98 brk_point(0), stack_base(0), stack_size(0), stack_min(0),
99 max_stack_size(params->max_stack_size),
100 next_thread_stack_base(0),
101 useArchPT(params->useArchPT),
102 kvmInSE(params->kvmInSE),
103 pTable(useArchPT ?
104 static_cast<PageTableBase *>(new ArchPageTable(name(), params->pid,
105 system)) :
106 static_cast<PageTableBase *>(new FuncPageTable(name(), params->pid))),
107 initVirtMem(system->getSystemPort(), this,
108 SETranslatingPortProxy::Always),
109 objFile(obj_file),
110 argv(params->cmd), envp(params->env), cwd(params->cwd),
111 executable(params->executable),
112 _uid(params->uid), _euid(params->euid),
113 _gid(params->gid), _egid(params->egid),
114 _pid(params->pid), _ppid(params->ppid),
115 drivers(params->drivers),
116 fds(make_shared<FDArray>(params->input, params->output, params->errout))
117{
118 mmap_end = 0;
119
120 // load up symbols, if any... these may be used for debugging or
121 // profiling.
122 if (!debugSymbolTable) {
123 debugSymbolTable = new SymbolTable();
124 if (!objFile->loadGlobalSymbols(debugSymbolTable) ||
125 !objFile->loadLocalSymbols(debugSymbolTable) ||
126 !objFile->loadWeakSymbols(debugSymbolTable)) {

--- 12 unchanged lines hidden (view full) ---

139 using namespace Stats;
140
141 num_syscalls
142 .name(name() + ".num_syscalls")
143 .desc("Number of system calls")
144 ;
145}
146
147ThreadContext *
148Process::findFreeContext()
149{
150 for (int id : contextIds) {
151 ThreadContext *tc = system->getThreadContext(id);
152 if (tc->status() == ThreadContext::Halted)
153 return tc;
154 }

--- 13 unchanged lines hidden (view full) ---

168 tc->activate();
169
170 pTable->initState(tc);
171}
172
173DrainState
174Process::drain()
175{
176 fds->updateFileOffsets();
177 return DrainState::Drained;
178}
179
180void
181Process::allocateMem(Addr vaddr, int64_t size, bool clobber)
182{
183 int npages = divCeil(size, (int64_t)PageBytes);
184 Addr paddr = system->allocPhysPages(npages);
185 pTable->map(vaddr, paddr, size,
186 clobber ? PageTableBase::Clobber : PageTableBase::Zero);
187}
188

--- 18 unchanged lines hidden (view full) ---

207 inform("Increasing stack size by one page.");
208 };
209 return true;
210 }
211 return false;
212}
213
214void
215Process::serialize(CheckpointOut &cp) const
216{
217 SERIALIZE_SCALAR(brk_point);
218 SERIALIZE_SCALAR(stack_base);
219 SERIALIZE_SCALAR(stack_size);
220 SERIALIZE_SCALAR(stack_min);
221 SERIALIZE_SCALAR(next_thread_stack_base);
222 SERIALIZE_SCALAR(mmap_end);
223 pTable->serialize(cp);
224 /**
225 * Checkpoints for file descriptors currently do not work. Need to
226 * come back and fix them at a later date.
227 */
228
229 warn("Checkpoints for file descriptors currently do not work.");
230#if 0
231 for (int x = 0; x < fds->getSize(); x++)
232 (*fds)[x].serializeSection(cp, csprintf("FDEntry%d", x));
233#endif
234
235}
236
237void
238Process::unserialize(CheckpointIn &cp)
239{
240 UNSERIALIZE_SCALAR(brk_point);
241 UNSERIALIZE_SCALAR(stack_base);
242 UNSERIALIZE_SCALAR(stack_size);
243 UNSERIALIZE_SCALAR(stack_min);
244 UNSERIALIZE_SCALAR(next_thread_stack_base);
245 UNSERIALIZE_SCALAR(mmap_end);
246 pTable->unserialize(cp);
247 /**
248 * Checkpoints for file descriptors currently do not work. Need to
249 * come back and fix them at a later date.
250 */
251 warn("Checkpoints for file descriptors currently do not work.");
252#if 0
253 for (int x = 0; x < fds->getSize(); x++)
254 (*fds)[x]->unserializeSection(cp, csprintf("FDEntry%d", x));
255 fds->restoreFileOffsets();
256#endif
257 // The above returns a bool so that you could do something if you don't
258 // find the param in the checkpoint if you wanted to, like set a default
259 // but in this case we'll just stick with the instantiated value if not
260 // found.
261}
262
263bool
264Process::map(Addr vaddr, Addr paddr, int size, bool cacheable)

--- 250 unchanged lines hidden ---