diff --git a/base-codezero/src/core/cpu_session_support.cc b/base-codezero/src/core/cpu_session_support.cc new file mode 100644 index 0000000000..07223f033a --- /dev/null +++ b/base-codezero/src/core/cpu_session_support.cc @@ -0,0 +1,28 @@ +/* + * \brief Platform-specific parts of cores CPU-service + * \author Martin Stein + * \date 2012-04-17 + */ + +/* + * Copyright (C) 2009-2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* Core includes */ +#include + +using namespace Genode; + + +Ram_dataspace_capability Cpu_session_component::utcb(Thread_capability thread_cap) +{ + PERR("%s: Not implemented", __PRETTY_FUNCTION__); + return Ram_dataspace_capability(); +} + diff --git a/base-codezero/src/core/include/platform_thread.h b/base-codezero/src/core/include/platform_thread.h index d8e6455f47..710cc32980 100644 --- a/base-codezero/src/core/include/platform_thread.h +++ b/base-codezero/src/core/include/platform_thread.h @@ -52,7 +52,7 @@ namespace Genode { * Constructor */ Platform_thread(const char *name = 0, unsigned priority = 0, - int thread_id = THREAD_INVALID); + addr_t utcb = 0, int thread_id = THREAD_INVALID); /** * Destructor diff --git a/base-codezero/src/core/platform_thread.cc b/base-codezero/src/core/platform_thread.cc index 6112bd61a8..5aa9822771 100644 --- a/base-codezero/src/core/platform_thread.cc +++ b/base-codezero/src/core/platform_thread.cc @@ -91,7 +91,8 @@ void Platform_thread::cancel_blocking() } -Platform_thread::Platform_thread(const char *name, unsigned, int thread_id) +Platform_thread::Platform_thread(const char *name, unsigned, addr_t, + int thread_id) : _tid(-1) { strncpy(_name, name, sizeof(_name)); diff --git a/base-codezero/src/core/target.inc b/base-codezero/src/core/target.inc index 33faac26a7..abda2b1bed 100644 --- a/base-codezero/src/core/target.inc +++ b/base-codezero/src/core/target.inc @@ -10,6 +10,7 @@ SRC_CC = \ ram_session_support.cc \ rom_session_component.cc \ cpu_session_component.cc \ + cpu_session_support.cc \ pd_session_component.cc \ io_mem_session_component.cc \ io_mem_session_support.cc \ diff --git a/base-fiasco/src/core/cpu_session_support.cc b/base-fiasco/src/core/cpu_session_support.cc new file mode 100644 index 0000000000..07223f033a --- /dev/null +++ b/base-fiasco/src/core/cpu_session_support.cc @@ -0,0 +1,28 @@ +/* + * \brief Platform-specific parts of cores CPU-service + * \author Martin Stein + * \date 2012-04-17 + */ + +/* + * Copyright (C) 2009-2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* Core includes */ +#include + +using namespace Genode; + + +Ram_dataspace_capability Cpu_session_component::utcb(Thread_capability thread_cap) +{ + PERR("%s: Not implemented", __PRETTY_FUNCTION__); + return Ram_dataspace_capability(); +} + diff --git a/base-fiasco/src/core/include/platform_thread.h b/base-fiasco/src/core/include/platform_thread.h index 440f2d7476..62405e26f7 100644 --- a/base-fiasco/src/core/include/platform_thread.h +++ b/base-fiasco/src/core/include/platform_thread.h @@ -53,7 +53,7 @@ namespace Genode { * Constructor */ Platform_thread(const char *name = 0, unsigned priority = 0, - int thread_id = THREAD_INVALID); + addr_t utcb = 0, int thread_id = THREAD_INVALID); /** * Destructor diff --git a/base-fiasco/src/core/platform_thread.cc b/base-fiasco/src/core/platform_thread.cc index 3a60bba49e..b5b8c4c039 100644 --- a/base-fiasco/src/core/platform_thread.cc +++ b/base-fiasco/src/core/platform_thread.cc @@ -135,7 +135,7 @@ void Platform_thread::cancel_blocking() } -Platform_thread::Platform_thread(const char *name, unsigned, int thread_id) +Platform_thread::Platform_thread(const char *name, unsigned, addr_t, int thread_id) : _thread_id(thread_id), _l4_thread_id(L4_INVALID_ID), _pager(0) { strncpy(_name, name, sizeof(_name)); diff --git a/base-fiasco/src/core/target.inc b/base-fiasco/src/core/target.inc index 16505825c5..393f30f127 100644 --- a/base-fiasco/src/core/target.inc +++ b/base-fiasco/src/core/target.inc @@ -10,6 +10,7 @@ SRC_CC = main.cc \ ram_session_support.cc \ rom_session_component.cc \ cpu_session_component.cc \ + cpu_session_support.cc \ pd_session_component.cc \ io_mem_session_component.cc \ io_mem_session_support.cc \ diff --git a/base-foc/src/core/cpu_session_extension.cc b/base-foc/src/core/cpu_session_extension.cc index 0ba9e8d6c0..5f1bf9a7e1 100644 --- a/base-foc/src/core/cpu_session_extension.cc +++ b/base-foc/src/core/cpu_session_extension.cc @@ -25,6 +25,14 @@ namespace Fiasco { } +Genode::Ram_dataspace_capability Genode::Cpu_session_component::utcb(Genode::Thread_capability thread_cap) +{ + using namespace Genode; + PERR("%s: Not implemented", __PRETTY_FUNCTION__); + return Ram_dataspace_capability(); +} + + void Genode::Cpu_session_component::enable_vcpu(Genode::Thread_capability thread_cap, Genode::addr_t vcpu_state) { diff --git a/base-foc/src/core/include/cpu_session_component.h b/base-foc/src/core/include/cpu_session_component.h index ba03ae9614..360995babc 100644 --- a/base-foc/src/core/include/cpu_session_component.h +++ b/base-foc/src/core/include/cpu_session_component.h @@ -53,7 +53,7 @@ namespace Genode { public: - Cpu_thread_component(const char *name, unsigned priority) + Cpu_thread_component(const char *name, unsigned priority, addr_t) : _platform_thread(name, priority), _bound(false) { } @@ -80,8 +80,8 @@ namespace Genode { Rpc_entrypoint *_thread_ep; Pager_entrypoint *_pager_ep; Allocator_guard _md_alloc; /* guarded meta-data allocator */ - Cpu_thread_allocator _slab; /* meta-data allocator */ - Lock _slab_lock; /* protect slab access */ + Cpu_thread_allocator _thread_alloc; /* meta-data allocator */ + Lock _thread_alloc_lock; /* protect alloc access */ List _thread_list; Lock _thread_list_lock; /* protect thread list */ unsigned _priority; /* priority of threads @@ -127,7 +127,8 @@ namespace Genode { ** CPU session interface ** ***************************/ - Thread_capability create_thread(Name const &); + Thread_capability create_thread(Name const &, addr_t); + Ram_dataspace_capability utcb(Thread_capability thread); void kill_thread(Thread_capability); Thread_capability first(); Thread_capability next(Thread_capability); diff --git a/base-host/src/core/cpu_session_support.cc b/base-host/src/core/cpu_session_support.cc new file mode 100644 index 0000000000..b43e9e5c25 --- /dev/null +++ b/base-host/src/core/cpu_session_support.cc @@ -0,0 +1,28 @@ +/* + * \brief Platform-specific parts of cores CPU-session interface + * \author Martin Stein + * \date 2012-04-17 + */ + +/* + * Copyright (C) 2009-2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* Core includes */ +#include + +using namespace Genode; + + +Ram_dataspace_capability Cpu_session_component::utcb(Thread_capability thread_cap) +{ + PERR("%s: Not implemented", __PRETTY_FUNCTION__); + return Ram_dataspace_capability(); +} + diff --git a/base-host/src/core/include/platform_thread.h b/base-host/src/core/include/platform_thread.h index d4f4bf7236..681704503f 100644 --- a/base-host/src/core/include/platform_thread.h +++ b/base-host/src/core/include/platform_thread.h @@ -32,7 +32,7 @@ namespace Genode { * Constructor */ Platform_thread(const char *name = 0, unsigned priority = 0, - int thread_id = THREAD_INVALID); + addr_t utcb = 0, int thread_id = THREAD_INVALID); /** * Destructor diff --git a/base-host/src/core/platform_thread.cc b/base-host/src/core/platform_thread.cc index 0d8b96c492..1d1bdd79dc 100644 --- a/base-host/src/core/platform_thread.cc +++ b/base-host/src/core/platform_thread.cc @@ -65,7 +65,8 @@ unsigned long Platform_thread::pager_object_badge() const } -Platform_thread::Platform_thread(const char *name, unsigned, int thread_id) +Platform_thread::Platform_thread(const char *name, unsigned, addr_t, + int thread_id) { PWRN("not implemented"); } diff --git a/base-host/src/core/target.inc b/base-host/src/core/target.inc index 94d6093857..4e227348a3 100644 --- a/base-host/src/core/target.inc +++ b/base-host/src/core/target.inc @@ -10,6 +10,7 @@ SRC_CC = \ ram_session_support.cc \ rom_session_component.cc \ cpu_session_component.cc \ + cpu_session_support.cc \ pd_session_component.cc \ io_mem_session_component.cc \ io_mem_session_support.cc \ diff --git a/base-linux/src/core/cpu_session_support.cc b/base-linux/src/core/cpu_session_support.cc new file mode 100644 index 0000000000..07223f033a --- /dev/null +++ b/base-linux/src/core/cpu_session_support.cc @@ -0,0 +1,28 @@ +/* + * \brief Platform-specific parts of cores CPU-service + * \author Martin Stein + * \date 2012-04-17 + */ + +/* + * Copyright (C) 2009-2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* Core includes */ +#include + +using namespace Genode; + + +Ram_dataspace_capability Cpu_session_component::utcb(Thread_capability thread_cap) +{ + PERR("%s: Not implemented", __PRETTY_FUNCTION__); + return Ram_dataspace_capability(); +} + diff --git a/base-linux/src/core/include/platform_thread.h b/base-linux/src/core/include/platform_thread.h index 5d1b838136..e2e7a28b2b 100644 --- a/base-linux/src/core/include/platform_thread.h +++ b/base-linux/src/core/include/platform_thread.h @@ -34,7 +34,7 @@ namespace Genode { /** * Constructor */ - Platform_thread(const char *name, unsigned priority); + Platform_thread(const char *name, unsigned priority, addr_t); /** * Cancel currently blocking operation diff --git a/base-linux/src/core/platform_thread.cc b/base-linux/src/core/platform_thread.cc index c316339872..1807aac0fe 100644 --- a/base-linux/src/core/platform_thread.cc +++ b/base-linux/src/core/platform_thread.cc @@ -28,7 +28,7 @@ using namespace Genode; typedef Token Tid_token; -Platform_thread::Platform_thread(const char *name, unsigned) +Platform_thread::Platform_thread(const char *name, unsigned, addr_t) { /* search for thread-id portion of thread name */ Tid_token tok(name); diff --git a/base-linux/src/core/target.mk b/base-linux/src/core/target.mk index 6b4a0906da..948d1a8b81 100644 --- a/base-linux/src/core/target.mk +++ b/base-linux/src/core/target.mk @@ -11,6 +11,7 @@ SRC_CC = main.cc \ ram_session_support.cc \ rom_session_component.cc \ cpu_session_component.cc \ + cpu_session_support.cc \ pd_session_component.cc \ io_mem_session_component.cc \ io_port_session_component.cc \ diff --git a/base-nova/src/core/cpu_session_support.cc b/base-nova/src/core/cpu_session_support.cc new file mode 100644 index 0000000000..07223f033a --- /dev/null +++ b/base-nova/src/core/cpu_session_support.cc @@ -0,0 +1,28 @@ +/* + * \brief Platform-specific parts of cores CPU-service + * \author Martin Stein + * \date 2012-04-17 + */ + +/* + * Copyright (C) 2009-2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* Core includes */ +#include + +using namespace Genode; + + +Ram_dataspace_capability Cpu_session_component::utcb(Thread_capability thread_cap) +{ + PERR("%s: Not implemented", __PRETTY_FUNCTION__); + return Ram_dataspace_capability(); +} + diff --git a/base-nova/src/core/include/platform_thread.h b/base-nova/src/core/include/platform_thread.h index d0daf9bfa8..3c0fa50db4 100644 --- a/base-nova/src/core/include/platform_thread.h +++ b/base-nova/src/core/include/platform_thread.h @@ -41,7 +41,7 @@ namespace Genode { * Constructor */ Platform_thread(const char *name = 0, unsigned priority = 0, - int thread_id = THREAD_INVALID); + addr_t utcb = 0, int thread_id = THREAD_INVALID); /** * Destructor diff --git a/base-nova/src/core/platform_thread.cc b/base-nova/src/core/platform_thread.cc index 01d3ad5a51..8ddebf096d 100644 --- a/base-nova/src/core/platform_thread.cc +++ b/base-nova/src/core/platform_thread.cc @@ -130,7 +130,7 @@ const static int id_cnt; -Platform_thread::Platform_thread(const char *name, unsigned, int thread_id) +Platform_thread::Platform_thread(const char *name, unsigned, addr_t, int thread_id) : _pd(0), _id(++id_cnt) { } diff --git a/base-nova/src/core/target.inc b/base-nova/src/core/target.inc index fc026e7b87..7e348e77dd 100644 --- a/base-nova/src/core/target.inc +++ b/base-nova/src/core/target.inc @@ -10,6 +10,7 @@ SRC_CC = \ ram_session_support.cc \ rom_session_component.cc \ cpu_session_component.cc \ + cpu_session_support.cc \ pd_session_component.cc \ io_mem_session_component.cc \ io_mem_session_support.cc \ diff --git a/base-okl4/src/core/cpu_session_support.cc b/base-okl4/src/core/cpu_session_support.cc new file mode 100644 index 0000000000..07223f033a --- /dev/null +++ b/base-okl4/src/core/cpu_session_support.cc @@ -0,0 +1,28 @@ +/* + * \brief Platform-specific parts of cores CPU-service + * \author Martin Stein + * \date 2012-04-17 + */ + +/* + * Copyright (C) 2009-2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* Core includes */ +#include + +using namespace Genode; + + +Ram_dataspace_capability Cpu_session_component::utcb(Thread_capability thread_cap) +{ + PERR("%s: Not implemented", __PRETTY_FUNCTION__); + return Ram_dataspace_capability(); +} + diff --git a/base-okl4/src/core/include/platform_thread.h b/base-okl4/src/core/include/platform_thread.h index 22f13c2bd2..4fd0e45547 100644 --- a/base-okl4/src/core/include/platform_thread.h +++ b/base-okl4/src/core/include/platform_thread.h @@ -48,7 +48,7 @@ namespace Genode { * Constructor */ Platform_thread(const char *name = 0, - unsigned priority = 0, + unsigned priority = 0, addr_t utcb = 0, int thread_id = THREAD_INVALID); /** diff --git a/base-okl4/src/core/platform_thread.cc b/base-okl4/src/core/platform_thread.cc index 7fd973b4ae..02939634dd 100644 --- a/base-okl4/src/core/platform_thread.cc +++ b/base-okl4/src/core/platform_thread.cc @@ -178,7 +178,7 @@ unsigned long Platform_thread::pager_object_badge() const } -Platform_thread::Platform_thread(const char *name, unsigned prio, int thread_id) +Platform_thread::Platform_thread(const char *name, unsigned prio, addr_t, int thread_id) : _thread_id(thread_id), _l4_thread_id(L4_nilthread), _platform_pd(0), _priority(prio), _pager(0) { diff --git a/base-okl4/src/core/target.inc b/base-okl4/src/core/target.inc index 9bcb0bd215..739e1aaf9d 100644 --- a/base-okl4/src/core/target.inc +++ b/base-okl4/src/core/target.inc @@ -10,6 +10,7 @@ SRC_CC = main.cc \ ram_session_support.cc \ rom_session_component.cc \ cpu_session_component.cc \ + cpu_session_support.cc \ pd_session_component.cc \ okl4_pd_session_component.cc \ io_mem_session_component.cc \ diff --git a/base-pistachio/src/core/cpu_session_platform.cc b/base-pistachio/src/core/cpu_session_platform.cc index 439ae32c20..f24d9385b5 100644 --- a/base-pistachio/src/core/cpu_session_platform.cc +++ b/base-pistachio/src/core/cpu_session_platform.cc @@ -1,4 +1,17 @@ +/* + * \brief Platform-specific parts of the core CPU session interface + * \author Martin Stein + * \date 2012-04-17 + */ +/* + * Copyright (C) 2009-2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ #include #include @@ -13,3 +26,9 @@ using namespace Pistachio; // return 1; // } +Ram_dataspace_capability Cpu_session_component::utcb(Thread_capability thread_cap) +{ + PERR("%s: Not implemented", __PRETTY_FUNCTION__); + return Ram_dataspace_capability(); +} + diff --git a/base-pistachio/src/core/include/platform_thread.h b/base-pistachio/src/core/include/platform_thread.h index 70df56cbc3..c345672a67 100644 --- a/base-pistachio/src/core/include/platform_thread.h +++ b/base-pistachio/src/core/include/platform_thread.h @@ -53,7 +53,7 @@ namespace Genode { * Constructor */ Platform_thread(const char *name = 0, unsigned priority = 0, - int thread_id = THREAD_INVALID); + addr_t utcb = 0, int thread_id = THREAD_INVALID); /** * Destructor diff --git a/base-pistachio/src/core/platform_thread.cc b/base-pistachio/src/core/platform_thread.cc index 4b27281cee..1faae2678e 100644 --- a/base-pistachio/src/core/platform_thread.cc +++ b/base-pistachio/src/core/platform_thread.cc @@ -217,7 +217,7 @@ void Platform_thread::cancel_blocking() } -Platform_thread::Platform_thread(const char *name, unsigned prio, int id) +Platform_thread::Platform_thread(const char *name, unsigned prio, addr_t, int id) : _thread_id(id), _l4_thread_id(L4_nilthread), _priority(prio), _pager(0) { strncpy(_name, name, sizeof(_name)); diff --git a/base/include/cpu_session/client.h b/base/include/cpu_session/client.h index a452a67697..5744325dcf 100644 --- a/base/include/cpu_session/client.h +++ b/base/include/cpu_session/client.h @@ -24,8 +24,11 @@ namespace Genode { explicit Cpu_session_client(Cpu_session_capability session) : Rpc_client(session) { } - Thread_capability create_thread(Name const &name) { - return call(name); } + Thread_capability create_thread(Name const &name, addr_t utcb = 0) { + return call(name, utcb); } + + Ram_dataspace_capability utcb(Thread_capability thread) { + return call(thread); } void kill_thread(Thread_capability thread) { call(thread); } diff --git a/base/include/cpu_session/cpu_session.h b/base/include/cpu_session/cpu_session.h index bb78bbdb2b..add9964b6d 100644 --- a/base/include/cpu_session/cpu_session.h +++ b/base/include/cpu_session/cpu_session.h @@ -62,10 +62,18 @@ namespace Genode { * Create a new thread * * \param name name for the thread + * \param utcb Base of the UTCB that will be used by the thread * \return capability representing the new thread * \throw Thread_creation_failed */ - virtual Thread_capability create_thread(Name const &name) = 0; + virtual Thread_capability create_thread(Name const &name, + addr_t utcb = 0) = 0; + + /** + * Get dataspace of the UTCB that is used by the specified thread + */ + virtual Ram_dataspace_capability + utcb(Thread_capability thread) = 0; /** * Kill an existing thread @@ -188,7 +196,9 @@ namespace Genode { *********************/ GENODE_RPC_THROW(Rpc_create_thread, Thread_capability, create_thread, - GENODE_TYPE_LIST(Thread_creation_failed), Name const &); + GENODE_TYPE_LIST(Thread_creation_failed), + Name const &, addr_t); + GENODE_RPC(Rpc_utcb, Ram_dataspace_capability, utcb, Thread_capability); GENODE_RPC(Rpc_kill_thread, void, kill_thread, Thread_capability); GENODE_RPC(Rpc_first, Thread_capability, first,); GENODE_RPC(Rpc_next, Thread_capability, next, Thread_capability); @@ -211,6 +221,7 @@ namespace Genode { * of employing the convenience macro 'GENODE_RPC_INTERFACE'. */ typedef Meta::Type_tuple - > > > > > > > > > > > Rpc_functions; + > > > > > > > > > > > > Rpc_functions; }; } diff --git a/base/src/base/thread/thread_start.cc b/base/src/base/thread/thread_start.cc index bd53d4bc46..918a4aadfe 100644 --- a/base/src/base/thread/thread_start.cc +++ b/base/src/base/thread/thread_start.cc @@ -49,7 +49,8 @@ void Thread_base::start() /* create thread at core */ char buf[48]; name(buf, sizeof(buf)); - _thread_cap = env()->cpu_session()->create_thread(buf); + Cpu_session * cpu = env()->cpu_session(); + _thread_cap = cpu->create_thread(buf, (addr_t)&_context->utcb); /* assign thread to protection domain */ env()->pd_session()->bind_thread(_thread_cap); diff --git a/base/src/core/cpu_session_component.cc b/base/src/core/cpu_session_component.cc index 6db8dd713f..1921716e08 100644 --- a/base/src/core/cpu_session_component.cc +++ b/base/src/core/cpu_session_component.cc @@ -24,14 +24,15 @@ using namespace Genode; -Thread_capability Cpu_session_component::create_thread(Name const &name) +Thread_capability Cpu_session_component::create_thread(Name const &name, addr_t utcb) { Lock::Guard thread_list_lock_guard(_thread_list_lock); - Lock::Guard slab_lock_guard(_slab_lock); + Lock::Guard slab_lock_guard(_thread_alloc_lock); Cpu_thread_component *thread = 0; try { - thread = new(&_slab) Cpu_thread_component(name.string(), _priority); + thread = new(&_thread_alloc) Cpu_thread_component(name.string(), + _priority, utcb); } catch (Allocator::Out_of_memory) { throw Thread_creation_failed(); } @@ -43,7 +44,7 @@ Thread_capability Cpu_session_component::create_thread(Name const &name) void Cpu_session_component::_unsynchronized_kill_thread(Cpu_thread_component *thread) { - Lock::Guard lock_guard(_slab_lock); + Lock::Guard lock_guard(_thread_alloc_lock); _thread_ep->dissolve(thread); _thread_list.remove(thread); @@ -53,7 +54,7 @@ void Cpu_session_component::_unsynchronized_kill_thread(Cpu_thread_component *th if (rc) rc->member_rm_session()->dissolve(rc); - destroy(&_slab, thread); + destroy(&_thread_alloc, thread); } @@ -169,7 +170,7 @@ Cpu_session_component::Cpu_session_component(Rpc_entrypoint *thread_ep, const char *args) : _thread_ep(thread_ep), _pager_ep(pager_ep), _md_alloc(md_alloc, Arg_string::find_arg(args, "ram_quota").long_value(0)), - _slab(&_md_alloc), _priority(0) + _thread_alloc(&_md_alloc), _priority(0) { Arg a = Arg_string::find_arg(args, "priority"); if (a.valid()) { diff --git a/base/src/core/include/core_env.h b/base/src/core/include/core_env.h index 1c9c07347d..9dbb0ab8cb 100644 --- a/base/src/core/include/core_env.h +++ b/base/src/core/include/core_env.h @@ -24,6 +24,7 @@ #include /* core includes */ +#include #include #include #include diff --git a/base/src/core/include/cpu_session_component.h b/base/src/core/include/cpu_session_component.h index cf33b60570..a521b2f604 100644 --- a/base/src/core/include/cpu_session_component.h +++ b/base/src/core/include/cpu_session_component.h @@ -17,13 +17,13 @@ /* Genode includes */ #include #include -#include #include #include #include #include -/* core includes */ +/* Core includes */ +#include #include namespace Genode { @@ -52,8 +52,9 @@ namespace Genode { public: - Cpu_thread_component(const char *name, unsigned priority) - : _platform_thread(name, priority), _bound(false) { } + Cpu_thread_component(const char *name, unsigned priority, + addr_t utcb) + : _platform_thread(name, priority, utcb), _bound(false) { } /************************ @@ -70,17 +71,11 @@ namespace Genode { { private: - /** - * Allocator used for managing the CPU threads associated with the - * CPU session - */ - typedef Tslab Cpu_thread_allocator; - Rpc_entrypoint *_thread_ep; Pager_entrypoint *_pager_ep; Allocator_guard _md_alloc; /* guarded meta-data allocator */ - Cpu_thread_allocator _slab; /* meta-data allocator */ - Lock _slab_lock; /* protect slab access */ + Cpu_thread_allocator _thread_alloc; /* meta-data allocator */ + Lock _thread_alloc_lock; /* protect allocator access */ List _thread_list; Lock _thread_list_lock; /* protect thread list */ unsigned _priority; /* priority of threads @@ -126,7 +121,8 @@ namespace Genode { ** CPU session interface ** ***************************/ - Thread_capability create_thread(Name const &); + Thread_capability create_thread(Name const &, addr_t utcb); + Ram_dataspace_capability utcb(Thread_capability thread); void kill_thread(Thread_capability); Thread_capability first(); Thread_capability next(Thread_capability); diff --git a/base/src/core/include/cpu_thread_allocator.h b/base/src/core/include/cpu_thread_allocator.h new file mode 100644 index 0000000000..f81fdb46b6 --- /dev/null +++ b/base/src/core/include/cpu_thread_allocator.h @@ -0,0 +1,31 @@ +/* + * \brief Allocator to manage CPU threads associated with a CPU session + * \author Martin Stein + * \date 2012-05-28 + */ + +/* + * Copyright (C) 2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _BASE__SRC__CORE__INCLUDE__CPU_THREAD_ALLOCATOR_H_ +#define _BASE__SRC__CORE__INCLUDE__CPU_THREAD_ALLOCATOR_H_ + +/* Genode includes */ +#include + +namespace Genode +{ + class Cpu_thread_component; + + /** + * Allocator to manage CPU threads associated with a CPU session + */ + typedef Tslab Cpu_thread_allocator; +} + +#endif /* _BASE__SRC__CORE__INCLUDE__CPU_THREAD_ALLOCATOR_H_ */ + diff --git a/base/src/core/include/ram_session_component.h b/base/src/core/include/ram_session_component.h index e5eab6fe96..6e108cbce8 100644 --- a/base/src/core/include/ram_session_component.h +++ b/base/src/core/include/ram_session_component.h @@ -34,6 +34,8 @@ namespace Genode { { private: + class Invalid_dataspace : public Exception { }; + enum { SBS = 1024 }; /* slab block size */ typedef Tslab Ds_slab; @@ -144,6 +146,14 @@ namespace Genode { */ void upgrade_ram_quota(size_t ram_quota) { _md_alloc.upgrade(ram_quota); } + /** + * Get physical address of the RAM that backs a dataspace + * + * \param ds targeted dataspace + * + * \throw Invalid_dataspace + */ + addr_t phys_addr(Ram_dataspace_capability ds); /*************************** ** RAM Session interface ** diff --git a/base/src/core/ram_session_component.cc b/base/src/core/ram_session_component.cc index eb3f17d410..93e89640bf 100644 --- a/base/src/core/ram_session_component.cc +++ b/base/src/core/ram_session_component.cc @@ -24,6 +24,16 @@ using namespace Genode; static const bool verbose = false; +addr_t Ram_session_component::phys_addr(Ram_dataspace_capability ds) +{ + Dataspace_component * const dsc = + dynamic_cast(_ds_ep->obj_by_cap(ds)); + + if (!dsc) throw Invalid_dataspace(); + return dsc->phys_addr(); +} + + void Ram_session_component::_free_ds(Dataspace_component *ds) { if (!ds) return;