1/* 2 * Copyright (c) 2012, 2015 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 29 unchanged lines hidden (view full) --- 38 */ 39 40#include "sim/drain.hh" 41 42#include "base/misc.hh" 43#include "base/trace.hh" 44#include "debug/Drain.hh" 45#include "sim/sim_exit.hh" |
46#include "sim/sim_object.hh" |
47 48DrainManager DrainManager::_instance; 49 50DrainManager::DrainManager() 51 : _count(0), 52 _state(DrainState::Running) 53{ 54} --- 8 unchanged lines hidden (view full) --- 63 panic_if(_state == DrainState::Drained, 64 "Trying to drain a drained system\n"); 65 66 panic_if(_count != 0, 67 "Drain counter must be zero at the start of a drain cycle\n"); 68 69 DPRINTF(Drain, "Trying to drain %u objects.\n", drainableCount()); 70 _state = DrainState::Draining; |
71 for (auto *obj : _allDrainable) { 72 DrainState status = obj->dmDrain(); 73 if (DTRACE(Drain) && status != DrainState::Drained) { 74 SimObject *temp = dynamic_cast<SimObject*>(obj); 75 if (temp) 76 DPRINTF(Drain, "Failed to drain %s\n", temp->name()); 77 } 78 _count += status == DrainState::Drained ? 0 : 1; 79 } |
80 81 if (_count == 0) { 82 DPRINTF(Drain, "Drain done.\n"); 83 _state = DrainState::Drained; 84 return true; 85 } else { 86 DPRINTF(Drain, "Need another drain cycle. %u/%u objects not ready.\n", 87 _count, drainableCount()); --- 103 unchanged lines hidden --- |