mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
parent
ecd5bef7cb
commit
7c0542d4bc
@ -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
|
||||
|
@ -6,11 +6,8 @@
|
||||
*/
|
||||
|
||||
#include <base/allocator_avl.h>
|
||||
#include <base/sleep.h>
|
||||
#include <base/log.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <os/server.h>
|
||||
#include <os/signal_rpc_dispatcher.h>
|
||||
#include <usb_session/connection.h>
|
||||
#include <usb/usb.h>
|
||||
#include <util/xml_node.h>
|
||||
@ -119,8 +116,8 @@ struct Usb_host_device : List<Usb_host_device>::Element
|
||||
Signal_receiver &sig_rec;
|
||||
Signal_dispatcher<Usb_host_device> 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<Usb_host_device> ack_avail_dispatcher { sig_rec, *this, &Usb_host_device::ack_avail };
|
||||
|
||||
@ -157,9 +154,13 @@ struct Usb_host_device : List<Usb_host_device>::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<Usb_host_device>
|
||||
{
|
||||
Signal_receiver &_sig_rec;
|
||||
Env &_env;
|
||||
Allocator &_alloc;
|
||||
Signal_dispatcher<Usb_devices> _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<Usb_host_device>
|
||||
continue;
|
||||
|
||||
remove(d);
|
||||
Genode::destroy(env()->heap(), d);
|
||||
Genode::destroy(_alloc, d);
|
||||
}
|
||||
}
|
||||
|
||||
@ -610,8 +613,9 @@ struct Usb_devices : List<Usb_host_device>
|
||||
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_host_device>
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user