]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Emulate early IDE device which does not support identify.
authorToni Wilen <twilen@winuae.net>
Wed, 17 Apr 2019 17:03:13 +0000 (20:03 +0300)
committerToni Wilen <twilen@winuae.net>
Wed, 17 Apr 2019 17:03:13 +0000 (20:03 +0300)
ide.cpp

diff --git a/ide.cpp b/ide.cpp
index e87fc8e20facf4bd8af5fd1cae4efa581d74d663..0865b50547fe7c73fe8f35a95aa980674bab32c1 100644 (file)
--- 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,