From: Giacomo Travaglini Date: Tue, 16 Apr 2019 10:39:30 +0000 (+0100) Subject: dev: Enable Terminal output's dump to stdout X-Git-Tag: v19.0.0.0~570 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1c72e90;p=gem5.git 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 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20639 Maintainer: Jason Lowe-Power Tested-by: kokoro Reviewed-by: Daniel Carvalho Reviewed-by: Jason Lowe-Power Reviewed-by: Andreas Sandberg --- 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;