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; --- 39 unchanged lines hidden (view full) --- 48using namespace std; 49using namespace MipsISA; 50 51MipsProcess::MipsProcess(ProcessParams * params, ObjectFile *objFile) 52 : 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 memState->stackBase = 0x7FFFFFFF; |
57 58 // Set pointer for next thread stack. Reserve 8M for main stack. |
59 memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024); |
60 61 // Set up break point (Top of Heap) |
62 memState->brkPoint = objFile->dataBase() + objFile->dataSize() + 63 objFile->bssSize(); 64 memState->brkPoint = roundUp(memState->brkPoint, PageBytes); |
65 66 // Set up region for mmaps. Start it 1GB above the top of the heap. |
67 memState->mmapEnd = memState->brkPoint + 0x40000000L; |
68} 69 70void 71MipsProcess::initState() 72{ 73 Process::initState(); 74 75 argsInit<uint32_t>(PageBytes); --- 60 unchanged lines hidden (view full) --- 136 int space_needed = 137 argv_array_size + 138 envp_array_size + 139 auxv_array_size + 140 arg_data_size + 141 env_data_size; 142 143 // set bottom of stack |
144 memState->stackMin = memState->stackBase - space_needed; |
145 // align it |
146 memState->stackMin = roundDown(memState->stackMin, pageSize); 147 memState->stackSize = memState->stackBase - memState->stackMin; |
148 // map memory |
149 allocateMem(memState->stackMin, roundUp(memState->stackSize, pageSize)); |
150 151 // map out initial stack contents |
152 IntType argv_array_base = memState->stackMin + intSize; // room for argc |
153 IntType envp_array_base = argv_array_base + argv_array_size; 154 IntType auxv_array_base = envp_array_base + envp_array_size; 155 IntType arg_data_base = auxv_array_base + auxv_array_size; 156 IntType env_data_base = arg_data_base + arg_data_size; 157 158 // write contents to stack 159 IntType argc = argv.size(); 160 161 argc = htog((IntType)argc); 162 |
163 initVirtMem.writeBlob(memState->stackMin, (uint8_t*)&argc, intSize); |
164 165 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); 166 167 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); 168 169 // Copy the aux vector 170 for (typename vector<auxv_t>::size_type x = 0; x < auxv.size(); x++) { 171 initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize, --- 8 unchanged lines hidden (view full) --- 180 const Addr addr = auxv_array_base + 2 * intSize * (auxv.size() + i); 181 initVirtMem.writeBlob(addr, (uint8_t*)&zero, intSize); 182 } 183 184 ThreadContext *tc = system->getThreadContext(contextIds[0]); 185 186 setSyscallArg(tc, 0, argc); 187 setSyscallArg(tc, 1, argv_array_base); |
188 tc->setIntReg(StackPointerReg, memState->stackMin); |
189 190 tc->pcState(getStartPC()); 191} 192 193 194MipsISA::IntReg 195MipsProcess::getSyscallArg(ThreadContext *tc, int &i) 196{ --- 24 unchanged lines hidden --- |