From 3bf088f2c8d7165deca1644f706dae895ccc84cf Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Wed, 21 Aug 2024 21:15:17 +0200 Subject: [PATCH] atahd: fix RECALIBRATE command. Although being optional in ATA-3 and absent in >= ATA-4, RECALIBRATE is issued by Open Firmware 3.1.1 during device initialization. If it fails, the drive is considered non-bootable. --- devices/common/ata/atahd.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/devices/common/ata/atahd.cpp b/devices/common/ata/atahd.cpp index 23c179e..a75613e 100644 --- a/devices/common/ata/atahd.cpp +++ b/devices/common/ata/atahd.cpp @@ -85,10 +85,14 @@ int AtaHardDisk::perform_command() { switch (this->r_command) { case NOP: break; - case RECALIBRATE: - this->r_error = 0; - this->r_cylinder_lo = 0; + case RECALIBRATE: // is optional in ATA-3; disappeared in >= ATA-4 + // OF 3.1.1 won't boot off the drive that reports error for this command this->r_cylinder_hi = 0; + this->r_cylinder_lo = 0; + this->r_dev_head &= 0xF0; + this->r_sect_num = (this->r_dev_head & ATA_Dev_Head::LBA) ? 0 : 1; + this->r_status &= ~BSY; + this->update_intrq(1); break; case READ_SECTOR: case READ_SECTOR_NR: {