block session: remove Block::Session::Operations

This patch modernizes the 'Block::Session::info' interface. Instead of
using out parameters, the 'init' RPC function returns a compound 'Info'
object now. The rather complicated 'Operations' struct is replaced by
a 'writeable' attribute in the 'Info' object.

Fixes #3275
This commit is contained in:
Norman Feske
2019-04-03 16:05:10 +02:00
committed by Christian Helmuth
parent 10c567daee
commit 2208220c12
45 changed files with 385 additions and 526 deletions

View File

@@ -29,27 +29,16 @@ class Backend
{
private:
Genode::Allocator_avl _alloc { &Rump::env().heap() };
Block::Connection _session { Rump::env().env(), &_alloc };
Genode::size_t _blk_size; /* block size of the device */
Block::sector_t _blk_cnt; /* number of blocks of device */
Block::Session::Operations _blk_ops;
Genode::Lock _session_lock;
Genode::Allocator_avl _alloc { &Rump::env().heap() };
Block::Connection _session { Rump::env().env(), &_alloc };
Block::Session::Info _info { _session.info() };
Genode::Lock _session_lock;
public:
Backend()
{
_session.info(&_blk_cnt, &_blk_size, &_blk_ops);
}
uint64_t block_count() const { return (uint64_t)_blk_cnt; }
size_t block_size() const { return (size_t)_blk_size; }
bool writable()
{
return _blk_ops.supported(Block::Packet_descriptor::WRITE);
}
uint64_t block_count() const { return _info.block_count; }
size_t block_size() const { return _info.block_size; }
bool writable() const { return _info.writeable; }
void sync()
{
@@ -69,8 +58,8 @@ class Backend
/* allocate packet */
try {
Packet_descriptor packet( _session.dma_alloc_packet(length),
opcode, offset / _blk_size,
length / _blk_size);
opcode, offset / _info.block_size,
length / _info.block_size);
/* out packet -> copy data */
if (opcode == Packet_descriptor::WRITE)