From 362016b206f6b2236d2cbcac09928ba60f0b5817 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Wed, 17 Apr 2019 20:03:13 +0300 Subject: [PATCH] Emulate early IDE device which does not support identify. --- ide.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/ide.cpp b/ide.cpp index e87fc8e2..0865b505 100644 --- a/ide.cpp +++ b/ide.cpp @@ -524,7 +524,7 @@ static void ide_identity_buffer(struct ide_hdf *ide) totalsecs = 0x0fffffff; pw(ide, 60, (uae_u16)totalsecs); pw(ide, 61, (uae_u16)(totalsecs >> 16)); - if (ide->ata_level) { + if (ide->ata_level > 0) { pw(ide, 64, ide->ata_level ? 0x03 : 0x00); /* PIO3 and PIO4 */ pw(ide, 65, 120); /* MDMA2 supported */ pw(ide, 66, 120); @@ -565,7 +565,7 @@ static void ide_identity_buffer(struct ide_hdf *ide) static void ide_identify_drive (struct ide_hdf *ide) { - if (!ide_isdrive (ide)) { + if (!ide_isdrive (ide) || ide->ata_level < 0) { ide_fail (ide); return; } @@ -658,6 +658,11 @@ static void ide_initialize_drive_parameters (struct ide_hdf *ide) static void ide_set_multiple_mode (struct ide_hdf *ide) { + if (ide->ata_level < 0) { + ide_fail(ide); + return; + } + write_log (_T("IDE%d drive multiple mode = %d\n"), ide->num, ide->regs.ide_nsector); if (ide->regs.ide_nsector > (ide->max_multiple_mode >> (ide->blocksize / 512 - 1))) { ide_fail(ide); @@ -669,6 +674,11 @@ static void ide_set_multiple_mode (struct ide_hdf *ide) static void ide_set_features (struct ide_hdf *ide) { + if (ide->ata_level < 0) { + ide_fail(ide); + return; + } + int type = ide->regs.ide_nsector >> 3; int mode = ide->regs.ide_nsector & 7; @@ -1027,7 +1037,7 @@ static void ide_read_sectors (struct ide_hdf *ide, int flags) int multi = flags & 1; ide->lba48cmd = (flags & 2) != 0; - if (multi && ide->multiple_mode == 0) { + if (multi && (ide->multiple_mode == 0 || ide->ata_level < 0)) { ide_fail (ide); return; } @@ -1065,7 +1075,7 @@ static void ide_write_sectors (struct ide_hdf *ide, int flags) int multi = flags & 1; ide->lba48cmd = (flags & 2) != 0; - if (multi && ide->multiple_mode == 0) { + if (multi && (ide->multiple_mode == 0 || ide->ata_level < 0)) { ide_fail (ide); return; } @@ -1196,7 +1206,11 @@ static void ide_do_command (struct ide_hdf *ide, uae_u8 cmd) } else if (cmd == 0x70) { /* seek */ ide_interrupt (ide); } else if (cmd == 0xe0 || cmd == 0xe1 || cmd == 0xe7 || cmd == 0xea) { /* standby now/idle/flush cache/flush cache ext */ - ide_interrupt (ide); + if (ide->ata_level < 0) { + ide_fail(ide); + } else { + ide_interrupt(ide); + } } else if (cmd == 0xe5) { /* check power mode */ ide->regs.ide_nsector = 0xff; ide_interrupt (ide); @@ -1614,6 +1628,7 @@ void remove_ide_unit(struct ide_hdf **idetable, int ch) struct ide_hdf *add_ide_unit (struct ide_hdf **idetable, int max, int ch, struct uaedev_config_info *ci, struct romconfig *rc) { struct ide_hdf *ide; + bool vb; alloc_ide_mem(idetable, max, NULL); if (ch < 0) @@ -1688,6 +1703,14 @@ struct ide_hdf *add_ide_unit (struct ide_hdf **idetable, int max, int ch, struct ide->max_lba = ci.max_lba; if (ide->lba48 && !ide->ata_level) ide->ata_level = 1; + if (ini_getbool(ide->hdhfd.hfd.geometry, _T("IDENTITY"), _T("disabled"), &vb)) { + if (vb) { + ide->ata_level = -1; + ide->lba48 = false; + ide->lba = false; + ide->max_multiple_mode = 0; + } + } write_log (_T("IDE%d HD '%s', LCHS=%d/%d/%d. PCHS=%d/%d/%d %uM. MM=%d LBA48=%d\n"), ch, ide->hdhfd.hfd.ci.rootdir, -- 2.47.3