mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
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.
This commit is contained in:
parent
82eb0e9f9a
commit
ebfe49ca84
@ -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<Io_channel>
|
||||
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);
|
||||
|
34
ports/src/noux/terminal_connection.h
Normal file
34
ports/src/noux/terminal_connection.h
Normal file
@ -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 <base/printf.h>
|
||||
#include <base/lock.h>
|
||||
#include <terminal_session/connection.h>
|
||||
#include <util/string.h>
|
||||
|
||||
/* Noux includes */
|
||||
#include <noux_session/sysio.h>
|
||||
#include "file_system.h"
|
||||
|
||||
|
||||
namespace Noux {
|
||||
|
||||
Terminal::Connection *terminal();
|
||||
|
||||
}
|
||||
|
||||
#endif /* _NOUX__TERMINAL_CONNECTION_H_ */
|
Loading…
x
Reference in New Issue
Block a user