gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Andreas Hansson
38  */
39 
40 #ifndef __MEM_PHYSICAL_HH__
41 #define __MEM_PHYSICAL_HH__
42 
43 #include "base/addr_range_map.hh"
44 #include "mem/packet.hh"
45 
49 class AbstractMemory;
50 
55 {
56  public:
57 
63  bool conf_table_reported, bool in_addr_map, bool kvm_map)
64  : range(range), pmem(pmem), confTableReported(conf_table_reported),
65  inAddrMap(in_addr_map), kvmMap(kvm_map)
66  {}
67 
72 
77  uint8_t* pmem;
78 
83 
87  bool inAddrMap;
88 
93  bool kvmMap;
94 };
95 
113 {
114 
115  private:
116 
117  // Name for debugging
118  std::string _name;
119 
120  // Global address map
122 
123  // All address-mapped memories
125 
126  // The total memory size
127  uint64_t size;
128 
129  // Let the user choose if we reserve swap space when calling mmap
130  const bool mmapUsingNoReserve;
131 
132  // The physical memory used to provide the memory in the simulated
133  // system
135 
136  // Prevent copying
138 
139  // Prevent assignment
140  PhysicalMemory& operator=(const PhysicalMemory&);
141 
151  void createBackingStore(AddrRange range,
152  const std::vector<AbstractMemory*>& _memories,
153  bool conf_table_reported,
154  bool in_addr_map, bool kvm_map);
155 
156  public:
157 
161  PhysicalMemory(const std::string& _name,
162  const std::vector<AbstractMemory*>& _memories,
163  bool mmap_using_noreserve);
164 
168  ~PhysicalMemory();
169 
174  const std::string name() const { return _name; }
175 
183  bool isMemAddr(Addr addr) const;
184 
193  AddrRangeList getConfAddrRanges() const;
194 
200  uint64_t totalSize() const { return size; }
201 
215  { return backingStore; }
216 
224  void access(PacketPtr pkt);
225 
234  void functionalAccess(PacketPtr pkt);
235 
244  void serialize(CheckpointOut &cp) const override;
245 
253  void serializeStore(CheckpointOut &cp, unsigned int store_id,
254  AddrRange range, uint8_t* pmem) const;
255 
261  void unserialize(CheckpointIn &cp) override;
262 
266  void unserializeStore(CheckpointIn &cp);
267 
268 };
269 
270 #endif //__MEM_PHYSICAL_HH__
const std::string name() const
Return the name for debugging and for creation of sections for checkpointing.
Definition: physical.hh:174
BackingStoreEntry(AddrRange range, uint8_t *pmem, bool conf_table_reported, bool in_addr_map, bool kvm_map)
Create a backing store entry.
Definition: physical.hh:62
uint64_t totalSize() const
Get the total physical memory size.
Definition: physical.hh:200
ip6_addr_t addr
Definition: inet.hh:335
AddrRange range
The address range covered in the guest.
Definition: physical.hh:71
bool kvmMap
Whether KVM should map this memory into the guest address space during acceleration.
Definition: physical.hh:93
Definition: cprintf.cc:42
STL vector class.
Definition: stl.hh:40
std::vector< AbstractMemory * > memories
Definition: physical.hh:124
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:72
bool inAddrMap
Whether this memory should appear in the global address map.
Definition: physical.hh:87
std::vector< BackingStoreEntry > getBackingStore() const
Get the pointers to the backing store for external host access.
Definition: physical.hh:214
AddrRangeMap< AbstractMemory *, 1 > addrMap
Definition: physical.hh:121
bool confTableReported
Whether this memory should be reported to the configuration table.
Definition: physical.hh:82
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
uint8_t * pmem
Pointer to the host memory this range maps to.
Definition: physical.hh:77
The physical memory encapsulates all memories in the system and provides basic functionality for acce...
Definition: physical.hh:112
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
A single entry for the backing store.
Definition: physical.hh:54
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
Basic support for object serialization.
Definition: serialize.hh:153
std::string _name
Definition: physical.hh:118
std::vector< BackingStoreEntry > backingStore
Definition: physical.hh:134
Declaration of the Packet class.
std::ostream CheckpointOut
Definition: serialize.hh:68
uint64_t size
Definition: physical.hh:127
const bool mmapUsingNoReserve
Definition: physical.hh:130
An abstract memory represents a contiguous block of physical memory, with an associated address range...
void unserialize(ThreadContext &tc, CheckpointIn &cp)

Generated on Fri Feb 28 2020 16:27:02 for gem5 by doxygen 1.8.13