diff --git a/repos/ports/lib/mk/spec/nova/virtualbox5-hwaccl.mk b/repos/ports/lib/mk/spec/nova/virtualbox5-hwaccl.mk index 356af712aa..4c9cea2960 100644 --- a/repos/ports/lib/mk/spec/nova/virtualbox5-hwaccl.mk +++ b/repos/ports/lib/mk/spec/nova/virtualbox5-hwaccl.mk @@ -6,7 +6,7 @@ INC_DIR += $(call select_from_repositories,src/lib/libc) INC_DIR += $(call select_from_repositories,src/lib/pthread) INC_DIR += $(VBOX_DIR)/VMM/include -INC_DIR += $(REP_DIR)/src/virtualbox5 +INC_DIR += $(REP_DIR)/src/virtualbox vpath sup.cc $(REP_DIR)/src/virtualbox5/spec/nova/ vpath pgm.cc $(REP_DIR)/src/virtualbox5/spec/nova/ diff --git a/repos/ports/src/virtualbox/mm.cc b/repos/ports/src/virtualbox/mm.cc index 9e2096b674..ca4364ed63 100644 --- a/repos/ports/src/virtualbox/mm.cc +++ b/repos/ports/src/virtualbox/mm.cc @@ -32,55 +32,7 @@ #include #include "util.h" - - -/** - * Sub rm_session as backend for the Libc::Mem_alloc implementation. - * Purpose is that memory allocation by vbox of a specific type (MMTYP) are - * all located within a 2G virtual window. Reason is that virtualbox converts - * internally pointers at several places in base + offset, whereby offset is - * a int32_t type. - */ -class Sub_rm_connection : private Genode::Rm_connection, - public Genode::Region_map_client -{ - - private: - - Genode::addr_t const _offset; - Genode::size_t const _size; - - public: - - Sub_rm_connection(Genode::size_t size) - : - Genode::Region_map_client(Rm_connection::create(size)), - _offset(Genode::env()->rm_session()->attach(dataspace())), - _size(size) - { } - - Local_addr attach(Genode::Dataspace_capability ds, - Genode::size_t size = 0, Genode::off_t offset = 0, - bool use_local_addr = false, - Local_addr local_addr = (void *)0, - bool executable = false) - { - Local_addr addr = Region_map_client::attach(ds, size, offset, - use_local_addr, local_addr, - executable); - Genode::addr_t new_addr = addr; - new_addr += _offset; - return Local_addr(new_addr); - } - - bool contains(void * ptr) - { - Genode::addr_t addr = reinterpret_cast(ptr); - - return (_offset <= addr && addr < _offset + _size); - } - -}; +#include "mm.h" static struct { diff --git a/repos/ports/src/virtualbox5/mm.h b/repos/ports/src/virtualbox/mm.h similarity index 100% rename from repos/ports/src/virtualbox5/mm.h rename to repos/ports/src/virtualbox/mm.h diff --git a/repos/ports/src/virtualbox/rt.cc b/repos/ports/src/virtualbox/rt.cc index 523f7299db..a3de39f38f 100644 --- a/repos/ports/src/virtualbox/rt.cc +++ b/repos/ports/src/virtualbox/rt.cc @@ -26,6 +26,16 @@ #include #include +#include "mm.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: @@ -129,12 +139,6 @@ class Avl_ds : public Genode::Avl_node static void memory_freeup(Genode::addr_t const cb) { - /* free up memory if we hit some chosen limits */ - enum { - MEMORY_MAX = 64 * 1024 * 1024, - MEMORY_CACHED = 16 * 1024 * 1024, - }; - ::size_t cbx = cb * 4; while (_unused_ds.first() && cbx && (_mem_allocated + cb > MEMORY_MAX || @@ -219,9 +223,9 @@ static void *alloc_mem(size_t cb, const char *pszTag, bool executable = false) bool const any_addr = false; void * any_local_addr = nullptr; - void * local_addr = env()->rm_session()->attach(ds, whole_size, offset, - any_addr, any_local_addr, - executable); + void * local_addr = rt_memory.attach(ds, whole_size, offset, + any_addr, any_local_addr, + executable); Assert(local_addr); diff --git a/repos/ports/src/virtualbox/sup.h b/repos/ports/src/virtualbox/sup.h index b4da0175dc..b6272a81ad 100644 --- a/repos/ports/src/virtualbox/sup.h +++ b/repos/ports/src/virtualbox/sup.h @@ -23,7 +23,12 @@ #include #include +#if VBOX_VERSION_MAJOR == 4 #include "MachineImpl.h" +HRESULT genode_setup_machine(ComObjPtr machine); + +HRESULT genode_check_memory_config(ComObjPtr machine); +#endif /** * Returns true if a vCPU could be started. If false we run without @@ -46,8 +51,4 @@ Genode::Cpu_session * get_vcpu_cpu_session(); void genode_VMMR0_DO_GVMM_CREATE_VM(PSUPVMMR0REQHDR pReqHdr); void genode_VMMR0_DO_GVMM_REGISTER_VMCPU(PVMR0 pVMR0, VMCPUID idCpu); -HRESULT genode_setup_machine(ComObjPtr machine); - -HRESULT genode_check_memory_config(ComObjPtr machine); - #endif /* _SUP_H_ */ diff --git a/repos/ports/src/virtualbox5/sup.h b/repos/ports/src/virtualbox5/sup.h deleted file mode 100644 index 494eb72d0f..0000000000 --- a/repos/ports/src/virtualbox5/sup.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * \brief Common VirtualBox SUPLib supplements - * \author Norman Feske - * \date 2013-08-20 - */ - -/* - * Copyright (C) 2013 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _SUP_H_ -#define _SUP_H_ - -/* Genode includes */ -#include - -/* VirtualBox includes */ -#include -#include -#include - -/** - * Returns true if a vCPU could be started. If false we run without - * hardware acceleration support. - */ -bool create_emt_vcpu(pthread_t * pthread, ::size_t stack, - const pthread_attr_t *attr, - void *(*start_routine)(void *), void *arg, - Genode::Cpu_session * cpu_session, - Genode::Affinity::Location location, - unsigned int cpu_id, - const char * name); - - -uint64_t genode_cpu_hz(); -void genode_update_tsc(void (*update_func)(void), unsigned long update_us); - -Genode::Cpu_session * get_vcpu_cpu_session(); - -void genode_VMMR0_DO_GVMM_CREATE_VM(PSUPVMMR0REQHDR pReqHdr); -void genode_VMMR0_DO_GVMM_REGISTER_VMCPU(PVMR0 pVMR0, VMCPUID idCpu); - -#endif /* _SUP_H_ */ diff --git a/repos/ports/src/virtualbox5/target.mk b/repos/ports/src/virtualbox5/target.mk index aebfb660fa..f56706fcee 100644 --- a/repos/ports/src/virtualbox5/target.mk +++ b/repos/ports/src/virtualbox5/target.mk @@ -55,6 +55,9 @@ SRC_CC += frontend/dummy/errorinfo.cc frontend/dummy/virtualboxbase.cc SRC_CC += frontend/dummy/autostart.cc frontend/dummy/rest.cc SRC_CC += frontend/dummy/host.cc +#vbox 4 include +INC_DIR += $(REP_DIR)/src/virtualbox + INC_DIR += $(VBOX_DIR)/Main/include INC_DIR += $(VBOX_DIR)/VMM/include diff --git a/repos/ports/src/virtualbox5/util.h b/repos/ports/src/virtualbox5/util.h deleted file mode 100644 index d2779c59ff..0000000000 --- a/repos/ports/src/virtualbox5/util.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * \brief VirtualBox utilities - * \author Christian Helmuth - * \date 2013-08-28 - */ - -/* - * Copyright (C) 2013-2014 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _UTIL_H_ -#define _UTIL_H_ - -/* VirtualBox includes */ -#include - - -/** - * 64bit-aware cast of pointer to RTRCPTR (uint32_t) - */ -template -RTRCPTR to_rtrcptr(T* ptr) -{ - unsigned long long u64 = reinterpret_cast(ptr); - RTRCPTR rtrcptr = u64 & 0xFFFFFFFFULL; - - AssertMsg((u64 == rtrcptr) || (u64 >> 32) == 0xFFFFFFFFULL, - ("pointer transformation - %llx != %x", u64, rtrcptr)); - - return rtrcptr; -} - -#endif /* _UTIL_H_ */