2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Client-side block session interface
|
|
|
|
* \author Stefan Kalkowski
|
|
|
|
* \date 2010-07-06
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
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__BLOCK_SESSION__CLIENT_H_
|
|
|
|
#define _INCLUDE__BLOCK_SESSION__CLIENT_H_
|
|
|
|
|
|
|
|
#include <base/rpc_client.h>
|
|
|
|
#include <block_session/capability.h>
|
|
|
|
#include <packet_stream_tx/client.h>
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
namespace Block { class Session_client; }
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
class Block::Session_client : public Genode::Rpc_client<Session>
|
|
|
|
{
|
2019-04-10 13:07:16 +00:00
|
|
|
protected:
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
Packet_stream_tx::Client<Tx> _tx;
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2019-04-04 16:25:54 +00:00
|
|
|
Info const _info = info();
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
public:
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* \param session session capability
|
|
|
|
* \param tx_buffer_alloc allocator used for managing the
|
|
|
|
* transmission buffer
|
|
|
|
*/
|
|
|
|
Session_client(Session_capability session,
|
2016-07-22 08:05:52 +00:00
|
|
|
Genode::Range_allocator &tx_buffer_alloc,
|
|
|
|
Genode::Region_map &rm)
|
2015-03-04 20:12:14 +00:00
|
|
|
:
|
|
|
|
Genode::Rpc_client<Session>(session),
|
2018-12-12 20:22:19 +00:00
|
|
|
_tx(tx_cap(), rm, tx_buffer_alloc)
|
2015-03-04 20:12:14 +00:00
|
|
|
{ }
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
/*****************************
|
|
|
|
** Block session interface **
|
|
|
|
*****************************/
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2019-04-03 14:05:10 +00:00
|
|
|
Info info() const override { return call<Rpc_info>(); }
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2019-02-14 21:39:08 +00:00
|
|
|
Tx *tx_channel() override { return &_tx; }
|
2018-12-12 20:22:19 +00:00
|
|
|
|
2019-02-14 21:39:08 +00:00
|
|
|
Tx::Source *tx() override { return _tx.source(); }
|
2018-12-12 20:22:19 +00:00
|
|
|
|
|
|
|
Genode::Capability<Tx> tx_cap() override { return call<Rpc_tx_cap>(); }
|
|
|
|
|
2019-04-04 16:25:54 +00:00
|
|
|
/**
|
|
|
|
* Allocate packet respecting the server's alignment constraints
|
2015-03-04 20:12:14 +00:00
|
|
|
*/
|
2019-04-04 16:25:54 +00:00
|
|
|
Packet_descriptor alloc_packet(Genode::size_t size)
|
2015-03-04 20:12:14 +00:00
|
|
|
{
|
2019-04-04 16:25:54 +00:00
|
|
|
return tx()->alloc_packet(size, _info.align_log2);
|
2015-03-04 20:12:14 +00:00
|
|
|
}
|
|
|
|
};
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#endif /* _INCLUDE__BLOCK_SESSION__CLIENT_H_ */
|