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/signal.h>
#include <base/allocator.h>
namespace Qemu {
@ -102,7 +103,7 @@ 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,
Genode::Entrypoint &ep,
Genode::Allocator &, Genode::Env &);
/**

View File

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

View File

@ -185,15 +185,6 @@ class Libc::Env_implementation : public Libc::Env
void close(Parent::Client::Id id) override {
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 */
void exec_static_constructors() override { }

View File

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

View File

@ -220,14 +220,14 @@ struct Usb_host_device : List<Usb_host_device>::Element
Fifo<Isoc_packet> isoc_read_queue { };
Reconstructible<Isoc_packet> isoc_write_packet { Usb::Packet_descriptor(), nullptr };
Signal_receiver &sig_rec;
Signal_dispatcher<Usb_host_device> state_dispatcher { sig_rec, *this, &Usb_host_device::state_change };
Entrypoint &_ep;
Signal_handler<Usb_host_device> state_dispatcher { _ep, *this, &Usb_host_device::state_change };
Allocator &_alloc;
Allocator_avl _usb_alloc { &_alloc };
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()
{
@ -265,13 +265,13 @@ struct Usb_host_device : List<Usb_host_device>::Element
return result;
}
Usb_host_device(Signal_receiver &sig_rec, Allocator &alloc,
Usb_host_device(Entrypoint &ep, Allocator &alloc,
Env &env, char const *label,
Dev_info info)
:
label(label), _alloc(alloc),
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);
@ -300,7 +300,7 @@ struct Usb_host_device : List<Usb_host_device>::Element
}
}
void ack_avail(unsigned)
void ack_avail()
{
Lock::Guard g(_lock);
@ -461,7 +461,7 @@ struct Usb_host_device : List<Usb_host_device>::Element
qemu_dev = nullptr;
}
void state_change(unsigned)
void state_change()
{
Lock::Guard g(_lock);
if (usb_raw.plugged())
@ -876,10 +876,10 @@ static void usb_host_register_types(void)
struct Usb_devices : List<Usb_host_device>
{
Signal_receiver &_sig_rec;
Entrypoint &_ep;
Env &_env;
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" };
void _garbage_collect()
@ -903,7 +903,7 @@ struct Usb_devices : List<Usb_host_device>
fn(*d);
}
void _devices_update(unsigned)
void _devices_update()
{
Lock::Guard g(_lock);
@ -953,7 +953,7 @@ struct Usb_devices : List<Usb_host_device>
try {
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);
insert(new_device);
@ -974,8 +974,8 @@ struct Usb_devices : List<Usb_host_device>
_garbage_collect();
}
Usb_devices(Signal_receiver *sig_rec, Allocator &alloc, Env &env)
: _sig_rec(*sig_rec), _env(env), _alloc(alloc)
Usb_devices(Entrypoint &ep, Allocator &alloc, Env &env)
: _ep(ep), _env(env), _alloc(alloc)
{
_devices_rom.sigh(_device_dispatcher);
}
@ -1005,19 +1005,19 @@ extern "C" void usb_host_update_devices()
{
if (_devices == nullptr) return;
_devices->_devices_update(0);
_devices->_devices_update();
}
/*
* 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,
Env *env)
{
usb_host_register_types();
static Usb_devices devices(sig_rec, *alloc, *env);
static Usb_devices devices(*ep, *alloc, *env);
_devices = &devices;
}

View File

@ -14,7 +14,6 @@
/* Genode includes */
#include <base/env.h>
#include <base/printf.h>
#include <base/log.h>
#include <util/misc_math.h>
@ -36,7 +35,7 @@ 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::Entrypoint*,
Genode::Allocator*,
Genode::Env *);
extern "C" void _type_init_xhci_register_types();
@ -52,7 +51,7 @@ 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,
Genode::Entrypoint &ep,
Genode::Allocator &alloc, Genode::Env &env)
{
_heap = &alloc;
@ -61,7 +60,7 @@ Qemu::Controller *Qemu::usb_init(Timer_queue &tq, Pci_device &pci,
_type_init_usb_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();
}
@ -108,10 +107,14 @@ void *memset(void *s, int c, size_t n) {
void q_printf(char const *fmt, ...)
{
va_list va;
va_start(va, fmt);
Genode::vprintf(fmt, va);
va_end(va);
enum { BUF_SIZE = 128 };
char buf[BUF_SIZE] { };
va_list args;
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/printf.h>
#include <base/debug.h>
#include <framebuffer_session/connection.h>
#include <libc/component.h>
@ -155,7 +154,7 @@ void _eglutNativeEventLoop()
if (win->display_cb)
win->display_cb();
if (eglut_win.is_constructed()) {
if (eglut_win.constructed()) {
eglWaitClient();
eglSwapBuffers(_eglut->dpy, win->surface);
eglut_win->refresh();

View File

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

View File

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

View File

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

View File

@ -21,8 +21,6 @@
#include <base/attached_io_mem_dataspace.h>
#include <util/mmio.h>
#include <base/printf.h>
namespace Gpio {
class Reg;
@ -72,7 +70,7 @@ struct Gpio::Reg : Attached_io_mem_dataspace, Mmio
case 5: write<Int_con::Con5>(value); break;
case 6: write<Int_con::Con6>(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 <irq_session/connection.h>
#include <timer_session/connection.h>
#include <os/server.h>
/* local includes */
#include <board.h>

View File

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

View File

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

View File

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

View File

@ -21,25 +21,31 @@ class Irq_handler
{
private:
Genode::Irq_connection _irq;
Genode::Signal_receiver _sig_rec { };
Genode::Signal_dispatcher<Irq_handler> _dispatcher;
Genode::Env &_env;
Genode::Irq_connection _irq;
Genode::Signal_handler<Irq_handler> _handler;
void _handle(unsigned) { }
unsigned _sem_cnt = 1;
void _handle() { _sem_cnt = 0; }
public:
Irq_handler(Genode::Env &env, int irq_number)
:
_irq(env, irq_number),
_dispatcher(_sig_rec, *this, &Irq_handler::_handle)
_env(env), _irq(env, irq_number),
_handler(env.ep(), *this, &Irq_handler::_handle)
{
_irq.sigh(_dispatcher);
_irq.sigh(_handler);
_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(); }
};

View File

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

View File

@ -448,7 +448,7 @@ namespace Genode
/* Wait till MDIO interface is ready to accept a new transaction. */
while (!read<Status::Phy_mgmt_idle>()) {
if (timeout <= 0) {
PWRN("%s: Timeout\n", __func__);
warning(__func__, ": Timeout");
throw Phy_timeout_for_idle();
}
@ -644,7 +644,7 @@ namespace Genode
Genode::Packet_descriptor packet = _tx.sink()->get_packet();
if (!packet.size()) {
PWRN("Invalid tx packet");
Genode::warning("Invalid tx packet");
return true;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -21,6 +21,7 @@ SRC_CC += network.cpp
SRC_CC += audio.cc
INC_DIR += $(VBOX_DIR)/Devices/Audio
INC_DIR += $(call select_from_repositories,src/lib/libc)
vpath network.cpp $(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)
_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 =
@ -1418,7 +1418,7 @@ void Component::construct(Genode::Env &env)
Genode::log("--- Vancouver VMM starting ---");
/* request max available memory */
vm_size = env.ram().avail_ram().value;
vm_size = env.pd().avail_ram().value;
/* reserve some memory for the VMM */
vm_size -= 10 * 1024 * 1024;
/* 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;
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_2(env, Vcpu_o::SVM, "vcpu_o_2", 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.rpc_cap());
}

View File

@ -20,6 +20,9 @@
/* qemu-usb includes */
#include <qemu/usb.h>
/* libc internal includes */
#include <thread_create.h>
/* Virtualbox includes */
#define LOG_GROUP LOG_GROUP_DEV_EHCI
#include <VBox/pci.h>
@ -54,7 +57,6 @@ static bool const verbose_timer = false;
************************/
struct Timer_queue;
struct Destruction_helper;
struct XHCI
@ -74,15 +76,11 @@ struct XHCI
/** Address of the MMIO region assigned by PCI. */
RTGCPHYS32 MMIOBase;
/** Receiver thread that handles all USB signals. */
PPDMTHREAD pThread;
PTMTIMERR3 controller_timer;
Timer_queue *timer_queue;
Qemu::Controller *ctl;
Genode::Signal_receiver *usb_sig_rec;
Destruction_helper *destruction_helper;
Genode::Entrypoint *usb_ep;
};
@ -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 **
***********************************************/
@ -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}
*/
@ -459,9 +434,7 @@ static DECLCALLBACK(int) xhciR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFG
PXHCI pThis = PDMINS_2_DATA(pDevIns, PXHCI);
PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
pThis->usb_sig_rec = new (vmm_heap()) Genode::Signal_receiver();
pThis->destruction_helper = new (vmm_heap())
Destruction_helper(*(pThis->usb_sig_rec));
pThis->usb_ep = new Usb_ep(genode_env());
int rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, Timer_queue::tm_timer_cb,
pThis, TMTIMER_FLAGS_NO_CRIT_SECT,
@ -471,11 +444,7 @@ static DECLCALLBACK(int) xhciR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFG
pThis->timer_queue = &timer_queue;
static Pci_device pci_device(pDevIns);
rc = PDMDevHlpThreadCreate(pDevIns, &pThis->pThread, pThis,
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_ep,
vmm_heap(), genode_env());
/*

View File

@ -41,6 +41,8 @@
#include <nic/packet_allocator.h>
#include <base/snprintf.h>
#include <thread_create.h>
/* VBox Genode specific */
#include "vmm.h"
@ -74,6 +76,17 @@ typedef struct DRVNIC
} 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
{
private:
@ -85,12 +98,15 @@ class Nic_client
Nic::Packet_allocator *_tx_block_alloc;
Nic::Connection _nic;
Genode::Signal_receiver _sig_rec;
Genode::Signal_dispatcher<Nic_client> _link_state_dispatcher;
Genode::Signal_dispatcher<Nic_client> _rx_packet_avail_dispatcher;
Genode::Signal_dispatcher<Nic_client> _rx_ready_to_ack_dispatcher;
Genode::Signal_dispatcher<Nic_client> _destruct_dispatcher;
enum { NIC_EP_STACK = 32u << 10, };
Genode::Entrypoint _ep;
pthread_t _pthread;
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;
@ -98,7 +114,7 @@ class Nic_client
PPDMINETWORKDOWN _down_rx;
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()) {
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();
@ -127,12 +143,14 @@ class Nic_client
: PDMNETWORKLINKSTATE_DOWN);
}
/**
* By handling this signal the I/O thread gets unblocked
* and will leave its loop when the DRVNIC instance is
* being destructed.
*/
void _handle_destruct(unsigned) { }
void _handle_destruct()
{
_nic.link_state_sigh(Genode::Signal_context_capability());
_nic.rx_channel()->sigh_packet_avail(Genode::Signal_context_capability());
_nic.rx_channel()->sigh_ready_to_ack(Genode::Signal_context_capability());
destruct_lock()->unlock();
}
void _tx_ack(bool block = false)
{
@ -161,22 +179,39 @@ class Nic_client
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:
Nic_client(Genode::Env &env, PDRVNIC drvtap, char const *label)
:
_tx_block_alloc(_packet_allocator()),
_nic(env, _tx_block_alloc, BUF_SIZE, BUF_SIZE, label),
_link_state_dispatcher(_sig_rec, *this, &Nic_client::_handle_link_state),
_rx_packet_avail_dispatcher(_sig_rec, *this, &Nic_client::_handle_rx_packet_avail),
_rx_ready_to_ack_dispatcher(_sig_rec, *this, &Nic_client::_handle_rx_ready_to_ack),
_destruct_dispatcher(_sig_rec, *this, &Nic_client::_handle_destruct),
_ep(env, NIC_EP_STACK, "nic_ep", Genode::Affinity::Location()),
_link_state_dispatcher(_ep, *this, &Nic_client::_handle_link_state),
_rx_packet_avail_dispatcher(_ep, *this, &Nic_client::_handle_rx_packet_avail),
_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_config(drvtap->pIAboveConfig)
{ }
{
Genode::Signal_transmitter(_pthread_reg_sigh).submit();
}
~Nic_client()
{
/* XXX Libc::pthread_free(&_pthread); */
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);
/* set initial link-state */
_handle_link_state(1);
_handle_link_state();
}
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(); }
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. */
#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)) )
@ -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 -=-=-=-=- */
/**
@ -549,15 +520,7 @@ static DECLCALLBACK(int) drvNicConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uin
return VERR_HOSTIF_INIT_FAILED;
}
/*
* 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;
return 0;
}

View File

@ -75,7 +75,7 @@ class Avl_ds : public Genode::Avl_node<Avl_ds>
genode_env().ram().free(_ds);
Genode::log("free up ", _size, " ", _mem_allocated, "/",
_mem_unused, " hit=", hit, "/", hit_coarse, " avail=",
genode_env().ram().avail_ram());
genode_env().pd().avail_ram());
}
void unused()
@ -140,7 +140,7 @@ class Avl_ds : public Genode::Avl_node<Avl_ds>
while (_unused_ds.first() && cbx &&
(_mem_allocated + cb > MEMORY_MAX ||
_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(),
stack, start_routine,
arg, cpu_session, location,
cpu_id, name, pd_vcpus);
cpu_id, name, pd_vcpus.rpc_cap());
if (svm)
vcpu_handler = new (0x10) Vcpu_handler_svm(genode_env(),
stack, start_routine,
arg, cpu_session, location,
cpu_id, name, pd_vcpus);
cpu_id, name, pd_vcpus.rpc_cap());
Assert(!(reinterpret_cast<unsigned long>(vcpu_handler) & 0xf));

View File

@ -387,7 +387,7 @@ HRESULT genode_check_memory_config(ComObjPtr<Machine> machine)
return rc;
/* 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;
if (memory_vbox + memory_vmm > memory_genode) {