gem5  v22.1.0.0
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:
75 
76  bool hpmCounterEnabled(int counter) const;
77 
78  public:
79  using Params = RiscvISAParams;
80 
81  void clear() override;
82 
83  PCStateBase *
84  newPCState(Addr new_inst_addr=0) const override
85  {
86  return new PCState(new_inst_addr);
87  }
88 
89  public:
90  RegVal readMiscRegNoEffect(RegIndex idx) const override;
91  RegVal readMiscReg(RegIndex idx) override;
92  void setMiscRegNoEffect(RegIndex idx, RegVal val) override;
93  void setMiscReg(RegIndex idx, RegVal val) override;
94 
95  // Derived class could provide knowledge of non-standard CSRs to other
96  // components by overriding the two getCSRxxxMap here and properly
97  // implementing the corresponding read/set function. However, customized
98  // maps should always be compatible with the standard maps.
99  virtual const std::unordered_map<int, CSRMetadata>&
101  {
102  return CSRData;
103  }
104  virtual const std::unordered_map<int, RegVal>&
106  {
107  return CSRMasks;
108  }
109 
110  bool alignmentCheckEnabled() const { return checkAlignment; }
111 
112  bool inUserMode() const override;
113  void copyRegsFrom(ThreadContext *src) override;
114 
115  void serialize(CheckpointOut &cp) const override;
116  void unserialize(CheckpointIn &cp) override;
117 
118  ISA(const Params &p);
119 
120  void handleLockedRead(const RequestPtr &req) override;
121 
122  bool handleLockedWrite(const RequestPtr &req,
123  Addr cacheBlockMask) override;
124 
125  void handleLockedSnoop(PacketPtr pkt, Addr cacheBlockMask) override;
126 
127  void globalClearExclusive() override;
128 };
129 
130 } // namespace RiscvISA
131 } // namespace gem5
132 
133 std::ostream &operator<<(std::ostream &os, gem5::RiscvISA::PrivilegeMode pm);
134 
135 #endif // __ARCH_RISCV_ISA_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
void setMiscReg(RegIndex idx, RegVal val) override
Definition: isa.cc:403
void handleLockedSnoop(PacketPtr pkt, Addr cacheBlockMask) override
Definition: isa.cc:542
RegVal readMiscReg(RegIndex idx) override
Definition: isa.cc:295
void globalClearExclusive() override
Definition: isa.cc:604
PCStateBase * newPCState(Addr new_inst_addr=0) const override
Definition: isa.hh:84
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: isa.cc:523
virtual const std::unordered_map< int, RegVal > & getCSRMaskMap() const
Definition: isa.hh:105
bool alignmentCheckEnabled() const
Definition: isa.hh:110
void setMiscRegNoEffect(RegIndex idx, RegVal val) override
Definition: isa.cc:393
RegVal readMiscRegNoEffect(RegIndex idx) const override
Definition: isa.cc:285
bool hpmCounterEnabled(int counter) const
Definition: isa.cc:262
void copyRegsFrom(ThreadContext *src) override
Definition: isa.cc:227
bool handleLockedWrite(const RequestPtr &req, Addr cacheBlockMask) override
Definition: isa.cc:566
void clear() override
Definition: isa.cc:241
std::vector< RegVal > miscRegFile
Definition: isa.hh:73
bool inUserMode() const override
Definition: isa.cc:221
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: isa.cc:530
bool checkAlignment
Definition: isa.hh:74
RiscvISAParams Params
Definition: isa.hh:79
virtual const std::unordered_map< int, CSRMetadata > & getCSRDataMap() const
Definition: isa.hh:100
ISA(const Params &p)
Definition: isa.cc:206
void handleLockedRead(const RequestPtr &req) override
Definition: isa.cc:556
ThreadContext is the external interface to all thread state for anything outside of the CPU.
GenericISA::DelaySlotPCState< 4 > PCState
Definition: pcstate.hh:40
Bitfield< 0 > p
const std::unordered_map< int, CSRMetadata > CSRData
Definition: misc.hh:381
const std::unordered_map< int, RegVal > CSRMasks
Definition: misc.hh:664
Bitfield< 17 > os
Definition: misc.hh:810
Bitfield< 63 > val
Definition: misc.hh:776
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
uint16_t RegIndex
Definition: types.hh:176
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
uint64_t RegVal
Definition: types.hh:173
std::ostream & operator<<(std::ostream &os, gem5::RiscvISA::PrivilegeMode pm)
Definition: isa.cc:613

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