#include "dev/platform.hh"
#include "dev/simconsole.hh"
#include "dev/uart.hh"
-#include "sim/builder.hh"
using namespace std;
/*
* 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)
+SimConsole::SimConsole(const Params *p)
+ : SimObject(p), listenEvent(NULL), dataEvent(NULL), number(p->number),
+ data_fd(-1), txbuf(16384), rxbuf(16384), outfile(NULL)
#if TRACING_ON == 1
, linebuf(16384)
#endif
{
- if (outfile)
+ if (!p->output.empty()) {
+ if (p->append_name)
+ outfile = simout.find(p->output + "." + p->name);
+ else
+ outfile = simout.find(p->output);
+
outfile->setf(ios::unitbuf);
+ }
- if (port)
- listen(port);
+ if (p->port)
+ listen(p->port);
}
SimConsole::~SimConsole()
}
-BEGIN_DECLARE_SIM_OBJECT_PARAMS(SimConsole)
-
- SimObjectParam<IntrControl *> intr_control;
- Param<string> output;
- Param<int> port;
- Param<bool> append_name;
- Param<int> number;
-
-END_DECLARE_SIM_OBJECT_PARAMS(SimConsole)
-
-BEGIN_INIT_SIM_OBJECT_PARAMS(SimConsole)
-
- 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)
-
-END_INIT_SIM_OBJECT_PARAMS(SimConsole)
-
-CREATE_SIM_OBJECT(SimConsole)
+SimConsole *
+SimConsoleParams::create()
{
- string filename = output;
- ostream *stream = NULL;
-
- if (!filename.empty()) {
- if (append_name)
- filename += "." + getInstanceName();
- stream = simout.find(filename);
- }
-
- return new SimConsole(getInstanceName(), stream, number, port);
+ return new SimConsole(this);
}
-
-REGISTER_SIM_OBJECT("SimConsole", SimConsole)