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

Method ATADiskDevice

Kernel/src/storage/atadrive.cpp:10–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9namespace ATA{
10 ATADiskDevice::ATADiskDevice(int port, int drive) {
11 this->port = port;
12 this->drive = drive;
13
14 prdBufferPhys = Memory::AllocatePhysicalMemoryBlock();
15 prdBuffer = (uint8_t*)Memory::KernelAllocate4KPages(1);
16
17 prdtPhys = Memory::AllocatePhysicalMemoryBlock();
18 prdt = (uint64_t*)Memory::GetIOMapping(prdtPhys);
19
20 Memory::KernelMapVirtualMemory4K(prdBufferPhys, (uintptr_t)prdBuffer, 1);
21 Memory::KernelMapVirtualMemory4K(prdtPhys, (uintptr_t)prdt, 1);
22
23 prd = ATA_PRD_BUFFER((uint64_t)prdBufferPhys) | ((uint64_t)PAGE_SIZE_4K << 32) | ATA_PRD_END; // Assign the buffer, transfer size (4K) and designate the PRDT entry as the last one
24 *prdt = prd;
25
26 switch(GPT::Parse(this)){
27 case 0:
28 Log::Error("ATA Disk ");
29 Log::Write(this->port ? "Secondary " : "Primary ");
30 Log::Write(this->drive ? "Slave " : "Master ");
31 Log::Write("has a corrupted or non-existant GPT. MBR disks are NOT supported.");
32 break;
33 case -1:
34 Log::Error("Disk Error while Parsing GPT for ATA Disk ");
35 Log::Write(this->port ? "Secondary " : "Primary ");
36 Log::Write(this->drive ? "Slave " : "Master ");
37 break;
38 }
39
40 InitializePartitions();
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);

Callers

nothing calls this directly

Calls 7

KernelAllocate4KPagesFunction · 0.85
GetIOMappingFunction · 0.85
KernelMapVirtualMemory4KFunction · 0.85
ErrorFunction · 0.85
ParseFunction · 0.50
WriteFunction · 0.50

Tested by

no test coverage detected