gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
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/free_list.hh"
39#include "base/types.hh"
40#include "sim/serialize.hh"
41
42namespace gem5
43{
44
46class MemPool : public Serializable
47{
48 private:
50
53
56
58
59 MemPool() = default;
60
61 friend class MemPools;
62
63 public:
64 MemPool(Addr page_shift, Addr ptr, Addr limit);
65
66 Counter startPage() const;
67 Counter totalPages() const;
68
69 Counter allocatedPages() const;
70 Counter freePages() const;
71
72 Addr startAddr() const;
73 Addr allocatedBytes() const;
74 Addr freeBytes() const;
75 Addr totalBytes() const;
76
77 Addr allocate(Addr npages);
78 void deallocate(Addr start, Addr npages);
79
80 void serialize(CheckpointOut &cp) const override;
81 void unserialize(CheckpointIn &cp) override;
82};
83
84class MemPools : public Serializable
85{
86 private:
88
90
91 public:
92 MemPools(Addr page_shift) : pageShift(page_shift) {}
93
94 void populate(const AddrRangeList &memories);
95
98 Addr allocPhysPages(int npages, int pool_id=0);
99
102 void deallocPhysPages(Addr page_addr, int npages, int pool_id=0);
103
105 Addr memSize(int pool_id=0) const;
106
108 Addr freeMemSize(int pool_id=0) const;
109
110 void serialize(CheckpointOut &cp) const override;
111 void unserialize(CheckpointIn &cp) override;
112};
113
114} // namespace gem5
115
116#endif // __MEM_POOL_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Addr totalBytes() const
Definition mem_pool.cc:90
Addr startAddr() const
Definition mem_pool.cc:72
FreeList< Addr > freePhysPages
Definition mem_pool.hh:57
Counter totalPages() const
Definition mem_pool.cc:54
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition mem_pool.cc:111
Counter _totalPages
The size of the pool, in number of pages.
Definition mem_pool.hh:55
Counter allocatedPages() const
Definition mem_pool.cc:60
void deallocate(Addr start, Addr npages)
Definition mem_pool.cc:105
MemPool()=default
Counter startPageNum
Start page of pool.
Definition mem_pool.hh:52
friend class MemPools
Definition mem_pool.hh:61
Addr allocatedBytes() const
Definition mem_pool.cc:78
Counter startPage() const
Definition mem_pool.cc:48
Addr allocate(Addr npages)
Definition mem_pool.cc:96
Addr freeBytes() const
Definition mem_pool.cc:84
Counter freePages() const
Definition mem_pool.cc:66
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition mem_pool.cc:128
Addr allocPhysPages(int npages, int pool_id=0)
Allocate npages contiguous unused physical pages.
Definition mem_pool.cc:163
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition mem_pool.cc:187
void populate(const AddrRangeList &memories)
Definition mem_pool.cc:156
Addr freeMemSize(int pool_id=0) const
Amount of physical memory that is still free in a pool.
Definition mem_pool.cc:181
std::vector< MemPool > pools
Definition mem_pool.hh:89
Addr memSize(int pool_id=0) const
Amount of physical memory that exists in a pool.
Definition mem_pool.cc:175
void deallocPhysPages(Addr page_addr, int npages, int pool_id=0)
Deallocate physical pages.
Definition mem_pool.cc:169
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition mem_pool.cc:198
MemPools(Addr page_shift)
Definition mem_pool.hh:92
STL vector class.
Definition stl.hh:37
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
Definition addr_range.hh:64
BitfieldType< SegDescriptorLimit > limit
Definition misc.hh:959
double Counter
All counters are of 64-bit values.
Definition types.hh:46
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
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 Mon May 26 2025 09:19:13 for gem5 by doxygen 1.13.2