Remove residual uses of deprecated APIs

Issue #1987, related also to issue #3163 and issue #3164.
This commit is contained in:
Norman Feske 2019-02-17 15:57:38 +01:00
parent c4c19f885f
commit b24edc1633
30 changed files with 169 additions and 247 deletions

View File

@ -17,6 +17,7 @@
#include <base/stdint.h> #include <base/stdint.h>
#include <base/signal.h> #include <base/signal.h>
#include <base/allocator.h>
namespace Qemu { namespace Qemu {
@ -102,7 +103,7 @@ namespace Qemu {
* \return Pointer to Controller object that is used to access the xHCI device state * \return Pointer to Controller object that is used to access the xHCI device state
*/ */
Controller *usb_init(Timer_queue &tq, Pci_device &pd, Controller *usb_init(Timer_queue &tq, Pci_device &pd,
Genode::Signal_receiver &sr, Genode::Entrypoint &ep,
Genode::Allocator &, Genode::Env &); Genode::Allocator &, Genode::Env &);
/** /**

View File

@ -16,6 +16,7 @@
/* Genode includes */ /* Genode includes */
#include <base/env.h> #include <base/env.h>
#include <base/allocator.h>
#include <util/xml_node.h> #include <util/xml_node.h>
namespace Libc { namespace Libc {

View File

@ -185,15 +185,6 @@ class Libc::Env_implementation : public Libc::Env
void close(Parent::Client::Id id) override { void close(Parent::Client::Id id) override {
return _env.close(id); } return _env.close(id); }
/*
* \deprecated
*
* Emulation of deprecated part of the 'Env' interface. To be
* removed once they are removed from 'Genode::Env'.
*/
Pd_session &ram() override { return pd(); }
Pd_session_capability ram_session_cap() override { return pd_session_cap(); }
/* already done by the libc */ /* already done by the libc */
void exec_static_constructors() override { } void exec_static_constructors() override { }

View File

@ -13,8 +13,8 @@
*/ */
/* Genode includes */ /* Genode includes */
#include <base/printf.h>
#include <base/sleep.h> #include <base/sleep.h>
#include <base/log.h>
/* local includes */ /* local includes */
#include <extern_c_begin.h> #include <extern_c_begin.h>
@ -30,14 +30,14 @@ enum {
#define TRACE_AND_STOP \ #define TRACE_AND_STOP \
do { \ do { \
PWRN("%s not implemented called from: %p", __func__, __builtin_return_address(0)); \ Genode::warning(__func__, " not implemented called from: ", __builtin_return_address(0)); \
Genode::sleep_forever(); \ Genode::sleep_forever(); \
} while (0) } while (0)
#define TRACE \ #define TRACE \
do { \ do { \
if (SHOW_TRACE) \ if (SHOW_TRACE) \
PWRN("%s not implemented", __func__); \ Genode::warning(__func__, " not implemented"); \
} while (0) } while (0)

View File

@ -220,14 +220,14 @@ struct Usb_host_device : List<Usb_host_device>::Element
Fifo<Isoc_packet> isoc_read_queue { }; Fifo<Isoc_packet> isoc_read_queue { };
Reconstructible<Isoc_packet> isoc_write_packet { Usb::Packet_descriptor(), nullptr }; Reconstructible<Isoc_packet> isoc_write_packet { Usb::Packet_descriptor(), nullptr };
Signal_receiver &sig_rec; Entrypoint &_ep;
Signal_dispatcher<Usb_host_device> state_dispatcher { sig_rec, *this, &Usb_host_device::state_change }; Signal_handler<Usb_host_device> state_dispatcher { _ep, *this, &Usb_host_device::state_change };
Allocator &_alloc; Allocator &_alloc;
Allocator_avl _usb_alloc { &_alloc }; Allocator_avl _usb_alloc { &_alloc };
Usb::Connection usb_raw; //{ &_usb_alloc, label, 1024*1024, state_dispatcher }; Usb::Connection usb_raw; //{ &_usb_alloc, label, 1024*1024, state_dispatcher };
Signal_dispatcher<Usb_host_device> ack_avail_dispatcher { sig_rec, *this, &Usb_host_device::ack_avail }; Signal_handler<Usb_host_device> ack_avail_dispatcher { _ep, *this, &Usb_host_device::ack_avail };
void _release_interfaces() void _release_interfaces()
{ {
@ -265,13 +265,13 @@ struct Usb_host_device : List<Usb_host_device>::Element
return result; return result;
} }
Usb_host_device(Signal_receiver &sig_rec, Allocator &alloc, Usb_host_device(Entrypoint &ep, Allocator &alloc,
Env &env, char const *label, Env &env, char const *label,
Dev_info info) Dev_info info)
: :
label(label), _alloc(alloc), label(label), _alloc(alloc),
usb_raw(env, &_usb_alloc, label, 6*1024*1024, state_dispatcher), usb_raw(env, &_usb_alloc, label, 6*1024*1024, state_dispatcher),
info(info), sig_rec(sig_rec) info(info), _ep(ep)
{ {
usb_raw.tx_channel()->sigh_ack_avail(ack_avail_dispatcher); usb_raw.tx_channel()->sigh_ack_avail(ack_avail_dispatcher);
@ -300,7 +300,7 @@ struct Usb_host_device : List<Usb_host_device>::Element
} }
} }
void ack_avail(unsigned) void ack_avail()
{ {
Lock::Guard g(_lock); Lock::Guard g(_lock);
@ -461,7 +461,7 @@ struct Usb_host_device : List<Usb_host_device>::Element
qemu_dev = nullptr; qemu_dev = nullptr;
} }
void state_change(unsigned) void state_change()
{ {
Lock::Guard g(_lock); Lock::Guard g(_lock);
if (usb_raw.plugged()) if (usb_raw.plugged())
@ -876,10 +876,10 @@ static void usb_host_register_types(void)
struct Usb_devices : List<Usb_host_device> struct Usb_devices : List<Usb_host_device>
{ {
Signal_receiver &_sig_rec; Entrypoint &_ep;
Env &_env; Env &_env;
Allocator &_alloc; Allocator &_alloc;
Signal_dispatcher<Usb_devices> _device_dispatcher { _sig_rec, *this, &Usb_devices::_devices_update }; Signal_handler<Usb_devices> _device_dispatcher { _ep, *this, &Usb_devices::_devices_update };
Attached_rom_dataspace _devices_rom = { _env, "usb_devices" }; Attached_rom_dataspace _devices_rom = { _env, "usb_devices" };
void _garbage_collect() void _garbage_collect()
@ -903,7 +903,7 @@ struct Usb_devices : List<Usb_host_device>
fn(*d); fn(*d);
} }
void _devices_update(unsigned) void _devices_update()
{ {
Lock::Guard g(_lock); Lock::Guard g(_lock);
@ -953,7 +953,7 @@ struct Usb_devices : List<Usb_host_device>
try { try {
Usb_host_device *new_device = new (_alloc) Usb_host_device *new_device = new (_alloc)
Usb_host_device(_sig_rec, _alloc, _env, label.string(), Usb_host_device(_ep, _alloc, _env, label.string(),
dev_info); dev_info);
insert(new_device); insert(new_device);
@ -974,8 +974,8 @@ struct Usb_devices : List<Usb_host_device>
_garbage_collect(); _garbage_collect();
} }
Usb_devices(Signal_receiver *sig_rec, Allocator &alloc, Env &env) Usb_devices(Entrypoint &ep, Allocator &alloc, Env &env)
: _sig_rec(*sig_rec), _env(env), _alloc(alloc) : _ep(ep), _env(env), _alloc(alloc)
{ {
_devices_rom.sigh(_device_dispatcher); _devices_rom.sigh(_device_dispatcher);
} }
@ -1005,19 +1005,19 @@ extern "C" void usb_host_update_devices()
{ {
if (_devices == nullptr) return; if (_devices == nullptr) return;
_devices->_devices_update(0); _devices->_devices_update();
} }
/* /*
* Do not use type_init macro because of name mangling * Do not use type_init macro because of name mangling
*/ */
extern "C" void _type_init_usb_host_register_types(Signal_receiver *sig_rec, extern "C" void _type_init_usb_host_register_types(Entrypoint *ep,
Allocator *alloc, Allocator *alloc,
Env *env) Env *env)
{ {
usb_host_register_types(); usb_host_register_types();
static Usb_devices devices(sig_rec, *alloc, *env); static Usb_devices devices(*ep, *alloc, *env);
_devices = &devices; _devices = &devices;
} }

View File

@ -14,7 +14,6 @@
/* Genode includes */ /* Genode includes */
#include <base/env.h> #include <base/env.h>
#include <base/printf.h>
#include <base/log.h> #include <base/log.h>
#include <util/misc_math.h> #include <util/misc_math.h>
@ -36,7 +35,7 @@ static bool const verbose_iov = false;
static bool const verbose_mmio = false; static bool const verbose_mmio = false;
extern "C" void _type_init_usb_register_types(); 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::Entrypoint*,
Genode::Allocator*, Genode::Allocator*,
Genode::Env *); Genode::Env *);
extern "C" void _type_init_xhci_register_types(); extern "C" void _type_init_xhci_register_types();
@ -52,7 +51,7 @@ static Qemu::Pci_device* _pci_device;
static Genode::Allocator *_heap = nullptr; static Genode::Allocator *_heap = nullptr;
Qemu::Controller *Qemu::usb_init(Timer_queue &tq, Pci_device &pci, Qemu::Controller *Qemu::usb_init(Timer_queue &tq, Pci_device &pci,
Genode::Signal_receiver &sig_rec, Genode::Entrypoint &ep,
Genode::Allocator &alloc, Genode::Env &env) Genode::Allocator &alloc, Genode::Env &env)
{ {
_heap = &alloc; _heap = &alloc;
@ -61,7 +60,7 @@ Qemu::Controller *Qemu::usb_init(Timer_queue &tq, Pci_device &pci,
_type_init_usb_register_types(); _type_init_usb_register_types();
_type_init_xhci_register_types(); _type_init_xhci_register_types();
_type_init_usb_host_register_types(&sig_rec, &alloc, &env); _type_init_usb_host_register_types(&ep, &alloc, &env);
return qemu_controller(); return qemu_controller();
} }
@ -108,10 +107,14 @@ void *memset(void *s, int c, size_t n) {
void q_printf(char const *fmt, ...) void q_printf(char const *fmt, ...)
{ {
va_list va; enum { BUF_SIZE = 128 };
va_start(va, fmt); char buf[BUF_SIZE] { };
Genode::vprintf(fmt, va); va_list args;
va_end(va); va_start(args, fmt);
Genode::String_console sc(buf, BUF_SIZE);
sc.vprintf(fmt, args);
Genode::log(Genode::Cstring(buf));
va_end(args);
} }

View File

@ -27,7 +27,6 @@
*/ */
#include <base/heap.h> #include <base/heap.h>
#include <base/printf.h>
#include <base/debug.h> #include <base/debug.h>
#include <framebuffer_session/connection.h> #include <framebuffer_session/connection.h>
#include <libc/component.h> #include <libc/component.h>
@ -155,7 +154,7 @@ void _eglutNativeEventLoop()
if (win->display_cb) if (win->display_cb)
win->display_cb(); win->display_cb();
if (eglut_win.is_constructed()) { if (eglut_win.constructed()) {
eglWaitClient(); eglWaitClient();
eglSwapBuffers(_eglut->dpy, win->surface); eglSwapBuffers(_eglut->dpy, win->surface);
eglut_win->refresh(); eglut_win->refresh();

View File

@ -12,8 +12,6 @@
* under the terms of the GNU Affero General Public License version 3. * under the terms of the GNU Affero General Public License version 3.
*/ */
#include <base/printf.h>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>

View File

@ -14,7 +14,6 @@
#ifndef _INCLUDE__GPIO__COMPONENT_H_ #ifndef _INCLUDE__GPIO__COMPONENT_H_
#define _INCLUDE__GPIO__COMPONENT_H_ #define _INCLUDE__GPIO__COMPONENT_H_
#include <base/printf.h>
#include <root/component.h> #include <root/component.h>
#include <gpio_session/gpio_session.h> #include <gpio_session/gpio_session.h>
#include <gpio/driver.h> #include <gpio/driver.h>

View File

@ -16,7 +16,7 @@
/* Genode includes */ /* Genode includes */
#include <util/misc_math.h> #include <util/misc_math.h>
#include <base/printf.h> #include <base/log.h>
/* board-specific includes */ /* board-specific includes */
#include <drivers/defs/rpi.h> #include <drivers/defs/rpi.h>
@ -207,14 +207,13 @@ struct Platform::Property_message
void dump(char const *label) void dump(char const *label)
{ {
unsigned const *buf = (unsigned *)this; unsigned const *buf = (unsigned *)this;
printf("%s message:\n", label); log(label, " message:");
for (unsigned i = 0;; i++) { for (unsigned i = 0;; i++) {
for (unsigned j = 0; j < 8; j++) { for (unsigned j = 0; j < 8; j++) {
unsigned const msg_word_idx = i*8 + j; unsigned const msg_word_idx = i*8 + j;
printf(" %08x", buf[msg_word_idx]); log(" ", Hex(buf[msg_word_idx]));
if (msg_word_idx*sizeof(unsigned) < buf_size) if (msg_word_idx*sizeof(unsigned) < buf_size)
continue; continue;
printf("\n");
return; return;
} }
} }

View File

@ -21,8 +21,6 @@
#include <base/attached_io_mem_dataspace.h> #include <base/attached_io_mem_dataspace.h>
#include <util/mmio.h> #include <util/mmio.h>
#include <base/printf.h>
namespace Gpio { namespace Gpio {
class Reg; class Reg;
@ -72,7 +70,7 @@ struct Gpio::Reg : Attached_io_mem_dataspace, Mmio
case 5: write<Int_con::Con5>(value); break; case 5: write<Int_con::Con5>(value); break;
case 6: write<Int_con::Con6>(value); break; case 6: write<Int_con::Con6>(value); break;
case 7: write<Int_con::Con7>(value); break; case 7: write<Int_con::Con7>(value); break;
default: PWRN("Not is valid irq con!"); default: warning("Not is valid irq con!");
} }
} }
}; };

View File

@ -21,7 +21,6 @@
#include <gpio/driver.h> #include <gpio/driver.h>
#include <irq_session/connection.h> #include <irq_session/connection.h>
#include <timer_session/connection.h> #include <timer_session/connection.h>
#include <os/server.h>
/* local includes */ /* local includes */
#include <board.h> #include <board.h>

View File

@ -20,7 +20,6 @@
#include <base/heap.h> #include <base/heap.h>
#include <gpio/component.h> #include <gpio/component.h>
#include <gpio/config.h> #include <gpio/config.h>
#include <os/server.h>
/* local includes */ /* local includes */
#include <driver.h> #include <driver.h>

View File

@ -18,7 +18,6 @@
#define _DRIVERS__GPIO__SPEC__RPI__GPIO_H_ #define _DRIVERS__GPIO__SPEC__RPI__GPIO_H_
/* Genode includes */ /* Genode includes */
#include <base/printf.h>
#include <base/attached_io_mem_dataspace.h> #include <base/attached_io_mem_dataspace.h>
#include <util/mmio.h> #include <util/mmio.h>
#include <timer_session/connection.h> #include <timer_session/connection.h>

View File

@ -20,7 +20,6 @@
#include <base/heap.h> #include <base/heap.h>
#include <gpio/component.h> #include <gpio/component.h>
#include <gpio/config.h> #include <gpio/config.h>
#include <os/server.h>
/* local includes */ /* local includes */
#include "driver.h" #include "driver.h"

View File

@ -21,25 +21,31 @@ class Irq_handler
{ {
private: private:
Genode::Irq_connection _irq; Genode::Env &_env;
Genode::Signal_receiver _sig_rec { }; Genode::Irq_connection _irq;
Genode::Signal_dispatcher<Irq_handler> _dispatcher; Genode::Signal_handler<Irq_handler> _handler;
void _handle(unsigned) { } unsigned _sem_cnt = 1;
void _handle() { _sem_cnt = 0; }
public: public:
Irq_handler(Genode::Env &env, int irq_number) Irq_handler(Genode::Env &env, int irq_number)
: :
_irq(env, irq_number), _env(env), _irq(env, irq_number),
_dispatcher(_sig_rec, *this, &Irq_handler::_handle) _handler(env.ep(), *this, &Irq_handler::_handle)
{ {
_irq.sigh(_dispatcher); _irq.sigh(_handler);
_irq.ack_irq(); _irq.ack_irq();
} }
void wait() { _sig_rec.wait_for_signal(); } void wait()
{
_sem_cnt++;
while (_sem_cnt > 0)
_env.ep().wait_and_dispatch_one_io_signal();
}
void ack() { _irq.ack_irq(); } void ack() { _irq.ack_irq(); }
}; };

View File

@ -20,7 +20,6 @@
#include <platform_session/connection.h> #include <platform_session/connection.h>
#include <input/component.h> #include <input/component.h>
#include <input/root.h> #include <input/root.h>
#include <os/server.h>
/* local includes */ /* local includes */
#include <driver.h> #include <driver.h>

View File

@ -448,7 +448,7 @@ namespace Genode
/* Wait till MDIO interface is ready to accept a new transaction. */ /* Wait till MDIO interface is ready to accept a new transaction. */
while (!read<Status::Phy_mgmt_idle>()) { while (!read<Status::Phy_mgmt_idle>()) {
if (timeout <= 0) { if (timeout <= 0) {
PWRN("%s: Timeout\n", __func__); warning(__func__, ": Timeout");
throw Phy_timeout_for_idle(); throw Phy_timeout_for_idle();
} }
@ -644,7 +644,7 @@ namespace Genode
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;
} }

View File

@ -16,7 +16,6 @@
#define _INCLUDE__DRIVERS__NIC__GEM__MARVELL_PHY_H_ #define _INCLUDE__DRIVERS__NIC__GEM__MARVELL_PHY_H_
/* Genode includes */ /* Genode includes */
#include <base/printf.h>
#include <os/attached_mmio.h> #include <os/attached_mmio.h>
#include <nic_session/nic_session.h> #include <nic_session/nic_session.h>
#include <timer_session/connection.h> #include <timer_session/connection.h>
@ -483,7 +482,7 @@ namespace Genode
} }
if ((i++ % 500) == 0) if ((i++ % 500) == 0)
Genode::printf("."); Genode::log(".");
_timer.msleep(1); _timer.msleep(1);
mii_reg = phy_read<Bmsr>(); mii_reg = phy_read<Bmsr>();
@ -525,7 +524,7 @@ namespace Genode
} }
if ((i++ % 1000) == 0) if ((i++ % 1000) == 0)
Genode::printf("."); Genode::log(".");
_timer.msleep(1); _timer.msleep(1);
} }
log(" done"); log(" done");

View File

@ -16,7 +16,7 @@
/* Genode includes */ /* Genode includes */
#include <util/misc_math.h> #include <util/misc_math.h>
#include <base/printf.h> #include <base/log.h>
/* board-specific includes */ /* board-specific includes */
#include <drivers/defs/rpi.h> #include <drivers/defs/rpi.h>
@ -42,19 +42,19 @@ struct Platform::Framebuffer_message : Framebuffer_info
void dump(char const *label) void dump(char const *label)
{ {
using Genode::printf; using Genode::log;
printf("%s message:\n", label); log(label, " message:");
printf(" phys_width: %u\n", phys_width); log(" phys_width: ", phys_width);
printf(" phys_height: %u\n", phys_height); log(" phys_height: ", phys_height);
printf(" virt_width: %u\n", virt_width); log(" virt_width: ", virt_width);
printf(" virt_height: %u\n", virt_height); log(" virt_height: ", virt_height);
printf(" pitch: %u\n", pitch); log(" pitch: ", pitch);
printf(" depth: %d\n", depth); log(" depth: ", depth);
printf(" x_offset: %d\n", x_offset); log(" x_offset: ", x_offset);
printf(" y_offset: %d\n", y_offset); log(" y_offset: ", y_offset);
printf(" addr: 0x%08x\n", addr); log(" addr: ", Genode::Hex(addr));
printf(" size: 0x%08x\n", size); log(" size: ", Genode::Hex(size));
} }
inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; } inline void *operator new (__SIZE_TYPE__, void *ptr) { return ptr; }

View File

@ -15,7 +15,6 @@
#define _INCLUDE__VMM__UTCB_GUARD_H_ #define _INCLUDE__VMM__UTCB_GUARD_H_
/* Genode includes */ /* Genode includes */
#include <base/printf.h>
#include <util/string.h> #include <util/string.h>
/* NOVA syscalls */ /* NOVA syscalls */

View File

@ -72,6 +72,7 @@ SRC_CC += GuestHost/HGSMI/HGSMICommon.cpp
SRC_CC += GuestHost/HGSMI/HGSMIMemAlloc.cpp SRC_CC += GuestHost/HGSMI/HGSMIMemAlloc.cpp
SRC_CC += devxhci.cc SRC_CC += devxhci.cc
INC_DIR += $(call select_from_repositories,src/lib/libc)
INC_DIR += $(VBOX_DIR)/Devices/build INC_DIR += $(VBOX_DIR)/Devices/build
INC_DIR += $(VBOX_DIR)/Devices/Bus INC_DIR += $(VBOX_DIR)/Devices/Bus

View File

@ -21,6 +21,7 @@ SRC_CC += network.cpp
SRC_CC += audio.cc SRC_CC += audio.cc
INC_DIR += $(VBOX_DIR)/Devices/Audio INC_DIR += $(VBOX_DIR)/Devices/Audio
INC_DIR += $(call select_from_repositories,src/lib/libc)
vpath network.cpp $(REP_DIR)/src/virtualbox5 vpath network.cpp $(REP_DIR)/src/virtualbox5
vpath audio.cc $(REP_DIR)/src/virtualbox5 vpath audio.cc $(REP_DIR)/src/virtualbox5

View File

@ -994,7 +994,7 @@ class Machine : public StaticReceiver<Machine>
if (!_pd_vcpus) if (!_pd_vcpus)
_pd_vcpus = new Genode::Pd_connection(_env, "VM"); _pd_vcpus = new Genode::Pd_connection(_env, "VM");
vcpu_thread = new Vmm::Vcpu_other_pd(&_cpu_session, location, *_pd_vcpus); vcpu_thread = new Vmm::Vcpu_other_pd(&_cpu_session, location, _pd_vcpus->rpc_cap());
} }
Vcpu_dispatcher *vcpu_dispatcher = Vcpu_dispatcher *vcpu_dispatcher =
@ -1418,7 +1418,7 @@ void Component::construct(Genode::Env &env)
Genode::log("--- Vancouver VMM starting ---"); Genode::log("--- Vancouver VMM starting ---");
/* request max available memory */ /* request max available memory */
vm_size = env.ram().avail_ram().value; vm_size = env.pd().avail_ram().value;
/* reserve some memory for the VMM */ /* reserve some memory for the VMM */
vm_size -= 10 * 1024 * 1024; vm_size -= 10 * 1024 * 1024;
/* calculate max memory for the VM */ /* calculate max memory for the VM */

View File

@ -95,6 +95,6 @@ void Component::construct(Genode::Env &env)
typedef Vcpu_dispatcher<Vmm::Vcpu_other_pd> Vcpu_o; typedef Vcpu_dispatcher<Vmm::Vcpu_other_pd> Vcpu_o;
static Genode::Pd_connection remote_pd(env, "VM"); static Genode::Pd_connection remote_pd(env, "VM");
static Vcpu_o vcpu_o_1(env, Vcpu_o::SVM, "vcpu_o_1", remote_pd); static Vcpu_o vcpu_o_1(env, Vcpu_o::SVM, "vcpu_o_1", remote_pd.rpc_cap());
static Vcpu_o vcpu_o_2(env, Vcpu_o::SVM, "vcpu_o_2", remote_pd); static Vcpu_o vcpu_o_2(env, Vcpu_o::SVM, "vcpu_o_2", remote_pd.rpc_cap());
} }

View File

@ -20,6 +20,9 @@
/* qemu-usb includes */ /* qemu-usb includes */
#include <qemu/usb.h> #include <qemu/usb.h>
/* libc internal includes */
#include <thread_create.h>
/* Virtualbox includes */ /* Virtualbox includes */
#define LOG_GROUP LOG_GROUP_DEV_EHCI #define LOG_GROUP LOG_GROUP_DEV_EHCI
#include <VBox/pci.h> #include <VBox/pci.h>
@ -54,7 +57,6 @@ static bool const verbose_timer = false;
************************/ ************************/
struct Timer_queue; struct Timer_queue;
struct Destruction_helper;
struct XHCI struct XHCI
@ -74,15 +76,11 @@ struct XHCI
/** Address of the MMIO region assigned by PCI. */ /** Address of the MMIO region assigned by PCI. */
RTGCPHYS32 MMIOBase; RTGCPHYS32 MMIOBase;
/** Receiver thread that handles all USB signals. */
PPDMTHREAD pThread;
PTMTIMERR3 controller_timer; PTMTIMERR3 controller_timer;
Timer_queue *timer_queue; Timer_queue *timer_queue;
Qemu::Controller *ctl; Qemu::Controller *ctl;
Genode::Signal_receiver *usb_sig_rec; Genode::Entrypoint *usb_ep;
Destruction_helper *destruction_helper;
}; };
@ -317,56 +315,6 @@ struct Pci_device : public Qemu::Pci_device
}; };
/*************************************
** Qemu::Usb signal thread backend **
*************************************/
struct Destruction_helper
{
Genode::Signal_receiver &sig_rec;
Genode::Signal_dispatcher<Destruction_helper> dispatcher {
sig_rec, *this, &Destruction_helper::handle };
void handle(unsigned) { }
Destruction_helper(Genode::Signal_receiver &sig_rec)
: sig_rec(sig_rec) { }
};
static DECLCALLBACK(int) usb_signal_thread(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
{
PXHCI pThis = PDMINS_2_DATA(pDevIns, PXHCI);
if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
return VINF_SUCCESS;
while (pThread->enmState == PDMTHREADSTATE_RUNNING)
{
Genode::Signal sig = pThis->usb_sig_rec->wait_for_signal();
int num = sig.num();
Genode::Signal_dispatcher_base *dispatcher;
dispatcher = dynamic_cast<Genode::Signal_dispatcher_base *>(sig.context());
if (dispatcher) {
dispatcher->dispatch(num);
}
}
return VINF_SUCCESS;
}
static DECLCALLBACK(int) usb_signal_thread_wakeup(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
{
PXHCI pThis = PDMINS_2_DATA(pDevIns, PXHCI);
Genode::Signal_transmitter(pThis->destruction_helper->dispatcher).submit();
return VINF_SUCCESS;
}
/*********************************************** /***********************************************
** Virtualbox Device function implementation ** ** Virtualbox Device function implementation **
***********************************************/ ***********************************************/
@ -451,6 +399,33 @@ static DECLCALLBACK(int) xhciDestruct(PPDMDEVINS pDevIns)
} }
struct Usb_ep : Genode::Entrypoint
{
pthread_t _pthread;
void _handle_pthread_registration()
{
Genode::Thread *myself = Genode::Thread::myself();
if (!myself || Libc::pthread_create(&_pthread, *myself)) {
Genode::error("USB passthough will not work - thread for "
"pthread registration invalid");
}
}
Genode::Signal_handler<Usb_ep> _pthread_reg_sigh;
enum { USB_EP_STACK = 32u << 10, };
Usb_ep(Genode::Env &env)
:
Entrypoint(env, USB_EP_STACK, "usb_ep", Genode::Affinity::Location()),
_pthread_reg_sigh(*this, *this, &Usb_ep::_handle_pthread_registration)
{
Genode::Signal_transmitter(_pthread_reg_sigh).submit();
}
};
/** /**
* @interface_method_impl{PDMDEVREG,pfnConstruct,XHCI constructor} * @interface_method_impl{PDMDEVREG,pfnConstruct,XHCI constructor}
*/ */
@ -459,9 +434,7 @@ static DECLCALLBACK(int) xhciR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFG
PXHCI pThis = PDMINS_2_DATA(pDevIns, PXHCI); PXHCI pThis = PDMINS_2_DATA(pDevIns, PXHCI);
PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
pThis->usb_sig_rec = new (vmm_heap()) Genode::Signal_receiver(); pThis->usb_ep = new Usb_ep(genode_env());
pThis->destruction_helper = new (vmm_heap())
Destruction_helper(*(pThis->usb_sig_rec));
int rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, Timer_queue::tm_timer_cb, int rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, Timer_queue::tm_timer_cb,
pThis, TMTIMER_FLAGS_NO_CRIT_SECT, pThis, TMTIMER_FLAGS_NO_CRIT_SECT,
@ -471,11 +444,7 @@ static DECLCALLBACK(int) xhciR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFG
pThis->timer_queue = &timer_queue; pThis->timer_queue = &timer_queue;
static Pci_device pci_device(pDevIns); static Pci_device pci_device(pDevIns);
rc = PDMDevHlpThreadCreate(pDevIns, &pThis->pThread, pThis, pThis->ctl = Qemu::usb_init(timer_queue, pci_device, *pThis->usb_ep,
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,
vmm_heap(), genode_env()); vmm_heap(), genode_env());
/* /*

View File

@ -41,6 +41,8 @@
#include <nic/packet_allocator.h> #include <nic/packet_allocator.h>
#include <base/snprintf.h> #include <base/snprintf.h>
#include <thread_create.h>
/* VBox Genode specific */ /* VBox Genode specific */
#include "vmm.h" #include "vmm.h"
@ -74,6 +76,17 @@ typedef struct DRVNIC
} DRVNIC, *PDRVNIC; } DRVNIC, *PDRVNIC;
/**
* Return lock to synchronize the destruction of the
* PDRVNIC, i.e., the Nic_client.
*/
static Genode::Lock *destruct_lock()
{
static Genode::Lock lock(Genode::Lock::LOCKED);
return &lock;
}
class Nic_client class Nic_client
{ {
private: private:
@ -85,12 +98,15 @@ class Nic_client
Nic::Packet_allocator *_tx_block_alloc; Nic::Packet_allocator *_tx_block_alloc;
Nic::Connection _nic; Nic::Connection _nic;
Genode::Signal_receiver _sig_rec;
Genode::Signal_dispatcher<Nic_client> _link_state_dispatcher; enum { NIC_EP_STACK = 32u << 10, };
Genode::Signal_dispatcher<Nic_client> _rx_packet_avail_dispatcher; Genode::Entrypoint _ep;
Genode::Signal_dispatcher<Nic_client> _rx_ready_to_ack_dispatcher; pthread_t _pthread;
Genode::Signal_dispatcher<Nic_client> _destruct_dispatcher;
Genode::Signal_handler<Nic_client> _link_state_dispatcher;
Genode::Signal_handler<Nic_client> _rx_packet_avail_dispatcher;
Genode::Signal_handler<Nic_client> _rx_ready_to_ack_dispatcher;
Genode::Signal_handler<Nic_client> _destruct_dispatcher;
bool _link_up = false; bool _link_up = false;
@ -98,7 +114,7 @@ class Nic_client
PPDMINETWORKDOWN _down_rx; PPDMINETWORKDOWN _down_rx;
PPDMINETWORKCONFIG _down_rx_config; PPDMINETWORKCONFIG _down_rx_config;
void _handle_rx_packet_avail(unsigned) void _handle_rx_packet_avail()
{ {
while (_nic.rx()->packet_avail() && _nic.rx()->ready_to_ack()) { while (_nic.rx()->packet_avail() && _nic.rx()->ready_to_ack()) {
Nic::Packet_descriptor rx_packet = _nic.rx()->get_packet(); Nic::Packet_descriptor rx_packet = _nic.rx()->get_packet();
@ -116,9 +132,9 @@ class Nic_client
} }
} }
void _handle_rx_ready_to_ack(unsigned) { _handle_rx_packet_avail(0); } void _handle_rx_ready_to_ack() { _handle_rx_packet_avail(); }
void _handle_link_state(unsigned) void _handle_link_state()
{ {
_link_up = _nic.link_state(); _link_up = _nic.link_state();
@ -127,12 +143,14 @@ class Nic_client
: PDMNETWORKLINKSTATE_DOWN); : PDMNETWORKLINKSTATE_DOWN);
} }
/** void _handle_destruct()
* By handling this signal the I/O thread gets unblocked {
* and will leave its loop when the DRVNIC instance is _nic.link_state_sigh(Genode::Signal_context_capability());
* being destructed. _nic.rx_channel()->sigh_packet_avail(Genode::Signal_context_capability());
*/ _nic.rx_channel()->sigh_ready_to_ack(Genode::Signal_context_capability());
void _handle_destruct(unsigned) { }
destruct_lock()->unlock();
}
void _tx_ack(bool block = false) void _tx_ack(bool block = false)
{ {
@ -161,22 +179,39 @@ class Nic_client
return new (vmm_heap()) Nic::Packet_allocator(&vmm_heap()); return new (vmm_heap()) Nic::Packet_allocator(&vmm_heap());
} }
void _handle_pthread_registration()
{
Genode::Thread *myself = Genode::Thread::myself();
if (!myself || Libc::pthread_create(&_pthread, *myself)) {
Genode::error("network will not work - thread for pthread "
"registration invalid");
return;
}
}
Genode::Signal_handler<Nic_client> _pthread_reg_sigh {
_ep, *this, &Nic_client::_handle_pthread_registration };
public: public:
Nic_client(Genode::Env &env, PDRVNIC drvtap, char const *label) Nic_client(Genode::Env &env, PDRVNIC drvtap, char const *label)
: :
_tx_block_alloc(_packet_allocator()), _tx_block_alloc(_packet_allocator()),
_nic(env, _tx_block_alloc, BUF_SIZE, BUF_SIZE, label), _nic(env, _tx_block_alloc, BUF_SIZE, BUF_SIZE, label),
_link_state_dispatcher(_sig_rec, *this, &Nic_client::_handle_link_state), _ep(env, NIC_EP_STACK, "nic_ep", Genode::Affinity::Location()),
_rx_packet_avail_dispatcher(_sig_rec, *this, &Nic_client::_handle_rx_packet_avail), _link_state_dispatcher(_ep, *this, &Nic_client::_handle_link_state),
_rx_ready_to_ack_dispatcher(_sig_rec, *this, &Nic_client::_handle_rx_ready_to_ack), _rx_packet_avail_dispatcher(_ep, *this, &Nic_client::_handle_rx_packet_avail),
_destruct_dispatcher(_sig_rec, *this, &Nic_client::_handle_destruct), _rx_ready_to_ack_dispatcher(_ep, *this, &Nic_client::_handle_rx_ready_to_ack),
_destruct_dispatcher(_ep, *this, &Nic_client::_handle_destruct),
_down_rx(drvtap->pIAboveNet), _down_rx(drvtap->pIAboveNet),
_down_rx_config(drvtap->pIAboveConfig) _down_rx_config(drvtap->pIAboveConfig)
{ } {
Genode::Signal_transmitter(_pthread_reg_sigh).submit();
}
~Nic_client() ~Nic_client()
{ {
/* XXX Libc::pthread_free(&_pthread); */
destroy(vmm_heap(), _tx_block_alloc); destroy(vmm_heap(), _tx_block_alloc);
} }
@ -187,11 +222,10 @@ class Nic_client
_nic.rx_channel()->sigh_ready_to_ack(_rx_ready_to_ack_dispatcher); _nic.rx_channel()->sigh_ready_to_ack(_rx_ready_to_ack_dispatcher);
/* set initial link-state */ /* set initial link-state */
_handle_link_state(1); _handle_link_state();
} }
Genode::Signal_context_capability dispatcher() { return _destruct_dispatcher; } Genode::Signal_context_capability dispatcher() { return _destruct_dispatcher; }
Genode::Signal_receiver &sig_rec() { return _sig_rec; }
Nic::Mac_address mac_address() { return _nic.mac_address(); } Nic::Mac_address mac_address() { return _nic.mac_address(); }
int send_packet(void *packet, uint32_t packet_len) int send_packet(void *packet, uint32_t packet_len)
@ -211,17 +245,6 @@ class Nic_client
}; };
/**
* Return lock to synchronize the destruction of the
* PDRVNIC, i.e., the Nic_client.
*/
static Genode::Lock *destruct_lock()
{
static Genode::Lock lock(Genode::Lock::LOCKED);
return &lock;
}
/** Converts a pointer to Nic::INetworkUp to a PRDVNic. */ /** Converts a pointer to Nic::INetworkUp to a PRDVNic. */
#define PDMINETWORKUP_2_DRVNIC(pInterface) ( (PDRVNIC)((uintptr_t)pInterface - RT_OFFSETOF(DRVNIC, INetworkUp)) ) #define PDMINETWORKUP_2_DRVNIC(pInterface) ( (PDRVNIC)((uintptr_t)pInterface - RT_OFFSETOF(DRVNIC, INetworkUp)) )
#define PDMINETWORKCONFIG_2_DRVNIC(pInterface) ( (PDRVNIC)((uintptr_t)pInterface - RT_OFFSETOF(DRVNIC, INetworkConfig)) ) #define PDMINETWORKCONFIG_2_DRVNIC(pInterface) ( (PDRVNIC)((uintptr_t)pInterface - RT_OFFSETOF(DRVNIC, INetworkConfig)) )
@ -393,58 +416,6 @@ static DECLCALLBACK(int) drvGetMac(PPDMINETWORKCONFIG pInterface, PRTMAC pMac)
} }
/**
* Asynchronous I/O thread for handling receive.
*
* @returns VINF_SUCCESS (ignored).
* @param Thread Thread handle.
* @param pvUser Pointer to a DRVNIC structure.
*/
static DECLCALLBACK(int) drvNicAsyncIoThread(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
{
PDRVNIC pThis = PDMINS_2_DATA(pDrvIns, PDRVNIC);
LogFlow(("drvNicAsyncIoThread: pThis=%p\n", pThis));
if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
return VINF_SUCCESS;
Genode::Signal_receiver &sig_rec = pThis->nic_client->sig_rec();
while (pThread->enmState == PDMTHREADSTATE_RUNNING)
{
Genode::Signal sig = sig_rec.wait_for_signal();
int num = sig.num();
Genode::Signal_dispatcher_base *dispatcher;
dispatcher = dynamic_cast<Genode::Signal_dispatcher_base *>(sig.context());
dispatcher->dispatch(num);
}
destruct_lock()->unlock();
return VINF_SUCCESS;
}
/**
* Unblock the asynchronous I/O thread.
*
* @returns VBox status code.
* @param pDevIns The pcnet device instance.
* @param pThread The asynchronous I/O thread.
*/
static DECLCALLBACK(int) drvNicAsyncIoWakeup(PPDMDRVINS pDrvIns, PPDMTHREAD pThread)
{
PDRVNIC pThis = PDMINS_2_DATA(pDrvIns, PDRVNIC);
Nic_client *nic_client = pThis->nic_client;
if (nic_client)
Genode::Signal_transmitter(nic_client->dispatcher()).submit();
return VINF_SUCCESS;
}
/* -=-=-=-=- PDMIBASE -=-=-=-=- */ /* -=-=-=-=- PDMIBASE -=-=-=-=- */
/** /**
@ -549,15 +520,7 @@ static DECLCALLBACK(int) drvNicConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uin
return VERR_HOSTIF_INIT_FAILED; return VERR_HOSTIF_INIT_FAILED;
} }
/* return 0;
* Create the asynchronous I/O thread.
*/
rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pThread, pThis,
drvNicAsyncIoThread, drvNicAsyncIoWakeup,
128 * _1K, RTTHREADTYPE_IO, "nic_thread");
AssertRCReturn(rc, rc);
return rc;
} }

View File

@ -75,7 +75,7 @@ class Avl_ds : public Genode::Avl_node<Avl_ds>
genode_env().ram().free(_ds); genode_env().ram().free(_ds);
Genode::log("free up ", _size, " ", _mem_allocated, "/", Genode::log("free up ", _size, " ", _mem_allocated, "/",
_mem_unused, " hit=", hit, "/", hit_coarse, " avail=", _mem_unused, " hit=", hit, "/", hit_coarse, " avail=",
genode_env().ram().avail_ram()); genode_env().pd().avail_ram());
} }
void unused() void unused()
@ -140,7 +140,7 @@ class Avl_ds : public Genode::Avl_node<Avl_ds>
while (_unused_ds.first() && cbx && while (_unused_ds.first() && cbx &&
(_mem_allocated + cb > MEMORY_MAX || (_mem_allocated + cb > MEMORY_MAX ||
_mem_unused + cb > MEMORY_CACHED || _mem_unused + cb > MEMORY_CACHED ||
genode_env().ram().avail_ram().value < cb * 2 genode_env().pd().avail_ram().value < cb * 2
) )
) )
{ {

View File

@ -798,13 +798,13 @@ bool create_emt_vcpu(pthread_t * pthread, ::size_t stack,
vcpu_handler = new (0x10) Vcpu_handler_vmx(genode_env(), vcpu_handler = new (0x10) Vcpu_handler_vmx(genode_env(),
stack, start_routine, stack, start_routine,
arg, cpu_session, location, arg, cpu_session, location,
cpu_id, name, pd_vcpus); cpu_id, name, pd_vcpus.rpc_cap());
if (svm) if (svm)
vcpu_handler = new (0x10) Vcpu_handler_svm(genode_env(), vcpu_handler = new (0x10) Vcpu_handler_svm(genode_env(),
stack, start_routine, stack, start_routine,
arg, cpu_session, location, arg, cpu_session, location,
cpu_id, name, pd_vcpus); cpu_id, name, pd_vcpus.rpc_cap());
Assert(!(reinterpret_cast<unsigned long>(vcpu_handler) & 0xf)); Assert(!(reinterpret_cast<unsigned long>(vcpu_handler) & 0xf));

View File

@ -387,7 +387,7 @@ HRESULT genode_check_memory_config(ComObjPtr<Machine> machine)
return rc; return rc;
/* Request max available memory */ /* Request max available memory */
size_t memory_genode = genode_env().ram().avail_ram().value >> 20; size_t memory_genode = genode_env().pd().avail_ram().value >> 20;
size_t memory_vmm = 28; size_t memory_vmm = 28;
if (memory_vbox + memory_vmm > memory_genode) { if (memory_vbox + memory_vmm > memory_genode) {