drain.hh (9554:406fbcf60223) drain.hh (10910:32f3d1c454ec)
1/*
1/*
2 * Copyright (c) 2012 ARM Limited
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
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 Event;
48class Drainable;
49
49
50#ifndef SWIG // SWIG doesn't support strongly typed enums
50/**
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/**
51 * This class coordinates draining of a System.
52 *
53 * When draining a System, we need to make sure that all SimObjects in
54 * that system have drained their state before declaring the operation
55 * to be successful. This class keeps track of how many objects are
56 * still in the process of draining their state. Once it determines
57 * that all objects have drained their state, it exits the simulation
58 * loop.

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

136 *
137 * <li>Call Drainable::drainResume() and continue the simulation.
138 * </ol>
139 *
140 */
141class Drainable
142{
143 public:
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:
144 /**
145 * Object drain/handover states
146 *
147 * An object starts out in the Running state. When the simulator
148 * prepares to take a snapshot or prepares a CPU for handover, it
149 * calls the drain() method to transfer the object into the
150 * Draining or Drained state. If any object enters the Draining
151 * state (drain() returning >0), simulation continues until it all
152 * objects have entered the Drained state.
153 *
154 * Before resuming simulation, the simulator calls resume() to
155 * transfer the object to the Running state.
156 *
157 * \note Even though the state of an object (visible to the rest
158 * of the world through getState()) could be used to determine if
159 * all objects have entered the Drained state, the protocol is
160 * actually a bit more elaborate. See drain() for details.
161 */
162 enum State {
163 Running, /** Running normally */
164 Draining, /** Draining buffers pending serialization/handover */
165 Drained /** Buffers drained, ready for serialization/handover */
166 };
167
168 Drainable();
169 virtual ~Drainable();
170
171 /**
172 * Determine if an object needs draining and register a
173 * DrainManager.
174 *
175 * When draining the state of an object, the simulator calls drain

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

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