Remove Rpc_entrypoint::Native_context

This patch largely reverts the commit "base: lay groundwork for
base-linux caps change" because the use of 'epoll' instead of 'select'
alleviated the need to allocate large FD sets, which motivated the
introduction of the 'Native_context' hook.

Related to issue #3581
This commit is contained in:
Norman Feske 2020-04-21 16:41:13 +02:00
parent 01bf32b998
commit b134867f31
20 changed files with 78 additions and 197 deletions

View File

@ -10,7 +10,5 @@ LIBS += startup-fiasco syscall-fiasco
SRC_CC += capability.cc capability_raw.cc SRC_CC += capability.cc capability_raw.cc
SRC_CC += rpc_dispatch_loop.cc SRC_CC += rpc_dispatch_loop.cc
SRC_CC += rpc_entrypoint_manage.cc
SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc
SRC_CC += stack_area_addr.cc SRC_CC += stack_area_addr.cc
SRC_CC += rpc_entry.cc

View File

@ -204,11 +204,10 @@ void Genode::ipc_reply(Native_capability caller, Rpc_exception_code exc,
} }
Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller, Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
Rpc_exception_code exc, Rpc_exception_code exc,
Msgbuf_base &reply_msg, Msgbuf_base &reply_msg,
Msgbuf_base &request_msg, Msgbuf_base &request_msg)
Rpc_entrypoint::Native_context &)
{ {
using namespace Fiasco; using namespace Fiasco;
@ -275,10 +274,9 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_
} }
Ipc_server::Ipc_server(Rpc_entrypoint::Native_context& native_context) Ipc_server::Ipc_server()
: :
Native_capability(Capability_space::import(Fiasco::l4_myself(), Rpc_obj_key())), Native_capability(Capability_space::import(Fiasco::l4_myself(), Rpc_obj_key()))
_native_context(native_context)
{ } { }

View File

@ -10,9 +10,7 @@ LIBS += syscall-foc startup-foc
SRC_CC += spin_lock.cc cap_map.cc SRC_CC += spin_lock.cc cap_map.cc
SRC_CC += rpc_dispatch_loop.cc SRC_CC += rpc_dispatch_loop.cc
SRC_CC += rpc_entrypoint_manage.cc
SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc utcb.cc SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc utcb.cc
SRC_CC += capability.cc SRC_CC += capability.cc
SRC_CC += signal_source_client.cc SRC_CC += signal_source_client.cc
SRC_CC += platform.cc SRC_CC += platform.cc
SRC_CC += rpc_entry.cc

View File

@ -316,11 +316,10 @@ void Genode::ipc_reply(Native_capability, Rpc_exception_code exc,
} }
Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &, Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &,
Rpc_exception_code exc, Rpc_exception_code exc,
Msgbuf_base &reply_msg, Msgbuf_base &reply_msg,
Msgbuf_base &request_msg, Msgbuf_base &request_msg)
Rpc_entrypoint::Native_context &)
{ {
Receive_window &rcv_window = Thread::myself()->native_thread().rcv_window; Receive_window &rcv_window = Thread::myself()->native_thread().rcv_window;
@ -371,10 +370,9 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &,
} }
Ipc_server::Ipc_server(Rpc_entrypoint::Native_context& native_context) Ipc_server::Ipc_server()
: :
Native_capability((Cap_index*)Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_BADGE]), Native_capability((Cap_index*)Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_BADGE])
_native_context(native_context)
{ {
Thread::myself()->native_thread().rcv_window.init(); Thread::myself()->native_thread().rcv_window.init();
} }

View File

@ -10,7 +10,5 @@ include $(BASE_DIR)/lib/mk/base-common.inc
LIBS += syscall-hw LIBS += syscall-hw
SRC_CC += rpc_dispatch_loop.cc SRC_CC += rpc_dispatch_loop.cc
SRC_CC += rpc_entrypoint_manage.cc
SRC_CC += thread.cc thread_myself.cc thread_bootstrap.cc SRC_CC += thread.cc thread_myself.cc thread_bootstrap.cc
SRC_CC += signal_transmitter.cc SRC_CC += signal_transmitter.cc
SRC_CC += rpc_entry.cc

View File

@ -130,11 +130,10 @@ void Genode::ipc_reply(Native_capability, Rpc_exception_code exc,
} }
Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &, Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &,
Rpc_exception_code exc, Rpc_exception_code exc,
Msgbuf_base &reply_msg, Msgbuf_base &reply_msg,
Msgbuf_base &request_msg, Msgbuf_base &request_msg)
Rpc_entrypoint::Native_context &)
{ {
Native_utcb &utcb = *Thread::myself()->utcb(); Native_utcb &utcb = *Thread::myself()->utcb();
@ -163,11 +162,10 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &,
} }
Ipc_server::Ipc_server(Rpc_entrypoint::Native_context& _native_context) Ipc_server::Ipc_server()
: :
Native_capability(Thread::myself() ? Thread::myself()->native_thread().cap Native_capability(Thread::myself() ? Thread::myself()->native_thread().cap
: Hw::_main_thread_cap), : Hw::_main_thread_cap)
_native_context(_native_context)
{ } { }

View File

@ -10,8 +10,6 @@ LIBS += syscall-linux
SRC_CC += region_map_mmap.cc debug.cc SRC_CC += region_map_mmap.cc debug.cc
SRC_CC += rpc_dispatch_loop.cc SRC_CC += rpc_dispatch_loop.cc
SRC_CC += rpc_entrypoint_manage.cc
SRC_CC += thread_env.cc SRC_CC += thread_env.cc
SRC_CC += capability.cc SRC_CC += capability.cc
SRC_CC += rpc_entry.cc
SRC_CC += native_thread.cc SRC_CC += native_thread.cc

View File

@ -370,11 +370,10 @@ void Genode::ipc_reply(Native_capability caller, Rpc_exception_code exc,
} }
Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller, Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
Rpc_exception_code exc, Rpc_exception_code exc,
Msgbuf_base &reply_msg, Msgbuf_base &reply_msg,
Msgbuf_base &request_msg, Msgbuf_base &request_msg)
Rpc_entrypoint::Native_context &)
{ {
/* when first called, there was no request yet */ /* when first called, there was no request yet */
if (last_caller.valid() && exc.value != Rpc_exception_code::INVALID_OBJECT) if (last_caller.valid() && exc.value != Rpc_exception_code::INVALID_OBJECT)
@ -423,9 +422,7 @@ Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
} }
Ipc_server::Ipc_server(Rpc_entrypoint::Native_context& native_context) Ipc_server::Ipc_server()
:
_native_context(native_context)
{ {
/* /*
* If 'thread' is 0, the constructor was called by the main thread. By * If 'thread' is 0, the constructor was called by the main thread. By

View File

@ -10,7 +10,5 @@ LIBS += startup-okl4 syscall-okl4
SRC_CC += capability.cc capability_raw.cc SRC_CC += capability.cc capability_raw.cc
SRC_CC += rpc_dispatch_loop.cc SRC_CC += rpc_dispatch_loop.cc
SRC_CC += rpc_entrypoint_manage.cc
SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc
SRC_CC += stack_area_addr.cc SRC_CC += stack_area_addr.cc
SRC_CC += rpc_entry.cc

View File

@ -195,11 +195,10 @@ void Genode::ipc_reply(Native_capability caller, Rpc_exception_code exc,
} }
Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller, Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
Rpc_exception_code exc, Rpc_exception_code exc,
Msgbuf_base &reply_msg, Msgbuf_base &reply_msg,
Msgbuf_base &request_msg, Msgbuf_base &request_msg)
Rpc_entrypoint::Native_context &)
{ {
L4_MsgTag_t rcv_tag; L4_MsgTag_t rcv_tag;
@ -238,10 +237,9 @@ static inline Okl4::L4_ThreadId_t thread_get_my_global_id()
} }
Ipc_server::Ipc_server(Rpc_entrypoint::Native_context& _native_context) Ipc_server::Ipc_server()
: :
Native_capability(Capability_space::import(thread_get_my_global_id(), Rpc_obj_key())), Native_capability(Capability_space::import(thread_get_my_global_id(), Rpc_obj_key()))
_native_context(_native_context)
{ } { }

View File

@ -10,10 +10,8 @@ LIBS += startup-pistachio syscall-pistachio
SRC_CC += capability.cc capability_raw.cc SRC_CC += capability.cc capability_raw.cc
SRC_CC += rpc_dispatch_loop.cc SRC_CC += rpc_dispatch_loop.cc
SRC_CC += rpc_entrypoint_manage.cc
SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc SRC_CC += thread.cc thread_bootstrap.cc thread_myself.cc
SRC_CC += stack_area_addr.cc SRC_CC += stack_area_addr.cc
SRC_CC += rpc_entry.cc
# suppress warning caused by Pistachio's 'l4/message.h' # suppress warning caused by Pistachio's 'l4/message.h'
CC_WARN += -Wno-array-bounds CC_WARN += -Wno-array-bounds

View File

@ -185,11 +185,10 @@ void Genode::ipc_reply(Native_capability caller, Rpc_exception_code exc,
} }
Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller, Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller,
Rpc_exception_code exc, Rpc_exception_code exc,
Msgbuf_base &reply_msg, Msgbuf_base &reply_msg,
Msgbuf_base &request_msg, Msgbuf_base &request_msg)
Rpc_entrypoint::Native_context &)
{ {
bool need_to_wait = true; bool need_to_wait = true;
@ -238,10 +237,9 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_
} }
Ipc_server::Ipc_server(Rpc_entrypoint::Native_context& _native_context) Ipc_server::Ipc_server()
: :
Native_capability(Capability_space::import(Pistachio::L4_Myself(), Rpc_obj_key())), Native_capability(Capability_space::import(Pistachio::L4_Myself(), Rpc_obj_key()))
_native_context(_native_context)
{ } { }

View File

@ -9,9 +9,7 @@ include $(BASE_DIR)/lib/mk/base-common.inc
LIBS += startup-sel4 syscall-sel4 LIBS += startup-sel4 syscall-sel4
SRC_CC += rpc_dispatch_loop.cc SRC_CC += rpc_dispatch_loop.cc
SRC_CC += rpc_entrypoint_manage.cc
SRC_CC += thread.cc thread_myself.cc thread_bootstrap.cc SRC_CC += thread.cc thread_myself.cc thread_bootstrap.cc
SRC_CC += capability.cc capability_raw.cc SRC_CC += capability.cc capability_raw.cc
SRC_CC += stack_area_addr.cc SRC_CC += stack_area_addr.cc
SRC_CC += platform.cc SRC_CC += platform.cc
SRC_CC += rpc_entry.cc

View File

@ -359,11 +359,10 @@ void Genode::ipc_reply(Native_capability, Rpc_exception_code exc,
} }
Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &, Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &,
Rpc_exception_code exc, Rpc_exception_code exc,
Msgbuf_base &reply_msg, Msgbuf_base &reply_msg,
Msgbuf_base &request_msg, Msgbuf_base &request_msg)
Rpc_entrypoint::Native_context &)
{ {
/* allocate and define receive selector */ /* allocate and define receive selector */
if (!rcv_sel()) if (!rcv_sel())
@ -392,10 +391,9 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &,
} }
Ipc_server::Ipc_server(Rpc_entrypoint::Native_context& _native_context) Ipc_server::Ipc_server()
: :
Native_capability(Capability_space::create_ep_cap(*Thread::myself())), Native_capability(Capability_space::create_ep_cap(*Thread::myself()))
_native_context(_native_context)
{ } { }

View File

@ -1,13 +1,11 @@
/* /*
* \brief Server-side API of the RPC framework * \brief Server-side API of the RPC framework
* \author Norman Feske * \author Norman Feske
* \author Stefan Thöni
* \date 2006-04-28 * \date 2006-04-28
*/ */
/* /*
* Copyright (C) 2006-2020 Genode Labs GmbH * Copyright (C) 2006-2017 Genode Labs GmbH
* Copyright (C) 2020 gapfruit AG
* *
* This file is part of the Genode OS framework, which is distributed * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3. * under the terms of the GNU Affero General Public License version 3.
@ -280,6 +278,7 @@ struct Genode::Rpc_object : Rpc_object_base, Rpc_dispatcher<RPC_INTERFACE, SERVE
} }
}; };
/** /**
* RPC entrypoint serving RPC objects * RPC entrypoint serving RPC objects
* *
@ -302,10 +301,6 @@ class Genode::Rpc_entrypoint : Thread, public Object_pool<Rpc_object_base>
*/ */
friend class Signal_receiver; friend class Signal_receiver;
public:
class Native_context;
private: private:
/** /**
@ -325,8 +320,6 @@ class Genode::Rpc_entrypoint : Thread, public Object_pool<Rpc_object_base>
*/ */
static void _activation_entry(); static void _activation_entry();
static size_t _native_stack_size(size_t stack_size);
struct Exit : Genode::Interface struct Exit : Genode::Interface
{ {
GENODE_RPC(Rpc_exit, void, _exit); GENODE_RPC(Rpc_exit, void, _exit);
@ -351,7 +344,6 @@ class Genode::Rpc_entrypoint : Thread, public Object_pool<Rpc_object_base>
Pd_session &_pd_session; /* for creating capabilities */ Pd_session &_pd_session; /* for creating capabilities */
Exit_handler _exit_handler { }; Exit_handler _exit_handler { };
Capability<Exit> _exit_cap { }; Capability<Exit> _exit_cap { };
Native_context *_native_context { nullptr };
/** /**
* Access to kernel-specific part of the PD session interface * Access to kernel-specific part of the PD session interface
@ -407,12 +399,6 @@ class Genode::Rpc_entrypoint : Thread, public Object_pool<Rpc_object_base>
*/ */
void entry() override; void entry() override;
/**
* Called by implementation specific entry function
* with created native context
*/
void _entry(Native_context& native_context);
public: public:
/** /**
@ -429,12 +415,8 @@ class Genode::Rpc_entrypoint : Thread, public Object_pool<Rpc_object_base>
char const *name, bool start_on_construction = true, char const *name, bool start_on_construction = true,
Affinity::Location location = Affinity::Location()); Affinity::Location location = Affinity::Location());
Rpc_entrypoint(Genode::Rpc_entrypoint const &) = delete;
~Rpc_entrypoint(); ~Rpc_entrypoint();
Genode::Rpc_entrypoint operator=(Genode::Rpc_entrypoint const &) = delete;
/** /**
* Associate RPC object with the entry point * Associate RPC object with the entry point
*/ */

View File

@ -17,7 +17,6 @@
/* Genode includes */ /* Genode includes */
#include <base/stdint.h> #include <base/stdint.h>
#include <base/ipc.h> #include <base/ipc.h>
#include <base/rpc_server.h>
namespace Genode { namespace Genode {
@ -45,25 +44,17 @@ namespace Genode {
/** /**
* Send result of previous RPC request and wait for new one * Send result of previous RPC request and wait for new one
*/ */
Rpc_request ipc_reply_wait(Reply_capability const &caller, Rpc_request ipc_reply_wait(Reply_capability const &caller,
Rpc_exception_code reply_exc, Rpc_exception_code reply_exc,
Msgbuf_base &reply_msg, Msgbuf_base &reply_msg,
Msgbuf_base &request_msg, Msgbuf_base &request_msg);
Rpc_entrypoint::Native_context &native_context);
} }
class Genode::Ipc_server : public Native_capability struct Genode::Ipc_server : Native_capability
{ {
private: Ipc_server();
~Ipc_server();
Rpc_entrypoint::Native_context& _native_context;
public:
Ipc_server(Rpc_entrypoint::Native_context& native_context);
~Ipc_server();
}; };
#endif /* _INCLUDE__BASE__INTERNAL__IPC_SERVER_H_ */ #endif /* _INCLUDE__BASE__INTERNAL__IPC_SERVER_H_ */

View File

@ -20,11 +20,33 @@
using namespace Genode; using namespace Genode;
void Rpc_entrypoint::_entry(Native_context& native_context)
{
_native_context = &native_context;
Ipc_server srv(native_context); /***********************
** Server entrypoint **
***********************/
Untyped_capability Rpc_entrypoint::_manage(Rpc_object_base *obj)
{
/* don't manage RPC object twice */
if (obj->cap().valid()) {
warning("attempt to manage RPC object twice");
return obj->cap();
}
Untyped_capability new_obj_cap = _alloc_rpc_cap(_pd_session, _cap);
/* add server object to object pool */
obj->cap(new_obj_cap);
insert(obj);
/* return capability that uses the object id as badge */
return new_obj_cap;
}
void Rpc_entrypoint::entry()
{
Ipc_server srv;
_cap = srv; _cap = srv;
_cap_valid.wakeup(); _cap_valid.wakeup();
@ -41,7 +63,7 @@ void Rpc_entrypoint::_entry(Native_context& native_context)
while (!_exit_handler.exit) { while (!_exit_handler.exit) {
Rpc_request const request = ipc_reply_wait(_caller, exc, _snd_buf, _rcv_buf, native_context); Rpc_request const request = ipc_reply_wait(_caller, exc, _snd_buf, _rcv_buf);
_caller = request.caller; _caller = request.caller;
Ipc_unmarshaller unmarshaller(_rcv_buf); Ipc_unmarshaller unmarshaller(_rcv_buf);

View File

@ -1,40 +0,0 @@
/*
* \brief Default version of platform-specific part of RPC framework
* \author Stefan Thöni
* \date 2020-01-30
*/
/*
* Copyright (C) 2006-2020 Genode Labs GmbH
* Copyright (C) 2020 gapfruit AG
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* Genode includes */
#include <base/rpc_server.h>
/* base-internal includes */
#include <base/internal/ipc_server.h>
using namespace Genode;
class Rpc_entrypoint::Native_context
{
};
void Rpc_entrypoint::entry()
{
Native_context context { };
_entry(context);
}
size_t Rpc_entrypoint::_native_stack_size(size_t stack_size)
{
return stack_size + sizeof(Native_context);
}

View File

@ -73,7 +73,7 @@ Rpc_entrypoint::Rpc_entrypoint(Pd_session *pd_session, size_t stack_size,
char const *name, bool start_on_construction, char const *name, bool start_on_construction,
Affinity::Location location) Affinity::Location location)
: :
Thread(Cpu_session::Weight::DEFAULT_WEIGHT, name, _native_stack_size(stack_size), location), Thread(Cpu_session::Weight::DEFAULT_WEIGHT, name, stack_size, location),
_cap(Untyped_capability()), _cap(Untyped_capability()),
_pd_session(*pd_session) _pd_session(*pd_session)
{ {

View File

@ -1,45 +0,0 @@
/*
* \brief Default version of platform-specific part of RPC framework
* \author Norman Feske
* \date 2006-05-12
*/
/*
* Copyright (C) 2006-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.
*/
/* Genode includes */
#include <util/retry.h>
#include <base/rpc_server.h>
/* base-internal includes */
#include <base/internal/ipc_server.h>
using namespace Genode;
/***********************
** Server entrypoint **
***********************/
Untyped_capability Rpc_entrypoint::_manage(Rpc_object_base *obj)
{
/* don't manage RPC object twice */
if (obj->cap().valid()) {
warning("attempt to manage RPC object twice");
return obj->cap();
}
Untyped_capability new_obj_cap = _alloc_rpc_cap(_pd_session, _cap);
/* add server object to object pool */
obj->cap(new_obj_cap);
insert(obj);
/* return capability that uses the object id as badge */
return new_obj_cap;
}