gem5  v22.0.0.2
physical.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __MEM_PHYSICAL_HH__
39 #define __MEM_PHYSICAL_HH__
40 
41 #include <cstdint>
42 #include <string>
43 #include <vector>
44 
45 #include "base/addr_range.hh"
46 #include "base/addr_range_map.hh"
47 #include "mem/packet.hh"
48 #include "sim/serialize.hh"
49 
50 namespace gem5
51 {
52 
53 namespace memory
54 {
55 
59 class AbstractMemory;
60 
65 {
66  public:
67 
73  bool conf_table_reported, bool in_addr_map, bool kvm_map,
74  int shm_fd=-1, off_t shm_offset=0)
75  : range(range), pmem(pmem), confTableReported(conf_table_reported),
76  inAddrMap(in_addr_map), kvmMap(kvm_map), shmFd(shm_fd),
77  shmOffset(shm_offset)
78  {}
79 
84 
89  uint8_t* pmem;
90 
95 
99  bool inAddrMap;
100 
105  bool kvmMap;
106 
111  int shmFd;
112 
117  off_t shmOffset;
118 };
119 
137 {
138 
139  private:
140 
141  // Name for debugging
142  std::string _name;
143 
144  // Global address map
146 
147  // All address-mapped memories
149 
150  // The total memory size
151  uint64_t size;
152 
153  // Let the user choose if we reserve swap space when calling mmap
154  const bool mmapUsingNoReserve;
155 
156  const std::string sharedBackstore;
158 
159  long pageSize;
160 
161  // The physical memory used to provide the memory in the simulated
162  // system
164 
165  // Prevent copying
167 
168  // Prevent assignment
170 
180  void createBackingStore(AddrRange range,
181  const std::vector<AbstractMemory*>& _memories,
182  bool conf_table_reported,
183  bool in_addr_map, bool kvm_map);
184 
185  public:
186 
190  PhysicalMemory(const std::string& _name,
191  const std::vector<AbstractMemory*>& _memories,
192  bool mmap_using_noreserve,
193  const std::string& shared_backstore,
194  bool auto_unlink_shared_backstore);
195 
199  ~PhysicalMemory();
200 
205  const std::string name() const { return _name; }
206 
214  bool isMemAddr(Addr addr) const;
215 
225 
231  uint64_t totalSize() const { return size; }
232 
246  { return backingStore; }
247 
255  void access(PacketPtr pkt);
256 
265  void functionalAccess(PacketPtr pkt);
266 
275  void serialize(CheckpointOut &cp) const override;
276 
284  void serializeStore(CheckpointOut &cp, unsigned int store_id,
285  AddrRange range, uint8_t* pmem) const;
286 
292  void unserialize(CheckpointIn &cp) override;
293 
297  void unserializeStore(CheckpointIn &cp);
298 
299 };
300 
301 } // namespace memory
302 } // namespace gem5
303 
304 #endif //__MEM_PHYSICAL_HH__
gem5::memory::PhysicalMemory::getBackingStore
std::vector< BackingStoreEntry > getBackingStore() const
Get the pointers to the backing store for external host access.
Definition: physical.hh:245
gem5::memory::PhysicalMemory::serialize
void serialize(CheckpointOut &cp) const override
Serialize all the memories in the system.
Definition: physical.cc:333
gem5::memory::BackingStoreEntry::confTableReported
bool confTableReported
Whether this memory should be reported to the configuration table.
Definition: physical.hh:94
gem5::AddrRangeMap
The AddrRangeMap uses an STL map to implement an interval tree for address decoding.
Definition: addr_range_map.hh:62
serialize.hh
memory
Definition: mem.h:38
gem5::memory::PhysicalMemory
The physical memory encapsulates all memories in the system and provides basic functionality for acce...
Definition: physical.hh:136
gem5::memory::BackingStoreEntry::inAddrMap
bool inAddrMap
Whether this memory should appear in the global address map.
Definition: physical.hh:99
gem5::memory::PhysicalMemory::access
void access(PacketPtr pkt)
Perform an untimed memory access and update all the state (e.g.
Definition: physical.cc:315
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::memory::PhysicalMemory::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize the memories in the system.
Definition: physical.cc:410
gem5::memory::PhysicalMemory::backingStore
std::vector< BackingStoreEntry > backingStore
Definition: physical.hh:163
gem5::memory::PhysicalMemory::unserializeStore
void unserializeStore(CheckpointIn &cp)
Unserialize a specific backing store, identified by a section.
Definition: physical.cc:435
gem5::memory::BackingStoreEntry::range
AddrRange range
The address range covered in the guest.
Definition: physical.hh:83
gem5::memory::BackingStoreEntry::shmFd
int shmFd
If this backing store is based on a shared memory, this is the fd to the shared memory.
Definition: physical.hh:111
gem5::memory::PhysicalMemory::serializeStore
void serializeStore(CheckpointOut &cp, unsigned int store_id, AddrRange range, uint8_t *pmem) const
Serialize a specific store.
Definition: physical.cc:363
std::vector
STL vector class.
Definition: stl.hh:37
gem5::memory::BackingStoreEntry::kvmMap
bool kvmMap
Whether KVM should map this memory into the guest address space during acceleration.
Definition: physical.hh:105
packet.hh
gem5::memory::BackingStoreEntry::shmOffset
off_t shmOffset
If this backing store is based on a shared memory, this is the offset of this backing store in the sh...
Definition: physical.hh:117
gem5::memory::PhysicalMemory::PhysicalMemory
PhysicalMemory(const PhysicalMemory &)
gem5::memory::PhysicalMemory::addrMap
AddrRangeMap< AbstractMemory *, 1 > addrMap
Definition: physical.hh:145
gem5::memory::PhysicalMemory::sharedBackstoreSize
uint64_t sharedBackstoreSize
Definition: physical.hh:157
gem5::Serializable
Basic support for object serialization.
Definition: serialize.hh:169
addr_range_map.hh
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:291
gem5::memory::BackingStoreEntry
A single entry for the backing store.
Definition: physical.hh:64
gem5::memory::PhysicalMemory::~PhysicalMemory
~PhysicalMemory()
Unmap all the backing store we have used.
Definition: physical.cc:265
gem5::memory::PhysicalMemory::mmapUsingNoReserve
const bool mmapUsingNoReserve
Definition: physical.hh:154
gem5::memory::PhysicalMemory::sharedBackstore
const std::string sharedBackstore
Definition: physical.hh:156
gem5::memory::PhysicalMemory::memories
std::vector< AbstractMemory * > memories
Definition: physical.hh:148
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::memory::PhysicalMemory::functionalAccess
void functionalAccess(PacketPtr pkt)
Perform an untimed memory read or write without changing anything but the memory itself.
Definition: physical.cc:324
addr_range.hh
gem5::memory::PhysicalMemory::name
const std::string name() const
Return the name for debugging and for creation of sections for checkpointing.
Definition: physical.hh:205
gem5::memory::PhysicalMemory::operator=
PhysicalMemory & operator=(const PhysicalMemory &)
gem5::memory::BackingStoreEntry::BackingStoreEntry
BackingStoreEntry(AddrRange range, uint8_t *pmem, bool conf_table_reported, bool in_addr_map, bool kvm_map, int shm_fd=-1, off_t shm_offset=0)
Create a backing store entry.
Definition: physical.hh:72
gem5::memory::PhysicalMemory::size
uint64_t size
Definition: physical.hh:151
gem5::memory::PhysicalMemory::pageSize
long pageSize
Definition: physical.hh:159
gem5::memory::PhysicalMemory::isMemAddr
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.
Definition: physical.cc:273
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::memory::PhysicalMemory::totalSize
uint64_t totalSize() const
Get the total physical memory size.
Definition: physical.hh:231
gem5::AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:81
std::list< AddrRange >
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::memory::PhysicalMemory::_name
std::string _name
Definition: physical.hh:142
gem5::memory::PhysicalMemory::getConfAddrRanges
AddrRangeList getConfAddrRanges() const
Get the memory ranges for all memories that are to be reported to the configuration table.
Definition: physical.cc:279
gem5::memory::BackingStoreEntry::pmem
uint8_t * pmem
Pointer to the host memory this range maps to.
Definition: physical.hh:89
gem5::memory::PhysicalMemory::createBackingStore
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 ...
Definition: physical.cc:199
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Thu Jul 28 2022 13:32:35 for gem5 by doxygen 1.8.17