Deleted Added
sdiff udiff text old ( 11854:0e94e16e26ea ) new ( 11886:43b882cada33 )
full compact
1/*
2 * Copyright (c) 2003-2004 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;

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

45#include "sim/system.hh"
46
47using namespace AlphaISA;
48using namespace std;
49
50AlphaProcess::AlphaProcess(ProcessParams *params, ObjectFile *objFile)
51 : Process(params, objFile)
52{
53 memState->brkPoint = objFile->dataBase() + objFile->dataSize() +
54 objFile->bssSize();
55 memState->brkPoint = roundUp(memState->brkPoint, PageBytes);
56
57 // Set up stack. On Alpha, stack goes below text section. This
58 // code should get moved to some architecture-specific spot.
59 memState->stackBase = objFile->textBase() - (409600+4096);
60
61 // Set up region for mmaps. Tru64 seems to start just above 0 and
62 // grow up from there.
63 memState->mmapEnd = 0x10000;
64
65 // Set pointer for next thread stack. Reserve 8M for main stack.
66 memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024);
67
68}
69
70void
71AlphaProcess::argsInit(int intSize, int pageSize)
72{
73 // Patch the ld_bias for dynamic executables.
74 updateBias();

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

126 auxv_array_size +
127 arg_data_size +
128 env_data_size;
129
130 if (space_needed < 32*1024)
131 space_needed = 32*1024;
132
133 // set bottom of stack
134 memState->stackMin = memState->stackBase - space_needed;
135 // align it
136 memState->stackMin = roundDown(memState->stackMin, pageSize);
137 memState->stackSize = memState->stackBase - memState->stackMin;
138 // map memory
139 allocateMem(memState->stackMin, roundUp(memState->stackSize, pageSize));
140
141 // map out initial stack contents
142 Addr argv_array_base = memState->stackMin + intSize; // room for argc
143 Addr envp_array_base = argv_array_base + argv_array_size;
144 Addr auxv_array_base = envp_array_base + envp_array_size;
145 Addr arg_data_base = auxv_array_base + auxv_array_size;
146 Addr env_data_base = arg_data_base + arg_data_size;
147
148 // write contents to stack
149 uint64_t argc = argv.size();
150 if (intSize == 8)
151 argc = htog((uint64_t)argc);
152 else if (intSize == 4)
153 argc = htog((uint32_t)argc);
154 else
155 panic("Unknown int size");
156
157 initVirtMem.writeBlob(memState->stackMin, (uint8_t*)&argc, intSize);
158
159 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
160 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
161
162 //Copy the aux stuff
163 for (vector<auxv_t>::size_type x = 0; x < auxv.size(); x++) {
164 initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize,
165 (uint8_t*)&(auxv[x].a_type), intSize);
166 initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
167 (uint8_t*)&(auxv[x].a_val), intSize);
168 }
169
170 ThreadContext *tc = system->getThreadContext(contextIds[0]);
171
172 setSyscallArg(tc, 0, argc);
173 setSyscallArg(tc, 1, argv_array_base);
174 tc->setIntReg(StackPointerReg, memState->stackMin);
175
176 tc->pcState(getStartPC());
177}
178
179void
180AlphaProcess::setupASNReg()
181{
182 ThreadContext *tc = system->getThreadContext(contextIds[0]);

--- 64 unchanged lines hidden ---