gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
gem5::memory::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 gem5::memory::PhysicalMemory:
gem5::Serializable

Public Member Functions

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

Private Attributes

std::string _name
 
AddrRangeMap< AbstractMemory *, 1 > addrMap
 
std::vector< AbstractMemory * > memories
 
uint64_t size
 
const bool mmapUsingNoReserve
 
const std::string sharedBackstore
 
uint64_t sharedBackstoreSize
 
long pageSize
 
std::vector< BackingStoreEntrybackingStore
 

Additional Inherited Members

- Static Public Member Functions inherited from gem5::Serializable
static const std::string & currentSection ()
 Gets the fully-qualified name of the active section.
 
static void generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream)
 Generate a checkpoint file so that the serialization can be routed to it.
 

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 136 of file physical.hh.

Constructor & Destructor Documentation

◆ PhysicalMemory() [1/2]

gem5::memory::PhysicalMemory::PhysicalMemory ( const PhysicalMemory & )
private

References PhysicalMemory().

Referenced by operator=(), and PhysicalMemory().

◆ PhysicalMemory() [2/2]

gem5::memory::PhysicalMemory::PhysicalMemory ( const std::string & _name,
const std::vector< AbstractMemory * > & _memories,
bool mmap_using_noreserve,
const std::string & shared_backstore,
bool auto_unlink_shared_backstore )

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

Definition at line 79 of file physical.cc.

References _name, mmapUsingNoReserve, pageSize, sharedBackstore, sharedBackstoreSize, and size.

◆ ~PhysicalMemory()

gem5::memory::PhysicalMemory::~PhysicalMemory ( )

Unmap all the backing store we have used.

Definition at line 265 of file physical.cc.

References backingStore, gem5::ArmISA::s, and ~PhysicalMemory().

Referenced by ~PhysicalMemory().

Member Function Documentation

◆ access()

void gem5::memory::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 315 of file physical.cc.

References access(), addrMap, gem5::Packet::getAddrRange(), gem5::Packet::isRequest(), and gem5::ArmISA::m.

Referenced by access().

◆ createBackingStore()

void gem5::memory::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 199 of file physical.cc.

References backingStore, createBackingStore(), DPRINTF, fatal, gem5::AddrRange::interleaved(), gem5::ArmISA::m, mmapUsingNoReserve, pageSize, panic, panic_if, gem5::roundUp(), sharedBackstore, sharedBackstoreSize, gem5::AddrRange::size(), and gem5::AddrRange::to_string().

Referenced by createBackingStore().

◆ functionalAccess()

void gem5::memory::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 324 of file physical.cc.

References addrMap, functionalAccess(), gem5::Packet::getAddrRange(), gem5::Packet::isRequest(), and gem5::ArmISA::m.

Referenced by functionalAccess().

◆ getBackingStore()

std::vector< BackingStoreEntry > gem5::memory::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 245 of file physical.hh.

References backingStore.

◆ getConfAddrRanges()

AddrRangeList gem5::memory::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 279 of file physical.cc.

References addrMap, getConfAddrRanges(), and gem5::MipsISA::r.

Referenced by gem5::BaseSemihosting::gatherHeapInfo(), and getConfAddrRanges().

◆ isMemAddr()

bool gem5::memory::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 273 of file physical.cc.

References gem5::X86ISA::addr, addrMap, and isMemAddr().

Referenced by isMemAddr().

◆ name()

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

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

Definition at line 205 of file physical.hh.

References _name.

◆ operator=()

PhysicalMemory & gem5::memory::PhysicalMemory::operator= ( const PhysicalMemory & )
private

References _name, and PhysicalMemory().

◆ serialize()

void gem5::memory::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 gem5::Serializable.

Definition at line 333 of file physical.cc.

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

Referenced by serialize().

◆ serializeStore()

void gem5::memory::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 363 of file physical.cc.

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

Referenced by serialize(), and serializeStore().

◆ totalSize()

uint64_t gem5::memory::PhysicalMemory::totalSize ( ) const
inline

Get the total physical memory size.

Returns
The sum of all memory sizes

Definition at line 231 of file physical.hh.

References size.

◆ unserialize()

void gem5::memory::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 gem5::Serializable.

Definition at line 410 of file physical.cc.

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

Referenced by unserialize().

◆ unserializeStore()

void gem5::memory::PhysicalMemory::unserializeStore ( CheckpointIn & cp)

Unserialize a specific backing store, identified by a section.

Definition at line 435 of file physical.cc.

References backingStore, DPRINTF, fatal, gem5::AddrRange::size(), UNSERIALIZE_SCALAR, and unserializeStore().

Referenced by unserialize(), and unserializeStore().

Member Data Documentation

◆ _name

std::string gem5::memory::PhysicalMemory::_name
private

Definition at line 142 of file physical.hh.

Referenced by name(), operator=(), and PhysicalMemory().

◆ addrMap

AddrRangeMap<AbstractMemory*, 1> gem5::memory::PhysicalMemory::addrMap
private

Definition at line 145 of file physical.hh.

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

◆ backingStore

std::vector<BackingStoreEntry> gem5::memory::PhysicalMemory::backingStore
private

◆ memories

std::vector<AbstractMemory*> gem5::memory::PhysicalMemory::memories
private

Definition at line 148 of file physical.hh.

Referenced by serialize().

◆ mmapUsingNoReserve

const bool gem5::memory::PhysicalMemory::mmapUsingNoReserve
private

Definition at line 154 of file physical.hh.

Referenced by createBackingStore(), and PhysicalMemory().

◆ pageSize

long gem5::memory::PhysicalMemory::pageSize
private

Definition at line 159 of file physical.hh.

Referenced by createBackingStore(), and PhysicalMemory().

◆ sharedBackstore

const std::string gem5::memory::PhysicalMemory::sharedBackstore
private

Definition at line 156 of file physical.hh.

Referenced by createBackingStore(), and PhysicalMemory().

◆ sharedBackstoreSize

uint64_t gem5::memory::PhysicalMemory::sharedBackstoreSize
private

Definition at line 157 of file physical.hh.

Referenced by createBackingStore(), and PhysicalMemory().

◆ size

uint64_t gem5::memory::PhysicalMemory::size
private

Definition at line 151 of file physical.hh.

Referenced by PhysicalMemory(), and totalSize().


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

Generated on Mon May 26 2025 09:19:33 for gem5 by doxygen 1.13.2