snapshot: reading secondary drive also works

dd if=/dev/zero of=data.img count=20160
  echo '(+ 1 1)' |dd of=data.img conv=notrunc
  ./translate ex2.mu  &&  qemu-system-i386 -hda disk.img -hdb data.img

Compare output with `xxd data.img |head`.

This works because primary and secondary drives on the primary bus share
the same ports. All we have to do is select the right drive by flipping
a bit.
This commit is contained in:
Kartik K. Agaram 2021-03-21 22:25:26 -07:00
parent fba2146593
commit 0c3f126377
1 changed files with 1 additions and 3 deletions

View File

@ -941,12 +941,10 @@ read-a-sector:
(abort "primary bus has no drives")
}
# kick off read
(ata-drive-select 0xe0) # primary drive; 4 LSBs contain 4 upper bits of LBA (here 0)
#? (ata-drive-select 0xa0) # primary drive in CHS + head number
(ata-drive-select 0xf0) # primary bus, secondary drive; 4 LSBs contain 4 upper bits of LBA (here 0)
(ata-error 0)
(ata-sector-count 1)
(ata-lba 0 0 0) # lower 24 bits of LBA
#? (ata-cyl-sector 1 0 0)
(ata-command 0x20) # read sectors with retries
# poll for results
(poll-ata-primary-bus-primary-drive-regular-status-word)