Use new lwIP netif facility for tftp_rom
LwIP can be used without libc or its plugin libraries. Fix #36
This commit is contained in:
committed by
Norman Feske
parent
2a45dc173f
commit
6dbbba4603
@@ -39,6 +39,7 @@ append config {
|
|||||||
<service name="ROM"/>
|
<service name="ROM"/>
|
||||||
<service name="SIGNAL"/>
|
<service name="SIGNAL"/>
|
||||||
</parent-provides>
|
</parent-provides>
|
||||||
|
<default caps="256"/>
|
||||||
<default-route>
|
<default-route>
|
||||||
<any-service> <parent/> <any-child/> </any-service>
|
<any-service> <parent/> <any-child/> </any-service>
|
||||||
</default-route>}
|
</default-route>}
|
||||||
@@ -57,18 +58,21 @@ append config {
|
|||||||
<start name="tftp_rom">
|
<start name="tftp_rom">
|
||||||
<resource name="RAM" quantum="32M"/>
|
<resource name="RAM" quantum="32M"/>
|
||||||
<provides> <service name="ROM"/> </provides>
|
<provides> <service name="ROM"/> </provides>
|
||||||
<config verbose="yes">
|
<config verbose="yes" dhcp="yes">
|
||||||
<libc stdout="/log" stderr="/log">
|
<libc stdout="/log" stderr="/log">
|
||||||
<vfs> <log/> </vfs>
|
<vfs> <log/> </vfs>
|
||||||
</libc>
|
</libc>
|
||||||
<policy label_prefix="init" ip="10.0.2.2" port="69"
|
<default-policy label_prefix="init" ip="10.0.2.2" port="69"
|
||||||
dir="/genode" timeout="10"/>
|
dir="/genode" timeout="10"/>
|
||||||
</config>
|
</config>
|
||||||
</start>
|
</start>
|
||||||
<start name="init">
|
<start name="init">
|
||||||
<exit propagate="yes"/>
|
|
||||||
<resource name="RAM" quantum="6M"/>
|
<resource name="RAM" quantum="6M"/>
|
||||||
<route>
|
<route>
|
||||||
|
<service name="ROM" unscoped_label="ld.lib.so">
|
||||||
|
<parent/> </service>
|
||||||
|
<service name="ROM" label_suffix="ld.lib.so">
|
||||||
|
<parent/> </service>
|
||||||
<any-service>
|
<any-service>
|
||||||
<child name="tftp_rom"/>
|
<child name="tftp_rom"/>
|
||||||
<parent/>
|
<parent/>
|
||||||
@@ -88,6 +92,7 @@ append config {
|
|||||||
<default-route>
|
<default-route>
|
||||||
<any-service> <parent/> </any-service>
|
<any-service> <parent/> </any-service>
|
||||||
</default-route>
|
</default-route>
|
||||||
|
<default caps="256"/>
|
||||||
<start name="test-libc">
|
<start name="test-libc">
|
||||||
<resource name="RAM" quantum="4M"/>
|
<resource name="RAM" quantum="4M"/>
|
||||||
<config>
|
<config>
|
||||||
|
|||||||
@@ -21,17 +21,18 @@
|
|||||||
#include <base/attached_rom_dataspace.h>
|
#include <base/attached_rom_dataspace.h>
|
||||||
#include <base/heap.h>
|
#include <base/heap.h>
|
||||||
#include <root/component.h>
|
#include <root/component.h>
|
||||||
#include <libc/component.h>
|
#include <base/component.h>
|
||||||
#include <util/list.h>
|
#include <util/list.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/endian.h>
|
#include <util/endian.h>
|
||||||
|
|
||||||
/* lwIP raw API */
|
/* LwIP includes */
|
||||||
#include <lwip/genode.h>
|
|
||||||
#include <lwip/api.h>
|
#include <lwip/api.h>
|
||||||
#include <lwip/inet.h>
|
#include <lwip/inet.h>
|
||||||
#include <lwip/udp.h>
|
#include <lwip/udp.h>
|
||||||
#include <lwip/init.h>
|
#include <lwip/init.h>
|
||||||
|
#include <lwip/genode_init.h>
|
||||||
|
#include <lwip/nic_netif.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Tftp_rom {
|
namespace Tftp_rom {
|
||||||
@@ -48,11 +49,11 @@ namespace Tftp_rom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" void rrq_cb(void *arg, udp_pcb *upcb, pbuf *pbuf,
|
extern "C" void rrq_cb(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||||
ip_addr_t *addr, Genode::uint16_t port);
|
const ip_addr_t *addr, u16_t port);
|
||||||
|
|
||||||
extern "C" void data_cb(void *arg, udp_pcb *upcb, pbuf *pbuf,
|
extern "C" void data_cb(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||||
ip_addr_t *addr, Genode::uint16_t port);
|
const ip_addr_t *addr, u16_t port);
|
||||||
|
|
||||||
|
|
||||||
class Tftp_rom::Session_component :
|
class Tftp_rom::Session_component :
|
||||||
@@ -185,7 +186,7 @@ class Tftp_rom::Session_component :
|
|||||||
udp_send(_pcb, ack);
|
udp_send(_pcb, ack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void first_response(pbuf *data, ip_addr_t *addr, uint16_t port)
|
void first_response(pbuf *data, ip_addr_t const *addr, uint16_t port)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* we now know the port the server will use,
|
* we now know the port the server will use,
|
||||||
@@ -325,8 +326,8 @@ class Tftp_rom::Session_component :
|
|||||||
********************/
|
********************/
|
||||||
|
|
||||||
|
|
||||||
extern "C" void rrq_cb(void *arg, udp_pcb *upcb, pbuf *data,
|
extern "C" void rrq_cb(void *arg, struct udp_pcb *pcb, struct pbuf *data,
|
||||||
ip_addr_t *addr, Genode::uint16_t port)
|
const ip_addr_t *addr, u16_t port)
|
||||||
{
|
{
|
||||||
Tftp_rom::Session_component *session = (Tftp_rom::Session_component*)arg;
|
Tftp_rom::Session_component *session = (Tftp_rom::Session_component*)arg;
|
||||||
|
|
||||||
@@ -347,7 +348,7 @@ extern "C" void rrq_cb(void *arg, udp_pcb *upcb, pbuf *data,
|
|||||||
|
|
||||||
|
|
||||||
extern "C" void data_cb(void *arg, udp_pcb *upcb, pbuf *data,
|
extern "C" void data_cb(void *arg, udp_pcb *upcb, pbuf *data,
|
||||||
ip_addr_t *addr, Genode::uint16_t port)
|
ip_addr_t const *addr, Genode::uint16_t port)
|
||||||
{
|
{
|
||||||
Tftp_rom::Session_component *session = (Tftp_rom::Session_component*)arg;
|
Tftp_rom::Session_component *session = (Tftp_rom::Session_component*)arg;
|
||||||
if (session->add_block(data)) return;
|
if (session->add_block(data)) return;
|
||||||
@@ -365,6 +366,11 @@ class Tftp_rom::Root : public Genode::Root_component<Session_component>
|
|||||||
Genode::Env &_env;
|
Genode::Env &_env;
|
||||||
Genode::Attached_rom_dataspace _config_rom { _env, "config" };
|
Genode::Attached_rom_dataspace _config_rom { _env, "config" };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LwIP connection to Nic service
|
||||||
|
*/
|
||||||
|
Lwip::Nic_netif _netif { _env, *md_alloc(), _config_rom.xml() };
|
||||||
|
|
||||||
class Timeout_dispatcher : Genode::Thread, Genode::Lock
|
class Timeout_dispatcher : Genode::Thread, Genode::Lock
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -456,6 +462,9 @@ class Tftp_rom::Root : public Genode::Root_component<Session_component>
|
|||||||
|
|
||||||
Session_component *_create_session(const char *args) override
|
Session_component *_create_session(const char *args) override
|
||||||
{
|
{
|
||||||
|
while (!_netif.ready())
|
||||||
|
_env.ep().wait_and_dispatch_one_io_signal();
|
||||||
|
|
||||||
Session_component *session;
|
Session_component *session;
|
||||||
|
|
||||||
_config_rom.update();
|
_config_rom.update();
|
||||||
@@ -531,9 +540,14 @@ class Tftp_rom::Root : public Genode::Root_component<Session_component>
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void Libc::Component::construct(Libc::Env &env )
|
void Component::construct(Genode::Env &env)
|
||||||
{
|
{
|
||||||
static Genode::Sliced_heap sliced_heap(env.ram(), env.rm());
|
env.exec_static_constructors();
|
||||||
static Tftp_rom::Root root(env, sliced_heap);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
static Genode::Heap heap(env.ram(), env.rm());
|
||||||
|
static Timer::Connection timer(env, "lwip");
|
||||||
|
|
||||||
|
Lwip::genode_init(heap, timer);
|
||||||
|
|
||||||
|
static Tftp_rom::Root root(env, heap);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
TARGET = tftp_rom
|
TARGET = tftp_rom
|
||||||
SRC_CC = component.cc
|
SRC_CC = component.cc
|
||||||
LIBS = base lwip libc libc_lwip libc_lwip_nic_dhcp
|
LIBS = base lwip
|
||||||
|
|
||||||
CC_CXX_WARN_STRICT =
|
CC_CXX_WARN_STRICT =
|
||||||
|
|||||||
Reference in New Issue
Block a user