usb_block_drv: calculate block count correctly

Fixes #2823
This commit is contained in:
Christian Prochaska 2018-05-07 16:10:39 +02:00 committed by Christian Helmuth
parent 3d480ec947
commit 106a5f1d4d
2 changed files with 12 additions and 12 deletions

View File

@ -223,7 +223,7 @@ struct Usb::Block_driver : Usb::Completion,
Capacity_response_10 r((addr_t)data);
if (verbose_scsi) r.dump();
block_count = r.block_count();
block_count = r.last_block() + 1;
block_size = r.block_size();
break;
}
@ -232,7 +232,7 @@ struct Usb::Block_driver : Usb::Completion,
Capacity_response_16 r((addr_t)data);
if (verbose_scsi) r.dump();
block_count = r.block_count();
block_count = r.last_block() + 1;
block_size = r.block_size();
break;
}

View File

@ -176,18 +176,18 @@ struct Scsi::Capacity_response_10 : Genode::Mmio
{
enum { LENGTH = 8 };
struct Bc : Register<0x0, 32> { };
struct Bs : Register<0x4, 32> { };
struct Lba : Register<0x0, 32> { };
struct Bs : Register<0x4, 32> { };
Capacity_response_10(addr_t addr) : Mmio(addr) { }
uint32_t block_count() const { return be32(read<Bc>()); }
uint32_t block_size() const { return be32(read<Bs>()); }
uint32_t last_block() const { return be32(read<Lba>()); }
uint32_t block_size() const { return be32(read<Bs>()); }
void dump()
{
Genode::log("--- Dump READ_CAPACITY_10 data ---");
Genode::log("Bc: ", Genode::Hex(block_count()));
Genode::log("Lba: ", Genode::Hex(last_block()));
Genode::log("Bs: ", Genode::Hex(block_size()));
}
};
@ -197,18 +197,18 @@ struct Scsi::Capacity_response_16 : Genode::Mmio
{
enum { LENGTH = 32 };
struct Bc : Register<0x0, 64> { };
struct Bs : Register<0x8, 32> { };
struct Lba : Register<0x0, 64> { };
struct Bs : Register<0x8, 32> { };
Capacity_response_16(addr_t addr) : Mmio(addr) { }
uint64_t block_count() const { return be64(read<Bc>()); }
uint32_t block_size() const { return be32(read<Bs>()); }
uint64_t last_block() const { return be64(read<Lba>()); }
uint32_t block_size() const { return be32(read<Bs>()); }
void dump()
{
Genode::log("--- Dump READ_CAPACITY_16 data ---");
Genode::log("Bc: ", Genode::Hex(block_count()));
Genode::log("Lba: ", Genode::Hex(last_block()));
Genode::log("Bs: ", Genode::Hex(block_size()));
}
};