diff --git a/repos/ports/run/vbox_auto_win7_share.run b/repos/ports/run/vbox_auto_win7_share.run
index 22d3d14cae..a5126c40e9 100644
--- a/repos/ports/run/vbox_auto_win7_share.run
+++ b/repos/ports/run/vbox_auto_win7_share.run
@@ -211,20 +211,19 @@ set config_of_app {
-
-
-
- }
+
+
+
+ }
append_if [expr $use_ram_fs] config_of_app {
- }
+ }
append config_of_app {
-
-
-
-
-
+
+
+
+
}
diff --git a/repos/ports/run/vbox_win.inc b/repos/ports/run/vbox_win.inc
index 3bacad6536..c6066396b9 100644
--- a/repos/ports/run/vbox_win.inc
+++ b/repos/ports/run/vbox_win.inc
@@ -252,30 +252,29 @@ for { set i 1} { $i <= $use_vms } { incr i} {
"
}
append config_of_app {
-
-
-
- }
+
+
+
+ }
append_if [expr !$use_rumpfs] config_of_app {
- }
+ }
append config_of_app {
- }
+ }
append_if [expr $use_ram_fs] config_of_app {
- }
+ }
append config_of_app "
- "
+ "
append_if [expr !$use_rumpfs] config_of_app "
- "
+ "
append_if [expr $use_rumpfs || $use_ram_fs] config_of_app {
- }
+ }
append config_of_app {
-
-
+
}
diff --git a/repos/ports/run/virtualbox.run b/repos/ports/run/virtualbox.run
index 8caaed9cd0..6983f515fa 100644
--- a/repos/ports/run/virtualbox.run
+++ b/repos/ports/run/virtualbox.run
@@ -119,18 +119,17 @@ append config {
-
-
- }
+
+
+ }
append_if [expr $use_serial] config {
- }
+ }
append config {
-
-
-
-
+
+
+
diff --git a/repos/ports/src/test/vmm_utils/main.cc b/repos/ports/src/test/vmm_utils/main.cc
index 3b419f6a35..af62020acc 100644
--- a/repos/ports/src/test/vmm_utils/main.cc
+++ b/repos/ports/src/test/vmm_utils/main.cc
@@ -94,7 +94,7 @@ void Component::construct(Genode::Env &env)
typedef Vcpu_dispatcher Vcpu_o;
- static Genode::Pd_connection remote_pd("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_2(env, Vcpu_o::SVM, "vcpu_o_2", remote_pd);
}
diff --git a/repos/ports/src/virtualbox/accloff/sup.cc b/repos/ports/src/virtualbox/accloff/sup.cc
index aa09ab22c7..0d3fbaf89a 100644
--- a/repos/ports/src/virtualbox/accloff/sup.cc
+++ b/repos/ports/src/virtualbox/accloff/sup.cc
@@ -107,7 +107,7 @@ void genode_update_tsc(void (*update_func)(void), unsigned long update_us)
{
using namespace Genode;
- Timer::Connection timer;
+ Timer::Connection timer(genode_env());
Signal_context sig_ctx;
Signal_receiver sig_rec;
Signal_context_capability sig_cap = sig_rec.manage(&sig_ctx);
diff --git a/repos/ports/src/virtualbox/audiodrv.cpp b/repos/ports/src/virtualbox/audiodrv.cpp
index d111d152bf..cf1397de77 100644
--- a/repos/ports/src/virtualbox/audiodrv.cpp
+++ b/repos/ports/src/virtualbox/audiodrv.cpp
@@ -30,6 +30,8 @@ extern "C" {
#include "audio_int.h"
}
+/* VBox Genode specific */
+#include "vmm.h"
template
struct A_ring_buffer_to_bind_them
@@ -278,12 +280,12 @@ static int genode_init_out(HWVoiceOut *hw, audsettings_t *as)
for (int i = 0; i < VBOX_CHANNELS; i++) {
try {
- out->audio[i] = new (Genode::env()->heap())
- Audio_out::Connection(channel_names[i]);
+ out->audio[i] = new (vmm_heap())
+ Audio_out::Connection(genode_env(), channel_names[i]);
} catch (...) {
Genode::error("could not establish Audio_out connection");
while (--i > 0)
- Genode::destroy(Genode::env()->heap(), out->audio[i]);
+ Genode::destroy(vmm_heap(), out->audio[i]);
return -1;
}
}
@@ -306,7 +308,7 @@ static void genode_fini_out(HWVoiceOut *hw)
{
GenodeVoiceOut * const out = (GenodeVoiceOut *)hw;
for (int i = 0; i < VBOX_CHANNELS; i++)
- Genode::destroy(Genode::env()->heap(), out->audio[i]);
+ Genode::destroy(vmm_heap(), out->audio[i]);
}
@@ -339,7 +341,7 @@ static int genode_init_in(HWVoiceIn *hw, audsettings_t *as)
GenodeVoiceIn *in = (GenodeVoiceIn*)hw;
try {
- in->audio = new (Genode::env()->heap()) Audio_in::Connection("left");
+ in->audio = new (vmm_heap()) Audio_in::Connection("left");
} catch (...) {
Genode::error("could not establish Audio_in connection");
return -1;
@@ -362,7 +364,7 @@ static int genode_init_in(HWVoiceIn *hw, audsettings_t *as)
static void genode_fini_in(HWVoiceIn *hw)
{
GenodeVoiceIn * const in = (GenodeVoiceIn*)hw;
- Genode::destroy(Genode::env()->heap(), in->audio);
+ Genode::destroy(vmm_heap(), in->audio);
}
diff --git a/repos/ports/src/virtualbox/devices.cc b/repos/ports/src/virtualbox/devices.cc
index 064c5fbe4e..ae9729cdd3 100644
--- a/repos/ports/src/virtualbox/devices.cc
+++ b/repos/ports/src/virtualbox/devices.cc
@@ -12,12 +12,13 @@
*/
/* Genode includes */
-#include
+#include
/* VirtualBox includes */
#include
#include
+#include "vmm.h"
#define REGISTER(device) \
do { \
@@ -79,7 +80,7 @@ extern "C" int VBoxDevicesRegister(PPDMDEVREGCB pCallbacks, uint32_t u32Version)
static bool read_force_ioapic_from_config()
{
try {
- Genode::Attached_rom_dataspace config("config");
+ Genode::Attached_rom_dataspace config(genode_env(), "config");
return config.xml().attribute_value("force_ioapic", false);
} catch (Genode::Rom_connection::Rom_connection_failed) {
return false;
diff --git a/repos/ports/src/virtualbox/devxhci.cc b/repos/ports/src/virtualbox/devxhci.cc
index 7cd08cf4f2..130680a93d 100644
--- a/repos/ports/src/virtualbox/devxhci.cc
+++ b/repos/ports/src/virtualbox/devxhci.cc
@@ -13,9 +13,8 @@
*/
/* Genode includes */
-#include
#include
-#include
+#include
#include
/* qemu-usb includes */
@@ -44,6 +43,8 @@
#include
#include
+/* VBox Genode specific */
+#include "vmm.h"
static bool const verbose_timer = false;
@@ -115,7 +116,7 @@ struct Timer_queue : public Qemu::Timer_queue
void _append_new_context(void *qtimer, void (*cb)(void*), void *data)
{
- Context *new_ctx = new (Genode::env()->heap()) Context(qtimer, cb, data);
+ Context *new_ctx = new (vmm_heap()) Context(qtimer, cb, data);
_context_list.insert(new_ctx);
}
@@ -255,7 +256,7 @@ struct Timer_queue : public Qemu::Timer_queue
_deactivate_timer(qtimer);
_context_list.remove(c);
- Genode::destroy(Genode::env()->heap(), c);
+ Genode::destroy(vmm_heap(), c);
}
void activate_timer(void *qtimer, long long int expire_abs) override
@@ -453,8 +454,8 @@ 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 (Genode::env()->heap()) Genode::Signal_receiver();
- pThis->destruction_helper = new (Genode::env()->heap())
+ pThis->usb_sig_rec = new (vmm_heap()) Genode::Signal_receiver();
+ pThis->destruction_helper = new (vmm_heap())
Destruction_helper(*(pThis->usb_sig_rec));
int rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, Timer_queue::tm_timer_cb,
@@ -575,7 +576,7 @@ const PDMDEVREG g_DeviceXHCI =
bool use_xhci_controller()
{
try {
- Genode::Attached_rom_dataspace config("config");
+ Genode::Attached_rom_dataspace config(genode_env(), "config");
return config.xml().attribute_value("xhci", false);
} catch (Genode::Rom_connection::Rom_connection_failed) {
return false;
diff --git a/repos/ports/src/virtualbox/frontend/console.cc b/repos/ports/src/virtualbox/frontend/console.cc
index e50c791778..a330f2c004 100644
--- a/repos/ports/src/virtualbox/frontend/console.cc
+++ b/repos/ports/src/virtualbox/frontend/console.cc
@@ -28,6 +28,7 @@
#include "console.h"
#include "fb.h"
+#include "../vmm.h"
static const bool debug = false;
@@ -134,7 +135,7 @@ void fireStateChangedEvent(IEventSource* aSource,
if (a_state != MachineState_PoweredOff)
return;
- Genode::env()->parent()->exit(0);
+ genode_env().parent().exit(0);
}
void fireRuntimeErrorEvent(IEventSource* aSource, BOOL a_fatal,
@@ -348,7 +349,7 @@ void GenodeConsole::init_clipboard()
if (mode == ClipboardMode_Bidirectional ||
mode == ClipboardMode_HostToGuest) {
- _clipboard_rom = new Genode::Attached_rom_dataspace("clipboard");
+ _clipboard_rom = new Genode::Attached_rom_dataspace(genode_env(), "clipboard");
_clipboard_rom->sigh(_clipboard_signal_dispatcher);
clipboard_rom = _clipboard_rom;
@@ -357,7 +358,7 @@ void GenodeConsole::init_clipboard()
if (mode == ClipboardMode_Bidirectional ||
mode == ClipboardMode_GuestToHost) {
- _clipboard_reporter = new Genode::Reporter("clipboard");
+ _clipboard_reporter = new Genode::Reporter(genode_env(), "clipboard");
_clipboard_reporter->enabled(true);
clipboard_reporter = _clipboard_reporter;
diff --git a/repos/ports/src/virtualbox/frontend/console.h b/repos/ports/src/virtualbox/frontend/console.h
index 59905cf0a9..6c3b8e71ee 100644
--- a/repos/ports/src/virtualbox/frontend/console.h
+++ b/repos/ports/src/virtualbox/frontend/console.h
@@ -17,8 +17,8 @@
#include
#include
#include
-#include
-#include
+#include
+#include
#include
#include
#include
@@ -29,10 +29,11 @@
/* repos/ports includes */
#include
+#include "../vmm.h"
+
/* VirtualBox includes */
#include "ConsoleImpl.h"
-
class Scan_code
{
private:
@@ -139,10 +140,12 @@ class GenodeConsole : public Console {
GenodeConsole()
:
Console(),
+ _input(genode_env()),
_ax(0), _ay(0),
_last_received_motion_event_was_absolute(false),
- _shape_report_connection("shape", sizeof(Vbox_pointer::Shape_report)),
- _shape_report_ds(_shape_report_connection.dataspace()),
+ _shape_report_connection(genode_env(), "shape",
+ sizeof(Vbox_pointer::Shape_report)),
+ _shape_report_ds(genode_env().rm(), _shape_report_connection.dataspace()),
_shape_report(_shape_report_ds.local_addr()),
_clipboard_reporter(nullptr),
_clipboard_rom(nullptr),
diff --git a/repos/ports/src/virtualbox/frontend/fb.h b/repos/ports/src/virtualbox/frontend/fb.h
index 66ae8327f1..b61f487802 100644
--- a/repos/ports/src/virtualbox/frontend/fb.h
+++ b/repos/ports/src/virtualbox/frontend/fb.h
@@ -26,6 +26,7 @@ class Genodefb :
{
private:
+ Genode::Env &_env;
Fb_Genode::Connection _fb;
/* The mode matching the currently attached dataspace */
@@ -52,12 +53,14 @@ class Genodefb :
public:
- Genodefb ()
+ Genodefb (Genode::Env &env)
:
+ _env(env),
+ _fb(env, Fb_Genode::Mode(0, 0, Fb_Genode::Mode::INVALID)),
_fb_mode(_fb.mode()),
_next_fb_mode(_fb_mode),
_virtual_fb_mode(_fb_mode),
- _fb_base(Genode::env()->rm_session()->attach(_fb.dataspace()))
+ _fb_base(env.rm().attach(_fb.dataspace()))
{
int rc = RTCritSectInit(&_fb_lock);
Assert(rc == VINF_SUCCESS);
@@ -165,9 +168,9 @@ class Genodefb :
_virtual_fb_mode = Fb_Genode::Mode(w, h, Fb_Genode::Mode::RGB565);
- Genode::env()->rm_session()->detach(_fb_base);
+ _env.rm().detach(_fb_base);
- _fb_base = Genode::env()->rm_session()->attach(_fb.dataspace());
+ _fb_base = _env.rm().attach(_fb.dataspace());
result = S_OK;
diff --git a/repos/ports/src/virtualbox/frontend/main.cc b/repos/ports/src/virtualbox/frontend/main.cc
index a6f56fb86a..cfcb631536 100644
--- a/repos/ports/src/virtualbox/frontend/main.cc
+++ b/repos/ports/src/virtualbox/frontend/main.cc
@@ -14,9 +14,10 @@
/* Genode includes */
+#include
+#include
#include
#include
-#include
/* Virtualbox includes */
#include
@@ -87,7 +88,7 @@ RTDECL(int) RTPathUserHome(char *pszPath, size_t cchPath)
}
-HRESULT setupmachine()
+HRESULT setupmachine(Genode::Env &env)
{
HRESULT rc;
@@ -152,7 +153,7 @@ HRESULT setupmachine()
unsigned uScreenId;
for (uScreenId = 0; uScreenId < cMonitors; uScreenId++)
{
- Genodefb *fb = new Genodefb();
+ Genodefb *fb = new Genodefb(env);
display->SetFramebuffer(uScreenId, fb);
}
@@ -194,7 +195,7 @@ HRESULT setupmachine()
}
-static Genode::Env *genode_env_ptr;
+static Genode::Env *genode_env_ptr = nullptr;
Genode::Env &genode_env()
@@ -207,6 +208,13 @@ Genode::Env &genode_env()
}
+Genode::Allocator &vmm_heap()
+{
+ static Genode::Heap heap (genode_env().ram(), genode_env().rm());
+ return heap;
+}
+
+
void Libc::Component::construct(Libc::Env &env)
{
/* make Genode environment accessible via the global 'genode_env()' */
@@ -215,10 +223,10 @@ void Libc::Component::construct(Libc::Env &env)
try {
using namespace Genode;
- Xml_node node = config()->xml_node();
- Xml_node::Attribute vbox_file = node.attribute("vbox_file");
+ Attached_rom_dataspace config(env, "config");
+ Xml_node::Attribute vbox_file = config.xml().attribute("vbox_file");
vbox_file.value(c_vbox_file, sizeof(c_vbox_file));
- Xml_node::Attribute vm_name = node.attribute("vm_name");
+ Xml_node::Attribute vm_name = config.xml().attribute("vm_name");
vm_name.value(c_vbox_vmname, sizeof(c_vbox_vmname));
} catch (...) {
Genode::error("missing attributes in configuration, minimum requirements: ");
@@ -237,7 +245,7 @@ void Libc::Component::construct(Libc::Env &env)
if (RT_FAILURE(rc))
throw -1;
- HRESULT hrc = setupmachine();
+ HRESULT hrc = setupmachine(env);
if (FAILED(hrc)) {
Genode::error("startup of VMM failed - reason ", hrc, " - exiting ...");
throw -2;
diff --git a/repos/ports/src/virtualbox/guest_memory.h b/repos/ports/src/virtualbox/guest_memory.h
index 618e35a9cd..5291f9253a 100644
--- a/repos/ports/src/virtualbox/guest_memory.h
+++ b/repos/ports/src/virtualbox/guest_memory.h
@@ -16,29 +16,19 @@
#ifndef _GUEST_MEMORY_H_
#define _GUEST_MEMORY_H_
-/*
- * Work-around for a naming conflict between the enum definition of PAGE_SIZE
- * in 'os/attached_ram_dataspace.h' and the VirtualBox #define with the same
- * name.
- */
-#define BACKUP_PAGESIZE PAGE_SIZE
-#undef PAGE_SIZE
-
/* Genode includes */
-#include
#include
#include
#include
#include
-#include
+
+#include "vmm.h"
/* VirtualBox includes */
#include
#include
#include
-#define PAGE_SIZE BACKUP_PAGESIZE
-
class Guest_memory
{
@@ -246,7 +236,7 @@ class Guest_memory
/*
* XXX check for overlapping regions
*/
- _ram_regions.insert(new (Genode::env()->heap())
+ _ram_regions.insert(new (vmm_heap())
Region(GCPhys, cb, pv, 0, 0, 0, 0, 0, 0));
}
@@ -259,7 +249,7 @@ class Guest_memory
/*
* XXX check for overlapping regions
*/
- _rom_regions.insert(new (Genode::env()->heap())
+ _rom_regions.insert(new (vmm_heap())
Region(GCPhys, cb,
(void *)pv, pDevIns, 0, 0, 0, 0, 0));
}
@@ -278,7 +268,7 @@ class Guest_memory
/*
* XXX check for overlapping regions
*/
- _mmio_regions.insert(new (Genode::env()->heap())
+ _mmio_regions.insert(new (vmm_heap())
Region(GCPhys, cb, 0,
pDevIns, pvUser, pfnWriteCallback,
pfnReadCallback, pfnFillCallback, fFlags));
diff --git a/repos/ports/src/virtualbox/ioport.cc b/repos/ports/src/virtualbox/ioport.cc
index a5802bba78..bf79bdbb16 100644
--- a/repos/ports/src/virtualbox/ioport.cc
+++ b/repos/ports/src/virtualbox/ioport.cc
@@ -15,13 +15,14 @@
#include
#include
#include
-#include
/* VirtualBox includes */
#include
#include
#include
+#include "vmm.h"
+
static bool verbose = false;
class Guest_ioports
@@ -169,7 +170,7 @@ class Guest_ioports
Genode::Hex(cPorts), " - '",
pDevIns && pDevIns->pReg ? pDevIns->pReg->szName : 0, "'");
- _ranges.insert(new (Genode::env()->heap())
+ _ranges.insert(new (vmm_heap())
Range(pDevIns, PortStart, cPorts, pvUser,
pfnOutCallback, pfnInCallback,
pfnOutStringCallback, pfnInStringCallback));
@@ -203,7 +204,7 @@ class Guest_ioports
r = r->next();
_ranges.remove(s);
- destroy(Genode::env()->heap(), s);
+ destroy(vmm_heap(), s);
}
return deleted ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
diff --git a/repos/ports/src/virtualbox/mm.cc b/repos/ports/src/virtualbox/mm.cc
index ca4364ed63..aa8725f909 100644
--- a/repos/ports/src/virtualbox/mm.cc
+++ b/repos/ports/src/virtualbox/mm.cc
@@ -33,7 +33,7 @@
#include "util.h"
#include "mm.h"
-
+#include "vmm.h"
static struct {
Sub_rm_connection * conn;
@@ -56,7 +56,7 @@ static Libc::Mem_alloc * heap_by_mmtag(MMTAG enmTag)
if (memory_regions[enmTag].conn)
return memory_regions[enmTag].heap;
- memory_regions[enmTag].conn = new Sub_rm_connection(REGION_SIZE);
+ memory_regions[enmTag].conn = new Sub_rm_connection(genode_env(), REGION_SIZE);
memory_regions[enmTag].heap = new Libc::Mem_alloc_impl(memory_regions[enmTag].conn);
return memory_regions[enmTag].heap;
diff --git a/repos/ports/src/virtualbox/mm.h b/repos/ports/src/virtualbox/mm.h
index f2bcd5533f..328062cca0 100644
--- a/repos/ports/src/virtualbox/mm.h
+++ b/repos/ports/src/virtualbox/mm.h
@@ -35,10 +35,11 @@ class Sub_rm_connection : private Genode::Rm_connection,
public:
- Sub_rm_connection(Genode::size_t size)
+ Sub_rm_connection(Genode::Env &env, Genode::size_t size)
:
+ Rm_connection(env),
Genode::Region_map_client(Rm_connection::create(size)),
- _offset(Genode::env()->rm_session()->attach(dataspace())),
+ _offset(env.rm().attach(dataspace())),
_size(size)
{ }
diff --git a/repos/ports/src/virtualbox/network.cpp b/repos/ports/src/virtualbox/network.cpp
index efd3e0fbf2..d34e85b2a8 100644
--- a/repos/ports/src/virtualbox/network.cpp
+++ b/repos/ports/src/virtualbox/network.cpp
@@ -41,6 +41,9 @@
#include
#include
+/* VBox Genode specific */
+#include "vmm.h"
+
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
@@ -155,16 +158,15 @@ class Nic_client
static Nic::Packet_allocator* _packet_allocator()
{
- using namespace Genode;
- return new (env()->heap())Nic::Packet_allocator(env()->heap());
+ return new (vmm_heap()) Nic::Packet_allocator(&vmm_heap());
}
public:
- Nic_client(PDRVNIC drvtap, char const *label)
+ Nic_client(Genode::Env &env, PDRVNIC drvtap, char const *label)
:
_tx_block_alloc(_packet_allocator()),
- _nic(_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),
_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),
@@ -175,8 +177,7 @@ class Nic_client
~Nic_client()
{
- using namespace Genode;
- destroy(env()->heap(), _tx_block_alloc);
+ destroy(vmm_heap(), _tx_block_alloc);
}
void enable_signals()
@@ -478,7 +479,7 @@ static DECLCALLBACK(void) drvNicDestruct(PPDMDRVINS pDrvIns)
destruct_lock()->lock();
if (nic_client)
- destroy(Genode::env()->heap(), nic_client);
+ destroy(vmm_heap(), nic_client);
}
@@ -543,7 +544,7 @@ static DECLCALLBACK(int) drvNicConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uin
* Setup Genode nic_session connection
*/
try {
- pThis->nic_client = new (Genode::env()->heap()) Nic_client(pThis, label);
+ pThis->nic_client = new (vmm_heap()) Nic_client(genode_env(), pThis, label);
} catch (...) {
return VERR_HOSTIF_INIT_FAILED;
}
diff --git a/repos/ports/src/virtualbox/pgm.cc b/repos/ports/src/virtualbox/pgm.cc
index 54c463ab84..c237460d00 100644
--- a/repos/ports/src/virtualbox/pgm.cc
+++ b/repos/ports/src/virtualbox/pgm.cc
@@ -36,7 +36,7 @@ using Genode::Rm_session;
Vmm_memory *vmm_memory()
{
- static Vmm_memory inst(*Genode::env()->ram_session());
+ static Vmm_memory inst(genode_env());
return &inst;
}
diff --git a/repos/ports/src/virtualbox/rt.cc b/repos/ports/src/virtualbox/rt.cc
index a3de39f38f..7ea867a571 100644
--- a/repos/ports/src/virtualbox/rt.cc
+++ b/repos/ports/src/virtualbox/rt.cc
@@ -13,7 +13,6 @@
/* Genode includes */
#include
-#include
#include
@@ -27,15 +26,13 @@
#include
#include "mm.h"
+#include "vmm.h"
enum {
MEMORY_MAX = 64 * 1024 * 1024,
MEMORY_CACHED = 16 * 1024 * 1024,
};
-/* using managed dataspace to have all addresses within a 1 << 31 bit range */
-static Sub_rm_connection rt_memory(2 * MEMORY_MAX);
-
class Avl_ds : public Genode::Avl_node
{
private:
@@ -75,10 +72,10 @@ class Avl_ds : public Genode::Avl_node
_mem_unused -= _size;
_mem_allocated -= _size;
- Genode::env()->ram_session()->free(_ds);
+ genode_env().ram().free(_ds);
Genode::log("free up ", _size, " ", _mem_allocated, "/",
_mem_unused, " hit=", hit, "/", hit_coarse, " avail=",
- Genode::env()->ram_session()->avail());
+ genode_env().ram().avail());
}
void unused()
@@ -143,7 +140,7 @@ class Avl_ds : public Genode::Avl_node
while (_unused_ds.first() && cbx &&
(_mem_allocated + cb > MEMORY_MAX ||
_mem_unused + cb > MEMORY_CACHED ||
- Genode::env()->ram_session()->avail() < cb * 2
+ genode_env().ram().avail() < cb * 2
)
)
{
@@ -153,7 +150,7 @@ class Avl_ds : public Genode::Avl_node
continue;
}
- destroy(Genode::env()->heap(), ds_free);
+ destroy(vmm_heap(), ds_free);
}
}
@@ -188,6 +185,9 @@ Genode::addr_t Avl_ds::_mem_unused = 0;
static void *alloc_mem(size_t cb, const char *pszTag, bool executable = false)
{
+ /* using managed dataspace to have all addresses within a 1 << 31 bit range */
+ static Sub_rm_connection rt_memory(genode_env(), 2 * MEMORY_MAX);
+
using namespace Genode;
if (!cb)
@@ -215,7 +215,7 @@ static void *alloc_mem(size_t cb, const char *pszTag, bool executable = false)
Avl_ds::memory_freeup(cb);
try {
- Ram_dataspace_capability ds = env()->ram_session()->alloc(cb);
+ Ram_dataspace_capability ds = genode_env().ram().alloc(cb);
Assert(ds.valid());
Genode::size_t const whole_size = 0;
@@ -229,7 +229,7 @@ static void *alloc_mem(size_t cb, const char *pszTag, bool executable = false)
Assert(local_addr);
- new (env()->heap()) Avl_ds(ds, local_addr, cb);
+ new (vmm_heap()) Avl_ds(ds, local_addr, cb);
return local_addr;
} catch (...) {
diff --git a/repos/ports/src/virtualbox/spec/muen/guest_interrupts.h b/repos/ports/src/virtualbox/spec/muen/guest_interrupts.h
index 45fc5124c2..f76229979d 100644
--- a/repos/ports/src/virtualbox/spec/muen/guest_interrupts.h
+++ b/repos/ports/src/virtualbox/spec/muen/guest_interrupts.h
@@ -17,7 +17,6 @@
/* Genode includes */
#include
-#include
namespace Genode
{
diff --git a/repos/ports/src/virtualbox/spec/muen/mem_region.h b/repos/ports/src/virtualbox/spec/muen/mem_region.h
index 500bb051f1..d31d9825a0 100644
--- a/repos/ports/src/virtualbox/spec/muen/mem_region.h
+++ b/repos/ports/src/virtualbox/spec/muen/mem_region.h
@@ -20,7 +20,7 @@
#include
#include
#include
-#include
+#include
#include
#include
@@ -33,7 +33,6 @@ struct Mem_region;
struct Mem_region : Genode::List::Element,
Genode::Attached_io_mem_dataspace
{
- typedef Genode::Ram_session Ram_session;
typedef Genode::size_t size_t;
typedef Genode::addr_t addr_t;
@@ -46,7 +45,7 @@ struct Mem_region : Genode::List::Element,
size_t region_size;
bool _clear;
- addr_t _phys_base(size_t size)
+ addr_t _phys_base(Genode::Env &env, size_t size)
{
struct Region_info
{
@@ -77,10 +76,8 @@ struct Mem_region : Genode::List::Element,
Region_info cur_region;
if (!counter) {
- Genode::Rom_connection sinfo_rom("subject_info_page");
- Genode::Sinfo sinfo
- ((addr_t)Genode::env()->rm_session()->attach
- (sinfo_rom.dataspace()));
+ Genode::Rom_connection sinfo_rom(env, "subject_info_page");
+ Genode::Sinfo sinfo ((addr_t)env.rm().attach (sinfo_rom.dataspace()));
struct Genode::Sinfo::Memregion_info region1, region4;
if (!sinfo.get_memregion_info("vm_ram_1", ®ion1)) {
@@ -119,10 +116,10 @@ struct Mem_region : Genode::List::Element,
size_t size() const { return region_size; }
- Mem_region(Ram_session &ram, size_t size, PPDMDEVINS pDevIns,
- unsigned iRegion)
+ Mem_region(Genode::Env &env, size_t size,
+ PPDMDEVINS pDevIns, unsigned iRegion)
:
- Attached_io_mem_dataspace(_phys_base(size), size),
+ Attached_io_mem_dataspace(env, _phys_base(env, size), size),
pDevIns(pDevIns),
iRegion(iRegion),
vm_phys(0), pfnHandlerR3(0), pvUserR3(0),
diff --git a/repos/ports/src/virtualbox/spec/muen/sup.cc b/repos/ports/src/virtualbox/spec/muen/sup.cc
index d252adace7..13c2d71733 100644
--- a/repos/ports/src/virtualbox/spec/muen/sup.cc
+++ b/repos/ports/src/virtualbox/spec/muen/sup.cc
@@ -16,7 +16,7 @@
/* Genode includes */
#include
#include
-#include
+#include
#include
#include
@@ -75,8 +75,6 @@ enum {
cur_state->REG.base = pCtx->REG.u64Base; \
cur_state->REG.access = pCtx->REG.Attr.u ? : VMCS_SEG_UNUSABLE
-static Genode::Vm_handler vm_handler;
-
struct Subject_state *cur_state;
Genode::Guest_interrupts *guest_interrupts;
@@ -92,9 +90,9 @@ static Genode::Sinfo * sinfo()
if (!ptr) {
try {
- static Rom_connection sinfo_rom("subject_info_page");
+ static Rom_connection sinfo_rom(genode_env(), "subject_info_page");
static Sinfo sinfo(
- (addr_t)env()->rm_session()->attach(sinfo_rom.dataspace()));
+ (addr_t)genode_env().rm().attach(sinfo_rom.dataspace()));
ptr = &sinfo;
} catch (...) {
error("unable to attach Sinfo ROM");
@@ -123,8 +121,9 @@ bool setup_subject_state()
}
try {
- static Attached_io_mem_dataspace subject_ds(region.address,
- region.size);
+ static Attached_io_mem_dataspace subject_ds(genode_env(),
+ region.address,
+ region.size);
cur_state = subject_ds.local_addr();
return true;
} catch (...) {
@@ -152,8 +151,9 @@ bool setup_subject_interrupts()
}
try {
- static Attached_io_mem_dataspace subject_intrs(region.address,
- region.size);
+ static Attached_io_mem_dataspace subject_intrs(genode_env(),
+ region.address,
+ region.size);
static Guest_interrupts g((addr_t)subject_intrs.local_addr());
guest_interrupts = &g;
return true;
@@ -392,6 +392,8 @@ int SUPR3QueryVTxSupported(void) { return VINF_SUCCESS; }
int SUPR3CallVMMR0Fast(PVMR0 pVMR0, unsigned uOperation, VMCPUID idCpu)
{
+ static Genode::Vm_handler vm_handler(genode_env());
+
switch (uOperation) {
case SUP_VMMR0_DO_HM_RUN:
@@ -718,7 +720,7 @@ void genode_update_tsc(void (*update_func)(void), unsigned long update_us)
{
using namespace Genode;
- Timer::Connection timer;
+ Timer::Connection timer(genode_env());
Signal_context sig_ctx;
Signal_receiver sig_rec;
Signal_context_capability sig_cap = sig_rec.manage(&sig_ctx);
diff --git a/repos/ports/src/virtualbox/spec/muen/vm_handler.h b/repos/ports/src/virtualbox/spec/muen/vm_handler.h
index a9a42ad9f7..a262ed5fa6 100644
--- a/repos/ports/src/virtualbox/spec/muen/vm_handler.h
+++ b/repos/ports/src/virtualbox/spec/muen/vm_handler.h
@@ -13,7 +13,6 @@
#ifndef _VIRTUALBOX__SPEC__MUEN__VM_HANDLER_H_
#define _VIRTUALBOX__SPEC__MUEN__VM_HANDLER_H_
-#include
#include
#include
@@ -34,21 +33,22 @@ class Genode::Vm_handler
Vm_connection _vm_session;
Signal_context_capability _sig_cap;
- Signal_receiver *_sig_rcv;
+ Signal_receiver _sig_rcv;
Signal_transmitter _sig_xmit;
Signal_context _sig_ctx;
public:
- Vm_handler()
+ Vm_handler(Genode::Env &env)
+ :
+ _vm_session(env)
{
- _sig_rcv = new (env()->heap())Signal_receiver();
- _sig_cap = _sig_rcv->manage(&_sig_ctx);
+ _sig_cap = _sig_rcv.manage(&_sig_ctx);
_sig_xmit.context(_sig_cap);
_vm_session.exception_handler(_sig_cap);
}
- ~Vm_handler() { _sig_rcv->dissolve(&_sig_ctx); }
+ ~Vm_handler() { _sig_rcv.dissolve(&_sig_ctx); }
/**
* Starts execution of the Vm and blocks until the Vm returns or the
@@ -57,7 +57,7 @@ class Genode::Vm_handler
void run_vm()
{
_vm_session.run();
- _sig_rcv->wait_for_signal();
+ _sig_rcv.wait_for_signal();
}
};
diff --git a/repos/ports/src/virtualbox/spec/nova/sup.cc b/repos/ports/src/virtualbox/spec/nova/sup.cc
index 209c8214da..feb68392e8 100644
--- a/repos/ports/src/virtualbox/spec/nova/sup.cc
+++ b/repos/ports/src/virtualbox/spec/nova/sup.cc
@@ -18,7 +18,7 @@
#include
#include
#include
-#include
+#include
#include
#include
@@ -35,6 +35,7 @@
#include
/* Genode's VirtualBox includes */
+#include "vmm.h"
#include "vcpu.h"
#include "vcpu_svm.h"
#include "vcpu_vmx.h"
@@ -64,20 +65,22 @@ static Vcpu_handler *lookup_vcpu_handler(unsigned int cpu_id)
/* Genode specific function */
-static Genode::Attached_rom_dataspace hip_rom("hypervisor_info_page");
+Nova::Hip &hip_rom()
+{
+ static Genode::Attached_rom_dataspace hip_rom(genode_env(),
+ "hypervisor_info_page");
+ return *hip_rom.local_addr();
+}
void SUPR3QueryHWACCLonGenodeSupport(VM * pVM)
{
try {
- Nova::Hip * hip = hip_rom.local_addr();
+ pVM->hm.s.svm.fSupported = hip_rom().has_feature_svm();
+ pVM->hm.s.vmx.fSupported = hip_rom().has_feature_vmx();
- pVM->hm.s.svm.fSupported = hip->has_feature_svm();
- pVM->hm.s.vmx.fSupported = hip->has_feature_vmx();
-
- if (hip->has_feature_svm() || hip->has_feature_vmx()) {
- Genode::log("Using ",
- hip->has_feature_svm() ? "SVM" : "VMX", " "
- "virtualization extension.");
+ if (hip_rom().has_feature_svm() || hip_rom().has_feature_vmx()) {
+ Genode::log("Using ", hip_rom().has_feature_svm() ? "SVM" : "VMX",
+ " virtualization extension.");
return;
}
} catch (...) { /* if we get an exception let hardware support off */ }
@@ -192,14 +195,7 @@ uint64_t genode_cpu_hz()
if (!cpu_freq) {
try {
- using namespace Genode;
-
- Rom_connection hip_rom("hypervisor_info_page");
-
- Nova::Hip * const hip = env()->rm_session()->attach(hip_rom.dataspace());
-
- cpu_freq = hip->tsc_freq * 1000;
-
+ cpu_freq = hip_rom().tsc_freq * 1000;
} catch (...) {
Genode::error("could not read out CPU frequency");
Genode::Lock lock;
@@ -282,7 +278,7 @@ extern "C" void pthread_yield(void)
void *operator new (__SIZE_TYPE__ size, int log2_align)
{
- static Libc::Mem_alloc_impl heap(Genode::env()->rm_session());
+ static Libc::Mem_alloc_impl heap(&genode_env().rm());
return heap.alloc(size, log2_align);
}
@@ -294,22 +290,20 @@ bool create_emt_vcpu(pthread_t * pthread, size_t stack,
Genode::Affinity::Location location,
unsigned int cpu_id, const char * name)
{
- Nova::Hip * hip = hip_rom.local_addr();
-
- if (!hip->has_feature_vmx() && !hip->has_feature_svm())
+ if (!hip_rom().has_feature_vmx() && !hip_rom().has_feature_svm())
return false;
- static Genode::Pd_connection pd_vcpus("VM");
+ static Genode::Pd_connection pd_vcpus(genode_env(), "VM");
Vcpu_handler *vcpu_handler = 0;
- if (hip->has_feature_vmx())
+ if (hip_rom().has_feature_vmx())
vcpu_handler = new (0x10) Vcpu_handler_vmx(genode_env(),
stack, attr, start_routine,
arg, cpu_session, location,
cpu_id, name, pd_vcpus);
- if (hip->has_feature_svm())
+ if (hip_rom().has_feature_svm())
vcpu_handler = new (0x10) Vcpu_handler_svm(genode_env(),
stack, attr, start_routine,
arg, cpu_session, location,
diff --git a/repos/ports/src/virtualbox/spec/nova/vcpu.h b/repos/ports/src/virtualbox/spec/nova/vcpu.h
index 6d5085383f..9e1bd1e819 100644
--- a/repos/ports/src/virtualbox/spec/nova/vcpu.h
+++ b/repos/ports/src/virtualbox/spec/nova/vcpu.h
@@ -18,6 +18,7 @@
/* Genode includes */
#include
#include
+#include
#include
#include
diff --git a/repos/ports/src/virtualbox/sup.cc b/repos/ports/src/virtualbox/sup.cc
index 416e71537f..ddfa298000 100644
--- a/repos/ports/src/virtualbox/sup.cc
+++ b/repos/ports/src/virtualbox/sup.cc
@@ -12,11 +12,12 @@
*/
/* Genode includes */
-#include
+#include
#include
/* Genode/Virtualbox includes */
#include "sup.h"
+#include "vmm.h"
/* VirtualBox includes */
#include
@@ -31,7 +32,7 @@
struct Attached_gip : Genode::Attached_ram_dataspace
{
Attached_gip()
- : Attached_ram_dataspace(Genode::env()->ram_session(), PAGE_SIZE)
+ : Attached_ram_dataspace(genode_env().ram(), genode_env().rm(), PAGE_SIZE)
{ }
};
@@ -46,9 +47,9 @@ enum {
PSUPGLOBALINFOPAGE g_pSUPGlobalInfoPage;
-struct Periodic_gip : public Genode::Thread_deprecated<2*4096>
+struct Periodic_gip : public Genode::Thread
{
- Periodic_gip() : Thread_deprecated("periodic_gip") { start(); }
+ Periodic_gip(Genode::Env &env) : Thread(env, "periodic_gip", 8192) { start(); }
static void update()
{
@@ -147,7 +148,7 @@ int SUPR3Init(PSUPDRVSESSION *ppSession)
cpu->idApic = 0;
/* schedule periodic call of GIP update function */
- static Periodic_gip periodic_gip;
+ static Periodic_gip periodic_gip (genode_env());
initialized = true;
@@ -331,7 +332,7 @@ HRESULT genode_check_memory_config(ComObjPtr machine)
return rc;
/* Request max available memory */
- size_t memory_genode = Genode::env()->ram_session()->avail() >> 20;
+ size_t memory_genode = genode_env().ram().avail() >> 20;
size_t memory_vmm = 28;
if (memory_vbox + memory_vmm > memory_genode) {
diff --git a/repos/ports/src/virtualbox/sup.h b/repos/ports/src/virtualbox/sup.h
index 5c5ae73404..30955a858e 100644
--- a/repos/ports/src/virtualbox/sup.h
+++ b/repos/ports/src/virtualbox/sup.h
@@ -48,8 +48,6 @@ void genode_update_tsc(void (*update_func)(void), unsigned long update_us);
Genode::Cpu_session * get_vcpu_cpu_session();
-Genode::Env &genode_env();
-
void genode_VMMR0_DO_GVMM_CREATE_VM(PSUPVMMR0REQHDR pReqHdr);
void genode_VMMR0_DO_GVMM_REGISTER_VMCPU(PVMR0 pVMR0, VMCPUID idCpu);
diff --git a/repos/ports/src/virtualbox/target.mk b/repos/ports/src/virtualbox/target.mk
index 11548679ae..d7e7cc63a0 100644
--- a/repos/ports/src/virtualbox/target.mk
+++ b/repos/ports/src/virtualbox/target.mk
@@ -21,7 +21,6 @@ SRC_CC = frontend/main.cc frontend/console.cc \
hm.cc thread.cc dynlib.cc unimpl.cc
LIBS += base
-LIBS += config_args
LIBS += stdcxx
LIBS += virtualbox-bios virtualbox-recompiler virtualbox-runtime \
diff --git a/repos/ports/src/virtualbox/thread.cc b/repos/ports/src/virtualbox/thread.cc
index b745f624b9..1ab1bfd81b 100644
--- a/repos/ports/src/virtualbox/thread.cc
+++ b/repos/ports/src/virtualbox/thread.cc
@@ -14,13 +14,13 @@
/* Genode */
#include
#include
-#include
#include
/* Genode libc pthread binding */
#include "thread.h"
#include "sup.h"
+#include "vmm.h"
/* libc */
#include
@@ -51,11 +51,11 @@ static Genode::Cpu_connection * cpu_connection(RTTHREADTYPE type) {
long const prio = (VIRTUAL_GENODE_VBOX_LEVELS - type) *
Cpu_session::PRIORITY_LIMIT / VIRTUAL_GENODE_VBOX_LEVELS;
- char * data = new (env()->heap()) char[16];
+ char * data = new (vmm_heap()) char[16];
Genode::snprintf(data, 16, "vbox %u", type);
- con[type - 1] = new (env()->heap()) Cpu_connection(data, prio);
+ con[type - 1] = new (vmm_heap()) Cpu_connection(genode_env(), data, prio);
return con[type - 1];
}
@@ -98,7 +98,7 @@ static int create_thread(pthread_t *thread, const pthread_attr_t *attr,
*/
}
- pthread_t thread_obj = new (Genode::env()->heap())
+ pthread_t thread_obj = new (vmm_heap())
pthread(attr ? *attr : 0, start_routine,
arg, stack_size, rtthread->szName,
cpu_connection(rtthread->enmType),
diff --git a/repos/ports/src/virtualbox/vmm.h b/repos/ports/src/virtualbox/vmm.h
new file mode 100644
index 0000000000..c72e764007
--- /dev/null
+++ b/repos/ports/src/virtualbox/vmm.h
@@ -0,0 +1,10 @@
+#ifndef _VMM_H_
+#define _VMM_H_
+
+#include
+#include
+
+Genode::Env & genode_env();
+Genode::Allocator & vmm_heap();
+
+#endif /* _VMM_H_ */
diff --git a/repos/ports/src/virtualbox/vmm_memory.h b/repos/ports/src/virtualbox/vmm_memory.h
index ecbe6d0f86..bd375aa43f 100644
--- a/repos/ports/src/virtualbox/vmm_memory.h
+++ b/repos/ports/src/virtualbox/vmm_memory.h
@@ -14,14 +14,6 @@
#ifndef _VMM_MEMORY_H_
#define _VMM_MEMORY_H_
-/*
- * Work-around for a naming conflict between the enum definition of PAGE_SIZE
- * in 'os/attached_ram_dataspace.h' and the VirtualBox #define with the same
- * name.
- */
-#define BACKUP_PAGESIZE PAGE_SIZE
-#undef PAGE_SIZE
-
/* Genode includes */
#include
#include
@@ -29,8 +21,7 @@
/* Genode/Virtualbox includes */
#include "mem_region.h"
-
-#define PAGE_SIZE BACKUP_PAGESIZE
+#include "vmm.h"
/* VirtualBox includes */
#include
@@ -38,21 +29,19 @@
class Vmm_memory
{
- typedef Genode::Ram_session Ram_session;
- typedef Genode::Region_map Region_map;
typedef Genode::size_t size_t;
typedef Genode::Lock Lock;
typedef Genode::List Mem_region_list;
private:
- Lock _lock;
- Mem_region_list _regions;
+ Lock _lock;
+ Mem_region_list _regions;
+ Genode::Env &_env;
/**
* Backing store
*/
- Genode::Ram_session &_ram;
Mem_region *_lookup_unsynchronized(PPDMDEVINS pDevIns, unsigned iRegion)
{
@@ -75,7 +64,7 @@ class Vmm_memory
public:
- Vmm_memory(Ram_session &ram) : _ram(ram) { }
+ Vmm_memory(Genode::Env &env) : _env(env) { }
/**
* \throw Ram_session::Alloc_failed
@@ -86,17 +75,17 @@ class Vmm_memory
Lock::Guard guard(_lock);
try {
- Mem_region *r = new (Genode::env()->heap())
- Mem_region(_ram, cb, pDevIns, iRegion);
+ Mem_region *r = new (vmm_heap()) Mem_region(_env, cb,
+ pDevIns, iRegion);
_regions.insert(r);
return r->local_addr();
- } catch (Ram_session::Alloc_failed) {
+ } catch (Genode::Ram_session::Alloc_failed) {
Genode::error("Vmm_memory::alloc(", Genode::Hex(cb), "): "
"RAM allocation failed");
throw;
- } catch (Region_map::Attach_failed) {
+ } catch (Genode::Region_map::Attach_failed) {
Genode::error("Vmm_memory::alloc(", Genode::Hex(cb), "): "
"RM attach failed");
throw;
diff --git a/repos/ports/src/virtualbox/vmm_region.h b/repos/ports/src/virtualbox/vmm_region.h
index 3ba70d93a1..a12f683090 100644
--- a/repos/ports/src/virtualbox/vmm_region.h
+++ b/repos/ports/src/virtualbox/vmm_region.h
@@ -30,9 +30,6 @@ struct Mem_region : public Genode::List::Element,
private Genode::Rm_connection,
public Genode::Region_map_client
{
- typedef Genode::Ram_session Ram_session;
- typedef Genode::Region_map Region_map;
-
PPDMDEVINS pDevIns;
unsigned const iRegion;
RTGCPHYS vm_phys;
@@ -43,14 +40,16 @@ struct Mem_region : public Genode::List::Element,
Genode::addr_t _base;
Genode::size_t _size;
- Mem_region(Ram_session &ram, size_t size, PPDMDEVINS pDevIns,
- unsigned iRegion, unsigned sub_rm_max_ds = 32 * 1024 * 1024)
+ Mem_region(Genode::Env &env, size_t size,
+ PPDMDEVINS pDevIns, unsigned iRegion,
+ unsigned sub_rm_max_ds = 32 * 1024 * 1024)
:
+ Rm_connection(env),
Region_map_client(Rm_connection::create(size)),
pDevIns(pDevIns),
iRegion(iRegion),
vm_phys(0), pfnHandlerR3(0), pvUserR3(0),
- _base(Genode::env()->rm_session()->attach(Region_map_client::dataspace())),
+ _base(env.rm().attach(Region_map_client::dataspace())),
_size(size)
{
@@ -58,7 +57,7 @@ struct Mem_region : public Genode::List::Element,
Genode::addr_t map_size = rest_size < sub_rm_max_ds ? rest_size : sub_rm_max_ds;
do {
- Genode::Ram_dataspace_capability ds = Genode::env()->ram_session()->alloc(map_size);
+ Genode::Ram_dataspace_capability ds = env.ram().alloc(map_size);
attach_at(ds, _size - rest_size, map_size);
rest_size -= map_size;
diff --git a/repos/ports/src/virtualbox5/devices.cc b/repos/ports/src/virtualbox5/devices.cc
index 6f0d3ba511..2450f7bd5b 100644
--- a/repos/ports/src/virtualbox5/devices.cc
+++ b/repos/ports/src/virtualbox5/devices.cc
@@ -12,12 +12,13 @@
*/
/* Genode includes */
-#include
+#include
/* VirtualBox includes */
#include
#include
+#include "vmm.h"
#define REGISTER(device) \
do { \
@@ -75,7 +76,7 @@ extern "C" int VBoxDevicesRegister(PPDMDEVREGCB pCallbacks, uint32_t u32Version)
static bool read_force_ioapic_from_config()
{
try {
- Genode::Attached_rom_dataspace config("config");
+ Genode::Attached_rom_dataspace config(genode_env(), "config");
return config.xml().attribute_value("force_ioapic", false);
} catch (Genode::Rom_connection::Rom_connection_failed) {
return false;
diff --git a/repos/ports/src/virtualbox5/frontend/console.cc b/repos/ports/src/virtualbox5/frontend/console.cc
index 3b36b9fb68..88aaf43099 100644
--- a/repos/ports/src/virtualbox5/frontend/console.cc
+++ b/repos/ports/src/virtualbox5/frontend/console.cc
@@ -27,6 +27,7 @@
#include "console.h"
#include "fb.h"
+#include "vmm.h"
static const bool debug = false;
@@ -73,7 +74,7 @@ void fireStateChangedEvent(IEventSource* aSource,
if (a_state != MachineState_PoweredOff)
return;
- Genode::env()->parent()->exit(0);
+ genode_env().parent().exit(0);
}
void fireRuntimeErrorEvent(IEventSource* aSource, BOOL a_fatal,
@@ -296,7 +297,7 @@ void GenodeConsole::init_clipboard()
if (mode == ClipboardMode_Bidirectional ||
mode == ClipboardMode_HostToGuest) {
- _clipboard_rom = new Genode::Attached_rom_dataspace("clipboard");
+ _clipboard_rom = new Genode::Attached_rom_dataspace(genode_env(), "clipboard");
_clipboard_rom->sigh(_clipboard_signal_dispatcher);
clipboard_rom = _clipboard_rom;
@@ -305,7 +306,7 @@ void GenodeConsole::init_clipboard()
if (mode == ClipboardMode_Bidirectional ||
mode == ClipboardMode_GuestToHost) {
- _clipboard_reporter = new Genode::Reporter("clipboard");
+ _clipboard_reporter = new Genode::Reporter(genode_env(), "clipboard");
_clipboard_reporter->enabled(true);
clipboard_reporter = _clipboard_reporter;
diff --git a/repos/ports/src/virtualbox5/frontend/console.h b/repos/ports/src/virtualbox5/frontend/console.h
index 65a001f1f4..ab77999a7d 100644
--- a/repos/ports/src/virtualbox5/frontend/console.h
+++ b/repos/ports/src/virtualbox5/frontend/console.h
@@ -17,8 +17,8 @@
#include
#include
#include
-#include
-#include
+#include
+#include
#include
#include
#include
@@ -29,10 +29,11 @@
/* repos/ports includes */
#include
+#include "../vmm.h"
+
/* VirtualBox includes */
#include "ConsoleImpl.h"
-
class Scan_code
{
private:
@@ -139,10 +140,12 @@ class GenodeConsole : public Console {
GenodeConsole()
:
Console(),
+ _input(genode_env()),
_ax(0), _ay(0),
_last_received_motion_event_was_absolute(false),
- _shape_report_connection("shape", sizeof(Vbox_pointer::Shape_report)),
- _shape_report_ds(_shape_report_connection.dataspace()),
+ _shape_report_connection(genode_env(), "shape",
+ sizeof(Vbox_pointer::Shape_report)),
+ _shape_report_ds(genode_env().rm(), _shape_report_connection.dataspace()),
_shape_report(_shape_report_ds.local_addr()),
_clipboard_reporter(nullptr),
_clipboard_rom(nullptr),
diff --git a/repos/ports/src/virtualbox5/frontend/fb.h b/repos/ports/src/virtualbox5/frontend/fb.h
index 2930e524e3..3716af933b 100644
--- a/repos/ports/src/virtualbox5/frontend/fb.h
+++ b/repos/ports/src/virtualbox5/frontend/fb.h
@@ -31,6 +31,7 @@ class Genodefb :
{
private:
+ Genode::Env &_env;
Fb_Genode::Connection _fb;
/* The mode matching the currently attached dataspace */
@@ -57,12 +58,14 @@ class Genodefb :
public:
- Genodefb ()
+ Genodefb (Genode::Env &env)
:
+ _env(env),
+ _fb(env, Fb_Genode::Mode(0, 0, Fb_Genode::Mode::INVALID)),
_fb_mode(_fb.mode()),
_next_fb_mode(_fb_mode),
_virtual_fb_mode(_fb_mode),
- _fb_base(Genode::env()->rm_session()->attach(_fb.dataspace()))
+ _fb_base(env.rm().attach(_fb.dataspace()))
{
int rc = RTCritSectInit(&_fb_lock);
Assert(rc == VINF_SUCCESS);
@@ -120,9 +123,9 @@ class Genodefb :
_virtual_fb_mode = Fb_Genode::Mode(w, h, Fb_Genode::Mode::RGB565);
- Genode::env()->rm_session()->detach(_fb_base);
+ _env.rm().detach(_fb_base);
- _fb_base = Genode::env()->rm_session()->attach(_fb.dataspace());
+ _fb_base = _env.rm().attach(_fb.dataspace());
result = S_OK;
diff --git a/repos/ports/src/virtualbox5/frontend/main.cc b/repos/ports/src/virtualbox5/frontend/main.cc
index c9810c6c58..9a414865bd 100644
--- a/repos/ports/src/virtualbox5/frontend/main.cc
+++ b/repos/ports/src/virtualbox5/frontend/main.cc
@@ -14,9 +14,10 @@
/* Genode includes */
+#include
+#include
#include
#include
-#include
/* Virtualbox includes */
#include
@@ -35,12 +36,14 @@
/* Genode port specific includes */
#include "console.h"
#include "fb.h"
+#include "vmm.h"
static char c_vbox_file[128];
static char c_vbox_vmname[128];
extern "C" void init_libc_vbox_logger(void);
+
/**
* xpcom style memory allocation
*/
@@ -88,7 +91,7 @@ RTDECL(int) RTPathUserHome(char *pszPath, size_t cchPath)
extern "C" VirtualBox * genode_global_vbox_pointer;
VirtualBox * genode_global_vbox_pointer = nullptr;
-HRESULT setupmachine()
+HRESULT setupmachine(Genode::Env &env)
{
HRESULT rc;
@@ -118,11 +121,9 @@ HRESULT setupmachine()
return rc;
rc = virtualbox->RegisterMachine(machine);
-
if (FAILED(rc))
return rc;
-
// open a session
ComObjPtr session;
rc = session.createObject();
@@ -140,7 +141,7 @@ HRESULT setupmachine()
return rc;
/* request max available memory */
- size_t memory_genode = Genode::env()->ram_session()->avail() >> 20;
+ size_t memory_genode = genode_env().ram().avail() >> 20;
size_t memory_vmm = 28;
if (memory_vbox + memory_vmm > memory_genode) {
@@ -181,7 +182,7 @@ HRESULT setupmachine()
unsigned uScreenId;
for (uScreenId = 0; uScreenId < cMonitors; uScreenId++)
{
- Genodefb *fb = new Genodefb();
+ Genodefb *fb = new Genodefb(env);
HRESULT rc = display->AttachFramebuffer(uScreenId, fb, gaFramebufferId[uScreenId].asOutParam());
if (FAILED(rc))
return rc;
@@ -225,7 +226,7 @@ HRESULT setupmachine()
}
-static Genode::Env *genode_env_ptr;
+static Genode::Env *genode_env_ptr = nullptr;
Genode::Env &genode_env()
@@ -238,6 +239,13 @@ Genode::Env &genode_env()
}
+Genode::Allocator &vmm_heap()
+{
+ static Genode::Heap heap (genode_env().ram(), genode_env().rm());
+ return heap;
+}
+
+
void Libc::Component::construct(Libc::Env &env)
{
/* make Genode environment accessible via the global 'genode_env()' */
@@ -246,10 +254,10 @@ void Libc::Component::construct(Libc::Env &env)
try {
using namespace Genode;
- Xml_node node = config()->xml_node();
- Xml_node::Attribute vbox_file = node.attribute("vbox_file");
+ Attached_rom_dataspace config(env, "config");
+ Xml_node::Attribute vbox_file = config.xml().attribute("vbox_file");
vbox_file.value(c_vbox_file, sizeof(c_vbox_file));
- Xml_node::Attribute vm_name = node.attribute("vm_name");
+ Xml_node::Attribute vm_name = config.xml().attribute("vm_name");
vm_name.value(c_vbox_vmname, sizeof(c_vbox_vmname));
} catch (...) {
Genode::error("missing attributes in configuration, minimum requirements: ");
@@ -268,7 +276,7 @@ void Libc::Component::construct(Libc::Env &env)
if (RT_FAILURE(rc))
throw -1;
- HRESULT hrc = setupmachine();
+ HRESULT hrc = setupmachine(env);
if (FAILED(hrc)) {
Genode::error("startup of VMM failed - reason ", hrc, " '",
RTErrCOMGet(hrc)->pszMsgFull, "' - exiting ...");
diff --git a/repos/ports/src/virtualbox5/mm.cc b/repos/ports/src/virtualbox5/mm.cc
index 0ae1d80342..847bfb9a65 100644
--- a/repos/ports/src/virtualbox5/mm.cc
+++ b/repos/ports/src/virtualbox5/mm.cc
@@ -16,7 +16,7 @@
#include
#include
-#include
+#include
/* VirtualBox includes */
#include
@@ -35,6 +35,7 @@
#include "util.h"
#include "mm.h"
+#include "vmm.h"
enum { VERBOSE_MM = false };
@@ -59,7 +60,7 @@ static Libc::Mem_alloc * heap_by_mmtag(MMTAG enmTag)
if (memory_regions[enmTag].conn)
return memory_regions[enmTag].heap;
- memory_regions[enmTag].conn = new Sub_rm_connection(REGION_SIZE);
+ memory_regions[enmTag].conn = new Sub_rm_connection(genode_env(), REGION_SIZE);
memory_regions[enmTag].heap = new Libc::Mem_alloc_impl(memory_regions[enmTag].conn);
return memory_regions[enmTag].heap;
@@ -433,7 +434,9 @@ VMMDECL(RTHCPHYS) MMPage2Phys(PVM pVM, void *pvPage) {
VMMR3DECL(void *) MMR3PageAlloc(PVM pVM)
{
using Genode::Attached_ram_dataspace;
- Attached_ram_dataspace * ds = new Attached_ram_dataspace(Genode::env()->ram_session(), 4096);
+ Attached_ram_dataspace * ds = new Attached_ram_dataspace(genode_env().ram(),
+ genode_env().rm(),
+ 4096);
return ds->local_addr();
}
diff --git a/repos/ports/src/virtualbox5/spec/nova/sup.cc b/repos/ports/src/virtualbox5/spec/nova/sup.cc
index a5bdac5149..0981b3ec0f 100644
--- a/repos/ports/src/virtualbox5/spec/nova/sup.cc
+++ b/repos/ports/src/virtualbox5/spec/nova/sup.cc
@@ -18,8 +18,8 @@
#include
#include
#include
-#include
-#include
+#include
+#include
#include
#include
@@ -29,6 +29,7 @@
#include
/* Genode's VirtualBox includes */
+#include "vmm.h"
#include "vcpu.h"
#include "vcpu_svm.h"
#include "vcpu_vmx.h"
@@ -40,11 +41,6 @@
extern "C" bool PGMUnmapMemoryGenode(void *, ::size_t);
-/* XXX does not work on 32bit host - since vm memory is from 0 - 4G and
- * such large areas can't be attached to a process
- * We need several sub_rm areas .... XXX
- */
-static Sub_rm_connection vm_memory((sizeof(void *) == 4 ? 2UL : 4UL) * 1024 * 1024 * 1024);
static Genode::List &vcpu_handler_list()
{
@@ -67,19 +63,23 @@ static Vcpu_handler *lookup_vcpu_handler(unsigned int cpu_id)
/* Genode specific function */
-static Genode::Attached_rom_dataspace hip_rom("hypervisor_info_page");
+Nova::Hip &hip_rom()
+{
+ static Genode::Attached_rom_dataspace hip_rom(genode_env(),
+ "hypervisor_info_page");
+ return *hip_rom.local_addr();
+}
+
void SUPR3QueryHWACCLonGenodeSupport(VM * pVM)
{
try {
- Nova::Hip * hip = hip_rom.local_addr();
+ pVM->hm.s.svm.fSupported = hip_rom().has_feature_svm();
+ pVM->hm.s.vmx.fSupported = hip_rom().has_feature_vmx();
- pVM->hm.s.svm.fSupported = hip->has_feature_svm();
- pVM->hm.s.vmx.fSupported = hip->has_feature_vmx();
-
- if (hip->has_feature_svm() || hip->has_feature_vmx()) {
- Genode::log("Using ", hip->has_feature_svm() ? "SVM " : "VMX ",
- "virtualization extension.");
+ if (hip_rom().has_feature_svm() || hip_rom().has_feature_vmx()) {
+ Genode::log("Using ", hip_rom().has_feature_svm() ? "SVM" : "VMX",
+ " virtualization extension.");
return;
}
} catch (...) { /* if we get an exception let hardware support off */ }
@@ -113,7 +113,9 @@ int SUPR3PageAllocEx(::size_t cPages, uint32_t fFlags, void **ppvPages,
" r3=", ppvPages, " r0=", pR0Ptr);
using Genode::Attached_ram_dataspace;
- Attached_ram_dataspace * ds = new Attached_ram_dataspace(Genode::env()->ram_session(), cPages * 4096); /* XXX PAGE_SIZE ? */
+ Attached_ram_dataspace * ds = new Attached_ram_dataspace(genode_env().ram(),
+ genode_env().rm(),
+ cPages * 4096); /* XXX PAGE_SIZE ? */
*ppvPages = ds->local_addr();
if (pR0Ptr)
*pR0Ptr = reinterpret_cast(*ppvPages);
@@ -136,6 +138,12 @@ int SUPR3PageAllocEx(::size_t cPages, uint32_t fFlags, void **ppvPages,
int SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned
uOperation, uint64_t u64Arg, PSUPVMMR0REQHDR pReqHdr)
{
+ /* XXX does not work on 32bit host - since vm memory is from 0 - 4G and
+ * such large areas can't be attached to a process
+ * We need several sub_rm areas .... XXX
+ */
+ static Sub_rm_connection vm_memory(genode_env(), (sizeof(void *) == 4 ? 2UL : 4UL) * 1024 * 1024 * 1024);
+
static unsigned long chunkid = 1500;
switch (uOperation) {
@@ -251,7 +259,7 @@ int SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned
Assert(req->idChunkUnmap == NIL_GMM_CHUNKID);
Assert(req->idChunkMap != NIL_GMM_CHUNKID);
- Genode::Ram_dataspace_capability ds = Genode::env()->ram_session()->alloc(GMM_CHUNK_SIZE);
+ Genode::Ram_dataspace_capability ds = genode_env().ram().alloc(GMM_CHUNK_SIZE);
Genode::addr_t local_addr_offset = (req->idChunkMap - 1) << GMM_CHUNK_SHIFT;
enum { OFFSET_DS = 0, USE_LOCAL_ADDR = true };
@@ -462,16 +470,9 @@ uint64_t genode_cpu_hz()
if (!cpu_freq) {
try {
- using namespace Genode;
-
- Rom_connection hip_rom("hypervisor_info_page");
-
- Nova::Hip * const hip = env()->rm_session()->attach(hip_rom.dataspace());
-
- cpu_freq = hip->tsc_freq * 1000;
-
+ cpu_freq = hip_rom().tsc_freq * 1000;
} catch (...) {
- Genode::error("could not read out CPU frequency.");
+ Genode::error("could not read out CPU frequency");
Genode::Lock lock;
lock.lock();
}
@@ -543,7 +544,7 @@ extern "C" void pthread_yield(void)
void *operator new (__SIZE_TYPE__ size, int log2_align)
{
- static Libc::Mem_alloc_impl heap(Genode::env()->rm_session());
+ static Libc::Mem_alloc_impl heap(&genode_env().rm());
return heap.alloc(size, log2_align);
}
@@ -555,22 +556,20 @@ bool create_emt_vcpu(pthread_t * pthread, ::size_t stack,
Genode::Affinity::Location location,
unsigned int cpu_id, const char * name)
{
- Nova::Hip * hip = hip_rom.local_addr();
-
- if (!hip->has_feature_vmx() && !hip->has_feature_svm())
+ if (!hip_rom().has_feature_vmx() && !hip_rom().has_feature_svm())
return false;
- static Genode::Pd_connection pd_vcpus("VM");
+ static Genode::Pd_connection pd_vcpus(genode_env(), "VM");
Vcpu_handler *vcpu_handler = 0;
- if (hip->has_feature_vmx())
+ if (hip_rom().has_feature_vmx())
vcpu_handler = new (0x10) Vcpu_handler_vmx(genode_env(),
stack, attr, start_routine,
arg, cpu_session, location,
cpu_id, name, pd_vcpus);
- if (hip->has_feature_svm())
+ if (hip_rom().has_feature_svm())
vcpu_handler = new (0x10) Vcpu_handler_svm(genode_env(),
stack, attr, start_routine,
arg, cpu_session, location,
diff --git a/repos/ports/src/virtualbox5/sup.cc b/repos/ports/src/virtualbox5/sup.cc
index 00f82977ff..c046afb49b 100644
--- a/repos/ports/src/virtualbox5/sup.cc
+++ b/repos/ports/src/virtualbox5/sup.cc
@@ -12,7 +12,7 @@
*/
/* Genode includes */
-#include
+#include
#include
/* Genode/Virtualbox includes */
@@ -27,6 +27,7 @@
/* libc memory allocator */
#include
+#include "vmm.h"
enum {
UPDATE_HZ = 1000,
@@ -38,9 +39,9 @@ enum {
PSUPGLOBALINFOPAGE g_pSUPGlobalInfoPage;
-struct Periodic_gip : public Genode::Thread_deprecated<4096>
+struct Periodic_gip : public Genode::Thread
{
- Periodic_gip() : Thread_deprecated("periodic_gip") { start(); }
+ Periodic_gip(Genode::Env &env) : Thread(env, "periodic_gip", 8192) { start(); }
static void update()
{
@@ -98,7 +99,7 @@ struct Periodic_gip : public Genode::Thread_deprecated<4096>
struct Attached_gip : Genode::Attached_ram_dataspace
{
Attached_gip()
- : Attached_ram_dataspace(Genode::env()->ram_session(), PAGE_SIZE)
+ : Attached_ram_dataspace(genode_env().ram(), genode_env().rm(), PAGE_SIZE)
{
g_pSUPGlobalInfoPage = local_addr();
@@ -134,13 +135,15 @@ struct Attached_gip : Genode::Attached_ram_dataspace
cpu->idApic = 0;
/* schedule periodic call of GIP update function */
- static Periodic_gip periodic_gip;
+ static Periodic_gip periodic_gip(genode_env());
}
-} static gip;
+};
int SUPR3Init(PSUPDRVSESSION *ppSession)
{
+ static Attached_gip gip;
+
return VINF_SUCCESS;
}
diff --git a/repos/ports/src/virtualbox5/target.mk b/repos/ports/src/virtualbox5/target.mk
index 6ff303307d..410d684d0c 100644
--- a/repos/ports/src/virtualbox5/target.mk
+++ b/repos/ports/src/virtualbox5/target.mk
@@ -23,7 +23,6 @@ vpath rt.cc $(REP_DIR)/src/virtualbox
vpath thread.cc $(REP_DIR)/src/virtualbox
LIBS += base
-LIBS += config_args
LIBS += stdcxx
LIBS += virtualbox5-bios virtualbox5-recompiler virtualbox5-runtime \