46 #include "arch/locked_mem.hh"
47 #include "arch/mmapped_ipr.hh"
48 #include "arch/utility.hh"
50 #include "config/the_isa.hh"
52 #include "debug/Config.hh"
53 #include "debug/Drain.hh"
54 #include "debug/ExecFaulting.hh"
55 #include "debug/Mwait.hh"
56 #include "debug/SimpleCPU.hh"
59 #include "params/TimingSimpleCPU.hh"
65 using namespace TheISA;
77 cpu->schedule(
this, t);
82 dcachePort(this), ifetch_pkt(NULL), dcache_pkt(NULL), previousCycle(0),
102 DPRINTF(Drain,
"No need to drain.\n");
106 DPRINTF(Drain,
"Requesting drain.\n");
125 DPRINTF(SimpleCPU,
"Resume\n");
128 assert(!threadContexts.empty());
132 for (
ThreadID tid = 0; tid < numThreads; tid++) {
149 system->totalNumInsts = 0;
158 DPRINTF(Drain,
"tryCompleteDrain.\n");
162 DPRINTF(Drain,
"CPU done draining, processing drain event\n");
174 BaseSimpleCPU::switchOut();
179 assert(thread->microPC() == 0);
196 if (!
system->isTimingMode()) {
197 fatal(
"The timing CPU requires the memory system to be in "
205 DPRINTF(SimpleCPU,
"ActivateContext %d\n", thread_num);
207 assert(thread_num < numThreads);
222 BaseCPU::activateContext(thread_num);
229 DPRINTF(SimpleCPU,
"SuspendContext %d\n", thread_num);
231 assert(thread_num < numThreads);
249 BaseCPU::suspendContext(thread_num);
267 new IprEvent(pkt,
this, clockEdge(delay));
297 bool do_access =
true;
381 uint8_t *
data,
bool read)
403 main_send_state->fragments[0] = pkt1;
404 main_send_state->fragments[1] = pkt2;
405 main_send_state->outstanding = 2;
414 panic(
"readMem() is for atomic accesses, and should "
415 "never be called on TimingSimpleCPU.\n");
428 unsigned block_size = cacheLineSize();
440 assert(split_addr <= addr || split_addr - addr < block_size);
443 if (split_addr > addr) {
456 thread->
dtb->translateTiming(req1, thread->
getTC(), trans1,
mode);
457 thread->
dtb->translateTiming(req2, thread->
getTC(), trans2,
mode);
463 thread->
dtb->translateTiming(req, thread->
getTC(), translation,
mode);
498 uint8_t *newData =
new uint8_t[
size];
501 unsigned block_size = cacheLineSize();
507 memset(newData, 0, size);
509 memcpy(newData, data, size);
521 assert(split_addr <= addr || split_addr - addr < block_size);
524 if (split_addr > addr) {
536 thread->
dtb->translateTiming(req1, thread->
getTC(), trans1,
mode);
537 thread->
dtb->translateTiming(req2, thread->
getTC(), trans2,
mode);
543 thread->
dtb->translateTiming(req, thread->
getTC(), translation,
mode);
553 for (
ThreadID tid = 0; tid < numThreads; tid++) {
555 if (getCpuAddrMonitor(tid)->doMonitor(pkt)) {
573 delete [] state->
data;
617 ifetch_req->
taskId(taskId());
620 DPRINTF(SimpleCPU,
"Translating address %#x\n", ifetch_req->
getVaddr());
621 thread->
itb->translateTiming(ifetch_req, thread->
getTC(),
637 DPRINTF(SimpleCPU,
"Sending fetch for addr %#x(pa: %#x)\n",
640 ifetch_pkt->dataStatic(&
inst);
641 DPRINTF(SimpleCPU,
" -- pkt addr: %#x\n", ifetch_pkt->getAddr());
653 DPRINTF(SimpleCPU,
"Translation of addr %#x faulted\n", req->
getVaddr());
673 DPRINTF(SimpleCPU,
"Fault occured, scheduling fetch event\n");
678 clockEdge(syscallRetryLatency) : clockEdge();
707 DPRINTF(SimpleCPU,
"Complete ICache Fetch for addr %#x\n", pkt ?
712 assert(!pkt || !pkt->
isError());
782 DPRINTF(SimpleCPU,
"Received fetch response %#x\n", pkt->
getAddr());
830 assert(main_send_state);
838 delete main_send_state;
872 ppCycles->notify(delta);
880 for (
ThreadID tid = 0; tid <
cpu->numThreads; tid++) {
881 if (
cpu->getCpuAddrMonitor(tid)->doMonitor(pkt)) {
900 for (
ThreadID tid = 0; tid <
cpu->numThreads; tid++) {
901 if (
cpu->getCpuAddrMonitor(tid)->doMonitor(pkt)) {
910 DPRINTF(SimpleCPU,
"Received load/store response %#x\n", pkt->
getAddr());
951 assert(main_send_state);
958 if (other_index > 0) {
959 tmp = main_send_state->
fragments[other_index];
963 main_send_state->
fragments[other_index] = NULL;
980 : pkt(_pkt),
cpu(_cpu)
982 cpu->schedule(
this, t);
988 cpu->completeDataAccess(pkt);
994 return "Timing Simple CPU Delay IPR event";
1010 TimingSimpleCPUParams::create()
StaticInstPtr curStaticInst
void advancePC(const Fault &fault)
This class represents part of a data address translation.
bool isFirstMicroop() const
virtual const char * description() const
Return a C string describing the event.
std::list< ThreadID > activeThreads
decltype(nullptr) constexpr NoFault
Cycles is a wrapper class for representing cycle counts, i.e.
void switchOut() override
DrainState
Object drain/handover states.
void schedule(PacketPtr _pkt, Tick t)
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the slave port.
bool isDrained()
Check if a system is in a drained state.
void setExtraData(uint64_t extraData)
Accessor function for store conditional return value.
bool isDelayedCommit() const
void suspendContext(ThreadID thread_num) override
TheISA::MachInst inst
Current instruction.
void deleteReqs()
Delete all requests that make up this translation.
void wakeup(ThreadID tid) override
void sendData(RequestPtr req, uint8_t *data, uint64_t *res, bool read)
bool scheduled() const
Determine if the current event is scheduled.
bool isMmappedIpr() const
virtual Fault initiateAcc(ExecContext *xc, Trace::InstRecord *traceData) const
void verifyMemoryMode() const override
bool handleLockedWrite(XC *xc, Request *req, Addr cacheBlockMask)
virtual Fault execute(ExecContext *xc, Trace::InstRecord *traceData) const =0
void setContext(ContextID context_id)
Set up Context numbers.
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
This is a write that is targeted and zeroing an entire cache block.
void checkForInterrupts()
PacketPtr buildPacket(RequestPtr req, bool read)
This class captures the state of an address translation.
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the slave port by calling its corresponding receive function...
Cycles handleIprRead(ThreadContext *xc, Packet *pkt)
Helper function to handle IPRs when the target architecture doesn't need its own IPR handling...
Cycles handleIprWrite(ThreadContext *xc, Packet *pkt)
Helper function to handle IPRs when the target architecture doesn't need its own IPR handling...
ThreadContext is the external interface to all thread state for anything outside of the CPU...
void setAccessLatency()
Set/Get the time taken to complete this request's access, not including the time to successfully tran...
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
void completeIfetch(PacketPtr)
Fault getFault() const
Determine whether this translation produced a fault.
void handleLockedSnoop(XC *xc, PacketPtr pkt, Addr cacheBlockMask)
void buildSplitPacket(PacketPtr &pkt1, PacketPtr &pkt2, RequestPtr req1, RequestPtr req2, RequestPtr req, uint8_t *data, bool read)
bool tryCompleteDrain()
Try to complete a drain request.
void sendFetch(const Fault &fault, RequestPtr req, ThreadContext *tc)
bool isPrefetch() const
Check if this request is a prefetch.
void takeOverFrom(ThreadContext &ntc, ThreadContext &otc)
Copy state between thread contexts in preparation for CPU handover.
uint64_t Tick
Tick count type.
bool handleReadPacket(PacketPtr pkt)
FetchTranslation fetchTranslation
void translationFault(const Fault &fault)
EventWrapper< MasterPort,&MasterPort::sendRetryResp > retryRespEvent
void takeOverFrom(BaseCPU *oldCPU) override
void setMem(Addr a, Addr s, unsigned f)
const RequestPtr req
A pointer to the original request.
void splitOnVaddr(Addr split_addr, RequestPtr &req1, RequestPtr &req2)
Generate two requests as if this request had been split into two pieces.
virtual void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the slave port.
T roundDown(const T &val, const U &align)
StaticInstPtr curMacroStaticInst
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
ThreadContext * getTC()
Returns the pointer to this SimpleThread's ThreadContext.
void printAddr(Addr a)
Inject a PrintReq for the given address to print the state of that address throughout the memory syst...
Draining buffers pending serialization/handover.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
virtual void recvReqRetry()
Called by the slave port if sendTimingReq was called on this master port (causing recvTimingReq to be...
static bool isRomMicroPC(MicroPC upc)
void threadSnoop(PacketPtr pkt, ThreadID sender)
void activateContext(ThreadID thread_num) override
virtual ~TimingSimpleCPU()
void sendSplitData(RequestPtr req1, RequestPtr req2, RequestPtr req, uint8_t *data, bool read)
TheISA::PCState pcState()
static const int NumArgumentRegs M5_VAR_USED
Flags getFlags()
Accessor for flags.
int16_t ThreadID
Thread index/ID type.
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
virtual void recvReqRetry()
Called by the slave port if sendTimingReq was called on this master port (causing recvTimingReq to be...
Declaration of the Packet class.
The request should not cause a memory access.
Trace::InstRecord * traceData
IprEvent(Packet *_pkt, TimingSimpleCPU *_cpu, Tick t)
SenderState * senderState
This packet's sender state.
GenericISA::SimplePCState< MachInst > PCState
MemCmd cmd
The command field of the packet.
virtual Fault completeAcc(Packet *pkt, ExecContext *xc, Trace::InstRecord *traceData) const
void advanceInst(const Fault &fault)
virtual bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the slave port.
std::vector< SimpleExecContext * > threadInfo
Fault readMem(Addr addr, uint8_t *data, unsigned size, Request::Flags flags) override
static PacketPtr createRead(const RequestPtr req)
Constructor-like methods that return Packets based on Request objects.
void dataDynamic(T *p)
Set the data pointer to a value that should have delete [] called on it.
void finishTranslation(WholeTranslationState *state)
Finish a DTB translation.
Fault writeMem(uint8_t *data, unsigned size, Addr addr, Request::Flags flags, uint64_t *res) override
void completeDataAccess(PacketPtr pkt)
void setNoFault()
Remove all faults from the translation.
DrainState drain() override
TimingSimpleCPU(TimingSimpleCPUParams *params)
ContextID contextId() const
bool isInvalidate() const
static PacketPtr createWrite(const RequestPtr req)
void printAddr(Addr a)
Print state of address in memory system via PrintReq (for debugging).
virtual void recvTimingSnoopReq(PacketPtr pkt)
Snoop a coherence request, we need to check if this causes a wakeup event on a cpu that is monitoring...
Command responseCommand() const
Fault initiateMemRead(Addr addr, unsigned size, Request::Flags flags) override
std::shared_ptr< FaultBase > Fault
void setupFetchRequest(Request *req)
void drainResume() override
void handleLockedRead(XC *xc, Request *req)
ProbePointArg< PacketInfo > Packet
Packet probe point.