gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
BitUnion64(SATP) Bitfield< 63
Bitfield< 1 > r
Definition: pagetable.hh:71
unsigned logBytes
Definition: pagetable.hh:86
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pagetable.cc:40
Definition: cprintf.cc:40
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pagetable.cc:51
Trie< Addr, TlbEntry > TlbEntryTrie
Definition: pagetable.hh:76
Bitfield< 3, 1 > perm
Definition: pagetable.hh:68
Bitfield< 3 > x
Definition: pagetable.hh:69
Bitfield< 6 > a
Definition: pagetable.hh:65
Bitfield< 59, 44 > asid
Definition: pagetable.hh:43
Bitfield< 27, 19 > ppn1
Definition: pagetable.hh:62
EndBitUnion(SATP) enum AddrXlateMode
Definition: pagetable.hh:45
Bitfield< 0 > v
Definition: pagetable.hh:72
const Addr LEVEL_BITS
Definition: pagetable.hh:56
Bitfield< 4 > u
Definition: pagetable.hh:67
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
const Addr LEVEL_MASK
Definition: pagetable.hh:57
Basic support for object serialization.
Definition: serialize.hh:166
Bitfield< 18, 10 > ppn0
Definition: pagetable.hh:63
Addr size() const
Definition: pagetable.hh:102
Bitfield< 7 > d
Definition: pagetable.hh:64
Bitfield< 5 > g
Definition: pagetable.hh:66
std::ostream CheckpointOut
Definition: serialize.hh:63
const Addr VADDR_BITS
Definition: pagetable.hh:55
Bitfield< 43, 0 > ppn
Definition: pagetable.hh:44
TlbEntryTrie::Handle trieHandle
Definition: pagetable.hh:92
Bitfield< 53, 28 > ppn2
Definition: pagetable.hh:61
Bitfield< 2 > w
Definition: pagetable.hh:70

Generated on Mon Jun 8 2020 15:34:40 for gem5 by doxygen 1.8.13