2003-11-03 02:43:39 +01:00
|
|
|
/*
|
2004-06-08 19:37:27 +02:00
|
|
|
* Copyright (c) 2003-2004 The Regents of The University of Michigan
|
2003-11-03 02:43:39 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2004-07-02 00:03:05 +02:00
|
|
|
#include <fcntl.h>
|
2004-07-02 18:30:06 +02:00
|
|
|
#include <unistd.h>
|
2004-07-02 00:03:05 +02:00
|
|
|
#include <cstdio>
|
2004-07-02 18:30:06 +02:00
|
|
|
|
2003-11-03 02:52:40 +01:00
|
|
|
#include <string>
|
|
|
|
|
2003-11-03 02:43:39 +01:00
|
|
|
#include "arch/alpha/pseudo_inst.hh"
|
2004-07-02 00:03:05 +02:00
|
|
|
#include "arch/alpha/vtophys.hh"
|
|
|
|
#include "cpu/base_cpu.hh"
|
2004-08-02 23:10:02 +02:00
|
|
|
#include "cpu/sampling_cpu/sampling_cpu.hh"
|
2003-11-03 02:43:39 +01:00
|
|
|
#include "cpu/exec_context.hh"
|
2004-08-20 17:35:31 +02:00
|
|
|
#include "kern/kernel_stats.hh"
|
2003-11-03 02:52:40 +01:00
|
|
|
#include "sim/param.hh"
|
2003-11-03 02:43:39 +01:00
|
|
|
#include "sim/serialize.hh"
|
|
|
|
#include "sim/sim_exit.hh"
|
2004-05-04 23:01:00 +02:00
|
|
|
#include "sim/stat_control.hh"
|
|
|
|
#include "sim/stats.hh"
|
2004-07-02 00:03:05 +02:00
|
|
|
#include "sim/system.hh"
|
2004-08-02 23:10:02 +02:00
|
|
|
#include "sim/debug.hh"
|
2003-11-03 02:43:39 +01:00
|
|
|
|
2003-11-03 02:52:40 +01:00
|
|
|
using namespace std;
|
2004-08-02 23:10:02 +02:00
|
|
|
|
|
|
|
extern SamplingCPU *SampCPU;
|
|
|
|
|
2004-05-21 19:39:20 +02:00
|
|
|
using namespace Stats;
|
2003-11-03 02:43:39 +01:00
|
|
|
|
|
|
|
namespace AlphaPseudo
|
|
|
|
{
|
2003-11-03 02:52:40 +01:00
|
|
|
bool doStatisticsInsts;
|
|
|
|
bool doCheckpointInsts;
|
2003-11-03 22:47:08 +01:00
|
|
|
bool doQuiesce;
|
|
|
|
|
2004-05-13 14:03:36 +02:00
|
|
|
void
|
|
|
|
arm(ExecContext *xc)
|
|
|
|
{
|
2004-08-20 17:35:31 +02:00
|
|
|
xc->kernelStats->arm();
|
2004-05-13 14:03:36 +02:00
|
|
|
}
|
|
|
|
|
2003-11-03 22:47:08 +01:00
|
|
|
void
|
|
|
|
quiesce(ExecContext *xc)
|
|
|
|
{
|
|
|
|
if (!doQuiesce)
|
|
|
|
return;
|
|
|
|
|
2003-12-11 02:47:28 +01:00
|
|
|
xc->suspend();
|
2004-08-20 17:35:31 +02:00
|
|
|
xc->kernelStats->quiesce();
|
2003-11-03 22:47:08 +01:00
|
|
|
}
|
2003-11-03 02:52:40 +01:00
|
|
|
|
2004-05-13 14:03:36 +02:00
|
|
|
void
|
|
|
|
ivlb(ExecContext *xc)
|
|
|
|
{
|
2004-08-20 17:35:31 +02:00
|
|
|
xc->kernelStats->ivlb();
|
2004-05-13 14:03:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ivle(ExecContext *xc)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-11-03 02:43:39 +01:00
|
|
|
void
|
|
|
|
m5exit_old(ExecContext *xc)
|
|
|
|
{
|
|
|
|
SimExit(curTick, "m5_exit_old instruction encountered");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
m5exit(ExecContext *xc)
|
|
|
|
{
|
|
|
|
Tick delay = xc->regs.intRegFile[16];
|
|
|
|
Tick when = curTick + NS2Ticks(delay);
|
|
|
|
SimExit(when, "m5_exit instruction encountered");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
resetstats(ExecContext *xc)
|
|
|
|
{
|
2003-11-03 02:52:40 +01:00
|
|
|
if (!doStatisticsInsts)
|
|
|
|
return;
|
|
|
|
|
2003-11-03 02:43:39 +01:00
|
|
|
Tick delay = xc->regs.intRegFile[16];
|
|
|
|
Tick period = xc->regs.intRegFile[17];
|
|
|
|
|
|
|
|
Tick when = curTick + NS2Ticks(delay);
|
|
|
|
Tick repeat = NS2Ticks(period);
|
|
|
|
|
2004-05-21 19:39:20 +02:00
|
|
|
using namespace Stats;
|
2003-11-03 02:43:39 +01:00
|
|
|
SetupEvent(Reset, when, repeat);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dumpstats(ExecContext *xc)
|
|
|
|
{
|
2003-11-03 02:52:40 +01:00
|
|
|
if (!doStatisticsInsts)
|
|
|
|
return;
|
|
|
|
|
2003-11-03 02:43:39 +01:00
|
|
|
Tick delay = xc->regs.intRegFile[16];
|
|
|
|
Tick period = xc->regs.intRegFile[17];
|
|
|
|
|
|
|
|
Tick when = curTick + NS2Ticks(delay);
|
|
|
|
Tick repeat = NS2Ticks(period);
|
|
|
|
|
2004-05-21 19:39:20 +02:00
|
|
|
using namespace Stats;
|
2003-11-03 02:43:39 +01:00
|
|
|
SetupEvent(Dump, when, repeat);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dumpresetstats(ExecContext *xc)
|
|
|
|
{
|
2003-11-03 02:52:40 +01:00
|
|
|
if (!doStatisticsInsts)
|
|
|
|
return;
|
|
|
|
|
2003-11-03 02:43:39 +01:00
|
|
|
Tick delay = xc->regs.intRegFile[16];
|
|
|
|
Tick period = xc->regs.intRegFile[17];
|
|
|
|
|
|
|
|
Tick when = curTick + NS2Ticks(delay);
|
|
|
|
Tick repeat = NS2Ticks(period);
|
|
|
|
|
2004-05-21 19:39:20 +02:00
|
|
|
using namespace Stats;
|
2003-11-03 02:43:39 +01:00
|
|
|
SetupEvent(Dump|Reset, when, repeat);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
m5checkpoint(ExecContext *xc)
|
|
|
|
{
|
2003-11-03 02:52:40 +01:00
|
|
|
if (!doCheckpointInsts)
|
|
|
|
return;
|
|
|
|
|
2003-11-03 02:43:39 +01:00
|
|
|
Tick delay = xc->regs.intRegFile[16];
|
|
|
|
Tick period = xc->regs.intRegFile[17];
|
|
|
|
|
|
|
|
Tick when = curTick + NS2Ticks(delay);
|
|
|
|
Tick repeat = NS2Ticks(period);
|
|
|
|
|
2004-01-12 00:24:18 +01:00
|
|
|
Checkpoint::setup(when, repeat);
|
2003-11-03 02:43:39 +01:00
|
|
|
}
|
|
|
|
|
2004-07-02 00:03:05 +02:00
|
|
|
void
|
|
|
|
readfile(ExecContext *xc)
|
|
|
|
{
|
2004-08-20 17:35:31 +02:00
|
|
|
const string &file = xc->cpu->system->params->readfile;
|
2004-07-02 00:03:05 +02:00
|
|
|
if (file.empty()) {
|
|
|
|
xc->regs.intRegFile[0] = ULL(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Addr vaddr = xc->regs.intRegFile[16];
|
|
|
|
uint64_t len = xc->regs.intRegFile[17];
|
|
|
|
uint64_t offset = xc->regs.intRegFile[18];
|
|
|
|
uint64_t result = 0;
|
|
|
|
|
|
|
|
int fd = ::open(file.c_str(), O_RDONLY, 0);
|
|
|
|
if (fd < 0)
|
|
|
|
panic("could not open file %s\n", file);
|
|
|
|
|
|
|
|
char *buf = new char[len];
|
|
|
|
char *p = buf;
|
|
|
|
while (len > 0) {
|
|
|
|
int bytes = ::pread(fd, p, len, offset);
|
|
|
|
if (bytes <= 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
p += bytes;
|
|
|
|
offset += bytes;
|
|
|
|
result += bytes;
|
|
|
|
len -= bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
CopyIn(xc, vaddr, buf, result);
|
|
|
|
delete [] buf;
|
|
|
|
xc->regs.intRegFile[0] = result;
|
|
|
|
}
|
|
|
|
|
2003-11-03 02:52:40 +01:00
|
|
|
class Context : public ParamContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Context(const string §ion) : ParamContext(section) {}
|
|
|
|
void checkParams();
|
|
|
|
};
|
|
|
|
|
2005-01-21 10:34:01 +01:00
|
|
|
Context context("pseudo_inst");
|
2003-11-03 02:52:40 +01:00
|
|
|
|
2003-11-03 22:47:08 +01:00
|
|
|
Param<bool> __quiesce(&context, "quiesce",
|
|
|
|
"enable quiesce instructions",
|
|
|
|
true);
|
2003-11-03 03:58:23 +01:00
|
|
|
Param<bool> __statistics(&context, "statistics",
|
2003-11-03 22:47:08 +01:00
|
|
|
"enable statistics pseudo instructions",
|
2003-11-03 04:12:20 +01:00
|
|
|
true);
|
2003-11-03 03:58:23 +01:00
|
|
|
Param<bool> __checkpoint(&context, "checkpoint",
|
2003-11-03 22:47:08 +01:00
|
|
|
"enable checkpoint pseudo instructions",
|
2003-11-03 04:12:20 +01:00
|
|
|
true);
|
2003-11-03 02:52:40 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
Context::checkParams()
|
|
|
|
{
|
2003-11-03 22:47:08 +01:00
|
|
|
doQuiesce = __quiesce;
|
2003-11-03 02:52:40 +01:00
|
|
|
doStatisticsInsts = __statistics;
|
|
|
|
doCheckpointInsts = __checkpoint;
|
|
|
|
}
|
2004-08-02 23:10:02 +02:00
|
|
|
|
|
|
|
void debugbreak(ExecContext *xc)
|
|
|
|
{
|
|
|
|
debug_break();
|
|
|
|
}
|
|
|
|
|
|
|
|
void switchcpu(ExecContext *xc)
|
|
|
|
{
|
|
|
|
if (SampCPU)
|
|
|
|
SampCPU->switchCPUs();
|
|
|
|
}
|
2003-11-03 02:43:39 +01:00
|
|
|
}
|