2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Server-side interface for packet-stream reception
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2010-03-01
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 12:23:52 +00:00
|
|
|
* Copyright (C) 2010-2017 Genode Labs GmbH
|
2011-12-22 15:19:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2011-12-22 15:19:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__PACKET_STREAM_RX__RPC_OBJECT_H_
|
|
|
|
#define _INCLUDE__PACKET_STREAM_RX__RPC_OBJECT_H_
|
|
|
|
|
|
|
|
#include <packet_stream_rx/packet_stream_rx.h>
|
|
|
|
#include <base/rpc_server.h>
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
namespace Packet_stream_rx { template <typename> class Rpc_object; }
|
|
|
|
|
|
|
|
|
|
|
|
template <typename CHANNEL>
|
|
|
|
class Packet_stream_rx::Rpc_object : public Genode::Rpc_object<CHANNEL, Rpc_object<CHANNEL> >
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
Genode::Rpc_entrypoint &_ep;
|
|
|
|
Genode::Capability<CHANNEL> _cap;
|
|
|
|
typename CHANNEL::Source _source;
|
|
|
|
|
|
|
|
Genode::Signal_context_capability _sigh_ready_to_submit;
|
|
|
|
Genode::Signal_context_capability _sigh_ack_avail;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* \param ds dataspace used as communication buffer
|
|
|
|
* for the receive packet stream
|
|
|
|
* \param buffer_alloc allocator used for managing the communication
|
|
|
|
* buffer of the receive packet stream
|
|
|
|
* \param ep entry point used for serving the channel's RPC
|
|
|
|
* interface
|
|
|
|
*/
|
|
|
|
Rpc_object(Genode::Dataspace_capability ds,
|
2016-07-22 08:05:52 +00:00
|
|
|
Genode::Region_map &rm,
|
|
|
|
Genode::Range_allocator &buffer_alloc,
|
2015-03-04 20:12:14 +00:00
|
|
|
Genode::Rpc_entrypoint &ep)
|
2016-07-22 08:05:52 +00:00
|
|
|
: _ep(ep), _cap(_ep.manage(this)), _source(ds, rm, buffer_alloc),
|
2015-03-04 20:12:14 +00:00
|
|
|
|
|
|
|
/* init signal handlers with default handlers of source */
|
|
|
|
_sigh_ready_to_submit(_source.sigh_ready_to_submit()),
|
|
|
|
_sigh_ack_avail(_source.sigh_ack_avail()) { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
~Rpc_object() { _ep.dissolve(this); }
|
|
|
|
|
|
|
|
/*
|
2015-03-20 16:50:41 +00:00
|
|
|
* The 'sigh_ack_avail()' and 'sigh_ready_to_submit()' methods
|
2015-03-04 20:12:14 +00:00
|
|
|
* may be called at session-creation time to override the default
|
|
|
|
* data-flow signal handlers as provided by the packet-stream source.
|
|
|
|
* The default handlers let the server block in the event of data
|
|
|
|
* congestion. By installing custom signal handlers, a server
|
|
|
|
* implementation is able to avoid blocking for a single event by
|
|
|
|
* facilitating the use of a select-like mode of operation.
|
|
|
|
*
|
2015-03-20 16:50:41 +00:00
|
|
|
* Note that calling these methods after the finished creation of
|
2015-03-04 20:12:14 +00:00
|
|
|
* the session has no effect because the client queries the signal
|
|
|
|
* handlers only once at session-creation time.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override default handler for server-side ready-to-submit signals
|
|
|
|
*
|
|
|
|
* Must be called at constuction time only.
|
|
|
|
*/
|
|
|
|
void sigh_ready_to_submit(Genode::Signal_context_capability sigh) {
|
|
|
|
_sigh_ready_to_submit = sigh; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override default handler for server-side ack-avail signals
|
|
|
|
*
|
|
|
|
* Must be called at constuction time only.
|
|
|
|
*/
|
|
|
|
void sigh_ack_avail(Genode::Signal_context_capability sigh) {
|
|
|
|
_sigh_ack_avail = sigh; }
|
|
|
|
|
|
|
|
typename CHANNEL::Source *source() { return &_source; }
|
|
|
|
|
|
|
|
Genode::Capability<CHANNEL> cap() const { return _cap; }
|
|
|
|
|
|
|
|
|
|
|
|
/*******************
|
|
|
|
** RPC functions **
|
|
|
|
*******************/
|
|
|
|
|
|
|
|
Genode::Dataspace_capability dataspace() { return _source.dataspace(); }
|
|
|
|
|
|
|
|
void sigh_ready_to_ack(Genode::Signal_context_capability sigh) {
|
|
|
|
_source.register_sigh_ready_to_ack(sigh); }
|
|
|
|
|
|
|
|
void sigh_packet_avail(Genode::Signal_context_capability sigh) {
|
|
|
|
_source.register_sigh_packet_avail(sigh); }
|
|
|
|
|
|
|
|
virtual Genode::Signal_context_capability sigh_ready_to_submit() {
|
|
|
|
return _sigh_ready_to_submit; }
|
|
|
|
|
|
|
|
virtual Genode::Signal_context_capability sigh_ack_avail() {
|
|
|
|
return _sigh_ack_avail; }
|
|
|
|
|
|
|
|
};
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#endif /* _INCLUDE__PACKET_STREAM_RX__RPC_OBJECT_H_ */
|