5e47adca1cd7023b1b8d445667a7d495eebd1d43
2 * Copyright (c) 2013 ARM Limited
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
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
14 * Copyright (c) 2002-2005 The Regents of The University of Michigan
15 * Copyright (c) 2013 Advanced Micro Devices, Inc.
16 * Copyright (c) 2013 Mark D. Hill and David A. Wood
17 * All rights reserved.
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions are
21 * met: redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer;
23 * redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution;
26 * neither the name of the copyright holders nor the names of its
27 * contributors may be used to endorse or promote products derived from
28 * this software without specific prior written permission.
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 * Authors: Nathan Binkert
47 #include "base/callback.hh"
48 #include "base/hostinfo.hh"
49 #include "sim/eventq_impl.hh"
50 #include "sim/sim_events.hh"
51 #include "sim/sim_exit.hh"
52 #include "sim/stats.hh"
56 GlobalSimLoopExitEvent::GlobalSimLoopExitEvent(Tick when
,
57 const std::string
&_cause
,
58 int c
, Tick r
, bool serialize
)
59 : GlobalEvent(when
, Sim_Exit_Pri
,
60 IsExitEvent
| (serialize
? AutoSerialize
: 0)),
61 cause(_cause
), code(c
), repeat(r
)
66 GlobalSimLoopExitEvent::description() const
68 return "global simulation loop exit";
72 // handle termination event
75 GlobalSimLoopExitEvent::process()
78 schedule(curTick() + repeat
);
83 exitSimLoop(const std::string
&message
, int exit_code
, Tick when
, Tick repeat
,
86 new GlobalSimLoopExitEvent(when
+ simQuantum
, message
, exit_code
, repeat
,
90 LocalSimLoopExitEvent::LocalSimLoopExitEvent()
91 : Event(Sim_Exit_Pri
, IsExitEvent
| AutoSerialize
),
92 cause(""), code(0), repeat(0)
96 LocalSimLoopExitEvent::LocalSimLoopExitEvent(const std::string
&_cause
, int c
,
97 Tick r
, bool serialize
)
98 : Event(Sim_Exit_Pri
, IsExitEvent
| (serialize
? AutoSerialize
: 0)),
99 cause(_cause
), code(c
), repeat(r
)
104 // handle termination event
107 LocalSimLoopExitEvent::process()
109 exitSimLoop(cause
, 0);
114 LocalSimLoopExitEvent::description() const
116 return "simulation loop exit";
120 LocalSimLoopExitEvent::serialize(ostream
&os
)
122 paramOut(os
, "type", string("SimLoopExitEvent"));
123 Event::serialize(os
);
125 SERIALIZE_SCALAR(cause
);
126 SERIALIZE_SCALAR(code
);
127 SERIALIZE_SCALAR(repeat
);
131 LocalSimLoopExitEvent::unserialize(Checkpoint
*cp
, const string
§ion
)
133 Event::unserialize(cp
, section
);
135 UNSERIALIZE_SCALAR(cause
);
136 UNSERIALIZE_SCALAR(code
);
137 UNSERIALIZE_SCALAR(repeat
);
141 LocalSimLoopExitEvent::unserialize(Checkpoint
*cp
, const string
§ion
,
144 Event::unserialize(cp
, section
, eventq
);
146 UNSERIALIZE_SCALAR(cause
);
147 UNSERIALIZE_SCALAR(code
);
148 UNSERIALIZE_SCALAR(repeat
);
152 LocalSimLoopExitEvent::createForUnserialize(Checkpoint
*cp
,
153 const string
§ion
)
155 return new LocalSimLoopExitEvent();
158 REGISTER_SERIALIZEABLE("LocalSimLoopExitEvent", LocalSimLoopExitEvent
)
161 // constructor: automatically schedules at specified time
163 CountedExitEvent::CountedExitEvent(const std::string
&_cause
, int &counter
)
164 : Event(Sim_Exit_Pri
), cause(_cause
), downCounter(counter
)
166 // catch stupid mistakes
167 assert(downCounter
> 0);
172 // handle termination event
175 CountedExitEvent::process()
177 if (--downCounter
== 0) {
178 exitSimLoop(cause
, 0);
184 CountedExitEvent::description() const
186 return "counted exit";