gem5  v22.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 namespace gem5
40 {
41 
42 class ThreadContext;
43 class Packet;
44 
45 namespace SparcISA
46 {
47 
48 const Addr StartVAddrHole = 0x0000800000000000ULL;
49 const Addr EndVAddrHole = 0xFFFF7FFFFFFFFFFFULL;
50 const Addr VAddrAMask = 0xFFFFFFFFULL;
51 const Addr PAddrImplMask = 0x000000FFFFFFFFFFULL;
52 
53 class TLB : public BaseTLB
54 {
55  friend class MMU;
56 
57  // TLB state
58  protected:
59  // Only used when this is the data TLB.
60  uint64_t sfar;
61  uint64_t c0_tsb_ps0;
62  uint64_t c0_tsb_ps1;
63  uint64_t c0_config;
64  uint64_t cx_tsb_ps0;
65  uint64_t cx_tsb_ps1;
66  uint64_t cx_config;
67  uint64_t sfsr;
68  uint64_t tag_access;
69 
70  protected:
73 
75 
76  int size;
79 
80  uint64_t cacheState;
81  bool cacheValid;
82 
84 
86  {
89  SideEffect = 0x2,
90  AtomicToIo = 0x4,
91  IllegalAsi = 0x8,
92  LoadFromNfo = 0x10,
93  VaOutOfRange = 0x20,
94  VaOutOfRangeJmp = 0x40
95  };
96 
98  {
99  Primary = 0,
101  Nucleus = 2
102  };
103 
105  {
107  Ps1
108  };
109  public:
121  TlbEntry *lookup(Addr va, int partition_id, bool real, int context_id = 0,
122  bool update_used = true);
123 
125  void flushAll() override;
126 
127  protected:
129  void insert(Addr vpn, int partition_id, int context_id, bool real,
130  const PageTableEntry& PTE, int entry = -1);
131 
133  uint64_t TagRead(int entry);
134 
136  void demapAll(int partition_id);
137 
139  void demapContext(int partition_id, int context_id);
140 
143  void demapPage(Addr va, int partition_id, bool real, int context_id);
144 
146  bool validVirtualAddress(Addr va, bool am);
147 
148  void writeSfsr(bool write, ContextType ct,
149  bool se, FaultTypes ft, int asi);
150 
151  void clearUsedBits();
152 
153 
154  void writeTagAccess(Addr va, int context);
155 
156  Fault translateInst(const RequestPtr &req, ThreadContext *tc);
157  Fault translateData(const RequestPtr &req, ThreadContext *tc, bool write);
158 
159  public:
160  typedef SparcTLBParams Params;
161  TLB(const Params &p);
162 
163  void takeOverFrom(BaseTLB *otlb) override {}
164 
165  void
166  demapPage(Addr vaddr, uint64_t asn) override
167  {
168  panic("demapPage(Addr) is not implemented.\n");
169  }
170 
171  void dumpAll();
172 
174  const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override;
176  const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override;
177  void translateTiming(
178  const RequestPtr &req, ThreadContext *tc,
179  BaseMMU::Translation *translation, BaseMMU::Mode mode) override;
181  const RequestPtr &req,
182  ThreadContext *tc, BaseMMU::Mode mode) const override;
185  void GetTsbPtr(ThreadContext *tc, Addr addr, int ctx, Addr *ptrs);
186 
187  // Checkpointing
188  void serialize(CheckpointOut &cp) const override;
189  void unserialize(CheckpointIn &cp) override;
190 
192  uint64_t TteRead(int entry);
193 
194  private:
195  void writeSfsr(Addr a, bool write, ContextType ct,
196  bool se, FaultTypes ft, int asi);
197 
198  uint64_t MakeTsbPtr(TsbPageSize ps, uint64_t tag_access, uint64_t c0_tsb,
199  uint64_t c0_config, uint64_t cX_tsb, uint64_t cX_config);
200 
201 
204 };
205 
206 } // namespace SparcISA
207 } // namespace gem5
208 
209 #endif // __ARCH_SPARC_TLB_HH__
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
uint64_t c0_tsb_ps0
Definition: tlb.hh:61
uint64_t TagRead(int entry)
Given an entry id, read that tlb entries' tag.
Definition: tlb.cc:355
TLB(const Params &p)
Definition: tlb.cc:60
uint64_t cx_tsb_ps1
Definition: tlb.hh:65
bool cacheValid
Definition: tlb.hh:81
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:254
void dumpAll()
Definition: tlb.cc:240
void GetTsbPtr(ThreadContext *tc, Addr addr, int ctx, Addr *ptrs)
Definition: tlb.cc:1393
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: tlb.cc:1477
Cycles doMmuRegWrite(ThreadContext *tc, Packet *pkt)
Definition: tlb.cc:1141
uint64_t c0_config
Definition: tlb.hh:63
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:1420
TlbMap::iterator MapIter
Definition: tlb.hh:71
TlbEntry * cacheEntry[2]
Definition: tlb.hh:202
SparcTLBParams Params
Definition: tlb.hh:160
void writeSfsr(bool write, ContextType ct, bool se, FaultTypes ft, int asi)
Definition: tlb.cc:381
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:166
std::list< TlbEntry * > freeList
Definition: tlb.hh:83
void clearUsedBits()
Definition: tlb.cc:88
void flushAll() override
Remove all entries from the TLB.
Definition: tlb.cc:327
void demapContext(int partition_id, int context_id)
Remove all entries that match a given context/partition id.
Definition: tlb.cc:286
TlbEntry * tlb
Definition: tlb.hh:74
uint64_t sfsr
Definition: tlb.hh:67
uint64_t c0_tsb_ps1
Definition: tlb.hh:62
ASI cacheAsi[2]
Definition: tlb.hh:203
void translateTiming(const RequestPtr &req, ThreadContext *tc, BaseMMU::Translation *translation, BaseMMU::Mode mode) override
Definition: tlb.cc:941
uint64_t TteRead(int entry)
Give an entry id, read that tlb entries' tte.
Definition: tlb.cc:342
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) const override
Do post-translation physical address finalization.
Definition: tlb.cc:949
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
Definition: tlb.cc:834
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:196
uint64_t sfar
Definition: tlb.hh:60
Fault translateInst(const RequestPtr &req, ThreadContext *tc)
Definition: tlb.cc:219
Fault translateData(const RequestPtr &req, ThreadContext *tc, bool write)
Definition: tlb.cc:234
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:102
TlbMap lookupTable
Definition: tlb.hh:71
uint64_t cx_tsb_ps0
Definition: tlb.hh:64
bool validVirtualAddress(Addr va, bool am)
Checks if the virtual address provided is a valid one.
Definition: tlb.cc:371
void demapAll(int partition_id)
Remove all non-locked entries from the tlb that match partition id.
Definition: tlb.cc:308
uint64_t tag_access
Definition: tlb.hh:68
int lastReplaced
Definition: tlb.hh:78
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: tlb.cc:1447
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
Definition: tlb.cc:844
uint64_t cx_config
Definition: tlb.hh:66
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:163
uint64_t cacheState
Definition: tlb.hh:80
void writeTagAccess(Addr va, int context)
Definition: tlb.cc:398
Cycles doMmuRegRead(ThreadContext *tc, Packet *pkt)
Definition: tlb.cc:956
RangeMap::iterator iterator
Definition: tlb_map.hh:49
ThreadContext is the external interface to all thread state for anything outside of the CPU.
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
Bitfield< 4, 0 > mode
Definition: misc_types.hh:74
Bitfield< 18, 16 > ps
Definition: misc_types.hh:520
Bitfield< 8 > a
Definition: misc_types.hh:66
Bitfield< 8 > va
Definition: misc_types.hh:282
const Addr VAddrAMask
Definition: tlb.hh:50
const Addr EndVAddrHole
Definition: tlb.hh:49
Bitfield< 3 > am
Definition: misc.hh:132
const Addr StartVAddrHole
Definition: tlb.hh:48
const Addr PAddrImplMask
Definition: tlb.hh:51
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 3 > addr
Definition: types.hh:84
ProbePointArg< PacketInfo > Packet
Packet probe point.
Definition: mem.hh:109
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
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
Declaration of a request, the overall memory request consisting of the parts of the request that are ...

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