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/translating_port.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// current number of allocated processes
81int num_processes = 0;
82
83template<class IntType>
84AuxVector<IntType>::AuxVector(IntType type, IntType val)
85{
86 a_type = TheISA::htog(type);
87 a_val = TheISA::htog(val);
88}
89
90template class AuxVector<uint32_t>;
91template class AuxVector<uint64_t>;
92
93Process::Process(ProcessParams * params)
94 : SimObject(params), system(params->system),
95 max_stack_size(params->max_stack_size)
96{
97 string in = params->input;
98 string out = params->output;
99 string err = params->errout;

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

155 // mark remaining fds as free
156 for (int i = 3; i <= MAX_FD; ++i) {
157 Process::FdMap *fdo = &fd_map[i];
158 fdo->fd = -1;
159 }
160
161 mmap_start = mmap_end = 0;
162 nxm_start = nxm_end = 0;
163 pTable = new PageTable(this);
164 // other parameters will be initialized when the program is loaded
165}
166
167
168void
169Process::regStats()
170{
171 using namespace Stats;

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

230 fatal("Process %s is not associated with any HW contexts!\n", name());
231
232 // first thread context for this process... initialize & enable
233 ThreadContext *tc = system->getThreadContext(contextIds[0]);
234
235 // mark this context as active so it will start ticking.
236 tc->activate(0);
237
238 Port *mem_port;
239 mem_port = system->physmem->getPort("functional");
240 initVirtMem = new TranslatingPort("process init port", this,
241 TranslatingPort::Always);
242 mem_port->setPeer(initVirtMem);
243 initVirtMem->setPeer(mem_port);
244}
245
246// map simulator fd sim_fd to target fd tgt_fd
247void
248Process::dup_fd(int sim_fd, int tgt_fd)
249{
250 if (tgt_fd < 0 || tgt_fd > MAX_FD)
251 panic("Process::dup_fd tried to dup past MAX_FD (%d)", tgt_fd);

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

314Process::sim_fd_obj(int tgt_fd)
315{
316 if (tgt_fd < 0 || tgt_fd > MAX_FD)
317 return NULL;
318
319 return &fd_map[tgt_fd];
320}
321
322bool
323Process::fixupStackFault(Addr vaddr)
324{
325 // Check if this is already on the stack and there's just no page there
326 // yet.
327 if (vaddr >= stack_min && vaddr < stack_base) {
328 pTable->allocate(roundDown(vaddr, VMPageSize), VMPageSize);
329 return true;
330 }
331
332 // We've accessed the next page of the stack, so extend it to include
333 // this address.
334 if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
335 while (vaddr < stack_min) {
336 stack_min -= TheISA::PageBytes;
337 if (stack_base - stack_min > max_stack_size)
338 fatal("Maximum stack size exceeded\n");
339 if (stack_base - stack_min > 8 * 1024 * 1024)
340 fatal("Over max stack size for one thread\n");
341 pTable->allocate(stack_min, TheISA::PageBytes);
342 inform("Increasing stack size by one page.");
343 };
344 return true;
345 }
346 warn("Not extending stack: address %#x isn't at the end of the stack.",
347 vaddr);
348 return false;
349}
350
351// find all offsets for currently open files and save them
352void
353Process::fix_file_offsets()
354{
355 Process::FdMap *fdo_stdin = &fd_map[STDIN_FILENO];

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

565 debugSymbolTable = NULL;
566 }
567 }
568}
569
570void
571LiveProcess::syscall(int64_t callnum, ThreadContext *tc)
572{
573#if !FULL_SYSTEM
574 num_syscalls++;
575
576 SyscallDesc *desc = getDesc(callnum);
577 if (desc == NULL)
578 fatal("Syscall %d out of range", callnum);
579
580 desc->doSyscall(callnum, this, tc);
581#endif
582}
583
584IntReg
585LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
586{
587 return getSyscallArg(tc, i);
588}
589

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

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

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

710 break;
711
712 default:
713 fatal("Unknown/unsupported operating system.");
714 }
715#else
716#error "THE_ISA not set"
717#endif
718#endif
719
720 if (process == NULL)
721 fatal("Unknown error creating process object.");
722 return process;
723}
724
725LiveProcess *
726LiveProcessParams::create()
727{
728 return LiveProcess::create(this);
729}