62b1c55399
This patch integrates the functionality of the former CAP session into the PD session and unifies the approch of supplementing the generic PD session with kernel-specific functionality. The latter is achieved by the new 'Native_pd' interface. The kernel-specific interface can be obtained via the Pd_session::native_pd accessor function. The kernel-specific interfaces are named Nova_native_pd, Foc_native_pd, and Linux_native_pd. The latter change allowed for to deduplication of the pd_session_component code among the various base platforms. To retain API compatibility, we keep the 'Cap_session' and 'Cap_connection' around. But those classes have become mere wrappers around the PD session interface. Issue #1841
81 lines
1.9 KiB
C++
81 lines
1.9 KiB
C++
/*
|
|
* \brief base-hw specific part of RPC framework
|
|
* \author Stefan Kalkowski
|
|
* \date 2015-03-05
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2015 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 <base/rpc_server.h>
|
|
#include <base/sleep.h>
|
|
#include <base/env.h>
|
|
#include <util/retry.h>
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
/***********************
|
|
** Server entrypoint **
|
|
***********************/
|
|
|
|
Untyped_capability Rpc_entrypoint::_manage(Rpc_object_base *obj)
|
|
{
|
|
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(&_snd_buf, &_rcv_buf);
|
|
_ipc_server = &srv;
|
|
_cap = srv;
|
|
_cap_valid.unlock();
|
|
|
|
/*
|
|
* Now, the capability of the server activation is initialized
|
|
* an can be passed around. However, the processing of capability
|
|
* invocations should not happen until activation-using server
|
|
* is completely initialized. Thus, we wait until the activation
|
|
* gets explicitly unblocked by calling 'Rpc_entrypoint::activate()'.
|
|
*/
|
|
_delay_start.lock();
|
|
|
|
while (!_exit_handler.exit) {
|
|
|
|
int opcode = 0;
|
|
|
|
srv >> IPC_REPLY_WAIT >> opcode;
|
|
|
|
/* set default return value */
|
|
srv.ret(Ipc_client::ERR_INVALID_OBJECT);
|
|
|
|
/* atomically lookup and lock referenced object */
|
|
apply(srv.badge(), [&] (Rpc_object_base *curr_obj) {
|
|
if (!curr_obj) return;
|
|
|
|
/* dispatch request */
|
|
try { srv.ret(curr_obj->dispatch(opcode, srv, srv)); }
|
|
catch (Blocking_canceled) { }
|
|
});
|
|
}
|
|
|
|
/* answer exit call, thereby wake up '~Rpc_entrypoint' */
|
|
srv << IPC_REPLY;
|
|
|
|
/* defer the destruction of 'Ipc_server' until '~Rpc_entrypoint' is ready */
|
|
_delay_exit.lock();
|
|
}
|