MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / ReadDiskBlock

Method ReadDiskBlock

Kernel/src/storage/atadrive.cpp:43–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41 }
42
43 int ATADiskDevice::ReadDiskBlock(uint64_t lba, uint32_t count, void* _buffer){
44 uint64_t blockCount = ((count / 512 * 512) < count) ? ((count / 512) + 1) : (count / 512);
45 uint8_t* buffer = reinterpret_cast<uint8_t*>(_buffer);
46
47 while(blockCount-- && count){
48 uint64_t size;
49 if(count < 512) size = count;
50 else size = 512;
51
52 if(!size) continue;
53
54 driveLock.Wait();
55 if(ATA::Access(this, lba, 1, false)){
56 driveLock.Signal();
57 return 1; // Error Reading Sectors
58 }
59
60 memcpy(buffer, prdBuffer, size);
61 driveLock.Signal();
62
63 buffer += size;
64 lba++;
65 }
66
67 return 0;
68 }
69
70 int ATADiskDevice::WriteDiskBlock(uint64_t lba, uint32_t count, void* _buffer){
71 uint64_t blockCount = ((count / 512 * 512) < count) ? ((count / 512) + 1) : (count / 512);

Callers

nothing calls this directly

Calls 4

AccessFunction · 0.85
memcpyFunction · 0.85
SignalMethod · 0.80
WaitMethod · 0.45

Tested by

no test coverage detected