Deleted Added
sdiff udiff text old ( 8777:dd43f1c9fa0a ) new ( 8784:05fb20d7064b )
full compact
1/*
2 * Copyright (c) 2010 ARM Limited
3 * All rights reserved
4 *
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

--- 46 unchanged lines hidden (view full) ---

55#include "config/the_isa.hh"
56#include "cpu/base.hh"
57#include "cpu/quiesce_event.hh"
58#include "cpu/thread_context.hh"
59#include "debug/Loader.hh"
60#include "debug/Quiesce.hh"
61#include "debug/WorkItems.hh"
62#include "params/BaseCPU.hh"
63#include "sim/pseudo_inst.hh"
64#include "sim/serialize.hh"
65#include "sim/sim_events.hh"
66#include "sim/sim_exit.hh"
67#include "sim/stat_control.hh"
68#include "sim/stats.hh"
69#include "sim/system.hh"
70#include "sim/vptr.hh"
71
72using namespace std;
73
74using namespace Stats;
75using namespace TheISA;
76
77namespace PseudoInst {
78
79#if FULL_SYSTEM
80
81void
82arm(ThreadContext *tc)
83{
84 if (tc->getKernelStats())
85 tc->getKernelStats()->arm();
86}
87
88void
89quiesce(ThreadContext *tc)
90{
91 if (!tc->getCpuPtr()->params()->do_quiesce)
92 return;
93
94 DPRINTF(Quiesce, "%s: quiesce()\n", tc->getCpuPtr()->name());
95
96 tc->suspend();
97 if (tc->getKernelStats())
98 tc->getKernelStats()->quiesce();
99}
100
101void
102quiesceSkip(ThreadContext *tc)
103{
104 BaseCPU *cpu = tc->getCpuPtr();
105
106 if (!cpu->params()->do_quiesce)
107 return;
108
109 EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent();
110
111 Tick resume = curTick() + 1;
112
113 cpu->reschedule(quiesceEvent, resume, true);
114
115 DPRINTF(Quiesce, "%s: quiesceSkip() until %d\n",
116 cpu->name(), resume);
117
118 tc->suspend();
119 if (tc->getKernelStats())
120 tc->getKernelStats()->quiesce();
121}
122
123void
124quiesceNs(ThreadContext *tc, uint64_t ns)
125{
126 BaseCPU *cpu = tc->getCpuPtr();
127
128 if (!cpu->params()->do_quiesce || ns == 0)
129 return;
130
131 EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent();
132
133 Tick resume = curTick() + SimClock::Int::ns * ns;
134
135 cpu->reschedule(quiesceEvent, resume, true);
136
137 DPRINTF(Quiesce, "%s: quiesceNs(%d) until %d\n",
138 cpu->name(), ns, resume);
139
140 tc->suspend();
141 if (tc->getKernelStats())
142 tc->getKernelStats()->quiesce();
143}
144
145void
146quiesceCycles(ThreadContext *tc, uint64_t cycles)
147{
148 BaseCPU *cpu = tc->getCpuPtr();
149
150 if (!cpu->params()->do_quiesce || cycles == 0)
151 return;
152
153 EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent();
154
155 Tick resume = curTick() + cpu->ticks(cycles);
156
157 cpu->reschedule(quiesceEvent, resume, true);
158
159 DPRINTF(Quiesce, "%s: quiesceCycles(%d) until %d\n",
160 cpu->name(), cycles, resume);
161
162 tc->suspend();
163 if (tc->getKernelStats())
164 tc->getKernelStats()->quiesce();
165}
166
167uint64_t
168quiesceTime(ThreadContext *tc)
169{
170 return (tc->readLastActivate() - tc->readLastSuspend()) /
171 SimClock::Int::ns;
172}
173
174#endif
175
176uint64_t
177rpns(ThreadContext *tc)
178{
179 return curTick() / SimClock::Int::ns;
180}
181
182void
183wakeCPU(ThreadContext *tc, uint64_t cpuid)

--- 6 unchanged lines hidden (view full) ---

190
191void
192m5exit(ThreadContext *tc, Tick delay)
193{
194 Tick when = curTick() + delay * SimClock::Int::ns;
195 exitSimLoop("m5_exit instruction encountered", 0, when);
196}
197
198#if FULL_SYSTEM
199
200void
201loadsymbol(ThreadContext *tc)
202{
203 const string &filename = tc->getCpuPtr()->system->params()->symbolfile;
204 if (filename.empty()) {
205 return;
206 }
207
208 std::string buffer;
209 ifstream file(filename.c_str());
210
211 if (!file)
212 fatal("file error: Can't open symbol table file %s\n", filename);
213
214 while (!file.eof()) {
215 getline(file, buffer);
216
217 if (buffer.empty())
218 continue;
219
220 string::size_type idx = buffer.find(' ');
221 if (idx == string::npos)
222 continue;
223
224 string address = "0x" + buffer.substr(0, idx);
225 eat_white(address);
226 if (address.empty())
227 continue;
228
229 // Skip over letter and space
230 string symbol = buffer.substr(idx + 3);
231 eat_white(symbol);
232 if (symbol.empty())
233 continue;
234
235 Addr addr;
236 if (!to_number(address, addr))
237 continue;
238
239 if (!tc->getSystemPtr()->kernelSymtab->insert(addr, symbol))
240 continue;
241
242
243 DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);
244 }
245 file.close();
246}
247
248void
249addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
250{
251 char symb[100];
252 CopyStringOut(tc, symb, symbolAddr, 100);
253 std::string symbol(symb);
254
255 DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);
256
257 tc->getSystemPtr()->kernelSymtab->insert(addr,symbol);
258 debugSymbolTable->insert(addr,symbol);
259}
260
261uint64_t
262initParam(ThreadContext *tc)
263{
264 return tc->getCpuPtr()->system->init_param;
265}
266
267#endif
268
269
270void
271resetstats(ThreadContext *tc, Tick delay, Tick period)
272{
273 if (!tc->getCpuPtr()->params()->do_statistics_insts)
274 return;
275
276
277 Tick when = curTick() + delay * SimClock::Int::ns;

--- 35 unchanged lines hidden (view full) ---

313 return;
314
315 Tick when = curTick() + delay * SimClock::Int::ns;
316 Tick repeat = period * SimClock::Int::ns;
317
318 exitSimLoop("checkpoint", 0, when, repeat);
319}
320
321#if FULL_SYSTEM
322
323uint64_t
324readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
325{
326 const string &file = tc->getSystemPtr()->params()->readfile;
327 if (file.empty()) {
328 return ULL(0);
329 }
330
331 uint64_t result = 0;
332
333 int fd = ::open(file.c_str(), O_RDONLY, 0);
334 if (fd < 0)
335 panic("could not open file %s\n", file);
336
337 if (::lseek(fd, offset, SEEK_SET) < 0)
338 panic("could not seek: %s", strerror(errno));
339
340 char *buf = new char[len];
341 char *p = buf;
342 while (len > 0) {
343 int bytes = ::read(fd, p, len);
344 if (bytes <= 0)
345 break;
346
347 p += bytes;
348 result += bytes;
349 len -= bytes;
350 }
351
352 close(fd);
353 CopyIn(tc, vaddr, buf, result);
354 delete [] buf;
355 return result;
356}
357
358#endif
359
360void
361debugbreak(ThreadContext *tc)
362{
363 Debug::breakpoint();
364}
365
366void
367switchcpu(ThreadContext *tc)

--- 111 unchanged lines hidden ---