VirtualBox

Changeset 81835 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Nov 13, 2019 4:51:59 PM (5 years ago)
Author:
vboxsync
Message:

DevBusLogic.cpp: Use pThis like everyone else. bugref:9218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevBusLogic.cpp

    r81833 r81835  
    10061006 * @returns nothing.
    10071007 * @param   pDevIns The device instance.
    1008  * @param   pThis   The BusLogic controller instance.
     1008 * @param   pThis   Pointer to the shared BusLogic instance data.
    10091009 * @param   GCPhys  The guest physical address of the memory buffer.
    10101010 * @param   pSgBuf  The pointer to the host R3 S/G buffer.
     
    10291029*********************************************************************************************************************************/
    10301030#ifdef IN_RING3
    1031 static int buslogicR3RegisterISARange(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, uint8_t uBaseCode);
     1031static int buslogicR3RegisterISARange(PPDMDEVINS pDevIns, PBUSLOGIC pThis, uint8_t uBaseCode);
    10321032#endif
    10331033
     
    10381038 * @returns nothing.
    10391039 * @param   pDevIns         The device instance.
    1040  * @param   pBusLogic       Pointer to the shared BusLogic instance data.
     1040 * @param   pThis           Pointer to the shared BusLogic instance data.
    10411041 * @param   fSuppressIrq    Flag to suppress IRQ generation regardless of fIRQEnabled
    10421042 * @param   uIrqType        Type of interrupt being generated.
    10431043 */
    1044 static void buslogicSetInterrupt(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, bool fSuppressIrq, uint8_t uIrqType)
    1045 {
    1046     LogFlowFunc(("pBusLogic=%#p\n", pBusLogic));
     1044static void buslogicSetInterrupt(PPDMDEVINS pDevIns, PBUSLOGIC pThis, bool fSuppressIrq, uint8_t uIrqType)
     1045{
     1046    LogFlowFunc(("pThis=%#p\n", pThis));
    10471047
    10481048    /* The CMDC interrupt has priority over IMBL and OMBR. */
    10491049    if (uIrqType & (BL_INTR_IMBL | BL_INTR_OMBR))
    10501050    {
    1051         if (!(pBusLogic->regInterrupt & BL_INTR_CMDC))
    1052             pBusLogic->regInterrupt |= uIrqType;    /* Report now. */
     1051        if (!(pThis->regInterrupt & BL_INTR_CMDC))
     1052            pThis->regInterrupt |= uIrqType;    /* Report now. */
    10531053        else
    1054             pBusLogic->uPendingIntr |= uIrqType;    /* Report later. */
     1054            pThis->uPendingIntr |= uIrqType;    /* Report later. */
    10551055    }
    10561056    else if (uIrqType & BL_INTR_CMDC)
    10571057    {
    1058         AssertMsg(pBusLogic->regInterrupt == 0 || pBusLogic->regInterrupt == (BL_INTR_INTV | BL_INTR_CMDC),
    1059                   ("regInterrupt=%02X\n", pBusLogic->regInterrupt));
    1060         pBusLogic->regInterrupt |= uIrqType;
     1058        AssertMsg(pThis->regInterrupt == 0 || pThis->regInterrupt == (BL_INTR_INTV | BL_INTR_CMDC),
     1059                  ("regInterrupt=%02X\n", pThis->regInterrupt));
     1060        pThis->regInterrupt |= uIrqType;
    10611061    }
    10621062    else
    10631063        AssertMsgFailed(("Invalid interrupt state!\n"));
    10641064
    1065     pBusLogic->regInterrupt |= BL_INTR_INTV;
    1066     if (pBusLogic->fIRQEnabled && !fSuppressIrq)
    1067     {
    1068         if (!pBusLogic->uIsaIrq)
     1065    pThis->regInterrupt |= BL_INTR_INTV;
     1066    if (pThis->fIRQEnabled && !fSuppressIrq)
     1067    {
     1068        if (!pThis->uIsaIrq)
    10691069            PDMDevHlpPCISetIrq(pDevIns, 0, 1);
    10701070        else
    1071             PDMDevHlpISASetIrq(pDevIns, pBusLogic->uIsaIrq, 1);
     1071            PDMDevHlpISASetIrq(pDevIns, pThis->uIsaIrq, 1);
    10721072    }
    10731073}
     
    10771077 *
    10781078 * @returns nothing.
    1079  * @param   pDevIns         The device instance.
    1080  * @param   pBusLogic       Pointer to the shared BusLogic instance data.
    1081  */
    1082 static void buslogicClearInterrupt(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic)
    1083 {
    1084     LogFlowFunc(("pBusLogic=%#p, clearing %#02x (pending %#02x)\n",
    1085                  pBusLogic, pBusLogic->regInterrupt, pBusLogic->uPendingIntr));
    1086     pBusLogic->regInterrupt = 0;
    1087     pBusLogic->regStatus &= ~BL_STAT_CMDINV;
    1088     if (!pBusLogic->uIsaIrq)
     1079 * @param   pDevIns     The device instance.
     1080 * @param   pThis       Pointer to the shared BusLogic instance data.
     1081 */
     1082static void buslogicClearInterrupt(PPDMDEVINS pDevIns, PBUSLOGIC pThis)
     1083{
     1084    LogFlowFunc(("pThis=%#p, clearing %#02x (pending %#02x)\n",
     1085                 pThis, pThis->regInterrupt, pThis->uPendingIntr));
     1086    pThis->regInterrupt = 0;
     1087    pThis->regStatus &= ~BL_STAT_CMDINV;
     1088    if (!pThis->uIsaIrq)
    10891089        PDMDevHlpPCISetIrq(pDevIns, 0, 0);
    10901090    else
    1091         PDMDevHlpISASetIrq(pDevIns, pBusLogic->uIsaIrq, 0);
     1091        PDMDevHlpISASetIrq(pDevIns, pThis->uIsaIrq, 0);
    10921092    /* If there's another pending interrupt, report it now. */
    1093     if (pBusLogic->uPendingIntr)
    1094     {
    1095         buslogicSetInterrupt(pDevIns, pBusLogic, false, pBusLogic->uPendingIntr);
    1096         pBusLogic->uPendingIntr = 0;
     1093    if (pThis->uPendingIntr)
     1094    {
     1095        buslogicSetInterrupt(pDevIns, pThis, false, pThis->uPendingIntr);
     1096        pThis->uPendingIntr = 0;
    10971097    }
    10981098}
     
    11041104 *
    11051105 * @returns nothing.
    1106  * @param   pBusLogic       The BusLogic controller instance.
    1107  */
    1108 DECLINLINE(void) buslogicR3OutgoingMailboxAdvance(PBUSLOGIC pBusLogic)
    1109 {
    1110     pBusLogic->uMailboxOutgoingPositionCurrent = (pBusLogic->uMailboxOutgoingPositionCurrent + 1) % pBusLogic->cMailbox;
     1106 * @param   pThis       Pointer to the shared BusLogic instance data.
     1107 */
     1108DECLINLINE(void) buslogicR3OutgoingMailboxAdvance(PBUSLOGIC pThis)
     1109{
     1110    pThis->uMailboxOutgoingPositionCurrent = (pThis->uMailboxOutgoingPositionCurrent + 1) % pThis->cMailbox;
    11111111}
    11121112
     
    11151115 *
    11161116 * @returns nothing.
    1117  * @param   pBusLogic       The BusLogic controller instance.
    1118  */
    1119 static void buslogicR3InitializeLocalRam(PBUSLOGIC pBusLogic)
     1117 * @param   pThis       Pointer to the shared BusLogic instance data.
     1118 */
     1119static void buslogicR3InitializeLocalRam(PBUSLOGIC pThis)
    11201120{
    11211121    /*
     
    11261126     * So they don't have to be right :)
    11271127     */
    1128     memset(pBusLogic->LocalRam.u8View, 0, sizeof(HostAdapterLocalRam));
    1129     pBusLogic->LocalRam.structured.autoSCSIData.fLevelSensitiveInterrupt = true;
    1130     pBusLogic->LocalRam.structured.autoSCSIData.fParityCheckingEnabled = true;
    1131     pBusLogic->LocalRam.structured.autoSCSIData.fExtendedTranslation = true; /* Same as in geometry register. */
    1132     pBusLogic->LocalRam.structured.autoSCSIData.u16DeviceEnabledMask = UINT16_MAX; /* All enabled. Maybe mask out non present devices? */
    1133     pBusLogic->LocalRam.structured.autoSCSIData.u16WidePermittedMask = UINT16_MAX;
    1134     pBusLogic->LocalRam.structured.autoSCSIData.u16FastPermittedMask = UINT16_MAX;
    1135     pBusLogic->LocalRam.structured.autoSCSIData.u16SynchronousPermittedMask = UINT16_MAX;
    1136     pBusLogic->LocalRam.structured.autoSCSIData.u16DisconnectPermittedMask = UINT16_MAX;
    1137     pBusLogic->LocalRam.structured.autoSCSIData.fStrictRoundRobinMode = pBusLogic->fStrictRoundRobinMode;
    1138     pBusLogic->LocalRam.structured.autoSCSIData.u16UltraPermittedMask = UINT16_MAX;
     1128    memset(pThis->LocalRam.u8View, 0, sizeof(HostAdapterLocalRam));
     1129    pThis->LocalRam.structured.autoSCSIData.fLevelSensitiveInterrupt = true;
     1130    pThis->LocalRam.structured.autoSCSIData.fParityCheckingEnabled = true;
     1131    pThis->LocalRam.structured.autoSCSIData.fExtendedTranslation = true; /* Same as in geometry register. */
     1132    pThis->LocalRam.structured.autoSCSIData.u16DeviceEnabledMask = UINT16_MAX; /* All enabled. Maybe mask out non present devices? */
     1133    pThis->LocalRam.structured.autoSCSIData.u16WidePermittedMask = UINT16_MAX;
     1134    pThis->LocalRam.structured.autoSCSIData.u16FastPermittedMask = UINT16_MAX;
     1135    pThis->LocalRam.structured.autoSCSIData.u16SynchronousPermittedMask = UINT16_MAX;
     1136    pThis->LocalRam.structured.autoSCSIData.u16DisconnectPermittedMask = UINT16_MAX;
     1137    pThis->LocalRam.structured.autoSCSIData.fStrictRoundRobinMode = pThis->fStrictRoundRobinMode;
     1138    pThis->LocalRam.structured.autoSCSIData.u16UltraPermittedMask = UINT16_MAX;
    11391139    /** @todo calculate checksum? */
    11401140}
     
    11451145 * @returns VBox status code.
    11461146 * @param   pDevIns     The device instance.
    1147  * @param   pBusLogic   Pointer to the shared BusLogic instance data.
     1147 * @param   pThis       Pointer to the shared BusLogic instance data.
    11481148 * @param   pThisCC     Pointer to the ring-3 BusLogic instance data.
    11491149 * @param   fResetIO    Flag determining whether ISA I/O should be reset.
    11501150 */
    1151 static int buslogicR3HwReset(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, PBUSLOGICCC pThisCC, bool fResetIO)
    1152 {
    1153     LogFlowFunc(("pBusLogic=%#p\n", pBusLogic));
     1151static int buslogicR3HwReset(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PBUSLOGICCC pThisCC, bool fResetIO)
     1152{
     1153    LogFlowFunc(("pThis=%#p\n", pThis));
    11541154
    11551155    /* Reset registers to default values. */
    1156     pBusLogic->regStatus = BL_STAT_HARDY | BL_STAT_INREQ;
    1157     pBusLogic->regGeometry = BL_GEOM_XLATEN;
    1158     pBusLogic->uOperationCode = 0xff; /* No command executing. */
    1159     pBusLogic->iParameter = 0;
    1160     pBusLogic->cbCommandParametersLeft = 0;
    1161     pBusLogic->fIRQEnabled = true;
    1162     pBusLogic->fStrictRoundRobinMode = false;
    1163     pBusLogic->fExtendedLunCCBFormat = false;
    1164     pBusLogic->uMailboxOutgoingPositionCurrent = 0;
    1165     pBusLogic->uMailboxIncomingPositionCurrent = 0;
    1166     pBusLogic->uAhaSigIdx = 0;
     1156    pThis->regStatus = BL_STAT_HARDY | BL_STAT_INREQ;
     1157    pThis->regGeometry = BL_GEOM_XLATEN;
     1158    pThis->uOperationCode = 0xff; /* No command executing. */
     1159    pThis->iParameter = 0;
     1160    pThis->cbCommandParametersLeft = 0;
     1161    pThis->fIRQEnabled = true;
     1162    pThis->fStrictRoundRobinMode = false;
     1163    pThis->fExtendedLunCCBFormat = false;
     1164    pThis->uMailboxOutgoingPositionCurrent = 0;
     1165    pThis->uMailboxIncomingPositionCurrent = 0;
     1166    pThis->uAhaSigIdx = 0;
    11671167
    11681168    /* Clear any active/pending interrupts. */
    1169     pBusLogic->uPendingIntr = 0;
    1170     buslogicClearInterrupt(pDevIns, pBusLogic);
     1169    pThis->uPendingIntr = 0;
     1170    buslogicClearInterrupt(pDevIns, pThis);
    11711171
    11721172    /* Guest-initiated HBA reset does not affect ISA port I/O. */
    11731173    if (fResetIO)
    1174         buslogicR3RegisterISARange(pDevIns, pBusLogic, pBusLogic->uDefaultISABaseCode);
    1175     buslogicR3InitializeLocalRam(pBusLogic);
     1174        buslogicR3RegisterISARange(pDevIns, pThis, pThis->uDefaultISABaseCode);
     1175    buslogicR3InitializeLocalRam(pThis);
    11761176    vboxscsiInitialize(&pThisCC->VBoxSCSI);
    11771177
     
    11861186 * @returns nothing.
    11871187 * @param   pDevIns         The device instance.
    1188  * @param   pBusLogic       Pointer to the shared BusLogic instance data.
     1188 * @param   pThis           Pointer to the shared BusLogic instance data.
    11891189 * @param   fSuppressIrq    Flag to suppress IRQ generation regardless of current state
    11901190 */
    1191 static void buslogicCommandComplete(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, bool fSuppressIrq)
    1192 {
    1193     LogFlowFunc(("pBusLogic=%#p\n", pBusLogic));
    1194     Assert(pBusLogic->uOperationCode != BUSLOGICCOMMAND_EXECUTE_MAILBOX_COMMAND);
    1195 
    1196     pBusLogic->fUseLocalRam = false;
    1197     pBusLogic->regStatus |= BL_STAT_HARDY;
    1198     pBusLogic->iReply = 0;
     1191static void buslogicCommandComplete(PPDMDEVINS pDevIns, PBUSLOGIC pThis, bool fSuppressIrq)
     1192{
     1193    LogFlowFunc(("pThis=%#p\n", pThis));
     1194    Assert(pThis->uOperationCode != BUSLOGICCOMMAND_EXECUTE_MAILBOX_COMMAND);
     1195
     1196    pThis->fUseLocalRam = false;
     1197    pThis->regStatus |= BL_STAT_HARDY;
     1198    pThis->iReply = 0;
    11991199
    12001200    /* The Enable OMBR command does not set CMDC when successful. */
    1201     if (pBusLogic->uOperationCode != BUSLOGICCOMMAND_ENABLE_OUTGOING_MAILBOX_AVAILABLE_INTERRUPT)
     1201    if (pThis->uOperationCode != BUSLOGICCOMMAND_ENABLE_OUTGOING_MAILBOX_AVAILABLE_INTERRUPT)
    12021202    {
    12031203        /* Notify that the command is complete. */
    1204         pBusLogic->regStatus &= ~BL_STAT_DIRRDY;
    1205         buslogicSetInterrupt(pDevIns, pBusLogic, fSuppressIrq, BL_INTR_CMDC);
    1206     }
    1207 
    1208     pBusLogic->uOperationCode = 0xff;
    1209     pBusLogic->iParameter = 0;
     1204        pThis->regStatus &= ~BL_STAT_DIRRDY;
     1205        buslogicSetInterrupt(pDevIns, pThis, fSuppressIrq, BL_INTR_CMDC);
     1206    }
     1207
     1208    pThis->uOperationCode = 0xff;
     1209    pThis->iParameter = 0;
    12101210}
    12111211
     
    12351235 * @returns nothing
    12361236 * @param   pDevIns     The device instance.
    1237  * @param   pBusLogic   Pointer to the shared BusLogic instance data.
     1237 * @param   pThis       Pointer to the shared BusLogic instance data.
    12381238 * @param   pThisCC     Pointer to the ring-3 BusLogic instance data.
    12391239 * @param   fHardReset  Flag initiating a hard (vs. soft) reset.
    12401240 */
    1241 static void buslogicR3InitiateReset(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, PBUSLOGICCC pThisCC, bool fHardReset)
    1242 {
    1243     LogFlowFunc(("pBusLogic=%#p fHardReset=%d\n", pBusLogic, fHardReset));
    1244 
    1245     buslogicR3HwReset(pDevIns, pBusLogic, pThisCC, false);
     1241static void buslogicR3InitiateReset(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PBUSLOGICCC pThisCC, bool fHardReset)
     1242{
     1243    LogFlowFunc(("pThis=%#p fHardReset=%d\n", pThis, fHardReset));
     1244
     1245    buslogicR3HwReset(pDevIns, pThis, pThisCC, false);
    12461246
    12471247    if (fHardReset)
    12481248    {
    12491249        /* Set the diagnostic active bit in the status register and clear the ready state. */
    1250         pBusLogic->regStatus |=  BL_STAT_DACT;
    1251         pBusLogic->regStatus &= ~BL_STAT_HARDY;
     1250        pThis->regStatus |=  BL_STAT_DACT;
     1251        pThis->regStatus &= ~BL_STAT_HARDY;
    12521252
    12531253        /* Remember when the guest initiated a reset (after we're done resetting). */
    1254         pBusLogic->u64ResetTime = PDMDevHlpTMTimeVirtGetNano(pDevIns);
     1254        pThis->u64ResetTime = PDMDevHlpTMTimeVirtGetNano(pDevIns);
    12551255    }
    12561256}
     
    12621262 * @returns nothing.
    12631263 * @param   pDevIns                 The device instance.
    1264  * @param   pBusLogic               Pointer to the shared BusLogic instance data.
     1264 * @param   pThis                   Pointer to the shared BusLogic instance data.
    12651265 * @param   GCPhysAddrCCB           The physical guest address of the CCB the mailbox is for.
    12661266 * @param   pCCBGuest               The command control block.
     
    12691269 * @param   uMailboxCompletionCode  Completion status code to set in the mailbox.
    12701270 */
    1271 static void buslogicR3SendIncomingMailbox(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, RTGCPHYS GCPhysAddrCCB,
     1271static void buslogicR3SendIncomingMailbox(PPDMDEVINS pDevIns, PBUSLOGIC pThis, RTGCPHYS GCPhysAddrCCB,
    12721272                                          PCCBU pCCBGuest, uint8_t uHostAdapterStatus,
    12731273                                          uint8_t uDeviceStatus, uint8_t uMailboxCompletionCode)
     
    12801280    MbxIn.u.in.uCompletionCode     = uMailboxCompletionCode;
    12811281
    1282     int rc = PDMDevHlpCritSectEnter(pDevIns, &pBusLogic->CritSectIntr, VINF_SUCCESS);
     1282    int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSectIntr, VINF_SUCCESS);
    12831283    AssertRC(rc);
    12841284
    1285     RTGCPHYS GCPhysAddrMailboxIncoming = pBusLogic->GCPhysAddrMailboxIncomingBase
    1286                                        + (   pBusLogic->uMailboxIncomingPositionCurrent
    1287                                           * (pBusLogic->fMbxIs24Bit ? sizeof(Mailbox24) : sizeof(Mailbox32)) );
     1285    RTGCPHYS GCPhysAddrMailboxIncoming = pThis->GCPhysAddrMailboxIncomingBase
     1286                                       + (   pThis->uMailboxIncomingPositionCurrent
     1287                                          * (pThis->fMbxIs24Bit ? sizeof(Mailbox24) : sizeof(Mailbox32)) );
    12881288
    12891289    if (uMailboxCompletionCode != BUSLOGIC_MAILBOX_INCOMING_COMPLETION_ABORTED_NOT_FOUND)
     
    12961296        pCCBGuest->c.uDeviceStatus      = uDeviceStatus;
    12971297        /* Rewrite CCB up to the CDB; perhaps more than necessary. */
    1298         blPhysWrite(pDevIns, pBusLogic, GCPhysAddrCCB, pCCBGuest, RT_UOFFSETOF(CCBC, abCDB));
     1298        blPhysWrite(pDevIns, pThis, GCPhysAddrCCB, pCCBGuest, RT_UOFFSETOF(CCBC, abCDB));
    12991299    }
    13001300
    13011301# ifdef RT_STRICT
    13021302    uint8_t     uCode;
    1303     unsigned    uCodeOffs = pBusLogic->fMbxIs24Bit ? RT_OFFSETOF(Mailbox24, uCmdState) : RT_OFFSETOF(Mailbox32, u.out.uActionCode);
     1303    unsigned    uCodeOffs = pThis->fMbxIs24Bit ? RT_OFFSETOF(Mailbox24, uCmdState) : RT_OFFSETOF(Mailbox32, u.out.uActionCode);
    13041304    PDMDevHlpPhysRead(pDevIns, GCPhysAddrMailboxIncoming + uCodeOffs, &uCode, sizeof(uCode));
    13051305    Assert(uCode == BUSLOGIC_MAILBOX_INCOMING_COMPLETION_FREE);
     
    13071307
    13081308    /* Update mailbox. */
    1309     if (pBusLogic->fMbxIs24Bit)
     1309    if (pThis->fMbxIs24Bit)
    13101310    {
    13111311        Mailbox24   Mbx24;
     
    13141314        U32_TO_ADDR(Mbx24.aPhysAddrCCB, MbxIn.u32PhysAddrCCB);
    13151315        Log(("24-bit mailbox: completion code=%u, CCB at %RGp\n", Mbx24.uCmdState, (RTGCPHYS)ADDR_TO_U32(Mbx24.aPhysAddrCCB)));
    1316         blPhysWrite(pDevIns, pBusLogic, GCPhysAddrMailboxIncoming, &Mbx24, sizeof(Mailbox24));
     1316        blPhysWrite(pDevIns, pThis, GCPhysAddrMailboxIncoming, &Mbx24, sizeof(Mailbox24));
    13171317    }
    13181318    else
    13191319    {
    13201320        Log(("32-bit mailbox: completion code=%u, CCB at %RGp\n", MbxIn.u.in.uCompletionCode, GCPhysAddrCCB));
    1321         blPhysWrite(pDevIns, pBusLogic, GCPhysAddrMailboxIncoming, &MbxIn, sizeof(Mailbox32));
     1321        blPhysWrite(pDevIns, pThis, GCPhysAddrMailboxIncoming, &MbxIn, sizeof(Mailbox32));
    13221322    }
    13231323
    13241324    /* Advance to next mailbox position. */
    1325     pBusLogic->uMailboxIncomingPositionCurrent++;
    1326     if (pBusLogic->uMailboxIncomingPositionCurrent >= pBusLogic->cMailbox)
    1327         pBusLogic->uMailboxIncomingPositionCurrent = 0;
     1325    pThis->uMailboxIncomingPositionCurrent++;
     1326    if (pThis->uMailboxIncomingPositionCurrent >= pThis->cMailbox)
     1327        pThis->uMailboxIncomingPositionCurrent = 0;
    13281328
    13291329# ifdef LOG_ENABLED
    1330     ASMAtomicIncU32(&pBusLogic->cInMailboxesReadyIfLogEnabled);
     1330    ASMAtomicIncU32(&pThis->cInMailboxesReadyIfLogEnabled);
    13311331# endif
    13321332
    1333     buslogicSetInterrupt(pDevIns, pBusLogic, false, BL_INTR_IMBL);
    1334 
    1335     PDMDevHlpCritSectLeave(pDevIns, &pBusLogic->CritSectIntr);
     1333    buslogicSetInterrupt(pDevIns, pThis, false, BL_INTR_IMBL);
     1334
     1335    PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSectIntr);
    13361336}
    13371337
     
    15761576 * @param   pDevIns         The device instance.
    15771577 * @param   pThis           Pointer to the Buslogic device state.
    1578  * @param   pReq            Pointe to the request state.
     1578 * @param   pReq            Pointer to the request state.
    15791579 * @param   pfnCopyWorker   The copy method to apply for each guest buffer.
    15801580 * @param   pSgBuf          The host S/G buffer.
     
    18041804 * @returns VBox status code.
    18051805 * @param   pDevIns     The PDM device instance.
    1806  * @param   pBusLogic   Pointer to the shared BusLogic instance data.
    1807  */
    1808 static int buslogicProcessCommand(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic)
     1806 * @param   pThis       Pointer to the shared BusLogic instance data.
     1807 */
     1808static int buslogicProcessCommand(PPDMDEVINS pDevIns, PBUSLOGIC pThis)
    18091809{
    18101810    int rc = VINF_SUCCESS;
    18111811    bool fSuppressIrq = false;
    18121812
    1813     LogFlowFunc(("pBusLogic=%#p\n", pBusLogic));
    1814     AssertMsg(pBusLogic->uOperationCode != 0xff, ("There is no command to execute\n"));
    1815 
    1816     switch (pBusLogic->uOperationCode)
     1813    LogFlowFunc(("pThis=%#p\n", pThis));
     1814    AssertMsg(pThis->uOperationCode != 0xff, ("There is no command to execute\n"));
     1815
     1816    switch (pThis->uOperationCode)
    18171817    {
    18181818        case BUSLOGICCOMMAND_TEST_CMDC_INTERRUPT:
    18191819            /* Valid command, no reply. */
    1820             pBusLogic->cbReplyParametersLeft = 0;
     1820            pThis->cbReplyParametersLeft = 0;
    18211821            break;
    18221822        case BUSLOGICCOMMAND_INQUIRE_PCI_HOST_ADAPTER_INFORMATION:
    18231823        {
    1824             PReplyInquirePCIHostAdapterInformation pReply = (PReplyInquirePCIHostAdapterInformation)pBusLogic->aReplyBuffer;
     1824            PReplyInquirePCIHostAdapterInformation pReply = (PReplyInquirePCIHostAdapterInformation)pThis->aReplyBuffer;
    18251825            memset(pReply, 0, sizeof(ReplyInquirePCIHostAdapterInformation));
    18261826
    18271827            /* It seems VMware does not provide valid information here too, lets do the same :) */
    18281828            pReply->InformationIsValid = 0;
    1829             pReply->IsaIOPort = pBusLogic->uISABaseCode;
     1829            pReply->IsaIOPort = pThis->uISABaseCode;
    18301830            pReply->IRQ = PCIDevGetInterruptLine(pDevIns->apPciDevs[0]);
    1831             pBusLogic->cbReplyParametersLeft = sizeof(ReplyInquirePCIHostAdapterInformation);
     1831            pThis->cbReplyParametersLeft = sizeof(ReplyInquirePCIHostAdapterInformation);
    18321832            break;
    18331833        }
     
    18351835        {
    18361836            /* no-op */
    1837             pBusLogic->cbReplyParametersLeft = 0;
     1837            pThis->cbReplyParametersLeft = 0;
    18381838            break;
    18391839        }
     
    18451845             */
    18461846#ifdef IN_RING3 /* We can do this from ring-0 now, but we'd like to see the LogRel, so we keep going back to ring-3 anyway. */
    1847             Log(("ISA I/O for PCI (code %x)\n", pBusLogic->aCommandBuffer[0]));
    1848             buslogicR3RegisterISARange(pDevIns, pBusLogic, pBusLogic->aCommandBuffer[0]);
    1849             pBusLogic->cbReplyParametersLeft = 0;
     1847            Log(("ISA I/O for PCI (code %x)\n", pThis->aCommandBuffer[0]));
     1848            buslogicR3RegisterISARange(pDevIns, pThis, pThis->aCommandBuffer[0]);
     1849            pThis->cbReplyParametersLeft = 0;
    18501850            fSuppressIrq = true;
    18511851            break;
     
    18611861             * the adapter only when the byte is *not* '0' or 'B'.
    18621862             */
    1863             if (pBusLogic->uDevType == DEV_AHA_1540B)
     1863            if (pThis->uDevType == DEV_AHA_1540B)
    18641864            {
    1865                 pBusLogic->aReplyBuffer[0] = 'A'; /* Firmware option bytes */
    1866                 pBusLogic->aReplyBuffer[1] = '0'; /* Special option byte */
     1865                pThis->aReplyBuffer[0] = 'A'; /* Firmware option bytes */
     1866                pThis->aReplyBuffer[1] = '0'; /* Special option byte */
    18671867            }
    18681868            else
    18691869            {
    1870                 pBusLogic->aReplyBuffer[0] = 'A'; /* Firmware option bytes */
    1871                 pBusLogic->aReplyBuffer[1] = 'A'; /* Special option byte */
     1870                pThis->aReplyBuffer[0] = 'A'; /* Firmware option bytes */
     1871                pThis->aReplyBuffer[1] = 'A'; /* Special option byte */
    18721872            }
    18731873
    18741874            /* We report version 5.07B. This reply will provide the first two digits. */
    1875             pBusLogic->aReplyBuffer[2] = '5'; /* Major version 5 */
    1876             pBusLogic->aReplyBuffer[3] = '0'; /* Minor version 0 */
    1877             pBusLogic->cbReplyParametersLeft = 4; /* Reply is 4 bytes long */
     1875            pThis->aReplyBuffer[2] = '5'; /* Major version 5 */
     1876            pThis->aReplyBuffer[3] = '0'; /* Minor version 0 */
     1877            pThis->cbReplyParametersLeft = 4; /* Reply is 4 bytes long */
    18781878            break;
    18791879        }
    18801880        case BUSLOGICCOMMAND_INQUIRE_FIRMWARE_VERSION_3RD_LETTER:
    18811881        {
    1882             if (pBusLogic->uDevType == DEV_AHA_1540B)
     1882            if (pThis->uDevType == DEV_AHA_1540B)
    18831883            {
    18841884                /* Newer ASPI4DOS.SYS versions expect this command to fail. */
    1885                 Log(("Command %#x not valid for this adapter\n", pBusLogic->uOperationCode));
    1886                 pBusLogic->cbReplyParametersLeft = 0;
    1887                 pBusLogic->regStatus |= BL_STAT_CMDINV;
     1885                Log(("Command %#x not valid for this adapter\n", pThis->uOperationCode));
     1886                pThis->cbReplyParametersLeft = 0;
     1887                pThis->regStatus |= BL_STAT_CMDINV;
    18881888                break;
    18891889            }
    18901890
    1891             pBusLogic->aReplyBuffer[0] = '7';
    1892             pBusLogic->cbReplyParametersLeft = 1;
     1891            pThis->aReplyBuffer[0] = '7';
     1892            pThis->cbReplyParametersLeft = 1;
    18931893            break;
    18941894        }
    18951895        case BUSLOGICCOMMAND_INQUIRE_FIRMWARE_VERSION_LETTER:
    18961896        {
    1897             pBusLogic->aReplyBuffer[0] = 'B';
    1898             pBusLogic->cbReplyParametersLeft = 1;
     1897            pThis->aReplyBuffer[0] = 'B';
     1898            pThis->cbReplyParametersLeft = 1;
    18991899            break;
    19001900        }
    19011901        case BUSLOGICCOMMAND_SET_ADAPTER_OPTIONS:
    19021902            /* The parameter list length is determined by the first byte of the command buffer. */
    1903             if (pBusLogic->iParameter == 1)
     1903            if (pThis->iParameter == 1)
    19041904            {
    19051905                /* First pass - set the number of following parameter bytes. */
    1906                 pBusLogic->cbCommandParametersLeft = pBusLogic->aCommandBuffer[0];
    1907                 Log(("Set HA options: %u bytes follow\n", pBusLogic->cbCommandParametersLeft));
     1906                pThis->cbCommandParametersLeft = pThis->aCommandBuffer[0];
     1907                Log(("Set HA options: %u bytes follow\n", pThis->cbCommandParametersLeft));
    19081908            }
    19091909            else
    19101910            {
    19111911                /* Second pass - process received data. */
    1912                 Log(("Set HA options: received %u bytes\n", pBusLogic->aCommandBuffer[0]));
     1912                Log(("Set HA options: received %u bytes\n", pThis->aCommandBuffer[0]));
    19131913                /* We ignore the data - it only concerns the SCSI hardware protocol. */
    19141914            }
    1915             pBusLogic->cbReplyParametersLeft = 0;
     1915            pThis->cbReplyParametersLeft = 0;
    19161916            break;
    19171917
     
    19201920             * the number of additional CDB bytes that will follow.
    19211921             */
    1922             if (pBusLogic->iParameter == 12)
     1922            if (pThis->iParameter == 12)
    19231923            {
    19241924                /* First pass - set the number of following CDB bytes. */
    1925                 pBusLogic->cbCommandParametersLeft = pBusLogic->aCommandBuffer[11];
    1926                 Log(("Execute SCSI cmd: %u more bytes follow\n", pBusLogic->cbCommandParametersLeft));
     1925                pThis->cbCommandParametersLeft = pThis->aCommandBuffer[11];
     1926                Log(("Execute SCSI cmd: %u more bytes follow\n", pThis->cbCommandParametersLeft));
    19271927            }
    19281928            else
     
    19311931
    19321932                /* Second pass - process received data. */
    1933                 Log(("Execute SCSI cmd: received %u bytes\n", pBusLogic->aCommandBuffer[0]));
    1934 
    1935                 pCmd = (PESCMD)pBusLogic->aCommandBuffer;
     1933                Log(("Execute SCSI cmd: received %u bytes\n", pThis->aCommandBuffer[0]));
     1934
     1935                pCmd = (PESCMD)pThis->aCommandBuffer;
    19361936                Log(("Addr %08X, cbData %08X, cbCDB=%u\n", pCmd->u32PhysAddrData, pCmd->cbData, pCmd->cbCDB));
    19371937            }
    19381938            // This is currently a dummy - just fails every command.
    1939             pBusLogic->cbReplyParametersLeft = 4;
    1940             pBusLogic->aReplyBuffer[0] = pBusLogic->aReplyBuffer[1] = 0;
    1941             pBusLogic->aReplyBuffer[2] = 0x11;      /* HBA status (timeout). */
    1942             pBusLogic->aReplyBuffer[3] = 0;         /* Device status. */
     1939            pThis->cbReplyParametersLeft = 4;
     1940            pThis->aReplyBuffer[0] = pThis->aReplyBuffer[1] = 0;
     1941            pThis->aReplyBuffer[2] = 0x11;      /* HBA status (timeout). */
     1942            pThis->aReplyBuffer[3] = 0;         /* Device status. */
    19431943            break;
    19441944
     
    19461946        {
    19471947            /* Not supported on AHA-154x. */
    1948             if (pBusLogic->uDevType == DEV_AHA_1540B)
     1948            if (pThis->uDevType == DEV_AHA_1540B)
    19491949            {
    1950                 Log(("Command %#x not valid for this adapter\n", pBusLogic->uOperationCode));
    1951                 pBusLogic->cbReplyParametersLeft = 0;
    1952                 pBusLogic->regStatus |= BL_STAT_CMDINV;
     1950                Log(("Command %#x not valid for this adapter\n", pThis->uOperationCode));
     1951                pThis->cbReplyParametersLeft = 0;
     1952                pThis->regStatus |= BL_STAT_CMDINV;
    19531953                break;
    19541954            }
    19551955
    19561956            /* The reply length is set by the guest and is found in the first byte of the command buffer. */
    1957             if (pBusLogic->aCommandBuffer[0] > sizeof(pBusLogic->aReplyBuffer))
     1957            if (pThis->aCommandBuffer[0] > sizeof(pThis->aReplyBuffer))
    19581958            {
    1959                 Log(("Requested too much adapter model number data (%u)!\n", pBusLogic->aCommandBuffer[0]));
    1960                 pBusLogic->regStatus |= BL_STAT_CMDINV;
     1959                Log(("Requested too much adapter model number data (%u)!\n", pThis->aCommandBuffer[0]));
     1960                pThis->regStatus |= BL_STAT_CMDINV;
    19611961                break;
    19621962            }
    1963             pBusLogic->cbReplyParametersLeft = pBusLogic->aCommandBuffer[0];
    1964             memset(pBusLogic->aReplyBuffer, 0, sizeof(pBusLogic->aReplyBuffer));
     1963            pThis->cbReplyParametersLeft = pThis->aCommandBuffer[0];
     1964            memset(pThis->aReplyBuffer, 0, sizeof(pThis->aReplyBuffer));
    19651965            const char aModelName[] = "958D ";  /* Trailing \0 is fine, that's the filler anyway. */
    1966             int cCharsToTransfer =   pBusLogic->cbReplyParametersLeft <= sizeof(aModelName)
    1967                                    ? pBusLogic->cbReplyParametersLeft
     1966            int cCharsToTransfer =   pThis->cbReplyParametersLeft <= sizeof(aModelName)
     1967                                   ? pThis->cbReplyParametersLeft
    19681968                                   : sizeof(aModelName);
    19691969
    19701970            for (int i = 0; i < cCharsToTransfer; i++)
    1971                 pBusLogic->aReplyBuffer[i] = aModelName[i];
     1971                pThis->aReplyBuffer[i] = aModelName[i];
    19721972
    19731973            break;
     
    19771977            uint8_t uIrq;
    19781978
    1979             if (pBusLogic->uIsaIrq)
    1980                 uIrq = pBusLogic->uIsaIrq;
     1979            if (pThis->uIsaIrq)
     1980                uIrq = pThis->uIsaIrq;
    19811981            else
    19821982                uIrq = PCIDevGetInterruptLine(pDevIns->apPciDevs[0]);
    19831983
    1984             pBusLogic->cbReplyParametersLeft = sizeof(ReplyInquireConfiguration);
    1985             PReplyInquireConfiguration pReply = (PReplyInquireConfiguration)pBusLogic->aReplyBuffer;
     1984            pThis->cbReplyParametersLeft = sizeof(ReplyInquireConfiguration);
     1985            PReplyInquireConfiguration pReply = (PReplyInquireConfiguration)pThis->aReplyBuffer;
    19861986            memset(pReply, 0, sizeof(ReplyInquireConfiguration));
    19871987
     
    20152015             * Adaptec 154x models supposedly support it too??
    20162016             */
    2017             if (pBusLogic->uDevType == DEV_AHA_1540B)
     2017            if (pThis->uDevType == DEV_AHA_1540B)
    20182018            {
    2019                 Log(("Command %#x not valid for this adapter\n", pBusLogic->uOperationCode));
    2020                 pBusLogic->cbReplyParametersLeft = 0;
    2021                 pBusLogic->regStatus |= BL_STAT_CMDINV;
     2019                Log(("Command %#x not valid for this adapter\n", pThis->uOperationCode));
     2020                pThis->cbReplyParametersLeft = 0;
     2021                pThis->regStatus |= BL_STAT_CMDINV;
    20222022                break;
    20232023            }
    20242024
    20252025            /* The reply length is set by the guest and is found in the first byte of the command buffer. */
    2026             pBusLogic->cbReplyParametersLeft = pBusLogic->aCommandBuffer[0];
    2027             PReplyInquireExtendedSetupInformation pReply = (PReplyInquireExtendedSetupInformation)pBusLogic->aReplyBuffer;
     2026            pThis->cbReplyParametersLeft = pThis->aCommandBuffer[0];
     2027            PReplyInquireExtendedSetupInformation pReply = (PReplyInquireExtendedSetupInformation)pThis->aReplyBuffer;
    20282028            memset(pReply, 0, sizeof(ReplyInquireExtendedSetupInformation));
    20292029
     
    20312031            pReply->uBusType = 'E';         /* EISA style */
    20322032            pReply->u16ScatterGatherLimit = 8192;
    2033             pReply->cMailbox = pBusLogic->cMailbox;
    2034             pReply->uMailboxAddressBase = (uint32_t)pBusLogic->GCPhysAddrMailboxOutgoingBase;
     2033            pReply->cMailbox = pThis->cMailbox;
     2034            pReply->uMailboxAddressBase = (uint32_t)pThis->GCPhysAddrMailboxOutgoingBase;
    20352035            pReply->fLevelSensitiveInterrupt = true;
    20362036            pReply->fHostWideSCSI = true;
     
    20432043        {
    20442044            /* The reply length is set by the guest and is found in the first byte of the command buffer. */
    2045             pBusLogic->cbReplyParametersLeft = pBusLogic->aCommandBuffer[0];
    2046             PReplyInquireSetupInformation pReply = (PReplyInquireSetupInformation)pBusLogic->aReplyBuffer;
     2045            pThis->cbReplyParametersLeft = pThis->aCommandBuffer[0];
     2046            PReplyInquireSetupInformation pReply = (PReplyInquireSetupInformation)pThis->aReplyBuffer;
    20472047            memset(pReply, 0, sizeof(ReplyInquireSetupInformation));
    20482048            pReply->fSynchronousInitiationEnabled = true;
    20492049            pReply->fParityCheckingEnabled = true;
    2050             pReply->cMailbox = pBusLogic->cMailbox;
    2051             U32_TO_ADDR(pReply->MailboxAddress, pBusLogic->GCPhysAddrMailboxOutgoingBase);
     2050            pReply->cMailbox = pThis->cMailbox;
     2051            U32_TO_ADDR(pReply->MailboxAddress, pThis->GCPhysAddrMailboxOutgoingBase);
    20522052            /* The 'D' signature (actually 'SD' for Storage Dimensions, and 'BD' for BusLogic)
    20532053             * prevents Adaptec's OS/2 drivers from getting too friendly with BusLogic hardware
    20542054             * and upsetting the HBA state.
    20552055             */
    2056             if (pBusLogic->uDevType == DEV_AHA_1540B)
     2056            if (pThis->uDevType == DEV_AHA_1540B)
    20572057            {
    20582058                pReply->uSignature  = 0;    /* Zeros for Adaptec. */
     
    20732073             * and second one the number of bytes to read.
    20742074             */
    2075             uint8_t uOffset = pBusLogic->aCommandBuffer[0];
    2076             pBusLogic->cbReplyParametersLeft  = pBusLogic->aCommandBuffer[1];
    2077 
    2078             pBusLogic->fUseLocalRam = true;
    2079             pBusLogic->iReply = uOffset;
     2075            uint8_t uOffset = pThis->aCommandBuffer[0];
     2076            pThis->cbReplyParametersLeft  = pThis->aCommandBuffer[1];
     2077
     2078            pThis->fUseLocalRam = true;
     2079            pThis->iReply = uOffset;
    20802080            break;
    20812081        }
    20822082        case BUSLOGICCOMMAND_INITIALIZE_MAILBOX:
    20832083        {
    2084             PRequestInitMbx pRequest = (PRequestInitMbx)pBusLogic->aCommandBuffer;
    2085 
    2086             pBusLogic->cbReplyParametersLeft = 0;
     2084            PRequestInitMbx pRequest = (PRequestInitMbx)pThis->aCommandBuffer;
     2085
     2086            pThis->cbReplyParametersLeft = 0;
    20872087            if (!pRequest->cMailbox)
    20882088            {
    2089                 Log(("cMailboxes=%u (24-bit mode), fail!\n", pBusLogic->cMailbox));
    2090                 pBusLogic->regStatus |= BL_STAT_CMDINV;
     2089                Log(("cMailboxes=%u (24-bit mode), fail!\n", pThis->cMailbox));
     2090                pThis->regStatus |= BL_STAT_CMDINV;
    20912091                break;
    20922092            }
    2093             pBusLogic->fMbxIs24Bit = true;
    2094             pBusLogic->cMailbox = pRequest->cMailbox;
    2095             pBusLogic->GCPhysAddrMailboxOutgoingBase = (RTGCPHYS)ADDR_TO_U32(pRequest->aMailboxBaseAddr);
     2093            pThis->fMbxIs24Bit = true;
     2094            pThis->cMailbox = pRequest->cMailbox;
     2095            pThis->GCPhysAddrMailboxOutgoingBase = (RTGCPHYS)ADDR_TO_U32(pRequest->aMailboxBaseAddr);
    20962096            /* The area for incoming mailboxes is right after the last entry of outgoing mailboxes. */
    2097             pBusLogic->GCPhysAddrMailboxIncomingBase = pBusLogic->GCPhysAddrMailboxOutgoingBase + (pBusLogic->cMailbox * sizeof(Mailbox24));
    2098 
    2099             Log(("GCPhysAddrMailboxOutgoingBase=%RGp\n", pBusLogic->GCPhysAddrMailboxOutgoingBase));
    2100             Log(("GCPhysAddrMailboxIncomingBase=%RGp\n", pBusLogic->GCPhysAddrMailboxIncomingBase));
    2101             Log(("cMailboxes=%u (24-bit mode)\n", pBusLogic->cMailbox));
     2097            pThis->GCPhysAddrMailboxIncomingBase = pThis->GCPhysAddrMailboxOutgoingBase + (pThis->cMailbox * sizeof(Mailbox24));
     2098
     2099            Log(("GCPhysAddrMailboxOutgoingBase=%RGp\n", pThis->GCPhysAddrMailboxOutgoingBase));
     2100            Log(("GCPhysAddrMailboxIncomingBase=%RGp\n", pThis->GCPhysAddrMailboxIncomingBase));
     2101            Log(("cMailboxes=%u (24-bit mode)\n", pThis->cMailbox));
    21022102            LogRel(("Initialized 24-bit mailbox, %d entries at %08x\n", pRequest->cMailbox, ADDR_TO_U32(pRequest->aMailboxBaseAddr)));
    21032103
    2104             pBusLogic->regStatus &= ~BL_STAT_INREQ;
     2104            pThis->regStatus &= ~BL_STAT_INREQ;
    21052105            break;
    21062106        }
    21072107        case BUSLOGICCOMMAND_INITIALIZE_EXTENDED_MAILBOX:
    21082108        {
    2109             if (pBusLogic->uDevType == DEV_AHA_1540B)
     2109            if (pThis->uDevType == DEV_AHA_1540B)
    21102110            {
    2111                 Log(("Command %#x not valid for this adapter\n", pBusLogic->uOperationCode));
    2112                 pBusLogic->cbReplyParametersLeft = 0;
    2113                 pBusLogic->regStatus |= BL_STAT_CMDINV;
     2111                Log(("Command %#x not valid for this adapter\n", pThis->uOperationCode));
     2112                pThis->cbReplyParametersLeft = 0;
     2113                pThis->regStatus |= BL_STAT_CMDINV;
    21142114                break;
    21152115            }
    21162116
    2117             PRequestInitializeExtendedMailbox pRequest = (PRequestInitializeExtendedMailbox)pBusLogic->aCommandBuffer;
    2118 
    2119             pBusLogic->cbReplyParametersLeft = 0;
     2117            PRequestInitializeExtendedMailbox pRequest = (PRequestInitializeExtendedMailbox)pThis->aCommandBuffer;
     2118
     2119            pThis->cbReplyParametersLeft = 0;
    21202120            if (!pRequest->cMailbox)
    21212121            {
    2122                 Log(("cMailboxes=%u (32-bit mode), fail!\n", pBusLogic->cMailbox));
    2123                 pBusLogic->regStatus |= BL_STAT_CMDINV;
     2122                Log(("cMailboxes=%u (32-bit mode), fail!\n", pThis->cMailbox));
     2123                pThis->regStatus |= BL_STAT_CMDINV;
    21242124                break;
    21252125            }
    2126             pBusLogic->fMbxIs24Bit = false;
    2127             pBusLogic->cMailbox = pRequest->cMailbox;
    2128             pBusLogic->GCPhysAddrMailboxOutgoingBase = (RTGCPHYS)pRequest->uMailboxBaseAddress;
     2126            pThis->fMbxIs24Bit = false;
     2127            pThis->cMailbox = pRequest->cMailbox;
     2128            pThis->GCPhysAddrMailboxOutgoingBase = (RTGCPHYS)pRequest->uMailboxBaseAddress;
    21292129            /* The area for incoming mailboxes is right after the last entry of outgoing mailboxes. */
    2130             pBusLogic->GCPhysAddrMailboxIncomingBase = (RTGCPHYS)pRequest->uMailboxBaseAddress + (pBusLogic->cMailbox * sizeof(Mailbox32));
    2131 
    2132             Log(("GCPhysAddrMailboxOutgoingBase=%RGp\n", pBusLogic->GCPhysAddrMailboxOutgoingBase));
    2133             Log(("GCPhysAddrMailboxIncomingBase=%RGp\n", pBusLogic->GCPhysAddrMailboxIncomingBase));
    2134             Log(("cMailboxes=%u (32-bit mode)\n", pBusLogic->cMailbox));
     2130            pThis->GCPhysAddrMailboxIncomingBase = (RTGCPHYS)pRequest->uMailboxBaseAddress + (pThis->cMailbox * sizeof(Mailbox32));
     2131
     2132            Log(("GCPhysAddrMailboxOutgoingBase=%RGp\n", pThis->GCPhysAddrMailboxOutgoingBase));
     2133            Log(("GCPhysAddrMailboxIncomingBase=%RGp\n", pThis->GCPhysAddrMailboxIncomingBase));
     2134            Log(("cMailboxes=%u (32-bit mode)\n", pThis->cMailbox));
    21352135            LogRel(("Initialized 32-bit mailbox, %d entries at %08x\n", pRequest->cMailbox, pRequest->uMailboxBaseAddress));
    21362136
    2137             pBusLogic->regStatus &= ~BL_STAT_INREQ;
     2137            pThis->regStatus &= ~BL_STAT_INREQ;
    21382138            break;
    21392139        }
    21402140        case BUSLOGICCOMMAND_ENABLE_STRICT_ROUND_ROBIN_MODE:
    21412141        {
    2142             if (pBusLogic->aCommandBuffer[0] == 0)
    2143                 pBusLogic->fStrictRoundRobinMode = false;
    2144             else if (pBusLogic->aCommandBuffer[0] == 1)
    2145                 pBusLogic->fStrictRoundRobinMode = true;
     2142            if (pThis->aCommandBuffer[0] == 0)
     2143                pThis->fStrictRoundRobinMode = false;
     2144            else if (pThis->aCommandBuffer[0] == 1)
     2145                pThis->fStrictRoundRobinMode = true;
    21462146            else
    2147                 AssertMsgFailed(("Invalid round robin mode %d\n", pBusLogic->aCommandBuffer[0]));
    2148 
    2149             pBusLogic->cbReplyParametersLeft = 0;
     2147                AssertMsgFailed(("Invalid round robin mode %d\n", pThis->aCommandBuffer[0]));
     2148
     2149            pThis->cbReplyParametersLeft = 0;
    21502150            break;
    21512151        }
    21522152        case BUSLOGICCOMMAND_SET_CCB_FORMAT:
    21532153        {
    2154             if (pBusLogic->aCommandBuffer[0] == 0)
    2155                 pBusLogic->fExtendedLunCCBFormat = false;
    2156             else if (pBusLogic->aCommandBuffer[0] == 1)
    2157                 pBusLogic->fExtendedLunCCBFormat = true;
     2154            if (pThis->aCommandBuffer[0] == 0)
     2155                pThis->fExtendedLunCCBFormat = false;
     2156            else if (pThis->aCommandBuffer[0] == 1)
     2157                pThis->fExtendedLunCCBFormat = true;
    21582158            else
    2159                 AssertMsgFailed(("Invalid CCB format %d\n", pBusLogic->aCommandBuffer[0]));
    2160 
    2161             pBusLogic->cbReplyParametersLeft = 0;
     2159                AssertMsgFailed(("Invalid CCB format %d\n", pThis->aCommandBuffer[0]));
     2160
     2161            pThis->cbReplyParametersLeft = 0;
    21622162            break;
    21632163        }
     
    21662166             * We cheat and skip that, since we already know what's attached
    21672167             */
    2168             memset(pBusLogic->aReplyBuffer, 0, 8);
     2168            memset(pThis->aReplyBuffer, 0, 8);
    21692169            for (int i = 0; i < 8; ++i)
    21702170            {
    2171                 if (pBusLogic->afDevicePresent[i])
    2172                     pBusLogic->aReplyBuffer[i] = 1;
     2171                if (pThis->afDevicePresent[i])
     2172                    pThis->aReplyBuffer[i] = 1;
    21732173            }
    2174             pBusLogic->aReplyBuffer[7] = 0;     /* HA hardcoded at ID 7. */
    2175             pBusLogic->cbReplyParametersLeft = 8;
     2174            pThis->aReplyBuffer[7] = 0;     /* HA hardcoded at ID 7. */
     2175            pThis->cbReplyParametersLeft = 8;
    21762176            break;
    21772177        case BUSLOGICCOMMAND_INQUIRE_INSTALLED_DEVICES_ID_8_TO_15:
    21782178            /* See note about cheating above. */
    2179             memset(pBusLogic->aReplyBuffer, 0, 8);
     2179            memset(pThis->aReplyBuffer, 0, 8);
    21802180            for (int i = 0; i < 8; ++i)
    21812181            {
    2182                 if (pBusLogic->afDevicePresent[i + 8])
    2183                     pBusLogic->aReplyBuffer[i] = 1;
     2182                if (pThis->afDevicePresent[i + 8])
     2183                    pThis->aReplyBuffer[i] = 1;
    21842184            }
    2185             pBusLogic->cbReplyParametersLeft = 8;
     2185            pThis->cbReplyParametersLeft = 8;
    21862186            break;
    21872187        case BUSLOGICCOMMAND_INQUIRE_TARGET_DEVICES:
     
    21902190            uint16_t u16TargetsPresentMask = 0;
    21912191
    2192             for (uint8_t i = 0; i < RT_ELEMENTS(pBusLogic->afDevicePresent); i++)
     2192            for (uint8_t i = 0; i < RT_ELEMENTS(pThis->afDevicePresent); i++)
    21932193            {
    2194                 if (pBusLogic->afDevicePresent[i])
     2194                if (pThis->afDevicePresent[i])
    21952195                    u16TargetsPresentMask |= (1 << i);
    21962196            }
    2197             pBusLogic->aReplyBuffer[0] = (uint8_t)u16TargetsPresentMask;
    2198             pBusLogic->aReplyBuffer[1] = (uint8_t)(u16TargetsPresentMask >> 8);
    2199             pBusLogic->cbReplyParametersLeft = 2;
     2197            pThis->aReplyBuffer[0] = (uint8_t)u16TargetsPresentMask;
     2198            pThis->aReplyBuffer[1] = (uint8_t)(u16TargetsPresentMask >> 8);
     2199            pThis->cbReplyParametersLeft = 2;
    22002200            break;
    22012201        }
    22022202        case BUSLOGICCOMMAND_INQUIRE_SYNCHRONOUS_PERIOD:
    22032203        {
    2204             if (pBusLogic->aCommandBuffer[0] > sizeof(pBusLogic->aReplyBuffer))
     2204            if (pThis->aCommandBuffer[0] > sizeof(pThis->aReplyBuffer))
    22052205            {
    2206                 Log(("Requested too much synch period inquiry (%u)!\n", pBusLogic->aCommandBuffer[0]));
    2207                 pBusLogic->regStatus |= BL_STAT_CMDINV;
     2206                Log(("Requested too much synch period inquiry (%u)!\n", pThis->aCommandBuffer[0]));
     2207                pThis->regStatus |= BL_STAT_CMDINV;
    22082208                break;
    22092209            }
    2210             pBusLogic->cbReplyParametersLeft = pBusLogic->aCommandBuffer[0];
    2211             for (uint8_t i = 0; i < pBusLogic->cbReplyParametersLeft; i++)
    2212                 pBusLogic->aReplyBuffer[i] = 0; /** @todo Figure if we need something other here. It's not needed for the linux driver */
     2210            pThis->cbReplyParametersLeft = pThis->aCommandBuffer[0];
     2211            for (uint8_t i = 0; i < pThis->cbReplyParametersLeft; i++)
     2212                pThis->aReplyBuffer[i] = 0; /** @todo Figure if we need something other here. It's not needed for the linux driver */
    22132213
    22142214            break;
     
    22172217        {
    22182218            /* Not supported on AHA-154x HBAs. */
    2219             if (pBusLogic->uDevType == DEV_AHA_1540B)
     2219            if (pThis->uDevType == DEV_AHA_1540B)
    22202220            {
    2221                 Log(("Command %#x not valid for this adapter\n", pBusLogic->uOperationCode));
    2222                 pBusLogic->cbReplyParametersLeft = 0;
    2223                 pBusLogic->regStatus |= BL_STAT_CMDINV;
     2221                Log(("Command %#x not valid for this adapter\n", pThis->uOperationCode));
     2222                pThis->cbReplyParametersLeft = 0;
     2223                pThis->regStatus |= BL_STAT_CMDINV;
    22242224                break;
    22252225            }
    22262226
    2227             pBusLogic->cbReplyParametersLeft = 0;
    2228             if (pBusLogic->aCommandBuffer[0] == 0)
    2229                 pBusLogic->fIRQEnabled = false;
     2227            pThis->cbReplyParametersLeft = 0;
     2228            if (pThis->aCommandBuffer[0] == 0)
     2229                pThis->fIRQEnabled = false;
    22302230            else
    2231                 pBusLogic->fIRQEnabled = true;
     2231                pThis->fIRQEnabled = true;
    22322232            /* No interrupt signaled regardless of enable/disable. */
    22332233            fSuppressIrq = true;
     
    22362236        case BUSLOGICCOMMAND_ECHO_COMMAND_DATA:
    22372237        {
    2238             pBusLogic->aReplyBuffer[0] = pBusLogic->aCommandBuffer[0];
    2239             pBusLogic->cbReplyParametersLeft = 1;
     2238            pThis->aReplyBuffer[0] = pThis->aCommandBuffer[0];
     2239            pThis->cbReplyParametersLeft = 1;
    22402240            break;
    22412241        }
    22422242        case BUSLOGICCOMMAND_ENABLE_OUTGOING_MAILBOX_AVAILABLE_INTERRUPT:
    22432243        {
    2244             uint8_t     uEnable = pBusLogic->aCommandBuffer[0];
    2245 
    2246             pBusLogic->cbReplyParametersLeft = 0;
     2244            uint8_t     uEnable = pThis->aCommandBuffer[0];
     2245
     2246            pThis->cbReplyParametersLeft = 0;
    22472247            Log(("Enable OMBR: %u\n", uEnable));
    22482248            /* Only 0/1 are accepted. */
    22492249            if (uEnable > 1)
    2250                 pBusLogic->regStatus |= BL_STAT_CMDINV;
     2250                pThis->regStatus |= BL_STAT_CMDINV;
    22512251            else
    22522252            {
    2253                 pBusLogic->LocalRam.structured.autoSCSIData.uReserved6 = uEnable;
     2253                pThis->LocalRam.structured.autoSCSIData.uReserved6 = uEnable;
    22542254                fSuppressIrq = true;
    22552255            }
     
    22582258        case BUSLOGICCOMMAND_SET_PREEMPT_TIME_ON_BUS:
    22592259        {
    2260             pBusLogic->cbReplyParametersLeft = 0;
    2261             pBusLogic->LocalRam.structured.autoSCSIData.uBusOnDelay = pBusLogic->aCommandBuffer[0];
    2262             Log(("Bus-on time: %d\n", pBusLogic->aCommandBuffer[0]));
     2260            pThis->cbReplyParametersLeft = 0;
     2261            pThis->LocalRam.structured.autoSCSIData.uBusOnDelay = pThis->aCommandBuffer[0];
     2262            Log(("Bus-on time: %d\n", pThis->aCommandBuffer[0]));
    22632263            break;
    22642264        }
    22652265        case BUSLOGICCOMMAND_SET_TIME_OFF_BUS:
    22662266        {
    2267             pBusLogic->cbReplyParametersLeft = 0;
    2268             pBusLogic->LocalRam.structured.autoSCSIData.uBusOffDelay = pBusLogic->aCommandBuffer[0];
    2269             Log(("Bus-off time: %d\n", pBusLogic->aCommandBuffer[0]));
     2267            pThis->cbReplyParametersLeft = 0;
     2268            pThis->LocalRam.structured.autoSCSIData.uBusOffDelay = pThis->aCommandBuffer[0];
     2269            Log(("Bus-off time: %d\n", pThis->aCommandBuffer[0]));
    22702270            break;
    22712271        }
    22722272        case BUSLOGICCOMMAND_SET_BUS_TRANSFER_RATE:
    22732273        {
    2274             pBusLogic->cbReplyParametersLeft = 0;
    2275             pBusLogic->LocalRam.structured.autoSCSIData.uDMATransferRate = pBusLogic->aCommandBuffer[0];
    2276             Log(("Bus transfer rate: %02X\n", pBusLogic->aCommandBuffer[0]));
     2274            pThis->cbReplyParametersLeft = 0;
     2275            pThis->LocalRam.structured.autoSCSIData.uDMATransferRate = pThis->aCommandBuffer[0];
     2276            Log(("Bus transfer rate: %02X\n", pThis->aCommandBuffer[0]));
    22772277            break;
    22782278        }
     
    22822282            Addr24   addr;
    22832283
    2284             pBusLogic->cbReplyParametersLeft = 0;
    2285             addr.hi  = pBusLogic->aCommandBuffer[0];
    2286             addr.mid = pBusLogic->aCommandBuffer[1];
    2287             addr.lo  = pBusLogic->aCommandBuffer[2];
     2284            pThis->cbReplyParametersLeft = 0;
     2285            addr.hi  = pThis->aCommandBuffer[0];
     2286            addr.mid = pThis->aCommandBuffer[1];
     2287            addr.lo  = pThis->aCommandBuffer[2];
    22882288            GCPhysFifoBuf = (RTGCPHYS)ADDR_TO_U32(addr);
    22892289            Log(("Write busmaster FIFO at: %04X\n", ADDR_TO_U32(addr)));
    22902290            PDMDevHlpPhysRead(pDevIns, GCPhysFifoBuf,
    2291                               &pBusLogic->LocalRam.u8View[64], 64);
     2291                              &pThis->LocalRam.u8View[64], 64);
    22922292            break;
    22932293        }
     
    22972297            Addr24   addr;
    22982298
    2299             pBusLogic->cbReplyParametersLeft = 0;
    2300             addr.hi  = pBusLogic->aCommandBuffer[0];
    2301             addr.mid = pBusLogic->aCommandBuffer[1];
    2302             addr.lo  = pBusLogic->aCommandBuffer[2];
     2299            pThis->cbReplyParametersLeft = 0;
     2300            addr.hi  = pThis->aCommandBuffer[0];
     2301            addr.mid = pThis->aCommandBuffer[1];
     2302            addr.lo  = pThis->aCommandBuffer[2];
    23032303            GCPhysFifoBuf = (RTGCPHYS)ADDR_TO_U32(addr);
    23042304            Log(("Read busmaster FIFO at: %04X\n", ADDR_TO_U32(addr)));
    2305             blPhysWrite(pDevIns, pBusLogic, GCPhysFifoBuf, &pBusLogic->LocalRam.u8View[64], 64);
     2305            blPhysWrite(pDevIns, pThis, GCPhysFifoBuf, &pThis->LocalRam.u8View[64], 64);
    23062306            break;
    23072307        }
    23082308        default:
    2309             AssertMsgFailed(("Invalid command %#x\n", pBusLogic->uOperationCode));
     2309            AssertMsgFailed(("Invalid command %#x\n", pThis->uOperationCode));
    23102310            RT_FALL_THRU();
    23112311        case BUSLOGICCOMMAND_EXT_BIOS_INFO:
     
    23142314             * we pretend being 154xB compatible. Just mark the command as invalid.
    23152315             */
    2316             Log(("Command %#x not valid for this adapter\n", pBusLogic->uOperationCode));
    2317             pBusLogic->cbReplyParametersLeft = 0;
    2318             pBusLogic->regStatus |= BL_STAT_CMDINV;
     2316            Log(("Command %#x not valid for this adapter\n", pThis->uOperationCode));
     2317            pThis->cbReplyParametersLeft = 0;
     2318            pThis->regStatus |= BL_STAT_CMDINV;
    23192319            break;
    23202320        case BUSLOGICCOMMAND_EXECUTE_MAILBOX_COMMAND: /* Should be handled already. */
     
    23222322    }
    23232323
    2324     Log(("uOperationCode=%#x, cbReplyParametersLeft=%d\n", pBusLogic->uOperationCode, pBusLogic->cbReplyParametersLeft));
     2324    Log(("uOperationCode=%#x, cbReplyParametersLeft=%d\n", pThis->uOperationCode, pThis->cbReplyParametersLeft));
    23252325
    23262326    /* Fail command if too much parameter data requested. */
    2327     if ((pBusLogic->cbCommandParametersLeft + pBusLogic->iParameter) > sizeof(pBusLogic->aCommandBuffer))
    2328     {
    2329         Log(("Invalid command parameter length (%u)\n", pBusLogic->cbCommandParametersLeft));
    2330         pBusLogic->cbReplyParametersLeft   = 0;
    2331         pBusLogic->cbCommandParametersLeft = 0;
    2332         pBusLogic->regStatus |= BL_STAT_CMDINV;
     2327    if ((pThis->cbCommandParametersLeft + pThis->iParameter) > sizeof(pThis->aCommandBuffer))
     2328    {
     2329        Log(("Invalid command parameter length (%u)\n", pThis->cbCommandParametersLeft));
     2330        pThis->cbReplyParametersLeft   = 0;
     2331        pThis->cbCommandParametersLeft = 0;
     2332        pThis->regStatus |= BL_STAT_CMDINV;
    23332333    }
    23342334
    23352335    /* Set the data in ready bit in the status register in case the command has a reply. */
    2336     if (pBusLogic->cbReplyParametersLeft)
    2337         pBusLogic->regStatus |= BL_STAT_DIRRDY;
    2338     else if (!pBusLogic->cbCommandParametersLeft)
    2339         buslogicCommandComplete(pDevIns, pBusLogic, fSuppressIrq);
     2336    if (pThis->cbReplyParametersLeft)
     2337        pThis->regStatus |= BL_STAT_DIRRDY;
     2338    else if (!pThis->cbCommandParametersLeft)
     2339        buslogicCommandComplete(pDevIns, pThis, fSuppressIrq);
    23402340
    23412341    return rc;
     
    23472347 * @returns VBox status code.
    23482348 * @param   pDevIns     The device instance.
    2349  * @param   pBusLogic   Pointer to the shared BusLogic instance data.
     2349 * @param   pThis       Pointer to the shared BusLogic instance data.
    23502350 * @param   iRegister   The index of the register to read.
    23512351 * @param   pu32        Where to store the register content.
    23522352 */
    2353 static int buslogicRegisterRead(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, unsigned iRegister, uint32_t *pu32)
     2353static int buslogicRegisterRead(PPDMDEVINS pDevIns, PBUSLOGIC pThis, unsigned iRegister, uint32_t *pu32)
    23542354{
    23552355    static const char s_szAhaSig[] = "ADAP";
     
    23602360        case BUSLOGIC_REGISTER_STATUS:
    23612361        {
    2362             *pu32 = pBusLogic->regStatus;
     2362            *pu32 = pThis->regStatus;
    23632363
    23642364            /* If the diagnostic active bit is set, we are in a guest-initiated
     
    23692369             * the DIAG bit at all.
    23702370             */
    2371             if (pBusLogic->regStatus & BL_STAT_DACT)
     2371            if (pThis->regStatus & BL_STAT_DACT)
    23722372            {
    23732373                uint64_t    u64AccessTime = PDMDevHlpTMTimeVirtGetNano(pDevIns);
    23742374
    2375                 pBusLogic->regStatus &= ~BL_STAT_DACT;
    2376                 pBusLogic->regStatus |= BL_STAT_HARDY;
    2377 
    2378                 if (u64AccessTime - pBusLogic->u64ResetTime > BUSLOGIC_RESET_DURATION_NS)
     2375                pThis->regStatus &= ~BL_STAT_DACT;
     2376                pThis->regStatus |= BL_STAT_HARDY;
     2377
     2378                if (u64AccessTime - pThis->u64ResetTime > BUSLOGIC_RESET_DURATION_NS)
    23792379                {
    23802380                    /* If reset already expired, let the guest see that right away. */
    2381                     *pu32 = pBusLogic->regStatus;
    2382                     pBusLogic->u64ResetTime = 0;
     2381                    *pu32 = pThis->regStatus;
     2382                    pThis->u64ResetTime = 0;
    23832383                }
    23842384            }
     
    23872387        case BUSLOGIC_REGISTER_DATAIN:
    23882388        {
    2389             if (pBusLogic->fUseLocalRam)
    2390                 *pu32 = pBusLogic->LocalRam.u8View[pBusLogic->iReply];
     2389            if (pThis->fUseLocalRam)
     2390                *pu32 = pThis->LocalRam.u8View[pThis->iReply];
    23912391            else
    2392                 *pu32 = pBusLogic->aReplyBuffer[pBusLogic->iReply];
     2392                *pu32 = pThis->aReplyBuffer[pThis->iReply];
    23932393
    23942394            /* Careful about underflow - guest can read data register even if
    23952395             * no data is available.
    23962396             */
    2397             if (pBusLogic->cbReplyParametersLeft)
     2397            if (pThis->cbReplyParametersLeft)
    23982398            {
    2399                 pBusLogic->iReply++;
    2400                 pBusLogic->cbReplyParametersLeft--;
    2401                 if (!pBusLogic->cbReplyParametersLeft)
     2399                pThis->iReply++;
     2400                pThis->cbReplyParametersLeft--;
     2401                if (!pThis->cbReplyParametersLeft)
    24022402                {
    24032403                    /*
     
    24062406                     * NB: Some commands do not set the CMDC bit / raise completion interrupt.
    24072407                     */
    2408                     if (pBusLogic->uOperationCode == BUSLOGICCOMMAND_FETCH_HOST_ADAPTER_LOCAL_RAM)
    2409                         buslogicCommandComplete(pDevIns, pBusLogic, true /* fSuppressIrq */);
     2408                    if (pThis->uOperationCode == BUSLOGICCOMMAND_FETCH_HOST_ADAPTER_LOCAL_RAM)
     2409                        buslogicCommandComplete(pDevIns, pThis, true /* fSuppressIrq */);
    24102410                    else
    2411                         buslogicCommandComplete(pDevIns, pBusLogic, false);
     2411                        buslogicCommandComplete(pDevIns, pThis, false);
    24122412                }
    24132413            }
    24142414            LogFlowFunc(("data=%02x, iReply=%d, cbReplyParametersLeft=%u\n", *pu32,
    2415                          pBusLogic->iReply, pBusLogic->cbReplyParametersLeft));
     2415                         pThis->iReply, pThis->cbReplyParametersLeft));
    24162416            break;
    24172417        }
    24182418        case BUSLOGIC_REGISTER_INTERRUPT:
    24192419        {
    2420             *pu32 = pBusLogic->regInterrupt;
     2420            *pu32 = pThis->regInterrupt;
    24212421            break;
    24222422        }
    24232423        case BUSLOGIC_REGISTER_GEOMETRY:
    24242424        {
    2425             if (pBusLogic->uDevType == DEV_AHA_1540B)
     2425            if (pThis->uDevType == DEV_AHA_1540B)
    24262426            {
    2427                 uint8_t off = pBusLogic->uAhaSigIdx & 3;
     2427                uint8_t off = pThis->uAhaSigIdx & 3;
    24282428                *pu32 = s_szAhaSig[off];
    2429                 pBusLogic->uAhaSigIdx = (off + 1) & 3;
     2429                pThis->uAhaSigIdx = (off + 1) & 3;
    24302430            }
    24312431            else
    2432                 *pu32 = pBusLogic->regGeometry;
     2432                *pu32 = pThis->regGeometry;
    24332433            break;
    24342434        }
     
    24482448 * @returns VBox status code.
    24492449 * @param   pDevIns     The PDM device instance.
    2450  * @param   pBusLogic   Pointer to the shared BusLogic instance data.
     2450 * @param   pThis       Pointer to the shared BusLogic instance data.
    24512451 * @param   iRegister   The index of the register to read.
    24522452 * @param   uVal        The value to write.
    24532453 */
    2454 static int buslogicRegisterWrite(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, unsigned iRegister, uint8_t uVal)
     2454static int buslogicRegisterWrite(PPDMDEVINS pDevIns, PBUSLOGIC pThis, unsigned iRegister, uint8_t uVal)
    24552455{
    24562456    int rc = VINF_SUCCESS;
     
    24662466
    24672467                LogRel(("BusLogic: %s reset\n", fHardReset ? "hard" : "soft"));
    2468                 buslogicR3InitiateReset(pDevIns, pBusLogic, PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC), fHardReset);
     2468                buslogicR3InitiateReset(pDevIns, pThis, PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC), fHardReset);
    24692469#else
    24702470                rc = VINF_IOM_R3_IOPORT_WRITE;
     
    24732473            }
    24742474
    2475             rc = PDMDevHlpCritSectEnter(pDevIns, &pBusLogic->CritSectIntr, VINF_IOM_R3_IOPORT_WRITE);
     2475            rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSectIntr, VINF_IOM_R3_IOPORT_WRITE);
    24762476            if (rc != VINF_SUCCESS)
    24772477                return rc;
    24782478
    24792479#ifdef LOG_ENABLED
    2480             uint32_t cMailboxesReady = ASMAtomicXchgU32(&pBusLogic->cInMailboxesReadyIfLogEnabled, 0);
     2480            uint32_t cMailboxesReady = ASMAtomicXchgU32(&pThis->cInMailboxesReadyIfLogEnabled, 0);
    24812481            Log(("%u incoming mailboxes were ready when this interrupt was cleared\n", cMailboxesReady));
    24822482#endif
    24832483
    24842484            if (uVal & BL_CTRL_RINT)
    2485                 buslogicClearInterrupt(pDevIns, pBusLogic);
    2486 
    2487             PDMDevHlpCritSectLeave(pDevIns, &pBusLogic->CritSectIntr);
     2485                buslogicClearInterrupt(pDevIns, pThis);
     2486
     2487            PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSectIntr);
    24882488
    24892489            break;
     
    24922492        {
    24932493            /* Fast path for mailbox execution command. */
    2494             if ((uVal == BUSLOGICCOMMAND_EXECUTE_MAILBOX_COMMAND) && (pBusLogic->uOperationCode == 0xff))
     2494            if ((uVal == BUSLOGICCOMMAND_EXECUTE_MAILBOX_COMMAND) && (pThis->uOperationCode == 0xff))
    24952495            {
    24962496                /// @todo Should fail if BL_STAT_INREQ is set
    24972497                /* If there are no mailboxes configured, don't even try to do anything. */
    2498                 if (pBusLogic->cMailbox)
     2498                if (pThis->cMailbox)
    24992499                {
    2500                     ASMAtomicIncU32(&pBusLogic->cMailboxesReady);
    2501                     if (!ASMAtomicXchgBool(&pBusLogic->fNotificationSent, true))
     2500                    ASMAtomicIncU32(&pThis->cMailboxesReady);
     2501                    if (!ASMAtomicXchgBool(&pThis->fNotificationSent, true))
    25022502                    {
    25032503                        /* Wake up the worker thread. */
    2504                         int rc2 = PDMDevHlpSUPSemEventSignal(pDevIns, pBusLogic->hEvtProcess);
     2504                        int rc2 = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtProcess);
    25052505                        AssertRC(rc2);
    25062506                    }
     
    25142514             * If not we initialize executing a new command.
    25152515             */
    2516             if (pBusLogic->uOperationCode == 0xff)
     2516            if (pThis->uOperationCode == 0xff)
    25172517            {
    2518                 pBusLogic->uOperationCode = uVal;
    2519                 pBusLogic->iParameter = 0;
     2518                pThis->uOperationCode = uVal;
     2519                pThis->iParameter = 0;
    25202520
    25212521                /* Mark host adapter as busy and clear the invalid status bit. */
    2522                 pBusLogic->regStatus &= ~(BL_STAT_HARDY | BL_STAT_CMDINV);
     2522                pThis->regStatus &= ~(BL_STAT_HARDY | BL_STAT_CMDINV);
    25232523
    25242524                /* Get the number of bytes for parameters from the command code. */
    2525                 switch (pBusLogic->uOperationCode)
     2525                switch (pThis->uOperationCode)
    25262526                {
    25272527                    case BUSLOGICCOMMAND_TEST_CMDC_INTERRUPT:
     
    25342534                    case BUSLOGICCOMMAND_INQUIRE_INSTALLED_DEVICES_ID_8_TO_15:
    25352535                    case BUSLOGICCOMMAND_INQUIRE_TARGET_DEVICES:
    2536                         pBusLogic->cbCommandParametersLeft = 0;
     2536                        pThis->cbCommandParametersLeft = 0;
    25372537                        break;
    25382538                    case BUSLOGICCOMMAND_MODIFY_IO_ADDRESS:
     
    25412541                    case BUSLOGICCOMMAND_INQUIRE_HOST_ADAPTER_MODEL_NUMBER:
    25422542                        /* These commands are not on AHA-154x, some Adaptec drivers (ASPI4DOS.SYS) test them. */
    2543                         if (pBusLogic->uDevType == DEV_AHA_1540B)
     2543                        if (pThis->uDevType == DEV_AHA_1540B)
    25442544                        {
    2545                             pBusLogic->cbCommandParametersLeft = 0;
     2545                            pThis->cbCommandParametersLeft = 0;
    25462546                            break;
    25472547                        }
     
    25562556                    case BUSLOGICCOMMAND_SET_TIME_OFF_BUS:
    25572557                    case BUSLOGICCOMMAND_SET_BUS_TRANSFER_RATE:
    2558                         pBusLogic->cbCommandParametersLeft = 1;
     2558                        pThis->cbCommandParametersLeft = 1;
    25592559                        break;
    25602560                    case BUSLOGICCOMMAND_FETCH_HOST_ADAPTER_LOCAL_RAM:
    2561                         pBusLogic->cbCommandParametersLeft = 2;
     2561                        pThis->cbCommandParametersLeft = 2;
    25622562                        break;
    25632563                    case BUSLOGICCOMMAND_READ_BUSMASTER_CHIP_FIFO:
    25642564                    case BUSLOGICCOMMAND_WRITE_BUSMASTER_CHIP_FIFO:
    2565                         pBusLogic->cbCommandParametersLeft = 3;
     2565                        pThis->cbCommandParametersLeft = 3;
    25662566                        break;
    25672567                    case BUSLOGICCOMMAND_SET_SCSI_SELECTION_TIMEOUT:
    2568                         pBusLogic->cbCommandParametersLeft = 4;
     2568                        pThis->cbCommandParametersLeft = 4;
    25692569                        break;
    25702570                    case BUSLOGICCOMMAND_INITIALIZE_MAILBOX:
    2571                         pBusLogic->cbCommandParametersLeft = sizeof(RequestInitMbx);
     2571                        pThis->cbCommandParametersLeft = sizeof(RequestInitMbx);
    25722572                        break;
    25732573                    case BUSLOGICCOMMAND_INITIALIZE_EXTENDED_MAILBOX:
    25742574                        /* Some Adaptec drivers (ASPI4DOS.SYS) test this command. */
    2575                         if (pBusLogic->uDevType == DEV_AHA_1540B)
     2575                        if (pThis->uDevType == DEV_AHA_1540B)
    25762576                        {
    2577                             pBusLogic->cbCommandParametersLeft = 0;
     2577                            pThis->cbCommandParametersLeft = 0;
    25782578                            break;
    25792579                        }
    2580                         pBusLogic->cbCommandParametersLeft = sizeof(RequestInitializeExtendedMailbox);
     2580                        pThis->cbCommandParametersLeft = sizeof(RequestInitializeExtendedMailbox);
    25812581                        break;
    25822582                    case BUSLOGICCOMMAND_SET_ADAPTER_OPTIONS:
    25832583                        /* There must be at least one byte following this command. */
    2584                         pBusLogic->cbCommandParametersLeft = 1;
     2584                        pThis->cbCommandParametersLeft = 1;
    25852585                        break;
    25862586                    case BUSLOGICCOMMAND_EXECUTE_SCSI_COMMAND:
    25872587                        /* 12 bytes + variable-length CDB. */
    2588                         pBusLogic->cbCommandParametersLeft = 12;
     2588                        pThis->cbCommandParametersLeft = 12;
    25892589                        break;
    25902590                    case BUSLOGICCOMMAND_EXT_BIOS_INFO:
    25912591                    case BUSLOGICCOMMAND_UNLOCK_MAILBOX:
    25922592                        /* Invalid commands. */
    2593                         pBusLogic->cbCommandParametersLeft = 0;
     2593                        pThis->cbCommandParametersLeft = 0;
    25942594                        break;
    25952595                    case BUSLOGICCOMMAND_EXECUTE_MAILBOX_COMMAND: /* Should not come here anymore. */
     
    26022602#ifndef IN_RING3
    26032603                /* This command must be executed in R3 as it rehooks the ISA I/O port. */
    2604                 if (pBusLogic->uOperationCode == BUSLOGICCOMMAND_MODIFY_IO_ADDRESS)
     2604                if (pThis->uOperationCode == BUSLOGICCOMMAND_MODIFY_IO_ADDRESS)
    26052605                {
    26062606                    rc = VINF_IOM_R3_IOPORT_WRITE;
     
    26142614                 * function.
    26152615                 */
    2616                 pBusLogic->aCommandBuffer[pBusLogic->iParameter] = uVal;
    2617                 pBusLogic->iParameter++;
    2618                 pBusLogic->cbCommandParametersLeft--;
     2616                pThis->aCommandBuffer[pThis->iParameter] = uVal;
     2617                pThis->iParameter++;
     2618                pThis->cbCommandParametersLeft--;
    26192619            }
    26202620
    26212621            /* Start execution of command if there are no parameters left. */
    2622             if (!pBusLogic->cbCommandParametersLeft)
     2622            if (!pThis->cbCommandParametersLeft)
    26232623            {
    2624                 rc = buslogicProcessCommand(pDevIns, pBusLogic);
     2624                rc = buslogicProcessCommand(pDevIns, pThis);
    26252625                AssertMsgRC(rc, ("Processing command failed rc=%Rrc\n", rc));
    26262626            }
     
    26322632         */
    26332633        case BUSLOGIC_REGISTER_INTERRUPT:
    2634             if (pBusLogic->uDevType == DEV_AHA_1540B)
     2634            if (pThis->uDevType == DEV_AHA_1540B)
    26352635                break;
    2636             pBusLogic->regInterrupt = uVal;
     2636            pThis->regInterrupt = uVal;
    26372637            break;
    26382638
    26392639        case BUSLOGIC_REGISTER_GEOMETRY:
    2640             if (pBusLogic->uDevType == DEV_AHA_1540B)
     2640            if (pThis->uDevType == DEV_AHA_1540B)
    26412641                break;
    2642             pBusLogic->regGeometry = uVal;
     2642            pThis->regGeometry = uVal;
    26432643            break;
    26442644
     
    26812681buslogicIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb)
    26822682{
    2683     PBUSLOGIC pBusLogic = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
     2683    PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
    26842684    unsigned iRegister = offPort % 4;
    26852685    RT_NOREF(pvUser, cb);
     
    26872687    ASSERT_GUEST(cb == 1);
    26882688
    2689     return buslogicRegisterRead(pDevIns, pBusLogic, iRegister, pu32);
     2689    return buslogicRegisterRead(pDevIns, pThis, iRegister, pu32);
    26902690}
    26912691
     
    26962696buslogicIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    26972697{
    2698     PBUSLOGIC pBusLogic = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
     2698    PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
    26992699    unsigned iRegister = offPort % 4;
    27002700    RT_NOREF(pvUser, cb);
     
    27022702    ASSERT_GUEST(cb == 1);
    27032703
    2704     int rc = buslogicRegisterWrite(pDevIns, pBusLogic, iRegister, (uint8_t)u32);
     2704    int rc = buslogicRegisterWrite(pDevIns, pThis, iRegister, (uint8_t)u32);
    27052705
    27062706    Log2(("#%d %s: pvUser=%#p cb=%d u32=%#x offPort=%#x rc=%Rrc\n",
     
    28772877 * @returns nothing.
    28782878 * @param   pDevIns         The device instance.
    2879  * @param   pBusLogic       Pointer to the shared BusLogic instance data.
     2879 * @param   pThis           Pointer to the shared BusLogic instance data.
    28802880 * @param   uBaseCode       Encoded ISA I/O base; only low 3 bits are used.
    28812881 */
    2882 static int buslogicR3RegisterISARange(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, uint8_t uBaseCode)
     2882static int buslogicR3RegisterISARange(PPDMDEVINS pDevIns, PBUSLOGIC pThis, uint8_t uBaseCode)
    28832883{
    28842884    uint8_t     uCode = uBaseCode & MAX_ISA_BASE;
     
    28892889
    28902890    /* Check if the same port range actually changed. */
    2891     if (uNewBase != pBusLogic->IOISABase)
     2891    if (uNewBase != pThis->IOISABase)
    28922892    {
    28932893        /* Unmap the old range, if necessary. */
    2894         if (pBusLogic->IOISABase)
    2895         {
    2896             rc = PDMDevHlpIoPortUnmap(pDevIns, pBusLogic->hIoPortsIsa);
     2894        if (pThis->IOISABase)
     2895        {
     2896            rc = PDMDevHlpIoPortUnmap(pDevIns, pThis->hIoPortsIsa);
    28972897            AssertRC(rc);
    28982898        }
    28992899        if (RT_SUCCESS(rc))
    29002900        {
    2901             pBusLogic->IOISABase = 0;   /* First mark as unregistered. */
    2902             pBusLogic->uISABaseCode = ISA_BASE_DISABLED;
     2901            pThis->IOISABase = 0;   /* First mark as unregistered. */
     2902            pThis->uISABaseCode = ISA_BASE_DISABLED;
    29032903
    29042904            if (uNewBase)
    29052905            {
    29062906                /* Register the new range if requested. */
    2907                 rc = PDMDevHlpIoPortMap(pDevIns, pBusLogic->hIoPortsIsa, uNewBase);
     2907                rc = PDMDevHlpIoPortMap(pDevIns, pThis->hIoPortsIsa, uNewBase);
    29082908                if (RT_SUCCESS(rc))
    29092909                {
    2910                     pBusLogic->IOISABase = uNewBase;
    2911                     pBusLogic->uISABaseCode = uCode;
     2910                    pThis->IOISABase = uNewBase;
     2911                    pThis->uISABaseCode = uCode;
    29122912                }
    29132913            }
     
    31343134}
    31353135
    3136 static int buslogicR3DeviceSCSIRequestSetup(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, PBUSLOGICCC pThisCC, RTGCPHYS GCPhysAddrCCB)
     3136static int buslogicR3DeviceSCSIRequestSetup(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PBUSLOGICCC pThisCC, RTGCPHYS GCPhysAddrCCB)
    31373137{
    31383138    int rc = VINF_SUCCESS;
     
    31453145                      &CCBGuest, sizeof(CCB32));
    31463146
    3147     uTargetIdCCB = pBusLogic->fMbxIs24Bit ? CCBGuest.o.uTargetId : CCBGuest.n.uTargetId;
     3147    uTargetIdCCB = pThis->fMbxIs24Bit ? CCBGuest.o.uTargetId : CCBGuest.n.uTargetId;
    31483148    if (RT_LIKELY(uTargetIdCCB < RT_ELEMENTS(pThisCC->aDeviceStates)))
    31493149    {
     
    31513151
    31523152#ifdef LOG_ENABLED
    3153         buslogicR3DumpCCBInfo(&CCBGuest, pBusLogic->fMbxIs24Bit);
     3153        buslogicR3DumpCCBInfo(&CCBGuest, pThis->fMbxIs24Bit);
    31543154#endif
    31553155
     
    31673167                pReq->fBIOS         = false;
    31683168                pReq->hIoReq        = hIoReq;
    3169                 pReq->fIs24Bit      = pBusLogic->fMbxIs24Bit;
     3169                pReq->fIs24Bit      = pThis->fMbxIs24Bit;
    31703170
    31713171                /* Make a copy of the CCB */
     
    31993199                                                               &pReq->u8ScsiSts, 30 * RT_MS_1SEC);
    32003200                if (rc != VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS)
    3201                     buslogicR3ReqComplete(pDevIns, pBusLogic, pThisCC, pReq, rc);
     3201                    buslogicR3ReqComplete(pDevIns, pThis, pThisCC, pReq, rc);
    32023202            }
    32033203            else
    3204                 buslogicR3SendIncomingMailbox(pDevIns, pBusLogic, GCPhysAddrCCB, &CCBGuest,
     3204                buslogicR3SendIncomingMailbox(pDevIns, pThis, GCPhysAddrCCB, &CCBGuest,
    32053205                                              BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_SCSI_SELECTION_TIMEOUT,
    32063206                                              BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD,
     
    32083208        }
    32093209        else
    3210             buslogicR3SendIncomingMailbox(pDevIns, pBusLogic, GCPhysAddrCCB, &CCBGuest,
     3210            buslogicR3SendIncomingMailbox(pDevIns, pThis, GCPhysAddrCCB, &CCBGuest,
    32113211                                          BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_SCSI_SELECTION_TIMEOUT,
    32123212                                          BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD,
     
    32143214    }
    32153215    else
    3216         buslogicR3SendIncomingMailbox(pDevIns, pBusLogic, GCPhysAddrCCB, &CCBGuest,
     3216        buslogicR3SendIncomingMailbox(pDevIns, pThis, GCPhysAddrCCB, &CCBGuest,
    32173217                                      BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_INVALID_COMMAND_PARAMETER,
    32183218                                      BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD,
     
    32223222}
    32233223
    3224 static int buslogicR3DeviceSCSIRequestAbort(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, RTGCPHYS GCPhysAddrCCB)
     3224static int buslogicR3DeviceSCSIRequestAbort(PPDMDEVINS pDevIns, PBUSLOGIC pThis, RTGCPHYS GCPhysAddrCCB)
    32253225{
    32263226    uint8_t  uTargetIdCCB;
     
    32303230                      &CCBGuest, sizeof(CCB32));
    32313231
    3232     uTargetIdCCB = pBusLogic->fMbxIs24Bit ? CCBGuest.o.uTargetId : CCBGuest.n.uTargetId;
    3233     if (RT_LIKELY(uTargetIdCCB < RT_ELEMENTS(pBusLogic->afDevicePresent)))
    3234         buslogicR3SendIncomingMailbox(pDevIns, pBusLogic, GCPhysAddrCCB, &CCBGuest,
     3232    uTargetIdCCB = pThis->fMbxIs24Bit ? CCBGuest.o.uTargetId : CCBGuest.n.uTargetId;
     3233    if (RT_LIKELY(uTargetIdCCB < RT_ELEMENTS(pThis->afDevicePresent)))
     3234        buslogicR3SendIncomingMailbox(pDevIns, pThis, GCPhysAddrCCB, &CCBGuest,
    32353235                                      BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_ABORT_QUEUE_GENERATED,
    32363236                                      BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD,
    32373237                                      BUSLOGIC_MAILBOX_INCOMING_COMPLETION_ABORTED_NOT_FOUND);
    32383238    else
    3239         buslogicR3SendIncomingMailbox(pDevIns, pBusLogic, GCPhysAddrCCB, &CCBGuest,
     3239        buslogicR3SendIncomingMailbox(pDevIns, pThis, GCPhysAddrCCB, &CCBGuest,
    32403240                                      BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_INVALID_COMMAND_PARAMETER,
    32413241                                      BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD,
     
    32503250 *
    32513251 * @returns Mailbox guest physical address.
    3252  * @param   pDevIns      The device instance.
    3253  * @param   pBusLogic    Pointer to the shared BusLogic instance data.
    3254  * @param   pMbx         Pointer to the mailbox to read into.
    3255  */
    3256 static RTGCPHYS buslogicR3ReadOutgoingMailbox(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, PMailbox32 pMbx)
     3252 * @param   pDevIns     The device instance.
     3253 * @param   pThis       Pointer to the shared BusLogic instance data.
     3254 * @param   pMbx        Pointer to the mailbox to read into.
     3255 */
     3256static RTGCPHYS buslogicR3ReadOutgoingMailbox(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PMailbox32 pMbx)
    32573257{
    32583258    RTGCPHYS    GCMailbox;
    32593259
    3260     if (pBusLogic->fMbxIs24Bit)
     3260    if (pThis->fMbxIs24Bit)
    32613261    {
    32623262        Mailbox24   Mbx24;
    32633263
    3264         GCMailbox = pBusLogic->GCPhysAddrMailboxOutgoingBase + (pBusLogic->uMailboxOutgoingPositionCurrent * sizeof(Mailbox24));
     3264        GCMailbox = pThis->GCPhysAddrMailboxOutgoingBase + (pThis->uMailboxOutgoingPositionCurrent * sizeof(Mailbox24));
    32653265        PDMDevHlpPhysRead(pDevIns, GCMailbox, &Mbx24, sizeof(Mailbox24));
    32663266        pMbx->u32PhysAddrCCB    = ADDR_TO_U32(Mbx24.aPhysAddrCCB);
     
    32693269    else
    32703270    {
    3271         GCMailbox = pBusLogic->GCPhysAddrMailboxOutgoingBase + (pBusLogic->uMailboxOutgoingPositionCurrent * sizeof(Mailbox32));
     3271        GCMailbox = pThis->GCPhysAddrMailboxOutgoingBase + (pThis->uMailboxOutgoingPositionCurrent * sizeof(Mailbox32));
    32723272        PDMDevHlpPhysRead(pDevIns, GCMailbox, pMbx, sizeof(Mailbox32));
    32733273    }
     
    32803280 *
    32813281 * @returns VBox status code.
    3282  * @param   pDevIns         The device instance.
    3283  * @param   pBusLogic       Pointer to the shared BusLogic instance data.
    3284  * @param   pThisCC         Pointer to the ring-3 BusLogic instance data.
    3285  */
    3286 static int buslogicR3ProcessMailboxNext(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, PBUSLOGICCC pThisCC)
     3282 * @param   pDevIns     The device instance.
     3283 * @param   pThis       Pointer to the shared BusLogic instance data.
     3284 * @param   pThisCC     Pointer to the ring-3 BusLogic instance data.
     3285 */
     3286static int buslogicR3ProcessMailboxNext(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PBUSLOGICCC pThisCC)
    32873287{
    32883288    RTGCPHYS     GCPhysAddrMailboxCurrent;
     
    32903290    int rc = VINF_SUCCESS;
    32913291
    3292     if (!pBusLogic->fStrictRoundRobinMode)
     3292    if (!pThis->fStrictRoundRobinMode)
    32933293    {
    32943294        /* Search for a filled mailbox - stop if we have scanned all mailboxes. */
    3295         uint8_t uMailboxPosCur = pBusLogic->uMailboxOutgoingPositionCurrent;
     3295        uint8_t uMailboxPosCur = pThis->uMailboxOutgoingPositionCurrent;
    32963296
    32973297        do
    32983298        {
    32993299            /* Fetch mailbox from guest memory. */
    3300             GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pDevIns, pBusLogic, &MailboxGuest);
     3300            GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pDevIns, pThis, &MailboxGuest);
    33013301
    33023302            /* Check the next mailbox. */
    3303             buslogicR3OutgoingMailboxAdvance(pBusLogic);
     3303            buslogicR3OutgoingMailboxAdvance(pThis);
    33043304        } while (   MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_FREE
    3305                  && uMailboxPosCur != pBusLogic->uMailboxOutgoingPositionCurrent);
     3305                 && uMailboxPosCur != pThis->uMailboxOutgoingPositionCurrent);
    33063306    }
    33073307    else
    33083308    {
    33093309        /* Fetch mailbox from guest memory. */
    3310         GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pDevIns, pBusLogic, &MailboxGuest);
     3310        GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pDevIns, pThis, &MailboxGuest);
    33113311    }
    33123312
     
    33233323    }
    33243324
    3325     LogFlow(("Got loaded mailbox at slot %u, CCB phys %RGp\n", pBusLogic->uMailboxOutgoingPositionCurrent, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB));
     3325    LogFlow(("Got loaded mailbox at slot %u, CCB phys %RGp\n", pThis->uMailboxOutgoingPositionCurrent, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB));
    33263326#ifdef LOG_ENABLED
    33273327    buslogicR3DumpMailboxInfo(&MailboxGuest, true);
     
    33303330    /* We got the mailbox, mark it as free in the guest. */
    33313331    uint8_t uActionCode = BUSLOGIC_MAILBOX_OUTGOING_ACTION_FREE;
    3332     unsigned uCodeOffs = pBusLogic->fMbxIs24Bit ? RT_OFFSETOF(Mailbox24, uCmdState) : RT_OFFSETOF(Mailbox32, u.out.uActionCode);
    3333     blPhysWrite(pDevIns, pBusLogic, GCPhysAddrMailboxCurrent + uCodeOffs, &uActionCode, sizeof(uActionCode));
     3332    unsigned uCodeOffs = pThis->fMbxIs24Bit ? RT_OFFSETOF(Mailbox24, uCmdState) : RT_OFFSETOF(Mailbox32, u.out.uActionCode);
     3333    blPhysWrite(pDevIns, pThis, GCPhysAddrMailboxCurrent + uCodeOffs, &uActionCode, sizeof(uActionCode));
    33343334
    33353335    if (MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_START_COMMAND)
    3336         rc = buslogicR3DeviceSCSIRequestSetup(pDevIns, pBusLogic, pThisCC, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB);
     3336        rc = buslogicR3DeviceSCSIRequestSetup(pDevIns, pThis, pThisCC, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB);
    33373337    else if (MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_ABORT_COMMAND)
    33383338    {
    33393339        LogFlow(("Aborting mailbox\n"));
    3340         rc = buslogicR3DeviceSCSIRequestAbort(pDevIns, pBusLogic, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB);
     3340        rc = buslogicR3DeviceSCSIRequestAbort(pDevIns, pThis, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB);
    33413341    }
    33423342    else
     
    33463346
    33473347    /* Advance to the next mailbox. */
    3348     if (pBusLogic->fStrictRoundRobinMode)
    3349         buslogicR3OutgoingMailboxAdvance(pBusLogic);
     3348    if (pThis->fStrictRoundRobinMode)
     3349        buslogicR3OutgoingMailboxAdvance(pThis);
    33503350
    33513351    return rc;
     
    33693369static DECLCALLBACK(int) buslogicR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    33703370{
    3371     PBUSLOGIC       pBusLogic      = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
     3371    PBUSLOGIC       pThis      = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
    33723372    PBUSLOGICCC     pThisCC        = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC);
    33733373    PCPDMDEVHLPR3   pHlp           = pDevIns->pHlpR3;
     
    33883388    }
    33893389    /* Now the main device state. */
    3390     pHlp->pfnSSMPutU8    (pSSM, pBusLogic->regStatus);
    3391     pHlp->pfnSSMPutU8    (pSSM, pBusLogic->regInterrupt);
    3392     pHlp->pfnSSMPutU8    (pSSM, pBusLogic->regGeometry);
    3393     pHlp->pfnSSMPutMem   (pSSM, &pBusLogic->LocalRam, sizeof(pBusLogic->LocalRam));
    3394     pHlp->pfnSSMPutU8    (pSSM, pBusLogic->uOperationCode);
    3395     pHlp->pfnSSMPutMem   (pSSM, &pBusLogic->aCommandBuffer, sizeof(pBusLogic->aCommandBuffer));
    3396     pHlp->pfnSSMPutU8    (pSSM, pBusLogic->iParameter);
    3397     pHlp->pfnSSMPutU8    (pSSM, pBusLogic->cbCommandParametersLeft);
    3398     pHlp->pfnSSMPutBool  (pSSM, pBusLogic->fUseLocalRam);
    3399     pHlp->pfnSSMPutMem   (pSSM, pBusLogic->aReplyBuffer, sizeof(pBusLogic->aReplyBuffer));
    3400     pHlp->pfnSSMPutU8    (pSSM, pBusLogic->iReply);
    3401     pHlp->pfnSSMPutU8    (pSSM, pBusLogic->cbReplyParametersLeft);
    3402     pHlp->pfnSSMPutBool  (pSSM, pBusLogic->fIRQEnabled);
    3403     pHlp->pfnSSMPutU8    (pSSM, pBusLogic->uISABaseCode);
    3404     pHlp->pfnSSMPutU32   (pSSM, pBusLogic->cMailbox);
    3405     pHlp->pfnSSMPutBool  (pSSM, pBusLogic->fMbxIs24Bit);
    3406     pHlp->pfnSSMPutGCPhys(pSSM, pBusLogic->GCPhysAddrMailboxOutgoingBase);
    3407     pHlp->pfnSSMPutU32   (pSSM, pBusLogic->uMailboxOutgoingPositionCurrent);
    3408     pHlp->pfnSSMPutU32   (pSSM, pBusLogic->cMailboxesReady);
    3409     pHlp->pfnSSMPutBool  (pSSM, pBusLogic->fNotificationSent);
    3410     pHlp->pfnSSMPutGCPhys(pSSM, pBusLogic->GCPhysAddrMailboxIncomingBase);
    3411     pHlp->pfnSSMPutU32   (pSSM, pBusLogic->uMailboxIncomingPositionCurrent);
    3412     pHlp->pfnSSMPutBool  (pSSM, pBusLogic->fStrictRoundRobinMode);
    3413     pHlp->pfnSSMPutBool  (pSSM, pBusLogic->fExtendedLunCCBFormat);
     3390    pHlp->pfnSSMPutU8    (pSSM, pThis->regStatus);
     3391    pHlp->pfnSSMPutU8    (pSSM, pThis->regInterrupt);
     3392    pHlp->pfnSSMPutU8    (pSSM, pThis->regGeometry);
     3393    pHlp->pfnSSMPutMem   (pSSM, &pThis->LocalRam, sizeof(pThis->LocalRam));
     3394    pHlp->pfnSSMPutU8    (pSSM, pThis->uOperationCode);
     3395    pHlp->pfnSSMPutMem   (pSSM, &pThis->aCommandBuffer, sizeof(pThis->aCommandBuffer));
     3396    pHlp->pfnSSMPutU8    (pSSM, pThis->iParameter);
     3397    pHlp->pfnSSMPutU8    (pSSM, pThis->cbCommandParametersLeft);
     3398    pHlp->pfnSSMPutBool  (pSSM, pThis->fUseLocalRam);
     3399    pHlp->pfnSSMPutMem   (pSSM, pThis->aReplyBuffer, sizeof(pThis->aReplyBuffer));
     3400    pHlp->pfnSSMPutU8    (pSSM, pThis->iReply);
     3401    pHlp->pfnSSMPutU8    (pSSM, pThis->cbReplyParametersLeft);
     3402    pHlp->pfnSSMPutBool  (pSSM, pThis->fIRQEnabled);
     3403    pHlp->pfnSSMPutU8    (pSSM, pThis->uISABaseCode);
     3404    pHlp->pfnSSMPutU32   (pSSM, pThis->cMailbox);
     3405    pHlp->pfnSSMPutBool  (pSSM, pThis->fMbxIs24Bit);
     3406    pHlp->pfnSSMPutGCPhys(pSSM, pThis->GCPhysAddrMailboxOutgoingBase);
     3407    pHlp->pfnSSMPutU32   (pSSM, pThis->uMailboxOutgoingPositionCurrent);
     3408    pHlp->pfnSSMPutU32   (pSSM, pThis->cMailboxesReady);
     3409    pHlp->pfnSSMPutBool  (pSSM, pThis->fNotificationSent);
     3410    pHlp->pfnSSMPutGCPhys(pSSM, pThis->GCPhysAddrMailboxIncomingBase);
     3411    pHlp->pfnSSMPutU32   (pSSM, pThis->uMailboxIncomingPositionCurrent);
     3412    pHlp->pfnSSMPutBool  (pSSM, pThis->fStrictRoundRobinMode);
     3413    pHlp->pfnSSMPutBool  (pSSM, pThis->fExtendedLunCCBFormat);
    34143414
    34153415    vboxscsiR3SaveExec(pDevIns->pHlpR3, &pThisCC->VBoxSCSI, pSSM);
     
    34893489static DECLCALLBACK(int) buslogicR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    34903490{
    3491     PBUSLOGIC       pBusLogic = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
    3492     PBUSLOGICCC     pThisCC   = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC);
    3493     PCPDMDEVHLPR3   pHlp      = pDevIns->pHlpR3;
    3494     int             rc        = VINF_SUCCESS;
     3491    PBUSLOGIC       pThis  = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
     3492    PBUSLOGICCC     pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC);
     3493    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
     3494    int             rc      = VINF_SUCCESS;
    34953495
    34963496    /* We support saved states only from this and older versions. */
     
    35193519
    35203520    /* Now the main device state. */
    3521     pHlp->pfnSSMGetU8V   (pSSM, &pBusLogic->regStatus);
    3522     pHlp->pfnSSMGetU8V   (pSSM, &pBusLogic->regInterrupt);
    3523     pHlp->pfnSSMGetU8V   (pSSM, &pBusLogic->regGeometry);
    3524     pHlp->pfnSSMGetMem   (pSSM, &pBusLogic->LocalRam, sizeof(pBusLogic->LocalRam));
    3525     pHlp->pfnSSMGetU8    (pSSM, &pBusLogic->uOperationCode);
     3521    pHlp->pfnSSMGetU8V   (pSSM, &pThis->regStatus);
     3522    pHlp->pfnSSMGetU8V   (pSSM, &pThis->regInterrupt);
     3523    pHlp->pfnSSMGetU8V   (pSSM, &pThis->regGeometry);
     3524    pHlp->pfnSSMGetMem   (pSSM, &pThis->LocalRam, sizeof(pThis->LocalRam));
     3525    pHlp->pfnSSMGetU8    (pSSM, &pThis->uOperationCode);
    35263526    if (uVersion > BUSLOGIC_SAVED_STATE_MINOR_PRE_CMDBUF_RESIZE)
    3527         pHlp->pfnSSMGetMem(pSSM, &pBusLogic->aCommandBuffer, sizeof(pBusLogic->aCommandBuffer));
     3527        pHlp->pfnSSMGetMem(pSSM, &pThis->aCommandBuffer, sizeof(pThis->aCommandBuffer));
    35283528    else
    3529         pHlp->pfnSSMGetMem(pSSM, &pBusLogic->aCommandBuffer, BUSLOGIC_COMMAND_SIZE_OLD);
    3530     pHlp->pfnSSMGetU8    (pSSM, &pBusLogic->iParameter);
    3531     pHlp->pfnSSMGetU8    (pSSM, &pBusLogic->cbCommandParametersLeft);
    3532     pHlp->pfnSSMGetBool  (pSSM, &pBusLogic->fUseLocalRam);
    3533     pHlp->pfnSSMGetMem   (pSSM, pBusLogic->aReplyBuffer, sizeof(pBusLogic->aReplyBuffer));
    3534     pHlp->pfnSSMGetU8    (pSSM, &pBusLogic->iReply);
    3535     pHlp->pfnSSMGetU8    (pSSM, &pBusLogic->cbReplyParametersLeft);
    3536     pHlp->pfnSSMGetBool  (pSSM, &pBusLogic->fIRQEnabled);
    3537     pHlp->pfnSSMGetU8    (pSSM, &pBusLogic->uISABaseCode);
    3538     pHlp->pfnSSMGetU32   (pSSM, &pBusLogic->cMailbox);
     3529        pHlp->pfnSSMGetMem(pSSM, &pThis->aCommandBuffer, BUSLOGIC_COMMAND_SIZE_OLD);
     3530    pHlp->pfnSSMGetU8    (pSSM, &pThis->iParameter);
     3531    pHlp->pfnSSMGetU8    (pSSM, &pThis->cbCommandParametersLeft);
     3532    pHlp->pfnSSMGetBool  (pSSM, &pThis->fUseLocalRam);
     3533    pHlp->pfnSSMGetMem   (pSSM, pThis->aReplyBuffer, sizeof(pThis->aReplyBuffer));
     3534    pHlp->pfnSSMGetU8    (pSSM, &pThis->iReply);
     3535    pHlp->pfnSSMGetU8    (pSSM, &pThis->cbReplyParametersLeft);
     3536    pHlp->pfnSSMGetBool  (pSSM, &pThis->fIRQEnabled);
     3537    pHlp->pfnSSMGetU8    (pSSM, &pThis->uISABaseCode);
     3538    pHlp->pfnSSMGetU32   (pSSM, &pThis->cMailbox);
    35393539    if (uVersion > BUSLOGIC_SAVED_STATE_MINOR_PRE_24BIT_MBOX)
    3540         pHlp->pfnSSMGetBool(pSSM, &pBusLogic->fMbxIs24Bit);
    3541     pHlp->pfnSSMGetGCPhys(pSSM, &pBusLogic->GCPhysAddrMailboxOutgoingBase);
    3542     pHlp->pfnSSMGetU32   (pSSM, &pBusLogic->uMailboxOutgoingPositionCurrent);
    3543     pHlp->pfnSSMGetU32V  (pSSM, &pBusLogic->cMailboxesReady);
    3544     pHlp->pfnSSMGetBoolV (pSSM, &pBusLogic->fNotificationSent);
    3545     pHlp->pfnSSMGetGCPhys(pSSM, &pBusLogic->GCPhysAddrMailboxIncomingBase);
    3546     pHlp->pfnSSMGetU32   (pSSM, &pBusLogic->uMailboxIncomingPositionCurrent);
    3547     pHlp->pfnSSMGetBool  (pSSM, &pBusLogic->fStrictRoundRobinMode);
    3548     pHlp->pfnSSMGetBool  (pSSM, &pBusLogic->fExtendedLunCCBFormat);
     3540        pHlp->pfnSSMGetBool(pSSM, &pThis->fMbxIs24Bit);
     3541    pHlp->pfnSSMGetGCPhys(pSSM, &pThis->GCPhysAddrMailboxOutgoingBase);
     3542    pHlp->pfnSSMGetU32   (pSSM, &pThis->uMailboxOutgoingPositionCurrent);
     3543    pHlp->pfnSSMGetU32V  (pSSM, &pThis->cMailboxesReady);
     3544    pHlp->pfnSSMGetBoolV (pSSM, &pThis->fNotificationSent);
     3545    pHlp->pfnSSMGetGCPhys(pSSM, &pThis->GCPhysAddrMailboxIncomingBase);
     3546    pHlp->pfnSSMGetU32   (pSSM, &pThis->uMailboxIncomingPositionCurrent);
     3547    pHlp->pfnSSMGetBool  (pSSM, &pThis->fStrictRoundRobinMode);
     3548    pHlp->pfnSSMGetBool  (pSSM, &pThis->fExtendedLunCCBFormat);
    35493549
    35503550    rc = vboxscsiR3LoadExec(pDevIns->pHlpR3, &pThisCC->VBoxSCSI, pSSM);
     
    40804080{
    40814081    PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
    4082     PBUSLOGIC  pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
     4082    PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);
    40834083
    40844084    PDMDevHlpCritSectDelete(pDevIns, &pThis->CritSectIntr);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette