process.cc (11800:54436a1784dc) process.cc (11851:824055fe6b30)
1/*
2 * Copyright (c) 2004-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;

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

42#include "sim/process.hh"
43#include "sim/process_impl.hh"
44#include "sim/syscall_return.hh"
45#include "sim/system.hh"
46
47using namespace std;
48using namespace MipsISA;
49
1/*
2 * Copyright (c) 2004-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;

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

42#include "sim/process.hh"
43#include "sim/process_impl.hh"
44#include "sim/syscall_return.hh"
45#include "sim/system.hh"
46
47using namespace std;
48using namespace MipsISA;
49
50MipsLiveProcess::MipsLiveProcess(LiveProcessParams * params,
51 ObjectFile *objFile)
52 : LiveProcess(params, objFile)
50MipsProcess::MipsProcess(ProcessParams * params, ObjectFile *objFile)
51 : Process(params, objFile)
53{
54 // Set up stack. On MIPS, stack starts at the top of kuseg
55 // user address space. MIPS stack grows down from here
56 stack_base = 0x7FFFFFFF;
57
58 // Set pointer for next thread stack. Reserve 8M for main stack.
59 next_thread_stack_base = stack_base - (8 * 1024 * 1024);
60
61 // Set up break point (Top of Heap)
62 brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
63 brk_point = roundUp(brk_point, PageBytes);
64
65 // Set up region for mmaps. Start it 1GB above the top of the heap.
66 mmap_end = brk_point + 0x40000000L;
67}
68
69void
52{
53 // Set up stack. On MIPS, stack starts at the top of kuseg
54 // user address space. MIPS stack grows down from here
55 stack_base = 0x7FFFFFFF;
56
57 // Set pointer for next thread stack. Reserve 8M for main stack.
58 next_thread_stack_base = stack_base - (8 * 1024 * 1024);
59
60 // Set up break point (Top of Heap)
61 brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
62 brk_point = roundUp(brk_point, PageBytes);
63
64 // Set up region for mmaps. Start it 1GB above the top of the heap.
65 mmap_end = brk_point + 0x40000000L;
66}
67
68void
70MipsLiveProcess::initState()
69MipsProcess::initState()
71{
70{
72 LiveProcess::initState();
71 Process::initState();
73
74 argsInit<uint32_t>(PageBytes);
75}
76
77template<class IntType>
78void
72
73 argsInit<uint32_t>(PageBytes);
74}
75
76template<class IntType>
77void
79MipsLiveProcess::argsInit(int pageSize)
78MipsProcess::argsInit(int pageSize)
80{
81 int intSize = sizeof(IntType);
82
83 // Patch the ld_bias for dynamic executables.
84 updateBias();
85
86 // load object file into target memory
87 objFile->loadSections(initVirtMem);

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

186 setSyscallArg(tc, 1, argv_array_base);
187 tc->setIntReg(StackPointerReg, stack_min);
188
189 tc->pcState(getStartPC());
190}
191
192
193MipsISA::IntReg
79{
80 int intSize = sizeof(IntType);
81
82 // Patch the ld_bias for dynamic executables.
83 updateBias();
84
85 // load object file into target memory
86 objFile->loadSections(initVirtMem);

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

185 setSyscallArg(tc, 1, argv_array_base);
186 tc->setIntReg(StackPointerReg, stack_min);
187
188 tc->pcState(getStartPC());
189}
190
191
192MipsISA::IntReg
194MipsLiveProcess::getSyscallArg(ThreadContext *tc, int &i)
193MipsProcess::getSyscallArg(ThreadContext *tc, int &i)
195{
196 assert(i < 6);
197 return tc->readIntReg(FirstArgumentReg + i++);
198}
199
200void
194{
195 assert(i < 6);
196 return tc->readIntReg(FirstArgumentReg + i++);
197}
198
199void
201MipsLiveProcess::setSyscallArg(ThreadContext *tc,
202 int i, MipsISA::IntReg val)
200MipsProcess::setSyscallArg(ThreadContext *tc, int i, MipsISA::IntReg val)
203{
204 assert(i < 6);
205 tc->setIntReg(FirstArgumentReg + i, val);
206}
207
208void
201{
202 assert(i < 6);
203 tc->setIntReg(FirstArgumentReg + i, val);
204}
205
206void
209MipsLiveProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret)
207MipsProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret)
210{
211 if (sysret.successful()) {
212 // no error
213 tc->setIntReg(SyscallSuccessReg, 0);
214 tc->setIntReg(ReturnValueReg, sysret.returnValue());
215 } else {
216 // got an error, return details
217 tc->setIntReg(SyscallSuccessReg, (IntReg) -1);
218 tc->setIntReg(ReturnValueReg, sysret.errnoValue());
219 }
220}
208{
209 if (sysret.successful()) {
210 // no error
211 tc->setIntReg(SyscallSuccessReg, 0);
212 tc->setIntReg(ReturnValueReg, sysret.returnValue());
213 } else {
214 // got an error, return details
215 tc->setIntReg(SyscallSuccessReg, (IntReg) -1);
216 tc->setIntReg(ReturnValueReg, sysret.errnoValue());
217 }
218}