gem5  v22.1.0.0
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 
40 namespace gem5
41 {
42 
43 namespace RiscvISA {
44 
46  Bitfield<63, 60> mode;
47  Bitfield<59, 44> asid;
48  Bitfield<43, 0> ppn;
50 
51 enum AddrXlateMode
52 {
53  BARE = 0,
54  SV39 = 8,
55  SV48 = 9,
56 };
57 
58 // Sv39 paging
59 const Addr VADDR_BITS = 39;
60 const Addr LEVEL_BITS = 9;
61 const Addr LEVEL_MASK = (1 << LEVEL_BITS) - 1;
62 
63 BitUnion64(PTESv39)
64  Bitfield<53, 10> ppn;
65  Bitfield<53, 28> ppn2;
66  Bitfield<27, 19> ppn1;
67  Bitfield<18, 10> ppn0;
68  Bitfield<7> d;
69  Bitfield<6> a;
70  Bitfield<5> g;
71  Bitfield<4> u;
72  Bitfield<3, 1> perm;
73  Bitfield<3> x;
74  Bitfield<2> w;
75  Bitfield<1> r;
76  Bitfield<0> v;
77 EndBitUnion(PTESv39)
78 
79 struct TlbEntry;
81 
82 struct TlbEntry : public Serializable
83 {
84  // The base of the physical page.
86 
87  // The beginning of the virtual page this entry maps.
89  // The size of the page this represents, in address bits.
90  unsigned logBytes;
91 
92  uint16_t asid;
93 
94  PTESv39 pte;
95 
97 
98  // A sequence number to keep track of LRU.
99  uint64_t lruSeq;
100 
102  : paddr(0), vaddr(0), logBytes(0), pte(), lruSeq(0)
103  {}
104 
105  // Return the page size in bytes
106  Addr size() const
107  {
108  return (static_cast<Addr>(1) << logBytes);
109  }
110 
111  void serialize(CheckpointOut &cp) const override;
112  void unserialize(CheckpointIn &cp) override;
113 };
114 
115 } // namespace RiscvISA
116 } // namespace gem5
117 
118 #endif // __ARCH_RISCV_PAGETABLE_H__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Basic support for object serialization.
Definition: serialize.hh:170
Base class for formula statistic node.
Definition: statistics.hh:1524
const Addr LEVEL_BITS
Definition: pagetable.hh:60
Bitfield< 3, 1 > perm
Definition: pagetable.hh:72
Bitfield< 27, 19 > ppn1
Definition: pagetable.hh:66
Bitfield< 6 > a
Definition: pagetable.hh:69
Bitfield< 43, 0 > ppn
Definition: pagetable.hh:48
Bitfield< 53, 28 > ppn2
Definition: pagetable.hh:65
Bitfield< 5 > g
Definition: pagetable.hh:70
Trie< Addr, TlbEntry > TlbEntryTrie
Definition: pagetable.hh:80
Bitfield< 2 > w
Definition: pagetable.hh:74
Bitfield< 4 > u
Definition: pagetable.hh:71
Bitfield< 0 > v
Definition: pagetable.hh:76
EndBitUnion(SATP) enum AddrXlateMode
Definition: pagetable.hh:49
Bitfield< 7 > d
Definition: pagetable.hh:68
Bitfield< 59, 44 > asid
Definition: pagetable.hh:47
Bitfield< 3 > x
Definition: pagetable.hh:73
Bitfield< 18, 10 > ppn0
Definition: pagetable.hh:67
const Addr VADDR_BITS
Definition: pagetable.hh:59
const Addr LEVEL_MASK
Definition: pagetable.hh:61
BitUnion64(SATP) Bitfield< 63
Bitfield< 1 > r
Definition: pagetable.hh:75
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
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:96

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