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 |
50MipsProcess::MipsProcess(ProcessParams * params, ObjectFile *objFile) 51 : Process(params, objFile) |
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 |
69MipsProcess::initState() |
70{ |
71 Process::initState(); |
72 73 argsInit<uint32_t>(PageBytes); 74} 75 76template<class IntType> 77void |
78MipsProcess::argsInit(int pageSize) |
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 |
193MipsProcess::getSyscallArg(ThreadContext *tc, int &i) |
194{ 195 assert(i < 6); 196 return tc->readIntReg(FirstArgumentReg + i++); 197} 198 199void |
200MipsProcess::setSyscallArg(ThreadContext *tc, int i, MipsISA::IntReg val) |
201{ 202 assert(i < 6); 203 tc->setIntReg(FirstArgumentReg + i, val); 204} 205 206void |
207MipsProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret) |
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} |