gem5  v22.0.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
base.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012,2015,2018,2020-2021 ARM Limited
3  * Copyright (c) 2013 Advanced Micro Devices, Inc.
4  * All rights reserved
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Copyright (c) 2002-2005 The Regents of The University of Michigan
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
42 #ifndef __CPU_SIMPLE_BASE_HH__
43 #define __CPU_SIMPLE_BASE_HH__
44 
45 #include <memory>
46 
47 #include "arch/generic/pcstate.hh"
48 #include "base/statistics.hh"
49 #include "cpu/base.hh"
50 #include "cpu/checker/cpu.hh"
51 #include "cpu/exec_context.hh"
52 #include "cpu/pc_event.hh"
53 #include "cpu/simple_thread.hh"
54 #include "cpu/static_inst.hh"
55 #include "mem/packet.hh"
56 #include "mem/port.hh"
57 #include "mem/request.hh"
58 #include "sim/eventq.hh"
59 #include "sim/full_system.hh"
60 #include "sim/system.hh"
61 
62 namespace gem5
63 {
64 
65 // forward declarations
66 class Checkpoint;
67 class Process;
68 class Processor;
69 class ThreadContext;
70 
71 namespace Trace
72 {
73  class InstRecord;
74 }
75 
76 struct BaseSimpleCPUParams;
77 namespace branch_prediction
78 {
79  class BPredUnit;
80 } // namespace branch_prediction
81 class SimpleExecContext;
82 
83 class BaseSimpleCPU : public BaseCPU
84 {
85  protected:
88 
89  void checkPcEventQueue();
90  void swapActiveThread();
91 
92  public:
93  BaseSimpleCPU(const BaseSimpleCPUParams &params);
94  virtual ~BaseSimpleCPU();
95  void wakeup(ThreadID tid) override;
96  public:
99 
102 
106 
107  protected:
108  enum Status
109  {
121  };
122 
124 
131  void traceFault();
132 
133  std::unique_ptr<PCStateBase> preExecuteTempPC;
134 
135  public:
136  void checkForInterrupts();
137  void setupFetchRequest(const RequestPtr &req);
138  void serviceInstCountEvents();
139  void preExecute();
140  void postExecute();
141  void advancePC(const Fault &fault);
142 
143  void haltContext(ThreadID thread_num) override;
144 
145  // statistics
146  void resetStats() override;
147 
148  virtual Fault
149  readMem(Addr addr, uint8_t* data, unsigned size, Request::Flags flags,
150  const std::vector<bool>& byte_enable=std::vector<bool>())
151  {
152  panic("readMem() is not implemented");
153  }
154 
155  virtual Fault
157  const std::vector<bool>& byte_enable=std::vector<bool>())
158  {
159  panic("initiateMemRead() is not implemented\n");
160  }
161 
162  virtual Fault
163  writeMem(uint8_t* data, unsigned size, Addr addr, Request::Flags flags,
164  uint64_t* res,
165  const std::vector<bool>& byte_enable=std::vector<bool>())
166  {
167  panic("writeMem() is not implemented\n");
168  }
169 
170  virtual Fault
171  amoMem(Addr addr, uint8_t* data, unsigned size, Request::Flags flags,
172  AtomicOpFunctorPtr amo_op)
173  {
174  panic("amoMem() is not implemented\n");
175  }
176 
177  virtual Fault
179  AtomicOpFunctorPtr amo_op)
180  {
181  panic("initiateMemAMO() is not implemented\n");
182  }
183 
184  void countInst();
185  Counter totalInsts() const override;
186  Counter totalOps() const override;
187 
188  void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
189  void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
190 
199 
200 };
201 
202 } // namespace gem5
203 
204 #endif // __CPU_SIMPLE_BASE_HH__
gem5::BaseSimpleCPU::initiateMemAMO
virtual Fault initiateMemAMO(Addr addr, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
Definition: base.hh:178
gem5::BaseSimpleCPU::serializeThread
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Definition: base.cc:208
gem5::BaseSimpleCPU::DcacheRetry
@ DcacheRetry
Definition: base.hh:118
gem5::BaseSimpleCPU::totalOps
Counter totalOps() const override
Definition: base.cc:176
gem5::BaseSimpleCPU::threadInfo
std::vector< SimpleExecContext * > threadInfo
Definition: base.hh:100
system.hh
data
const char data[]
Definition: circlebuf.test.cc:48
gem5::BaseSimpleCPU::traceData
Trace::InstRecord * traceData
Definition: base.hh:97
gem5::BaseSimpleCPU::_status
Status _status
Definition: base.hh:123
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::BaseSimpleCPU::curStaticInst
StaticInstPtr curStaticInst
Current instruction.
Definition: base.hh:104
gem5::BaseSimpleCPU::amoMem
virtual Fault amoMem(Addr addr, uint8_t *data, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
Definition: base.hh:171
gem5::BaseSimpleCPU::ITBWaitResponse
@ ITBWaitResponse
Definition: base.hh:113
std::vector
STL vector class.
Definition: stl.hh:37
gem5::BaseSimpleCPU::BaseSimpleCPU
BaseSimpleCPU(const BaseSimpleCPUParams &params)
Definition: base.cc:84
gem5::BaseSimpleCPU::unserializeThread
void unserializeThread(CheckpointIn &cp, ThreadID tid) override
Definition: base.cc:216
gem5::BaseSimpleCPU::IcacheRetry
@ IcacheRetry
Definition: base.hh:114
gem5::BaseSimpleCPU::~BaseSimpleCPU
virtual ~BaseSimpleCPU()
Definition: base.cc:186
request.hh
gem5::BaseSimpleCPU::checkForInterrupts
void checkForInterrupts()
Definition: base.cc:249
gem5::RefCountingPtr< StaticInst >
packet.hh
gem5::BaseSimpleCPU::writeMem
virtual Fault writeMem(uint8_t *data, unsigned size, Addr addr, Request::Flags flags, uint64_t *res, const std::vector< bool > &byte_enable=std::vector< bool >())
Definition: base.hh:163
gem5::Flags< FlagsType >
gem5::BaseSimpleCPU::readMem
virtual Fault readMem(Addr addr, uint8_t *data, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
Definition: base.hh:149
gem5::BaseSimpleCPU::checkPcEventQueue
void checkPcEventQueue()
Definition: base.cc:124
gem5::BaseSimpleCPU::Status
Status
Definition: base.hh:108
gem5::Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
gem5::BaseSimpleCPU::preExecute
void preExecute()
Definition: base.cc:304
statistics.hh
gem5::CheckerCPU
CheckerCPU class.
Definition: cpu.hh:84
gem5::BaseSimpleCPU::setupFetchRequest
void setupFetchRequest(const RequestPtr &req)
Definition: base.cc:280
cpu.hh
gem5::BaseSimpleCPU::preExecuteTempPC
std::unique_ptr< PCStateBase > preExecuteTempPC
Definition: base.hh:133
gem5::RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
gem5::BaseSimpleCPU::DTBWaitResponse
@ DTBWaitResponse
Definition: base.hh:117
port.hh
gem5::BaseSimpleCPU::activeThreads
std::list< ThreadID > activeThreads
Definition: base.hh:101
gem5::BaseSimpleCPU
Definition: base.hh:83
flags
uint8_t flags
Definition: helpers.cc:66
static_inst.hh
gem5::BaseSimpleCPU::traceFault
void traceFault()
Handler used when encountering a fault; its purpose is to tear down the InstRecord.
Definition: base.cc:238
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::BaseSimpleCPU::IcacheWaitSwitch
@ IcacheWaitSwitch
Definition: base.hh:116
full_system.hh
gem5::BaseSimpleCPU::postExecute
void postExecute()
Definition: base.cc:383
gem5::BaseSimpleCPU::Faulting
@ Faulting
Definition: base.hh:112
pcstate.hh
gem5::BaseSimpleCPU::branchPred
branch_prediction::BPredUnit * branchPred
Definition: base.hh:87
simple_thread.hh
gem5::BaseSimpleCPU::initiateMemMgmtCmd
virtual Fault initiateMemMgmtCmd(Request::Flags flags)=0
Memory management commands such as hardware transactional memory commands or TLB invalidation command...
gem5::BaseSimpleCPU::countInst
void countInst()
Definition: base.cc:152
gem5::BaseSimpleCPU::resetStats
void resetStats() override
Definition: base.cc:199
base.hh
pc_event.hh
gem5::BaseSimpleCPU::Running
@ Running
Definition: base.hh:111
gem5::BaseSimpleCPU::initiateMemRead
virtual Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
Definition: base.hh:156
gem5::BaseSimpleCPU::swapActiveThread
void swapActiveThread()
Definition: base.cc:136
exec_context.hh
gem5::BaseSimpleCPU::IcacheWaitResponse
@ IcacheWaitResponse
Definition: base.hh:115
gem5::statistics::Counter
double Counter
All counters are of 64-bit values.
Definition: types.hh:47
gem5::BaseSimpleCPU::serviceInstCountEvents
void serviceInstCountEvents()
Definition: base.cc:297
gem5::branch_prediction::BPredUnit
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition: bpred_unit.hh:68
gem5::BaseSimpleCPU::wakeup
void wakeup(ThreadID tid) override
Definition: base.cc:227
gem5::BaseSimpleCPU::advancePC
void advancePC(const Fault &fault)
Definition: base.cc:458
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::BaseSimpleCPU::checker
CheckerCPU * checker
Definition: base.hh:98
gem5::Trace::InstRecord
Definition: insttracer.hh:61
std::list< ThreadID >
gem5::BaseSimpleCPU::haltContext
void haltContext(ThreadID thread_num) override
Definition: base.cc:191
gem5::AtomicOpFunctorPtr
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
Definition: amo.hh:242
gem5::BaseSimpleCPU::DcacheWaitResponse
@ DcacheWaitResponse
Definition: base.hh:119
gem5::BaseSimpleCPU::totalInsts
Counter totalInsts() const override
Definition: base.cc:165
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::BaseSimpleCPU::Idle
@ Idle
Definition: base.hh:110
gem5::BaseSimpleCPU::curMacroStaticInst
StaticInstPtr curMacroStaticInst
Definition: base.hh:105
gem5::BaseSimpleCPU::curThread
ThreadID curThread
Definition: base.hh:86
gem5::BaseSimpleCPU::DcacheWaitSwitch
@ DcacheWaitSwitch
Definition: base.hh:120
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
eventq.hh

Generated on Wed Jul 13 2022 10:39:13 for gem5 by doxygen 1.8.17