Index: /trunk/src/VBox/Devices/Storage/DevBusLogic.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevBusLogic.cpp	(revision 76073)
+++ /trunk/src/VBox/Devices/Storage/DevBusLogic.cpp	(revision 76074)
@@ -323,5 +323,5 @@
     DEV_BT_958D     = 0,    /* BusLogic BT-958D, PCI. */
     DEV_BT_545C     = 1,    /* BusLogic BT-545C, ISA. */
-    DEV_AHA_1540C   = 2     /* Adaptec AHA-1540C, ISA. */
+    DEV_AHA_1540B   = 2     /* Adaptec AHA-1540B, ISA. */
 };
 
@@ -407,4 +407,6 @@
     /** Emulated device type. */
     uint8_t                         uDevType;
+    /** Signature index for Adaptec models. */
+    uint8_t                         uAhaSigIdx;
 
     /** Number of mailboxes the guest set up. */
@@ -1151,4 +1153,5 @@
     pBusLogic->uMailboxOutgoingPositionCurrent = 0;
     pBusLogic->uMailboxIncomingPositionCurrent = 0;
+    pBusLogic->uAhaSigIdx = 0;
 
     /* Clear any active/pending interrupts. */
@@ -1840,6 +1843,14 @@
              * the adapter only when the byte is *not* '0' or 'B'.
              */
-            pBusLogic->aReplyBuffer[0] = 'A'; /* Firmware option bytes */
-            pBusLogic->aReplyBuffer[1] = 'A'; /* Special option byte */
+            if (pBusLogic->uDevType == DEV_AHA_1540B)
+            {
+                pBusLogic->aReplyBuffer[0] = 'A'; /* Firmware option bytes */
+                pBusLogic->aReplyBuffer[1] = '0'; /* Special option byte */
+            }
+            else
+            {
+                pBusLogic->aReplyBuffer[0] = 'A'; /* Firmware option bytes */
+                pBusLogic->aReplyBuffer[1] = 'A'; /* Special option byte */
+            }
 
             /* We report version 5.07B. This reply will provide the first two digits. */
@@ -1851,4 +1862,13 @@
         case BUSLOGICCOMMAND_INQUIRE_FIRMWARE_VERSION_3RD_LETTER:
         {
+            if (pBusLogic->uDevType == DEV_AHA_1540B)
+            {
+                /* Newer ASPI4DOS.SYS versions expect this command to fail. */
+                Log(("Command %#x not valid for this adapter\n", pBusLogic->uOperationCode));
+                pBusLogic->cbReplyParametersLeft = 0;
+                pBusLogic->regStatus |= BL_STAT_CMDINV;
+                break;
+            }
+
             pBusLogic->aReplyBuffer[0] = '7';
             pBusLogic->cbReplyParametersLeft = 1;
@@ -1907,4 +1927,13 @@
         case BUSLOGICCOMMAND_INQUIRE_HOST_ADAPTER_MODEL_NUMBER:
         {
+            /* Not supported on AHA-154x. */
+            if (pBusLogic->uDevType == DEV_AHA_1540B)
+            {
+                Log(("Command %#x not valid for this adapter\n", pBusLogic->uOperationCode));
+                pBusLogic->cbReplyParametersLeft = 0;
+                pBusLogic->regStatus |= BL_STAT_CMDINV;
+                break;
+            }
+
             /* The reply length is set by the guest and is found in the first byte of the command buffer. */
             if (pBusLogic->aCommandBuffer[0] > sizeof(pBusLogic->aReplyBuffer))
@@ -1968,4 +1997,11 @@
              * Adaptec 154x models supposedly support it too??
              */
+            if (pBusLogic->uDevType == DEV_AHA_1540B)
+            {
+                Log(("Command %#x not valid for this adapter\n", pBusLogic->uOperationCode));
+                pBusLogic->cbReplyParametersLeft = 0;
+                pBusLogic->regStatus |= BL_STAT_CMDINV;
+                break;
+            }
 
             /* The reply length is set by the guest and is found in the first byte of the command buffer. */
@@ -1996,9 +2032,18 @@
             pReply->cMailbox = pBusLogic->cMailbox;
             U32_TO_ADDR(pReply->MailboxAddress, pBusLogic->GCPhysAddrMailboxOutgoingBase);
-            pReply->uSignature = 'B';
-            /* The 'D' signature prevents Adaptec's OS/2 drivers from getting too
-             * friendly with BusLogic hardware and upsetting the HBA state.
+            /* The 'D' signature (actually 'SD' for Storage Dimensions, and 'BD' for BusLogic)
+             * prevents Adaptec's OS/2 drivers from getting too friendly with BusLogic hardware
+             * and upsetting the HBA state.
              */
-            pReply->uCharacterD = 'D';      /* BusLogic model. */
+            if (pBusLogic->uDevType == DEV_AHA_1540B)
+            {
+                pReply->uSignature  = 0;    /* Zeros for Adaptec. */
+                pReply->uCharacterD = 0;
+            }
+            else
+            {
+                pReply->uSignature  = 'B';
+                pReply->uCharacterD = 'D';      /* BusLogic model. */
+            }
             pReply->uHostBusType = 'F';     /* PCI bus. */
             break;
@@ -2044,4 +2089,12 @@
         case BUSLOGICCOMMAND_INITIALIZE_EXTENDED_MAILBOX:
         {
+            if (pBusLogic->uDevType == DEV_AHA_1540B)
+            {
+                Log(("Command %#x not valid for this adapter\n", pBusLogic->uOperationCode));
+                pBusLogic->cbReplyParametersLeft = 0;
+                pBusLogic->regStatus |= BL_STAT_CMDINV;
+                break;
+            }
+
             PRequestInitializeExtendedMailbox pRequest = (PRequestInitializeExtendedMailbox)pBusLogic->aCommandBuffer;
 
@@ -2145,4 +2198,13 @@
         case BUSLOGICCOMMAND_DISABLE_HOST_ADAPTER_INTERRUPT:
         {
+            /* Not supported on AHA-154x HBAs. */
+            if (pBusLogic->uDevType == DEV_AHA_1540B)
+            {
+                Log(("Command %#x not valid for this adapter\n", pBusLogic->uOperationCode));
+                pBusLogic->cbReplyParametersLeft = 0;
+                pBusLogic->regStatus |= BL_STAT_CMDINV;
+                break;
+            }
+
             pBusLogic->cbReplyParametersLeft = 0;
             if (pBusLogic->aCommandBuffer[0] == 0)
@@ -2272,4 +2334,5 @@
 static int buslogicRegisterRead(PBUSLOGIC pBusLogic, unsigned iRegister, uint32_t *pu32)
 {
+    static const char achAhaSig[] = "ADAP";
     int rc = VINF_SUCCESS;
 
@@ -2341,5 +2404,11 @@
         case BUSLOGIC_REGISTER_GEOMETRY:
         {
-            *pu32 = pBusLogic->regGeometry;
+            if (pBusLogic->uDevType == DEV_AHA_1540B)
+            {
+                *pu32 = achAhaSig[pBusLogic->uAhaSigIdx];
+                pBusLogic->uAhaSigIdx = (pBusLogic->uAhaSigIdx + 1) & 3;
+            }
+            else
+                *pu32 = pBusLogic->regGeometry;
             break;
         }
@@ -2449,10 +2518,17 @@
                     case BUSLOGICCOMMAND_MODIFY_IO_ADDRESS:
                     case BUSLOGICCOMMAND_INQUIRE_EXTENDED_SETUP_INFORMATION:
+                    case BUSLOGICCOMMAND_DISABLE_HOST_ADAPTER_INTERRUPT:
+                    case BUSLOGICCOMMAND_INQUIRE_HOST_ADAPTER_MODEL_NUMBER:
+                        /* These commands are not on AHA-154x, some Adaptec drivers (ASPI4DOS.SYS) test them. */
+                        if (pBusLogic->uDevType == DEV_AHA_1540B)
+                        {
+                            pBusLogic->cbCommandParametersLeft = 0;
+                            break;
+                        }
+                        /* Fall through. */
                     case BUSLOGICCOMMAND_INQUIRE_SETUP_INFORMATION:
-                    case BUSLOGICCOMMAND_INQUIRE_HOST_ADAPTER_MODEL_NUMBER:
                     case BUSLOGICCOMMAND_ENABLE_STRICT_ROUND_ROBIN_MODE:
                     case BUSLOGICCOMMAND_SET_CCB_FORMAT:
                     case BUSLOGICCOMMAND_INQUIRE_SYNCHRONOUS_PERIOD:
-                    case BUSLOGICCOMMAND_DISABLE_HOST_ADAPTER_INTERRUPT:
                     case BUSLOGICCOMMAND_ECHO_COMMAND_DATA:
                     case BUSLOGICCOMMAND_ENABLE_OUTGOING_MAILBOX_AVAILABLE_INTERRUPT:
@@ -2476,4 +2552,10 @@
                         break;
                     case BUSLOGICCOMMAND_INITIALIZE_EXTENDED_MAILBOX:
+                        /* Some Adaptec drivers (ASPI4DOS.SYS) test this command. */
+                        if (pBusLogic->uDevType == DEV_AHA_1540B)
+                        {
+                            pBusLogic->cbCommandParametersLeft = 0;
+                            break;
+                        }
                         pBusLogic->cbCommandParametersLeft = sizeof(RequestInitializeExtendedMailbox);
                         break;
@@ -2530,8 +2612,12 @@
          */
         case BUSLOGIC_REGISTER_INTERRUPT:
+            if (pBusLogic->uDevType == DEV_AHA_1540B)
+                break;
             pBusLogic->regInterrupt = uVal;
             break;
 
         case BUSLOGIC_REGISTER_GEOMETRY:
+            if (pBusLogic->uDevType == DEV_AHA_1540B)
+                break;
             pBusLogic->regGeometry = uVal;
             break;
@@ -3752,5 +3838,5 @@
 static DECLCALLBACK(void) buslogicR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
 {
-    static const char *apszModels[] = { "BusLogic BT-958D", "BusLogic BT-545C", "Adaptec AHA-1540C" };
+    static const char *apszModels[] = { "BusLogic BT-958D", "BusLogic BT-545C", "Adaptec AHA-1540B" };
     PBUSLOGIC   pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     unsigned    i;
@@ -4201,11 +4287,9 @@
         pThis->uIsaIrq = 11;
     }
-#if 0   /* Maybe someday. */
-    else if (!strcmp(achCfgStr, "AHA-1540C"))   /* Competitor ISA device. */
-    {
-        pThis->uDevType = DEV_AHA_1540C;
+    else if (!strcmp(achCfgStr, "AHA-1540B"))   /* Competitor ISA device. */
+    {
+        pThis->uDevType = DEV_AHA_1540B;
         pThis->uIsaIrq = 11;
     }
-#endif
     else
         return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
