diff --git a/repos/libports/include/qemu/usb.h b/repos/libports/include/qemu/usb.h
index 6c569349f5..7f25f9e7b1 100644
--- a/repos/libports/include/qemu/usb.h
+++ b/repos/libports/include/qemu/usb.h
@@ -101,7 +101,9 @@ namespace Qemu {
*
* \return Pointer to Controller object that is used to access the xHCI device state
*/
- Controller *usb_init(Timer_queue &tq, Pci_device &pd, Genode::Signal_receiver &sr);
+ Controller *usb_init(Timer_queue &tq, Pci_device &pd,
+ Genode::Signal_receiver &sr,
+ Genode::Allocator &, Genode::Env &);
/**
* Reset USB libray
diff --git a/repos/libports/src/lib/qemu-usb/host.cc b/repos/libports/src/lib/qemu-usb/host.cc
index c46cd7412f..33ac9f643d 100644
--- a/repos/libports/src/lib/qemu-usb/host.cc
+++ b/repos/libports/src/lib/qemu-usb/host.cc
@@ -6,11 +6,8 @@
*/
#include
-#include
#include
#include
-#include
-#include
#include
#include
#include
@@ -119,8 +116,8 @@ struct Usb_host_device : List::Element
Signal_receiver &sig_rec;
Signal_dispatcher state_dispatcher { sig_rec, *this, &Usb_host_device::state_change };
- Allocator_avl alloc { env()->heap() };
- Usb::Connection usb_raw { &alloc, label, 1024*1024, state_dispatcher };
+ Allocator_avl _alloc;
+ Usb::Connection usb_raw; // { &alloc, label, 1024*1024, state_dispatcher };
Signal_dispatcher ack_avail_dispatcher { sig_rec, *this, &Usb_host_device::ack_avail };
@@ -157,9 +154,13 @@ struct Usb_host_device : List::Element
return result;
}
- Usb_host_device(Signal_receiver &sig_rec, char const *label,
+ Usb_host_device(Signal_receiver &sig_rec, Allocator &alloc,
+ Genode::Env &env, char const *label,
unsigned bus, unsigned dev)
- : label(label), bus(bus), dev(dev), sig_rec(sig_rec)
+ :
+ label(label), _alloc(&alloc),
+ usb_raw(env, &_alloc, label, 1024*1024, state_dispatcher),
+ bus(bus), dev(dev), sig_rec(sig_rec)
{
usb_raw.tx_channel()->sigh_ack_avail(ack_avail_dispatcher);
@@ -530,8 +531,10 @@ static void usb_host_register_types(void)
struct Usb_devices : List
{
Signal_receiver &_sig_rec;
+ Env &_env;
+ Allocator &_alloc;
Signal_dispatcher _device_dispatcher { _sig_rec, *this, &Usb_devices::_devices_update };
- Attached_rom_dataspace _devices_rom { "usb_devices" };
+ Attached_rom_dataspace _devices_rom = { _env, "usb_devices" };
void _garbage_collect()
{
@@ -540,7 +543,7 @@ struct Usb_devices : List
continue;
remove(d);
- Genode::destroy(env()->heap(), d);
+ Genode::destroy(_alloc, d);
}
}
@@ -610,8 +613,9 @@ struct Usb_devices : List
if (_find_usb_device(bus, dev)) return;
try {
- Usb_host_device *new_device = new (env()->heap())
- Usb_host_device(_sig_rec, label.string(), bus, dev);
+ Usb_host_device *new_device = new (_alloc)
+ Usb_host_device(_sig_rec, _alloc, _env, label.string(),
+ bus, dev);
insert(new_device);
@@ -623,8 +627,8 @@ struct Usb_devices : List
});
}
- Usb_devices(Signal_receiver *sig_rec)
- : _sig_rec(*sig_rec)
+ Usb_devices(Signal_receiver *sig_rec, Allocator &alloc, Genode::Env &env)
+ : _sig_rec(*sig_rec), _env(env), _alloc(alloc)
{
_devices_rom.sigh(_device_dispatcher);
}
@@ -661,10 +665,12 @@ extern "C" void usb_host_update_devices()
/*
* Do not use type_init macro because of name mangling
*/
-extern "C" void _type_init_usb_host_register_types(Genode::Signal_receiver *sig_rec)
+extern "C" void _type_init_usb_host_register_types(Genode::Signal_receiver *sig_rec,
+ Genode::Allocator *alloc,
+ Genode::Env *env)
{
usb_host_register_types();
- static Usb_devices devices(sig_rec);
+ static Usb_devices devices(sig_rec, *alloc, *env);
_devices = &devices;
}
diff --git a/repos/libports/src/lib/qemu-usb/qemu_emul.cc b/repos/libports/src/lib/qemu-usb/qemu_emul.cc
index 7b0a92c130..1f84f0f861 100644
--- a/repos/libports/src/lib/qemu-usb/qemu_emul.cc
+++ b/repos/libports/src/lib/qemu-usb/qemu_emul.cc
@@ -36,7 +36,9 @@ static bool const verbose_iov = false;
static bool const verbose_mmio = false;
extern "C" void _type_init_usb_register_types();
-extern "C" void _type_init_usb_host_register_types(Genode::Signal_receiver*);
+extern "C" void _type_init_usb_host_register_types(Genode::Signal_receiver*,
+ Genode::Allocator*,
+ Genode::Env *);
extern "C" void _type_init_xhci_register_types();
extern Genode::Lock _lock;
@@ -47,15 +49,19 @@ Qemu::Controller *qemu_controller();
static Qemu::Timer_queue* _timer_queue;
static Qemu::Pci_device* _pci_device;
+static Genode::Allocator *_heap = nullptr;
-Qemu::Controller *Qemu::usb_init(Timer_queue &tq, Pci_device &pci, Genode::Signal_receiver &sig_rec)
+Qemu::Controller *Qemu::usb_init(Timer_queue &tq, Pci_device &pci,
+ Genode::Signal_receiver &sig_rec,
+ Genode::Allocator &alloc, Genode::Env &env)
{
+ _heap = &alloc;
_timer_queue = &tq;
_pci_device = &pci;
_type_init_usb_register_types();
_type_init_xhci_register_types();
- _type_init_usb_host_register_types(&sig_rec);
+ _type_init_usb_host_register_types(&sig_rec, &alloc, &env);
return qemu_controller();
}
@@ -87,7 +93,7 @@ void Qemu::usb_timer_callback(void (*cb)(void*), void *data)
**********/
void *malloc(size_t size) {
- return Genode::env()->heap()->alloc(size); }
+ return _heap->alloc(size); }
void *memset(void *s, int c, size_t n) {
@@ -96,7 +102,7 @@ void *memset(void *s, int c, size_t n) {
void free(void *p) {
if (!p) return;
- Genode::env()->heap()->free(p, 0);
+ _heap->free(p, 0);
}
diff --git a/repos/ports/src/virtualbox/devxhci.cc b/repos/ports/src/virtualbox/devxhci.cc
index d30be81580..c764519b12 100644
--- a/repos/ports/src/virtualbox/devxhci.cc
+++ b/repos/ports/src/virtualbox/devxhci.cc
@@ -470,7 +470,8 @@ static DECLCALLBACK(int) xhciR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFG
usb_signal_thread, usb_signal_thread_wakeup,
32 * 1024 , RTTHREADTYPE_IO, "usb_signal");
- pThis->ctl = Qemu::usb_init(timer_queue, pci_device, *pThis->usb_sig_rec);
+ pThis->ctl = Qemu::usb_init(timer_queue, pci_device, *pThis->usb_sig_rec,
+ vmm_heap(), genode_env());
/*
* Init instance data.