gem5  v20.1.0.0
tlb.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 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 
29 #ifndef __ARCH_SPARC_TLB_HH__
30 #define __ARCH_SPARC_TLB_HH__
31 
32 #include "arch/generic/tlb.hh"
33 #include "arch/sparc/asi.hh"
34 #include "arch/sparc/tlb_map.hh"
35 #include "base/logging.hh"
36 #include "mem/request.hh"
37 #include "params/SparcTLB.hh"
38 
39 class ThreadContext;
40 class Packet;
41 
42 namespace SparcISA
43 {
44 
45 const Addr StartVAddrHole = ULL(0x0000800000000000);
46 const Addr EndVAddrHole = ULL(0xFFFF7FFFFFFFFFFF);
47 const Addr VAddrAMask = ULL(0xFFFFFFFF);
48 const Addr PAddrImplMask = ULL(0x000000FFFFFFFFFF);
49 
50 class TLB : public BaseTLB
51 {
52  // These faults need to be able to populate the tlb in SE mode.
54  friend class FastDataAccessMMUMiss;
55 
56  // TLB state
57  protected:
58  // Only used when this is the data TLB.
59  uint64_t sfar;
60  uint64_t c0_tsb_ps0;
61  uint64_t c0_tsb_ps1;
62  uint64_t c0_config;
63  uint64_t cx_tsb_ps0;
64  uint64_t cx_tsb_ps1;
65  uint64_t cx_config;
66  uint64_t sfsr;
67  uint64_t tag_access;
68 
69  protected:
71  typedef TlbMap::iterator MapIter;
72 
74 
75  int size;
78 
79  uint64_t cacheState;
80  bool cacheValid;
81 
83 
84  enum FaultTypes {
87  SideEffect = 0x2,
88  AtomicToIo = 0x4,
89  IllegalAsi = 0x8,
90  LoadFromNfo = 0x10,
91  VaOutOfRange = 0x20,
93  };
94 
95  enum ContextType {
96  Primary = 0,
97  Secondary = 1,
98  Nucleus = 2
99  };
100 
101  enum TsbPageSize {
104  };
105  public:
117  TlbEntry *lookup(Addr va, int partition_id, bool real, int context_id = 0,
118  bool update_used = true);
119 
121  void flushAll() override;
122 
123  protected:
125  void insert(Addr vpn, int partition_id, int context_id, bool real,
126  const PageTableEntry& PTE, int entry = -1);
127 
129  uint64_t TagRead(int entry);
130 
132  void demapAll(int partition_id);
133 
135  void demapContext(int partition_id, int context_id);
136 
139  void demapPage(Addr va, int partition_id, bool real, int context_id);
140 
142  bool validVirtualAddress(Addr va, bool am);
143 
144  void writeSfsr(bool write, ContextType ct,
145  bool se, FaultTypes ft, int asi);
146 
147  void clearUsedBits();
148 
149 
150  void writeTagAccess(Addr va, int context);
151 
152  Fault translateInst(const RequestPtr &req, ThreadContext *tc);
153  Fault translateData(const RequestPtr &req, ThreadContext *tc, bool write);
154 
155  public:
156  typedef SparcTLBParams Params;
157  TLB(const Params *p);
158 
159  void takeOverFrom(BaseTLB *otlb) override {}
160 
161  void
162  demapPage(Addr vaddr, uint64_t asn) override
163  {
164  panic("demapPage(Addr) is not implemented.\n");
165  }
166 
167  void dumpAll();
168 
170  const RequestPtr &req, ThreadContext *tc, Mode mode) override;
172  const RequestPtr &req, ThreadContext *tc, Mode mode) override;
173  void translateTiming(
174  const RequestPtr &req, ThreadContext *tc,
175  Translation *translation, Mode mode) override;
177  const RequestPtr &req,
178  ThreadContext *tc, Mode mode) const override;
181  void GetTsbPtr(ThreadContext *tc, Addr addr, int ctx, Addr *ptrs);
182 
183  // Checkpointing
184  void serialize(CheckpointOut &cp) const override;
185  void unserialize(CheckpointIn &cp) override;
186 
188  uint64_t TteRead(int entry);
189 
190  private:
191  void writeSfsr(Addr a, bool write, ContextType ct,
192  bool se, FaultTypes ft, int asi);
193 
194  uint64_t MakeTsbPtr(TsbPageSize ps, uint64_t tag_access, uint64_t c0_tsb,
195  uint64_t c0_config, uint64_t cX_tsb, uint64_t cX_config);
196 
197 
200 };
201 
202 }
203 
204 #endif // __ARCH_SPARC_TLB_HH__
SparcISA::TLB
Definition: tlb.hh:50
SparcISA::TLB::TteRead
uint64_t TteRead(int entry)
Give an entry id, read that tlb entries' tte.
Definition: tlb.cc:337
SparcISA::TLB::c0_tsb_ps1
uint64_t c0_tsb_ps1
Definition: tlb.hh:61
SparcISA::TLB::cx_tsb_ps0
uint64_t cx_tsb_ps0
Definition: tlb.hh:63
SparcISA::TLB::demapContext
void demapContext(int partition_id, int context_id)
Remove all entries that match a given context/partition id.
Definition: tlb.cc:281
SparcISA::TLB::demapPage
void demapPage(Addr va, int partition_id, bool real, int context_id)
Remve all entries that match a certain partition id, (contextid), and va).
Definition: tlb.cc:249
SparcISA::TLB::freeList
std::list< TlbEntry * > freeList
Definition: tlb.hh:82
SparcISA::EndVAddrHole
const Addr EndVAddrHole
Definition: tlb.hh:46
SparcISA::TLB::cacheState
uint64_t cacheState
Definition: tlb.hh:79
SparcISA::TLB::c0_tsb_ps0
uint64_t c0_tsb_ps0
Definition: tlb.hh:60
SparcISA::TLB::FaultTypes
FaultTypes
Definition: tlb.hh:84
SparcISA::TLB::GetTsbPtr
void GetTsbPtr(ThreadContext *tc, Addr addr, int ctx, Addr *ptrs)
Definition: tlb.cc:1388
SparcISA::TLB::translateAtomic
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) override
Definition: tlb.cc:829
SparcISA::TLB::Primary
@ Primary
Definition: tlb.hh:96
tlb_map.hh
SparcISA::TLB::demapPage
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:162
SparcISA::TLB::OtherFault
@ OtherFault
Definition: tlb.hh:85
SparcISA::TLB::Secondary
@ Secondary
Definition: tlb.hh:97
SparcISA::TLB::translateFunctional
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, Mode mode) override
Definition: tlb.cc:838
tlb.hh
BaseTLB::Mode
Mode
Definition: tlb.hh:57
SparcISA::TlbEntry
Definition: pagetable.hh:221
SparcISA::TLB::usedEntries
int usedEntries
Definition: tlb.hh:76
SparcISA::TLB::Nucleus
@ Nucleus
Definition: tlb.hh:98
SparcISA::TLB::translateData
Fault translateData(const RequestPtr &req, ThreadContext *tc, bool write)
Definition: tlb.cc:526
SparcISA::TLB::lookup
TlbEntry * lookup(Addr va, int partition_id, bool real, int context_id=0, bool update_used=true)
lookup an entry in the TLB based on the partition id, and real bit if real is true or the partition i...
Definition: tlb.cc:191
RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:82
SparcISA::TLB::IllegalAsi
@ IllegalAsi
Definition: tlb.hh:89
SparcISA::TLB::doMmuRegWrite
Cycles doMmuRegWrite(ThreadContext *tc, Packet *pkt)
Definition: tlb.cc:1134
SparcISA::TLB::cx_config
uint64_t cx_config
Definition: tlb.hh:65
SparcISA::TLB::writeSfsr
void writeSfsr(bool write, ContextType ct, bool se, FaultTypes ft, int asi)
Definition: tlb.cc:376
SparcISA::TLB::sfar
uint64_t sfar
Definition: tlb.hh:59
SparcISA::TLB::MakeTsbPtr
uint64_t MakeTsbPtr(TsbPageSize ps, uint64_t tag_access, uint64_t c0_tsb, uint64_t c0_config, uint64_t cX_tsb, uint64_t cX_config)
Definition: tlb.cc:1415
SparcISA::TLB::LoadFromNfo
@ LoadFromNfo
Definition: tlb.hh:90
SparcISA::TLB::cacheEntry
TlbEntry * cacheEntry[2]
Definition: tlb.hh:198
SparcISA::TLB::Ps1
@ Ps1
Definition: tlb.hh:103
SparcISA::VAddrAMask
const Addr VAddrAMask
Definition: tlb.hh:47
request.hh
BaseTLB
Definition: tlb.hh:50
SparcISA::TLB::tag_access
uint64_t tag_access
Definition: tlb.hh:67
SparcISA::TLB::doMmuRegRead
Cycles doMmuRegRead(ThreadContext *tc, Packet *pkt)
Definition: tlb.cc:949
SparcISA
Definition: asi.cc:31
SparcISA::TLB::MapIter
TlbMap::iterator MapIter
Definition: tlb.hh:70
SparcISA::TLB::PrivViolation
@ PrivViolation
Definition: tlb.hh:86
SparcISA::TLB::lastReplaced
int lastReplaced
Definition: tlb.hh:77
cp
Definition: cprintf.cc:40
SparcISA::TLB::TLB
TLB(const Params *p)
Definition: tlb.cc:55
SparcISA::TLB::cacheValid
bool cacheValid
Definition: tlb.hh:80
ArmISA::a
Bitfield< 8 > a
Definition: miscregs_types.hh:62
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
SparcISA::TLB::clearUsedBits
void clearUsedBits()
Definition: tlb.cc:83
SparcISA::TLB::flushAll
void flushAll() override
Remove all entries from the TLB.
Definition: tlb.cc:322
SparcISA::TLB::insert
void insert(Addr vpn, int partition_id, int context_id, bool real, const PageTableEntry &PTE, int entry=-1)
Insert a PTE into the TLB.
Definition: tlb.cc:97
SparcISA::TLB::lookupTable
TlbMap lookupTable
Definition: tlb.hh:70
SparcISA::am
Bitfield< 3 > am
Definition: miscregs.hh:127
asi.hh
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
MipsISA::vaddr
vaddr
Definition: pra_constants.hh:275
SparcISA::TLB::SideEffect
@ SideEffect
Definition: tlb.hh:87
SparcISA::TLB::cx_tsb_ps1
uint64_t cx_tsb_ps1
Definition: tlb.hh:64
SparcISA::TLB::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: tlb.cc:1442
ArmISA::mode
Bitfield< 4, 0 > mode
Definition: miscregs_types.hh:70
SparcISA::TLB::takeOverFrom
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:159
SparcISA::TLB::Params
SparcTLBParams Params
Definition: tlb.hh:156
SparcISA::TLB::demapAll
void demapAll(int partition_id)
Remove all non-locked entries from the tlb that match partition id.
Definition: tlb.cc:303
SparcISA::TLB::dumpAll
void dumpAll()
Definition: tlb.cc:235
SparcISA::TlbMap::iterator
RangeMap::iterator iterator
Definition: tlb_map.hh:46
SparcISA::PAddrImplMask
const Addr PAddrImplMask
Definition: tlb.hh:48
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
SparcISA::TLB::cacheAsi
ASI cacheAsi[2]
Definition: tlb.hh:199
SparcISA::ASI
ASI
Definition: asi.hh:35
SparcISA::TLB::TsbPageSize
TsbPageSize
Definition: tlb.hh:101
SparcISA::TLB::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: tlb.cc:1472
SparcISA::TLB::Ps0
@ Ps0
Definition: tlb.hh:102
SparcISA::TLB::size
int size
Definition: tlb.hh:75
SparcISA::TLB::ContextType
ContextType
Definition: tlb.hh:95
SparcISA::TLB::translateTiming
void translateTiming(const RequestPtr &req, ThreadContext *tc, Translation *translation, Mode mode) override
Definition: tlb.cc:934
SparcISA::TLB::translateInst
Fault translateInst(const RequestPtr &req, ThreadContext *tc)
Definition: tlb.cc:412
SparcISA::FastInstructionAccessMMUMiss
Definition: faults.hh:204
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
SparcISA::TLB::sfsr
uint64_t sfsr
Definition: tlb.hh:66
addr
ip6_addr_t addr
Definition: inet.hh:423
SparcISA::TlbMap
Definition: tlb_map.hh:39
SparcISA::TLB::tlb
TlbEntry * tlb
Definition: tlb.hh:73
SparcISA::TLB::writeTagAccess
void writeTagAccess(Addr va, int context)
Definition: tlb.cc:393
SparcISA::TLB::validVirtualAddress
bool validVirtualAddress(Addr va, bool am)
Checks if the virtual address provided is a valid one.
Definition: tlb.cc:366
logging.hh
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
SparcISA::StartVAddrHole
const Addr StartVAddrHole
Definition: tlb.hh:45
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
SparcISA::TLB::finalizePhysical
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, Mode mode) const override
Do post-translation physical address finalization.
Definition: tlb.cc:942
SparcISA::TLB::VaOutOfRange
@ VaOutOfRange
Definition: tlb.hh:91
SparcISA::FastDataAccessMMUMiss
Definition: faults.hh:218
SparcISA::PageTableEntry
Definition: pagetable.hh:65
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
std::list< TlbEntry * >
ArmISA::ps
Bitfield< 18, 16 > ps
Definition: miscregs_types.hh:508
CheckpointIn
Definition: serialize.hh:67
SparcISA::TLB::VaOutOfRangeJmp
@ VaOutOfRangeJmp
Definition: tlb.hh:92
SparcISA::TLB::TagRead
uint64_t TagRead(int entry)
Given an entry id, read that tlb entries' tag.
Definition: tlb.cc:350
SparcISA::TLB::AtomicToIo
@ AtomicToIo
Definition: tlb.hh:88
ULL
#define ULL(N)
uint64_t constant
Definition: types.hh:50
SparcISA::TLB::c0_config
uint64_t c0_config
Definition: tlb.hh:62
ArmISA::va
Bitfield< 8 > va
Definition: miscregs_types.hh:272
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171

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