gem5 v24.0.0.0
Loading...
Searching...
No Matches
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 * Copyright (c) 2020 Barkhausen Institut
5 * Copyright (c) 2021 Huawei International
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met: redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer;
12 * redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution;
15 * neither the name of the copyright holders nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef __ARCH_RISCV_TLB_HH__
33#define __ARCH_RISCV_TLB_HH__
34
35#include <list>
36
37#include "arch/generic/tlb.hh"
38#include "arch/riscv/isa.hh"
42#include "arch/riscv/utility.hh"
43#include "base/statistics.hh"
44#include "mem/request.hh"
45#include "params/RiscvTLB.hh"
46#include "sim/sim_object.hh"
47
48namespace gem5
49{
50
51class ThreadContext;
52
53/* To maintain compatibility with other architectures, we'll
54 simply create an ITLB and DTLB that will point to the real TLB */
55namespace RiscvISA {
56
57class Walker;
58
59class TLB : public BaseTLB
60{
62
63 protected:
64 size_t size;
66 TlbEntryTrie trie; // for quick access
67 EntryList freeList; // free entries
68 uint64_t lruSeq;
69
71
87
88 public:
91
92 public:
93 typedef RiscvTLBParams Params;
94 TLB(const Params &p);
95
97
98 void takeOverFrom(BaseTLB *old) override {}
99
100 TlbEntry *insert(Addr vpn, const TlbEntry &entry);
101 void flushAll() override;
102 void demapPage(Addr vaddr, uint64_t asn) override;
103
105 BaseMMU::Mode mode, PTESv39 pte);
107
109
110 // Checkpointing
111 void serialize(CheckpointOut &cp) const override;
112 void unserialize(CheckpointIn &cp) override;
113
125
127
129 ThreadContext *tc, BaseMMU::Mode mode) override;
131 BaseMMU::Translation *translation,
132 BaseMMU::Mode mode) override;
134 BaseMMU::Mode mode) override;
136 BaseMMU::Mode mode) const override;
137 TlbEntry *lookup(Addr vpn, uint16_t asid, BaseMMU::Mode mode, bool hidden);
138
139 private:
140 uint64_t nextSeq() { return ++lruSeq; }
141
142 void evictLRU();
143 void remove(size_t idx);
144
145 Fault translate(const RequestPtr &req, ThreadContext *tc,
147 bool &delayed);
150 bool &delayed);
151};
152
153} // namespace RiscvISA
154} // namespace gem5
155
156#endif // __RISCV_MEMORY_HH__
Ports are used to interface objects to each other.
Definition port.hh:62
Based on the RISC-V ISA privileged specifications V1.11, there is no implementation guidelines on the...
This class helps to implement RISCV's physical memory protection (pmp) primitive.
Definition pmp.hh:58
void remove(size_t idx)
Definition tlb.cc:210
void translateTiming(const RequestPtr &req, ThreadContext *tc, BaseMMU::Translation *translation, BaseMMU::Mode mode) override
RiscvTLBParams Params
Definition tlb.hh:93
void unserialize(CheckpointIn &cp) override
Unserialize an object.
TLB(const Params &p)
Fault finalizePhysical(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) const override
Do post-translation physical address finalization.
Walker * walker
Definition tlb.hh:70
Fault createPagefault(Addr vaddr, BaseMMU::Mode mode)
Definition tlb.cc:257
BasePMAChecker * pma
Definition tlb.hh:89
Port * getTableWalkerPort() override
Get the table walker port.
gem5::RiscvISA::TLB::TlbStats stats
TlbEntry * insert(Addr vpn, const TlbEntry &entry)
Definition tlb.cc:143
Walker * getWalker()
uint64_t lruSeq
Definition tlb.hh:68
EntryList freeList
Definition tlb.hh:67
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
std::list< TlbEntry * > EntryList
Definition tlb.hh:61
uint64_t nextSeq()
Definition tlb.hh:140
std::vector< TlbEntry > tlb
Definition tlb.hh:65
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
TlbEntryTrie trie
Definition tlb.hh:66
PrivilegeMode getMemPriv(ThreadContext *tc, BaseMMU::Mode mode)
Definition tlb.cc:326
void flushAll() override
Remove all entries from the TLB.
TlbEntry * lookup(Addr vpn, uint16_t asid, BaseMMU::Mode mode, bool hidden)
Definition tlb.cc:109
Fault doTranslate(const RequestPtr &req, ThreadContext *tc, BaseMMU::Translation *translation, BaseMMU::Mode mode, bool &delayed)
Definition tlb.cc:278
Fault translate(const RequestPtr &req, ThreadContext *tc, BaseMMU::Translation *translation, BaseMMU::Mode mode, bool &delayed)
Definition tlb.cc:336
void serialize(CheckpointOut &cp) const override
Serialize an object.
Fault checkPermissions(STATUS status, PrivilegeMode pmode, Addr vaddr, BaseMMU::Mode mode, PTESv39 pte)
Definition tlb.cc:223
void demapPage(Addr vaddr, uint64_t asn) override
Addr translateWithTLB(Addr vaddr, uint16_t asid, BaseMMU::Mode mode)
Definition tlb.cc:270
void takeOverFrom(BaseTLB *old) override
Take over from an old tlb context.
Definition tlb.hh:98
ThreadContext is the external interface to all thread state for anything outside of the CPU.
A formula for statistics that is calculated when printed.
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
STL list class.
Definition stl.hh:51
STL vector class.
Definition stl.hh:37
Bitfield< 5, 0 > status
Bitfield< 0 > p
Bitfield< 59, 44 > asid
Definition pagetable.hh:47
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
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.
statistics::Formula accesses
Definition tlb.hh:85
statistics::Scalar readHits
Definition tlb.hh:76
statistics::Formula misses
Definition tlb.hh:84
statistics::Formula hits
Definition tlb.hh:83
statistics::Scalar writeAccesses
Definition tlb.hh:81
TlbStats(statistics::Group *parent)
statistics::Scalar writeMisses
Definition tlb.hh:80
statistics::Scalar writeHits
Definition tlb.hh:79
statistics::Scalar readMisses
Definition tlb.hh:77
statistics::Scalar readAccesses
Definition tlb.hh:78

Generated on Tue Jun 18 2024 16:24:00 for gem5 by doxygen 1.11.0