From ebfe49ca848da0f8fe4c3c306150a404321922cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Thu, 4 Oct 2012 12:52:27 +0200 Subject: [PATCH] Noux: use Terminal::Connection as singleton We will reuse the terminal connection in the stdio filesystem to implement /dev/tty. Therefor we need to access the terminal from different locations which is simplified if it is provided by a singleton. --- ports/src/noux/main.cc | 15 ++++++++---- ports/src/noux/terminal_connection.h | 34 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 ports/src/noux/terminal_connection.h diff --git a/ports/src/noux/main.cc b/ports/src/noux/main.cc index cb54c3f71..3a58364eb 100644 --- a/ports/src/noux/main.cc +++ b/ports/src/noux/main.cc @@ -807,6 +807,13 @@ Noux::Io_receptor_registry * Noux::io_receptor_registry() } +Terminal::Connection *Noux::terminal() +{ + static Terminal::Connection _inst; + return &_inst; +} + + void *operator new (Genode::size_t size) { return Genode::env()->heap()->alloc(size); } @@ -869,17 +876,15 @@ int main(int argc, char **argv) resources_ep, false); - static Terminal::Connection terminal; - /* * I/O channels must be dynamically allocated to handle cases where the * init program closes one of these. */ typedef Terminal_io_channel Tio; /* just a local abbreviation */ Shared_pointer - channel_0(new Tio(terminal, Tio::STDIN, sig_rec), Genode::env()->heap()), - channel_1(new Tio(terminal, Tio::STDOUT, sig_rec), Genode::env()->heap()), - channel_2(new Tio(terminal, Tio::STDERR, sig_rec), Genode::env()->heap()); + channel_0(new Tio(*Noux::terminal(), Tio::STDIN, sig_rec), Genode::env()->heap()), + channel_1(new Tio(*Noux::terminal(), Tio::STDOUT, sig_rec), Genode::env()->heap()), + channel_2(new Tio(*Noux::terminal(), Tio::STDERR, sig_rec), Genode::env()->heap()); init_child->add_io_channel(channel_0, 0); init_child->add_io_channel(channel_1, 1); diff --git a/ports/src/noux/terminal_connection.h b/ports/src/noux/terminal_connection.h new file mode 100644 index 000000000..5c98f8615 --- /dev/null +++ b/ports/src/noux/terminal_connection.h @@ -0,0 +1,34 @@ +/* + * \brief Terminal connection + * \author Josef Soentgen + * \date 2012-08-02 + */ + +/* + * Copyright (C) 2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _NOUX__TERMINAL_CONNECTION_H_ +#define _NOUX__TERMINAL_CONNECTION_H_ + +/* Genode includes */ +#include +#include +#include +#include + +/* Noux includes */ +#include +#include "file_system.h" + + +namespace Noux { + + Terminal::Connection *terminal(); + +} + +#endif /* _NOUX__TERMINAL_CONNECTION_H_ */