gem5  v22.1.0.0
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__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Class for handling allocation of physical pages in SE mode.
Definition: mem_pool.hh:46
Addr totalBytes() const
Definition: mem_pool.cc:109
Addr startAddr() const
Definition: mem_pool.cc:91
void setFreePage(Counter value)
Definition: mem_pool.cc:61
Counter totalPages() const
Definition: mem_pool.cc:73
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: mem_pool.cc:127
Addr freePageAddr() const
Definition: mem_pool.cc:67
Counter _totalPages
The size of the pool, in number of pages.
Definition: mem_pool.hh:57
Counter allocatedPages() const
Definition: mem_pool.cc:79
Addr pageShift
Definition: mem_pool.hh:48
Counter startPageNum
Start page of pool.
Definition: mem_pool.hh:51
Addr allocatedBytes() const
Definition: mem_pool.cc:97
Counter startPage() const
Definition: mem_pool.cc:49
Addr allocate(Addr npages)
Definition: mem_pool.cc:115
Addr freeBytes() const
Definition: mem_pool.cc:103
Counter freePage() const
Definition: mem_pool.cc:55
Counter freePages() const
Definition: mem_pool.cc:85
Counter freePageNum
Page number of free memory.
Definition: mem_pool.hh:54
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: mem_pool.cc:136
Addr allocPhysPages(int npages, int pool_id=0)
Allocate npages contiguous unused physical pages.
Definition: mem_pool.cc:152
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: mem_pool.cc:170
void populate(const AddrRangeList &memories)
Definition: mem_pool.cc:145
Addr freeMemSize(int pool_id=0) const
Amount of physical memory that is still free in a pool.
Definition: mem_pool.cc:164
Addr pageShift
Definition: mem_pool.hh:89
std::vector< MemPool > pools
Definition: mem_pool.hh:91
Addr memSize(int pool_id=0) const
Amount of physical memory that exists in a pool.
Definition: mem_pool.cc:158
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: mem_pool.cc:181
MemPools(Addr page_shift)
Definition: mem_pool.hh:94
Basic support for object serialization.
Definition: serialize.hh:170
STL vector class.
Definition: stl.hh:37
BitfieldType< SegDescriptorLimit > limit
Definition: misc.hh:931
double Counter
All counters are of 64-bit values.
Definition: types.hh:47
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147

Generated on Wed Dec 21 2022 10:22:39 for gem5 by doxygen 1.9.1