Deleted Added
sdiff udiff text old ( 9554:406fbcf60223 ) new ( 10910:32f3d1c454ec )
full compact
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
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

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

40#ifndef __SIM_DRAIN_HH__
41#define __SIM_DRAIN_HH__
42
43#include <cassert>
44#include <vector>
45
46#include "base/flags.hh"
47
48class Drainable;
49
50#ifndef SWIG // SWIG doesn't support strongly typed enums
51/**
52 * Object drain/handover states
53 *
54 * An object starts out in the Running state. When the simulator
55 * prepares to take a snapshot or prepares a CPU for handover, it
56 * calls the drain() method to transfer the object into the Draining
57 * or Drained state. If any object enters the Draining state
58 * (Drainable::drain() returning >0), simulation continues until it
59 * all objects have entered the Drained state.
60 *
61 * Before resuming simulation, the simulator calls resume() to
62 * transfer the object to the Running state.
63 *
64 * \note Even though the state of an object (visible to the rest of
65 * the world through Drainable::getState()) could be used to determine
66 * if all objects have entered the Drained state, the protocol is
67 * actually a bit more elaborate. See Drainable::drain() for details.
68 */
69enum class DrainState {
70 Running, /** Running normally */
71 Draining, /** Draining buffers pending serialization/handover */
72 Drained /** Buffers drained, ready for serialization/handover */
73};
74#endif
75
76/**
77 * This class coordinates draining of a System.
78 *
79 * When draining a System, we need to make sure that all SimObjects in
80 * that system have drained their state before declaring the operation
81 * to be successful. This class keeps track of how many objects are
82 * still in the process of draining their state. Once it determines
83 * that all objects have drained their state, it exits the simulation
84 * loop.

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

162 *
163 * <li>Call Drainable::drainResume() and continue the simulation.
164 * </ol>
165 *
166 */
167class Drainable
168{
169 public:
170 Drainable();
171 virtual ~Drainable();
172
173 /**
174 * Determine if an object needs draining and register a
175 * DrainManager.
176 *
177 * When draining the state of an object, the simulator calls drain

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

222 * that might become stale when we return. This method is used to
223 * flush all such state back to main memory.
224 *
225 * @warn This does <i>not</i> cause any dirty state to be written
226 * back to memory.
227 */
228 virtual void memInvalidate() {};
229
230 DrainState getDrainState() const { return _drainState; }
231
232 protected:
233 void setDrainState(DrainState new_state) { _drainState = new_state; }
234
235 private:
236 DrainState _drainState;
237};
238
239DrainManager *createDrainManager();
240void cleanupDrainManager(DrainManager *drain_manager);
241
242#endif