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.
36 #include "arch/alpha/pseudo_inst.hh"
37 #include "arch/alpha/vtophys.hh"
38 #include "cpu/base_cpu.hh"
39 #include "cpu/sampling_cpu/sampling_cpu.hh"
40 #include "cpu/exec_context.hh"
41 #include "kern/kernel_stats.hh"
42 #include "sim/param.hh"
43 #include "sim/serialize.hh"
44 #include "sim/sim_exit.hh"
45 #include "sim/stat_control.hh"
46 #include "sim/stats.hh"
47 #include "sim/system.hh"
48 #include "sim/debug.hh"
52 extern SamplingCPU
*SampCPU
;
54 using namespace Stats
;
58 bool doStatisticsInsts
;
59 bool doCheckpointInsts
;
65 xc
->kernelStats
->arm();
69 quiesce(ExecContext
*xc
)
75 xc
->kernelStats
->quiesce();
81 xc
->kernelStats
->ivlb();
90 m5exit_old(ExecContext
*xc
)
92 SimExit(curTick
, "m5_exit_old instruction encountered");
96 m5exit(ExecContext
*xc
)
98 Tick delay
= xc
->regs
.intRegFile
[16];
99 Tick when
= curTick
+ delay
* Clock::Int::ns
;
100 SimExit(when
, "m5_exit instruction encountered");
104 resetstats(ExecContext
*xc
)
106 if (!doStatisticsInsts
)
109 Tick delay
= xc
->regs
.intRegFile
[16];
110 Tick period
= xc
->regs
.intRegFile
[17];
112 Tick when
= curTick
+ delay
* Clock::Int::ns
;
113 Tick repeat
= period
* Clock::Int::ns
;
115 using namespace Stats
;
116 SetupEvent(Reset
, when
, repeat
);
120 dumpstats(ExecContext
*xc
)
122 if (!doStatisticsInsts
)
125 Tick delay
= xc
->regs
.intRegFile
[16];
126 Tick period
= xc
->regs
.intRegFile
[17];
128 Tick when
= curTick
+ delay
* Clock::Int::ns
;
129 Tick repeat
= period
* Clock::Int::ns
;
131 using namespace Stats
;
132 SetupEvent(Dump
, when
, repeat
);
136 dumpresetstats(ExecContext
*xc
)
138 if (!doStatisticsInsts
)
141 Tick delay
= xc
->regs
.intRegFile
[16];
142 Tick period
= xc
->regs
.intRegFile
[17];
144 Tick when
= curTick
+ delay
* Clock::Int::ns
;
145 Tick repeat
= period
* Clock::Int::ns
;
147 using namespace Stats
;
148 SetupEvent(Dump
|Reset
, when
, repeat
);
152 m5checkpoint(ExecContext
*xc
)
154 if (!doCheckpointInsts
)
157 Tick delay
= xc
->regs
.intRegFile
[16];
158 Tick period
= xc
->regs
.intRegFile
[17];
160 Tick when
= curTick
+ delay
* Clock::Int::ns
;
161 Tick repeat
= period
* Clock::Int::ns
;
163 Checkpoint::setup(when
, repeat
);
167 readfile(ExecContext
*xc
)
169 const string
&file
= xc
->cpu
->system
->params
->readfile
;
171 xc
->regs
.intRegFile
[0] = ULL(0);
175 Addr vaddr
= xc
->regs
.intRegFile
[16];
176 uint64_t len
= xc
->regs
.intRegFile
[17];
177 uint64_t offset
= xc
->regs
.intRegFile
[18];
180 int fd
= ::open(file
.c_str(), O_RDONLY
, 0);
182 panic("could not open file %s\n", file
);
184 if (::lseek(fd
, offset
, SEEK_SET
) < 0)
185 panic("could not seek: %s", strerror(errno
));
187 char *buf
= new char[len
];
190 int bytes
= ::read(fd
, p
, len
);
200 CopyIn(xc
, vaddr
, buf
, result
);
202 xc
->regs
.intRegFile
[0] = result
;
205 class Context
: public ParamContext
208 Context(const string
§ion
) : ParamContext(section
) {}
212 Context
context("pseudo_inst");
214 Param
<bool> __quiesce(&context
, "quiesce",
215 "enable quiesce instructions",
217 Param
<bool> __statistics(&context
, "statistics",
218 "enable statistics pseudo instructions",
220 Param
<bool> __checkpoint(&context
, "checkpoint",
221 "enable checkpoint pseudo instructions",
225 Context::checkParams()
227 doQuiesce
= __quiesce
;
228 doStatisticsInsts
= __statistics
;
229 doCheckpointInsts
= __checkpoint
;
232 void debugbreak(ExecContext
*xc
)
237 void switchcpu(ExecContext
*xc
)
240 SampCPU
->switchCPUs();