2 * Copyright (c) 2003-2004 The Regents of The University of Michigan
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.
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.
35 #include "arch/alpha/pseudo_inst.hh"
36 #include "arch/alpha/vtophys.hh"
37 #include "cpu/base_cpu.hh"
38 #include "cpu/exec_context.hh"
39 #include "sim/param.hh"
40 #include "sim/serialize.hh"
41 #include "sim/sim_exit.hh"
42 #include "sim/stat_control.hh"
43 #include "sim/stats.hh"
44 #include "sim/system.hh"
47 using namespace Stats
;
51 bool doStatisticsInsts
;
52 bool doCheckpointInsts
;
58 xc
->kernelStats
.arm();
62 quiesce(ExecContext
*xc
)
68 xc
->kernelStats
.quiesce();
74 xc
->kernelStats
.ivlb();
83 m5exit_old(ExecContext
*xc
)
85 SimExit(curTick
, "m5_exit_old instruction encountered");
89 m5exit(ExecContext
*xc
)
91 Tick delay
= xc
->regs
.intRegFile
[16];
92 Tick when
= curTick
+ NS2Ticks(delay
);
93 SimExit(when
, "m5_exit instruction encountered");
97 resetstats(ExecContext
*xc
)
99 if (!doStatisticsInsts
)
102 Tick delay
= xc
->regs
.intRegFile
[16];
103 Tick period
= xc
->regs
.intRegFile
[17];
105 Tick when
= curTick
+ NS2Ticks(delay
);
106 Tick repeat
= NS2Ticks(period
);
108 using namespace Stats
;
109 SetupEvent(Reset
, when
, repeat
);
113 dumpstats(ExecContext
*xc
)
115 if (!doStatisticsInsts
)
118 Tick delay
= xc
->regs
.intRegFile
[16];
119 Tick period
= xc
->regs
.intRegFile
[17];
121 Tick when
= curTick
+ NS2Ticks(delay
);
122 Tick repeat
= NS2Ticks(period
);
124 using namespace Stats
;
125 SetupEvent(Dump
, when
, repeat
);
129 dumpresetstats(ExecContext
*xc
)
131 if (!doStatisticsInsts
)
134 Tick delay
= xc
->regs
.intRegFile
[16];
135 Tick period
= xc
->regs
.intRegFile
[17];
137 Tick when
= curTick
+ NS2Ticks(delay
);
138 Tick repeat
= NS2Ticks(period
);
140 using namespace Stats
;
141 SetupEvent(Dump
|Reset
, when
, repeat
);
145 m5checkpoint(ExecContext
*xc
)
147 if (!doCheckpointInsts
)
150 Tick delay
= xc
->regs
.intRegFile
[16];
151 Tick period
= xc
->regs
.intRegFile
[17];
153 Tick when
= curTick
+ NS2Ticks(delay
);
154 Tick repeat
= NS2Ticks(period
);
156 Checkpoint::setup(when
, repeat
);
160 readfile(ExecContext
*xc
)
162 const string
&file
= xc
->cpu
->system
->readfile
;
164 xc
->regs
.intRegFile
[0] = ULL(0);
168 Addr vaddr
= xc
->regs
.intRegFile
[16];
169 uint64_t len
= xc
->regs
.intRegFile
[17];
170 uint64_t offset
= xc
->regs
.intRegFile
[18];
173 int fd
= ::open(file
.c_str(), O_RDONLY
, 0);
175 panic("could not open file %s\n", file
);
177 char *buf
= new char[len
];
180 int bytes
= ::pread(fd
, p
, len
, offset
);
191 CopyIn(xc
, vaddr
, buf
, result
);
193 xc
->regs
.intRegFile
[0] = result
;
196 class Context
: public ParamContext
199 Context(const string
§ion
) : ParamContext(section
) {}
203 Context
context("PseudoInsts");
205 Param
<bool> __quiesce(&context
, "quiesce",
206 "enable quiesce instructions",
208 Param
<bool> __statistics(&context
, "statistics",
209 "enable statistics pseudo instructions",
211 Param
<bool> __checkpoint(&context
, "checkpoint",
212 "enable checkpoint pseudo instructions",
216 Context::checkParams()
218 doQuiesce
= __quiesce
;
219 doStatisticsInsts
= __statistics
;
220 doCheckpointInsts
= __checkpoint
;