gem5  v19.0.0.0
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  * 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
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * Authors: Nathan Binkert
29  * Steve Reinhardt
30  */
31 
32 #ifndef __ARCH_ALPHA_PAGETABLE_H__
33 #define __ARCH_ALPHA_PAGETABLE_H__
34 
35 #include "arch/alpha/isa_traits.hh"
36 #include "arch/alpha/utility.hh"
37 
38 namespace AlphaISA {
39 
40 struct VAddr
41 {
42  static const int ImplBits = 43;
43  static const Addr ImplMask = (ULL(1) << ImplBits) - 1;
44  static const Addr UnImplMask = ~ImplMask;
45 
47 
48  VAddr(const VAddr &) = default;
49  VAddr(Addr a) : addr(a) {}
50  operator Addr() const { return addr; }
51  const VAddr &operator=(Addr a) { addr = a; return *this; }
52 
53  Addr vpn() const { return (addr & ImplMask) >> PageShift; }
54  Addr page() const { return addr & PageMask; }
55  Addr offset() const { return addr & PageOffset; }
56 
57  Addr level3() const
58  { return PteAddr(addr >> PageShift); }
59  Addr level2() const
60  { return PteAddr(addr >> (NPtePageShift + PageShift)); }
61  Addr level1() const
62  { return PteAddr(addr >> (2 * NPtePageShift + PageShift)); }
63 };
64 
66 {
67  PageTableEntry(const PageTableEntry &) = default;
68  PageTableEntry(uint64_t e) : entry(e) {}
69  uint64_t entry;
70  operator uint64_t() const { return entry; }
71  const PageTableEntry &operator=(uint64_t e) { entry = e; return *this; }
73  { entry = e.entry; return *this; }
74 
75  Addr _pfn() const { return (entry >> 32) & 0xffffffff; }
76  Addr _sw() const { return (entry >> 16) & 0xffff; }
77  int _rsv0() const { return (entry >> 14) & 0x3; }
78  bool _uwe() const { return (entry >> 13) & 0x1; }
79  bool _kwe() const { return (entry >> 12) & 0x1; }
80  int _rsv1() const { return (entry >> 10) & 0x3; }
81  bool _ure() const { return (entry >> 9) & 0x1; }
82  bool _kre() const { return (entry >> 8) & 0x1; }
83  bool _nomb() const { return (entry >> 7) & 0x1; }
84  int _gh() const { return (entry >> 5) & 0x3; }
85  bool _asm_() const { return (entry >> 4) & 0x1; }
86  bool _foe() const { return (entry >> 3) & 0x1; }
87  bool _fow() const { return (entry >> 2) & 0x1; }
88  bool _for() const { return (entry >> 1) & 0x1; }
89  bool valid() const { return (entry >> 0) & 0x1; }
90 
91  Addr paddr() const { return _pfn() << PageShift; }
92 };
93 
94 // ITB/DTB table entry
95 struct TlbEntry : public Serializable
96 {
97  Addr tag; // virtual page number tag
98  Addr ppn; // physical page number
99  uint8_t xre; // read permissions - VMEM_PERM_* mask
100  uint8_t xwe; // write permissions - VMEM_PERM_* mask
101  uint8_t asn; // address space number
102  bool asma; // address space match
103  bool fonr; // fault on read
104  bool fonw; // fault on write
105  bool valid; // valid page table entry
106 
107 
108  TlbEntry(const TlbEntry &) = default;
109 
110  //Construct an entry that maps to physical address addr.
111  TlbEntry(Addr _asn, Addr _vaddr, Addr _paddr,
112  bool uncacheable, bool read_only)
113  {
114  VAddr vaddr(_vaddr);
115  VAddr paddr(_paddr);
116  tag = vaddr.vpn();
117  ppn = paddr.vpn();
118  xre = 15;
119  xwe = 15;
120  asn = _asn;
121  asma = false;
122  fonr = false;
123  fonw = false;
124  valid = true;
125  if (uncacheable || read_only)
126  warn("Alpha TlbEntry does not support uncacheable"
127  " or read-only mappings\n");
128  }
129 
131  : tag(0), ppn(0), xre(0), xwe(0), asn(0),
132  asma(false), fonr(0), fonw(0), valid(0)
133  {
134  }
135 
136  void
137  updateVaddr(Addr new_vaddr)
138  {
139  VAddr vaddr(new_vaddr);
140  tag = vaddr.vpn();
141  }
142 
143  Addr
145  {
146  return ppn << PageShift;
147  }
148 
149  void serialize(CheckpointOut &cp) const override;
150  void unserialize(CheckpointIn &cp) override;
151 };
152 
153 } // namespace AlphaISA
154 
155 #endif // __ARCH_ALPHA_PAGETABLE_H__
156 
Addr level3() const
Definition: pagetable.hh:57
const PageTableEntry & operator=(const PageTableEntry &e)
Definition: pagetable.hh:72
VAddr(const VAddr &)=default
static const int ImplBits
Definition: pagetable.hh:42
const Addr PageShift
Definition: isa_traits.hh:46
const Addr PageOffset
Definition: isa_traits.hh:49
Addr level1() const
Definition: pagetable.hh:61
VAddr(Addr a)
Definition: pagetable.hh:49
TlbEntry(Addr _asn, Addr _vaddr, Addr _paddr, bool uncacheable, bool read_only)
Definition: pagetable.hh:111
Definition: cprintf.cc:42
const Addr NPtePageShift
Definition: isa_traits.hh:57
const Addr PageMask
Definition: isa_traits.hh:48
void updateVaddr(Addr new_vaddr)
Definition: pagetable.hh:137
Addr PteAddr(Addr a)
Definition: utility.hh:69
static const Addr UnImplMask
Definition: pagetable.hh:44
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
Addr level2() const
Definition: pagetable.hh:59
const VAddr & operator=(Addr a)
Definition: pagetable.hh:51
Addr page() const
Definition: pagetable.hh:54
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
#define ULL(N)
uint64_t constant
Definition: types.hh:50
Bitfield< 5 > a
Definition: pagetable.hh:147
Basic support for object serialization.
Definition: serialize.hh:153
PageTableEntry(uint64_t e)
Definition: pagetable.hh:68
Bitfield< 9 > e
std::ostream CheckpointOut
Definition: serialize.hh:68
Addr vpn() const
Definition: pagetable.hh:53
Addr offset() const
Definition: pagetable.hh:55
void unserialize(ThreadContext &tc, CheckpointIn &cp)
#define warn(...)
Definition: logging.hh:212
static const Addr ImplMask
Definition: pagetable.hh:43
const PageTableEntry & operator=(uint64_t e)
Definition: pagetable.hh:71

Generated on Fri Feb 28 2020 16:26:56 for gem5 by doxygen 1.8.13