block: extend interface of generic driver class

To support read-only devices like CDROMs, or rom_blk the supported
block operations have to be stated by specific the device driver.

Ref #966
This commit is contained in:
Stefan Kalkowski 2013-11-23 00:24:44 +01:00 committed by Norman Feske
parent 5a4cb7fcfb
commit 0c8a4f9f3a
6 changed files with 40 additions and 3 deletions

View File

@ -136,8 +136,7 @@ class Block::Session_component : public Block::Session_rpc_object
{
*blk_count = _driver.block_count();
*blk_size = _driver.block_size();
ops->set_operation(Packet_descriptor::READ);
ops->set_operation(Packet_descriptor::WRITE);
*ops = _driver.ops();
}
void sync() { _driver.sync(); }

View File

@ -19,7 +19,7 @@
#include <base/stdint.h>
#include <ram_session/ram_session.h>
#include <block_session/block_session.h>
namespace Block {
@ -43,6 +43,11 @@ namespace Block {
*/
virtual Genode::size_t block_count() = 0;
/**
* Request operations supported by the device
*/
virtual Session::Operations ops() = 0;
/**
* Read from medium
*

View File

@ -46,6 +46,15 @@ class Ahci_driver_base : public Block::Driver
size_t block_size() { return Ahci_device::block_size(); }
size_t block_count() { return _device ? _device->block_count() : 0; }
Block::Session::Operations ops()
{
Block::Session::Operations o;
o.set_operation(Block::Packet_descriptor::READ);
o.set_operation(Block::Packet_descriptor::WRITE);
return o;
}
bool dma_enabled() { return true; }
void read_dma(size_t block_number,

View File

@ -89,6 +89,14 @@ class Block::Exynos5_driver : public Block::Driver
return _controller.card_info().capacity_mb() * 1024 * 2;
}
Block::Session::Operations ops()
{
Block::Session::Operations o;
o.set_operation(Block::Packet_descriptor::READ);
o.set_operation(Block::Packet_descriptor::WRITE);
return o;
}
void read(Genode::size_t block_number,
Genode::size_t block_count,
char *out_buffer)

View File

@ -82,6 +82,14 @@ class Block::Omap4_driver : public Block::Driver
return _controller.card_info().capacity_mb() * 1024 * 2;
}
Block::Session::Operations ops()
{
Block::Session::Operations o;
o.set_operation(Block::Packet_descriptor::READ);
o.set_operation(Block::Packet_descriptor::WRITE);
return o;
}
void read(Genode::size_t block_number,
Genode::size_t block_count,
char *out_buffer)

View File

@ -79,6 +79,14 @@ class Sd_card : public Block::Driver
*/
Genode::size_t block_count() { return 0x20000000 / BLOCK_SIZE; }
Block::Session::Operations ops()
{
Block::Session::Operations o;
o.set_operation(Block::Packet_descriptor::READ);
o.set_operation(Block::Packet_descriptor::WRITE);
return o;
}
void read(Genode::size_t block_number,
Genode::size_t block_count,
char *out_buffer)