base: lay groundwork for base-linux caps change

Include the necessary hooks to introduce file descriptor
based capabilities in base linux.

Issue #3581
This commit is contained in:
Stefan Thöni
2020-02-19 11:35:13 +01:00
committed by Christian Helmuth
parent 5eaaee0dbe
commit a7a9855493
28 changed files with 249 additions and 78 deletions

View File

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

View File

@ -0,0 +1,22 @@
/*
* \brief Platform dependant hook after binary ready
* \author Stefan Thoeni
* \date 2019-12-13
*/
/*
* Copyright (C) 2019 Genode Labs GmbH
* Copyright (C) 2019 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.
*/
/* base-internal includes */
#include <base/platform.h>
void binary_ready_hook_for_platform()
{
}

View File

@ -20,33 +20,11 @@
using namespace Genode;
/***********************
** Server entrypoint **
***********************/
Untyped_capability Rpc_entrypoint::_manage(Rpc_object_base *obj)
void Rpc_entrypoint::_entry(Native_context& native_context)
{
/* don't manage RPC object twice */
if (obj->cap().valid()) {
warning("attempt to manage RPC object twice");
return obj->cap();
}
_native_context = &native_context;
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;
Ipc_server srv(native_context);
_cap = srv;
_cap_valid.unlock();
@ -63,7 +41,7 @@ void Rpc_entrypoint::entry()
while (!_exit_handler.exit) {
Rpc_request const request = ipc_reply_wait(_caller, exc, _snd_buf, _rcv_buf);
Rpc_request const request = ipc_reply_wait(_caller, exc, _snd_buf, _rcv_buf, native_context);
_caller = request.caller;
Ipc_unmarshaller unmarshaller(_rcv_buf);

View File

@ -0,0 +1,40 @@
/*
* \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,
Affinity::Location location)
:
Thread(Cpu_session::Weight::DEFAULT_WEIGHT, name, stack_size, location),
Thread(Cpu_session::Weight::DEFAULT_WEIGHT, name, _native_stack_size(stack_size), location),
_cap(Untyped_capability()),
_cap_valid(Lock::LOCKED), _delay_start(Lock::LOCKED),
_delay_exit(Lock::LOCKED),

View File

@ -0,0 +1,45 @@
/*
* \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;
}

View File

@ -19,6 +19,7 @@
#include <util/string.h>
#include <base/thread.h>
#include <base/heap.h>
#include <base/platform.h>
/* base-internal includes */
#include <base/internal/unmanaged_singleton.h>
@ -783,6 +784,8 @@ void Component::construct(Genode::Env &env)
binary_ready_hook_for_gdb();
binary_ready_hook_for_platform();
/* start binary */
binary_ptr->call_entry_point(env);
}