gem5  v21.0.1.0
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 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(const 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 resetStats() override;
142 
143  virtual Fault readMem(Addr addr, uint8_t* data, unsigned size,
144  Request::Flags flags,
145  const std::vector<bool>& byte_enable =
147  { panic("readMem() is not implemented\n"); }
148 
149  virtual Fault initiateMemRead(Addr addr, unsigned size,
150  Request::Flags flags,
151  const std::vector<bool>& byte_enable =
153  { panic("initiateMemRead() is not implemented\n"); }
154 
155  virtual Fault writeMem(uint8_t* data, unsigned size, Addr addr,
156  Request::Flags flags, uint64_t* res,
157  const std::vector<bool>& byte_enable =
159  { panic("writeMem() is not implemented\n"); }
160 
161  virtual Fault amoMem(Addr addr, uint8_t* data, unsigned size,
162  Request::Flags flags,
163  AtomicOpFunctorPtr amo_op)
164  { panic("amoMem() is not implemented\n"); }
165 
166  virtual Fault initiateMemAMO(Addr addr, unsigned size,
167  Request::Flags flags,
168  AtomicOpFunctorPtr amo_op)
169  { panic("initiateMemAMO() is not implemented\n"); }
170 
171  void countInst();
172  Counter totalInsts() const override;
173  Counter totalOps() const override;
174 
175  void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
176  void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
177 
182  virtual Fault initiateHtmCmd(Request::Flags flags) = 0;
183 
192  virtual void htmSendAbortSignal(HtmFailureFaultCause cause) = 0;
193 };
194 
195 #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:47
BaseSimpleCPU::_status
Status _status
Definition: base.hh:121
BaseSimpleCPU::unserializeThread
void unserializeThread(CheckpointIn &cp, ThreadID tid) override
Unserialize one thread.
Definition: base.cc:224
Process
Definition: process.hh:65
BaseSimpleCPU::totalInsts
Counter totalInsts() const override
Definition: base.cc:173
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:233
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:216
Trace
Definition: nativetrace.cc:52
BaseSimpleCPU::BaseSimpleCPU
BaseSimpleCPU(const BaseSimpleCPUParams &params)
Definition: base.cc:80
TheISA
Definition: thread_context.hh:52
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:288
RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:86
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:246
BaseSimpleCPU::DcacheWaitSwitch
@ DcacheWaitSwitch
Definition: base.hh:118
BaseSimpleCPU::countInst
void countInst()
Definition: base.cc:158
BaseSimpleCPU::branchPred
BPredUnit * branchPred
Definition: base.hh:84
request.hh
BaseSimpleCPU::ITBWaitResponse
@ ITBWaitResponse
Definition: base.hh:111
BaseSimpleCPU::postExecute
void postExecute()
Definition: base.cc:390
packet.hh
BaseSimpleCPU::activeThreads
std::list< ThreadID > activeThreads
Definition: base.hh:99
Counter
int64_t Counter
Statistics counter type.
Definition: types.hh:54
BaseSimpleCPU::totalOps
Counter totalOps() const override
Definition: base.cc:184
cp
Definition: cprintf.cc:37
BaseSimpleCPU::checkPcEventQueue
void checkPcEventQueue()
Definition: base.cc:130
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:143
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:246
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
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:161
BaseSimpleCPU::initiateMemAMO
virtual Fault initiateMemAMO(Addr addr, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
Definition: base.hh:166
BaseSimpleCPU::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: base.cc:119
BaseSimpleCPU::initiateMemRead
virtual Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
Definition: base.hh:149
BaseSimpleCPU::checkForInterrupts
void checkForInterrupts()
Definition: base.cc:257
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:148
BaseSimpleCPU::~BaseSimpleCPU
virtual ~BaseSimpleCPU()
Definition: base.cc:194
BaseSimpleCPU::DcacheWaitResponse
@ DcacheWaitResponse
Definition: base.hh:117
BaseSimpleCPU::Faulting
@ Faulting
Definition: base.hh:110
full_system.hh
X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:80
BaseCPU
Definition: base.hh:104
BaseSimpleCPU::wakeup
void wakeup(ThreadID tid) override
Definition: base.cc:235
BaseSimpleCPU::curStaticInst
StaticInstPtr curStaticInst
Definition: base.hh:103
BaseSimpleCPU::swapActiveThread
void swapActiveThread()
Definition: base.cc:142
BaseSimpleCPU::advancePC
void advancePC(const Fault &fault)
Definition: base.cc:466
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:155
BaseSimpleCPU::preExecute
void preExecute()
Definition: base.cc:305
exec_context.hh
BaseSimpleCPU::resetStats
void resetStats() override
Callback to reset stats.
Definition: base.cc:207
BaseSimpleCPU::DcacheRetry
@ DcacheRetry
Definition: base.hh:116
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:64
RefCountingPtr< StaticInst >
SimObject::params
const Params & params() const
Definition: sim_object.hh:168
std::list< ThreadID >
CheckpointIn
Definition: serialize.hh:68
BaseSimpleCPU::haltContext
void haltContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now halted.
Definition: base.cc:199
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 Tue Jun 22 2021 15:28:25 for gem5 by doxygen 1.8.17