drain.cc (10998:cd22d66592bf) drain.cc (11417:6e89c756e1fb)
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"
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"
46
47DrainManager DrainManager::_instance;
48
49DrainManager::DrainManager()
50 : _count(0),
51 _state(DrainState::Running)
52{
53}

--- 8 unchanged lines hidden (view full) ---

62 panic_if(_state == DrainState::Drained,
63 "Trying to drain a drained system\n");
64
65 panic_if(_count != 0,
66 "Drain counter must be zero at the start of a drain cycle\n");
67
68 DPRINTF(Drain, "Trying to drain %u objects.\n", drainableCount());
69 _state = DrainState::Draining;
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;
70 for (auto *obj : _allDrainable)
71 _count += obj->dmDrain() == DrainState::Drained ? 0 : 1;
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 }
72
73 if (_count == 0) {
74 DPRINTF(Drain, "Drain done.\n");
75 _state = DrainState::Drained;
76 return true;
77 } else {
78 DPRINTF(Drain, "Need another drain cycle. %u/%u objects not ready.\n",
79 _count, drainableCount());

--- 103 unchanged lines hidden ---
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 ---