gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
isa.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 The Regents of The University of Michigan
3  * Copyright (c) 2009 The University of Edinburgh
4  * Copyright (c) 2014 Sven Karlsson
5  * Copyright (c) 2016 RISC-V Foundation
6  * Copyright (c) 2016 The University of Virginia
7  * Copyright (c) 2020 Barkhausen Institut
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are
12  * met: redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer;
14  * redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution;
17  * neither the name of the copyright holders nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef __ARCH_RISCV_ISA_HH__
35 #define __ARCH_RISCV_ISA_HH__
36 
37 #include <unordered_map>
38 #include <vector>
39 
40 #include "arch/generic/isa.hh"
41 #include "arch/riscv/pcstate.hh"
42 #include "arch/riscv/regs/misc.hh"
43 #include "arch/riscv/types.hh"
44 #include "base/types.hh"
45 
46 namespace gem5
47 {
48 
49 struct RiscvISAParams;
50 class Checkpoint;
51 
52 namespace RiscvISA
53 {
54 
56 {
57  PRV_U = 0,
58  PRV_S = 1,
59  PRV_M = 3
60 };
61 
63 {
64  OFF = 0,
65  INITIAL = 1,
66  CLEAN = 2,
67  DIRTY = 3,
68 };
69 
70 class ISA : public BaseISA
71 {
72  protected:
76 
77  bool hpmCounterEnabled(int counter) const;
78 
79  // Load reserve - store conditional monitor
80  const int WARN_FAILURE = 10000;
82  std::unordered_map<int, Addr> load_reservation_addrs;
83 
84  public:
85  using Params = RiscvISAParams;
86 
87  void clear() override;
88 
90  newPCState(Addr new_inst_addr=0) const override
91  {
92  return new PCState(new_inst_addr, rv_type);
93  }
94 
95  public:
96  RegVal readMiscRegNoEffect(RegIndex idx) const override;
97  RegVal readMiscReg(RegIndex idx) override;
98  void setMiscRegNoEffect(RegIndex idx, RegVal val) override;
99  void setMiscReg(RegIndex idx, RegVal val) override;
100 
101  // Derived class could provide knowledge of non-standard CSRs to other
102  // components by overriding the two getCSRxxxMap here and properly
103  // implementing the corresponding read/set function. However, customized
104  // maps should always be compatible with the standard maps.
105  virtual const std::unordered_map<int, CSRMetadata>&
107  {
108  return CSRData;
109  }
110  virtual const std::unordered_map<int, RegVal>&
112  {
113  return CSRMasks[rv_type];
114  }
115 
116  bool alignmentCheckEnabled() const { return checkAlignment; }
117 
118  bool inUserMode() const override;
119  void copyRegsFrom(ThreadContext *src) override;
120 
121  void serialize(CheckpointOut &cp) const override;
122  void unserialize(CheckpointIn &cp) override;
123 
124  ISA(const Params &p);
125 
126  void handleLockedRead(const RequestPtr &req) override;
127 
128  bool handleLockedWrite(const RequestPtr &req,
129  Addr cacheBlockMask) override;
130 
131  void handleLockedSnoop(PacketPtr pkt, Addr cacheBlockMask) override;
132 
133  void globalClearExclusive() override;
134 
135  void resetThread() override;
136 
137  RiscvType rvType() const { return rv_type; }
138 
139 };
140 
141 } // namespace RiscvISA
142 } // namespace gem5
143 
144 std::ostream &operator<<(std::ostream &os, gem5::RiscvISA::PrivilegeMode pm);
145 
146 #endif // __ARCH_RISCV_ISA_HH__
gem5::RiscvISA::ISA::alignmentCheckEnabled
bool alignmentCheckEnabled() const
Definition: isa.hh:116
gem5::RiscvISA::PRV_S
@ PRV_S
Definition: isa.hh:58
gem5::RiscvISA::ISA::WARN_FAILURE
const int WARN_FAILURE
Definition: isa.hh:80
gem5::RiscvISA::PRV_M
@ PRV_M
Definition: isa.hh:59
gem5::RegVal
uint64_t RegVal
Definition: types.hh:173
gem5::RiscvISA::ISA::inUserMode
bool inUserMode() const override
Definition: isa.cc:262
gem5::RiscvISA::FPUStatus
FPUStatus
Definition: isa.hh:62
gem5::RiscvISA::ISA::copyRegsFrom
void copyRegsFrom(ThreadContext *src) override
Definition: isa.cc:268
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::RiscvISA::PrivilegeMode
PrivilegeMode
Definition: isa.hh:55
gem5::X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:776
gem5::RiscvISA::ISA::INVALID_RESERVATION_ADDR
const Addr INVALID_RESERVATION_ADDR
Definition: isa.hh:81
std::vector< RegVal >
gem5::RiscvISA::ISA::load_reservation_addrs
std::unordered_map< int, Addr > load_reservation_addrs
Definition: isa.hh:82
gem5::RiscvISA::INITIAL
@ INITIAL
Definition: isa.hh:65
gem5::RiscvISA::ISA::Params
RiscvISAParams Params
Definition: isa.hh:85
misc.hh
pcstate.hh
gem5::RiscvISA::ISA::clear
void clear() override
Definition: isa.cc:282
gem5::RiscvISA::ISA::rvType
RiscvType rvType() const
Definition: isa.hh:137
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
gem5::RiscvISA::ISA::getCSRDataMap
virtual const std::unordered_map< int, CSRMetadata > & getCSRDataMap() const
Definition: isa.hh:106
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
gem5::MipsISA::PCState
GenericISA::DelaySlotPCState< 4 > PCState
Definition: pcstate.hh:40
gem5::RiscvISA::ISA::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: isa.cc:669
gem5::RiscvISA::ISA::newPCState
PCStateBase * newPCState(Addr new_inst_addr=0) const override
Definition: isa.hh:90
gem5::RiscvISA::ISA::rv_type
RiscvType rv_type
Definition: isa.hh:73
gem5::RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
types.hh
gem5::RiscvISA::CLEAN
@ CLEAN
Definition: isa.hh:66
gem5::RiscvISA::ISA::miscRegFile
std::vector< RegVal > miscRegFile
Definition: isa.hh:74
gem5::RiscvISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::RiscvISA::ISA::readMiscReg
RegVal readMiscReg(RegIndex idx) override
Definition: isa.cc:366
gem5::RiscvISA::ISA::handleLockedRead
void handleLockedRead(const RequestPtr &req) override
Definition: isa.cc:690
gem5::RiscvISA::ISA::setMiscRegNoEffect
void setMiscRegNoEffect(RegIndex idx, RegVal val) override
Definition: isa.cc:511
gem5::RiscvISA::ISA::handleLockedSnoop
void handleLockedSnoop(PacketPtr pkt, Addr cacheBlockMask) override
Definition: isa.cc:676
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::RiscvISA::ISA
Definition: isa.hh:70
operator<<
std::ostream & operator<<(std::ostream &os, gem5::RiscvISA::PrivilegeMode pm)
Definition: isa.cc:765
gem5::RiscvISA::ISA::setMiscReg
void setMiscReg(RegIndex idx, RegVal val) override
Definition: isa.cc:521
isa.hh
gem5::RiscvISA::ISA::resetThread
void resetThread() override
Definition: isa.cc:756
gem5::RiscvISA::RiscvType
enums::RiscvType RiscvType
Definition: pcstate.hh:53
types.hh
gem5::X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:810
gem5::RiscvISA::ISA::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: isa.cc:662
gem5::RiscvISA::ISA::globalClearExclusive
void globalClearExclusive() override
Definition: isa.cc:748
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::RiscvISA::PRV_U
@ PRV_U
Definition: isa.hh:57
gem5::PCStateBase
Definition: pcstate.hh:57
gem5::RiscvISA::ISA::handleLockedWrite
bool handleLockedWrite(const RequestPtr &req, Addr cacheBlockMask) override
Definition: isa.cc:700
gem5::BaseISA
Definition: isa.hh:58
gem5::RegIndex
uint16_t RegIndex
Definition: types.hh:176
gem5::RiscvISA::OFF
@ OFF
Definition: isa.hh:64
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::RiscvISA::DIRTY
@ DIRTY
Definition: isa.hh:67
gem5::RiscvISA::ISA::hpmCounterEnabled
bool hpmCounterEnabled(int counter) const
Definition: isa.cc:327
gem5::RiscvISA::CSRData
const std::unordered_map< int, CSRMetadata > CSRData
Definition: misc.hh:494
gem5::RiscvISA::ISA::ISA
ISA(const Params &p)
Definition: isa.cc:246
gem5::RiscvISA::ISA::getCSRMaskMap
virtual const std::unordered_map< int, RegVal > & getCSRMaskMap() const
Definition: isa.hh:111
gem5::RiscvISA::ISA::checkAlignment
bool checkAlignment
Definition: isa.hh:75
gem5::RiscvISA::ISA::readMiscRegNoEffect
RegVal readMiscRegNoEffect(RegIndex idx) const override
Definition: isa.cc:356
gem5::RiscvISA::CSRMasks
const std::unordered_map< int, RegVal > CSRMasks[enums::Num_RiscvType]
Definition: misc.hh:925

Generated on Sun Jul 30 2023 01:56:47 for gem5 by doxygen 1.8.17