gem5  v20.1.0.0
base.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012,2015,2018,2020 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 "base/statistics.hh"
46 #include "config/the_isa.hh"
47 #include "cpu/base.hh"
48 #include "cpu/checker/cpu.hh"
49 #include "cpu/exec_context.hh"
50 #include "cpu/pc_event.hh"
51 #include "cpu/simple_thread.hh"
52 #include "cpu/static_inst.hh"
53 #include "mem/packet.hh"
54 #include "mem/port.hh"
55 #include "mem/request.hh"
56 #include "sim/eventq.hh"
57 #include "sim/full_system.hh"
58 #include "sim/system.hh"
59 
60 // forward declarations
61 class Checkpoint;
62 class Process;
63 class Processor;
64 class ThreadContext;
65 
66 namespace TheISA
67 {
68  class DTB;
69  class ITB;
70 }
71 
72 namespace Trace {
73  class InstRecord;
74 }
75 
76 struct BaseSimpleCPUParams;
77 class BPredUnit;
78 class SimpleExecContext;
79 
80 class BaseSimpleCPU : public BaseCPU
81 {
82  protected:
85 
86  void checkPcEventQueue();
87  void swapActiveThread();
88 
89  public:
90  BaseSimpleCPU(BaseSimpleCPUParams *params);
91  virtual ~BaseSimpleCPU();
92  void wakeup(ThreadID tid) override;
93  void init() override;
94  public:
97 
100 
105 
106  protected:
107  enum Status {
119  };
120 
122 
129  void traceFault();
130 
131  public:
132  void checkForInterrupts();
133  void setupFetchRequest(const RequestPtr &req);
134  void preExecute();
135  void postExecute();
136  void advancePC(const Fault &fault);
137 
138  void haltContext(ThreadID thread_num) override;
139 
140  // statistics
141  void regStats() override;
142  void resetStats() override;
143 
144  virtual Fault readMem(Addr addr, uint8_t* data, unsigned size,
145  Request::Flags flags,
146  const std::vector<bool>& byte_enable =
148  { panic("readMem() is not implemented\n"); }
149 
150  virtual Fault initiateMemRead(Addr addr, unsigned size,
151  Request::Flags flags,
152  const std::vector<bool>& byte_enable =
154  { panic("initiateMemRead() is not implemented\n"); }
155 
156  virtual Fault writeMem(uint8_t* data, unsigned size, Addr addr,
157  Request::Flags flags, uint64_t* res,
158  const std::vector<bool>& byte_enable =
160  { panic("writeMem() is not implemented\n"); }
161 
162  virtual Fault amoMem(Addr addr, uint8_t* data, unsigned size,
163  Request::Flags flags,
164  AtomicOpFunctorPtr amo_op)
165  { panic("amoMem() is not implemented\n"); }
166 
167  virtual Fault initiateMemAMO(Addr addr, unsigned size,
168  Request::Flags flags,
169  AtomicOpFunctorPtr amo_op)
170  { panic("initiateMemAMO() is not implemented\n"); }
171 
172  void countInst();
173  Counter totalInsts() const override;
174  Counter totalOps() const override;
175 
176  void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
177  void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
178 
183  virtual Fault initiateHtmCmd(Request::Flags flags) = 0;
184 
193  virtual void htmSendAbortSignal(HtmFailureFaultCause cause) = 0;
194 };
195 
196 #endif // __CPU_SIMPLE_BASE_HH__
BaseSimpleCPU::IcacheWaitSwitch
@ IcacheWaitSwitch
Definition: base.hh:114
AtomicOpFunctorPtr
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
Definition: amo.hh:239
SimpleExecContext
Definition: exec_context.hh:57
BaseSimpleCPU::traceData
Trace::InstRecord * traceData
Definition: base.hh:95
system.hh
BaseSimpleCPU::curMacroStaticInst
StaticInstPtr curMacroStaticInst
Definition: base.hh:104
BaseSimpleCPU::DTBWaitResponse
@ DTBWaitResponse
Definition: base.hh:115
data
const char data[]
Definition: circlebuf.test.cc:42
BaseSimpleCPU::_status
Status _status
Definition: base.hh:121
BaseSimpleCPU::unserializeThread
void unserializeThread(CheckpointIn &cp, ThreadID tid) override
Unserialize one thread.
Definition: base.cc:414
Process
Definition: process.hh:65
BaseSimpleCPU::totalInsts
Counter totalInsts() const override
Definition: base.cc:177
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
ArmISA::MachInst
uint32_t MachInst
Definition: types.hh:52
Flags< FlagsType >
BaseSimpleCPU::checker
CheckerCPU * checker
Definition: base.hh:96
BaseSimpleCPU::serializeThread
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Serialize a single thread.
Definition: base.cc:406
Trace
Definition: nativetrace.cc:52
TheISA
Definition: decode_cache.hh:37
BaseSimpleCPU::initiateHtmCmd
virtual Fault initiateHtmCmd(Request::Flags flags)=0
Hardware transactional memory commands (HtmCmds), e.g.
Trace::InstRecord
Definition: insttracer.hh:55
BaseSimpleCPU::setupFetchRequest
void setupFetchRequest(const RequestPtr &req)
Definition: base.cc:478
RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:82
CheckerCPU
CheckerCPU class.
Definition: cpu.hh:85
std::vector< SimpleExecContext * >
HtmFailureFaultCause
HtmFailureFaultCause
Definition: htm.hh:44
BaseSimpleCPU::Status
Status
Definition: base.hh:107
BaseSimpleCPU::threadInfo
std::vector< SimpleExecContext * > threadInfo
Definition: base.hh:98
BaseSimpleCPU::traceFault
void traceFault()
Handler used when encountering a fault; its purpose is to tear down the InstRecord.
Definition: base.cc:436
BaseSimpleCPU::DcacheWaitSwitch
@ DcacheWaitSwitch
Definition: base.hh:118
BaseSimpleCPU::countInst
void countInst()
Definition: base.cc:161
BaseSimpleCPU::branchPred
BPredUnit * branchPred
Definition: base.hh:84
request.hh
BaseSimpleCPU::ITBWaitResponse
@ ITBWaitResponse
Definition: base.hh:111
BaseSimpleCPU::postExecute
void postExecute()
Definition: base.cc:583
packet.hh
BaseSimpleCPU::activeThreads
std::list< ThreadID > activeThreads
Definition: base.hh:99
Counter
int64_t Counter
Statistics counter type.
Definition: types.hh:58
BaseSimpleCPU::totalOps
Counter totalOps() const override
Definition: base.cc:188
cp
Definition: cprintf.cc:40
BaseSimpleCPU::checkPcEventQueue
void checkPcEventQueue()
Definition: base.cc:133
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
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:144
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
statistics.hh
BaseSimpleCPU::Idle
@ Idle
Definition: base.hh:108
BaseSimpleCPU::inst
TheISA::MachInst inst
Current instruction.
Definition: base.hh:102
cpu.hh
BaseSimpleCPU::IcacheWaitResponse
@ IcacheWaitResponse
Definition: base.hh:113
BaseSimpleCPU::regStats
void regStats() override
Definition: base.cc:212
BPredUnit
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition: bpred_unit.hh:62
port.hh
BaseSimpleCPU::htmSendAbortSignal
virtual void htmSendAbortSignal(HtmFailureFaultCause cause)=0
This function is used to instruct the memory subsystem that a transaction should be aborted and the s...
BaseSimpleCPU::amoMem
virtual Fault amoMem(Addr addr, uint8_t *data, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
Definition: base.hh:162
BaseSimpleCPU::initiateMemAMO
virtual Fault initiateMemAMO(Addr addr, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
Definition: base.hh:167
BaseSimpleCPU::init
void init() override
Definition: base.cc:122
BaseSimpleCPU::initiateMemRead
virtual Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
Definition: base.hh:150
BaseSimpleCPU::checkForInterrupts
void checkForInterrupts()
Definition: base.cc:447
BaseSimpleCPU
Definition: base.hh:80
static_inst.hh
BaseSimpleCPU::curThread
ThreadID curThread
Definition: base.hh:83
BaseSimpleCPU::IcacheRetry
@ IcacheRetry
Definition: base.hh:112
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
BaseCPU::params
const Params * params() const
Definition: base.hh:296
BaseSimpleCPU::~BaseSimpleCPU
virtual ~BaseSimpleCPU()
Definition: base.cc:198
BaseSimpleCPU::DcacheWaitResponse
@ DcacheWaitResponse
Definition: base.hh:117
BaseSimpleCPU::Faulting
@ Faulting
Definition: base.hh:110
full_system.hh
BaseCPU
Definition: cpu_dummy.hh:43
BaseSimpleCPU::wakeup
void wakeup(ThreadID tid) override
Definition: base.cc:425
BaseSimpleCPU::curStaticInst
StaticInstPtr curStaticInst
Definition: base.hh:103
BaseSimpleCPU::swapActiveThread
void swapActiveThread()
Definition: base.cc:145
BaseSimpleCPU::advancePC
void advancePC(const Fault &fault)
Definition: base.cc:659
simple_thread.hh
base.hh
pc_event.hh
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:156
BaseSimpleCPU::preExecute
void preExecute()
Definition: base.cc:495
exec_context.hh
addr
ip6_addr_t addr
Definition: inet.hh:423
BaseSimpleCPU::BaseSimpleCPU
BaseSimpleCPU(BaseSimpleCPUParams *params)
Definition: base.cc:83
BaseSimpleCPU::resetStats
void resetStats() override
Definition: base.cc:397
BaseSimpleCPU::DcacheRetry
@ DcacheRetry
Definition: base.hh:116
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
RefCountingPtr< StaticInst >
std::list< ThreadID >
CheckpointIn
Definition: serialize.hh:67
BaseSimpleCPU::haltContext
void haltContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now halted.
Definition: base.cc:203
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
BaseSimpleCPU::Running
@ Running
Definition: base.hh:109
eventq.hh

Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17