41#include "debug/Stack.hh"
43#include "params/Process.hh"
53using namespace SparcISA;
146template<
class IntType>
150 int intSize =
sizeof(IntType);
154 std::string filename;
169 HwcapSparcMuldiv = 8,
174 HwcapSparcUltra3 = 32
177 const int64_t hwcap =
229 int file_name_size = filename.size() + 1;
231 const int numRandomBytes = 16;
232 int aux_data_size = numRandomBytes;
234 int env_data_size = 0;
235 for (
int i = 0;
i <
envp.size(); ++
i) {
236 env_data_size +=
envp[
i].size() + 1;
238 int arg_data_size = 0;
239 for (
int i = 0;
i <
argv.size(); ++
i) {
240 arg_data_size +=
argv[
i].size() + 1;
244 int base_info_block_size =
245 sentry_size + file_name_size + env_data_size + arg_data_size;
247 int info_block_size =
roundUp(base_info_block_size, align);
249 int info_block_padding = info_block_size - base_info_block_size;
252 int aux_array_size = intSize * 2 * (auxv.size() + 1);
254 int envp_array_size = intSize * (
envp.size() + 1);
255 int argv_array_size = intSize * (
argv.size() + 1);
257 int argc_size = intSize;
258 int window_save_size = intSize * 16;
270 int aligned_partial_size =
roundUp(frame_size, align);
271 int aux_padding = aligned_partial_size - frame_size;
288 IntType sentry_base =
memState->getStackBase() - sentry_size;
289 IntType file_name_base = sentry_base - file_name_size;
290 IntType env_data_base = file_name_base - env_data_size;
291 IntType arg_data_base = env_data_base - arg_data_size;
292 IntType aux_data_base = arg_data_base - info_block_padding - aux_data_size;
293 IntType auxv_array_base = aux_data_base - aux_array_size - aux_padding;
294 IntType envp_array_base = auxv_array_base - envp_array_size;
295 IntType argv_array_base = envp_array_base - argv_array_size;
296 IntType argc_base = argv_array_base - argc_size;
297 IntType window_save_base = argc_base - window_save_size;
299 DPRINTF(Stack,
"The addresses of items on the initial stack:\n");
300 DPRINTF(Stack,
"%#x - sentry NULL\n", sentry_base);
301 DPRINTF(Stack,
"filename = %s\n", filename);
302 DPRINTF(Stack,
"%#x - file name\n", file_name_base);
303 DPRINTF(Stack,
"%#x - env data\n", env_data_base);
304 DPRINTF(Stack,
"%#x - arg data\n", arg_data_base);
305 DPRINTF(Stack,
"%#x - auxv array\n", auxv_array_base);
306 DPRINTF(Stack,
"%#x - envp array\n", envp_array_base);
307 DPRINTF(Stack,
"%#x - argv array\n", argv_array_base);
308 DPRINTF(Stack,
"%#x - argc \n", argc_base);
309 DPRINTF(Stack,
"%#x - window save\n", window_save_base);
312 assert(window_save_base ==
memState->getStackMin());
317 IntType argc =
argv.size();
318 IntType guestArgc =
htobe(argc);
321 uint64_t sentry_NULL = 0;
322 initVirtMem->writeBlob(sentry_base, &sentry_NULL, sentry_size);
325 initVirtMem->writeString(file_name_base, filename.c_str());
328 for (
auto &aux: auxv) {
330 aux.val = aux_data_base;
334 Addr auxv_array_end = auxv_array_base;
335 for (
const auto &aux: auxv) {
336 initVirtMem->write(auxv_array_end, aux, ByteOrder::big);
337 auxv_array_end +=
sizeof(aux);
343 auxv_array_end +=
sizeof(zero);
350 initVirtMem->writeBlob(argc_base, &guestArgc, intSize);
378 SparcProcess::argsInit<uint64_t>(pageSize);
390 SparcProcess::argsInit<uint32_t>(pageSize);
std::unique_ptr< SETranslatingPortProxy > initVirtMem
std::shared_ptr< MemState > memState
std::vector< std::string > argv
std::vector< ContextID > contextIds
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
std::vector< std::string > envp
loader::ObjectFile * objFile
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void argsInit(int intSize, int pageSize)
void argsInit(int intSize, int pageSize)
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void argsInit(int pageSize)
SparcProcess(const ProcessParams ¶ms, loader::ObjectFile *objFile, Addr _StackBias)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
virtual void setReg(const RegId ®, RegVal val)
static constexpr T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
static constexpr T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
const Params & params() const
constexpr auto & StackPointerReg
constexpr RegId Canrestore
const MachInst spillHandler64[numSpillInsts]
@ MISCREG_MMU_P_CONTEXT
MMU Internal Registers.
@ MISCREG_ASI
Ancillary State Registers.
@ MISCREG_FSR
Floating Point Status Register.
const MachInst fillHandler64[numFillInsts]
const MachInst fillHandler32[numFillInsts]
const MachInst spillHandler32[numSpillInsts]
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void copyStringArray(std::vector< std::string > &strings, AddrType array_ptr, AddrType data_ptr, const ByteOrder bo, PortProxy &memProxy)
Declarations of a non-full system Page Table.
const std::string & name()