gem5 v25.0.0.1
Loading...
Searching...
No Matches
pagetable.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * Copyright (c) 2007 MIPS Technologies, Inc.
4 * Copyright (c) 2020 Barkhausen Institut
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met: redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer;
11 * redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution;
14 * neither the name of the copyright holders nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef __ARCH_RISCV_PAGETABLE_H__
32#define __ARCH_RISCV_PAGETABLE_H__
33
34#include "base/bitunion.hh"
35#include "base/logging.hh"
36#include "base/trie.hh"
37#include "base/types.hh"
38#include "sim/serialize.hh"
39
40namespace gem5
41{
42
43namespace RiscvISA {
44
46 Bitfield<63, 60> mode;
47 Bitfield<59, 44> asid;
48 Bitfield<43, 0> ppn;
50
51enum AddrXlateMode
52{
53 BARE = 0,
54 SV39 = 8,
55 SV48 = 9,
56 SV57 = 10,
57};
58
59// Sv39 paging
60const Addr SV39_XLEN = 64;
62const Addr SV39_LEVELS = 3;
65
66BitUnion64(PTESv39)
67 Bitfield<63> n;
68 Bitfield<62, 54> reserved;
69 Bitfield<53, 10> ppn;
70 Bitfield<53, 28> ppn2;
71 Bitfield<27, 19> ppn1;
72 Bitfield<18, 10> ppn0;
73 Bitfield<7> d;
74 Bitfield<6> a;
75 Bitfield<5> g;
76 Bitfield<4> u;
77 Bitfield<3, 1> perm;
78 Bitfield<3> x;
79 Bitfield<2> w;
80 Bitfield<1> r;
81 Bitfield<0> v;
83
84
90
91struct TlbEntry;
93
94struct TlbEntry : public Serializable
95{
96 // The base of the physical page.
98
99 // The beginning of the virtual page this entry maps.
101 // The size of the page this represents, in address bits.
102 unsigned logBytes;
103
104 uint16_t asid;
105
106 PTESv39 pte;
107
108 PTESv39 gpte;
109
111
112 // A sequence number to keep track of LRU.
113 uint64_t lruSeq;
114
116 : paddr(0), vaddr(0), logBytes(0), pte(), gpte(), lruSeq(0)
117 {}
118
119 // Return the page size in bytes
120 Addr size() const
121 {
122 return (static_cast<Addr>(1) << logBytes);
123 }
124
125 void reset()
126 {
127 paddr = vaddr = logBytes = pte = gpte = lruSeq = 0;
128 }
129
130 void serialize(CheckpointOut &cp) const override;
131 void unserialize(CheckpointIn &cp) override;
132};
133
134} // namespace RiscvISA
135} // namespace gem5
136
137#endif // __ARCH_RISCV_PAGETABLE_H__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
A trie is a tree-based data structure used for data retrieval.
Definition trie.hh:55
#define BitUnion64(name)
Use this to define conveniently sized values overlayed with bitfields.
Definition bitunion.hh:494
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
Definition bitunion.hh:428
Bitfield< 31 > n
const Addr SV39_XLEN
Definition pagetable.hh:60
Bitfield< 3, 1 > perm
Definition pagetable.hh:77
Bitfield< 27, 19 > ppn1
Definition pagetable.hh:71
Bitfield< 6 > a
Definition pagetable.hh:74
Bitfield< 43, 0 > ppn
Definition pagetable.hh:48
Bitfield< 53, 28 > ppn2
Definition pagetable.hh:70
const Addr SV39X4_WIDENED_BITS
Definition pagetable.hh:64
Bitfield< 62, 54 > reserved
Definition pagetable.hh:68
Bitfield< 5 > g
Definition pagetable.hh:75
Trie< Addr, TlbEntry > TlbEntryTrie
Definition pagetable.hh:92
Bitfield< 2 > w
Definition pagetable.hh:79
Bitfield< 4 > u
Definition pagetable.hh:76
Bitfield< 0 > v
Definition pagetable.hh:81
const Addr SV39_VADDR_BITS
Definition pagetable.hh:61
EndBitUnion(SATP) enum AddrXlateMode
Definition pagetable.hh:49
Addr getVPNFromVAddr(Addr vaddr, Addr mode)
Definition pagetable.cc:64
Bitfield< 7 > d
Definition pagetable.hh:73
Bitfield< 59, 44 > asid
Definition pagetable.hh:47
Bitfield< 3 > x
Definition pagetable.hh:78
const Addr SV39_LEVELS
Definition pagetable.hh:62
Bitfield< 18, 10 > ppn0
Definition pagetable.hh:72
const Addr SV39_LEVEL_BITS
Definition pagetable.hh:63
Bitfield< 1 > r
Definition pagetable.hh:80
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
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition pagetable.cc:53
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition pagetable.cc:42
TlbEntryTrie::Handle trieHandle
Definition pagetable.hh:110

Generated on Sat Oct 18 2025 08:06:40 for gem5 by doxygen 1.14.0