gem5  v22.0.0.2
mem_pool.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2021 Advanced Micro Devices, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef __MEM_POOL_HH__
33 #define __MEM_POOL_HH__
34 
35 #include <vector>
36 
37 #include "base/addr_range.hh"
38 #include "base/types.hh"
39 #include "sim/serialize.hh"
40 
41 namespace gem5
42 {
43 
45 class MemPool : public Serializable
46 {
47  private:
49 
52 
55 
58 
59  MemPool() {}
60 
61  friend class MemPools;
62 
63  public:
64  MemPool(Addr page_shift, Addr ptr, Addr limit);
65 
66  Counter startPage() const;
67  Counter freePage() const;
68  void setFreePage(Counter value);
69  Addr freePageAddr() const;
70  Counter totalPages() const;
71 
72  Counter allocatedPages() const;
73  Counter freePages() const;
74 
75  Addr startAddr() const;
76  Addr allocatedBytes() const;
77  Addr freeBytes() const;
78  Addr totalBytes() const;
79 
80  Addr allocate(Addr npages);
81 
82  void serialize(CheckpointOut &cp) const override;
83  void unserialize(CheckpointIn &cp) override;
84 };
85 
86 class MemPools : public Serializable
87 {
88  private:
90 
92 
93  public:
94  MemPools(Addr page_shift) : pageShift(page_shift) {}
95 
96  void populate(const AddrRangeList &memories);
97 
100  Addr allocPhysPages(int npages, int pool_id=0);
101 
103  Addr memSize(int pool_id=0) const;
104 
106  Addr freeMemSize(int pool_id=0) const;
107 
108  void serialize(CheckpointOut &cp) const override;
109  void unserialize(CheckpointIn &cp) override;
110 };
111 
112 } // namespace gem5
113 
114 #endif // __MEM_POOL_HH__
gem5::MemPool::freeBytes
Addr freeBytes() const
Definition: mem_pool.cc:103
gem5::MemPools::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: mem_pool.cc:181
serialize.hh
gem5::MemPool::freePages
Counter freePages() const
Definition: mem_pool.cc:85
gem5::MemPools::pageShift
Addr pageShift
Definition: mem_pool.hh:89
gem5::CheckpointIn
Definition: serialize.hh:68
std::vector
STL vector class.
Definition: stl.hh:37
gem5::X86ISA::limit
BitfieldType< SegDescriptorLimit > limit
Definition: misc.hh:924
gem5::MemPool::startPageNum
Counter startPageNum
Start page of pool.
Definition: mem_pool.hh:51
gem5::MemPools::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: mem_pool.cc:170
gem5::MemPool
Class for handling allocation of physical pages in SE mode.
Definition: mem_pool.hh:45
gem5::MemPools::populate
void populate(const AddrRangeList &memories)
Definition: mem_pool.cc:145
gem5::MemPool::startAddr
Addr startAddr() const
Definition: mem_pool.cc:91
gem5::Serializable
Basic support for object serialization.
Definition: serialize.hh:169
gem5::MemPool::totalPages
Counter totalPages() const
Definition: mem_pool.cc:73
gem5::MemPool::setFreePage
void setFreePage(Counter value)
Definition: mem_pool.cc:61
gem5::MemPool::allocate
Addr allocate(Addr npages)
Definition: mem_pool.cc:115
gem5::MemPools::allocPhysPages
Addr allocPhysPages(int npages, int pool_id=0)
Allocate npages contiguous unused physical pages.
Definition: mem_pool.cc:152
gem5::MemPool::freePage
Counter freePage() const
Definition: mem_pool.cc:55
gem5::MemPools::memSize
Addr memSize(int pool_id=0) const
Amount of physical memory that exists in a pool.
Definition: mem_pool.cc:158
gem5::MemPool::totalBytes
Addr totalBytes() const
Definition: mem_pool.cc:109
gem5::MemPool::allocatedPages
Counter allocatedPages() const
Definition: mem_pool.cc:79
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::MemPool::allocatedBytes
Addr allocatedBytes() const
Definition: mem_pool.cc:97
gem5::MemPool::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: mem_pool.cc:127
addr_range.hh
gem5::MemPool::freePageAddr
Addr freePageAddr() const
Definition: mem_pool.cc:67
types.hh
gem5::MemPool::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: mem_pool.cc:136
gem5::statistics::Counter
double Counter
All counters are of 64-bit values.
Definition: types.hh:47
gem5::MemPool::startPage
Counter startPage() const
Definition: mem_pool.cc:49
gem5::MemPools::freeMemSize
Addr freeMemSize(int pool_id=0) const
Amount of physical memory that is still free in a pool.
Definition: mem_pool.cc:164
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::MemPool::freePageNum
Counter freePageNum
Page number of free memory.
Definition: mem_pool.hh:54
gem5::MemPools::MemPools
MemPools(Addr page_shift)
Definition: mem_pool.hh:94
gem5::MemPools
Definition: mem_pool.hh:86
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::MemPool::_totalPages
Counter _totalPages
The size of the pool, in number of pages.
Definition: mem_pool.hh:57
gem5::MemPools::pools
std::vector< MemPool > pools
Definition: mem_pool.hh:91
gem5::MemPool::MemPool
MemPool()
Definition: mem_pool.hh:59
gem5::MemPool::pageShift
Addr pageShift
Definition: mem_pool.hh:48

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