gem5  v20.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/logging.hh"
35 #include "base/trie.hh"
36 #include "base/types.hh"
37 #include "sim/serialize.hh"
38 
39 namespace RiscvISA {
40 
41 BitUnion64(SATP)
42  Bitfield<63, 60> mode;
43  Bitfield<59, 44> asid;
44  Bitfield<43, 0> ppn;
46 
47 enum AddrXlateMode
48 {
49  BARE = 0,
50  SV39 = 8,
51  SV48 = 9,
52 };
53 
54 // Sv39 paging
55 const Addr VADDR_BITS = 39;
56 const Addr LEVEL_BITS = 9;
57 const Addr LEVEL_MASK = (1 << LEVEL_BITS) - 1;
58 
59 BitUnion64(PTESv39)
60  Bitfield<53, 10> ppn;
61  Bitfield<53, 28> ppn2;
62  Bitfield<27, 19> ppn1;
63  Bitfield<18, 10> ppn0;
64  Bitfield<7> d;
65  Bitfield<6> a;
66  Bitfield<5> g;
67  Bitfield<4> u;
68  Bitfield<3, 1> perm;
69  Bitfield<3> x;
70  Bitfield<2> w;
71  Bitfield<1> r;
72  Bitfield<0> v;
73 EndBitUnion(PTESv39)
74 
75 struct TlbEntry;
77 
78 struct TlbEntry : public Serializable
79 {
80  // The base of the physical page.
82 
83  // The beginning of the virtual page this entry maps.
85  // The size of the page this represents, in address bits.
86  unsigned logBytes;
87 
88  uint16_t asid;
89 
90  PTESv39 pte;
91 
93 
94  // A sequence number to keep track of LRU.
95  uint64_t lruSeq;
96 
98  : paddr(0), vaddr(0), logBytes(0), pte(), lruSeq(0)
99  {}
100 
101  // Return the page size in bytes
102  Addr size() const
103  {
104  return (static_cast<Addr>(1) << logBytes);
105  }
106 
107  void serialize(CheckpointOut &cp) const override;
108  void unserialize(CheckpointIn &cp) override;
109 };
110 
111 };
112 #endif // __ARCH_RISCV_PAGETABLE_H__
113 
RiscvISA::TlbEntry
Definition: pagetable.hh:78
RiscvISA::mode
mode
Definition: pagetable.hh:42
serialize.hh
RiscvISA::TlbEntry::size
Addr size() const
Definition: pagetable.hh:102
Trie< Addr, TlbEntry >::Handle
Node * Handle
Definition: trie.hh:122
RiscvISA::ppn
Bitfield< 43, 0 > ppn
Definition: pagetable.hh:44
RiscvISA::w
Bitfield< 2 > w
Definition: pagetable.hh:70
Serializable
Basic support for object serialization.
Definition: serialize.hh:172
RiscvISA::ppn0
Bitfield< 18, 10 > ppn0
Definition: pagetable.hh:63
RiscvISA::TlbEntry::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pagetable.cc:51
RiscvISA::g
Bitfield< 5 > g
Definition: pagetable.hh:66
RiscvISA::TlbEntry::logBytes
unsigned logBytes
Definition: pagetable.hh:86
RiscvISA::asid
Bitfield< 59, 44 > asid
Definition: pagetable.hh:43
RiscvISA::TlbEntry::lruSeq
uint64_t lruSeq
Definition: pagetable.hh:95
RiscvISA::u
Bitfield< 4 > u
Definition: pagetable.hh:67
Trie< Addr, TlbEntry >
RiscvISA
Definition: fs_workload.cc:36
RiscvISA::VADDR_BITS
const Addr VADDR_BITS
Definition: pagetable.hh:55
RiscvISA::TlbEntry::TlbEntry
TlbEntry()
Definition: pagetable.hh:97
cp
Definition: cprintf.cc:40
RiscvISA::TlbEntry::pte
PTESv39 pte
Definition: pagetable.hh:90
RiscvISA::BitUnion64
BitUnion64(SATP) Bitfield< 63
RiscvISA::LEVEL_MASK
const Addr LEVEL_MASK
Definition: pagetable.hh:57
RiscvISA::perm
Bitfield< 3, 1 > perm
Definition: pagetable.hh:68
RiscvISA::x
Bitfield< 3 > x
Definition: pagetable.hh:69
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
RiscvISA::v
Bitfield< 0 > v
Definition: pagetable.hh:72
RiscvISA::ppn1
Bitfield< 27, 19 > ppn1
Definition: pagetable.hh:62
RiscvISA::LEVEL_BITS
const Addr LEVEL_BITS
Definition: pagetable.hh:56
RiscvISA::EndBitUnion
EndBitUnion(SATP) enum AddrXlateMode
Definition: pagetable.hh:45
RiscvISA::ppn2
Bitfield< 53, 28 > ppn2
Definition: pagetable.hh:61
types.hh
RiscvISA::r
Bitfield< 1 > r
Definition: pagetable.hh:71
logging.hh
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
RiscvISA::a
Bitfield< 6 > a
Definition: pagetable.hh:65
RiscvISA::TlbEntry::trieHandle
TlbEntryTrie::Handle trieHandle
Definition: pagetable.hh:92
CheckpointIn
Definition: serialize.hh:67
RiscvISA::d
Bitfield< 7 > d
Definition: pagetable.hh:64
RiscvISA::TlbEntryTrie
Trie< Addr, TlbEntry > TlbEntryTrie
Definition: pagetable.hh:76
RiscvISA::TlbEntry::vaddr
Addr vaddr
Definition: pagetable.hh:84
RiscvISA::TlbEntry::paddr
Addr paddr
Definition: pagetable.hh:81
trie.hh
RiscvISA::TlbEntry::asid
uint16_t asid
Definition: pagetable.hh:88
RiscvISA::TlbEntry::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pagetable.cc:40

Generated on Wed Sep 30 2020 14:02:01 for gem5 by doxygen 1.8.17