Merge with main repository.
This commit is contained in:
@@ -41,8 +41,15 @@ class System(SimObject):
|
||||
type = 'System'
|
||||
|
||||
@classmethod
|
||||
def swig_objdecls(cls, code):
|
||||
code('%include "python/swig/system.i"')
|
||||
def export_method_cxx_predecls(cls, code):
|
||||
code('#include "sim/system.hh"')
|
||||
|
||||
@classmethod
|
||||
def export_methods(cls, code):
|
||||
code('''
|
||||
Enums::MemoryMode getMemoryMode();
|
||||
void setMemoryMode(Enums::MemoryMode mode);
|
||||
''')
|
||||
|
||||
physmem = Param.PhysicalMemory("Physical Memory")
|
||||
mem_mode = Param.MemoryMode('atomic', "The mode the memory system is in")
|
||||
|
||||
@@ -159,7 +159,7 @@ Process::Process(ProcessParams * params)
|
||||
|
||||
mmap_start = mmap_end = 0;
|
||||
nxm_start = nxm_end = 0;
|
||||
pTable = new PageTable(this);
|
||||
pTable = new PageTable(name(), M5_pid);
|
||||
// other parameters will be initialized when the program is loaded
|
||||
}
|
||||
|
||||
@@ -318,13 +318,21 @@ Process::sim_fd_obj(int tgt_fd)
|
||||
return &fd_map[tgt_fd];
|
||||
}
|
||||
|
||||
void
|
||||
Process::allocateMem(Addr vaddr, int64_t size, bool clobber)
|
||||
{
|
||||
int npages = divCeil(size, (int64_t)VMPageSize);
|
||||
Addr paddr = system->allocPhysPages(npages);
|
||||
pTable->map(vaddr, paddr, size, clobber);
|
||||
}
|
||||
|
||||
bool
|
||||
Process::fixupStackFault(Addr vaddr)
|
||||
{
|
||||
// Check if this is already on the stack and there's just no page there
|
||||
// yet.
|
||||
if (vaddr >= stack_min && vaddr < stack_base) {
|
||||
pTable->allocate(roundDown(vaddr, VMPageSize), VMPageSize);
|
||||
allocateMem(roundDown(vaddr, VMPageSize), VMPageSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -337,7 +345,7 @@ Process::fixupStackFault(Addr vaddr)
|
||||
fatal("Maximum stack size exceeded\n");
|
||||
if (stack_base - stack_min > 8 * 1024 * 1024)
|
||||
fatal("Over max stack size for one thread\n");
|
||||
pTable->allocate(stack_min, TheISA::PageBytes);
|
||||
allocateMem(stack_min, TheISA::PageBytes);
|
||||
inform("Increasing stack size by one page.");
|
||||
};
|
||||
return true;
|
||||
|
||||
@@ -203,6 +203,8 @@ class Process : public SimObject
|
||||
|
||||
virtual void syscall(int64_t callnum, ThreadContext *tc) = 0;
|
||||
|
||||
void allocateMem(Addr vaddr, int64_t size, bool clobber = false);
|
||||
|
||||
/// Attempt to fix up a fault at vaddr by allocating a page on the stack.
|
||||
/// @return Whether the fault has been fixed.
|
||||
bool fixupStackFault(Addr vaddr);
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2005 The Regents of The University of Michigan
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met: redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer;
|
||||
* redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution;
|
||||
* neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors: Steve Reinhardt
|
||||
* Nathan Binkert
|
||||
*/
|
||||
|
||||
#ifndef __SIM_SIM_OBJECT_PARAMS_HH__
|
||||
#define __SIM_SIM_OBJECT_PARAMS_HH__
|
||||
|
||||
#ifndef PY_VERSION
|
||||
struct PyObject;
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
struct EventQueue;
|
||||
|
||||
struct SimObjectParams
|
||||
{
|
||||
SimObjectParams()
|
||||
{
|
||||
extern EventQueue mainEventQueue;
|
||||
eventq = &mainEventQueue;
|
||||
}
|
||||
virtual ~SimObjectParams() {}
|
||||
|
||||
std::string name;
|
||||
PyObject *pyobj;
|
||||
EventQueue *eventq;
|
||||
};
|
||||
|
||||
|
||||
#endif // __SIM_SIM_OBJECT_PARAMS_HH__
|
||||
@@ -166,8 +166,7 @@ brkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
|
||||
for (ChunkGenerator gen(p->brk_point, new_brk - p->brk_point,
|
||||
VMPageSize); !gen.done(); gen.next()) {
|
||||
if (!p->pTable->translate(gen.addr()))
|
||||
p->pTable->allocate(roundDown(gen.addr(), VMPageSize),
|
||||
VMPageSize);
|
||||
p->allocateMem(roundDown(gen.addr(), VMPageSize), VMPageSize);
|
||||
|
||||
// if the address is already there, zero it out
|
||||
else {
|
||||
|
||||
@@ -678,7 +678,7 @@ mremapFunc(SyscallDesc *desc, int callnum, LiveProcess *process, ThreadContext *
|
||||
if (new_length > old_length) {
|
||||
if ((start + old_length) == process->mmap_end) {
|
||||
uint64_t diff = new_length - old_length;
|
||||
process->pTable->allocate(process->mmap_end, diff);
|
||||
process->allocateMem(process->mmap_end, diff);
|
||||
process->mmap_end += diff;
|
||||
return start;
|
||||
} else {
|
||||
@@ -692,15 +692,15 @@ mremapFunc(SyscallDesc *desc, int callnum, LiveProcess *process, ThreadContext *
|
||||
process->mmap_end, process->mmap_end + new_length, new_length);
|
||||
start = process->mmap_end;
|
||||
// add on the remaining unallocated pages
|
||||
process->pTable->allocate(start + old_length, new_length - old_length);
|
||||
process->allocateMem(start + old_length,
|
||||
new_length - old_length);
|
||||
process->mmap_end += new_length;
|
||||
warn("returning %08p as start\n", start);
|
||||
return start;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
process->pTable->deallocate(start + new_length, old_length -
|
||||
new_length);
|
||||
process->pTable->unmap(start + new_length, old_length - new_length);
|
||||
return start;
|
||||
}
|
||||
}
|
||||
@@ -1028,20 +1028,45 @@ mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (start != 0) {
|
||||
warn("mmap: ignoring suggested map address 0x%x, using 0x%x",
|
||||
start, p->mmap_end);
|
||||
// are we ok with clobbering existing mappings? only set this to
|
||||
// true if the user has been warned.
|
||||
bool clobber = false;
|
||||
|
||||
// try to use the caller-provided address if there is one
|
||||
bool use_provided_address = (start != 0);
|
||||
|
||||
if (use_provided_address) {
|
||||
// check to see if the desired address is already in use
|
||||
if (!p->pTable->isUnmapped(start, length)) {
|
||||
// there are existing mappings in the desired range
|
||||
// whether we clobber them or not depends on whether the caller
|
||||
// specified MAP_FIXED
|
||||
if (flags & OS::TGT_MAP_FIXED) {
|
||||
// MAP_FIXED specified: clobber existing mappings
|
||||
warn("mmap: MAP_FIXED at 0x%x overwrites existing mappings\n",
|
||||
start);
|
||||
clobber = true;
|
||||
} else {
|
||||
// MAP_FIXED not specified: ignore suggested start address
|
||||
warn("mmap: ignoring suggested map address 0x%x\n", start);
|
||||
use_provided_address = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pick next address from our "mmap region"
|
||||
if (OS::mmapGrowsDown()) {
|
||||
start = p->mmap_end - length;
|
||||
p->mmap_end = start;
|
||||
} else {
|
||||
start = p->mmap_end;
|
||||
p->mmap_end += length;
|
||||
if (!use_provided_address) {
|
||||
// no address provided, or provided address unusable:
|
||||
// pick next address from our "mmap region"
|
||||
if (OS::mmapGrowsDown()) {
|
||||
start = p->mmap_end - length;
|
||||
p->mmap_end = start;
|
||||
} else {
|
||||
start = p->mmap_end;
|
||||
p->mmap_end += length;
|
||||
}
|
||||
}
|
||||
p->pTable->allocate(start, length);
|
||||
|
||||
p->allocateMem(start, length, clobber);
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
@@ -261,10 +261,10 @@ System::replaceThreadContext(ThreadContext *tc, int context_id)
|
||||
}
|
||||
|
||||
Addr
|
||||
System::new_page()
|
||||
System::allocPhysPages(int npages)
|
||||
{
|
||||
Addr return_addr = pagePtr << LogVMPageSize;
|
||||
++pagePtr;
|
||||
pagePtr += npages;
|
||||
if (return_addr >= physmem->size())
|
||||
fatal("Out of memory, please increase size of physical memory.");
|
||||
return return_addr;
|
||||
|
||||
@@ -271,7 +271,9 @@ class System : public SimObject
|
||||
*/
|
||||
Addr getKernelEntry() const { return kernelEntry; }
|
||||
|
||||
Addr new_page();
|
||||
/// Allocate npages contiguous unused physical pages
|
||||
/// @return Starting address of first page
|
||||
Addr allocPhysPages(int npages);
|
||||
|
||||
int registerThreadContext(ThreadContext *tc, int assigned=-1);
|
||||
void replaceThreadContext(ThreadContext *tc, int context_id);
|
||||
|
||||
Reference in New Issue
Block a user