gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PhysicalMemory Class Reference

The physical memory encapsulates all memories in the system and provides basic functionality for accessing those memories without going through the memory system and interconnect. More...

#include <physical.hh>

Inheritance diagram for PhysicalMemory:
Serializable

Public Member Functions

 PhysicalMemory (const std::string &_name, const std::vector< AbstractMemory * > &_memories, bool mmap_using_noreserve)
 Create a physical memory object, wrapping a number of memories. More...
 
 ~PhysicalMemory ()
 Unmap all the backing store we have used. More...
 
const std::string name () const
 Return the name for debugging and for creation of sections for checkpointing. More...
 
bool isMemAddr (Addr addr) const
 Check if a physical address is within a range of a memory that is part of the global address map. More...
 
AddrRangeList getConfAddrRanges () const
 Get the memory ranges for all memories that are to be reported to the configuration table. More...
 
uint64_t totalSize () const
 Get the total physical memory size. More...
 
std::vector< BackingStoreEntrygetBackingStore () const
 Get the pointers to the backing store for external host access. More...
 
void access (PacketPtr pkt)
 Perform an untimed memory access and update all the state (e.g. More...
 
void functionalAccess (PacketPtr pkt)
 Perform an untimed memory read or write without changing anything but the memory itself. More...
 
void serialize (CheckpointOut &cp) const override
 Serialize all the memories in the system. More...
 
void serializeStore (CheckpointOut &cp, unsigned int store_id, AddrRange range, uint8_t *pmem) const
 Serialize a specific store. More...
 
void unserialize (CheckpointIn &cp) override
 Unserialize the memories in the system. More...
 
void unserializeStore (CheckpointIn &cp)
 Unserialize a specific backing store, identified by a section. More...
 
- Public Member Functions inherited from Serializable
 Serializable ()
 
virtual ~Serializable ()
 
void serializeSection (CheckpointOut &cp, const char *name) const
 Serialize an object into a new section. More...
 
void serializeSection (CheckpointOut &cp, const std::string &name) const
 
void unserializeSection (CheckpointIn &cp, const char *name)
 Unserialize an a child object. More...
 
void unserializeSection (CheckpointIn &cp, const std::string &name)
 

Private Member Functions

 PhysicalMemory (const PhysicalMemory &)
 
PhysicalMemoryoperator= (const PhysicalMemory &)
 
void createBackingStore (AddrRange range, const std::vector< AbstractMemory * > &_memories, bool conf_table_reported, bool in_addr_map, bool kvm_map)
 Create the memory region providing the backing store for a given address range that corresponds to a set of memories in the simulated system. More...
 

Private Attributes

std::string _name
 
AddrRangeMap< AbstractMemory * > addrMap
 
AddrRangeMap< AbstractMemory * >
::const_iterator 
rangeCache
 
std::vector< AbstractMemory * > memories
 
uint64_t size
 
const bool mmapUsingNoReserve
 
std::vector< BackingStoreEntrybackingStore
 

Additional Inherited Members

- Static Public Member Functions inherited from Serializable
static const std::string & currentSection ()
 Get the fully-qualified name of the active section. More...
 
static void serializeAll (const std::string &cpt_dir)
 
static void unserializeGlobals (CheckpointIn &cp)
 
- Static Public Attributes inherited from Serializable
static int ckptCount = 0
 
static int ckptMaxCount = 0
 
static int ckptPrevCount = -1
 

Detailed Description

The physical memory encapsulates all memories in the system and provides basic functionality for accessing those memories without going through the memory system and interconnect.

The physical memory is also responsible for providing the host system backingstore used by the memories in the simulated guest system. When the system is created, the physical memory allocates the backing store based on the address ranges that are populated in the system, and does so independent of how those map to actual memory controllers. Thus, the physical memory completely abstracts the mapping of the backing store of the host system and the address mapping in the guest system. This enables us to arbitrarily change the number of memory controllers, and their address mapping, as long as the ranges stay the same.

Definition at line 112 of file physical.hh.

Constructor & Destructor Documentation

PhysicalMemory::PhysicalMemory ( const PhysicalMemory )
private
PhysicalMemory::PhysicalMemory ( const std::string &  _name,
const std::vector< AbstractMemory * > &  _memories,
bool  mmap_using_noreserve 
)

Create a physical memory object, wrapping a number of memories.

PhysicalMemory::~PhysicalMemory ( )

Unmap all the backing store we have used.

Definition at line 229 of file physical.cc.

References backingStore, and ArmISA::s.

Member Function Documentation

void PhysicalMemory::access ( PacketPtr  pkt)

Perform an untimed memory access and update all the state (e.g.

locked addresses) and statistics accordingly. The packet is turned into a response if required.

Parameters
pktPacket performing the access

Definition at line 292 of file physical.cc.

References addr, AddrRangeMap< V >::end(), Packet::getAddr(), Packet::isRequest(), ArmISA::m, and rangeCache.

void PhysicalMemory::createBackingStore ( AddrRange  range,
const std::vector< AbstractMemory * > &  _memories,
bool  conf_table_reported,
bool  in_addr_map,
bool  kvm_map 
)
private

Create the memory region providing the backing store for a given address range that corresponds to a set of memories in the simulated system.

Parameters
rangeThe address range covered
memoriesThe memories this range maps to
kvm_mapShould KVM map this memory for the guest

Definition at line 186 of file physical.cc.

References backingStore, DPRINTF, fatal, AddrRange::interleaved(), ArmISA::m, mmapUsingNoReserve, panic_if(), AddrRange::size(), and AddrRange::to_string().

void PhysicalMemory::functionalAccess ( PacketPtr  pkt)

Perform an untimed memory read or write without changing anything but the memory itself.

No stats are affected by this access. In addition to normal accesses this also facilitates print requests.

Parameters
pktPacket performing the access

Definition at line 308 of file physical.cc.

References addr, AddrRangeMap< V >::end(), Packet::getAddr(), Packet::isRequest(), ArmISA::m, and rangeCache.

std::vector<BackingStoreEntry> PhysicalMemory::getBackingStore ( ) const
inline

Get the pointers to the backing store for external host access.

Note that memory in the guest should be accessed using access() or functionalAccess(). This interface is primarily intended for CPU models using hardware virtualization. Note that memories that are null are not present, and that the backing store may also contain memories that are not part of the OS-visible global address map and thus are allowed to overlap.

Returns
Pointers to the memory backing store

Definition at line 218 of file physical.hh.

References backingStore.

Referenced by KvmVM::delayedStartup().

AddrRangeList PhysicalMemory::getConfAddrRanges ( ) const

Get the memory ranges for all memories that are to be reported to the configuration table.

The ranges are merged before they are returned such that any interleaved ranges appear as a single range.

Returns
All configuration table memory ranges

Definition at line 256 of file physical.cc.

References MipsISA::r.

Referenced by LinuxArmSystem::initState().

bool PhysicalMemory::isMemAddr ( Addr  addr) const

Check if a physical address is within a range of a memory that is part of the global address map.

Parameters
addrA physical address
Returns
Whether the address corresponds to a memory

Definition at line 237 of file physical.cc.

References AddrRangeMap< V >::end(), MipsISA::r, and rangeCache.

Referenced by System::isMemAddr().

const std::string PhysicalMemory::name ( ) const
inline

Return the name for debugging and for creation of sections for checkpointing.

Definition at line 178 of file physical.hh.

References _name.

Referenced by serializeStore().

PhysicalMemory& PhysicalMemory::operator= ( const PhysicalMemory )
private
void PhysicalMemory::serialize ( CheckpointOut cp) const
overridevirtual

Serialize all the memories in the system.

This is independent of the logical memory layout, and the serialization only sees the contigous backing store, independent of how this maps to logical memories in the guest system.

Parameters
osstream to serialize to

Implements Serializable.

Definition at line 324 of file physical.cc.

References backingStore, csprintf(), MipsISA::l, RiscvISA::locked_addrs, ArmISA::m, memories, ArmISA::s, SERIALIZE_CONTAINER, SERIALIZE_SCALAR, and serializeStore().

void PhysicalMemory::serializeStore ( CheckpointOut cp,
unsigned int  store_id,
AddrRange  range,
uint8_t *  pmem 
) const

Serialize a specific store.

Parameters
store_idUnique identifier of this backing store
rangeThe address range of this backing store
pmemThe host pointer to this backing store

Definition at line 354 of file physical.cc.

References CheckpointIn::dir(), DPRINTF, fatal, name(), SERIALIZE_SCALAR, and AddrRange::size().

Referenced by serialize().

uint64_t PhysicalMemory::totalSize ( ) const
inline

Get the total physical memory size.

Returns
The sum of all memory sizes

Definition at line 204 of file physical.hh.

References size.

Referenced by System::allocPhysPages(), System::freeMemSize(), and System::memSize().

void PhysicalMemory::unserialize ( CheckpointIn cp)
overridevirtual

Unserialize the memories in the system.

As with the serialization, this action is independent of how the address ranges are mapped to logical memories in the guest system.

Implements Serializable.

Definition at line 400 of file physical.cc.

References csprintf(), ArmISA::i, ArmISA::m, UNSERIALIZE_CONTAINER, UNSERIALIZE_SCALAR, and unserializeStore().

void PhysicalMemory::unserializeStore ( CheckpointIn cp)

Unserialize a specific backing store, identified by a section.

Definition at line 425 of file physical.cc.

References backingStore, CheckpointIn::cptDir, DPRINTF, fatal, AddrRange::size(), UNSERIALIZE_SCALAR, and X86ISA::x.

Referenced by unserialize().

Member Data Documentation

std::string PhysicalMemory::_name
private

Definition at line 118 of file physical.hh.

Referenced by name().

AddrRangeMap<AbstractMemory*> PhysicalMemory::addrMap
private

Definition at line 121 of file physical.hh.

std::vector<BackingStoreEntry> PhysicalMemory::backingStore
private
std::vector<AbstractMemory*> PhysicalMemory::memories
private

Definition at line 128 of file physical.hh.

Referenced by serialize().

const bool PhysicalMemory::mmapUsingNoReserve
private

Definition at line 134 of file physical.hh.

Referenced by createBackingStore().

AddrRangeMap<AbstractMemory*>::const_iterator PhysicalMemory::rangeCache
mutableprivate

Definition at line 125 of file physical.hh.

Referenced by access(), functionalAccess(), and isMemAddr().

uint64_t PhysicalMemory::size
private

Definition at line 131 of file physical.hh.

Referenced by totalSize().


The documentation for this class was generated from the following files:

Generated on Fri Jun 9 2017 13:04:16 for gem5 by doxygen 1.8.6