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