gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
base.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012,2015 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:
129 
130 
131  void checkForInterrupts();
132  void setupFetchRequest(Request *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) = 0;
147 
148  virtual Fault initiateMemRead(Addr addr, unsigned size,
149  Request::Flags flags) = 0;
150 
151  virtual Fault writeMem(uint8_t* data, unsigned size, Addr addr,
152  Request::Flags flags, uint64_t* res) = 0;
153 
154  void countInst();
155  Counter totalInsts() const override;
156  Counter totalOps() const override;
157 
158  void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
159  void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
160 
161 };
162 
163 #endif // __CPU_SIMPLE_BASE_HH__
StaticInstPtr curStaticInst
Definition: base.hh:107
Counter totalInsts() const override
Definition: base.cc:188
void advancePC(const Fault &fault)
Definition: base.cc:642
std::list< ThreadID > activeThreads
Definition: base.hh:103
void checkPcEventQueue()
Definition: base.cc:145
CheckerCPU class.
Definition: cpu.hh:91
void startup() override
Definition: base.cc:682
Addr dbg_vtophys(Addr addr)
Definition: base.cc:414
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
TheISA::MachInst inst
Current instruction.
Definition: base.hh:106
ip6_addr_t addr
Definition: inet.hh:335
void wakeup(ThreadID tid) override
Definition: base.cc:420
Port Object Declaration.
void checkForInterrupts()
Definition: base.cc:431
ThreadID curThread
Definition: base.hh:87
void preExecute()
Definition: base.cc:468
BaseSimpleCPU(BaseSimpleCPUParams *params)
Definition: base.cc:90
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Declaration of Statistics objects.
void resetStats() override
Definition: base.cc:387
uint32_t MachInst
Definition: types.hh:40
const char data[]
Definition: circlebuf.cc:43
void swapActiveThread()
Definition: base.cc:156
virtual Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags)=0
void countInst()
Definition: base.cc:172
void init() override
Definition: base.cc:129
void haltContext(ThreadID thread_num) override
Definition: base.cc:214
void unserializeThread(CheckpointIn &cp, ThreadID tid) override
Definition: base.cc:403
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
int64_t Counter
Statistics counter type.
Definition: types.hh:58
CheckerCPU * checker
Definition: base.hh:100
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Definition: base.cc:395
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:171
int size()
Definition: pagetable.hh:146
virtual Fault writeMem(uint8_t *data, unsigned size, Addr addr, Request::Flags flags, uint64_t *res)=0
Declaration of the Packet class.
Counter totalOps() const override
Definition: base.cc:199
std::ostream CheckpointOut
Definition: serialize.hh:67
Trace::InstRecord * traceData
Definition: base.hh:99
virtual ~BaseSimpleCPU()
Definition: base.cc:209
std::vector< SimpleExecContext * > threadInfo
Definition: base.hh:102
void regStats() override
Definition: base.cc:222
virtual Fault readMem(Addr addr, uint8_t *data, unsigned size, Request::Flags flags)=0
void postExecute()
Definition: base.cc:558
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
void setupFetchRequest(Request *req)
Definition: base.cc:451
BPredUnit * branchPred
Definition: base.hh:88

Generated on Fri Jun 9 2017 13:03:41 for gem5 by doxygen 1.8.6