mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
lxip/libc_lxip: adjust to new Genode API
This commit is contained in:
parent
93d8b4487f
commit
6f5c839df7
@ -39,7 +39,7 @@ namespace Lxip {
|
||||
*
|
||||
* \return Reference to Socketcall object
|
||||
*/
|
||||
Socketcall & init(char const *address_config);
|
||||
Socketcall & init(Genode::Env &env, char const *address_config);
|
||||
|
||||
typedef Genode::uint8_t uint8_t;
|
||||
typedef Genode::uint16_t uint16_t;
|
||||
|
@ -1,4 +1,4 @@
|
||||
SRC_CC = init.cc plugin.cc
|
||||
SRC_CC = plugin.cc
|
||||
|
||||
vpath %.cc $(REP_DIR)/src/lib/libc_lxip
|
||||
|
||||
|
@ -27,7 +27,7 @@ CC_CXX_OPT = -fpermissive
|
||||
SRC_CC = dummies.cc lxcc_emul.cc nic_handler.cc socket_handler.cc \
|
||||
timer_handler.cc random.cc
|
||||
|
||||
SRC_CC += malloc.cc printf.cc
|
||||
SRC_CC += malloc.cc printf.cc env.cc
|
||||
|
||||
SRC_C += driver.c dummies_c.c lxc_emul.c
|
||||
|
||||
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* \brief Lxip plugin creation
|
||||
* \author Christian Helmuth
|
||||
* \author Sebastian Sumpf
|
||||
* \date 2013-09-04
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2013 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.
|
||||
*/
|
||||
|
||||
#include <base/log.h>
|
||||
#include <base/snprintf.h>
|
||||
#include <os/config.h>
|
||||
#include <util/string.h>
|
||||
|
||||
extern void create_lxip_plugin(char const *address_config);
|
||||
|
||||
void __attribute__((constructor)) init_libc_lxip(void)
|
||||
{
|
||||
char ip_addr_str[16] = {0};
|
||||
char netmask_str[16] = {0};
|
||||
char gateway_str[16] = {0};
|
||||
char address_buf[128];
|
||||
char const *address_config;
|
||||
|
||||
try {
|
||||
Genode::Xml_node libc_node = Genode::config()->xml_node().sub_node("libc");
|
||||
|
||||
try {
|
||||
libc_node.attribute("ip_addr").value(ip_addr_str, sizeof(ip_addr_str));
|
||||
} catch(...) { }
|
||||
|
||||
try {
|
||||
libc_node.attribute("netmask").value(netmask_str, sizeof(netmask_str));
|
||||
} catch(...) { }
|
||||
|
||||
try {
|
||||
libc_node.attribute("gateway").value(gateway_str, sizeof(gateway_str));
|
||||
} catch(...) { }
|
||||
|
||||
/* either none or all 3 interface attributes must exist */
|
||||
if ((Genode::strlen(ip_addr_str) != 0) ||
|
||||
(Genode::strlen(netmask_str) != 0) ||
|
||||
(Genode::strlen(gateway_str) != 0)) {
|
||||
if (Genode::strlen(ip_addr_str) == 0) {
|
||||
Genode::error("missing \"ip_addr\" attribute. Ignoring network interface config.");
|
||||
throw Genode::Xml_node::Nonexistent_attribute();
|
||||
} else if (Genode::strlen(netmask_str) == 0) {
|
||||
Genode::error("missing \"netmask\" attribute. Ignoring network interface config.");
|
||||
throw Genode::Xml_node::Nonexistent_attribute();
|
||||
} else if (Genode::strlen(gateway_str) == 0) {
|
||||
Genode::error("missing \"gateway\" attribute. Ignoring network interface config.");
|
||||
throw Genode::Xml_node::Nonexistent_attribute();
|
||||
}
|
||||
} else
|
||||
throw -1;
|
||||
|
||||
Genode::log("static network interface: ",
|
||||
"ip_addr=", Genode::Cstring(ip_addr_str), " "
|
||||
"netmask=", Genode::Cstring(netmask_str), " "
|
||||
"gateway=", Genode::Cstring(gateway_str));
|
||||
|
||||
Genode::snprintf(address_buf, sizeof(address_buf), "%s::%s:%s:::off",
|
||||
ip_addr_str, gateway_str, netmask_str);
|
||||
address_config = address_buf;
|
||||
}
|
||||
catch (...) {
|
||||
Genode::log("Using DHCP for interface configuration.");
|
||||
address_config = "dhcp";
|
||||
}
|
||||
|
||||
Genode::log("init_libc_lxip() address config=", address_config);
|
||||
|
||||
create_lxip_plugin(address_config);
|
||||
}
|
@ -19,7 +19,9 @@
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <base/env.h>
|
||||
#include <base/heap.h>
|
||||
#include <base/log.h>
|
||||
|
||||
/* Libc plugin includes */
|
||||
@ -76,12 +78,34 @@ struct Plugin : Libc::Plugin
|
||||
/**
|
||||
* Interface to LXIP stack
|
||||
*/
|
||||
struct Lxip::Socketcall &socketcall;
|
||||
struct Socketcall
|
||||
{
|
||||
Genode::Heap heap;
|
||||
Lxip::Socketcall &socketcall;
|
||||
|
||||
Socketcall(Genode::Env &env, char const *address_config)
|
||||
: heap(env.ram(), env.rm()), socketcall(Lxip::init(env, address_config))
|
||||
{ }
|
||||
};
|
||||
|
||||
Genode::Constructible<Socketcall> socketconstruct;
|
||||
|
||||
Lxip::Socketcall &socketcall()
|
||||
{
|
||||
return socketconstruct->socketcall;
|
||||
}
|
||||
|
||||
Genode::Heap &heap()
|
||||
{
|
||||
return socketconstruct->heap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Plugin(char const *address_config);
|
||||
Plugin();
|
||||
|
||||
void init(Genode::Env &env) override;
|
||||
|
||||
bool supports_select(int nfds,
|
||||
fd_set *readfds,
|
||||
@ -138,12 +162,72 @@ struct Plugin : Libc::Plugin
|
||||
};
|
||||
|
||||
|
||||
Plugin::Plugin(char const *address_config) : socketcall(Lxip::init(address_config))
|
||||
Plugin::Plugin()
|
||||
{
|
||||
Genode::log("using the lxip libc plugin");
|
||||
}
|
||||
|
||||
|
||||
void Plugin::init(Genode::Env &env)
|
||||
{
|
||||
char ip_addr_str[16] = {0};
|
||||
char netmask_str[16] = {0};
|
||||
char gateway_str[16] = {0};
|
||||
char address_buf[128];
|
||||
char const *address_config;
|
||||
|
||||
Genode::Attached_rom_dataspace config { env, "config"} ;
|
||||
|
||||
try {
|
||||
Genode::Xml_node libc_node = config.xml().sub_node("libc");
|
||||
|
||||
try {
|
||||
libc_node.attribute("ip_addr").value(ip_addr_str, sizeof(ip_addr_str));
|
||||
} catch(...) { }
|
||||
|
||||
try {
|
||||
libc_node.attribute("netmask").value(netmask_str, sizeof(netmask_str));
|
||||
} catch(...) { }
|
||||
|
||||
try {
|
||||
libc_node.attribute("gateway").value(gateway_str, sizeof(gateway_str));
|
||||
} catch(...) { }
|
||||
|
||||
/* either none or all 3 interface attributes must exist */
|
||||
if ((Genode::strlen(ip_addr_str) != 0) ||
|
||||
(Genode::strlen(netmask_str) != 0) ||
|
||||
(Genode::strlen(gateway_str) != 0)) {
|
||||
if (Genode::strlen(ip_addr_str) == 0) {
|
||||
Genode::error("missing \"ip_addr\" attribute. Ignoring network interface config.");
|
||||
throw Genode::Xml_node::Nonexistent_attribute();
|
||||
} else if (Genode::strlen(netmask_str) == 0) {
|
||||
Genode::error("missing \"netmask\" attribute. Ignoring network interface config.");
|
||||
throw Genode::Xml_node::Nonexistent_attribute();
|
||||
} else if (Genode::strlen(gateway_str) == 0) {
|
||||
Genode::error("missing \"gateway\" attribute. Ignoring network interface config.");
|
||||
throw Genode::Xml_node::Nonexistent_attribute();
|
||||
}
|
||||
} else
|
||||
throw -1;
|
||||
|
||||
Genode::log("static network interface: ",
|
||||
"ip_addr=", Genode::Cstring(ip_addr_str), " "
|
||||
"netmask=", Genode::Cstring(netmask_str), " "
|
||||
"gateway=", Genode::Cstring(gateway_str));
|
||||
|
||||
Genode::snprintf(address_buf, sizeof(address_buf), "%s::%s:%s:::off",
|
||||
ip_addr_str, gateway_str, netmask_str);
|
||||
address_config = address_buf;
|
||||
}
|
||||
catch (...) {
|
||||
Genode::log("Using DHCP for interface configuration.");
|
||||
address_config = "dhcp";
|
||||
}
|
||||
|
||||
Genode::log("Plugin::init() address config=", address_config);
|
||||
socketconstruct.construct(env, address_config);
|
||||
};
|
||||
|
||||
/* TODO shameful copied from lwip... generalize this */
|
||||
bool Plugin::supports_select(int nfds,
|
||||
fd_set *readfds,
|
||||
@ -184,7 +268,7 @@ Libc::File_descriptor *Plugin::accept(Libc::File_descriptor *sockfdo,
|
||||
{
|
||||
Lxip::Handle handle;
|
||||
|
||||
handle = socketcall.accept(context(sockfdo)->handle(), (void *)addr, addrlen);
|
||||
handle = socketcall().accept(context(sockfdo)->handle(), (void *)addr, addrlen);
|
||||
if (!handle.socket)
|
||||
return 0;
|
||||
|
||||
@ -193,7 +277,7 @@ Libc::File_descriptor *Plugin::accept(Libc::File_descriptor *sockfdo,
|
||||
addr->sa_len = *addrlen;
|
||||
}
|
||||
|
||||
Plugin_context *context = new (Genode::env()->heap()) Plugin_context(handle);
|
||||
Plugin_context *context = new (heap()) Plugin_context(handle);
|
||||
Libc::File_descriptor *fd = Libc::file_descriptor_allocator()->alloc(this, context);
|
||||
return fd;
|
||||
}
|
||||
@ -209,7 +293,7 @@ int Plugin::bind(Libc::File_descriptor *sockfdo, const struct sockaddr *addr,
|
||||
return -1;
|
||||
}
|
||||
|
||||
errno = -socketcall.bind(context(sockfdo)->handle(), family, (void*)addr);
|
||||
errno = -socketcall().bind(context(sockfdo)->handle(), family, (void*)addr);
|
||||
|
||||
return errno > 0 ? -1 : 0;
|
||||
}
|
||||
@ -217,10 +301,10 @@ int Plugin::bind(Libc::File_descriptor *sockfdo, const struct sockaddr *addr,
|
||||
|
||||
int Plugin::close(Libc::File_descriptor *sockfdo)
|
||||
{
|
||||
socketcall.close(context(sockfdo)->handle());
|
||||
socketcall().close(context(sockfdo)->handle());
|
||||
|
||||
if (context(sockfdo))
|
||||
Genode::destroy(Genode::env()->heap(), context(sockfdo));
|
||||
Genode::destroy(heap(), context(sockfdo));
|
||||
|
||||
Libc::file_descriptor_allocator()->free(sockfdo);
|
||||
|
||||
@ -239,7 +323,7 @@ int Plugin::connect(Libc::File_descriptor *sockfdo,
|
||||
return -1;
|
||||
}
|
||||
|
||||
errno = -socketcall.connect(context(sockfdo)->handle(), family, (void *)addr);
|
||||
errno = -socketcall().connect(context(sockfdo)->handle(), family, (void *)addr);
|
||||
return errno > 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
@ -277,7 +361,7 @@ int Plugin::getpeername(Libc::File_descriptor *sockfdo,
|
||||
return -1;
|
||||
}
|
||||
|
||||
errno = -socketcall.getpeername(context(sockfdo)->handle(), (void *)addr, addrlen);
|
||||
errno = -socketcall().getpeername(context(sockfdo)->handle(), (void *)addr, addrlen);
|
||||
|
||||
addr->sa_family = bsd_family(addr);
|
||||
addr->sa_len = *addrlen;
|
||||
@ -295,7 +379,7 @@ int Plugin::getsockname(Libc::File_descriptor *sockfdo,
|
||||
return -1;
|
||||
}
|
||||
|
||||
errno = -socketcall.getsockname(context(sockfdo)->handle(), (void *)addr, addrlen);
|
||||
errno = -socketcall().getsockname(context(sockfdo)->handle(), (void *)addr, addrlen);
|
||||
|
||||
addr->sa_family = bsd_family(addr);
|
||||
addr->sa_len = *addrlen;
|
||||
@ -319,7 +403,7 @@ int Plugin::getsockopt(Libc::File_descriptor *sockfdo, int level,
|
||||
return -1;
|
||||
}
|
||||
|
||||
return socketcall.getsockopt(context(sockfdo)->handle(), Lxip::LINUX_SOL_SOCKET,
|
||||
return socketcall().getsockopt(context(sockfdo)->handle(), Lxip::LINUX_SOL_SOCKET,
|
||||
optname, optval, (int *)optlen);
|
||||
}
|
||||
|
||||
@ -335,7 +419,7 @@ int Plugin::ioctl(Libc::File_descriptor *sockfdo, int request, char *argp)
|
||||
|
||||
case FIONREAD:
|
||||
|
||||
errno = -socketcall.ioctl(context(sockfdo)->handle(), Lxip::LINUX_FIONREAD,
|
||||
errno = -socketcall().ioctl(context(sockfdo)->handle(), Lxip::LINUX_FIONREAD,
|
||||
argp);
|
||||
return errno > 0 ? -1 : 0;
|
||||
|
||||
@ -350,14 +434,14 @@ int Plugin::ioctl(Libc::File_descriptor *sockfdo, int request, char *argp)
|
||||
|
||||
int Plugin::listen(Libc::File_descriptor *sockfdo, int backlog)
|
||||
{
|
||||
errno = -socketcall.listen(context(sockfdo)->handle(), backlog);
|
||||
errno = -socketcall().listen(context(sockfdo)->handle(), backlog);
|
||||
return errno > 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
|
||||
int Plugin::shutdown(Libc::File_descriptor *sockfdo, int how)
|
||||
{
|
||||
errno = -socketcall.shutdown(context(sockfdo)->handle(), how);
|
||||
errno = -socketcall().shutdown(context(sockfdo)->handle(), how);
|
||||
return errno > 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
@ -405,7 +489,7 @@ int Plugin::select(int nfds,
|
||||
continue;
|
||||
|
||||
/* call IP stack blocking/non-blocking */
|
||||
int mask = socketcall.poll(context(sockfdo)->handle(), block);
|
||||
int mask = socketcall().poll(context(sockfdo)->handle(), block);
|
||||
|
||||
if (mask)
|
||||
block = false;
|
||||
@ -448,7 +532,7 @@ ssize_t Plugin::recvfrom(Libc::File_descriptor *sockfdo, void *buf, ::size_t len
|
||||
return -1;
|
||||
}
|
||||
|
||||
int recv = socketcall.recv(context(sockfdo)->handle(), buf, len, translate_msg_flags(flags),
|
||||
int recv = socketcall().recv(context(sockfdo)->handle(), buf, len, translate_msg_flags(flags),
|
||||
family, (void *)src_addr, addrlen);
|
||||
|
||||
if (recv < 0) {
|
||||
@ -482,7 +566,7 @@ ssize_t Plugin::sendto(Libc::File_descriptor *sockfdo, const void *buf,
|
||||
return -1;
|
||||
}
|
||||
|
||||
int send = socketcall.send(context(sockfdo)->handle(), buf, len, translate_msg_flags(flags),
|
||||
int send = socketcall().send(context(sockfdo)->handle(), buf, len, translate_msg_flags(flags),
|
||||
family, (void *)dest_addr);
|
||||
if (send < 0)
|
||||
errno = -send;
|
||||
@ -507,7 +591,7 @@ int Plugin::setsockopt(Libc::File_descriptor *sockfdo, int level,
|
||||
return -1;
|
||||
}
|
||||
|
||||
return socketcall.setsockopt(context(sockfdo)->handle(), Lxip::LINUX_SOL_SOCKET,
|
||||
return socketcall().setsockopt(context(sockfdo)->handle(), Lxip::LINUX_SOL_SOCKET,
|
||||
optname, optval, optlen);
|
||||
}
|
||||
|
||||
@ -515,14 +599,14 @@ int Plugin::setsockopt(Libc::File_descriptor *sockfdo, int level,
|
||||
Libc::File_descriptor *Plugin::socket(int domain, int type, int protocol)
|
||||
{
|
||||
using namespace Lxip;
|
||||
Handle handle = socketcall.socket(type == SOCK_STREAM ? TYPE_STREAM : TYPE_DGRAM);
|
||||
Handle handle = socketcall().socket(type == SOCK_STREAM ? TYPE_STREAM : TYPE_DGRAM);
|
||||
|
||||
if (!handle.socket) {
|
||||
errno = EBADF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Plugin_context *context = new (Genode::env()->heap()) Plugin_context(handle);
|
||||
Plugin_context *context = new (heap()) Plugin_context(handle);
|
||||
Libc::File_descriptor *fd = Libc::file_descriptor_allocator()->alloc(this, context);
|
||||
return fd;
|
||||
}
|
||||
@ -647,7 +731,7 @@ int Plugin::translate_ops_linux(int optname)
|
||||
} /* unnamed namespace */
|
||||
|
||||
|
||||
void create_lxip_plugin(char const *address_config)
|
||||
void __attribute__((constructor)) init_lxip_plugin()
|
||||
{
|
||||
static Plugin lxip_plugin(address_config);
|
||||
static Plugin lxip_plugin;
|
||||
}
|
||||
|
@ -17,19 +17,30 @@
|
||||
|
||||
#include <base/signal.h>
|
||||
|
||||
namespace Lx_kit { class Env; }
|
||||
|
||||
namespace Lx {
|
||||
|
||||
void nic_client_init(Genode::Env &env,
|
||||
Genode::Entrypoint &ep,
|
||||
Genode::Allocator &alloc,
|
||||
void (*ticker)());
|
||||
|
||||
void timer_init(Genode::Env &env,
|
||||
Genode::Entrypoint &ep,
|
||||
Genode::Allocator &alloc,
|
||||
void (*ticker)());
|
||||
void event_init(Genode::Env &env, void (*ticker)());
|
||||
|
||||
void event_init(Genode::Env &env,
|
||||
Genode::Entrypoint &ep,
|
||||
void (*ticker)());
|
||||
|
||||
void timer_update_jiffies();
|
||||
|
||||
void lxcc_emul_init(Lx_kit::Env &env);
|
||||
}
|
||||
|
||||
extern "C" int lxip_init(char const *address_config);
|
||||
|
||||
|
||||
#endif /* _LX_H_ */
|
||||
|
@ -28,19 +28,28 @@
|
||||
#include <lx.h>
|
||||
|
||||
|
||||
/* Lx_kit */
|
||||
#include <lx_kit/env.h>
|
||||
|
||||
/*********************************
|
||||
** Lx::Backend_alloc interface **
|
||||
*********************************/
|
||||
|
||||
#include <lx_kit/backend_alloc.h>
|
||||
|
||||
static Lx_kit::Env *lx_env;
|
||||
|
||||
void Lx::lxcc_emul_init(Lx_kit::Env &env)
|
||||
{
|
||||
lx_env = &env;
|
||||
}
|
||||
|
||||
struct Memory_object_base : Genode::Object_pool<Memory_object_base>::Entry
|
||||
{
|
||||
Memory_object_base(Genode::Ram_dataspace_capability cap)
|
||||
: Genode::Object_pool<Memory_object_base>::Entry(cap) {}
|
||||
|
||||
void free() { Genode::env()->ram_session()->free(ram_cap()); }
|
||||
void free() { lx_env->ram().free(ram_cap()); }
|
||||
|
||||
Genode::Ram_dataspace_capability ram_cap()
|
||||
{
|
||||
@ -58,8 +67,8 @@ Lx::backend_alloc(Genode::addr_t size, Genode::Cache_attribute cached)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
Genode::Ram_dataspace_capability cap = env()->ram_session()->alloc(size);
|
||||
Memory_object_base *o = new (env()->heap()) Memory_object_base(cap);
|
||||
Genode::Ram_dataspace_capability cap = lx_env->ram().alloc(size);
|
||||
Memory_object_base *o = new (lx_env->heap()) Memory_object_base(cap);
|
||||
|
||||
memory_pool.insert(o);
|
||||
return cap;
|
||||
@ -79,7 +88,7 @@ void Lx::backend_free(Genode::Ram_dataspace_capability cap)
|
||||
|
||||
object = o; /* save for destroy */
|
||||
});
|
||||
destroy(env()->heap(), object);
|
||||
destroy(lx_env->heap(), object);
|
||||
}
|
||||
|
||||
|
||||
@ -104,7 +113,8 @@ void *alloc_large_system_hash(const char *tablename,
|
||||
unsigned long nlog2 = ilog2(elements);
|
||||
nlog2 <<= (1 << nlog2) < elements ? 1 : 0;
|
||||
|
||||
void *table = Genode::env()->heap()->alloc(elements * bucketsize);
|
||||
void *table;
|
||||
lx_env->heap().alloc(elements * bucketsize, &table);
|
||||
|
||||
if (_hash_mask)
|
||||
*_hash_mask = (1 << nlog2) - 1;
|
||||
@ -311,10 +321,10 @@ struct Timeout : Genode::Signal_handler<Timeout>
|
||||
tick();
|
||||
}
|
||||
|
||||
Timeout(Genode::Env &env, void (*ticker)())
|
||||
Timeout(Genode::Env &env, Genode::Entrypoint &ep, void (*ticker)())
|
||||
:
|
||||
Signal_handler<Timeout>(env.ep(), *this, &Timeout::handle),
|
||||
ep(env.ep()), timer(env), tick(ticker)
|
||||
Signal_handler<Timeout>(ep, *this, &Timeout::handle),
|
||||
ep(ep), timer(env), tick(ticker)
|
||||
{
|
||||
timer.sigh(*this);
|
||||
}
|
||||
@ -336,9 +346,9 @@ struct Timeout : Genode::Signal_handler<Timeout>
|
||||
static Timeout *_timeout;
|
||||
static Genode::Signal_context_capability tick_sig_cap;
|
||||
|
||||
void Lx::event_init(Genode::Env &env, void (*ticker)())
|
||||
void Lx::event_init(Genode::Env &env, Genode::Entrypoint &ep, void (*ticker)())
|
||||
{
|
||||
static Timeout handler(env, ticker);
|
||||
static Timeout handler(env, ep, ticker);
|
||||
_timeout = &handler;
|
||||
}
|
||||
|
||||
@ -438,7 +448,7 @@ struct page *alloc_pages(gfp_t gfp_mask, unsigned int order)
|
||||
{
|
||||
Avl_page *p;
|
||||
try {
|
||||
p = (Avl_page *)new (Genode::env()->heap()) Avl_page(PAGE_SIZE << order);
|
||||
p = (Avl_page *)new (lx_env->heap()) Avl_page(PAGE_SIZE << order);
|
||||
tree.insert(p);
|
||||
} catch (...) { return 0; }
|
||||
|
||||
@ -461,7 +471,7 @@ void __free_page_frag(void *addr)
|
||||
Avl_page *p = tree.first()->find_by_address((Genode::addr_t)addr);
|
||||
|
||||
tree.remove(p);
|
||||
destroy(Genode::env()->heap(), p);
|
||||
destroy(lx_env->heap(), p);
|
||||
}
|
||||
|
||||
|
||||
@ -487,7 +497,7 @@ void put_page(struct page *page)
|
||||
Avl_page *p = tree.first()->find_by_address((Genode::addr_t)page->addr);
|
||||
|
||||
tree.remove(p);
|
||||
destroy(Genode::env()->heap(), p);
|
||||
destroy(lx_env->heap(), p);
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,14 +89,15 @@ class Nic_client
|
||||
public:
|
||||
|
||||
Nic_client(Genode::Env &env,
|
||||
Genode::Entrypoint &ep,
|
||||
Genode::Allocator &alloc,
|
||||
void (*ticker)())
|
||||
:
|
||||
_tx_block_alloc(&alloc),
|
||||
_nic(env, &_tx_block_alloc, BUF_SIZE, BUF_SIZE),
|
||||
_sink_ack(env.ep(), *this, &Nic_client::_packet_avail),
|
||||
_sink_submit(env.ep(), *this, &Nic_client::_ready_to_ack),
|
||||
_source_ack(env.ep(), *this, &Nic_client::_ack_avail),
|
||||
_sink_ack(ep, *this, &Nic_client::_packet_avail),
|
||||
_sink_submit(ep, *this, &Nic_client::_ready_to_ack),
|
||||
_source_ack(ep, *this, &Nic_client::_ack_avail),
|
||||
_tick(ticker)
|
||||
{
|
||||
_nic.rx_channel()->sigh_ready_to_ack(_sink_ack);
|
||||
@ -113,10 +114,11 @@ static Nic_client *_nic_client;
|
||||
|
||||
|
||||
void Lx::nic_client_init(Genode::Env &env,
|
||||
Genode::Allocator &alloc,
|
||||
void (*ticker)())
|
||||
Genode::Entrypoint &ep,
|
||||
Genode::Allocator &alloc,
|
||||
void (*ticker)())
|
||||
{
|
||||
static Nic_client _inst(env, alloc, ticker);
|
||||
static Nic_client _inst(env, ep, alloc, ticker);
|
||||
_nic_client = &_inst;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <lx.h>
|
||||
#include <nic.h>
|
||||
|
||||
/* Lx_kit */
|
||||
#include <lx_kit/env.h>
|
||||
|
||||
static const bool verbose = false;
|
||||
|
||||
@ -111,10 +113,8 @@ namespace Net
|
||||
};
|
||||
|
||||
|
||||
class Net::Socketcall : public Genode::Signal_dispatcher_base,
|
||||
public Genode::Signal_context_capability,
|
||||
public Lxip::Socketcall,
|
||||
public Genode::Thread_deprecated<64 * 1024 * sizeof(Genode::addr_t)>
|
||||
class Net::Socketcall : public Lxip::Socketcall,
|
||||
public Genode::Entrypoint
|
||||
{
|
||||
private:
|
||||
|
||||
@ -122,13 +122,12 @@ class Net::Socketcall : public Genode::Signal_dispatcher_base,
|
||||
Result _result;
|
||||
Lxip::Handle _handle;
|
||||
|
||||
Genode::Signal_receiver &_sig_rec;
|
||||
Genode::Signal_transmitter _signal;
|
||||
Genode::Semaphore _block;
|
||||
Genode::Semaphore _block;
|
||||
Genode::Signal_handler<Socketcall> _dispatcher { *this, *this, &Socketcall::_dispatch };
|
||||
|
||||
void _submit_and_block()
|
||||
{
|
||||
_signal.submit(); /* global submit */
|
||||
Genode::Signal_transmitter(_dispatcher).submit();
|
||||
_block.down();
|
||||
}
|
||||
|
||||
@ -388,32 +387,11 @@ class Net::Socketcall : public Genode::Signal_dispatcher_base,
|
||||
_handle.socket = static_cast<void *>(s);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Socketcall(Genode::Signal_receiver &sig_rec)
|
||||
:
|
||||
Thread_deprecated("socketcall"),
|
||||
_sig_rec(sig_rec),
|
||||
_signal(Genode::Signal_context_capability(_sig_rec.manage(this)))
|
||||
{
|
||||
start();
|
||||
}
|
||||
|
||||
~Socketcall() { _sig_rec.dissolve(this); }
|
||||
|
||||
void entry()
|
||||
{
|
||||
while (true) {
|
||||
Genode::Signal s = _sig_rec.wait_for_signal();
|
||||
static_cast<Genode::Signal_dispatcher_base *>(s.context())->dispatch(s.num());
|
||||
}
|
||||
}
|
||||
|
||||
/***********************
|
||||
** Signal dispatcher **
|
||||
***********************/
|
||||
|
||||
void dispatch(unsigned num)
|
||||
void _dispatch()
|
||||
{
|
||||
switch (_call.opcode) {
|
||||
|
||||
@ -441,6 +419,12 @@ class Net::Socketcall : public Genode::Signal_dispatcher_base,
|
||||
_unblock();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Socketcall(Genode::Env &env)
|
||||
:
|
||||
Entrypoint(env, 64 * 1024 * sizeof(long), "socketcall")
|
||||
{ }
|
||||
|
||||
/**************************
|
||||
** Socketcall interface **
|
||||
@ -631,17 +615,20 @@ class Net::Socketcall : public Genode::Signal_dispatcher_base,
|
||||
}
|
||||
};
|
||||
|
||||
static void ticker() { }
|
||||
|
||||
Lxip::Socketcall & Lxip::init(char const *address_config)
|
||||
Lxip::Socketcall & Lxip::init(Genode::Env &env, char const *address_config)
|
||||
{
|
||||
static Genode::Signal_receiver sig_rec;
|
||||
Lx_kit::Env &lx_env = Lx_kit::construct_env(env);
|
||||
|
||||
Lx::timer_init(sig_rec);
|
||||
Lx::event_init(sig_rec);
|
||||
Lx::nic_client_init(sig_rec);
|
||||
static Net::Socketcall socketcall(env);
|
||||
|
||||
static int init = lxip_init(address_config);
|
||||
static Net::Socketcall socketcall(sig_rec);
|
||||
Lx::timer_init(env, socketcall, lx_env.heap(), ticker);
|
||||
Lx::event_init(env, socketcall, ticker);
|
||||
Lx::nic_client_init(env, socketcall, lx_env.heap(), ticker);
|
||||
Lx::lxcc_emul_init(lx_env);
|
||||
|
||||
lxip_init(address_config);
|
||||
|
||||
return socketcall;
|
||||
}
|
||||
|
@ -192,10 +192,11 @@ class Lx::Timer
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Timer(Genode::Env &env, Genode::Allocator &alloc, void (*tick)())
|
||||
Timer(Genode::Env &env, Genode::Entrypoint &ep, Genode::Allocator &alloc,
|
||||
void (*tick)())
|
||||
:
|
||||
_timer_conn(env),
|
||||
_handler(env.ep(), *this, &Lx::Timer::_handle),
|
||||
_handler(ep, *this, &Lx::Timer::_handle),
|
||||
_timer_alloc(&alloc),
|
||||
_tick(tick)
|
||||
{
|
||||
@ -296,9 +297,10 @@ class Lx::Timer
|
||||
static Lx::Timer *_timer;
|
||||
|
||||
|
||||
void Lx::timer_init(Genode::Env &env, Genode::Allocator &alloc, void (*tick)())
|
||||
void Lx::timer_init(Genode::Env &env, Genode::Entrypoint &ep,
|
||||
Genode::Allocator &alloc, void (*tick)())
|
||||
{
|
||||
static Lx::Timer inst(env, alloc, tick);
|
||||
static Lx::Timer inst(env, ep, alloc, tick);
|
||||
_timer = &inst;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user