summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-04-26 12:23:00 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-04-26 12:23:00 +0200
commitfc19214c74c39177f85a4ee0748ac4ec9c1d4f33 (patch)
tree9589fc5a88b3ff7d62390289c8fe00f71dfb45e5 /Private/NewBoot/Source
parent72b014b98fab4a6f875648a4b7b42347f780067e (diff)
MHR-16: Fix bug inside GetDiskSize, use a simple formula instead of
doing stupid sh*t. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootATA.cxx23
1 files changed, 2 insertions, 21 deletions
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
index 4bf7bc96..8ab7dc20 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootATA.cxx
@@ -229,28 +229,9 @@ BootDeviceATA::ATATrait& BootDeviceATA::Leak() { return mTrait; }
@brief Getter, gets the number of sectors inside the drive.
*/
SizeT BootDeviceATA::GetSectorsCount() noexcept {
- return kATAData[60] + kATAData[61];
+ return (kATAData[61] << 16)| kATAData[60];
}
SizeT BootDeviceATA::GetDiskSize() noexcept {
- Out8(this->Leak().mBus + ATA_REG_COMMAND, 0xF8);
-
- boot_ata_wait_io(this->Leak().mBus);
-
- UInt64 result = 0;
-
- result = In8(this->Leak().mBus + ATA_CYL_LOW);
- result += In8(this->Leak().mBus + ATA_CYL_MID) << 8;
- result += In8(this->Leak().mBus + ATA_CYL_HIGH) << 16;
-
- Out8(this->Leak().mBus + ATA_REG_CONTROL, 0x80);
-
- result += In8(this->Leak().mBus + ATA_CYL_LOW) << 24;
- result += In8(this->Leak().mBus + ATA_CYL_MID) << 32;
- result += In8(this->Leak().mBus + ATA_CYL_HIGH) << 40;
-
- BTextWriter writer;
- writer.Write(L"Device-Size: ").Write(result).Write(L"\r\n");
-
- return result;
+ return this->GetSectorsCount() * BootDeviceATA::kSectorSize;
}