gem5  v22.1.0.0
tlb.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2005 The Regents of The University of Michigan
3  * Copyright (c) 2007 MIPS Technologies, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met: redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer;
10  * redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution;
13  * neither the name of the copyright holders nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef __ARCH_MIPS_TLB_HH__
31 #define __ARCH_MIPS_TLB_HH__
32 
33 #include <map>
34 
35 #include "arch/generic/tlb.hh"
36 #include "arch/mips/pagetable.hh"
37 #include "arch/mips/utility.hh"
38 #include "base/statistics.hh"
39 #include "mem/request.hh"
40 #include "params/MipsTLB.hh"
41 #include "sim/sim_object.hh"
42 
43 namespace gem5
44 {
45 
46 class ThreadContext;
47 
48 /* MIPS does not distinguish between a DTLB and an ITLB -> unified TLB
49  However, to maintain compatibility with other architectures, we'll
50  simply create an ITLB and DTLB that will point to the real TLB */
51 namespace MipsISA {
52 
53 class TLB : public BaseTLB
54 {
55  protected:
56  typedef std::multimap<Addr, int> PageTable;
57  PageTable lookupTable; // Quick lookup into page table
58 
59  MipsISA::PTE *table; // the Page Table
60  int size; // TLB Size
61  int nlu; // not last used entry (for replacement)
62 
63  void nextnlu() { if (++nlu >= size) nlu = 0; }
64  MipsISA::PTE *lookup(Addr vpn, uint8_t asn) const;
65 
66  public:
67  typedef MipsTLBParams Params;
68  TLB(const Params &p);
69 
70  int probeEntry(Addr vpn,uint8_t) const;
71  MipsISA::PTE *getEntry(unsigned) const;
72  virtual ~TLB();
73 
74  void takeOverFrom(BaseTLB *otlb) override {}
75 
77  int getsize() const { return size; }
78 
79  MipsISA::PTE &index(bool advance = true);
81  void insertAt(MipsISA::PTE &pte, unsigned Index, int _smallPages);
82  void flushAll() override;
83  void demapPage(Addr vaddr, uint64_t asn) override
84  {
85  panic("demapPage unimplemented.\n");
86  }
87 
88  // static helper functions... really
90 
91  static Fault checkCacheability(const RequestPtr &req);
92 
93  // Checkpointing
94  void serialize(CheckpointOut &cp) const override;
95  void unserialize(CheckpointIn &cp) override;
96 
98  const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override;
100  const RequestPtr &req, ThreadContext *tc,
101  BaseMMU::Translation *translation, BaseMMU::Mode mode) override;
103  const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override;
105  const RequestPtr &req,
106  ThreadContext *tc, BaseMMU::Mode mode) const override;
107 };
108 
109 } // namespace MipsISA
110 } // namespace gem5
111 
112 #endif // __MIPS_MEMORY_HH__
MipsISA::PTE * table
Definition: tlb.hh:59
static Fault checkCacheability(const RequestPtr &req)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
PageTable lookupTable
Definition: tlb.hh:57
static bool validVirtualAddress(Addr vaddr)
void insertAt(MipsISA::PTE &pte, unsigned Index, int _smallPages)
int smallPages
Definition: tlb.hh:76
int getsize() const
Definition: tlb.hh:77
void translateTiming(const RequestPtr &req, ThreadContext *tc, BaseMMU::Translation *translation, BaseMMU::Mode mode) override
MipsISA::PTE * getEntry(unsigned) const
void serialize(CheckpointOut &cp) const override
Serialize an object.
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
void insert(Addr vaddr, MipsISA::PTE &pte)
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) const override
Do post-translation physical address finalization.
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
void nextnlu()
Definition: tlb.hh:63
int probeEntry(Addr vpn, uint8_t) const
TLB(const Params &p)
void demapPage(Addr vaddr, uint64_t asn) override
Definition: tlb.hh:83
std::multimap< Addr, int > PageTable
Definition: tlb.hh:56
MipsISA::PTE * lookup(Addr vpn, uint8_t asn) const
void takeOverFrom(BaseTLB *otlb) override
Take over from an old tlb context.
Definition: tlb.hh:74
MipsISA::PTE & index(bool advance=true)
MipsTLBParams Params
Definition: tlb.hh:67
void flushAll() override
Remove all entries from the TLB.
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< 11, 7 > mode
Definition: dt_constants.hh:98
Bitfield< 0 > p
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 ...
Declaration of Statistics objects.

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