parent
aeb76b9c3c
commit
07b994c8bd
|
@ -6,7 +6,7 @@ INC_DIR += $(call select_from_repositories,src/lib/libc)
|
||||||
INC_DIR += $(call select_from_repositories,src/lib/pthread)
|
INC_DIR += $(call select_from_repositories,src/lib/pthread)
|
||||||
|
|
||||||
INC_DIR += $(VBOX_DIR)/VMM/include
|
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 sup.cc $(REP_DIR)/src/virtualbox5/spec/nova/
|
||||||
vpath pgm.cc $(REP_DIR)/src/virtualbox5/spec/nova/
|
vpath pgm.cc $(REP_DIR)/src/virtualbox5/spec/nova/
|
||||||
|
|
|
@ -32,55 +32,7 @@
|
||||||
#include <libc_mem_alloc.h>
|
#include <libc_mem_alloc.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "mm.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<Genode::addr_t>(ptr);
|
|
||||||
|
|
||||||
return (_offset <= addr && addr < _offset + _size);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
|
|
@ -26,6 +26,16 @@
|
||||||
#include <iprt/time.h>
|
#include <iprt/time.h>
|
||||||
#include <internal/iprt.h>
|
#include <internal/iprt.h>
|
||||||
|
|
||||||
|
#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<Avl_ds>
|
class Avl_ds : public Genode::Avl_node<Avl_ds>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -129,12 +139,6 @@ class Avl_ds : public Genode::Avl_node<Avl_ds>
|
||||||
|
|
||||||
static void memory_freeup(Genode::addr_t const cb)
|
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;
|
::size_t cbx = cb * 4;
|
||||||
while (_unused_ds.first() && cbx &&
|
while (_unused_ds.first() && cbx &&
|
||||||
(_mem_allocated + cb > MEMORY_MAX ||
|
(_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;
|
bool const any_addr = false;
|
||||||
void * any_local_addr = nullptr;
|
void * any_local_addr = nullptr;
|
||||||
|
|
||||||
void * local_addr = env()->rm_session()->attach(ds, whole_size, offset,
|
void * local_addr = rt_memory.attach(ds, whole_size, offset,
|
||||||
any_addr, any_local_addr,
|
any_addr, any_local_addr,
|
||||||
executable);
|
executable);
|
||||||
|
|
||||||
Assert(local_addr);
|
Assert(local_addr);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,12 @@
|
||||||
#include <VBox/com/ptr.h>
|
#include <VBox/com/ptr.h>
|
||||||
#include <iprt/param.h>
|
#include <iprt/param.h>
|
||||||
|
|
||||||
|
#if VBOX_VERSION_MAJOR == 4
|
||||||
#include "MachineImpl.h"
|
#include "MachineImpl.h"
|
||||||
|
HRESULT genode_setup_machine(ComObjPtr<Machine> machine);
|
||||||
|
|
||||||
|
HRESULT genode_check_memory_config(ComObjPtr<Machine> machine);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if a vCPU could be started. If false we run without
|
* 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_CREATE_VM(PSUPVMMR0REQHDR pReqHdr);
|
||||||
void genode_VMMR0_DO_GVMM_REGISTER_VMCPU(PVMR0 pVMR0, VMCPUID idCpu);
|
void genode_VMMR0_DO_GVMM_REGISTER_VMCPU(PVMR0 pVMR0, VMCPUID idCpu);
|
||||||
|
|
||||||
HRESULT genode_setup_machine(ComObjPtr<Machine> machine);
|
|
||||||
|
|
||||||
HRESULT genode_check_memory_config(ComObjPtr<Machine> machine);
|
|
||||||
|
|
||||||
#endif /* _SUP_H_ */
|
#endif /* _SUP_H_ */
|
||||||
|
|
|
@ -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 <cpu_session/cpu_session.h>
|
|
||||||
|
|
||||||
/* VirtualBox includes */
|
|
||||||
#include <VBox/vmm/vm.h>
|
|
||||||
#include <VBox/vmm/gvmm.h>
|
|
||||||
#include <iprt/param.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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_ */
|
|
|
@ -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/autostart.cc frontend/dummy/rest.cc
|
||||||
SRC_CC += frontend/dummy/host.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)/Main/include
|
||||||
INC_DIR += $(VBOX_DIR)/VMM/include
|
INC_DIR += $(VBOX_DIR)/VMM/include
|
||||||
|
|
||||||
|
|
|
@ -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 <iprt/types.h>
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 64bit-aware cast of pointer to RTRCPTR (uint32_t)
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
RTRCPTR to_rtrcptr(T* ptr)
|
|
||||||
{
|
|
||||||
unsigned long long u64 = reinterpret_cast<unsigned long long>(ptr);
|
|
||||||
RTRCPTR rtrcptr = u64 & 0xFFFFFFFFULL;
|
|
||||||
|
|
||||||
AssertMsg((u64 == rtrcptr) || (u64 >> 32) == 0xFFFFFFFFULL,
|
|
||||||
("pointer transformation - %llx != %x", u64, rtrcptr));
|
|
||||||
|
|
||||||
return rtrcptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _UTIL_H_ */
|
|
Loading…
Reference in New Issue
Block a user