Deleted Added
sdiff udiff text old ( 8737:770ccf3af571 ) new ( 8766:b0773af78423 )
full compact
1/*
2 * Copyright (c) 2001-2005 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;

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

40#include "base/loader/symtab.hh"
41#include "base/intmath.hh"
42#include "base/statistics.hh"
43#include "config/full_system.hh"
44#include "config/the_isa.hh"
45#include "cpu/thread_context.hh"
46#include "mem/page_table.hh"
47#include "mem/physical.hh"
48#include "mem/se_translating_port_proxy.hh"
49#include "params/LiveProcess.hh"
50#include "params/Process.hh"
51#include "sim/debug.hh"
52#include "sim/process.hh"
53#include "sim/process_impl.hh"
54#include "sim/stats.hh"
55#include "sim/syscall_emul.hh"
56#include "sim/system.hh"

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

72#else
73#error "THE_ISA not set"
74#endif
75
76
77using namespace std;
78using namespace TheISA;
79
80//
81// The purpose of this code is to fake the loader & syscall mechanism
82// when there's no OS: thus there's no resone to use it in FULL_SYSTEM
83// mode when we do have an OS
84//
85#if FULL_SYSTEM
86#error "process.cc not compatible with FULL_SYSTEM"
87#endif
88
89// current number of allocated processes
90int num_processes = 0;
91
92template<class IntType>
93AuxVector<IntType>::AuxVector(IntType type, IntType val)
94{
95 a_type = TheISA::htog(type);
96 a_val = TheISA::htog(val);
97}
98
99template struct AuxVector<uint32_t>;
100template struct AuxVector<uint64_t>;
101
102Process::Process(ProcessParams * params)
103 : SimObject(params), system(params->system),
104 max_stack_size(params->max_stack_size)
105{
106 string in = params->input;
107 string out = params->output;
108 string err = params->errout;

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

164 // mark remaining fds as free
165 for (int i = 3; i <= MAX_FD; ++i) {
166 Process::FdMap *fdo = &fd_map[i];
167 fdo->fd = -1;
168 }
169
170 mmap_start = mmap_end = 0;
171 nxm_start = nxm_end = 0;
172 pTable = new PageTable(name(), M5_pid);
173 // other parameters will be initialized when the program is loaded
174}
175
176
177void
178Process::regStats()
179{
180 using namespace Stats;

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

239 fatal("Process %s is not associated with any HW contexts!\n", name());
240
241 // first thread context for this process... initialize & enable
242 ThreadContext *tc = system->getThreadContext(contextIds[0]);
243
244 // mark this context as active so it will start ticking.
245 tc->activate(0);
246
247 initVirtMem = new SETranslatingPortProxy(*system->getSystemPort(), this,
248 SETranslatingPortProxy::Always);
249}
250
251// map simulator fd sim_fd to target fd tgt_fd
252void
253Process::dup_fd(int sim_fd, int tgt_fd)
254{
255 if (tgt_fd < 0 || tgt_fd > MAX_FD)
256 panic("Process::dup_fd tried to dup past MAX_FD (%d)", tgt_fd);

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

319Process::sim_fd_obj(int tgt_fd)
320{
321 if (tgt_fd < 0 || tgt_fd > MAX_FD)
322 return NULL;
323
324 return &fd_map[tgt_fd];
325}
326
327void
328Process::allocateMem(Addr vaddr, int64_t size, bool clobber)
329{
330 int npages = divCeil(size, (int64_t)VMPageSize);
331 Addr paddr = system->allocPhysPages(npages);
332 pTable->map(vaddr, paddr, size, clobber);
333}
334
335bool
336Process::fixupStackFault(Addr vaddr)
337{
338 // Check if this is already on the stack and there's just no page there
339 // yet.
340 if (vaddr >= stack_min && vaddr < stack_base) {
341 allocateMem(roundDown(vaddr, VMPageSize), VMPageSize);
342 return true;
343 }
344
345 // We've accessed the next page of the stack, so extend it to include
346 // this address.
347 if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
348 while (vaddr < stack_min) {
349 stack_min -= TheISA::PageBytes;
350 if (stack_base - stack_min > max_stack_size)
351 fatal("Maximum stack size exceeded\n");
352 if (stack_base - stack_min > 8 * 1024 * 1024)
353 fatal("Over max stack size for one thread\n");
354 allocateMem(stack_min, TheISA::PageBytes);
355 inform("Increasing stack size by one page.");
356 };
357 return true;
358 }
359 return false;
360}
361
362// find all offsets for currently open files and save them
363void
364Process::fix_file_offsets()
365{
366 Process::FdMap *fdo_stdin = &fd_map[STDIN_FILENO];

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

576 debugSymbolTable = NULL;
577 }
578 }
579}
580
581void
582LiveProcess::syscall(int64_t callnum, ThreadContext *tc)
583{
584 num_syscalls++;
585
586 SyscallDesc *desc = getDesc(callnum);
587 if (desc == NULL)
588 fatal("Syscall %d out of range", callnum);
589
590 desc->doSyscall(callnum, this, tc);
591}
592
593IntReg
594LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
595{
596 return getSyscallArg(tc, i);
597}
598

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

608 fatal("Can't load object file %s", executable);
609 }
610
611 if (objFile->isDynamic())
612 fatal("Object file is a dynamic executable however only static "
613 "executables are supported!\n Please recompile your "
614 "executable as a static binary and try again.\n");
615
616#if THE_ISA == ALPHA_ISA
617 if (objFile->getArch() != ObjectFile::Alpha)
618 fatal("Object file architecture does not match compiled ISA (Alpha).");
619
620 switch (objFile->getOpSys()) {
621 case ObjectFile::Tru64:
622 process = new AlphaTru64Process(params, objFile);
623 break;

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

718 break;
719
720 default:
721 fatal("Unknown/unsupported operating system.");
722 }
723#else
724#error "THE_ISA not set"
725#endif
726
727
728 if (process == NULL)
729 fatal("Unknown error creating process object.");
730 return process;
731}
732
733LiveProcess *
734LiveProcessParams::create()
735{
736 return LiveProcess::create(this);
737}