gem5  v19.0.0.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 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  * Authors: Steve Reinhardt
42  * Dave Greene
43  * Nathan Binkert
44  */
45 
46 #ifndef __CPU_SIMPLE_BASE_HH__
47 #define __CPU_SIMPLE_BASE_HH__
48 
49 #include "base/statistics.hh"
50 #include "config/the_isa.hh"
51 #include "cpu/base.hh"
52 #include "cpu/checker/cpu.hh"
53 #include "cpu/exec_context.hh"
54 #include "cpu/pc_event.hh"
55 #include "cpu/simple_thread.hh"
56 #include "cpu/static_inst.hh"
57 #include "mem/packet.hh"
58 #include "mem/port.hh"
59 #include "mem/request.hh"
60 #include "sim/eventq.hh"
61 #include "sim/full_system.hh"
62 #include "sim/system.hh"
63 
64 // forward declarations
65 class Checkpoint;
66 class Process;
67 class Processor;
68 class ThreadContext;
69 
70 namespace TheISA
71 {
72  class DTB;
73  class ITB;
74 }
75 
76 namespace Trace {
77  class InstRecord;
78 }
79 
80 struct BaseSimpleCPUParams;
81 class BPredUnit;
82 class SimpleExecContext;
83 
84 class BaseSimpleCPU : public BaseCPU
85 {
86  protected:
89 
90  void checkPcEventQueue();
91  void swapActiveThread();
92 
93  public:
94  BaseSimpleCPU(BaseSimpleCPUParams *params);
95  virtual ~BaseSimpleCPU();
96  void wakeup(ThreadID tid) override;
97  void init() override;
98  public:
101 
104 
109 
110  protected:
111  enum Status {
123  };
124 
126 
127  public:
128  Addr dbg_vtophys(Addr addr);
129 
130 
131  void checkForInterrupts();
132  void setupFetchRequest(const RequestPtr &req);
133  void preExecute();
134  void postExecute();
135  void advancePC(const Fault &fault);
136 
137  void haltContext(ThreadID thread_num) override;
138 
139  // statistics
140  void regStats() override;
141  void resetStats() override;
142 
143  void startup() override;
144 
145  virtual Fault readMem(Addr addr, uint8_t* data, unsigned size,
146  Request::Flags flags,
147  const std::vector<bool>& byte_enable =
149  { panic("readMem() is not implemented\n"); }
150 
151  virtual Fault initiateMemRead(Addr addr, unsigned size,
152  Request::Flags flags,
153  const std::vector<bool>& byte_enable =
155  { panic("initiateMemRead() is not implemented\n"); }
156 
157  virtual Fault writeMem(uint8_t* data, unsigned size, Addr addr,
158  Request::Flags flags, uint64_t* res,
159  const std::vector<bool>& byte_enable =
161  { panic("writeMem() is not implemented\n"); }
162 
163  virtual Fault amoMem(Addr addr, uint8_t* data, unsigned size,
164  Request::Flags flags,
165  AtomicOpFunctorPtr amo_op)
166  { panic("amoMem() is not implemented\n"); }
167 
168  virtual Fault initiateMemAMO(Addr addr, unsigned size,
169  Request::Flags flags,
170  AtomicOpFunctorPtr amo_op)
171  { panic("initiateMemAMO() is not implemented\n"); }
172 
173  void countInst();
174  Counter totalInsts() const override;
175  Counter totalOps() const override;
176 
177  void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
178  void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
179 
180 };
181 
182 #endif // __CPU_SIMPLE_BASE_HH__
StaticInstPtr curStaticInst
Definition: base.hh:107
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
virtual Fault amoMem(Addr addr, uint8_t *data, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
Definition: base.hh:163
std::list< ThreadID > activeThreads
Definition: base.hh:103
CheckerCPU class.
Definition: cpu.hh:87
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
std::shared_ptr< Request > RequestPtr
Definition: request.hh:83
TheISA::MachInst inst
Current instruction.
Definition: base.hh:106
ip6_addr_t addr
Definition: inet.hh:335
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
Definition: amo.hh:230
ThreadID curThread
Definition: base.hh:87
Definition: cprintf.cc:42
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Declaration of Statistics objects.
STL vector class.
Definition: stl.hh:40
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:145
uint32_t MachInst
Definition: types.hh:40
virtual Fault initiateMemAMO(Addr addr, unsigned size, Request::Flags flags, AtomicOpFunctorPtr amo_op)
Definition: base.hh:168
Port Object Declaration.
Status _status
Definition: base.hh:125
StaticInstPtr curMacroStaticInst
Definition: base.hh:108
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void advancePC(PCState &pc, const StaticInstPtr &inst)
Definition: utility.hh:98
int64_t Counter
Statistics counter type.
Definition: types.hh:58
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:157
CheckerCPU * checker
Definition: base.hh:100
Basically a wrapper class to hold both the branch predictor and the BTB.
Definition: bpred_unit.hh:67
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
Declaration of the Packet class.
std::ostream CheckpointOut
Definition: serialize.hh:68
Trace::InstRecord * traceData
Definition: base.hh:99
std::vector< SimpleExecContext * > threadInfo
Definition: base.hh:102
virtual Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags, const std::vector< bool > &byte_enable=std::vector< bool >())
Definition: base.hh:151
const char data[]
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
const FlagsType init
This Stat is Initialized.
Definition: info.hh:47
BPredUnit * branchPred
Definition: base.hh:88

Generated on Fri Feb 28 2020 16:26:58 for gem5 by doxygen 1.8.13