{
if (drainManager && stateQueues[L1].empty() && stateQueues[L2].empty() &&
pendingQueue.empty()) {
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
DPRINTF(Drain, "TableWalker done draining, processing drain event\n");
drainManager->signalDrainDone();
drainManager = NULL;
if (state_queues_not_empty || pendingQueue.size()) {
drainManager = dm;
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
DPRINTF(Drain, "TableWalker not drained\n");
// return port drain count plus the table walker itself needs to drain
return 1;
} else {
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
DPRINTF(Drain, "TableWalker free, no need to drain\n");
// table walker is drained, but its ports may still need to be drained
MinorCPU::signalDrainDone()
{
DPRINTF(Drain, "MinorCPU drain done\n");
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
drainManager->signalDrainDone();
drainManager = NULL;
}
void
MinorCPU::drainResume()
{
- assert(getDrainState() == Drainable::Drained ||
- getDrainState() == Drainable::Running);
+ assert(getDrainState() == DrainState::Drained ||
+ getDrainState() == DrainState::Running);
if (switchedOut()) {
DPRINTF(Drain, "drainResume while switched out. Ignoring\n");
wakeup();
pipeline->drainResume();
- setDrainState(Drainable::Running);
+ setDrainState(DrainState::Running);
}
void
{
DPRINTF(O3CPU, "\n\nFullO3CPU: Ticking main, FullO3CPU.\n");
assert(!switchedOut());
- assert(getDrainState() != Drainable::Drained);
+ assert(getDrainState() != DrainState::Drained);
++numCycles;
ppCycles->notify(1);
// We don't want to wake the CPU if it is drained. In that case,
// we just want to flag the thread as active and schedule the tick
// event from drainResume() instead.
- if (getDrainState() == Drainable::Drained)
+ if (getDrainState() == DrainState::Drained)
return;
// If we are time 0 or if the last activation time is in the past,
{
// If the CPU isn't doing anything, then return immediately.
if (switchedOut()) {
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return 0;
}
DPRINTF(Drain, "Draining...\n");
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
// We only need to signal a drain to the commit stage as this
// initiates squashing controls the draining. Once the commit
return 1;
} else {
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
DPRINTF(Drain, "CPU is already drained\n");
if (tickEvent.scheduled())
deschedule(tickEvent);
void
FullO3CPU<Impl>::drainResume()
{
- setDrainState(Drainable::Running);
+ setDrainState(DrainState::Running);
if (switchedOut())
return;
void updateThreadPriority();
/** Is the CPU draining? */
- bool isDraining() const { return getDrainState() == Drainable::Draining; }
+ bool isDraining() const { return getDrainState() == DrainState::Draining; }
void serializeThread(CheckpointOut &cp,
ThreadID tid) const M5_ATTR_OVERRIDE;
if (count) {
DPRINTF(Drain, "Flash device is draining...\n");
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
} else {
DPRINTF(Drain, "Flash device drained\n");
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
}
return count;
}
if (count) {
DPRINTF(UFSHostDevice, "UFSDevice is draining...\n");
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
} else {
DPRINTF(UFSHostDevice, "UFSDevice drained\n");
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
}
return count;
}
cr.status.dma_transfer_status(0);
nextState = DescriptorFetch;
fetchAddress = cr.descChainAddr;
- if (ce->getDrainState() == Drainable::Running)
+ if (ce->getDrainState() == DrainState::Running)
fetchDescriptor(cr.descChainAddr);
} else if (cr.command.append_dma()) {
if (!busy) {
nextState = AddressFetch;
- if (ce->getDrainState() == Drainable::Running)
+ if (ce->getDrainState() == DrainState::Running)
fetchNextAddr(lastDescriptorAddr);
} else
refreshNext = true;
bool
CopyEngine::CopyEngineChannel::inDrain()
{
- if (ce->getDrainState() == Drainable::Draining) {
+ if (ce->getDrainState() == DrainState::Draining) {
DPRINTF(Drain, "CopyEngine done draining, processing drain event\n");
assert(drainManager);
drainManager->signalDrainDone();
drainManager = NULL;
}
- return ce->getDrainState() != Drainable::Running;
+ return ce->getDrainState() != DrainState::Running;
}
unsigned int
CopyEngine::CopyEngineChannel::drain(DrainManager *dm)
{
- if (nextState == Idle || ce->getDrainState() != Drainable::Running)
+ if (nextState == Idle || ce->getDrainState() != DrainState::Running)
return 0;
unsigned int count = 1;
count += cePort.drain(dm);
count += chan[x]->drain(dm);
if (count)
- setDrainState(Draining);
+ setDrainState(DrainState::Draining);
else
- setDrainState(Drained);
+ setDrainState(DrainState::Drained);
DPRINTF(Drain, "CopyEngine not drained\n");
return count;
{
unsigned int count = pioPort.drain(dm) + dmaPort.drain(dm);
if (count)
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
else
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return count;
}
case REG_RDT:
regs.rdt = val;
DPRINTF(EthernetSM, "RXS: RDT Updated.\n");
- if (getDrainState() == Drainable::Running) {
+ if (getDrainState() == DrainState::Running) {
DPRINTF(EthernetSM, "RXS: RDT Fetching Descriptors!\n");
rxDescCache.fetchDescriptors();
} else {
case REG_TDT:
regs.tdt = val;
DPRINTF(EthernetSM, "TXS: TX Tail pointer updated\n");
- if (getDrainState() == Drainable::Running) {
+ if (getDrainState() == DrainState::Running) {
DPRINTF(EthernetSM, "TXS: TDT Fetching Descriptors!\n");
txDescCache.fetchDescriptors();
} else {
IGbE::DescCache<T>::writeback1()
{
// If we're draining delay issuing this DMA
- if (igbe->getDrainState() != Drainable::Running) {
+ if (igbe->getDrainState() != DrainState::Running) {
igbe->schedule(wbDelayEvent, curTick() + igbe->wbDelay);
return;
}
IGbE::DescCache<T>::fetchDescriptors1()
{
// If we're draining delay issuing this DMA
- if (igbe->getDrainState() != Drainable::Running) {
+ if (igbe->getDrainState() != DrainState::Running) {
igbe->schedule(fetchDelayEvent, curTick() + igbe->fetchDelay);
return;
}
IGbE::restartClock()
{
if (!tickEvent.scheduled() && (rxTick || txTick || txFifoTick) &&
- getDrainState() == Drainable::Running)
+ getDrainState() == DrainState::Running)
schedule(tickEvent, clockEdge(Cycles(1)));
}
if (count) {
DPRINTF(Drain, "IGbE not drained\n");
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
} else
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return count;
}
virtual void updateHead(long h) { igbe->regs.rdh(h); }
virtual void enableSm();
virtual void fetchAfterWb() {
- if (!igbe->rxTick && igbe->getDrainState() == Drainable::Running)
+ if (!igbe->rxTick && igbe->getDrainState() == DrainState::Running)
fetchDescriptors();
}
virtual void enableSm();
virtual void actionAfterWb();
virtual void fetchAfterWb() {
- if (!igbe->txTick && igbe->getDrainState() == Drainable::Running)
+ if (!igbe->txTick && igbe->getDrainState() == DrainState::Running)
fetchDescriptors();
}
panic("Inconsistent DMA transfer state: dmaState = %d devState = %d\n",
dmaState, devState);
- if (ctrl->dmaPending() || ctrl->getDrainState() != Drainable::Running) {
+ if (ctrl->dmaPending() || ctrl->getDrainState() != DrainState::Running) {
schedule(dmaTransferEvent, curTick() + DMA_BACKOFF_PERIOD);
return;
} else
curPrd.getByteCount(), TheISA::PageBytes);
}
- if (ctrl->dmaPending() || ctrl->getDrainState() != Drainable::Running) {
+ if (ctrl->dmaPending() || ctrl->getDrainState() != DrainState::Running) {
schedule(dmaReadWaitEvent, curTick() + DMA_BACKOFF_PERIOD);
return;
} else if (!dmaReadCG->done()) {
dmaWriteCG = new ChunkGenerator(curPrd.getBaseAddr(),
curPrd.getByteCount(), TheISA::PageBytes);
}
- if (ctrl->dmaPending() || ctrl->getDrainState() != Drainable::Running) {
+ if (ctrl->dmaPending() || ctrl->getDrainState() != DrainState::Running) {
schedule(dmaWriteWaitEvent, curTick() + DMA_BACKOFF_PERIOD);
DPRINTF(IdeDisk, "doDmaWrite: rescheduling\n");
return;
unsigned int count;
count = pioPort.drain(dm);
if (count)
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
else
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return count;
}
assert(rxDmaState == dmaIdle || rxDmaState == dmaReadWaiting);
rxDmaState = dmaReading;
- if (dmaPending() || getDrainState() != Drainable::Running)
+ if (dmaPending() || getDrainState() != DrainState::Running)
rxDmaState = dmaReadWaiting;
else
dmaRead(rxDmaAddr, rxDmaLen, &rxDmaReadEvent, (uint8_t*)rxDmaData);
assert(rxDmaState == dmaIdle || rxDmaState == dmaWriteWaiting);
rxDmaState = dmaWriting;
- if (dmaPending() || getDrainState() != Running)
+ if (dmaPending() || getDrainState() != DrainState::Running)
rxDmaState = dmaWriteWaiting;
else
dmaWrite(rxDmaAddr, rxDmaLen, &rxDmaWriteEvent, (uint8_t*)rxDmaData);
assert(txDmaState == dmaIdle || txDmaState == dmaReadWaiting);
txDmaState = dmaReading;
- if (dmaPending() || getDrainState() != Running)
+ if (dmaPending() || getDrainState() != DrainState::Running)
txDmaState = dmaReadWaiting;
else
dmaRead(txDmaAddr, txDmaLen, &txDmaReadEvent, (uint8_t*)txDmaData);
assert(txDmaState == dmaIdle || txDmaState == dmaWriteWaiting);
txDmaState = dmaWriting;
- if (dmaPending() || getDrainState() != Running)
+ if (dmaPending() || getDrainState() != DrainState::Running)
txDmaState = dmaWriteWaiting;
else
dmaWrite(txDmaAddr, txDmaLen, &txDmaWriteEvent, (uint8_t*)txDmaData);
unsigned int count;
count = pioPort.drain(dm) + dmaPort.drain(dm) + configPort.drain(dm);
if (count)
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
else
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return count;
}
break;
case rxBeginCopy:
- if (dmaPending() || getDrainState() != Drainable::Running)
+ if (dmaPending() || getDrainState() != DrainState::Running)
goto exit;
rxDmaAddr = params()->platform->pciToDma(
break;
case txBeginCopy:
- if (dmaPending() || getDrainState() != Drainable::Running)
+ if (dmaPending() || getDrainState() != DrainState::Running)
goto exit;
txDmaAddr = params()->platform->pciToDma(
// Set status
if (count != 0) {
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
DPRINTF(Drain, "Cache not drained\n");
return count;
}
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return 0;
}
DPRINTF(Drain, "MSHRQueue now empty, signalling drained\n");
drainManager->signalDrainDone();
drainManager = NULL;
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
}
return retval;
}
MSHRQueue::drain(DrainManager *dm)
{
if (allocated == 0) {
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return 0;
} else {
drainManager = dm;
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
return 1;
}
}
}
if (count)
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
else
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return count;
}
// check our outstanding reads and writes and if any they need to
// drain
if (nbrOutstanding() != 0) {
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
drainManager = dm;
return 1;
} else {
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return 0;
}
}
drainManager = dm;
DPRINTF(Drain, "DMASequencer not drained\n");
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
return child_drain_count + 1;
}
drainManager = NULL;
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return child_drain_count;
}
drainManager = dm;
DPRINTF(Drain, "RubyPort not drained\n");
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
return child_drain_count + 1;
}
drainManager = NULL;
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return child_drain_count;
}
void
Sequencer::wakeup()
{
- assert(getDrainState() != Drainable::Draining);
+ assert(getDrainState() != DrainState::Draining);
// Check for deadlock of any of the requests
Cycles current_time = curCycle();
// See if we should schedule a deadlock check
if (!deadlockCheckEvent.scheduled() &&
- getDrainState() != Drainable::Draining) {
+ getDrainState() != DrainState::Draining) {
schedule(deadlockCheckEvent, clockEdge(m_deadlock_threshold));
}
}
if (count)
- setDrainState(Drainable::Draining);
+ setDrainState(DrainState::Draining);
else
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return count;
}
/*
- * Copyright (c) 2012 ARM Limited
+ * Copyright (c) 2012, 2015 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
Drainable::Drainable()
- : _drainState(Running)
+ : _drainState(DrainState::Running)
{
}
void
Drainable::drainResume()
{
- _drainState = Running;
+ _drainState = DrainState::Running;
}
/*
- * Copyright (c) 2012 ARM Limited
+ * Copyright (c) 2012, 2015 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
#include "base/flags.hh"
-class Event;
+class Drainable;
+
+#ifndef SWIG // SWIG doesn't support strongly typed enums
+/**
+ * Object drain/handover states
+ *
+ * An object starts out in the Running state. When the simulator
+ * prepares to take a snapshot or prepares a CPU for handover, it
+ * calls the drain() method to transfer the object into the Draining
+ * or Drained state. If any object enters the Draining state
+ * (Drainable::drain() returning >0), simulation continues until it
+ * all objects have entered the Drained state.
+ *
+ * Before resuming simulation, the simulator calls resume() to
+ * transfer the object to the Running state.
+ *
+ * \note Even though the state of an object (visible to the rest of
+ * the world through Drainable::getState()) could be used to determine
+ * if all objects have entered the Drained state, the protocol is
+ * actually a bit more elaborate. See Drainable::drain() for details.
+ */
+enum class DrainState {
+ Running, /** Running normally */
+ Draining, /** Draining buffers pending serialization/handover */
+ Drained /** Buffers drained, ready for serialization/handover */
+};
+#endif
/**
* This class coordinates draining of a System.
class Drainable
{
public:
- /**
- * Object drain/handover states
- *
- * An object starts out in the Running state. When the simulator
- * prepares to take a snapshot or prepares a CPU for handover, it
- * calls the drain() method to transfer the object into the
- * Draining or Drained state. If any object enters the Draining
- * state (drain() returning >0), simulation continues until it all
- * objects have entered the Drained state.
- *
- * Before resuming simulation, the simulator calls resume() to
- * transfer the object to the Running state.
- *
- * \note Even though the state of an object (visible to the rest
- * of the world through getState()) could be used to determine if
- * all objects have entered the Drained state, the protocol is
- * actually a bit more elaborate. See drain() for details.
- */
- enum State {
- Running, /** Running normally */
- Draining, /** Draining buffers pending serialization/handover */
- Drained /** Buffers drained, ready for serialization/handover */
- };
-
Drainable();
virtual ~Drainable();
*/
virtual void memInvalidate() {};
- State getDrainState() const { return _drainState; }
+ DrainState getDrainState() const { return _drainState; }
protected:
- void setDrainState(State new_state) { _drainState = new_state; }
-
+ void setDrainState(DrainState new_state) { _drainState = new_state; }
private:
- State _drainState;
-
+ DrainState _drainState;
};
DrainManager *createDrainManager();
unsigned int
SimObject::drain(DrainManager *drain_manager)
{
- setDrainState(Drained);
+ setDrainState(DrainState::Drained);
return 0;
}
void
System::setMemoryMode(Enums::MemoryMode mode)
{
- assert(getDrainState() == Drainable::Drained);
+ assert(getDrainState() == DrainState::Drained);
memoryMode = mode;
}
unsigned int
System::drain(DrainManager *dm)
{
- setDrainState(Drainable::Drained);
+ setDrainState(DrainState::Drained);
return 0;
}