summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configs/common/FSConfig.py2
-rw-r--r--src/arch/sparc/isa/decoder.isa4
-rw-r--r--src/base/statistics.hh18
-rw-r--r--src/dev/ns_gige.cc26
-rw-r--r--src/dev/simconsole.cc229
-rw-r--r--src/dev/simconsole.hh76
-rw-r--r--src/python/m5/objects/SimConsole.py5
-rw-r--r--src/python/m5/objects/T1000.py6
-rw-r--r--src/sim/system.cc36
9 files changed, 164 insertions, 238 deletions
diff --git a/configs/common/FSConfig.py b/configs/common/FSConfig.py
index c341b762a..2b13388d6 100644
--- a/configs/common/FSConfig.py
+++ b/configs/common/FSConfig.py
@@ -78,7 +78,7 @@ def makeLinuxAlphaSystem(mem_mode, mdesc = None):
read_only = True))
self.intrctrl = IntrControl()
self.mem_mode = mem_mode
- self.sim_console = SimConsole(listener=ConsoleListener(port=3456))
+ self.sim_console = SimConsole()
self.kernel = binary('vmlinux')
self.pal = binary('ts_osfpal')
self.console = binary('console')
diff --git a/src/arch/sparc/isa/decoder.isa b/src/arch/sparc/isa/decoder.isa
index c07295248..0382aa35e 100644
--- a/src/arch/sparc/isa/decoder.isa
+++ b/src/arch/sparc/isa/decoder.isa
@@ -1009,6 +1009,7 @@ decode OP default Unknown::unknown()
0x80: Trap::shutdown({{fault = new IllegalInstruction;}});
0x81: FailUnimpl::siam();
}
+#if FULL_SYSTEM
// M5 special opcodes use the reserved IMPDEP2A opcode space
0x37: decode M5FUNC {
// we have 7 bits of space here to play with...
@@ -1024,6 +1025,9 @@ decode OP default Unknown::unknown()
}}, No_OpClass, IsNonSpeculative);
}
+#else
+ 0x37: Trap::impdep2({{fault = new IllegalInstruction;}});
+#endif
0x38: Branch::jmpl({{
Addr target = Rs1 + Rs2_or_imm13;
if(target & 0x3)
diff --git a/src/base/statistics.hh b/src/base/statistics.hh
index 8168473a1..761b30c2b 100644
--- a/src/base/statistics.hh
+++ b/src/base/statistics.hh
@@ -70,7 +70,7 @@
class Callback;
-/** The current simulated cycle. */
+/** The current simulated tick. */
extern Tick curTick;
/* A namespace for all of the Statistics */
@@ -598,9 +598,9 @@ struct StatStor
};
/**
- * Templatized storage and interface to a per-cycle average stat. This keeps
- * a current count and updates a total (count * cycles) when this count
- * changes. This allows the quick calculation of a per cycle count of the item
+ * Templatized storage and interface to a per-tick average stat. This keeps
+ * a current count and updates a total (count * ticks) when this count
+ * changes. This allows the quick calculation of a per tick count of the item
* being watched. This is good for keeping track of residencies in structures
* among other things.
*/
@@ -613,9 +613,9 @@ struct AvgStor
private:
/** The current count. */
Counter current;
- /** The total count for all cycles. */
+ /** The total count for all tick. */
mutable Result total;
- /** The cycle that current last changed. */
+ /** The tick that current last changed. */
mutable Tick last;
public:
@@ -1563,7 +1563,7 @@ struct FancyStor
};
/**
- * Templatized storage for distribution that calculates per cycle mean and
+ * Templatized storage for distribution that calculates per tick mean and
* variance.
*/
struct AvgFancy
@@ -2280,7 +2280,7 @@ class Value : public Wrap<Value, ValueBase, ScalarStatData>
};
/**
- * A stat that calculates the per cycle average of a value.
+ * A stat that calculates the per tick average of a value.
* @sa Stat, ScalarBase, AvgStor
*/
template<int N = 0>
@@ -2417,7 +2417,7 @@ class StandardDeviation
};
/**
- * Calculates the per cycle mean and variance of the samples.
+ * Calculates the per tick mean and variance of the samples.
* @sa Stat, DistBase, AvgFancy
*/
template<int N = 0>
diff --git a/src/dev/ns_gige.cc b/src/dev/ns_gige.cc
index 74f9d88d1..86f56b62e 100644
--- a/src/dev/ns_gige.cc
+++ b/src/dev/ns_gige.cc
@@ -92,28 +92,30 @@ NSGigE::NSGigE(Params *p)
: PciDev(p), ioEnable(false),
txFifo(p->tx_fifo_size), rxFifo(p->rx_fifo_size),
txPacket(0), rxPacket(0), txPacketBufPtr(NULL), rxPacketBufPtr(NULL),
- txXferLen(0), rxXferLen(0), clock(p->clock),
- txState(txIdle), txEnable(false), CTDD(false),
+ txXferLen(0), rxXferLen(0), rxDmaFree(false), txDmaFree(false),
+ clock(p->clock),
+ txState(txIdle), txEnable(false), CTDD(false), txHalt(false),
txFragPtr(0), txDescCnt(0), txDmaState(dmaIdle), rxState(rxIdle),
- rxEnable(false), CRDD(false), rxPktBytes(0),
+ rxEnable(false), CRDD(false), rxPktBytes(0), rxHalt(false),
rxFragPtr(0), rxDescCnt(0), rxDmaState(dmaIdle), extstsEnable(false),
- eepromState(eepromStart), rxDmaReadEvent(this), rxDmaWriteEvent(this),
+ eepromState(eepromStart), eepromClk(false), eepromBitsToRx(0),
+ eepromOpcode(0), eepromAddress(0), eepromData(0),
+ dmaReadDelay(p->dma_read_delay), dmaWriteDelay(p->dma_write_delay),
+ dmaReadFactor(p->dma_read_factor), dmaWriteFactor(p->dma_write_factor),
+ rxDmaData(NULL), rxDmaAddr(0), rxDmaLen(0),
+ txDmaData(NULL), txDmaAddr(0), txDmaLen(0),
+ rxDmaReadEvent(this), rxDmaWriteEvent(this),
txDmaReadEvent(this), txDmaWriteEvent(this),
dmaDescFree(p->dma_desc_free), dmaDataFree(p->dma_data_free),
txDelay(p->tx_delay), rxDelay(p->rx_delay),
rxKickTick(0), rxKickEvent(this), txKickTick(0), txKickEvent(this),
- txEvent(this), rxFilterEnable(p->rx_filter), acceptBroadcast(false),
- acceptMulticast(false), acceptUnicast(false),
+ txEvent(this), rxFilterEnable(p->rx_filter),
+ acceptBroadcast(false), acceptMulticast(false), acceptUnicast(false),
acceptPerfect(false), acceptArp(false), multicastHashEnable(false),
- intrTick(0), cpuPendingIntr(false),
+ intrDelay(p->intr_delay), intrTick(0), cpuPendingIntr(false),
intrEvent(0), interface(0)
{
- intrDelay = p->intr_delay;
- dmaReadDelay = p->dma_read_delay;
- dmaWriteDelay = p->dma_write_delay;
- dmaReadFactor = p->dma_read_factor;
- dmaWriteFactor = p->dma_write_factor;
regsReset();
memcpy(&rom.perfectMatch, p->eaddr.bytes(), ETH_ADDR_LEN);
diff --git a/src/dev/simconsole.cc b/src/dev/simconsole.cc
index 903368491..c6ff9c1c6 100644
--- a/src/dev/simconsole.cc
+++ b/src/dev/simconsole.cc
@@ -56,17 +56,31 @@
using namespace std;
-////////////////////////////////////////////////////////////////////////
-//
-//
-SimConsole::Event::Event(SimConsole *c, int fd, int e)
+/*
+ * Poll event for the listen socket
+ */
+SimConsole::ListenEvent::ListenEvent(SimConsole *c, int fd, int e)
+ : PollEvent(fd, e), cons(c)
+{
+}
+
+void
+SimConsole::ListenEvent::process(int revent)
+{
+ cons->accept();
+}
+
+/*
+ * Poll event for the data socket
+ */
+SimConsole::DataEvent::DataEvent(SimConsole *c, int fd, int e)
: PollEvent(fd, e), cons(c)
{
}
void
-SimConsole::Event::process(int revent)
+SimConsole::DataEvent::process(int revent)
{
if (revent & POLLIN)
cons->data();
@@ -74,41 +88,76 @@ SimConsole::Event::process(int revent)
cons->detach();
}
-SimConsole::SimConsole(const string &name, ostream *os, int num)
- : SimObject(name), event(NULL), number(num), in_fd(-1), out_fd(-1),
- listener(NULL), txbuf(16384), rxbuf(16384), outfile(os)
+/*
+ * SimConsole code
+ */
+SimConsole::SimConsole(const string &name, ostream *os, int num, int port)
+ : SimObject(name), listenEvent(NULL), dataEvent(NULL), number(num),
+ data_fd(-1), txbuf(16384), rxbuf(16384), outfile(os)
#if TRACING_ON == 1
, linebuf(16384)
#endif
{
if (outfile)
outfile->setf(ios::unitbuf);
+
+ if (port)
+ listen(port);
}
SimConsole::~SimConsole()
{
- close();
+ if (data_fd != -1)
+ ::close(data_fd);
+
+ if (listenEvent)
+ delete listenEvent;
+
+ if (dataEvent)
+ delete dataEvent;
}
+///////////////////////////////////////////////////////////////////////
+// socket creation and console attach
+//
+
void
-SimConsole::close()
+SimConsole::listen(int port)
{
- if (in_fd != -1)
- ::close(in_fd);
+ while (!listener.listen(port, true)) {
+ DPRINTF(Console,
+ ": can't bind address console port %d inuse PID %d\n",
+ port, getpid());
+ port++;
+ }
+
+ int p1, p2;
+ p2 = name().rfind('.') - 1;
+ p1 = name().rfind('.', p2);
+ ccprintf(cerr, "Listening for %s connection on port %d\n",
+ name().substr(p1+1,p2-p1), port);
- if (out_fd != in_fd && out_fd != -1)
- ::close(out_fd);
+ listenEvent = new ListenEvent(this, listener.getfd(), POLLIN);
+ pollQueue.schedule(listenEvent);
}
void
-SimConsole::attach(int in, int out, ConsoleListener *l)
+SimConsole::accept()
{
- in_fd = in;
- out_fd = out;
- listener = l;
+ if (!listener.islistening())
+ panic("%s: cannot accept a connection if not listening!", name());
+
+ int fd = listener.accept(true);
+ if (data_fd != -1) {
+ char message[] = "console already attached!\n";
+ ::write(fd, message, sizeof(message));
+ ::close(fd);
+ return;
+ }
- event = new Event(this, in, POLLIN);
- pollQueue.schedule(event);
+ data_fd = fd;
+ dataEvent = new DataEvent(this, data_fd, POLLIN);
+ pollQueue.schedule(dataEvent);
stringstream stream;
ccprintf(stream, "==== m5 slave console: Console %d ====", number);
@@ -119,26 +168,23 @@ SimConsole::attach(int in, int out, ConsoleListener *l)
write((const uint8_t *)stream.str().c_str(), stream.str().size());
-
DPRINTFN("attach console %d\n", number);
- txbuf.readall(out);
+ txbuf.readall(data_fd);
}
void
SimConsole::detach()
{
- close();
- in_fd = -1;
- out_fd = -1;
-
- pollQueue.remove(event);
-
- if (listener) {
- listener->add(this);
- listener = NULL;
+ if (data_fd != -1) {
+ ::close(data_fd);
+ data_fd = -1;
}
+ pollQueue.remove(dataEvent);
+ delete dataEvent;
+ dataEvent = NULL;
+
DPRINTFN("detach console %d\n", number);
}
@@ -159,12 +205,12 @@ SimConsole::data()
size_t
SimConsole::read(uint8_t *buf, size_t len)
{
- if (in_fd < 0)
+ if (data_fd < 0)
panic("Console not properly attached.\n");
size_t ret;
do {
- ret = ::read(in_fd, buf, len);
+ ret = ::read(data_fd, buf, len);
} while (ret == -1 && errno == EINTR);
@@ -183,12 +229,12 @@ SimConsole::read(uint8_t *buf, size_t len)
size_t
SimConsole::write(const uint8_t *buf, size_t len)
{
- if (out_fd < 0)
+ if (data_fd < 0)
panic("Console not properly attached.\n");
size_t ret;
for (;;) {
- ret = ::write(out_fd, buf, len);
+ ret = ::write(data_fd, buf, len);
if (ret >= 0)
break;
@@ -268,7 +314,7 @@ SimConsole::out(char c)
txbuf.write(c);
- if (out_fd >= 0)
+ if (data_fd >= 0)
write(c);
if (outfile)
@@ -279,23 +325,11 @@ SimConsole::out(char c)
}
-
-void
-SimConsole::serialize(ostream &os)
-{
-}
-
-void
-SimConsole::unserialize(Checkpoint *cp, const std::string &section)
-{
-}
-
-
BEGIN_DECLARE_SIM_OBJECT_PARAMS(SimConsole)
- SimObjectParam<ConsoleListener *> listener;
SimObjectParam<IntrControl *> intr_control;
Param<string> output;
+ Param<int> port;
Param<bool> append_name;
Param<int> number;
@@ -303,9 +337,9 @@ END_DECLARE_SIM_OBJECT_PARAMS(SimConsole)
BEGIN_INIT_SIM_OBJECT_PARAMS(SimConsole)
- INIT_PARAM(listener, "console listener"),
INIT_PARAM(intr_control, "interrupt controller"),
INIT_PARAM(output, "file to dump output to"),
+ INIT_PARAM(port, ""),
INIT_PARAM_DFLT(append_name, "append name() to filename", true),
INIT_PARAM_DFLT(number, "console number", 0)
@@ -322,100 +356,7 @@ CREATE_SIM_OBJECT(SimConsole)
stream = simout.find(filename);
}
- SimConsole *console = new SimConsole(getInstanceName(), stream, number);
- ((ConsoleListener *)listener)->add(console);
-
- return console;
+ return new SimConsole(getInstanceName(), stream, number, port);
}
REGISTER_SIM_OBJECT("SimConsole", SimConsole)
-
-////////////////////////////////////////////////////////////////////////
-//
-//
-
-ConsoleListener::ConsoleListener(const string &name)
- : SimObject(name), event(NULL)
-{}
-
-ConsoleListener::~ConsoleListener()
-{
- if (event)
- delete event;
-}
-
-void
-ConsoleListener::Event::process(int revent)
-{
- listener->accept();
-}
-
-///////////////////////////////////////////////////////////////////////
-// socket creation and console attach
-//
-
-void
-ConsoleListener::listen(int port)
-{
- while (!listener.listen(port, true)) {
- DPRINTF(Console,
- ": can't bind address console port %d inuse PID %d\n",
- port, getpid());
- port++;
- }
-
-
- int p1, p2;
- p2 = name().rfind('.') - 1;
- p1 = name().rfind('.', p2);
- ccprintf(cerr, "Listening for %s connection on port %d\n",
- name().substr(p1+1,p2-p1), port);
-
- event = new Event(this, listener.getfd(), POLLIN);
- pollQueue.schedule(event);
-}
-
-void
-ConsoleListener::add(SimConsole *cons)
-{ ConsoleList.push_back(cons);}
-
-void
-ConsoleListener::accept()
-{
- if (!listener.islistening())
- panic("%s: cannot accept a connection if not listening!", name());
-
- int sfd = listener.accept(true);
- if (sfd != -1) {
- iter_t i = ConsoleList.begin();
- iter_t end = ConsoleList.end();
- if (i == end) {
- close(sfd);
- } else {
- (*i)->attach(sfd, this);
- i = ConsoleList.erase(i);
- }
- }
-}
-
-BEGIN_DECLARE_SIM_OBJECT_PARAMS(ConsoleListener)
-
- Param<int> port;
-
-END_DECLARE_SIM_OBJECT_PARAMS(ConsoleListener)
-
-BEGIN_INIT_SIM_OBJECT_PARAMS(ConsoleListener)
-
- INIT_PARAM_DFLT(port, "listen port", 3456)
-
-END_INIT_SIM_OBJECT_PARAMS(ConsoleListener)
-
-CREATE_SIM_OBJECT(ConsoleListener)
-{
- ConsoleListener *listener = new ConsoleListener(getInstanceName());
- listener->listen(port);
-
- return listener;
-}
-
-REGISTER_SIM_OBJECT("ConsoleListener", ConsoleListener)
diff --git a/src/dev/simconsole.hh b/src/dev/simconsole.hh
index ec99c6028..18a193493 100644
--- a/src/dev/simconsole.hh
+++ b/src/dev/simconsole.hh
@@ -53,30 +53,47 @@ class SimConsole : public SimObject
Uart *uart;
protected:
- class Event : public PollEvent
+ class ListenEvent : public PollEvent
{
protected:
SimConsole *cons;
public:
- Event(SimConsole *c, int fd, int e);
+ ListenEvent(SimConsole *c, int fd, int e);
void process(int revent);
};
- friend class Event;
- Event *event;
+ friend class ListenEvent;
+ ListenEvent *listenEvent;
+
+ class DataEvent : public PollEvent
+ {
+ protected:
+ SimConsole *cons;
+
+ public:
+ DataEvent(SimConsole *c, int fd, int e);
+ void process(int revent);
+ };
+
+ friend class DataEvent;
+ DataEvent *dataEvent;
protected:
int number;
- int in_fd;
- int out_fd;
- ConsoleListener *listener;
+ int data_fd;
public:
- SimConsole(const std::string &name, std::ostream *os, int num);
+ SimConsole(const std::string &name, std::ostream *os, int num, int port);
~SimConsole();
protected:
+ ListenSocket listener;
+
+ void listen(int port);
+ void accept();
+
+ protected:
CircleBuf txbuf;
CircleBuf rxbuf;
std::ostream *outfile;
@@ -88,17 +105,13 @@ class SimConsole : public SimObject
///////////////////////
// Terminal Interface
- void attach(int fd, ConsoleListener *l = NULL) { attach(fd, fd, l); }
- void attach(int in, int out, ConsoleListener *l = NULL);
- void detach();
-
void data();
- void close();
void read(uint8_t &c) { read(&c, 1); }
size_t read(uint8_t *buf, size_t len);
void write(uint8_t c) { write(&c, 1); }
size_t write(const uint8_t *buf, size_t len);
+ void detach();
public:
/////////////////
@@ -126,43 +139,6 @@ class SimConsole : public SimObject
//Ask the console if data is available
bool dataAvailable() { return !rxbuf.empty(); }
-
- virtual void serialize(std::ostream &os);
- virtual void unserialize(Checkpoint *cp, const std::string &section);
-};
-
-class ConsoleListener : public SimObject
-{
- protected:
- class Event : public PollEvent
- {
- protected:
- ConsoleListener *listener;
-
- public:
- Event(ConsoleListener *l, int fd, int e)
- : PollEvent(fd, e), listener(l) {}
- void process(int revent);
- };
-
- friend class Event;
- Event *event;
-
- typedef std::list<SimConsole *> list_t;
- typedef list_t::iterator iter_t;
- list_t ConsoleList;
-
- protected:
- ListenSocket listener;
-
- public:
- ConsoleListener(const std::string &name);
- ~ConsoleListener();
-
- void add(SimConsole *cons);
-
- void accept();
- void listen(int port);
};
#endif // __CONSOLE_HH__
diff --git a/src/python/m5/objects/SimConsole.py b/src/python/m5/objects/SimConsole.py
index bdd7f246d..dfad18eb6 100644
--- a/src/python/m5/objects/SimConsole.py
+++ b/src/python/m5/objects/SimConsole.py
@@ -1,14 +1,11 @@
from m5.SimObject import SimObject
from m5.params import *
from m5.proxy import *
-class ConsoleListener(SimObject):
- type = 'ConsoleListener'
- port = Param.TcpPort(3456, "listen port")
class SimConsole(SimObject):
type = 'SimConsole'
append_name = Param.Bool(True, "append name() to filename")
intr_control = Param.IntrControl(Parent.any, "interrupt controller")
- listener = Param.ConsoleListener("console listener")
+ port = Param.TcpPort(3456, "listen port")
number = Param.Int(0, "console number")
output = Param.String('console', "file to dump output to")
diff --git a/src/python/m5/objects/T1000.py b/src/python/m5/objects/T1000.py
index 3ab6d4283..aeca491c4 100644
--- a/src/python/m5/objects/T1000.py
+++ b/src/python/m5/objects/T1000.py
@@ -3,7 +3,7 @@ from m5.proxy import *
from Device import BasicPioDevice, IsaFake, BadAddr
from Uart import Uart8250
from Platform import Platform
-from SimConsole import SimConsole, ConsoleListener
+from SimConsole import SimConsole
class MmDisk(BasicPioDevice):
@@ -69,11 +69,11 @@ class T1000(Platform):
fake_ssi = IsaFake(pio_addr=0xff00000000, pio_size=0x10000000)
#warn_access="Accessing SSI -- Unimplemented!")
- hconsole = SimConsole(listener = ConsoleListener())
+ hconsole = SimConsole()
hvuart = Uart8250(pio_addr=0xfff0c2c000)
htod = DumbTOD()
- pconsole = SimConsole(listener = ConsoleListener())
+ pconsole = SimConsole()
puart0 = Uart8250(pio_addr=0x1f10000000)
# Attach I/O devices to specified bus object. Can't do this
diff --git a/src/sim/system.cc b/src/sim/system.cc
index f6febe4b1..1a87e1754 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -142,6 +142,7 @@ System::~System()
}
int rgdb_wait = -1;
+int rgdb_enable = true;
void
System::setMemoryMode(MemoryMode mode)
@@ -152,7 +153,9 @@ System::setMemoryMode(MemoryMode mode)
bool System::breakpoint()
{
- return remoteGDB[0]->breakpoint();
+ if (remoteGDB.size())
+ return remoteGDB[0]->breakpoint();
+ return false;
}
int
@@ -174,22 +177,24 @@ System::registerThreadContext(ThreadContext *tc, int id)
threadContexts[id] = tc;
numcpus++;
- RemoteGDB *rgdb = new RemoteGDB(this, tc);
- GDBListener *gdbl = new GDBListener(rgdb, 7000 + id);
- gdbl->listen();
- /**
- * Uncommenting this line waits for a remote debugger to connect
- * to the simulator before continuing.
- */
- if (rgdb_wait != -1 && rgdb_wait == id)
- gdbl->accept();
+ if (rgdb_enable) {
+ RemoteGDB *rgdb = new RemoteGDB(this, tc);
+ GDBListener *gdbl = new GDBListener(rgdb, 7000 + id);
+ gdbl->listen();
+ /**
+ * Uncommenting this line waits for a remote debugger to
+ * connect to the simulator before continuing.
+ */
+ if (rgdb_wait != -1 && rgdb_wait == id)
+ gdbl->accept();
+
+ if (remoteGDB.size() <= id) {
+ remoteGDB.resize(id + 1);
+ }
- if (remoteGDB.size() <= id) {
- remoteGDB.resize(id + 1);
+ remoteGDB[id] = rgdb;
}
- remoteGDB[id] = rgdb;
-
return id;
}
@@ -210,7 +215,8 @@ System::replaceThreadContext(ThreadContext *tc, int id)
}
threadContexts[id] = tc;
- remoteGDB[id]->replaceThreadContext(tc);
+ if (id < remoteGDB.size())
+ remoteGDB[id]->replaceThreadContext(tc);
}
#if !FULL_SYSTEM