|
gem5
v21.2.1.1
|
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>
Public Member Functions | |
| PhysicalMemory (const std::string &_name, const std::vector< AbstractMemory * > &_memories, bool mmap_using_noreserve, const std::string &shared_backstore) | |
| 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< BackingStoreEntry > | getBackingStore () 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 gem5::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 &) | |
| PhysicalMemory & | operator= (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 *, 1 > | addrMap |
| std::vector< AbstractMemory * > | memories |
| uint64_t | size |
| const bool | mmapUsingNoReserve |
| const std::string | sharedBackstore |
| std::vector< BackingStoreEntry > | backingStore |
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. More... | |
| static void | generateCheckpointOut (const std::string &cpt_dir, std::ofstream &outstream) |
| Generate a checkpoint file so that the serialization can be routed to it. More... | |
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 122 of file physical.hh.
|
private |
| gem5::memory::PhysicalMemory::PhysicalMemory | ( | const std::string & | _name, |
| const std::vector< AbstractMemory * > & | _memories, | ||
| bool | mmap_using_noreserve, | ||
| const std::string & | shared_backstore | ||
| ) |
Create a physical memory object, wrapping a number of memories.
Definition at line 77 of file physical.cc.
References addrMap, gem5::ArmISA::c, createBackingStore(), DPRINTF, gem5::ArmISA::f, fatal, fatal_if, gem5::ArmISA::m, memories, gem5::MipsISA::r, size, and warn.
| gem5::memory::PhysicalMemory::~PhysicalMemory | ( | ) |
Unmap all the backing store we have used.
Definition at line 248 of file physical.cc.
References backingStore, and gem5::ArmISA::s.
| 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.
| pkt | Packet performing the access |
Definition at line 298 of file physical.cc.
References addrMap, gem5::Packet::getAddrRange(), gem5::Packet::isRequest(), and gem5::ArmISA::m.
|
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.
| range | The address range covered |
| memories | The memories this range maps to |
| kvm_map | Should KVM map this memory for the guest |
Definition at line 190 of file physical.cc.
References backingStore, DPRINTF, fatal, gem5::AddrRange::interleaved(), gem5::ArmISA::m, mmapUsingNoReserve, panic, panic_if, sharedBackstore, gem5::AddrRange::size(), and gem5::AddrRange::to_string().
Referenced by PhysicalMemory().
| 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.
| pkt | Packet performing the access |
Definition at line 307 of file physical.cc.
References addrMap, gem5::Packet::getAddrRange(), gem5::Packet::isRequest(), and gem5::ArmISA::m.
|
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.
Definition at line 227 of file physical.hh.
References backingStore.
Referenced by gem5::KvmVM::delayedStartup().
| 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.
Definition at line 262 of file physical.cc.
References addrMap, and gem5::MipsISA::r.
Referenced by gem5::ArmSemihosting::gatherHeapInfo(), and gem5::ArmISA::FsLinux::initState().
| 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.
| addr | A physical address |
Definition at line 256 of file physical.cc.
References gem5::X86ISA::addr, and addrMap.
Referenced by gem5::System::isMemAddr().
|
inline |
Return the name for debugging and for creation of sections for checkpointing.
Definition at line 187 of file physical.hh.
References _name.
Referenced by serializeStore().
|
private |
|
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.
| os | stream to serialize to |
Implements gem5::Serializable.
Definition at line 316 of file physical.cc.
References backingStore, gem5::csprintf(), gem5::MipsISA::l, gem5::RiscvISA::locked_addrs, gem5::ArmISA::m, memories, gem5::ArmISA::s, SERIALIZE_CONTAINER, SERIALIZE_SCALAR, and serializeStore().
| void gem5::memory::PhysicalMemory::serializeStore | ( | CheckpointOut & | cp, |
| unsigned int | store_id, | ||
| AddrRange | range, | ||
| uint8_t * | pmem | ||
| ) | const |
Serialize a specific store.
| store_id | Unique identifier of this backing store |
| range | The address range of this backing store |
| pmem | The host pointer to this backing store |
Definition at line 346 of file physical.cc.
References gem5::CheckpointIn::dir(), DPRINTF, fatal, name(), SERIALIZE_SCALAR, gem5::AddrRange::size(), and sc_dt::to_string().
Referenced by serialize().
|
inline |
Get the total physical memory size.
Definition at line 213 of file physical.hh.
References size.
Referenced by gem5::System::memSize().
|
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 393 of file physical.cc.
References addrMap, gem5::csprintf(), gem5::ArmISA::i, gem5::ArmISA::m, UNSERIALIZE_CONTAINER, UNSERIALIZE_SCALAR, and unserializeStore().
| void gem5::memory::PhysicalMemory::unserializeStore | ( | CheckpointIn & | cp | ) |
Unserialize a specific backing store, identified by a section.
Definition at line 418 of file physical.cc.
References backingStore, DPRINTF, fatal, gem5::CheckpointIn::getCptDir(), gem5::AddrRange::size(), UNSERIALIZE_SCALAR, and gem5::RiscvISA::x.
Referenced by unserialize().
|
private |
Definition at line 128 of file physical.hh.
Referenced by name().
|
private |
Definition at line 131 of file physical.hh.
Referenced by access(), functionalAccess(), getConfAddrRanges(), isMemAddr(), PhysicalMemory(), and unserialize().
|
private |
Definition at line 146 of file physical.hh.
Referenced by createBackingStore(), getBackingStore(), serialize(), unserializeStore(), and ~PhysicalMemory().
|
private |
Definition at line 134 of file physical.hh.
Referenced by PhysicalMemory(), and serialize().
|
private |
Definition at line 140 of file physical.hh.
Referenced by createBackingStore().
|
private |
Definition at line 142 of file physical.hh.
Referenced by createBackingStore().
|
private |
Definition at line 137 of file physical.hh.
Referenced by PhysicalMemory(), and totalSize().