summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiacomo Travaglini <giacomo.travaglini@arm.com>2019-04-16 11:39:30 +0100
committerGiacomo Travaglini <giacomo.travaglini@arm.com>2019-09-06 20:01:25 +0000
commit1c72e90e4e5ed1270d875893914d650a8898d6b5 (patch)
tree4b4a8d8a1685f562a864254bd3e8f5d5534cbb62
parente7c75d2c114836203fb5c4d0a7d842c4f4ebaa0e (diff)
downloadgem5-1c72e90e4e5ed1270d875893914d650a8898d6b5.tar.xz
dev: Enable Terminal output's dump to stdout
While the default option is to dump the Terminal content in a file (e.g. m5out/system.terminal), with this patch it will be possible to choose to dump it to standard output. Change-Id: If51c2fd671fa3eb0867a855b5f7d3b0df9cad025 Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20639 Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
-rw-r--r--src/dev/serial/Terminal.py17
-rw-r--r--src/dev/serial/terminal.cc30
-rw-r--r--src/dev/serial/terminal.hh13
3 files changed, 58 insertions, 2 deletions
diff --git a/src/dev/serial/Terminal.py b/src/dev/serial/Terminal.py
index be7fbdc91..534010456 100644
--- a/src/dev/serial/Terminal.py
+++ b/src/dev/serial/Terminal.py
@@ -1,3 +1,15 @@
+# Copyright (c) 2019 ARM Limited
+# All rights reserved.
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder. You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
# Copyright (c) 2005-2007 The Regents of The University of Michigan
# All rights reserved.
#
@@ -32,9 +44,12 @@ from m5.proxy import *
from m5.objects.Serial import SerialDevice
+class TerminalDump(Enum): vals = ["none", "stdout", "stderr", "file"]
+
class Terminal(SerialDevice):
type = 'Terminal'
cxx_header = "dev/serial/terminal.hh"
port = Param.TcpPort(3456, "listen port")
number = Param.Int(0, "terminal number")
- output = Param.Bool(True, "Enable output dump to file")
+ outfile = Param.TerminalDump("file",
+ "Selects if and where the terminal is dumping its output")
diff --git a/src/dev/serial/terminal.cc b/src/dev/serial/terminal.cc
index bc8c14c53..002a2ebb7 100644
--- a/src/dev/serial/terminal.cc
+++ b/src/dev/serial/terminal.cc
@@ -1,4 +1,16 @@
/*
+ * Copyright (c) 2019 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
* Copyright (c) 2001-2005 The Regents of The University of Michigan
* All rights reserved.
*
@@ -109,7 +121,7 @@ Terminal::DataEvent::process(int revent)
Terminal::Terminal(const Params *p)
: SerialDevice(p), listenEvent(NULL), dataEvent(NULL),
number(p->number), data_fd(-1), txbuf(16384), rxbuf(16384),
- outfile(p->output ? simout.findOrCreate(p->name) : NULL)
+ outfile(terminalDump(p))
#if TRACING_ON == 1
, linebuf(16384)
#endif
@@ -133,6 +145,22 @@ Terminal::~Terminal()
delete dataEvent;
}
+OutputStream *
+Terminal::terminalDump(const TerminalParams* p)
+{
+ switch (p->outfile) {
+ case Enums::TerminalDump::none:
+ return nullptr;
+ case Enums::TerminalDump::stdout:
+ return simout.findOrCreate("stdout");
+ case Enums::TerminalDump::stderr:
+ return simout.findOrCreate("stderr");
+ case Enums::TerminalDump::file:
+ return simout.findOrCreate(p->name);
+ default:
+ panic("Invalid option\n");
+ }
+}
///////////////////////////////////////////////////////////////////////
// socket creation and terminal attach
diff --git a/src/dev/serial/terminal.hh b/src/dev/serial/terminal.hh
index 9e114de14..bc2ebd8b1 100644
--- a/src/dev/serial/terminal.hh
+++ b/src/dev/serial/terminal.hh
@@ -1,4 +1,16 @@
/*
+ * Copyright (c) 2019 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
* Copyright (c) 2001-2005 The Regents of The University of Michigan
* All rights reserved.
*
@@ -86,6 +98,7 @@ class Terminal : public SerialDevice
typedef TerminalParams Params;
Terminal(const Params *p);
~Terminal();
+ OutputStream * terminalDump(const TerminalParams* p);
protected:
ListenSocket listener;