nic: remove usage of deprecated env()

This commit includes changes to the Nic::Session_component interface.
We now pass the entire env to the component instead of only ram, rm and
the ep because we need the env to open connections from within the
Session_component implemenation. So far only the cadence_gem driver
needs this, though.

Issue #2280.
This commit is contained in:
Josef Söntgen 2017-02-13 20:51:27 +01:00 committed by Christian Helmuth
parent e6e1d8c144
commit 15821e32ec
28 changed files with 112 additions and 127 deletions

View File

@ -101,11 +101,8 @@ class Ipxe_session_component : public Nic::Session_component
Ipxe_session_component(Genode::size_t const tx_buf_size,
Genode::size_t const rx_buf_size,
Genode::Allocator &rx_block_md_alloc,
Genode::Ram_session &ram_session,
Genode::Region_map &region_map,
Genode::Entrypoint &ep)
: Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc,
ram_session, region_map, ep)
Genode::Env &env)
: Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc, env)
{
instance = this;

View File

@ -179,12 +179,9 @@ class Usb_nic::Session_component : public Nic::Session_component
Session_component(Genode::size_t const tx_buf_size,
Genode::size_t const rx_buf_size,
Genode::Allocator &rx_block_md_alloc,
Genode::Ram_session &ram_session,
Genode::Region_map &region_map,
Genode::Entrypoint &ep,
Genode::Env &env,
Device *device)
: Nic::Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc,
ram_session, region_map, ep),
: Nic::Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc, env),
_device(device)
{ _device->session(this); }
@ -258,9 +255,7 @@ class Root : public Root_component
return new (Root::md_alloc())
Usb_nic::Session_component(tx_buf_size, rx_buf_size,
Lx::Malloc::mem(),
_env.ram(), _env.rm(),
_env.ep(), _device);
Lx::Malloc::mem(), _env, _device);
}
public:

View File

@ -90,11 +90,8 @@ class Wifi_session_component : public Nic::Session_component
Wifi_session_component(Genode::size_t const tx_buf_size,
Genode::size_t const rx_buf_size,
Genode::Allocator &rx_block_md_alloc,
Genode::Ram_session &ram_session,
Genode::Region_map &region_map,
Genode::Entrypoint &ep, net_device *ndev)
: Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc,
ram_session, region_map, ep),
Genode::Env &env, net_device *ndev)
: Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc, env),
_ndev(ndev)
{
_ndev->lx_nic_device = this;
@ -198,9 +195,7 @@ class Root : public Genode::Root_component<Wifi_session_component,
session = new (md_alloc())
Wifi_session_component(tx_buf_size, rx_buf_size,
*md_alloc(),
_env.ram(), _env.rm(),
_env.ep(), device);
*md_alloc(), _env, device);
return session;
}

View File

@ -79,9 +79,8 @@ set config {
<start name="test-lwip_httpsrv">
<resource name="RAM" quantum="5M"/>
<config>
<libc stdout="/dev/log" stderr="/dev/log">
<vfs> <dir name="dev"> <log/> </dir> </vfs>
</libc>
<vfs> <dir name="dev"> <log/> </dir> </vfs>
<libc stdout="/dev/log" stderr="/dev/log"/>
</config>
</start>}

View File

@ -16,7 +16,7 @@
#define _INCLUDE__NIC__COMPONENT_H_
#include <base/attached_ram_dataspace.h>
#include <base/entrypoint.h>
#include <base/env.h>
#include <nic/packet_allocator.h>
#include <nic_session/rpc_object.h>
@ -84,24 +84,22 @@ class Nic::Session_component : Communication_buffers, public Session_rpc_object
* \param rx_buf_size buffer size for rx channel
* \param rx_block_md_alloc backing store of the meta data of the
* rx block allocator
* \param ram_session RAM session to allocate tx and rx buffers
* \param ep entry point used for packet stream
* channels
* \param env Genode environment needed to access
* resources and open connections from
* within the Session_component
*/
Session_component(Genode::size_t const tx_buf_size,
Genode::size_t const rx_buf_size,
Genode::Allocator &rx_block_md_alloc,
Genode::Ram_session &ram_session,
Genode::Region_map &region_map,
Genode::Entrypoint &ep)
Genode::Env &env)
:
Communication_buffers(rx_block_md_alloc, ram_session, region_map,
Communication_buffers(rx_block_md_alloc, env.ram(), env.rm(),
tx_buf_size, rx_buf_size),
Session_rpc_object(region_map,
Session_rpc_object(env.rm(),
_tx_ds.cap(),
_rx_ds.cap(),
&_rx_packet_alloc, ep.rpc_ep()),
_ep(ep)
&_rx_packet_alloc, env.ep().rpc_ep()),
_ep(env.ep())
{
/* install data-flow signal handlers for both packet streams */
_tx.sigh_ready_to_ack(_packet_stream_dispatcher);

View File

@ -61,10 +61,7 @@ class Nic::Root : public Genode::Root_component<SESSION_COMPONENT,
return new (Root::md_alloc())
SESSION_COMPONENT(tx_buf_size, rx_buf_size,
_md_alloc,
_env.ram(),
_env.rm(),
_env.ep());
_md_alloc, _env);
}
public:

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
* Copyright (C) 2015-2017 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.
@ -70,8 +70,9 @@ class Buffer_descriptor : protected Attached_ram_dataspace, protected Mmio
* start of the ram spave contains all buffer descriptors
* after that the data spaces for the ethernet packages are following
*/
Buffer_descriptor(const size_t buffer_count = 1) :
Attached_ram_dataspace(env()->ram_session(), BUFFER_SIZE * buffer_count, UNCACHED),
Buffer_descriptor(Genode::Env &env, const size_t buffer_count = 1)
:
Attached_ram_dataspace(env.ram(), env.rm(), BUFFER_SIZE * buffer_count, UNCACHED),
Genode::Mmio( reinterpret_cast<addr_t>(local_addr<void>()) ),
_buffer_count(buffer_count),
_buffer_offset(BUFFER_DESC_SIZE * buffer_count),

View File

@ -459,17 +459,16 @@ namespace Genode
Cadence_gem(Genode::size_t const tx_buf_size,
Genode::size_t const rx_buf_size,
Genode::Allocator &rx_block_md_alloc,
Genode::Ram_session &ram_session,
Genode::Region_map &region_map,
Server::Entrypoint &ep,
Genode::Env &env,
addr_t const base, size_t const size, const int irq)
:
Genode::Attached_mmio(base, size),
Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc,
ram_session, region_map, ep),
_irq(irq),
_irq_handler(ep, *this, &Cadence_gem::_handle_irq),
_phy(*this)
Genode::Attached_mmio(env, base, size),
Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc, env),
_timer(env),
_sys_ctrl(env, _timer), _tx_buffer(env, _timer), _rx_buffer(env),
_irq(env, irq),
_irq_handler(env.ep(), *this, &Cadence_gem::_handle_irq),
_phy(*this, _timer)
{
_irq.sigh(_irq_handler);
_irq.ack_irq();

View File

@ -12,15 +12,19 @@
*/
/* Genode includes */
/*
* Needs to be included first because otherwise
* util/xml_node.h will not pick up the ascii_to
* overload.
*/
#include <nic/xml_node.h>
#include <base/attached_rom_dataspace.h>
#include <base/component.h>
#include <base/heap.h>
#include <base/sleep.h>
#include <drivers/board_base.h>
#include <nic/xml_node.h>
#include <nic/root.h>
#include <os/config.h>
#include "cadence_gem.h"
namespace Server {
@ -30,29 +34,30 @@ namespace Server {
struct Main;
}
class Server::Gem_session_component
:
public Cadence_gem
class Server::Gem_session_component : public Cadence_gem
{
private:
Genode::Attached_rom_dataspace _config_rom;
public:
Gem_session_component(Genode::size_t const tx_buf_size,
Genode::size_t const rx_buf_size,
Genode::Allocator &rx_block_md_alloc,
Genode::Ram_session &ram_session,
Genode::Region_map &region_map,
Server::Entrypoint &ep)
Genode::Env &env)
:
Cadence_gem(tx_buf_size, rx_buf_size, rx_block_md_alloc,
ram_session, region_map, ep,
Cadence_gem(tx_buf_size, rx_buf_size, rx_block_md_alloc, env,
Board_base::EMAC_0_MMIO_BASE,
Board_base::EMAC_0_MMIO_SIZE,
Board_base::EMAC_0_IRQ)
Board_base::EMAC_0_IRQ),
_config_rom(env, "config")
{
Nic::Mac_address mac_addr;
/* try using configured MAC address */
try {
Genode::Xml_node nic_config = Genode::config()->xml_node().sub_node("nic");
Genode::Xml_node nic_config = _config_rom.xml().sub_node("nic");
nic_config.attribute("mac").value(&mac_addr);
Genode::log("Using configured MAC address ", mac_addr);
} catch (...) {
@ -76,7 +81,7 @@ struct Server::Main
Env &_env;
Heap _heap { _env.ram(), _env.rm() };
Nic::Root<Gem_session_component> nic_root{ _env, *Genode::env()->heap() };
Nic::Root<Gem_session_component> nic_root{ _env, _heap };
Main(Env &env) : _env(env)
{
@ -84,5 +89,5 @@ struct Server::Main
}
};
void Component::construct(Genode::Env &env) { static Server::Main main(env); }
void Component::construct(Genode::Env &env) { static Server::Main main(env); }

View File

@ -6,7 +6,7 @@
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
* Copyright (C) 2015-2017 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.
@ -162,7 +162,7 @@ namespace Genode
PHY_AUTONEGOTIATE_TIMEOUT = 5000
};
Timer::Connection _timer;
Timer::Connection &_timer;
Phyio& _phyio;
int8_t _phyaddr;
bool _link_up;
@ -551,7 +551,9 @@ namespace Genode
public:
Marvel_phy(Phyio& phyio) :
Marvel_phy(Phyio& phyio, Timer::Connection &timer)
:
_timer(timer),
_phyio(phyio),
_phyaddr(0),
_link_up(false),

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
* Copyright (C) 2015-2017 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.
@ -52,7 +52,7 @@ class Rx_buffer_descriptor : public Buffer_descriptor
public:
Rx_buffer_descriptor() : Buffer_descriptor(BUFFER_COUNT)
Rx_buffer_descriptor(Genode::Env &env) : Buffer_descriptor(env, BUFFER_COUNT)
{
/*
* mark the last buffer descriptor

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
* Copyright (C) 2015-2017 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.
@ -108,9 +108,13 @@ class System_control : private Genode::Attached_mmio
unsigned int old_data[0x300];
Timer::Connection &_timer;
public:
System_control() :
Attached_mmio(Board_base::MMIO_1_BASE, 0xB80)
System_control(Genode::Env &env, Timer::Connection &timer) :
Attached_mmio(env, Board_base::MMIO_1_BASE, 0xB80),
_timer(timer)
{
Lock_guard lock(*this);
@ -143,8 +147,7 @@ class System_control : private Genode::Attached_mmio
write<Gem0_clk_ctrl>(clk);
write<Gem0_rclk_ctrl>(rclk);
static Timer::Connection timer;
timer.msleep(100);
_timer.msleep(100);
}
};

View File

@ -37,9 +37,11 @@ class Tx_buffer_descriptor : public Buffer_descriptor
class Package_send_timeout : public Genode::Exception {};
Timer::Connection &_timer;
public:
Tx_buffer_descriptor() : Buffer_descriptor(BUFFER_COUNT)
Tx_buffer_descriptor(Genode::Env &env, Timer::Connection &timer)
: Buffer_descriptor(env, BUFFER_COUNT), _timer(timer)
{
for (unsigned int i=0; i<BUFFER_COUNT; i++) {
_descriptors[i].status = Status::Used::bits(1) | Status::Last_buffer::bits(1);
@ -63,8 +65,7 @@ class Tx_buffer_descriptor : public Buffer_descriptor
}
timeout--;
static Timer::Connection timer;
timer.msleep(1);
_timer.msleep(1);
}

View File

@ -303,8 +303,7 @@ class Lan9118 : public Nic::Session_component
Genode::size_t const rx_buf_size,
Genode::Allocator &rx_block_md_alloc,
Genode::Env &env)
: Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc,
env.ram(), env.rm(), env.ep()),
: Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc, env),
_mmio(env, mmio_base, mmio_size),
_reg_base(_mmio.local_addr<Genode::uint32_t>()),
_timer(env),

View File

@ -24,13 +24,19 @@
*/
/* Genode */
/*
* Needs to be included first because otherwise
* util/xml_node.h will not pick up the ascii_to
* overload.
*/
#include <nic/xml_node.h>
#include <base/attached_rom_dataspace.h>
#include <base/component.h>
#include <base/heap.h>
#include <base/thread.h>
#include <base/log.h>
#include <nic/root.h>
#include <nic/xml_node.h>
#include <os/config.h>
/* Linux */
#include <errno.h>
@ -76,6 +82,8 @@ class Linux_session_component : public Nic::Session_component
}
};
Genode::Attached_rom_dataspace _config_rom;
Nic::Mac_address _mac_addr;
int _tap_fd;
Rx_signal_thread _rx_thread;
@ -104,7 +112,7 @@ class Linux_session_component : public Nic::Session_component
/* get tap device from config */
try {
Genode::Xml_node nic_node = Genode::config()->xml_node().sub_node("nic");
Genode::Xml_node nic_node = _config_rom.xml().sub_node("nic");
nic_node.attribute("tap").value(ifr.ifr_name, sizeof(ifr.ifr_name));
Genode::log("using tap device \"", Genode::Cstring(ifr.ifr_name), "\"");
} catch (...) {
@ -198,17 +206,15 @@ class Linux_session_component : public Nic::Session_component
Linux_session_component(Genode::size_t const tx_buf_size,
Genode::size_t const rx_buf_size,
Genode::Allocator &rx_block_md_alloc,
Genode::Ram_session &ram_session,
Genode::Region_map &region_map,
Server::Entrypoint &ep)
Server::Env &env)
:
Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc,
ram_session, region_map, ep),
Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc, env),
_config_rom(env, "config"),
_tap_fd(_setup_tap_fd()), _rx_thread(_tap_fd, _packet_stream_dispatcher)
{
/* try using configured MAC address */
try {
Genode::Xml_node nic_config = Genode::config()->xml_node().sub_node("nic");
Genode::Xml_node nic_config = _config_rom.xml().sub_node("nic");
nic_config.attribute("mac").value(&_mac_addr);
Genode::log("Using configured MAC address ", _mac_addr);
} catch (...) {

View File

@ -6,7 +6,7 @@
*/
/*
* Copyright (C) 2013 Genode Labs GmbH
* Copyright (C) 2013-2017 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.

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2013 Genode Labs GmbH
* Copyright (C) 2013-2017 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.

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2013 Genode Labs GmbH
* Copyright (C) 2013-2017 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.

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2013 Genode Labs GmbH
* Copyright (C) 2013-2017 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.

View File

@ -6,7 +6,7 @@
*/
/*
* Copyright (C) 2013 Genode Labs GmbH
* Copyright (C) 2013-2017 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.

View File

@ -7,7 +7,7 @@
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
* Copyright (C) 2015-2017 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.

View File

@ -7,7 +7,7 @@
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
* Copyright (C) 2015-2017 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.

View File

@ -7,7 +7,7 @@
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
* Copyright (C) 2015-2017 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.

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2013 Genode Labs GmbH
* Copyright (C) 2013-2017 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.

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (C) 2013 Genode Labs GmbH
* Copyright (C) 2013-2017 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.

View File

@ -48,12 +48,10 @@ class Nic_loopback::Session_component : public Nic::Session_component
Session_component(size_t const tx_buf_size,
size_t const rx_buf_size,
Allocator &rx_block_md_alloc,
Ram_session &ram_session,
Region_map &region_map,
Entrypoint &ep)
Env &env)
:
Nic::Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc,
ram_session, region_map, ep)
env)
{ }
Nic::Mac_address mac_address() override
@ -145,9 +143,7 @@ class Nic_loopback::Root : public Root_component<Session_component>
{
private:
Entrypoint &_ep;
Ram_session &_ram;
Region_map &_rm;
Env &_env;
protected:
@ -174,18 +170,16 @@ class Nic_loopback::Root : public Root_component<Session_component>
}
return new (md_alloc()) Session_component(tx_buf_size, rx_buf_size,
*md_alloc(), _ram, _rm, _ep);
*md_alloc(), _env);
}
public:
Root(Entrypoint &ep,
Ram_session &ram,
Region_map &rm,
Allocator &md_alloc)
Root(Env &env,
Allocator &md_alloc)
:
Root_component<Session_component>(&ep.rpc_ep(), &md_alloc),
_ep(ep), _ram(ram), _rm(rm)
Root_component<Session_component>(&env.ep().rpc_ep(), &md_alloc),
_env(env)
{ }
};
@ -196,7 +190,7 @@ struct Nic_loopback::Main
Heap _heap { _env.ram(), _env.rm() };
Nic_loopback::Root _root { _env.ep(), _env.ram(), _env.rm(), _heap };
Nic_loopback::Root _root { _env, _heap };
Main(Env &env) : _env(env)
{

View File

@ -133,11 +133,8 @@ class Openvpn_component : public Tuntap_device,
Openvpn_component(Genode::size_t const tx_buf_size,
Genode::size_t const rx_buf_size,
Genode::Allocator &rx_block_md_alloc,
Genode::Ram_session &ram_session,
Genode::Region_map &region_map,
Genode::Entrypoint &ep)
: Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc,
ram_session, region_map, ep)
Genode::Env &env)
: Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc, env)
{
char buf[] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x01 };
_mac_addr = Nic::Mac_address((void*)buf);
@ -236,10 +233,9 @@ class Root : public Genode::Root_component<Openvpn_component, Genode::Single_cli
}
Openvpn_component *component = new (Root::md_alloc())
Openvpn_component(tx_buf_size, rx_buf_size,
_heap,
_env.ram(), _env.rm(),
_env.ep());
Openvpn_component(tx_buf_size,
rx_buf_size,
_heap, _env);
/**
* Setting the pointer in this manner is quite hackish but it has
* to be valid before OpenVPN calls open_tun(), which unfortunatly

View File

@ -14,9 +14,7 @@
/* Genode includes */
#include <base/log.h>
#include <base/snprintf.h>
#include <cap_session/connection.h>
#include <nic_session/rpc_object.h>
#include <os/server.h>
#include <root/component.h>
#include <util/string.h>