blob: d9c0a69f3ba2d0b95d8b6326a63e66e458d5150d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include "DiskDevice.h"
DiskDevice::DiskDevice()
{
}
DiskDevice::~DiskDevice()
{
}
bool DiskDevice::read(DiskOffset offset, unsigned length, byte* out) const
{
//kprintf("DD::read %u x%u\n", offset, length);
ASSERT((offset % block_size()) == 0);
ASSERT((length % block_size()) == 0);
dword firstBlock = offset / block_size();
dword endBlock = (offset + length) / block_size();
byte* outptr = out;
for (unsigned bi = firstBlock; bi < endBlock; ++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 firstBlock = offset / block_size();
dword endBlock = (offset + length) / block_size();
ASSERT(firstBlock <= 0xffffffff);
ASSERT(endBlock <= 0xffffffff);
const byte* inptr = in;
for (unsigned bi = firstBlock; bi < endBlock; ++bi) {
if (!write_block(bi, inptr))
return false;
inptr += block_size();
}
return true;
}
|