From 9a2bdf87981cb04ccbc0ba85d500de28fd132166 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Wed, 26 Sep 2018 13:03:46 +0200 Subject: [PATCH] vm_session: move from base-hw to base Issue #3111 --- repos/base-hw/include/vm_session/client.h | 59 ---------- repos/base-hw/include/vm_session/vm_session.h | 106 ------------------ repos/base-hw/src/core/vm_root.h | 50 --------- .../include/vm_session/capability.h | 0 repos/base/include/vm_session/client.h | 58 ++++++++++ .../include/vm_session/connection.h | 0 repos/base/include/vm_session/vm_session.h | 105 +++++++++++++++++ repos/base/src/core/include/vm_root.h | 49 ++++++++ 8 files changed, 212 insertions(+), 215 deletions(-) delete mode 100644 repos/base-hw/include/vm_session/client.h delete mode 100644 repos/base-hw/include/vm_session/vm_session.h delete mode 100644 repos/base-hw/src/core/vm_root.h rename repos/{base-hw => base}/include/vm_session/capability.h (100%) create mode 100644 repos/base/include/vm_session/client.h rename repos/{base-hw => base}/include/vm_session/connection.h (100%) create mode 100644 repos/base/include/vm_session/vm_session.h create mode 100644 repos/base/src/core/include/vm_root.h diff --git a/repos/base-hw/include/vm_session/client.h b/repos/base-hw/include/vm_session/client.h deleted file mode 100644 index 4e7d800873..0000000000 --- a/repos/base-hw/include/vm_session/client.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * \brief Client-side VM session interface - * \author Stefan Kalkowski - * \date 2012-10-02 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#ifndef _INCLUDE__VM_SESSION__CLIENT_H_ -#define _INCLUDE__VM_SESSION__CLIENT_H_ - -/* Genode includes */ -#include -#include - -namespace Genode -{ - /** - * Client-side VM session interface - */ - struct Vm_session_client : Rpc_client - { - /** - * Constructor - */ - explicit Vm_session_client(Vm_session_capability session) - : Rpc_client(session) { } - - - /************************** - ** Vm_session interface ** - **************************/ - - Dataspace_capability cpu_state() { - return call(); } - - void exception_handler(Signal_context_capability handler) { - call(handler); } - - void run() { call(); } - void pause() { call(); } - - void attach(Dataspace_capability ds,addr_t vm_addr) { - call(ds, vm_addr); } - - void detach(addr_t vm_addr, size_t size) { - call(vm_addr, size); } - - void attach_pic(addr_t vm_addr) { - call(vm_addr); } - }; -} - -#endif /* _INCLUDE__VM_SESSION__CLIENT_H_ */ diff --git a/repos/base-hw/include/vm_session/vm_session.h b/repos/base-hw/include/vm_session/vm_session.h deleted file mode 100644 index cc1c1b951f..0000000000 --- a/repos/base-hw/include/vm_session/vm_session.h +++ /dev/null @@ -1,106 +0,0 @@ - /* - * \brief VM-session interface - * \author Stefan Kalkowski - * \date 2012-10-02 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#ifndef _INCLUDE__VM_SESSION__VM_SESSION_H_ -#define _INCLUDE__VM_SESSION__VM_SESSION_H_ - -/* Genode includes */ -#include -#include -#include -#include - -namespace Genode { - - struct Vm_session : Session - { - static const char *service_name() { return "VM"; } - - enum { CAP_QUOTA = 3 }; - - class Invalid_dataspace : Exception { }; - - /** - * Destructor - */ - virtual ~Vm_session() { } - - /** - * Get dataspace of the CPU state of the VM - */ - virtual Dataspace_capability cpu_state(void) = 0; - - /** - * Register signal handler for exceptions of the Vm - */ - virtual void exception_handler(Signal_context_capability handler) = 0; - - /** - * (Re-)Start execution of the VM - */ - virtual void run(void) {} - - /** - * Stop execution of the VM - */ - virtual void pause(void) {} - - /** - * Attach dataspace to the guest-physical memory address space - * - * \param ds dataspace to be attached - * \param vm_addr address in guest-physical memory address space - */ - virtual void attach(Dataspace_capability ds, addr_t vm_addr) = 0; - - /** - * Invalidate region of the guest-physical memory address space - * - * \param vm_addr address in guest-physical memory address space - * \param size size of the region to invalidate - */ - virtual void detach(addr_t vm_addr, size_t size) = 0; - - /** - * Attach cpu-local interrupt-controller's interface to - * guest-physical memory address space. - * - * \param vm_addr address in guest-physical memory address space - * - * Note: this is currently only support for ARM interrupt-controller - * hardware virtualization - */ - virtual void attach_pic(addr_t vm_addr) = 0; - - - /********************* - ** RPC declaration ** - *********************/ - - GENODE_RPC(Rpc_cpu_state, Dataspace_capability, cpu_state); - GENODE_RPC(Rpc_exception_handler, void, exception_handler, - Signal_context_capability); - GENODE_RPC(Rpc_run, void, run); - GENODE_RPC(Rpc_pause, void, pause); - GENODE_RPC_THROW(Rpc_attach, void, attach, - GENODE_TYPE_LIST(Invalid_dataspace), - Dataspace_capability, addr_t); - GENODE_RPC(Rpc_detach, void, detach, addr_t, size_t); - GENODE_RPC(Rpc_attach_pic, void, attach_pic, addr_t); - GENODE_RPC_INTERFACE(Rpc_cpu_state, Rpc_exception_handler, - Rpc_run, Rpc_pause, Rpc_attach, Rpc_detach, - Rpc_attach_pic); - }; -} - -#endif /* _INCLUDE__VM_SESSION__VM_SESSION_H_ */ diff --git a/repos/base-hw/src/core/vm_root.h b/repos/base-hw/src/core/vm_root.h deleted file mode 100644 index 0778892fba..0000000000 --- a/repos/base-hw/src/core/vm_root.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * \brief Vm root interface - * \author Stefan Kalkowski - * \date 2012-10-08 - */ - -/* - * Copyright (C) 2012-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#ifndef _CORE__VM_ROOT_H_ -#define _CORE__VM_ROOT_H_ - -/* Genode includes */ -#include -#include - -/* core includes */ -#include - -namespace Genode { - - class Vm_root : public Root_component - { - protected: - - Vm_session_component *_create_session(const char *args) - { - size_t ram_quota = Arg_string::find_arg(args, "ram_quota").ulong_value(0); - return new (md_alloc()) Vm_session_component(ep(), ram_quota); - } - - public: - - /** - * Constructor - * - * \param session_ep entrypoint managing vm_session components - * \param md_alloc meta-data allocator to be used by root component - */ - Vm_root(Rpc_entrypoint *session_ep, - Allocator *md_alloc) - : Root_component(session_ep, md_alloc) { } - }; -} - -#endif /* _CORE__VM_ROOT_H_ */ diff --git a/repos/base-hw/include/vm_session/capability.h b/repos/base/include/vm_session/capability.h similarity index 100% rename from repos/base-hw/include/vm_session/capability.h rename to repos/base/include/vm_session/capability.h diff --git a/repos/base/include/vm_session/client.h b/repos/base/include/vm_session/client.h new file mode 100644 index 0000000000..e849060383 --- /dev/null +++ b/repos/base/include/vm_session/client.h @@ -0,0 +1,58 @@ +/* + * \brief Client-side VM session interface + * \author Stefan Kalkowski + * \date 2012-10-02 + */ + +/* + * Copyright (C) 2012-2017 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef _INCLUDE__VM_SESSION__CLIENT_H_ +#define _INCLUDE__VM_SESSION__CLIENT_H_ + +/* Genode includes */ +#include +#include + +namespace Genode { struct Vm_session_client; } + +/** + * Client-side VM session interface + */ +struct Genode::Vm_session_client : Rpc_client +{ + /** + * Constructor + */ + explicit Vm_session_client(Vm_session_capability session) + : Rpc_client(session) { } + + + /************************** + ** Vm_session interface ** + **************************/ + + Dataspace_capability cpu_state() { + return call(); } + + void exception_handler(Signal_context_capability handler) { + call(handler); } + + void run() { call(); } + void pause() { call(); } + + void attach(Dataspace_capability ds,addr_t vm_addr) { + call(ds, vm_addr); } + + void detach(addr_t vm_addr, size_t size) { + call(vm_addr, size); } + + void attach_pic(addr_t vm_addr) { + call(vm_addr); } +}; + +#endif /* _INCLUDE__VM_SESSION__CLIENT_H_ */ diff --git a/repos/base-hw/include/vm_session/connection.h b/repos/base/include/vm_session/connection.h similarity index 100% rename from repos/base-hw/include/vm_session/connection.h rename to repos/base/include/vm_session/connection.h diff --git a/repos/base/include/vm_session/vm_session.h b/repos/base/include/vm_session/vm_session.h new file mode 100644 index 0000000000..c45224480e --- /dev/null +++ b/repos/base/include/vm_session/vm_session.h @@ -0,0 +1,105 @@ + /* + * \brief VM-session interface + * \author Stefan Kalkowski + * \date 2012-10-02 + */ + +/* + * Copyright (C) 2012-2017 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef _INCLUDE__VM_SESSION__VM_SESSION_H_ +#define _INCLUDE__VM_SESSION__VM_SESSION_H_ + +/* Genode includes */ +#include +#include +#include +#include + +namespace Genode { struct Vm_session; } + +struct Genode::Vm_session : Session +{ + static const char *service_name() { return "VM"; } + + enum { CAP_QUOTA = 3 }; + + class Invalid_dataspace : Exception { }; + + /** + * Destructor + */ + virtual ~Vm_session() { } + + /** + * Get dataspace of the CPU state of the VM + */ + virtual Dataspace_capability cpu_state(void) = 0; + + /** + * Register signal handler for exceptions of the Vm + */ + virtual void exception_handler(Signal_context_capability handler) = 0; + + /** + * (Re-)Start execution of the VM + */ + virtual void run(void) {} + + /** + * Stop execution of the VM + */ + virtual void pause(void) {} + + /** + * Attach dataspace to the guest-physical memory address space + * + * \param ds dataspace to be attached + * \param vm_addr address in guest-physical memory address space + */ + virtual void attach(Dataspace_capability ds, addr_t vm_addr) = 0; + + /** + * Invalidate region of the guest-physical memory address space + * + * \param vm_addr address in guest-physical memory address space + * \param size size of the region to invalidate + */ + virtual void detach(addr_t vm_addr, size_t size) = 0; + + /** + * Attach cpu-local interrupt-controller's interface to + * guest-physical memory address space. + * + * \param vm_addr address in guest-physical memory address space + * + * Note: this is currently only support for ARM interrupt-controller + * hardware virtualization + */ + virtual void attach_pic(addr_t vm_addr) = 0; + + + /********************* + ** RPC declaration ** + *********************/ + + GENODE_RPC(Rpc_cpu_state, Dataspace_capability, cpu_state); + GENODE_RPC(Rpc_exception_handler, void, exception_handler, + Signal_context_capability); + GENODE_RPC(Rpc_run, void, run); + GENODE_RPC(Rpc_pause, void, pause); + GENODE_RPC_THROW(Rpc_attach, void, attach, + GENODE_TYPE_LIST(Invalid_dataspace), + Dataspace_capability, addr_t); + GENODE_RPC(Rpc_detach, void, detach, addr_t, size_t); + GENODE_RPC(Rpc_attach_pic, void, attach_pic, addr_t); + GENODE_RPC_INTERFACE(Rpc_cpu_state, Rpc_exception_handler, + Rpc_run, Rpc_pause, Rpc_attach, Rpc_detach, + Rpc_attach_pic); +}; + +#endif /* _INCLUDE__VM_SESSION__VM_SESSION_H_ */ diff --git a/repos/base/src/core/include/vm_root.h b/repos/base/src/core/include/vm_root.h new file mode 100644 index 0000000000..def04074d2 --- /dev/null +++ b/repos/base/src/core/include/vm_root.h @@ -0,0 +1,49 @@ +/* + * \brief Vm root interface + * \author Stefan Kalkowski + * \date 2012-10-08 + */ + +/* + * Copyright (C) 2012-2017 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef _CORE__INCLUDE__VM_ROOT_H_ +#define _CORE__INCLUDE__VM_ROOT_H_ + +/* Genode includes */ +#include +#include + +/* core includes */ +#include + +namespace Genode { class Vm_root; } + +class Genode::Vm_root : public Root_component +{ + protected: + + Vm_session_component *_create_session(const char *args) + { + size_t ram_quota = Arg_string::find_arg(args, "ram_quota").ulong_value(0); + return new (md_alloc()) Vm_session_component(ep(), ram_quota); + } + + public: + + /** + * Constructor + * + * \param session_ep entrypoint managing vm_session components + * \param md_alloc meta-data allocator to be used by root component + */ + Vm_root(Rpc_entrypoint *session_ep, + Allocator *md_alloc) + : Root_component(session_ep, md_alloc) { } +}; + +#endif /* _CORE__INCLUDE__VM_ROOT_H_ */