Deleted Added
sdiff udiff text old ( 5941:e8a1f956d76c ) new ( 5956:a49d9413a9e8 )
full compact
1/*
2 * Copyright (c) 2003-2006 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;

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

93#include "base/loader/object_file.hh"
94#include "base/loader/elf_object.hh"
95#include "base/misc.hh"
96#include "base/trace.hh"
97#include "cpu/thread_context.hh"
98#include "mem/page_table.hh"
99#include "mem/translating_port.hh"
100#include "sim/process_impl.hh"
101#include "sim/system.hh"
102
103using namespace std;
104using namespace X86ISA;
105
106
107X86LiveProcess::X86LiveProcess(LiveProcessParams * params,
108 ObjectFile *objFile)
109 : LiveProcess(params, objFile)
110{
111 brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
112 brk_point = roundUp(brk_point, VMPageSize);
113
114 // Set pointer for next thread stack. Reserve 8M for main stack.
115 next_thread_stack_base = stack_base - (8 * 1024 * 1024);
116
117 // Set up stack. On X86_64 Linux, stack goes from the top of memory
118 // downward, less the hole for the kernel address space plus one page
119 // for undertermined purposes.
120 stack_base = (Addr)0x7FFFFFFFF000ULL;
121
122 // Set up region for mmaps. This was determined empirically and may not
123 // always be correct.
124 mmap_start = mmap_end = (Addr)0x2aaaaaaab000ULL;
125}
126
127void X86LiveProcess::handleTrap(int trapNum, ThreadContext *tc)
128{
129 switch(trapNum)
130 {
131 default:
132 panic("Unimplemented trap to operating system: trap number %#x.\n", trapNum);
133 }
134}
135
136void
137X86LiveProcess::startup()
138{
139 if (checkpointRestored)
140 return;
141
142 argsInit(sizeof(IntReg), VMPageSize);
143
144 for (int i = 0; i < contextIds.size(); i++) {
145 ThreadContext * tc = system->getThreadContext(contextIds[i]);
146
147 SegAttr dataAttr = 0;
148 dataAttr.writable = 1;
149 dataAttr.readable = 1;
150 dataAttr.expandDown = 0;

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

193 efer.nxe = 1; // Enable nx support.
194 efer.svme = 0; // Disable svm support for now. It isn't implemented.
195 efer.ffxsr = 1; // Turn on fast fxsave and fxrstor.
196 tc->setMiscReg(MISCREG_EFER, efer);
197 }
198}
199
200void
201X86LiveProcess::argsInit(int intSize, int pageSize)
202{
203 typedef AuxVector<uint64_t> auxv_t;
204 std::vector<auxv_t> auxv;
205
206 Process::startup();
207
208 string filename;
209 if(argv.size() < 1)
210 filename = "";
211 else
212 filename = argv[0];
213
214 //We want 16 byte alignment
215 uint64_t align = 16;

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

391 stack_min = roundDown(stack_min, align);
392 stack_size = stack_base - stack_min;
393
394 // map memory
395 pTable->allocate(roundDown(stack_min, pageSize),
396 roundUp(stack_size, pageSize));
397
398 // map out initial stack contents
399 Addr sentry_base = stack_base - sentry_size;
400 Addr file_name_base = sentry_base - file_name_size;
401 Addr env_data_base = file_name_base - env_data_size;
402 Addr arg_data_base = env_data_base - arg_data_size;
403 Addr aux_data_base = arg_data_base - info_block_padding - aux_data_size;
404 Addr auxv_array_base = aux_data_base - aux_array_size - aux_padding;
405 Addr envp_array_base = auxv_array_base - envp_array_size;
406 Addr argv_array_base = envp_array_base - argv_array_size;
407 Addr argc_base = argv_array_base - argc_size;
408
409 DPRINTF(Stack, "The addresses of items on the initial stack:\n");
410 DPRINTF(Stack, "0x%x - file name\n", file_name_base);
411 DPRINTF(Stack, "0x%x - env data\n", env_data_base);
412 DPRINTF(Stack, "0x%x - arg data\n", arg_data_base);
413 DPRINTF(Stack, "0x%x - aux data\n", aux_data_base);
414 DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base);
415 DPRINTF(Stack, "0x%x - envp array\n", envp_array_base);
416 DPRINTF(Stack, "0x%x - argv array\n", argv_array_base);
417 DPRINTF(Stack, "0x%x - argc \n", argc_base);
418 DPRINTF(Stack, "0x%x - stack min\n", stack_min);
419
420 // write contents to stack
421
422 // figure out argc
423 uint64_t argc = argv.size();
424 uint64_t guestArgc = X86ISA::htog(argc);
425
426 //Write out the sentry void *
427 uint64_t sentry_NULL = 0;
428 initVirtMem->writeBlob(sentry_base,
429 (uint8_t*)&sentry_NULL, sentry_size);
430
431 //Write the file name
432 initVirtMem->writeString(file_name_base, filename.c_str());
433
434 //Fix up the aux vector which points to the "platform" string
435 assert(auxv[auxv.size() - 1].a_type = M5_AT_PLATFORM);

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

465 tc->setPC(prog_entry);
466 tc->setNextPC(prog_entry + sizeof(MachInst));
467
468 //Align the "stack_min" to a page boundary.
469 stack_min = roundDown(stack_min, pageSize);
470
471// num_processes++;
472}