2 * Copyright (c) 2003-2005 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 "sim/pseudo_inst.hh"
37 #include "targetarch/vtophys.hh"
38 #include "cpu/base.hh"
39 #include "cpu/sampler/sampler.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"
49 #include "sim/vptr.hh"
53 extern Sampler
*SampCPU
;
55 using namespace Stats
;
56 using namespace TheISA
;
60 bool doStatisticsInsts
;
61 bool doCheckpointInsts
;
67 xc
->kernelStats
->arm();
71 quiesce(ExecContext
*xc
)
77 xc
->kernelStats
->quiesce();
83 xc
->kernelStats
->ivlb();
92 m5exit_old(ExecContext
*xc
)
94 SimExit(curTick
, "m5_exit_old instruction encountered");
98 m5exit(ExecContext
*xc
, Tick delay
)
100 Tick when
= curTick
+ delay
* Clock::Int::ns
;
101 SimExit(when
, "m5_exit instruction encountered");
105 resetstats(ExecContext
*xc
, Tick delay
, Tick period
)
107 if (!doStatisticsInsts
)
111 Tick when
= curTick
+ delay
* Clock::Int::ns
;
112 Tick repeat
= period
* Clock::Int::ns
;
114 using namespace Stats
;
115 SetupEvent(Reset
, when
, repeat
);
119 dumpstats(ExecContext
*xc
, Tick delay
, Tick period
)
121 if (!doStatisticsInsts
)
125 Tick when
= curTick
+ delay
* Clock::Int::ns
;
126 Tick repeat
= period
* Clock::Int::ns
;
128 using namespace Stats
;
129 SetupEvent(Dump
, when
, repeat
);
133 addsymbol(ExecContext
*xc
, Addr addr
, Addr symbolAddr
)
136 CopyString(xc
, symb
, symbolAddr
, 100);
137 std::string
symbol(symb
);
139 DPRINTF(Loader
, "Loaded symbol: %s @ %#llx\n", symbol
, addr
);
141 xc
->system
->kernelSymtab
->insert(addr
,symbol
);
145 dumpresetstats(ExecContext
*xc
, Tick delay
, Tick period
)
147 if (!doStatisticsInsts
)
151 Tick when
= curTick
+ delay
* Clock::Int::ns
;
152 Tick repeat
= period
* Clock::Int::ns
;
154 using namespace Stats
;
155 SetupEvent(Dump
|Reset
, when
, repeat
);
159 m5checkpoint(ExecContext
*xc
, Tick delay
, Tick period
)
161 if (!doCheckpointInsts
)
165 Tick when
= curTick
+ delay
* Clock::Int::ns
;
166 Tick repeat
= period
* Clock::Int::ns
;
168 Checkpoint::setup(when
, repeat
);
172 readfile(ExecContext
*xc
, Addr vaddr
, uint64_t len
, uint64_t offset
)
174 const string
&file
= xc
->cpu
->system
->params
->readfile
;
181 int fd
= ::open(file
.c_str(), O_RDONLY
, 0);
183 panic("could not open file %s\n", file
);
185 if (::lseek(fd
, offset
, SEEK_SET
) < 0)
186 panic("could not seek: %s", strerror(errno
));
188 char *buf
= new char[len
];
191 int bytes
= ::read(fd
, p
, len
);
201 CopyIn(xc
, vaddr
, buf
, result
);
206 class Context
: public ParamContext
209 Context(const string
§ion
) : ParamContext(section
) {}
213 Context
context("pseudo_inst");
215 Param
<bool> __quiesce(&context
, "quiesce",
216 "enable quiesce instructions",
218 Param
<bool> __statistics(&context
, "statistics",
219 "enable statistics pseudo instructions",
221 Param
<bool> __checkpoint(&context
, "checkpoint",
222 "enable checkpoint pseudo instructions",
226 Context::checkParams()
228 doQuiesce
= __quiesce
;
229 doStatisticsInsts
= __statistics
;
230 doCheckpointInsts
= __checkpoint
;
233 void debugbreak(ExecContext
*xc
)
238 void switchcpu(ExecContext
*xc
)
241 SampCPU
->switchCPUs();