pseudo_inst.cc revision 695
1/*
2 * Copyright (c) 2003 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <string>
30
31#include "arch/alpha/pseudo_inst.hh"
32#include "cpu/exec_context.hh"
33#include "sim/annotation.hh"
34#include "sim/param.hh"
35#include "sim/serialize.hh"
36#include "sim/sim_exit.hh"
37#include "sim/stat_control.hh"
38#include "sim/stats.hh"
39
40using namespace std;
41using namespace Statistics;
42
43namespace AlphaPseudo
44{
45    bool doStatisticsInsts;
46    bool doCheckpointInsts;
47    bool doQuiesce;
48
49    void
50    quiesce(ExecContext *xc)
51    {
52        if (!doQuiesce)
53            return;
54
55        Annotate::QUIESCE(xc);
56        xc->suspend();
57        xc->kernelStats.quiesce();
58    }
59
60    void
61    m5exit_old(ExecContext *xc)
62    {
63        SimExit(curTick, "m5_exit_old instruction encountered");
64    }
65
66    void
67    m5exit(ExecContext *xc)
68    {
69        Tick delay = xc->regs.intRegFile[16];
70        Tick when = curTick + NS2Ticks(delay);
71        SimExit(when, "m5_exit instruction encountered");
72    }
73
74    void
75    resetstats(ExecContext *xc)
76    {
77        if (!doStatisticsInsts)
78            return;
79
80        Tick delay = xc->regs.intRegFile[16];
81        Tick period = xc->regs.intRegFile[17];
82
83        Tick when = curTick + NS2Ticks(delay);
84        Tick repeat = NS2Ticks(period);
85
86        using namespace Statistics;
87        SetupEvent(Reset, when, repeat);
88    }
89
90    void
91    dumpstats(ExecContext *xc)
92    {
93        if (!doStatisticsInsts)
94            return;
95
96        Tick delay = xc->regs.intRegFile[16];
97        Tick period = xc->regs.intRegFile[17];
98
99        Tick when = curTick + NS2Ticks(delay);
100        Tick repeat = NS2Ticks(period);
101
102        using namespace Statistics;
103        SetupEvent(Dump, when, repeat);
104    }
105
106    void
107    dumpresetstats(ExecContext *xc)
108    {
109        if (!doStatisticsInsts)
110            return;
111
112        Tick delay = xc->regs.intRegFile[16];
113        Tick period = xc->regs.intRegFile[17];
114
115        Tick when = curTick + NS2Ticks(delay);
116        Tick repeat = NS2Ticks(period);
117
118        using namespace Statistics;
119        SetupEvent(Dump|Reset, when, repeat);
120    }
121
122    void
123    m5checkpoint(ExecContext *xc)
124    {
125        if (!doCheckpointInsts)
126            return;
127
128        Tick delay = xc->regs.intRegFile[16];
129        Tick period = xc->regs.intRegFile[17];
130
131        Tick when = curTick + NS2Ticks(delay);
132        Tick repeat = NS2Ticks(period);
133
134        Checkpoint::setup(when, repeat);
135    }
136
137    class Context : public ParamContext
138    {
139      public:
140        Context(const string &section) : ParamContext(section) {}
141        void checkParams();
142    };
143
144    Context context("PseudoInsts");
145
146    Param<bool> __quiesce(&context, "quiesce",
147                          "enable quiesce instructions",
148                          true);
149    Param<bool> __statistics(&context, "statistics",
150                             "enable statistics pseudo instructions",
151                             true);
152    Param<bool> __checkpoint(&context, "checkpoint",
153                             "enable checkpoint pseudo instructions",
154                             true);
155
156    void
157    Context::checkParams()
158    {
159        doQuiesce = __quiesce;
160        doStatisticsInsts = __statistics;
161        doCheckpointInsts = __checkpoint;
162    }
163}
164