base: simplification of the IPC code

This commit replaces the stateful 'Ipc_client' type with the plain
function 'ipc_call' that takes all the needed state as arguments.
The stateful 'Ipc_server' class is retained but it moved from the public
API to the internal ipc_server.h header. The kernel-specific
implementations were cleaned up and simplified. E.g., the 'wait'
function does no longer exist. The badge and exception code are no
longer carried in the message buffers but are handled in kernel-specific
ways.

Issue #610
Issue #1832
This commit is contained in:
Norman Feske
2016-03-15 20:01:59 +01:00
committed by Christian Helmuth
parent 47878bd3e1
commit cda07b7da0
33 changed files with 1106 additions and 1115 deletions

View File

@ -11,11 +11,15 @@
* under the terms of the GNU General Public License version 2.
*/
/* Genode includes */
#include <base/rpc_server.h>
#include <base/rpc_client.h>
#include <base/blocking.h>
#include <base/env.h>
/* base-internal includes */
#include <base/internal/ipc_server.h>
using namespace Genode;
@ -58,7 +62,7 @@ void Rpc_entrypoint::reply_signal_info(Untyped_capability reply_cap,
Untyped_capability last_reply_cap = _ipc_server->caller();
/* direct ipc server to the specified reply destination */
_ipc_server->ret(0);
_ipc_server->ret(Rpc_exception_code(Rpc_exception_code::SUCCESS));
_ipc_server->caller(reply_cap);
_ipc_server->insert(Signal_source::Signal(imprint, cnt));
_ipc_server->reply();

View File

@ -18,9 +18,10 @@
/* Genode includes */
#include <base/rpc_server.h>
#include <base/sleep.h>
#include <base/printf.h>
/* base-internal includes */
#include <base/internal/native_connection_state.h>
#include <base/internal/ipc_server.h>
using namespace Genode;
@ -64,13 +65,13 @@ void Rpc_entrypoint::entry()
while (!_exit_handler.exit) {
int opcode = 0;
Rpc_opcode opcode(0);
srv.reply_wait();
srv.extract(opcode);
/* set default return value */
srv.ret(Ipc_client::ERR_INVALID_OBJECT);
srv.ret(Rpc_exception_code(Rpc_exception_code::INVALID_OBJECT));
Pool::apply(srv.badge(), [&] (Rpc_object_base *obj)
{

View File

@ -21,10 +21,9 @@ void Pager_object::wake_up()
{
/* notify pager to wake up faulter */
Msgbuf<16> snd, rcv;
Native_capability pager = cap();
Ipc_client ipc_client(pager, snd, rcv);
ipc_client.insert(this);
ipc_client.call();
Ipc_marshaller marshaller(snd);
marshaller.insert(this);
ipc_call(cap(), snd, rcv, 0);
}

View File

@ -0,0 +1,90 @@
/*
* \brief IPC server
* \author Norman Feske
* \date 2016-03-16
*/
/*
* Copyright (C) 2016 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 _INCLUDE__BASE__INTERNAL__IPC_SERVER_H_
#define _INCLUDE__BASE__INTERNAL__IPC_SERVER_H_
/* Genode includes */
#include <base/stdint.h>
#include <base/ipc.h>
/* base-internal includes */
#include <base/internal/native_connection_state.h>
namespace Genode {
class Native_connection_state;
class Ipc_server;
}
class Genode::Ipc_server : public Ipc_marshaller, public Ipc_unmarshaller,
public Native_capability
{
private:
bool _reply_needed = false; /* false for the first reply_wait */
Native_capability _caller;
Native_connection_state &_rcv_cs;
void _prepare_next_reply_wait();
unsigned long _badge = 0;
Rpc_exception_code _exception_code { 0 };
public:
/**
* Constructor
*/
Ipc_server(Native_connection_state &,
Msgbuf_base &snd_msg, Msgbuf_base &rcv_msg);
~Ipc_server();
/**
* Send reply to destination
*/
void reply();
/**
* Send result of previous RPC request and wait for new one
*/
void reply_wait();
/**
* Set return value of server call
*/
void ret(Rpc_exception_code code) { _exception_code = code; }
/**
* Read badge that was supplied with the message
*/
unsigned long badge() const { return _badge; }
/**
* Set reply destination
*/
void caller(Native_capability const &caller)
{
_caller = caller;
_reply_needed = caller.valid();
}
Native_capability caller() const { return _caller; }
};
#endif /* _INCLUDE__BASE__INTERNAL__IPC_SERVER_H_ */