Add hook to call map() on Process from python.

This enables configuration scripts to set up mappings
from process virtual addresses to specific physical
addresses in SE mode.  This feature is needed to
support modeling of user-accessible memories or
devices in SE mode, avoiding the complexities of FS
mode and the need to write a device driver.
This commit is contained in:
Steve Reinhardt 2012-07-10 22:51:54 -07:00
parent 645fa9c262
commit 2e47aaabc0
3 changed files with 31 additions and 0 deletions

View file

@ -39,6 +39,14 @@ class Process(SimObject):
system = Param.System(Parent.any, "system process will run on") system = Param.System(Parent.any, "system process will run on")
max_stack_size = Param.MemorySize('64MB', 'maximum size of the stack') max_stack_size = Param.MemorySize('64MB', 'maximum size of the stack')
@classmethod
def export_method_cxx_predecls(cls, code):
code('#include "sim/process.hh"')
@classmethod
def export_methods(cls, code):
code('bool map(Addr vaddr, Addr paddr, int size);')
class LiveProcess(Process): class LiveProcess(Process):
type = 'LiveProcess' type = 'LiveProcess'
executable = Param.String('', "executable (overrides cmd[0] if set)") executable = Param.String('', "executable (overrides cmd[0] if set)")

View file

@ -545,6 +545,14 @@ Process::unserialize(Checkpoint *cp, const std::string &section)
} }
bool
Process::map(Addr vaddr, Addr paddr, int size)
{
pTable->map(vaddr, paddr, size);
return true;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// //
// LiveProcess member definitions // LiveProcess member definitions

View file

@ -210,6 +210,21 @@ class Process : public SimObject
/// @return Whether the fault has been fixed. /// @return Whether the fault has been fixed.
bool fixupStackFault(Addr vaddr); bool fixupStackFault(Addr vaddr);
/**
* Map a contiguous range of virtual addresses in this process's
* address space to a contiguous range of physical addresses.
* This function exists primarily to enable exposing the map
* operation to python, so that configuration scripts can set up
* mappings in SE mode.
*
* @param vaddr The starting virtual address of the range.
* @param paddr The starting physical address of the range.
* @param size The length of the range in bytes.
* @return True if the map operation was successful. (At this
* point in time, the map operation always succeeds.)
*/
bool map(Addr vaddr, Addr paddr, int size);
void serialize(std::ostream &os); void serialize(std::ostream &os);
void unserialize(Checkpoint *cp, const std::string &section); void unserialize(Checkpoint *cp, const std::string &section);
}; };