1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:37:35 +00:00

Kernel: Move devices into Kernel/Devices/.

This commit is contained in:
Andreas Kling 2019-04-03 12:36:40 +02:00
parent 072ea7eece
commit ab43658c55
42 changed files with 53 additions and 54 deletions

View file

@ -0,0 +1,42 @@
#include <Kernel/Devices/DiskDevice.h>
DiskDevice::DiskDevice()
{
}
DiskDevice::~DiskDevice()
{
}
bool DiskDevice::read(DiskOffset offset, unsigned length, byte* out) const
{
ASSERT((offset % block_size()) == 0);
ASSERT((length % block_size()) == 0);
dword first_block = offset / block_size();
dword end_block = (offset + length) / block_size();
byte* outptr = out;
for (unsigned bi = first_block; bi < end_block; ++bi) {
if (!read_block(bi, outptr))
return false;
outptr += block_size();
}
return true;
}
bool DiskDevice::write(DiskOffset offset, unsigned length, const byte* in)
{
ASSERT((offset % block_size()) == 0);
ASSERT((length % block_size()) == 0);
dword first_block = offset / block_size();
dword end_block = (offset + length) / block_size();
ASSERT(first_block <= 0xffffffff);
ASSERT(end_block <= 0xffffffff);
const byte* inptr = in;
for (unsigned bi = first_block; bi < end_block; ++bi) {
if (!write_block(bi, inptr))
return false;
inptr += block_size();
}
return true;
}