mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
Kernel: Merge unnecessary DiskDevice class into BlockDevice
This commit is contained in:
parent
6be880bd10
commit
88ea152b24
27 changed files with 98 additions and 212 deletions
|
@ -29,3 +29,33 @@
|
|||
BlockDevice::~BlockDevice()
|
||||
{
|
||||
}
|
||||
|
||||
bool BlockDevice::read_block(unsigned index, u8* buffer) const
|
||||
{
|
||||
return const_cast<BlockDevice*>(this)->read_blocks(index, 1, buffer);
|
||||
}
|
||||
|
||||
bool BlockDevice::write_block(unsigned index, const u8* data)
|
||||
{
|
||||
return write_blocks(index, 1, data);
|
||||
}
|
||||
|
||||
bool BlockDevice::read_raw(u32 offset, unsigned length, u8* out) const
|
||||
{
|
||||
ASSERT((offset % block_size()) == 0);
|
||||
ASSERT((length % block_size()) == 0);
|
||||
u32 first_block = offset / block_size();
|
||||
u32 end_block = (offset + length) / block_size();
|
||||
return const_cast<BlockDevice*>(this)->read_blocks(first_block, end_block - first_block, out);
|
||||
}
|
||||
|
||||
bool BlockDevice::write_raw(u32 offset, unsigned length, const u8* in)
|
||||
{
|
||||
ASSERT((offset % block_size()) == 0);
|
||||
ASSERT((length % block_size()) == 0);
|
||||
u32 first_block = offset / block_size();
|
||||
u32 end_block = (offset + length) / block_size();
|
||||
ASSERT(first_block <= 0xffffffff);
|
||||
ASSERT(end_block <= 0xffffffff);
|
||||
return write_blocks(first_block, end_block - first_block, in);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue