ide: remove magic constants from the device register

(In QEMU, we call this the "select" register.)

My memory isn't good enough to memorize what these magic runes
do. Label them to prevent mixups from happening in the future.

Side note: I assume it's safe to always set 0xA0 even though ATA2 claims
these bits are reserved, because ATA3 immediately reinstated that these
bits should be always on. ATA4 and subsequent specs only claim that the
fields are obsolete, so I assume it's safe to leave these set and that
it should work with the widest array of guests.

Signed-off-by: John Snow <jsnow@redhat.com>
This commit is contained in:
John Snow 2020-07-24 01:22:58 -04:00
parent 14ee9b53ad
commit 0c7515e1c4
2 changed files with 25 additions and 12 deletions

View file

@ -29,6 +29,17 @@ OBJECT_DECLARE_SIMPLE_TYPE(IDEBus, IDE_BUS)
#define MAX_IDE_DEVS 2
/* Device/Head ("select") Register */
#define ATA_DEV_SELECT 0x10
/* ATA1,3: Defined as '1'.
* ATA2: Reserved.
* ATA3-7: obsolete. */
#define ATA_DEV_ALWAYS_ON 0xA0
#define ATA_DEV_LBA 0x40
#define ATA_DEV_LBA_MSB 0x0F /* LBA 24:27 */
#define ATA_DEV_HS 0x0F /* HS 3:0 */
/* Bits of HD_STATUS */
#define ERR_STAT 0x01
#define INDEX_STAT 0x02