usb: transition to the new base API

* remove all 'Genode::env()' calls
* use attached roms to read configuration
* use compoenent framework
* remove all PDBG, PINF, PWRN macros

Issue #1987
Fixes #2019
This commit is contained in:
Sebastian Sumpf 2016-06-21 12:59:11 +02:00 committed by Christian Helmuth
parent 58ef6e3695
commit d48219138c
25 changed files with 241 additions and 229 deletions

View File

@ -38,7 +38,7 @@ MOD_SUFFIX =
CC_OPT += -DMOD_SUFFIX=$(MOD_SUFFIX) CC_OPT += -DMOD_SUFFIX=$(MOD_SUFFIX)
# lx_kit # lx_kit
SRC_CC += printf.cc work.cc timer.cc scheduler.cc irq.cc malloc.cc SRC_CC += printf.cc work.cc timer.cc scheduler.cc irq.cc malloc.cc env.cc
# common lib # common lib
SRC_C += lib/int_sqrt.c SRC_C += lib/int_sqrt.c

View File

@ -659,11 +659,6 @@ unsigned int jiffies_to_usecs(const unsigned long j)
return -1; return -1;
} }
void kmem_cache_destroy(struct kmem_cache *cache)
{
TRACE_AND_STOP;
}
int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, char *envp[]) int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, char *envp[])
{ {
TRACE_AND_STOP; TRACE_AND_STOP;

View File

@ -11,12 +11,13 @@
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
*/ */
#include <os/server.h> #include <base/component.h>
extern void start_usb_driver(Server::Entrypoint &e); extern void start_usb_driver(Genode::Env &env);
namespace Server {
char const *name() { return "usb_drv_ep"; } Genode::size_t Component::stack_size() {
size_t stack_size() { return 4*1024*sizeof(long); } return 4*1024*sizeof(long); }
void construct(Entrypoint &e) { start_usb_driver(e); }
}
void Component::construct(Genode::Env &env) { start_usb_driver(env); }

View File

@ -1,3 +1,3 @@
TARGET = usb_drv TARGET = usb_drv
SRC_CC = main.cc SRC_CC = main.cc
LIBS = base usb server LIBS = base usb

View File

@ -307,7 +307,6 @@ DUMMY(-1, ipv4_is_local_multicast)
DUMMY(-1, irqs_disabled) DUMMY(-1, irqs_disabled)
DUMMY(-1, is_vlan_dev) DUMMY(-1, is_vlan_dev)
DUMMY(-1, kernel_sendmsg) DUMMY(-1, kernel_sendmsg)
DUMMY(-1, kmem_cache_destroy)
DUMMY(-1, kobject_put) DUMMY(-1, kobject_put)
DUMMY(-1, kobject_uevent) DUMMY(-1, kobject_uevent)
DUMMY(-1, krealloc) DUMMY(-1, krealloc)

View File

@ -16,14 +16,18 @@
#ifndef _PLATFORM_H_ #ifndef _PLATFORM_H_
#define _PLATFORM_H_ #define _PLATFORM_H_
#include <base/printf.h> #include <base/log.h>
#include <os/config.h>
#include <util/xml_node.h> #include <util/xml_node.h>
#include <os/signal_rpc_dispatcher.h> #include <os/signal_rpc_dispatcher.h>
#include <irq_session/capability.h> #include <irq_session/capability.h>
#include <lx_kit/env.h>
struct Services struct Services
{ {
Genode::Env &env;
/* USB profiles */ /* USB profiles */
bool hid = false; bool hid = false;
bool stor = false; bool stor = false;
@ -46,12 +50,13 @@ struct Services
/* report generation */ /* report generation */
bool raw_report_device_list = false; bool raw_report_device_list = false;
Services() Services(Genode::Env &env) : env(env)
{ {
using namespace Genode; using namespace Genode;
Genode::Xml_node config_node = Lx_kit::env().config_rom().xml();
try { try {
Genode::Xml_node node_hid = config()->xml_node().sub_node("hid"); Genode::Xml_node node_hid = config_node.sub_node("hid");
hid = true; hid = true;
try { try {
@ -61,28 +66,28 @@ struct Services
multitouch = node_screen.attribute_value("multitouch", false); multitouch = node_screen.attribute_value("multitouch", false);
} catch (...) { } catch (...) {
screen_width = screen_height = 0; screen_width = screen_height = 0;
PDBG("Could not read screen resolution in config node"); log("Could not read screen resolution in config node");
} }
} catch (Xml_node::Nonexistent_sub_node) { } catch (Xml_node::Nonexistent_sub_node) {
PDBG("No <hid> config node found - not starting the USB HID (Input) service"); log("No <hid> config node found - not starting the USB HID (Input) service");
} }
try { try {
config()->xml_node().sub_node("storage"); config_node.sub_node("storage");
stor = true; stor = true;
} catch (Xml_node::Nonexistent_sub_node) { } catch (Xml_node::Nonexistent_sub_node) {
PDBG("No <storage> config node found - not starting the USB Storage (Block) service"); log("No <storage> config node found - not starting the USB Storage (Block) service");
} }
try { try {
config()->xml_node().sub_node("nic"); config_node.sub_node("nic");
nic = true; nic = true;
} catch (Xml_node::Nonexistent_sub_node) { } catch (Xml_node::Nonexistent_sub_node) {
PDBG("No <nic> config node found - not starting the USB Nic (Network) service"); log("No <nic> config node found - not starting the USB Nic (Network) service");
} }
try { try {
Genode::Xml_node node_raw = config()->xml_node().sub_node("raw"); Genode::Xml_node node_raw = config_node.sub_node("raw");
raw = true; raw = true;
try { try {
@ -90,27 +95,27 @@ struct Services
raw_report_device_list = node_report.attribute_value("devices", false); raw_report_device_list = node_report.attribute_value("devices", false);
} catch (...) { } } catch (...) { }
} catch (Xml_node::Nonexistent_sub_node) { } catch (Xml_node::Nonexistent_sub_node) {
PDBG("No <raw> config node found - not starting external USB service"); log("No <raw> config node found - not starting external USB service");
} }
if (config()->xml_node().attribute_value("uhci", false)) { if (config_node.attribute_value("uhci", false)) {
uhci = true; uhci = true;
PINF("Enabled UHCI (USB 1.0/1.1) support"); log("Enabled UHCI (USB 1.0/1.1) support");
} }
if (config()->xml_node().attribute_value("ehci", false)) { if (config_node.attribute_value("ehci", false)) {
ehci = true; ehci = true;
PINF("Enabled EHCI (USB 2.0) support"); log("Enabled EHCI (USB 2.0) support");
} }
if (config()->xml_node().attribute_value("xhci", false)) { if (config_node.attribute_value("xhci", false)) {
xhci = true; xhci = true;
PINF("Enabled XHCI (USB 3.0) support"); log("Enabled XHCI (USB 3.0) support");
} }
if (!(uhci | ehci | xhci)) if (!(uhci | ehci | xhci))
PWRN("Warning: No USB controllers enabled.\n" warning("Warning: No USB controllers enabled.\n"
"Use <config (u/e/x)hci=\"yes\"> in your 'usb_drv' configuration"); "Use <config (u/e/x)hci=\"yes\"> in your 'usb_drv' configuration");
} }
}; };

View File

@ -14,10 +14,9 @@
#ifndef _SIGNAL_H_ #ifndef _SIGNAL_H_
#define _SIGNAL_H_ #define _SIGNAL_H_
#include <base/env.h> #include <platform.h>
#include <base/printf.h>
#include <base/signal.h> #include <base/signal.h>
#include <os/server.h>
static bool const verbose = false; static bool const verbose = false;
@ -28,32 +27,34 @@ class Signal_helper
{ {
private: private:
Server::Entrypoint &_ep; Genode::Env &_env;
Genode::Signal_transmitter _sender; Genode::Signal_transmitter _sender;
public: public:
Signal_helper(Server::Entrypoint &ep) : _ep(ep) { } Signal_helper(Genode::Env &env) : _env(env) { }
Server::Entrypoint &ep() { return _ep; } Genode::Entrypoint &ep() { return _env.ep(); }
Genode::Signal_transmitter &sender() { return _sender; } Genode::Signal_transmitter &sender() { return _sender; }
Genode::Parent &parent() { return _env.parent(); }
Genode::Env &env() { return _env; }
}; };
namespace Storage namespace Storage
{ {
void init(Server::Entrypoint &ep); void init(Genode::Env &env);
} }
namespace Nic namespace Nic
{ {
void init(Server::Entrypoint &ep); void init(Genode::Env &env);
} }
namespace Raw namespace Raw
{ {
void init(Server::Entrypoint &ep, bool report_device_list); void init(Genode::Env &env, bool report_device_list);
} }
#endif /* _SIGNAL_H_ */ #endif /* _SIGNAL_H_ */

View File

@ -17,6 +17,12 @@
#ifndef _ARM__PLATFORM_DEVICE__PLATFORM_DEVICE_H_ #ifndef _ARM__PLATFORM_DEVICE__PLATFORM_DEVICE_H_
#define _ARM__PLATFORM_DEVICE__PLATFORM_DEVICE_H_ #define _ARM__PLATFORM_DEVICE__PLATFORM_DEVICE_H_
#include <lx_emul/extern_c_begin.h>
#include <lx_emul/printf.h>
#include <lx_emul/extern_c_end.h>
#include <lx_kit/malloc.h>
#include <platform_device/device.h> #include <platform_device/device.h>
#include <irq_session/connection.h> #include <irq_session/connection.h>
@ -46,7 +52,7 @@ struct Platform::Device : Platform::Abstract_device, Genode::List<Device>::Eleme
Genode::Cache_attribute, Genode::Cache_attribute,
Genode::addr_t, Genode::size_t) override Genode::addr_t, Genode::size_t) override
{ {
PERR("%s: not implemented", __PRETTY_FUNCTION__); lx_printf("%s: not implemented\n", __PRETTY_FUNCTION__);
return Genode::Io_mem_session_capability(); return Genode::Io_mem_session_capability();
} }
@ -63,7 +69,7 @@ struct Platform::Device : Platform::Abstract_device, Genode::List<Device>::Eleme
if (d->irq_num == irq_num) if (d->irq_num == irq_num)
return *d; return *d;
d = new (Genode::env()->heap()) Device(irq_num); d = new (Lx::Malloc::mem()) Device(irq_num);
list().insert(d); list().insert(d);
return *d; return *d;

View File

@ -14,6 +14,7 @@
#ifndef _USB_NIC_COMPONENT_H_ #ifndef _USB_NIC_COMPONENT_H_
#define _USB_NIC_COMPONENT_H_ #define _USB_NIC_COMPONENT_H_
#include <base/log.h>
#include <nic/component.h> #include <nic/component.h>
#include <root/component.h> #include <root/component.h>
@ -148,7 +149,7 @@ class Usb_nic::Session_component : public Nic::Session_component
Genode::Packet_descriptor packet = _tx.sink()->get_packet(); Genode::Packet_descriptor packet = _tx.sink()->get_packet();
if (!packet.size()) { if (!packet.size()) {
PWRN("Invalid tx packet"); Genode::warning("Invalid tx packet");
return true; return true;
} }
@ -178,7 +179,7 @@ class Usb_nic::Session_component : public Nic::Session_component
Genode::size_t const rx_buf_size, Genode::size_t const rx_buf_size,
Genode::Allocator &rx_block_md_alloc, Genode::Allocator &rx_block_md_alloc,
Genode::Ram_session &ram_session, Genode::Ram_session &ram_session,
Server::Entrypoint &ep, Genode::Entrypoint &ep,
Device *device) Device *device)
: Nic::Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc, ram_session, ep), : Nic::Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc, ram_session, ep),
_device(device) _device(device)
@ -222,7 +223,7 @@ class Root : public Root_component
{ {
private: private:
Server::Entrypoint &_ep; Genode::Env &_env;
Usb_nic::Device *_device; Usb_nic::Device *_device;
protected: protected:
@ -246,24 +247,24 @@ class Root : public Root_component
*/ */
if (tx_buf_size + rx_buf_size < tx_buf_size || if (tx_buf_size + rx_buf_size < tx_buf_size ||
tx_buf_size + rx_buf_size > ram_quota - session_size) { tx_buf_size + rx_buf_size > ram_quota - session_size) {
PERR("insufficient 'ram_quota', got %zd, need %zd", Genode::error("insufficient 'ram_quota', got ", ram_quota, " need %zd",
ram_quota, tx_buf_size + rx_buf_size + session_size); tx_buf_size + rx_buf_size + session_size);
throw Genode::Root::Quota_exceeded(); throw Genode::Root::Quota_exceeded();
} }
return new (Root::md_alloc()) return new (Root::md_alloc())
Usb_nic::Session_component(tx_buf_size, rx_buf_size, Usb_nic::Session_component(tx_buf_size, rx_buf_size,
*env()->heap(), Lx::Malloc::mem(),
*env()->ram_session(), _env.ram(),
_ep, _device); _env.ep(), _device);
} }
public: public:
Root(Server::Entrypoint &ep, Genode::Allocator &md_alloc, Root(Genode::Env &env, Genode::Allocator &md_alloc,
Usb_nic::Device *device) Usb_nic::Device *device)
: Root_component(&ep.rpc_ep(), &md_alloc), : Root_component(&env.ep().rpc_ep(), &md_alloc),
_ep(ep), _device(device) _env(env), _device(device)
{ } { }
}; };

View File

@ -13,7 +13,6 @@
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
*/ */
#include <base/printf.h>
#include <base/rpc_server.h> #include <base/rpc_server.h>
#include <input/root.h> #include <input/root.h>
#include <os/ring_buffer.h> #include <os/ring_buffer.h>
@ -77,8 +76,9 @@ void start_input_service(void *ep_ptr, void * service_ptr)
{ {
Rpc_entrypoint *ep = static_cast<Rpc_entrypoint *>(ep_ptr); Rpc_entrypoint *ep = static_cast<Rpc_entrypoint *>(ep_ptr);
Services *service = static_cast<Services *>(service_ptr); Services *service = static_cast<Services *>(service_ptr);
Env &env = service->env;
env()->parent()->announce(ep->manage(&input_root(ep))); env.parent().announce(ep->manage(&input_root(ep)));
genode_input_register(input_callback, service->screen_width, genode_input_register(input_callback, service->screen_width,
service->screen_height, service->multitouch); service->screen_height, service->multitouch);

View File

@ -82,24 +82,20 @@ void dma_free(void *ptr)
void *vzalloc(unsigned long size) void *vzalloc(unsigned long size)
{ {
size_t real_size = size + sizeof(size_t);
size_t *addr; size_t *addr;
try { addr = (size_t *)Genode::env()->heap()->alloc(real_size); } try { addr = (size_t *)Lx::Malloc::mem().alloc_large(size); }
catch (...) { return 0; } catch (...) { return 0; }
*addr = real_size; memset(addr, 0, size);
memset(addr + 1, 0, size);
return addr + 1; return addr;
} }
void vfree(void *addr) void vfree(void *addr)
{ {
if (!addr) return; if (!addr) return;
Lx::Malloc::mem().free_large(addr);
size_t size = *(((size_t *)addr) - 1);
Genode::env()->heap()->free(const_cast<void *>(addr), size);
} }
@ -266,17 +262,13 @@ int ilog2(u32 n) { return Genode::log2(n); }
** linux/slab.h ** ** linux/slab.h **
********************/ ********************/
void kmem_cache_destroy(struct kmem_cache *cache)
{
destroy(Genode::env()->heap(), cache);
}
void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags) void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
{ {
void *ret; void *ret;
ret = kmem_cache_alloc(cache, flags); ret = kmem_cache_alloc(cache, flags);
memset(ret, 0, cache->size()); memset(ret, 0, cache->size());
return ret; return ret;
} }
@ -361,7 +353,7 @@ class Driver : public Genode::List<Driver>::Element
int driver_register(struct device_driver *drv) int driver_register(struct device_driver *drv)
{ {
lx_log(DEBUG_DRIVER, "%s at %p", drv->name, drv); lx_log(DEBUG_DRIVER, "%s at %p", drv->name, drv);
new (Genode::env()->heap()) Driver(drv); new (Lx::Malloc::mem()) Driver(drv);
return 0; return 0;
} }
@ -438,7 +430,7 @@ long find_next_zero_bit_le(const void *addr,
static unsigned cnt = 0; static unsigned cnt = 0;
unsigned long max_size = sizeof(long) * 8; unsigned long max_size = sizeof(long) * 8;
if (offset >= max_size) { if (offset >= max_size) {
PWRN("Offset greater max size"); Genode::warning("Offset greater max size");
return offset + size; return offset + size;
} }
@ -446,7 +438,7 @@ long find_next_zero_bit_le(const void *addr,
if (!(*(unsigned long*)addr & (1L << offset))) if (!(*(unsigned long*)addr & (1L << offset)))
return offset; return offset;
lx_log(DEBUG_TRACE, "No zero bit findable %u", cnt++); Genode::warning("No zero bit findable");
return offset + size; return offset + size;
} }
@ -551,7 +543,7 @@ struct dma_pool *dma_pool_create(const char *name, struct device *d, size_t size
if (align & (align - 1)) if (align & (align - 1))
return 0; return 0;
dma_pool *pool = new(Genode::env()->heap()) dma_pool; dma_pool *pool = new(Lx::Malloc::mem()) dma_pool;
pool->align = Genode::log2((int)align); pool->align = Genode::log2((int)align);
pool->size = size; pool->size = size;
return pool; return pool;
@ -561,7 +553,7 @@ struct dma_pool *dma_pool_create(const char *name, struct device *d, size_t size
void dma_pool_destroy(struct dma_pool *d) void dma_pool_destroy(struct dma_pool *d)
{ {
lx_log(DEBUG_DMA, "close"); lx_log(DEBUG_DMA, "close");
destroy(Genode::env()->heap(), d); destroy(Lx::Malloc::mem(), d);
} }
@ -615,7 +607,7 @@ dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
dma_addr_t phys = (dma_addr_t)Lx::Malloc::dma().phys_addr(ptr); dma_addr_t phys = (dma_addr_t)Lx::Malloc::dma().phys_addr(ptr);
if (phys == ~0UL) if (phys == ~0UL)
PERR("translation virt->phys %p->%lx failed, return ip %p", ptr, phys, Genode::error("translation virt->phys ", ptr, "->", Genode::Hex(phys), "failed, return ip ",
__builtin_return_address(0)); __builtin_return_address(0));
lx_log(DEBUG_DMA, "virt: %p phys: %lx", ptr, phys); lx_log(DEBUG_DMA, "virt: %p phys: %lx", ptr, phys);
@ -649,9 +641,9 @@ struct task_struct *kthread_run(int (*fn)(void *), void *arg, const char *n, ...
*/ */
lx_log(DEBUG_THREAD, "Run %s", n); lx_log(DEBUG_THREAD, "Run %s", n);
new (Genode::env()->heap()) Lx::Task((void (*)(void *))fn, arg, n, new (Lx::Malloc::mem()) Lx::Task((void (*)(void *))fn, arg, n,
Lx::Task::PRIORITY_2, Lx::Task::PRIORITY_2,
Lx::scheduler()); Lx::scheduler());
return 0; return 0;
} }
@ -728,7 +720,7 @@ int smp_call_function_single(int cpu, smp_call_func_t func, void *info,
struct net_device *alloc_etherdev(int sizeof_priv) struct net_device *alloc_etherdev(int sizeof_priv)
{ {
net_device *dev = new (Genode::env()->heap()) net_device(); net_device *dev = new (Lx::Malloc::mem()) net_device();
dev->mtu = 1500; dev->mtu = 1500;
dev->hard_header_len = 0; dev->hard_header_len = 0;
@ -1009,7 +1001,7 @@ void tasklet_hi_schedule(struct tasklet_struct *tasklet)
struct workqueue_struct *create_singlethread_workqueue(char const *name) struct workqueue_struct *create_singlethread_workqueue(char const *name)
{ {
workqueue_struct *wq = (workqueue_struct *)kzalloc(sizeof(workqueue_struct), 0); workqueue_struct *wq = (workqueue_struct *)kzalloc(sizeof(workqueue_struct), 0);
Lx::Work *work = Lx::Work::alloc_work_queue(Genode::env()->heap(), name); Lx::Work *work = Lx::Work::alloc_work_queue(&Lx::Malloc::mem(), name);
wq->task = (void *)work; wq->task = (void *)work;
return wq; return wq;

View File

@ -16,17 +16,17 @@
/* Genode */ /* Genode */
#include <base/printf.h>
#include <base/sleep.h> #include <base/sleep.h>
#include <os/server.h> #include <os/server.h>
#include <nic_session/nic_session.h> #include <nic_session/nic_session.h>
/* Local */ /* Local */
#include <platform.h>
#include <signal.h> #include <signal.h>
#include <lx_emul.h> #include <lx_emul.h>
#include <lx_kit/env.h>
#include <lx_kit/irq.h> #include <lx_kit/irq.h>
#include <lx_kit/malloc.h>
#include <lx_kit/scheduler.h> #include <lx_kit/scheduler.h>
#include <lx_kit/timer.h> #include <lx_kit/timer.h>
#include <lx_kit/work.h> #include <lx_kit/work.h>
@ -53,7 +53,7 @@ struct workqueue_struct *system_power_efficient_wq;
struct workqueue_struct *system_wq; struct workqueue_struct *system_wq;
struct workqueue_struct *tasklet_wq; struct workqueue_struct *tasklet_wq;
void breakpoint() { PDBG("BREAK"); } void breakpoint() { Genode::log("BREAK"); }
extern "C" int stdout_write(const char *); extern "C" int stdout_write(const char *);
@ -103,25 +103,26 @@ static void run_linux(void *s)
} }
void start_usb_driver(Server::Entrypoint &ep) void start_usb_driver(Genode::Env &env)
{ {
static Services services; /* initialize USB env */
Lx_kit::construct_env(env);
static Services services(env);
if (services.hid) if (services.hid)
start_input_service(&ep.rpc_ep(), &services); start_input_service(&env.ep().rpc_ep(), &services);
Storage::init(ep); Storage::init(env);
Nic::init(ep); Nic::init(env);
if (services.raw) if (services.raw)
Raw::init(ep, services.raw_report_device_list); Raw::init(env, services.raw_report_device_list);
Lx::Scheduler &sched = Lx::scheduler(); Lx::Scheduler &sched = Lx::scheduler();
Lx::Timer &timer = Lx::timer(&ep, &jiffies); Lx::Timer &timer = Lx::timer(&env.ep(), &jiffies);
Lx::Irq::irq(&ep, Genode::env()->heap());
Lx::Work::work_queue(Genode::env()->heap());
Lx::Irq::irq(&env.ep(), &Lx_kit::env().heap());
Lx::Work::work_queue(&Lx_kit::env().heap());
static Lx::Task linux(run_linux, &services, "linux", Lx::Task::PRIORITY_0, static Lx::Task linux(run_linux, &services, "linux", Lx::Task::PRIORITY_0,
Lx::scheduler()); Lx::scheduler());

View File

@ -17,7 +17,6 @@
#include <cap_session/connection.h> #include <cap_session/connection.h>
#include <nic/xml_node.h> #include <nic/xml_node.h>
#include <util/xml_node.h> #include <util/xml_node.h>
#include <os/config.h>
#include <lx_emul.h> #include <lx_emul.h>
#include <lx_emul/extern_c_begin.h> #include <lx_emul/extern_c_begin.h>
@ -25,6 +24,9 @@
#include <linux/usb/usbnet.h> #include <linux/usb/usbnet.h>
#include <lx_emul/extern_c_end.h> #include <lx_emul/extern_c_end.h>
#include <lx_kit/env.h>
#include <lx_kit/malloc.h>
#include <usb_nic_component.h> #include <usb_nic_component.h>
#include "signal.h" #include "signal.h"
@ -176,7 +178,7 @@ class Nic_device : public Usb_nic::Device
* Add device * Add device
*/ */
static Nic_device *add(struct net_device *ndev) { static Nic_device *add(struct net_device *ndev) {
return new (Genode::env()->heap()) Nic_device(ndev); } return new (Lx::Malloc::mem()) Nic_device(ndev); }
/** /**
* Report link state * Report link state
@ -244,7 +246,7 @@ class Nic_device : public Usb_nic::Device
_ndev->netdev_ops->ndo_start_xmit(skb, _ndev); _ndev->netdev_ops->ndo_start_xmit(skb, _ndev);
if (dropped < dev->net->stats.tx_dropped) if (dropped < dev->net->stats.tx_dropped)
PWRN("Dropped SKB"); Genode::warning("Dropped SKB");
} }
/** /**
@ -254,7 +256,7 @@ class Nic_device : public Usb_nic::Device
{ {
struct usbnet *dev = (usbnet *)netdev_priv(_ndev); struct usbnet *dev = (usbnet *)netdev_priv(_ndev);
if(!_tx_fixup || !_tx_fixup(dev, skb, 0)) if(!_tx_fixup || !_tx_fixup(dev, skb, 0))
PERR("Tx fixup error"); Genode::error("Tx fixup error");
} }
@ -302,8 +304,8 @@ class Nic_device : public Usb_nic::Device
static Nic_device *_nic = 0; static Nic_device *_nic = 0;
void Nic::init(Server::Entrypoint &ep) { void Nic::init(Genode::Env &env) {
_signal = new (Genode::env()->heap()) Signal_helper(ep); } _signal = new (Lx::Malloc::mem()) Signal_helper(env); }
/*********************** /***********************
@ -320,7 +322,7 @@ int register_netdev(struct net_device *ndev)
/* XXX: move to 'main' */ /* XXX: move to 'main' */
if (!announce) { if (!announce) {
static ::Root root(_signal->ep(), *env()->heap(), nic); static ::Root root(_signal->env(), Lx::Malloc::mem(), nic);
announce = true; announce = true;
@ -334,7 +336,7 @@ int register_netdev(struct net_device *ndev)
ndev->netdev_ops->ndo_set_rx_mode(ndev); ndev->netdev_ops->ndo_set_rx_mode(ndev);
_nic = nic; _nic = nic;
env()->parent()->announce(_signal->ep().rpc_ep().manage(&root)); _signal->parent().announce(_signal->ep().rpc_ep().manage(&root));
} }
return err; return err;
@ -387,7 +389,7 @@ int netif_rx(struct sk_buff *skb)
try { try {
_stat.data(new (skb->data) Net::Ethernet_frame(skb->len), skb->len); _stat.data(new (skb->data) Net::Ethernet_frame(skb->len), skb->len);
} catch(Net::Ethernet_frame::No_ethernet_frame) { } catch(Net::Ethernet_frame::No_ethernet_frame) {
PWRN("No ether frame"); Genode::warning("No ether frame");
} }
} }
#endif #endif
@ -441,7 +443,7 @@ struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, unsigned int l
void dev_kfree_skb(struct sk_buff *skb) void dev_kfree_skb(struct sk_buff *skb)
{ {
lx_log(DEBUG_SKB, "free skb: %p start: %p cloned: %d", lx_log(DEBUG_SKB, "free skb: %p start: %p cloned: %d",
skb, skb->start, skb->cloned); skb, skb->start, skb->cloned);
if (skb->cloned) { if (skb->cloned) {
skb->start = skb->clone; skb->start = skb->clone;
@ -466,8 +468,8 @@ void kfree_skb(struct sk_buff *skb) { dev_kfree_skb(skb); }
void skb_reserve(struct sk_buff *skb, int len) void skb_reserve(struct sk_buff *skb, int len)
{ {
if ((skb->data + len) > skb->end) { if ((skb->data + len) > skb->end) {
PERR("Error resevring SKB data: skb: %p data: %p end: %p len: %d", Genode::error("Error resevring SKB data: skb: ", skb, " data: ", skb->data,
skb, skb->data, skb->end, skb->len); " end: ", skb->end, "len: ", skb->len);
return; return;
} }
skb->data += len; skb->data += len;
@ -481,8 +483,8 @@ void skb_reserve(struct sk_buff *skb, int len)
unsigned char *skb_push(struct sk_buff *skb, unsigned int len) unsigned char *skb_push(struct sk_buff *skb, unsigned int len)
{ {
if((skb->data - len) < skb->start) { if((skb->data - len) < skb->start) {
PERR("Error SKB head room too small: %p data: %p start: %p len: %u", Genode::error("Error SKB head room too small: ", skb, " data: ", skb->data,
skb, skb->data, skb->start, len); " start: ", skb->start, " len: ", len);
return 0; return 0;
} }
@ -500,8 +502,8 @@ unsigned char *skb_push(struct sk_buff *skb, unsigned int len)
unsigned char *skb_put(struct sk_buff *skb, unsigned int len) unsigned char *skb_put(struct sk_buff *skb, unsigned int len)
{ {
if ((skb->data + len > skb->end)) { if ((skb->data + len > skb->end)) {
PERR("Error increasing SKB length: skb: %p data: %p end: %p len: %u", Genode::error("Error increasing SKB length: skb: ", skb, " data: ", skb->data,
skb, skb->data, skb->end, len); " end: ", skb->end, " len: ", len);
return 0; return 0;
} }
@ -535,8 +537,8 @@ int skb_tailroom(const struct sk_buff *skb)
unsigned char *skb_pull(struct sk_buff *skb, unsigned int len) unsigned char *skb_pull(struct sk_buff *skb, unsigned int len)
{ {
if (len > skb->len) { if (len > skb->len) {
PERR("Error try to pull too much: skb: %p len: %u pull len: %u", Genode::error("Error try to pull too much: skb: ", skb, " len: ", skb->len,
skb, skb->len, len); " pull len: ", len);
return 0; return 0;
} }
skb->len -= len; skb->len -= len;
@ -551,8 +553,8 @@ unsigned char *skb_pull(struct sk_buff *skb, unsigned int len)
void skb_trim(struct sk_buff *skb, unsigned int len) void skb_trim(struct sk_buff *skb, unsigned int len)
{ {
if (skb->len <= len) { if (skb->len <= len) {
PERR("Error trimming to %u bytes skb: %p data: %p start: %p len %u ret: %p", Genode::error("Error trimming to ", len, " bytes skb: ", skb, " data: ",
len, skb, skb->data, skb->start, skb->len, __builtin_return_address((0))); skb->data, " start: ", skb->start, " len ", skb->len);
return; return;
} }
@ -708,16 +710,17 @@ void random_ether_addr(u8 *addr)
u8 fallback[] = { 0x2e, 0x60, 0x90, 0x0c, 0x4e, 0x01 }; u8 fallback[] = { 0x2e, 0x60, 0x90, 0x0c, 0x4e, 0x01 };
Nic::Mac_address mac; Nic::Mac_address mac;
Xml_node config_node = Lx_kit::env().config_rom().xml();
/* try using configured mac */ /* try using configured mac */
try { try {
Xml_node nic_config = config()->xml_node().sub_node("nic"); Xml_node nic_config = config_node.sub_node("nic");
Xml_node::Attribute mac_node = nic_config.attribute("mac"); Xml_node::Attribute mac_node = nic_config.attribute("mac");
mac_node.value(&mac); mac_node.value(&mac);
} catch (...) { } catch (...) {
/* use fallback mac */ /* use fallback mac */
snprint_mac(str, fallback); snprint_mac(str, fallback);
PWRN("No mac address or wrong format attribute in <nic> - using fallback (%s)", Genode::warning("No mac address or wrong format attribute in <nic> - using fallback (", str, ")");
str);
Genode::memcpy(addr, fallback, ETH_ALEN); Genode::memcpy(addr, fallback, ETH_ALEN);
return; return;
@ -726,7 +729,7 @@ void random_ether_addr(u8 *addr)
/* use configured mac*/ /* use configured mac*/
Genode::memcpy(addr, mac.addr, ETH_ALEN); Genode::memcpy(addr, mac.addr, ETH_ALEN);
snprint_mac(str, (u8 *)mac.addr); snprint_mac(str, (u8 *)mac.addr);
PINF("Using configured mac: %s", str); Genode::log("Using configured mac: ", str);
#ifdef GENODE_NET_STAT #ifdef GENODE_NET_STAT
_stat.set_mac(mac.addr); _stat.set_mac(mac.addr);

View File

@ -11,8 +11,7 @@
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
*/ */
#include <base/env.h> #include <base/log.h>
#include <base/printf.h>
#include <os/reporter.h> #include <os/reporter.h>
#include <os/session_policy.h> #include <os/session_policy.h>
#include <root/component.h> #include <root/component.h>
@ -26,6 +25,7 @@
#include <lx_emul/extern_c_end.h> #include <lx_emul/extern_c_end.h>
#include <signal.h> #include <signal.h>
#include <lx_kit/malloc.h>
#include <lx_kit/scheduler.h> #include <lx_kit/scheduler.h>
using namespace Genode; using namespace Genode;
@ -183,7 +183,7 @@ class Usb::Worker
int length; int length;
if ((length = usb_string(_device->udev, p.string.index, buffer, p.size())) < 0) { if ((length = usb_string(_device->udev, p.string.index, buffer, p.size())) < 0) {
PWRN("Could not read string descriptor index: %u", p.string.index); warning("Could not read string descriptor index: ", (unsigned)p.string.index);
p.string.length = 0; p.string.length = 0;
} else { } else {
/* returned length is in bytes (char) */ /* returned length is in bytes (char) */
@ -296,7 +296,7 @@ class Usb::Worker
urb *bulk_urb = usb_alloc_urb(0, GFP_KERNEL); urb *bulk_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!bulk_urb) { if (!bulk_urb) {
PERR("Failed to allocate bulk URB"); error("Failed to allocate bulk URB");
kfree(buf); kfree(buf);
return false; return false;
} }
@ -309,7 +309,7 @@ class Usb::Worker
_async_complete, data); _async_complete, data);
if (usb_submit_urb(bulk_urb, GFP_KERNEL)) if (usb_submit_urb(bulk_urb, GFP_KERNEL))
PERR("Failed to submit URB"); error("Failed to submit URB");
return true; return true;
} }
@ -331,7 +331,7 @@ class Usb::Worker
urb *irq_urb = usb_alloc_urb(0, GFP_KERNEL); urb *irq_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!irq_urb) { if (!irq_urb) {
PERR("Failed to allocate interrupt URB"); error("Failed to allocate interrupt URB");
kfree(buf); kfree(buf);
return false; return false;
} }
@ -344,7 +344,7 @@ class Usb::Worker
_async_complete, data, p.transfer.timeout); _async_complete, data, p.transfer.timeout);
if (usb_submit_urb(irq_urb, GFP_KERNEL)) if (usb_submit_urb(irq_urb, GFP_KERNEL))
PERR("Failed to submit URB"); error("Failed to submit URB");
return true; return true;
} }
@ -372,7 +372,7 @@ class Usb::Worker
for (unsigned i = 0; i < config->desc.bNumInterfaces; i++) { for (unsigned i = 0; i < config->desc.bNumInterfaces; i++) {
if (usb_interface_claimed(config->interface[i])) { if (usb_interface_claimed(config->interface[i])) {
PERR("There are interfaces claimed, won't set configuration"); error("There are interfaces claimed, won't set configuration");
return; return;
} }
} }
@ -411,7 +411,7 @@ class Usb::Worker
Packet_descriptor p = _sink->get_packet(); Packet_descriptor p = _sink->get_packet();
if (verbose_raw) if (verbose_raw)
PDBG("PACKET: %u first value: %x", p.type, p.number); log("PACKET: ", (unsigned)p.type, " first value: ", Hex(p.number));
_p_in_flight++; _p_in_flight++;
@ -500,7 +500,7 @@ class Usb::Worker
void start() void start()
{ {
if (!_task) { if (!_task) {
_task = new (Genode::env()->heap()) Lx::Task(run, this, "raw_worker", _task = new (Lx::Malloc::mem()) Lx::Task(run, this, "raw_worker",
Lx::Task::PRIORITY_2, Lx::Task::PRIORITY_2,
Lx::scheduler()); Lx::scheduler());
if (!Lx::scheduler().active()) { if (!Lx::scheduler().active()) {
@ -513,7 +513,7 @@ class Usb::Worker
{ {
if (_task) { if (_task) {
Lx::scheduler().remove(_task); Lx::scheduler().remove(_task);
destroy(Genode::env()->heap(), _task); destroy(Lx::Malloc::mem(), _task);
_task = nullptr; _task = nullptr;
} }
} }
@ -539,7 +539,7 @@ class Usb::Session_component : public Session_rpc_object,
{ {
private: private:
Server::Entrypoint &_ep; Genode::Entrypoint &_ep;
unsigned long _vendor; unsigned long _vendor;
unsigned long _product; unsigned long _product;
long _bus = 0; long _bus = 0;
@ -571,7 +571,7 @@ class Usb::Session_component : public Session_rpc_object,
DEVICE_REMOVE, DEVICE_REMOVE,
}; };
Session_component(Genode::Ram_dataspace_capability tx_ds, Server::Entrypoint &ep, Session_component(Genode::Ram_dataspace_capability tx_ds, Genode::Entrypoint &ep,
unsigned long vendor, unsigned long product, unsigned long vendor, unsigned long product,
long bus, long dev) long bus, long dev)
: Session_rpc_object(tx_ds, ep.rpc_ep()), : Session_rpc_object(tx_ds, ep.rpc_ep()),
@ -700,9 +700,10 @@ class Usb::Session_component : public Session_rpc_object,
return false; return false;
if (_device) if (_device)
PWRN("Device type already present (vendor: %x product: %x). Overwrite!", warning("Device type already present (vendor: ",
device->udev->descriptor.idVendor, Hex(device->udev->descriptor.idVendor),
device->udev->descriptor.idProduct); " product: ", Hex(device->udev->descriptor.idProduct),
") Overwrite!");
_device = device; _device = device;
_worker.device(_device, _sigh_state_change); _worker.device(_device, _sigh_state_change);
@ -754,18 +755,18 @@ class Usb::Root : public Genode::Root_component<Session_component>
{ {
private: private:
Server::Entrypoint &_ep; Genode::Env &_env;
Genode::Signal_rpc_member<Usb::Root> _config_dispatcher = { Genode::Signal_rpc_member<Usb::Root> _config_dispatcher = {
_ep, *this, &Usb::Root::_handle_config }; _env.ep(), *this, &Usb::Root::_handle_config };
Genode::Reporter _config_reporter { "config" }; Genode::Reporter _config_reporter { "config" };
void _handle_config(unsigned) void _handle_config(unsigned)
{ {
Genode::config()->reload(); Lx_kit::env().config_rom().update();
Genode::Xml_node config = Genode::config()->xml_node(); Genode::Xml_node config = Lx_kit::env().config_rom().xml();
if (!_config_reporter.enabled()) if (!_config_reporter.enabled())
_config_reporter.enabled(true); _config_reporter.enabled(true);
@ -790,7 +791,8 @@ class Usb::Root : public Genode::Root_component<Session_component>
using namespace Genode; using namespace Genode;
try { try {
Xml_node raw = Genode::config()->xml_node().sub_node("raw"); Xml_node config_node = Lx_kit::env().config_rom().xml();
Xml_node raw = config_node.sub_node("raw");
Genode::Session_label label(args); Genode::Session_label label(args);
Genode::Session_policy policy(label, raw); Genode::Session_policy policy(label, raw);
@ -808,19 +810,19 @@ class Usb::Root : public Genode::Root_component<Session_component>
throw Root::Quota_exceeded(); throw Root::Quota_exceeded();
if (tx_buf_size > ram_quota - session_size) { if (tx_buf_size > ram_quota - session_size) {
PERR("Insufficient 'ram_quota',got %zu, need %zu", error("Insufficient 'ram_quota',got ", ram_quota, " need ",
ram_quota, tx_buf_size + session_size); tx_buf_size + session_size);
throw Root::Quota_exceeded(); throw Root::Quota_exceeded();
} }
Ram_dataspace_capability tx_ds = env()->ram_session()->alloc(tx_buf_size); Ram_dataspace_capability tx_ds = _env.ram().alloc(tx_buf_size);
Session_component *session = new (md_alloc()) Session_component *session = new (md_alloc())
Session_component(tx_ds, _ep, vendor, product, bus, dev); Session_component(tx_ds, _env.ep(), vendor, product, bus, dev);
::Session::list()->insert(session); ::Session::list()->insert(session);
return session; return session;
} catch (Genode::Session_policy::No_policy_defined) { } catch (Genode::Session_policy::No_policy_defined) {
PERR("Invalid session request, no matching policy for '%s'", error("Invalid session request, no matching policy for '",
Genode::Session_label(args).string()); Genode::Session_label(args).string(), "'");
throw Genode::Root::Unavailable(); throw Genode::Root::Unavailable();
} }
} }
@ -832,26 +834,26 @@ class Usb::Root : public Genode::Root_component<Session_component>
::Session::list()->remove(session); ::Session::list()->remove(session);
Genode::Root_component<Session_component>::_destroy_session(session); Genode::Root_component<Session_component>::_destroy_session(session);
Genode::env()->ram_session()->free(tx_ds); _env.ram().free(tx_ds);
} }
public: public:
Root(Server::Entrypoint &session_ep, Root(Genode::Env &env,
Genode::Allocator *md_alloc) Genode::Allocator *md_alloc)
: Genode::Root_component<Session_component>(&session_ep.rpc_ep(), md_alloc), : Genode::Root_component<Session_component>(&env.ep().rpc_ep(), md_alloc),
_ep(session_ep) _env(env)
{ {
Genode::config()->sigh(_config_dispatcher); Lx_kit::env().config_rom().sigh(_config_dispatcher);
} }
}; };
void Raw::init(Server::Entrypoint &ep, bool report_device_list) void Raw::init(Genode::Env &env, bool report_device_list)
{ {
Device::device_list_reporter().enabled(report_device_list); Device::device_list_reporter().enabled(report_device_list);
static Usb::Root root(ep, env()->heap()); static Usb::Root root(env, &Lx::Malloc::mem());
Genode::env()->parent()->announce(ep.rpc_ep().manage(&root)); env.parent().announce(env.ep().rpc_ep().manage(&root));
} }
@ -864,9 +866,9 @@ int raw_notify(struct notifier_block *nb, unsigned long action, void *data)
struct usb_device *udev = (struct usb_device*)data; struct usb_device *udev = (struct usb_device*)data;
if (verbose_raw) if (verbose_raw)
PDBG("RAW: %s vendor: %04x product: %04x\n", log("RAW: ",action == USB_DEVICE_ADD ? "Add" : "Remove",
action == USB_DEVICE_ADD ? "Add" : "Remove", " vendor: ", Hex(udev->descriptor.idVendor),
udev->descriptor.idVendor, udev->descriptor.idProduct); " product: ", Hex(udev->descriptor.idProduct));
switch (action) { switch (action) {
@ -874,7 +876,7 @@ int raw_notify(struct notifier_block *nb, unsigned long action, void *data)
case USB_DEVICE_ADD: case USB_DEVICE_ADD:
{ {
::Session::list()->state_change(Usb::Session_component::DEVICE_ADD, ::Session::list()->state_change(Usb::Session_component::DEVICE_ADD,
new (env()->heap()) Device(udev)); new (Lx::Malloc::mem()) Device(udev));
break; break;
} }
@ -884,7 +886,7 @@ int raw_notify(struct notifier_block *nb, unsigned long action, void *data)
udev->devnum); udev->devnum);
if (dev) { if (dev) {
::Session::list()->state_change(Usb::Session_component::DEVICE_REMOVE, dev); ::Session::list()->state_change(Usb::Session_component::DEVICE_REMOVE, dev);
destroy(env()->heap(), dev); destroy(Lx::Malloc::mem(), dev);
} }
break; break;
} }

View File

@ -14,6 +14,7 @@
#include <os/attached_io_mem_dataspace.h> #include <os/attached_io_mem_dataspace.h>
#include <lx_emul.h> #include <lx_emul.h>
#include <lx_kit/malloc.h>
#define to_platform_driver(drv) (container_of((drv), struct platform_driver, \ #define to_platform_driver(drv) (container_of((drv), struct platform_driver, \
driver)) driver))
@ -197,7 +198,7 @@ void platform_set_drvdata(struct platform_device *pdev, void *data)
void *_ioremap(phys_addr_t phys_addr, unsigned long size, int wc) void *_ioremap(phys_addr_t phys_addr, unsigned long size, int wc)
{ {
try { try {
Genode::Attached_io_mem_dataspace *ds = new(Genode::env()->heap()) Genode::Attached_io_mem_dataspace *ds = new(Lx::Malloc::mem())
Genode::Attached_io_mem_dataspace(phys_addr, size, !!wc); Genode::Attached_io_mem_dataspace(phys_addr, size, !!wc);
return ds->local_addr<void>(); return ds->local_addr<void>();
} catch (...) { } catch (...) {

View File

@ -11,11 +11,10 @@
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
*/ */
#include <base/env.h>
#include <lx_emul/irq.h> #include <lx_emul/irq.h>
#include <base/env.h>
#include <lx_kit/backend_alloc.h> #include <lx_kit/backend_alloc.h>
#include <lx_kit/env.h>
#include <lx_kit/irq.h> #include <lx_kit/irq.h>
@ -25,11 +24,11 @@
Genode::Ram_dataspace_capability Genode::Ram_dataspace_capability
Lx::backend_alloc(Genode::addr_t size, Genode::Cache_attribute cached) { Lx::backend_alloc(Genode::addr_t size, Genode::Cache_attribute cached) {
return Genode::env()->ram_session()->alloc(size, cached); } return Lx_kit::env().env().ram().alloc(size, cached); }
void Lx::backend_free(Genode::Ram_dataspace_capability cap) { void Lx::backend_free(Genode::Ram_dataspace_capability cap) {
return Genode::env()->ram_session()->free(cap); } return Lx_kit::env().env().ram().free(cap); }
/*********************** /***********************

View File

@ -116,7 +116,7 @@ static void gpio_direction_output(Gpio_bank *bank, int gpio, int en)
} }
static void arndale_ehci_init() static void arndale_ehci_init(Genode::Env &env)
{ {
enum Gpio_offset { D1 = 0x180, X3 = 0xc60 }; enum Gpio_offset { D1 = 0x180, X3 = 0xc60 };
@ -128,8 +128,8 @@ static void arndale_ehci_init()
reg_pwr.state(true); reg_pwr.state(true);
/* reset hub via GPIO */ /* reset hub via GPIO */
Io_mem_connection io_gpio(GPIO_BASE, 0x1000); Io_mem_connection io_gpio(env, GPIO_BASE, 0x1000);
addr_t gpio_base = (addr_t)env()->rm_session()->attach(io_gpio.dataspace()); addr_t gpio_base = (addr_t)env.rm().attach(io_gpio.dataspace());
Gpio_bank *d1 = reinterpret_cast<Gpio_bank *>(gpio_base + D1); Gpio_bank *d1 = reinterpret_cast<Gpio_bank *>(gpio_base + D1);
Gpio_bank *x3 = reinterpret_cast<Gpio_bank *>(gpio_base + X3); Gpio_bank *x3 = reinterpret_cast<Gpio_bank *>(gpio_base + X3);
@ -142,14 +142,14 @@ static void arndale_ehci_init()
gpio_direction_output(x3, 5, 1); gpio_direction_output(x3, 5, 1);
gpio_direction_output(d1, 7, 1); gpio_direction_output(d1, 7, 1);
env()->rm_session()->detach(gpio_base); env.rm().detach(gpio_base);
/* reset ehci controller */ /* reset ehci controller */
Io_mem_connection io_ehci(EHCI_BASE, 0x1000); Io_mem_connection io_ehci(env, EHCI_BASE, 0x1000);
addr_t ehci_base = (addr_t)env()->rm_session()->attach(io_ehci.dataspace()); addr_t ehci_base = (addr_t)env.rm().attach(io_ehci.dataspace());
Ehci ehci(ehci_base); Ehci ehci(ehci_base);
env()->rm_session()->detach(ehci_base); env.rm().detach(ehci_base);
} }
@ -267,7 +267,7 @@ struct Phy_usb3 : Genode::Mmio
}; };
static void arndale_xhci_init() static void arndale_xhci_init(Genode::Env &env)
{ {
/* enable USB3 clock and power up */ /* enable USB3 clock and power up */
static Regulator::Connection reg_clk(Regulator::CLK_USB30); static Regulator::Connection reg_clk(Regulator::CLK_USB30);
@ -277,7 +277,7 @@ static void arndale_xhci_init()
reg_pwr.state(true); reg_pwr.state(true);
/* setup PHY */ /* setup PHY */
Attached_io_mem_dataspace io_phy(DWC3_PHY_BASE, 0x1000); Attached_io_mem_dataspace io_phy(env, DWC3_PHY_BASE, 0x1000);
Phy_usb3 phy((addr_t)io_phy.local_addr<addr_t>()); Phy_usb3 phy((addr_t)io_phy.local_addr<addr_t>());
} }
@ -300,7 +300,7 @@ void ehci_setup(Services *services)
module_ehci_exynos_init(); module_ehci_exynos_init();
/* setup controller */ /* setup controller */
arndale_ehci_init(); arndale_ehci_init(services->env);
/* setup EHCI-controller platform device */ /* setup EHCI-controller platform device */
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0); platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);
@ -326,7 +326,7 @@ void xhci_setup(Services *services)
module_dwc3_driver_init(); module_dwc3_driver_init();
module_xhci_plat_init(); module_xhci_plat_init();
arndale_xhci_init(); arndale_xhci_init(services->env);
/* setup DWC3-controller platform device */ /* setup DWC3-controller platform device */
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0); platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);

View File

@ -130,18 +130,18 @@ static void clock_pwr_init()
reg_pwr.state(true); reg_pwr.state(true);
} }
static void usb_phy_init() static void usb_phy_init(Genode::Env &env)
{ {
Io_mem_connection io_usbotg(USBOTG, 0x1000); Io_mem_connection io_usbotg(env, USBOTG, 0x1000);
addr_t usbotg_base = (addr_t)env()->rm_session()->attach(io_usbotg.dataspace()); addr_t usbotg_base = (addr_t)env.rm().attach(io_usbotg.dataspace());
Usb_Otg usbotg(usbotg_base); Usb_Otg usbotg(usbotg_base);
env()->rm_session()->detach(usbotg_base); env.rm().detach(usbotg_base);
} }
static void odroidx2_ehci_init() static void odroidx2_ehci_init(Genode::Env &env)
{ {
clock_pwr_init(); clock_pwr_init();
usb_phy_init(); usb_phy_init(env);
/* reset hub via GPIO */ /* reset hub via GPIO */
enum { X30 = 294, X34 = 298, X35 = 299 }; enum { X30 = 294, X34 = 298, X35 = 299 };
@ -161,12 +161,12 @@ static void odroidx2_ehci_init()
gpio_x34.write(true); gpio_x34.write(true);
/* reset ehci controller */ /* reset ehci controller */
Io_mem_connection io_ehci(EHCI_BASE, 0x1000); Io_mem_connection io_ehci(env, EHCI_BASE, 0x1000);
addr_t ehci_base = (addr_t)env()->rm_session()->attach(io_ehci.dataspace()); addr_t ehci_base = (addr_t)env.rm().attach(io_ehci.dataspace());
Ehci ehci(ehci_base); Ehci ehci(ehci_base);
env()->rm_session()->detach(ehci_base); env.rm().detach(ehci_base);
} }
extern "C" void module_ehci_exynos_init(); extern "C" void module_ehci_exynos_init();
@ -187,7 +187,7 @@ void ehci_setup(Services *services)
module_ehci_exynos_init(); module_ehci_exynos_init();
/* setup controller */ /* setup controller */
odroidx2_ehci_init(); odroidx2_ehci_init(services->env);
/* setup EHCI-controller platform device */ /* setup EHCI-controller platform device */
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0); platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);

View File

@ -224,14 +224,14 @@ struct Ehci : Genode::Mmio
* Initialize the USB controller from scratch, since the boot loader might not * Initialize the USB controller from scratch, since the boot loader might not
* do it or even disable USB. * do it or even disable USB.
*/ */
static void omap_ehci_init() static void omap_ehci_init(Genode::Env &env)
{ {
/* taken from the Panda board manual */ /* taken from the Panda board manual */
enum { HUB_POWER = 1, HUB_NRESET = 62, ULPI_PHY_TYPE = 182 }; enum { HUB_POWER = 1, HUB_NRESET = 62, ULPI_PHY_TYPE = 182 };
/* SCRM */ /* SCRM */
Io_mem_connection io_scrm(SCRM_BASE, 0x1000); Io_mem_connection io_scrm(env, SCRM_BASE, 0x1000);
addr_t scrm_base = (addr_t)env()->rm_session()->attach(io_scrm.dataspace()); addr_t scrm_base = (addr_t)env.rm().attach(io_scrm.dataspace());
/* enable reference clock */ /* enable reference clock */
Aux3 aux3(scrm_base); Aux3 aux3(scrm_base);
@ -247,18 +247,18 @@ static void omap_ehci_init()
gpio_reset.write(true); gpio_reset.write(true);
/* enable clocks */ /* enable clocks */
Io_mem_connection io_clock(CAM_BASE, 0x1000); Io_mem_connection io_clock(env, CAM_BASE, 0x1000);
addr_t clock_base = (addr_t)env()->rm_session()->attach(io_clock.dataspace()); addr_t clock_base = (addr_t)env.rm().attach(io_clock.dataspace());
Clocks c(clock_base); Clocks c(clock_base);
/* reset TLL */ /* reset TLL */
Io_mem_connection io_tll(TLL_BASE, 0x1000); Io_mem_connection io_tll(env, TLL_BASE, 0x1000);
addr_t tll_base = (addr_t)env()->rm_session()->attach(io_tll.dataspace()); addr_t tll_base = (addr_t)env.rm().attach(io_tll.dataspace());
Tll t(tll_base); Tll t(tll_base);
/* reset host */ /* reset host */
Io_mem_connection io_uhh(UHH_BASE, 0x1000); Io_mem_connection io_uhh(env, UHH_BASE, 0x1000);
addr_t uhh_base = (addr_t)env()->rm_session()->attach(io_uhh.dataspace()); addr_t uhh_base = (addr_t)env.rm().attach(io_uhh.dataspace());
Uhh uhh(uhh_base); Uhh uhh(uhh_base);
/* enable hub power */ /* enable hub power */
@ -270,7 +270,7 @@ static void omap_ehci_init()
addr_t base[] = { scrm_base, clock_base, tll_base, uhh_base, 0 }; addr_t base[] = { scrm_base, clock_base, tll_base, uhh_base, 0 };
for (int i = 0; base[i]; i++) for (int i = 0; base[i]; i++)
env()->rm_session()->detach(base[i]); env.rm().detach(base[i]);
} }
@ -293,7 +293,7 @@ void platform_hcd_init(Services *services)
module_ehci_omap_init(); module_ehci_omap_init();
/* initialize EHCI */ /* initialize EHCI */
omap_ehci_init(); omap_ehci_init(services->env);
/* setup EHCI-controller platform device */ /* setup EHCI-controller platform device */
platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0); platform_device *pdev = (platform_device *)kzalloc(sizeof(platform_device), 0);
@ -314,7 +314,7 @@ void platform_hcd_init(Services *services)
static u64 dma_mask = ~(u64)0; static u64 dma_mask = ~(u64)0;
pdev->dev.dma_mask = &dma_mask; pdev->dev.dma_mask = &dma_mask;
pdev->dev.coherent_dma_mask = ~0; pdev->dev.coherent_dma_mask = ~0;
PDBG("register platform device");
platform_device_register(pdev); platform_device_register(pdev);
} }

View File

@ -204,7 +204,7 @@ extern "C" long name() { return retval; }
int in_irq() int in_irq()
{ {
TRACE; PDBG("called by %p", __builtin_return_address(0)); TRACE;
return 0; return 0;
} }

View File

@ -16,13 +16,14 @@
#include <base/entrypoint.h> #include <base/entrypoint.h>
#include <base/lock.h> #include <base/lock.h>
#include <base/signal.h> #include <base/signal.h>
#include <os/config.h>
#include <util/misc_math.h> #include <util/misc_math.h>
#include <lx_emul.h> #include <lx_emul.h>
#include <lx_kit/env.h>
#include <lx_kit/irq.h> #include <lx_kit/irq.h>
#include <lx_kit/pci_dev_registry.h> #include <lx_kit/pci_dev_registry.h>
#include <lx_kit/malloc.h>
#include <lx_kit/mapped_io_mem_range.h> #include <lx_kit/mapped_io_mem_range.h>
#include <lx_emul/impl/io.h> #include <lx_emul/impl/io.h>
@ -60,8 +61,8 @@ class Pci_dev_list
* 'Out_of_metadata' exception. * 'Out_of_metadata' exception.
*/ */
auto handler = [&] () { auto handler = [&] () {
Genode::env()->parent()->upgrade(Lx::pci()->cap(), Lx_kit::env().env().parent().upgrade(Lx::pci()->cap(),
"ram_quota=4096"); }; "ram_quota=4096"); };
/* /*
* Obtain first device, the operation may exceed the session quota. * Obtain first device, the operation may exceed the session quota.
@ -76,7 +77,7 @@ class Pci_dev_list
*/ */
while (cap.valid()) { while (cap.valid()) {
_pci_caps.insert(new (Genode::env()->heap()) Element(cap)); _pci_caps.insert(new (Lx::Malloc::mem()) Element(cap));
/* try next one. Upgrade session * quota on demand.*/ /* try next one. Upgrade session * quota on demand.*/
auto attempt = [&] () { auto attempt = [&] () {
@ -144,7 +145,7 @@ extern "C" int pci_register_driver(struct pci_driver *driver)
return false; return false;
/* create 'pci_dev' struct for matching device */ /* create 'pci_dev' struct for matching device */
Lx::Pci_dev *pci_dev = new (env()->heap()) Lx::Pci_dev(cap); Lx::Pci_dev *pci_dev = new (Lx::Malloc::mem()) Lx::Pci_dev(cap);
/* enable ioremap to work */ /* enable ioremap to work */
Lx::pci_dev_registry()->insert(pci_dev); Lx::pci_dev_registry()->insert(pci_dev);
@ -157,7 +158,7 @@ extern "C" int pci_register_driver(struct pci_driver *driver)
* access the USB controller after bootup. For this the ext cap register of * access the USB controller after bootup. For this the ext cap register of
* the PCI config space is checked * the PCI config space is checked
*/ */
if (config()->xml_node().attribute_value("bios_handoff", true)) if (Lx_kit::env().config_rom().xml().attribute_value("bios_handoff", true))
__pci_fixup_quirk_usb_early_handoff(pci_dev); __pci_fixup_quirk_usb_early_handoff(pci_dev);
/* call probe function of the Linux driver */ /* call probe function of the Linux driver */

View File

@ -11,6 +11,7 @@
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
*/ */
#include <base/log.h>
#include <base/rpc_server.h> #include <base/rpc_server.h>
#include <block/component.h> #include <block/component.h>
#include <cap_session/connection.h> #include <cap_session/connection.h>
@ -19,6 +20,7 @@
#include <lx_emul.h> #include <lx_emul.h>
#include <lx_kit/malloc.h>
#include <lx_kit/backend_alloc.h> #include <lx_kit/backend_alloc.h>
#include <lx_kit/scheduler.h> #include <lx_kit/scheduler.h>
@ -75,7 +77,7 @@ class Storage_device : public Genode::List<Storage_device>::Element,
_block_count++; _block_count++;
if (verbose) if (verbose)
PDBG("block size: %zu block count: %llu", _block_size, _block_count); Genode::log("block size: ", _block_size, " block count", _block_count);
scsi_free_buffer(cmnd); scsi_free_buffer(cmnd);
_scsi_free_command(cmnd); _scsi_free_command(cmnd);
@ -89,8 +91,8 @@ class Storage_device : public Genode::List<Storage_device>::Element,
throw Io_error(); throw Io_error();
if (verbose) if (verbose)
PDBG("PACKET: phys: %lx block: %llu count: %zu %s", log("PACKET: phys: ", Genode::Hex(phys), " block: ", block_nr, "count: ", block_count,
phys, block_nr, block_count, read ? "read" : "write"); read ? " read" : " write");
/* check if we can call queuecommand */ /* check if we can call queuecommand */
struct us_data *us = (struct us_data *) _sdev->host->hostdata; struct us_data *us = (struct us_data *) _sdev->host->hostdata;
@ -105,7 +107,7 @@ class Storage_device : public Genode::List<Storage_device>::Element,
cmnd->sc_data_direction = read ? DMA_FROM_DEVICE : DMA_TO_DEVICE; cmnd->sc_data_direction = read ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
cmnd->scsi_done = _async_done; cmnd->scsi_done = _async_done;
Block::Packet_descriptor *p = new (Genode::env()->heap()) Block::Packet_descriptor(); Block::Packet_descriptor *p = new (Lx::Malloc::mem()) Block::Packet_descriptor();
*p = packet; *p = packet;
cmnd->packet = (void *)p; cmnd->packet = (void *)p;
@ -176,8 +178,8 @@ class Storage_device : public Genode::List<Storage_device>::Element,
}; };
void Storage::init(Server::Entrypoint &ep) { void Storage::init(Genode::Env &env) {
_signal = new (Genode::env()->heap()) Signal_helper(ep); } _signal = new (Lx::Malloc::mem()) Signal_helper(env); }
struct Factory : Block::Driver_factory struct Factory : Block::Driver_factory
@ -201,10 +203,10 @@ extern "C" void ack_packet(work_struct *work)
(Block::Packet_descriptor *)(work->data); (Block::Packet_descriptor *)(work->data);
if (verbose) if (verbose)
PDBG("ACK packet for block: %llu", packet->block_number()); Genode::log("ACK packet for block: ", packet->block_number());
device->ack_packet(*packet); device->ack_packet(*packet);
Genode::destroy(Genode::env()->heap(), packet); Genode::destroy(Lx::Malloc::mem(), packet);
} }
@ -221,8 +223,8 @@ void scsi_add_device(struct scsi_device *sdev)
*/ */
if (!announce) { if (!announce) {
PREPARE_WORK(&delayed, ack_packet); PREPARE_WORK(&delayed, ack_packet);
static Block::Root root(_signal->ep(), env()->heap(), factory); static Block::Root root(_signal->ep(), &Lx::Malloc::mem(), factory);
env()->parent()->announce(_signal->ep().rpc_ep().manage(&root)); _signal->parent().announce(_signal->ep().rpc_ep().manage(&root));
announce = true; announce = true;
} }
} }

View File

@ -209,7 +209,6 @@ DUMMY(0, ipv6_hdr)
DUMMY(0, irqs_disabled) DUMMY(0, irqs_disabled)
DUMMY(0, isalpha) DUMMY(0, isalpha)
DUMMY(0, jhash_2words) DUMMY(0, jhash_2words)
DUMMY(0, kmem_cache_destroy)
DUMMY(0, kobject_uevent) DUMMY(0, kobject_uevent)
DUMMY(0, kobject_uevent_env) DUMMY(0, kobject_uevent_env)
DUMMY(0, kstrtoul) DUMMY(0, kstrtoul)

View File

@ -24,8 +24,13 @@ class Usb::Packet_handler
private: private:
Usb::Connection &_connection; Usb::Connection &_connection;
Signal_rpc_member<Packet_handler> _rpc_ack_avail; Genode::Entrypoint &_ep;
Signal_rpc_member<Packet_handler> _rpc_ready_submit;
Signal_rpc_member<Packet_handler> _rpc_ack_avail =
{_ep, *this, &Packet_handler::_packet_handler };
Signal_rpc_member<Packet_handler> _rpc_ready_submit =
{ _ep, *this, &Packet_handler::_ready_handler };
bool _ready_submit = true; bool _ready_submit = true;
@ -51,10 +56,8 @@ class Usb::Packet_handler
public: public:
Packet_handler(Connection &connection, Server::Entrypoint &ep) Packet_handler(Connection &connection, Genode::Entrypoint &ep)
: _connection(connection), : _connection(connection), _ep(ep)
_rpc_ack_avail(ep, *this, &Packet_handler::_packet_handler),
_rpc_ready_submit(ep, *this, &Packet_handler::_ready_handler)
{ {
/* connect 'ack_avail' to our rpc member */ /* connect 'ack_avail' to our rpc member */
_connection.tx_channel()->sigh_ack_avail(_rpc_ack_avail); _connection.tx_channel()->sigh_ack_avail(_rpc_ack_avail);
@ -73,7 +76,7 @@ class Usb::Packet_handler
void wait_for_packet() void wait_for_packet()
{ {
packet_avail() ? _packet_handler(0) : Server::wait_and_dispatch_one_signal(); packet_avail() ? _packet_handler(0) : _ep.wait_and_dispatch_one_signal();
} }
Packet_descriptor alloc(size_t size) Packet_descriptor alloc(size_t size)
@ -104,7 +107,7 @@ class Usb::Packet_handler
/* wait for ready_to_submit signal */ /* wait for ready_to_submit signal */
while (!_ready_submit) while (!_ready_submit)
Server::wait_and_dispatch_one_signal(); _ep.wait_and_dispatch_one_signal();
} }
_connection.source()->submit_packet(p); _connection.source()->submit_packet(p);

View File

@ -14,6 +14,7 @@
#define _INCLUDE__USB__USB_H_ #define _INCLUDE__USB__USB_H_
#include <base/allocator.h> #include <base/allocator.h>
#include <base/entrypoint.h>
#include <usb/types.h> #include <usb/types.h>
#include <usb/packet_handler.h> #include <usb/packet_handler.h>
#include <usb_session/connection.h> #include <usb_session/connection.h>
@ -451,7 +452,7 @@ class Usb::Device : public Meta_data
String serial_number_string; String serial_number_string;
Device(Genode::Allocator * const md_alloc, Connection &connection, Device(Genode::Allocator * const md_alloc, Connection &connection,
Server::Entrypoint &ep) Genode::Entrypoint &ep)
: Meta_data(md_alloc, connection, _handler), _handler(connection, ep) : Meta_data(md_alloc, connection, _handler), _handler(connection, ep)
{ } { }