Skip to content

Commit 3bf088f

Browse files
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.
1 parent bd16b7c commit 3bf088f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

devices/common/ata/atahd.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,14 @@ int AtaHardDisk::perform_command() {
8585
switch (this->r_command) {
8686
case NOP:
8787
break;
88-
case RECALIBRATE:
89-
this->r_error = 0;
90-
this->r_cylinder_lo = 0;
88+
case RECALIBRATE: // is optional in ATA-3; disappeared in >= ATA-4
89+
// OF 3.1.1 won't boot off the drive that reports error for this command
9190
this->r_cylinder_hi = 0;
91+
this->r_cylinder_lo = 0;
92+
this->r_dev_head &= 0xF0;
93+
this->r_sect_num = (this->r_dev_head & ATA_Dev_Head::LBA) ? 0 : 1;
94+
this->r_status &= ~BSY;
95+
this->update_intrq(1);
9296
break;
9397
case READ_SECTOR:
9498
case READ_SECTOR_NR: {

0 commit comments

Comments
 (0)