Changeset 81835 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- Nov 13, 2019 4:51:59 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevBusLogic.cpp
r81833 r81835 1006 1006 * @returns nothing. 1007 1007 * @param pDevIns The device instance. 1008 * @param pThis The BusLogic controller instance.1008 * @param pThis Pointer to the shared BusLogic instance data. 1009 1009 * @param GCPhys The guest physical address of the memory buffer. 1010 1010 * @param pSgBuf The pointer to the host R3 S/G buffer. … … 1029 1029 *********************************************************************************************************************************/ 1030 1030 #ifdef IN_RING3 1031 static int buslogicR3RegisterISARange(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, uint8_t uBaseCode);1031 static int buslogicR3RegisterISARange(PPDMDEVINS pDevIns, PBUSLOGIC pThis, uint8_t uBaseCode); 1032 1032 #endif 1033 1033 … … 1038 1038 * @returns nothing. 1039 1039 * @param pDevIns The device instance. 1040 * @param p BusLogicPointer to the shared BusLogic instance data.1040 * @param pThis Pointer to the shared BusLogic instance data. 1041 1041 * @param fSuppressIrq Flag to suppress IRQ generation regardless of fIRQEnabled 1042 1042 * @param uIrqType Type of interrupt being generated. 1043 1043 */ 1044 static void buslogicSetInterrupt(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, bool fSuppressIrq, uint8_t uIrqType)1045 { 1046 LogFlowFunc(("p BusLogic=%#p\n", pBusLogic));1044 static void buslogicSetInterrupt(PPDMDEVINS pDevIns, PBUSLOGIC pThis, bool fSuppressIrq, uint8_t uIrqType) 1045 { 1046 LogFlowFunc(("pThis=%#p\n", pThis)); 1047 1047 1048 1048 /* The CMDC interrupt has priority over IMBL and OMBR. */ 1049 1049 if (uIrqType & (BL_INTR_IMBL | BL_INTR_OMBR)) 1050 1050 { 1051 if (!(p BusLogic->regInterrupt & BL_INTR_CMDC))1052 p BusLogic->regInterrupt |= uIrqType; /* Report now. */1051 if (!(pThis->regInterrupt & BL_INTR_CMDC)) 1052 pThis->regInterrupt |= uIrqType; /* Report now. */ 1053 1053 else 1054 p BusLogic->uPendingIntr |= uIrqType; /* Report later. */1054 pThis->uPendingIntr |= uIrqType; /* Report later. */ 1055 1055 } 1056 1056 else if (uIrqType & BL_INTR_CMDC) 1057 1057 { 1058 AssertMsg(p BusLogic->regInterrupt == 0 || pBusLogic->regInterrupt == (BL_INTR_INTV | BL_INTR_CMDC),1059 ("regInterrupt=%02X\n", p BusLogic->regInterrupt));1060 p BusLogic->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; 1061 1061 } 1062 1062 else 1063 1063 AssertMsgFailed(("Invalid interrupt state!\n")); 1064 1064 1065 p BusLogic->regInterrupt |= BL_INTR_INTV;1066 if (p BusLogic->fIRQEnabled && !fSuppressIrq)1067 { 1068 if (!p BusLogic->uIsaIrq)1065 pThis->regInterrupt |= BL_INTR_INTV; 1066 if (pThis->fIRQEnabled && !fSuppressIrq) 1067 { 1068 if (!pThis->uIsaIrq) 1069 1069 PDMDevHlpPCISetIrq(pDevIns, 0, 1); 1070 1070 else 1071 PDMDevHlpISASetIrq(pDevIns, p BusLogic->uIsaIrq, 1);1071 PDMDevHlpISASetIrq(pDevIns, pThis->uIsaIrq, 1); 1072 1072 } 1073 1073 } … … 1077 1077 * 1078 1078 * @returns nothing. 1079 * @param pDevIns 1080 * @param p BusLogicPointer to the shared BusLogic instance data.1081 */ 1082 static void buslogicClearInterrupt(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic)1083 { 1084 LogFlowFunc(("p BusLogic=%#p, clearing %#02x (pending %#02x)\n",1085 p BusLogic, pBusLogic->regInterrupt, pBusLogic->uPendingIntr));1086 p BusLogic->regInterrupt = 0;1087 p BusLogic->regStatus &= ~BL_STAT_CMDINV;1088 if (!p BusLogic->uIsaIrq)1079 * @param pDevIns The device instance. 1080 * @param pThis Pointer to the shared BusLogic instance data. 1081 */ 1082 static 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) 1089 1089 PDMDevHlpPCISetIrq(pDevIns, 0, 0); 1090 1090 else 1091 PDMDevHlpISASetIrq(pDevIns, p BusLogic->uIsaIrq, 0);1091 PDMDevHlpISASetIrq(pDevIns, pThis->uIsaIrq, 0); 1092 1092 /* If there's another pending interrupt, report it now. */ 1093 if (p BusLogic->uPendingIntr)1094 { 1095 buslogicSetInterrupt(pDevIns, p BusLogic, false, pBusLogic->uPendingIntr);1096 p BusLogic->uPendingIntr = 0;1093 if (pThis->uPendingIntr) 1094 { 1095 buslogicSetInterrupt(pDevIns, pThis, false, pThis->uPendingIntr); 1096 pThis->uPendingIntr = 0; 1097 1097 } 1098 1098 } … … 1104 1104 * 1105 1105 * @returns nothing. 1106 * @param p BusLogic The BusLogic controller instance.1107 */ 1108 DECLINLINE(void) buslogicR3OutgoingMailboxAdvance(PBUSLOGIC p BusLogic)1109 { 1110 p BusLogic->uMailboxOutgoingPositionCurrent = (pBusLogic->uMailboxOutgoingPositionCurrent + 1) % pBusLogic->cMailbox;1106 * @param pThis Pointer to the shared BusLogic instance data. 1107 */ 1108 DECLINLINE(void) buslogicR3OutgoingMailboxAdvance(PBUSLOGIC pThis) 1109 { 1110 pThis->uMailboxOutgoingPositionCurrent = (pThis->uMailboxOutgoingPositionCurrent + 1) % pThis->cMailbox; 1111 1111 } 1112 1112 … … 1115 1115 * 1116 1116 * @returns nothing. 1117 * @param p BusLogic The BusLogic controller instance.1118 */ 1119 static void buslogicR3InitializeLocalRam(PBUSLOGIC p BusLogic)1117 * @param pThis Pointer to the shared BusLogic instance data. 1118 */ 1119 static void buslogicR3InitializeLocalRam(PBUSLOGIC pThis) 1120 1120 { 1121 1121 /* … … 1126 1126 * So they don't have to be right :) 1127 1127 */ 1128 memset(p BusLogic->LocalRam.u8View, 0, sizeof(HostAdapterLocalRam));1129 p BusLogic->LocalRam.structured.autoSCSIData.fLevelSensitiveInterrupt = true;1130 p BusLogic->LocalRam.structured.autoSCSIData.fParityCheckingEnabled = true;1131 p BusLogic->LocalRam.structured.autoSCSIData.fExtendedTranslation = true; /* Same as in geometry register. */1132 p BusLogic->LocalRam.structured.autoSCSIData.u16DeviceEnabledMask = UINT16_MAX; /* All enabled. Maybe mask out non present devices? */1133 p BusLogic->LocalRam.structured.autoSCSIData.u16WidePermittedMask = UINT16_MAX;1134 p BusLogic->LocalRam.structured.autoSCSIData.u16FastPermittedMask = UINT16_MAX;1135 p BusLogic->LocalRam.structured.autoSCSIData.u16SynchronousPermittedMask = UINT16_MAX;1136 p BusLogic->LocalRam.structured.autoSCSIData.u16DisconnectPermittedMask = UINT16_MAX;1137 p BusLogic->LocalRam.structured.autoSCSIData.fStrictRoundRobinMode = pBusLogic->fStrictRoundRobinMode;1138 p BusLogic->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; 1139 1139 /** @todo calculate checksum? */ 1140 1140 } … … 1145 1145 * @returns VBox status code. 1146 1146 * @param pDevIns The device instance. 1147 * @param p BusLogicPointer to the shared BusLogic instance data.1147 * @param pThis Pointer to the shared BusLogic instance data. 1148 1148 * @param pThisCC Pointer to the ring-3 BusLogic instance data. 1149 1149 * @param fResetIO Flag determining whether ISA I/O should be reset. 1150 1150 */ 1151 static int buslogicR3HwReset(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, PBUSLOGICCC pThisCC, bool fResetIO)1152 { 1153 LogFlowFunc(("p BusLogic=%#p\n", pBusLogic));1151 static int buslogicR3HwReset(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PBUSLOGICCC pThisCC, bool fResetIO) 1152 { 1153 LogFlowFunc(("pThis=%#p\n", pThis)); 1154 1154 1155 1155 /* Reset registers to default values. */ 1156 p BusLogic->regStatus = BL_STAT_HARDY | BL_STAT_INREQ;1157 p BusLogic->regGeometry = BL_GEOM_XLATEN;1158 p BusLogic->uOperationCode = 0xff; /* No command executing. */1159 p BusLogic->iParameter = 0;1160 p BusLogic->cbCommandParametersLeft = 0;1161 p BusLogic->fIRQEnabled = true;1162 p BusLogic->fStrictRoundRobinMode = false;1163 p BusLogic->fExtendedLunCCBFormat = false;1164 p BusLogic->uMailboxOutgoingPositionCurrent = 0;1165 p BusLogic->uMailboxIncomingPositionCurrent = 0;1166 p BusLogic->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; 1167 1167 1168 1168 /* Clear any active/pending interrupts. */ 1169 p BusLogic->uPendingIntr = 0;1170 buslogicClearInterrupt(pDevIns, p BusLogic);1169 pThis->uPendingIntr = 0; 1170 buslogicClearInterrupt(pDevIns, pThis); 1171 1171 1172 1172 /* Guest-initiated HBA reset does not affect ISA port I/O. */ 1173 1173 if (fResetIO) 1174 buslogicR3RegisterISARange(pDevIns, p BusLogic, pBusLogic->uDefaultISABaseCode);1175 buslogicR3InitializeLocalRam(p BusLogic);1174 buslogicR3RegisterISARange(pDevIns, pThis, pThis->uDefaultISABaseCode); 1175 buslogicR3InitializeLocalRam(pThis); 1176 1176 vboxscsiInitialize(&pThisCC->VBoxSCSI); 1177 1177 … … 1186 1186 * @returns nothing. 1187 1187 * @param pDevIns The device instance. 1188 * @param p BusLogicPointer to the shared BusLogic instance data.1188 * @param pThis Pointer to the shared BusLogic instance data. 1189 1189 * @param fSuppressIrq Flag to suppress IRQ generation regardless of current state 1190 1190 */ 1191 static void buslogicCommandComplete(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, bool fSuppressIrq)1192 { 1193 LogFlowFunc(("p BusLogic=%#p\n", pBusLogic));1194 Assert(p BusLogic->uOperationCode != BUSLOGICCOMMAND_EXECUTE_MAILBOX_COMMAND);1195 1196 p BusLogic->fUseLocalRam = false;1197 p BusLogic->regStatus |= BL_STAT_HARDY;1198 p BusLogic->iReply = 0;1191 static 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; 1199 1199 1200 1200 /* The Enable OMBR command does not set CMDC when successful. */ 1201 if (p BusLogic->uOperationCode != BUSLOGICCOMMAND_ENABLE_OUTGOING_MAILBOX_AVAILABLE_INTERRUPT)1201 if (pThis->uOperationCode != BUSLOGICCOMMAND_ENABLE_OUTGOING_MAILBOX_AVAILABLE_INTERRUPT) 1202 1202 { 1203 1203 /* Notify that the command is complete. */ 1204 p BusLogic->regStatus &= ~BL_STAT_DIRRDY;1205 buslogicSetInterrupt(pDevIns, p BusLogic, fSuppressIrq, BL_INTR_CMDC);1206 } 1207 1208 p BusLogic->uOperationCode = 0xff;1209 p BusLogic->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; 1210 1210 } 1211 1211 … … 1235 1235 * @returns nothing 1236 1236 * @param pDevIns The device instance. 1237 * @param p BusLogicPointer to the shared BusLogic instance data.1237 * @param pThis Pointer to the shared BusLogic instance data. 1238 1238 * @param pThisCC Pointer to the ring-3 BusLogic instance data. 1239 1239 * @param fHardReset Flag initiating a hard (vs. soft) reset. 1240 1240 */ 1241 static void buslogicR3InitiateReset(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, PBUSLOGICCC pThisCC, bool fHardReset)1242 { 1243 LogFlowFunc(("p BusLogic=%#p fHardReset=%d\n", pBusLogic, fHardReset));1244 1245 buslogicR3HwReset(pDevIns, p BusLogic, pThisCC, false);1241 static 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); 1246 1246 1247 1247 if (fHardReset) 1248 1248 { 1249 1249 /* Set the diagnostic active bit in the status register and clear the ready state. */ 1250 p BusLogic->regStatus |= BL_STAT_DACT;1251 p BusLogic->regStatus &= ~BL_STAT_HARDY;1250 pThis->regStatus |= BL_STAT_DACT; 1251 pThis->regStatus &= ~BL_STAT_HARDY; 1252 1252 1253 1253 /* Remember when the guest initiated a reset (after we're done resetting). */ 1254 p BusLogic->u64ResetTime = PDMDevHlpTMTimeVirtGetNano(pDevIns);1254 pThis->u64ResetTime = PDMDevHlpTMTimeVirtGetNano(pDevIns); 1255 1255 } 1256 1256 } … … 1262 1262 * @returns nothing. 1263 1263 * @param pDevIns The device instance. 1264 * @param p BusLogicPointer to the shared BusLogic instance data.1264 * @param pThis Pointer to the shared BusLogic instance data. 1265 1265 * @param GCPhysAddrCCB The physical guest address of the CCB the mailbox is for. 1266 1266 * @param pCCBGuest The command control block. … … 1269 1269 * @param uMailboxCompletionCode Completion status code to set in the mailbox. 1270 1270 */ 1271 static void buslogicR3SendIncomingMailbox(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, RTGCPHYS GCPhysAddrCCB,1271 static void buslogicR3SendIncomingMailbox(PPDMDEVINS pDevIns, PBUSLOGIC pThis, RTGCPHYS GCPhysAddrCCB, 1272 1272 PCCBU pCCBGuest, uint8_t uHostAdapterStatus, 1273 1273 uint8_t uDeviceStatus, uint8_t uMailboxCompletionCode) … … 1280 1280 MbxIn.u.in.uCompletionCode = uMailboxCompletionCode; 1281 1281 1282 int rc = PDMDevHlpCritSectEnter(pDevIns, &p BusLogic->CritSectIntr, VINF_SUCCESS);1282 int rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSectIntr, VINF_SUCCESS); 1283 1283 AssertRC(rc); 1284 1284 1285 RTGCPHYS GCPhysAddrMailboxIncoming = p BusLogic->GCPhysAddrMailboxIncomingBase1286 + ( p BusLogic->uMailboxIncomingPositionCurrent1287 * (p BusLogic->fMbxIs24Bit ? sizeof(Mailbox24) : sizeof(Mailbox32)) );1285 RTGCPHYS GCPhysAddrMailboxIncoming = pThis->GCPhysAddrMailboxIncomingBase 1286 + ( pThis->uMailboxIncomingPositionCurrent 1287 * (pThis->fMbxIs24Bit ? sizeof(Mailbox24) : sizeof(Mailbox32)) ); 1288 1288 1289 1289 if (uMailboxCompletionCode != BUSLOGIC_MAILBOX_INCOMING_COMPLETION_ABORTED_NOT_FOUND) … … 1296 1296 pCCBGuest->c.uDeviceStatus = uDeviceStatus; 1297 1297 /* Rewrite CCB up to the CDB; perhaps more than necessary. */ 1298 blPhysWrite(pDevIns, p BusLogic, GCPhysAddrCCB, pCCBGuest, RT_UOFFSETOF(CCBC, abCDB));1298 blPhysWrite(pDevIns, pThis, GCPhysAddrCCB, pCCBGuest, RT_UOFFSETOF(CCBC, abCDB)); 1299 1299 } 1300 1300 1301 1301 # ifdef RT_STRICT 1302 1302 uint8_t uCode; 1303 unsigned uCodeOffs = p BusLogic->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); 1304 1304 PDMDevHlpPhysRead(pDevIns, GCPhysAddrMailboxIncoming + uCodeOffs, &uCode, sizeof(uCode)); 1305 1305 Assert(uCode == BUSLOGIC_MAILBOX_INCOMING_COMPLETION_FREE); … … 1307 1307 1308 1308 /* Update mailbox. */ 1309 if (p BusLogic->fMbxIs24Bit)1309 if (pThis->fMbxIs24Bit) 1310 1310 { 1311 1311 Mailbox24 Mbx24; … … 1314 1314 U32_TO_ADDR(Mbx24.aPhysAddrCCB, MbxIn.u32PhysAddrCCB); 1315 1315 Log(("24-bit mailbox: completion code=%u, CCB at %RGp\n", Mbx24.uCmdState, (RTGCPHYS)ADDR_TO_U32(Mbx24.aPhysAddrCCB))); 1316 blPhysWrite(pDevIns, p BusLogic, GCPhysAddrMailboxIncoming, &Mbx24, sizeof(Mailbox24));1316 blPhysWrite(pDevIns, pThis, GCPhysAddrMailboxIncoming, &Mbx24, sizeof(Mailbox24)); 1317 1317 } 1318 1318 else 1319 1319 { 1320 1320 Log(("32-bit mailbox: completion code=%u, CCB at %RGp\n", MbxIn.u.in.uCompletionCode, GCPhysAddrCCB)); 1321 blPhysWrite(pDevIns, p BusLogic, GCPhysAddrMailboxIncoming, &MbxIn, sizeof(Mailbox32));1321 blPhysWrite(pDevIns, pThis, GCPhysAddrMailboxIncoming, &MbxIn, sizeof(Mailbox32)); 1322 1322 } 1323 1323 1324 1324 /* Advance to next mailbox position. */ 1325 p BusLogic->uMailboxIncomingPositionCurrent++;1326 if (p BusLogic->uMailboxIncomingPositionCurrent >= pBusLogic->cMailbox)1327 p BusLogic->uMailboxIncomingPositionCurrent = 0;1325 pThis->uMailboxIncomingPositionCurrent++; 1326 if (pThis->uMailboxIncomingPositionCurrent >= pThis->cMailbox) 1327 pThis->uMailboxIncomingPositionCurrent = 0; 1328 1328 1329 1329 # ifdef LOG_ENABLED 1330 ASMAtomicIncU32(&p BusLogic->cInMailboxesReadyIfLogEnabled);1330 ASMAtomicIncU32(&pThis->cInMailboxesReadyIfLogEnabled); 1331 1331 # endif 1332 1332 1333 buslogicSetInterrupt(pDevIns, p BusLogic, false, BL_INTR_IMBL);1334 1335 PDMDevHlpCritSectLeave(pDevIns, &p BusLogic->CritSectIntr);1333 buslogicSetInterrupt(pDevIns, pThis, false, BL_INTR_IMBL); 1334 1335 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSectIntr); 1336 1336 } 1337 1337 … … 1576 1576 * @param pDevIns The device instance. 1577 1577 * @param pThis Pointer to the Buslogic device state. 1578 * @param pReq Pointe to the request state.1578 * @param pReq Pointer to the request state. 1579 1579 * @param pfnCopyWorker The copy method to apply for each guest buffer. 1580 1580 * @param pSgBuf The host S/G buffer. … … 1804 1804 * @returns VBox status code. 1805 1805 * @param pDevIns The PDM device instance. 1806 * @param p BusLogicPointer to the shared BusLogic instance data.1807 */ 1808 static int buslogicProcessCommand(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic)1806 * @param pThis Pointer to the shared BusLogic instance data. 1807 */ 1808 static int buslogicProcessCommand(PPDMDEVINS pDevIns, PBUSLOGIC pThis) 1809 1809 { 1810 1810 int rc = VINF_SUCCESS; 1811 1811 bool fSuppressIrq = false; 1812 1812 1813 LogFlowFunc(("p BusLogic=%#p\n", pBusLogic));1814 AssertMsg(p BusLogic->uOperationCode != 0xff, ("There is no command to execute\n"));1815 1816 switch (p BusLogic->uOperationCode)1813 LogFlowFunc(("pThis=%#p\n", pThis)); 1814 AssertMsg(pThis->uOperationCode != 0xff, ("There is no command to execute\n")); 1815 1816 switch (pThis->uOperationCode) 1817 1817 { 1818 1818 case BUSLOGICCOMMAND_TEST_CMDC_INTERRUPT: 1819 1819 /* Valid command, no reply. */ 1820 p BusLogic->cbReplyParametersLeft = 0;1820 pThis->cbReplyParametersLeft = 0; 1821 1821 break; 1822 1822 case BUSLOGICCOMMAND_INQUIRE_PCI_HOST_ADAPTER_INFORMATION: 1823 1823 { 1824 PReplyInquirePCIHostAdapterInformation pReply = (PReplyInquirePCIHostAdapterInformation)p BusLogic->aReplyBuffer;1824 PReplyInquirePCIHostAdapterInformation pReply = (PReplyInquirePCIHostAdapterInformation)pThis->aReplyBuffer; 1825 1825 memset(pReply, 0, sizeof(ReplyInquirePCIHostAdapterInformation)); 1826 1826 1827 1827 /* It seems VMware does not provide valid information here too, lets do the same :) */ 1828 1828 pReply->InformationIsValid = 0; 1829 pReply->IsaIOPort = p BusLogic->uISABaseCode;1829 pReply->IsaIOPort = pThis->uISABaseCode; 1830 1830 pReply->IRQ = PCIDevGetInterruptLine(pDevIns->apPciDevs[0]); 1831 p BusLogic->cbReplyParametersLeft = sizeof(ReplyInquirePCIHostAdapterInformation);1831 pThis->cbReplyParametersLeft = sizeof(ReplyInquirePCIHostAdapterInformation); 1832 1832 break; 1833 1833 } … … 1835 1835 { 1836 1836 /* no-op */ 1837 p BusLogic->cbReplyParametersLeft = 0;1837 pThis->cbReplyParametersLeft = 0; 1838 1838 break; 1839 1839 } … … 1845 1845 */ 1846 1846 #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", p BusLogic->aCommandBuffer[0]));1848 buslogicR3RegisterISARange(pDevIns, p BusLogic, pBusLogic->aCommandBuffer[0]);1849 p BusLogic->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; 1850 1850 fSuppressIrq = true; 1851 1851 break; … … 1861 1861 * the adapter only when the byte is *not* '0' or 'B'. 1862 1862 */ 1863 if (p BusLogic->uDevType == DEV_AHA_1540B)1863 if (pThis->uDevType == DEV_AHA_1540B) 1864 1864 { 1865 p BusLogic->aReplyBuffer[0] = 'A'; /* Firmware option bytes */1866 p BusLogic->aReplyBuffer[1] = '0'; /* Special option byte */1865 pThis->aReplyBuffer[0] = 'A'; /* Firmware option bytes */ 1866 pThis->aReplyBuffer[1] = '0'; /* Special option byte */ 1867 1867 } 1868 1868 else 1869 1869 { 1870 p BusLogic->aReplyBuffer[0] = 'A'; /* Firmware option bytes */1871 p BusLogic->aReplyBuffer[1] = 'A'; /* Special option byte */1870 pThis->aReplyBuffer[0] = 'A'; /* Firmware option bytes */ 1871 pThis->aReplyBuffer[1] = 'A'; /* Special option byte */ 1872 1872 } 1873 1873 1874 1874 /* We report version 5.07B. This reply will provide the first two digits. */ 1875 p BusLogic->aReplyBuffer[2] = '5'; /* Major version 5 */1876 p BusLogic->aReplyBuffer[3] = '0'; /* Minor version 0 */1877 p BusLogic->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 */ 1878 1878 break; 1879 1879 } 1880 1880 case BUSLOGICCOMMAND_INQUIRE_FIRMWARE_VERSION_3RD_LETTER: 1881 1881 { 1882 if (p BusLogic->uDevType == DEV_AHA_1540B)1882 if (pThis->uDevType == DEV_AHA_1540B) 1883 1883 { 1884 1884 /* Newer ASPI4DOS.SYS versions expect this command to fail. */ 1885 Log(("Command %#x not valid for this adapter\n", p BusLogic->uOperationCode));1886 p BusLogic->cbReplyParametersLeft = 0;1887 p BusLogic->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; 1888 1888 break; 1889 1889 } 1890 1890 1891 p BusLogic->aReplyBuffer[0] = '7';1892 p BusLogic->cbReplyParametersLeft = 1;1891 pThis->aReplyBuffer[0] = '7'; 1892 pThis->cbReplyParametersLeft = 1; 1893 1893 break; 1894 1894 } 1895 1895 case BUSLOGICCOMMAND_INQUIRE_FIRMWARE_VERSION_LETTER: 1896 1896 { 1897 p BusLogic->aReplyBuffer[0] = 'B';1898 p BusLogic->cbReplyParametersLeft = 1;1897 pThis->aReplyBuffer[0] = 'B'; 1898 pThis->cbReplyParametersLeft = 1; 1899 1899 break; 1900 1900 } 1901 1901 case BUSLOGICCOMMAND_SET_ADAPTER_OPTIONS: 1902 1902 /* The parameter list length is determined by the first byte of the command buffer. */ 1903 if (p BusLogic->iParameter == 1)1903 if (pThis->iParameter == 1) 1904 1904 { 1905 1905 /* First pass - set the number of following parameter bytes. */ 1906 p BusLogic->cbCommandParametersLeft = pBusLogic->aCommandBuffer[0];1907 Log(("Set HA options: %u bytes follow\n", p BusLogic->cbCommandParametersLeft));1906 pThis->cbCommandParametersLeft = pThis->aCommandBuffer[0]; 1907 Log(("Set HA options: %u bytes follow\n", pThis->cbCommandParametersLeft)); 1908 1908 } 1909 1909 else 1910 1910 { 1911 1911 /* Second pass - process received data. */ 1912 Log(("Set HA options: received %u bytes\n", p BusLogic->aCommandBuffer[0]));1912 Log(("Set HA options: received %u bytes\n", pThis->aCommandBuffer[0])); 1913 1913 /* We ignore the data - it only concerns the SCSI hardware protocol. */ 1914 1914 } 1915 p BusLogic->cbReplyParametersLeft = 0;1915 pThis->cbReplyParametersLeft = 0; 1916 1916 break; 1917 1917 … … 1920 1920 * the number of additional CDB bytes that will follow. 1921 1921 */ 1922 if (p BusLogic->iParameter == 12)1922 if (pThis->iParameter == 12) 1923 1923 { 1924 1924 /* First pass - set the number of following CDB bytes. */ 1925 p BusLogic->cbCommandParametersLeft = pBusLogic->aCommandBuffer[11];1926 Log(("Execute SCSI cmd: %u more bytes follow\n", p BusLogic->cbCommandParametersLeft));1925 pThis->cbCommandParametersLeft = pThis->aCommandBuffer[11]; 1926 Log(("Execute SCSI cmd: %u more bytes follow\n", pThis->cbCommandParametersLeft)); 1927 1927 } 1928 1928 else … … 1931 1931 1932 1932 /* Second pass - process received data. */ 1933 Log(("Execute SCSI cmd: received %u bytes\n", p BusLogic->aCommandBuffer[0]));1934 1935 pCmd = (PESCMD)p BusLogic->aCommandBuffer;1933 Log(("Execute SCSI cmd: received %u bytes\n", pThis->aCommandBuffer[0])); 1934 1935 pCmd = (PESCMD)pThis->aCommandBuffer; 1936 1936 Log(("Addr %08X, cbData %08X, cbCDB=%u\n", pCmd->u32PhysAddrData, pCmd->cbData, pCmd->cbCDB)); 1937 1937 } 1938 1938 // This is currently a dummy - just fails every command. 1939 p BusLogic->cbReplyParametersLeft = 4;1940 p BusLogic->aReplyBuffer[0] = pBusLogic->aReplyBuffer[1] = 0;1941 p BusLogic->aReplyBuffer[2] = 0x11; /* HBA status (timeout). */1942 p BusLogic->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. */ 1943 1943 break; 1944 1944 … … 1946 1946 { 1947 1947 /* Not supported on AHA-154x. */ 1948 if (p BusLogic->uDevType == DEV_AHA_1540B)1948 if (pThis->uDevType == DEV_AHA_1540B) 1949 1949 { 1950 Log(("Command %#x not valid for this adapter\n", p BusLogic->uOperationCode));1951 p BusLogic->cbReplyParametersLeft = 0;1952 p BusLogic->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; 1953 1953 break; 1954 1954 } 1955 1955 1956 1956 /* The reply length is set by the guest and is found in the first byte of the command buffer. */ 1957 if (p BusLogic->aCommandBuffer[0] > sizeof(pBusLogic->aReplyBuffer))1957 if (pThis->aCommandBuffer[0] > sizeof(pThis->aReplyBuffer)) 1958 1958 { 1959 Log(("Requested too much adapter model number data (%u)!\n", p BusLogic->aCommandBuffer[0]));1960 p BusLogic->regStatus |= BL_STAT_CMDINV;1959 Log(("Requested too much adapter model number data (%u)!\n", pThis->aCommandBuffer[0])); 1960 pThis->regStatus |= BL_STAT_CMDINV; 1961 1961 break; 1962 1962 } 1963 p BusLogic->cbReplyParametersLeft = pBusLogic->aCommandBuffer[0];1964 memset(p BusLogic->aReplyBuffer, 0, sizeof(pBusLogic->aReplyBuffer));1963 pThis->cbReplyParametersLeft = pThis->aCommandBuffer[0]; 1964 memset(pThis->aReplyBuffer, 0, sizeof(pThis->aReplyBuffer)); 1965 1965 const char aModelName[] = "958D "; /* Trailing \0 is fine, that's the filler anyway. */ 1966 int cCharsToTransfer = p BusLogic->cbReplyParametersLeft <= sizeof(aModelName)1967 ? p BusLogic->cbReplyParametersLeft1966 int cCharsToTransfer = pThis->cbReplyParametersLeft <= sizeof(aModelName) 1967 ? pThis->cbReplyParametersLeft 1968 1968 : sizeof(aModelName); 1969 1969 1970 1970 for (int i = 0; i < cCharsToTransfer; i++) 1971 p BusLogic->aReplyBuffer[i] = aModelName[i];1971 pThis->aReplyBuffer[i] = aModelName[i]; 1972 1972 1973 1973 break; … … 1977 1977 uint8_t uIrq; 1978 1978 1979 if (p BusLogic->uIsaIrq)1980 uIrq = p BusLogic->uIsaIrq;1979 if (pThis->uIsaIrq) 1980 uIrq = pThis->uIsaIrq; 1981 1981 else 1982 1982 uIrq = PCIDevGetInterruptLine(pDevIns->apPciDevs[0]); 1983 1983 1984 p BusLogic->cbReplyParametersLeft = sizeof(ReplyInquireConfiguration);1985 PReplyInquireConfiguration pReply = (PReplyInquireConfiguration)p BusLogic->aReplyBuffer;1984 pThis->cbReplyParametersLeft = sizeof(ReplyInquireConfiguration); 1985 PReplyInquireConfiguration pReply = (PReplyInquireConfiguration)pThis->aReplyBuffer; 1986 1986 memset(pReply, 0, sizeof(ReplyInquireConfiguration)); 1987 1987 … … 2015 2015 * Adaptec 154x models supposedly support it too?? 2016 2016 */ 2017 if (p BusLogic->uDevType == DEV_AHA_1540B)2017 if (pThis->uDevType == DEV_AHA_1540B) 2018 2018 { 2019 Log(("Command %#x not valid for this adapter\n", p BusLogic->uOperationCode));2020 p BusLogic->cbReplyParametersLeft = 0;2021 p BusLogic->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; 2022 2022 break; 2023 2023 } 2024 2024 2025 2025 /* The reply length is set by the guest and is found in the first byte of the command buffer. */ 2026 p BusLogic->cbReplyParametersLeft = pBusLogic->aCommandBuffer[0];2027 PReplyInquireExtendedSetupInformation pReply = (PReplyInquireExtendedSetupInformation)p BusLogic->aReplyBuffer;2026 pThis->cbReplyParametersLeft = pThis->aCommandBuffer[0]; 2027 PReplyInquireExtendedSetupInformation pReply = (PReplyInquireExtendedSetupInformation)pThis->aReplyBuffer; 2028 2028 memset(pReply, 0, sizeof(ReplyInquireExtendedSetupInformation)); 2029 2029 … … 2031 2031 pReply->uBusType = 'E'; /* EISA style */ 2032 2032 pReply->u16ScatterGatherLimit = 8192; 2033 pReply->cMailbox = p BusLogic->cMailbox;2034 pReply->uMailboxAddressBase = (uint32_t)p BusLogic->GCPhysAddrMailboxOutgoingBase;2033 pReply->cMailbox = pThis->cMailbox; 2034 pReply->uMailboxAddressBase = (uint32_t)pThis->GCPhysAddrMailboxOutgoingBase; 2035 2035 pReply->fLevelSensitiveInterrupt = true; 2036 2036 pReply->fHostWideSCSI = true; … … 2043 2043 { 2044 2044 /* The reply length is set by the guest and is found in the first byte of the command buffer. */ 2045 p BusLogic->cbReplyParametersLeft = pBusLogic->aCommandBuffer[0];2046 PReplyInquireSetupInformation pReply = (PReplyInquireSetupInformation)p BusLogic->aReplyBuffer;2045 pThis->cbReplyParametersLeft = pThis->aCommandBuffer[0]; 2046 PReplyInquireSetupInformation pReply = (PReplyInquireSetupInformation)pThis->aReplyBuffer; 2047 2047 memset(pReply, 0, sizeof(ReplyInquireSetupInformation)); 2048 2048 pReply->fSynchronousInitiationEnabled = true; 2049 2049 pReply->fParityCheckingEnabled = true; 2050 pReply->cMailbox = p BusLogic->cMailbox;2051 U32_TO_ADDR(pReply->MailboxAddress, p BusLogic->GCPhysAddrMailboxOutgoingBase);2050 pReply->cMailbox = pThis->cMailbox; 2051 U32_TO_ADDR(pReply->MailboxAddress, pThis->GCPhysAddrMailboxOutgoingBase); 2052 2052 /* The 'D' signature (actually 'SD' for Storage Dimensions, and 'BD' for BusLogic) 2053 2053 * prevents Adaptec's OS/2 drivers from getting too friendly with BusLogic hardware 2054 2054 * and upsetting the HBA state. 2055 2055 */ 2056 if (p BusLogic->uDevType == DEV_AHA_1540B)2056 if (pThis->uDevType == DEV_AHA_1540B) 2057 2057 { 2058 2058 pReply->uSignature = 0; /* Zeros for Adaptec. */ … … 2073 2073 * and second one the number of bytes to read. 2074 2074 */ 2075 uint8_t uOffset = p BusLogic->aCommandBuffer[0];2076 p BusLogic->cbReplyParametersLeft = pBusLogic->aCommandBuffer[1];2077 2078 p BusLogic->fUseLocalRam = true;2079 p BusLogic->iReply = uOffset;2075 uint8_t uOffset = pThis->aCommandBuffer[0]; 2076 pThis->cbReplyParametersLeft = pThis->aCommandBuffer[1]; 2077 2078 pThis->fUseLocalRam = true; 2079 pThis->iReply = uOffset; 2080 2080 break; 2081 2081 } 2082 2082 case BUSLOGICCOMMAND_INITIALIZE_MAILBOX: 2083 2083 { 2084 PRequestInitMbx pRequest = (PRequestInitMbx)p BusLogic->aCommandBuffer;2085 2086 p BusLogic->cbReplyParametersLeft = 0;2084 PRequestInitMbx pRequest = (PRequestInitMbx)pThis->aCommandBuffer; 2085 2086 pThis->cbReplyParametersLeft = 0; 2087 2087 if (!pRequest->cMailbox) 2088 2088 { 2089 Log(("cMailboxes=%u (24-bit mode), fail!\n", p BusLogic->cMailbox));2090 p BusLogic->regStatus |= BL_STAT_CMDINV;2089 Log(("cMailboxes=%u (24-bit mode), fail!\n", pThis->cMailbox)); 2090 pThis->regStatus |= BL_STAT_CMDINV; 2091 2091 break; 2092 2092 } 2093 p BusLogic->fMbxIs24Bit = true;2094 p BusLogic->cMailbox = pRequest->cMailbox;2095 p BusLogic->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); 2096 2096 /* The area for incoming mailboxes is right after the last entry of outgoing mailboxes. */ 2097 p BusLogic->GCPhysAddrMailboxIncomingBase = pBusLogic->GCPhysAddrMailboxOutgoingBase + (pBusLogic->cMailbox * sizeof(Mailbox24));2098 2099 Log(("GCPhysAddrMailboxOutgoingBase=%RGp\n", p BusLogic->GCPhysAddrMailboxOutgoingBase));2100 Log(("GCPhysAddrMailboxIncomingBase=%RGp\n", p BusLogic->GCPhysAddrMailboxIncomingBase));2101 Log(("cMailboxes=%u (24-bit mode)\n", p BusLogic->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)); 2102 2102 LogRel(("Initialized 24-bit mailbox, %d entries at %08x\n", pRequest->cMailbox, ADDR_TO_U32(pRequest->aMailboxBaseAddr))); 2103 2103 2104 p BusLogic->regStatus &= ~BL_STAT_INREQ;2104 pThis->regStatus &= ~BL_STAT_INREQ; 2105 2105 break; 2106 2106 } 2107 2107 case BUSLOGICCOMMAND_INITIALIZE_EXTENDED_MAILBOX: 2108 2108 { 2109 if (p BusLogic->uDevType == DEV_AHA_1540B)2109 if (pThis->uDevType == DEV_AHA_1540B) 2110 2110 { 2111 Log(("Command %#x not valid for this adapter\n", p BusLogic->uOperationCode));2112 p BusLogic->cbReplyParametersLeft = 0;2113 p BusLogic->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; 2114 2114 break; 2115 2115 } 2116 2116 2117 PRequestInitializeExtendedMailbox pRequest = (PRequestInitializeExtendedMailbox)p BusLogic->aCommandBuffer;2118 2119 p BusLogic->cbReplyParametersLeft = 0;2117 PRequestInitializeExtendedMailbox pRequest = (PRequestInitializeExtendedMailbox)pThis->aCommandBuffer; 2118 2119 pThis->cbReplyParametersLeft = 0; 2120 2120 if (!pRequest->cMailbox) 2121 2121 { 2122 Log(("cMailboxes=%u (32-bit mode), fail!\n", p BusLogic->cMailbox));2123 p BusLogic->regStatus |= BL_STAT_CMDINV;2122 Log(("cMailboxes=%u (32-bit mode), fail!\n", pThis->cMailbox)); 2123 pThis->regStatus |= BL_STAT_CMDINV; 2124 2124 break; 2125 2125 } 2126 p BusLogic->fMbxIs24Bit = false;2127 p BusLogic->cMailbox = pRequest->cMailbox;2128 p BusLogic->GCPhysAddrMailboxOutgoingBase = (RTGCPHYS)pRequest->uMailboxBaseAddress;2126 pThis->fMbxIs24Bit = false; 2127 pThis->cMailbox = pRequest->cMailbox; 2128 pThis->GCPhysAddrMailboxOutgoingBase = (RTGCPHYS)pRequest->uMailboxBaseAddress; 2129 2129 /* The area for incoming mailboxes is right after the last entry of outgoing mailboxes. */ 2130 p BusLogic->GCPhysAddrMailboxIncomingBase = (RTGCPHYS)pRequest->uMailboxBaseAddress + (pBusLogic->cMailbox * sizeof(Mailbox32));2131 2132 Log(("GCPhysAddrMailboxOutgoingBase=%RGp\n", p BusLogic->GCPhysAddrMailboxOutgoingBase));2133 Log(("GCPhysAddrMailboxIncomingBase=%RGp\n", p BusLogic->GCPhysAddrMailboxIncomingBase));2134 Log(("cMailboxes=%u (32-bit mode)\n", p BusLogic->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)); 2135 2135 LogRel(("Initialized 32-bit mailbox, %d entries at %08x\n", pRequest->cMailbox, pRequest->uMailboxBaseAddress)); 2136 2136 2137 p BusLogic->regStatus &= ~BL_STAT_INREQ;2137 pThis->regStatus &= ~BL_STAT_INREQ; 2138 2138 break; 2139 2139 } 2140 2140 case BUSLOGICCOMMAND_ENABLE_STRICT_ROUND_ROBIN_MODE: 2141 2141 { 2142 if (p BusLogic->aCommandBuffer[0] == 0)2143 p BusLogic->fStrictRoundRobinMode = false;2144 else if (p BusLogic->aCommandBuffer[0] == 1)2145 p BusLogic->fStrictRoundRobinMode = true;2142 if (pThis->aCommandBuffer[0] == 0) 2143 pThis->fStrictRoundRobinMode = false; 2144 else if (pThis->aCommandBuffer[0] == 1) 2145 pThis->fStrictRoundRobinMode = true; 2146 2146 else 2147 AssertMsgFailed(("Invalid round robin mode %d\n", p BusLogic->aCommandBuffer[0]));2148 2149 p BusLogic->cbReplyParametersLeft = 0;2147 AssertMsgFailed(("Invalid round robin mode %d\n", pThis->aCommandBuffer[0])); 2148 2149 pThis->cbReplyParametersLeft = 0; 2150 2150 break; 2151 2151 } 2152 2152 case BUSLOGICCOMMAND_SET_CCB_FORMAT: 2153 2153 { 2154 if (p BusLogic->aCommandBuffer[0] == 0)2155 p BusLogic->fExtendedLunCCBFormat = false;2156 else if (p BusLogic->aCommandBuffer[0] == 1)2157 p BusLogic->fExtendedLunCCBFormat = true;2154 if (pThis->aCommandBuffer[0] == 0) 2155 pThis->fExtendedLunCCBFormat = false; 2156 else if (pThis->aCommandBuffer[0] == 1) 2157 pThis->fExtendedLunCCBFormat = true; 2158 2158 else 2159 AssertMsgFailed(("Invalid CCB format %d\n", p BusLogic->aCommandBuffer[0]));2160 2161 p BusLogic->cbReplyParametersLeft = 0;2159 AssertMsgFailed(("Invalid CCB format %d\n", pThis->aCommandBuffer[0])); 2160 2161 pThis->cbReplyParametersLeft = 0; 2162 2162 break; 2163 2163 } … … 2166 2166 * We cheat and skip that, since we already know what's attached 2167 2167 */ 2168 memset(p BusLogic->aReplyBuffer, 0, 8);2168 memset(pThis->aReplyBuffer, 0, 8); 2169 2169 for (int i = 0; i < 8; ++i) 2170 2170 { 2171 if (p BusLogic->afDevicePresent[i])2172 p BusLogic->aReplyBuffer[i] = 1;2171 if (pThis->afDevicePresent[i]) 2172 pThis->aReplyBuffer[i] = 1; 2173 2173 } 2174 p BusLogic->aReplyBuffer[7] = 0; /* HA hardcoded at ID 7. */2175 p BusLogic->cbReplyParametersLeft = 8;2174 pThis->aReplyBuffer[7] = 0; /* HA hardcoded at ID 7. */ 2175 pThis->cbReplyParametersLeft = 8; 2176 2176 break; 2177 2177 case BUSLOGICCOMMAND_INQUIRE_INSTALLED_DEVICES_ID_8_TO_15: 2178 2178 /* See note about cheating above. */ 2179 memset(p BusLogic->aReplyBuffer, 0, 8);2179 memset(pThis->aReplyBuffer, 0, 8); 2180 2180 for (int i = 0; i < 8; ++i) 2181 2181 { 2182 if (p BusLogic->afDevicePresent[i + 8])2183 p BusLogic->aReplyBuffer[i] = 1;2182 if (pThis->afDevicePresent[i + 8]) 2183 pThis->aReplyBuffer[i] = 1; 2184 2184 } 2185 p BusLogic->cbReplyParametersLeft = 8;2185 pThis->cbReplyParametersLeft = 8; 2186 2186 break; 2187 2187 case BUSLOGICCOMMAND_INQUIRE_TARGET_DEVICES: … … 2190 2190 uint16_t u16TargetsPresentMask = 0; 2191 2191 2192 for (uint8_t i = 0; i < RT_ELEMENTS(p BusLogic->afDevicePresent); i++)2192 for (uint8_t i = 0; i < RT_ELEMENTS(pThis->afDevicePresent); i++) 2193 2193 { 2194 if (p BusLogic->afDevicePresent[i])2194 if (pThis->afDevicePresent[i]) 2195 2195 u16TargetsPresentMask |= (1 << i); 2196 2196 } 2197 p BusLogic->aReplyBuffer[0] = (uint8_t)u16TargetsPresentMask;2198 p BusLogic->aReplyBuffer[1] = (uint8_t)(u16TargetsPresentMask >> 8);2199 p BusLogic->cbReplyParametersLeft = 2;2197 pThis->aReplyBuffer[0] = (uint8_t)u16TargetsPresentMask; 2198 pThis->aReplyBuffer[1] = (uint8_t)(u16TargetsPresentMask >> 8); 2199 pThis->cbReplyParametersLeft = 2; 2200 2200 break; 2201 2201 } 2202 2202 case BUSLOGICCOMMAND_INQUIRE_SYNCHRONOUS_PERIOD: 2203 2203 { 2204 if (p BusLogic->aCommandBuffer[0] > sizeof(pBusLogic->aReplyBuffer))2204 if (pThis->aCommandBuffer[0] > sizeof(pThis->aReplyBuffer)) 2205 2205 { 2206 Log(("Requested too much synch period inquiry (%u)!\n", p BusLogic->aCommandBuffer[0]));2207 p BusLogic->regStatus |= BL_STAT_CMDINV;2206 Log(("Requested too much synch period inquiry (%u)!\n", pThis->aCommandBuffer[0])); 2207 pThis->regStatus |= BL_STAT_CMDINV; 2208 2208 break; 2209 2209 } 2210 p BusLogic->cbReplyParametersLeft = pBusLogic->aCommandBuffer[0];2211 for (uint8_t i = 0; i < p BusLogic->cbReplyParametersLeft; i++)2212 p BusLogic->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 */ 2213 2213 2214 2214 break; … … 2217 2217 { 2218 2218 /* Not supported on AHA-154x HBAs. */ 2219 if (p BusLogic->uDevType == DEV_AHA_1540B)2219 if (pThis->uDevType == DEV_AHA_1540B) 2220 2220 { 2221 Log(("Command %#x not valid for this adapter\n", p BusLogic->uOperationCode));2222 p BusLogic->cbReplyParametersLeft = 0;2223 p BusLogic->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; 2224 2224 break; 2225 2225 } 2226 2226 2227 p BusLogic->cbReplyParametersLeft = 0;2228 if (p BusLogic->aCommandBuffer[0] == 0)2229 p BusLogic->fIRQEnabled = false;2227 pThis->cbReplyParametersLeft = 0; 2228 if (pThis->aCommandBuffer[0] == 0) 2229 pThis->fIRQEnabled = false; 2230 2230 else 2231 p BusLogic->fIRQEnabled = true;2231 pThis->fIRQEnabled = true; 2232 2232 /* No interrupt signaled regardless of enable/disable. */ 2233 2233 fSuppressIrq = true; … … 2236 2236 case BUSLOGICCOMMAND_ECHO_COMMAND_DATA: 2237 2237 { 2238 p BusLogic->aReplyBuffer[0] = pBusLogic->aCommandBuffer[0];2239 p BusLogic->cbReplyParametersLeft = 1;2238 pThis->aReplyBuffer[0] = pThis->aCommandBuffer[0]; 2239 pThis->cbReplyParametersLeft = 1; 2240 2240 break; 2241 2241 } 2242 2242 case BUSLOGICCOMMAND_ENABLE_OUTGOING_MAILBOX_AVAILABLE_INTERRUPT: 2243 2243 { 2244 uint8_t uEnable = p BusLogic->aCommandBuffer[0];2245 2246 p BusLogic->cbReplyParametersLeft = 0;2244 uint8_t uEnable = pThis->aCommandBuffer[0]; 2245 2246 pThis->cbReplyParametersLeft = 0; 2247 2247 Log(("Enable OMBR: %u\n", uEnable)); 2248 2248 /* Only 0/1 are accepted. */ 2249 2249 if (uEnable > 1) 2250 p BusLogic->regStatus |= BL_STAT_CMDINV;2250 pThis->regStatus |= BL_STAT_CMDINV; 2251 2251 else 2252 2252 { 2253 p BusLogic->LocalRam.structured.autoSCSIData.uReserved6 = uEnable;2253 pThis->LocalRam.structured.autoSCSIData.uReserved6 = uEnable; 2254 2254 fSuppressIrq = true; 2255 2255 } … … 2258 2258 case BUSLOGICCOMMAND_SET_PREEMPT_TIME_ON_BUS: 2259 2259 { 2260 p BusLogic->cbReplyParametersLeft = 0;2261 p BusLogic->LocalRam.structured.autoSCSIData.uBusOnDelay = pBusLogic->aCommandBuffer[0];2262 Log(("Bus-on time: %d\n", p BusLogic->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])); 2263 2263 break; 2264 2264 } 2265 2265 case BUSLOGICCOMMAND_SET_TIME_OFF_BUS: 2266 2266 { 2267 p BusLogic->cbReplyParametersLeft = 0;2268 p BusLogic->LocalRam.structured.autoSCSIData.uBusOffDelay = pBusLogic->aCommandBuffer[0];2269 Log(("Bus-off time: %d\n", p BusLogic->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])); 2270 2270 break; 2271 2271 } 2272 2272 case BUSLOGICCOMMAND_SET_BUS_TRANSFER_RATE: 2273 2273 { 2274 p BusLogic->cbReplyParametersLeft = 0;2275 p BusLogic->LocalRam.structured.autoSCSIData.uDMATransferRate = pBusLogic->aCommandBuffer[0];2276 Log(("Bus transfer rate: %02X\n", p BusLogic->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])); 2277 2277 break; 2278 2278 } … … 2282 2282 Addr24 addr; 2283 2283 2284 p BusLogic->cbReplyParametersLeft = 0;2285 addr.hi = p BusLogic->aCommandBuffer[0];2286 addr.mid = p BusLogic->aCommandBuffer[1];2287 addr.lo = p BusLogic->aCommandBuffer[2];2284 pThis->cbReplyParametersLeft = 0; 2285 addr.hi = pThis->aCommandBuffer[0]; 2286 addr.mid = pThis->aCommandBuffer[1]; 2287 addr.lo = pThis->aCommandBuffer[2]; 2288 2288 GCPhysFifoBuf = (RTGCPHYS)ADDR_TO_U32(addr); 2289 2289 Log(("Write busmaster FIFO at: %04X\n", ADDR_TO_U32(addr))); 2290 2290 PDMDevHlpPhysRead(pDevIns, GCPhysFifoBuf, 2291 &p BusLogic->LocalRam.u8View[64], 64);2291 &pThis->LocalRam.u8View[64], 64); 2292 2292 break; 2293 2293 } … … 2297 2297 Addr24 addr; 2298 2298 2299 p BusLogic->cbReplyParametersLeft = 0;2300 addr.hi = p BusLogic->aCommandBuffer[0];2301 addr.mid = p BusLogic->aCommandBuffer[1];2302 addr.lo = p BusLogic->aCommandBuffer[2];2299 pThis->cbReplyParametersLeft = 0; 2300 addr.hi = pThis->aCommandBuffer[0]; 2301 addr.mid = pThis->aCommandBuffer[1]; 2302 addr.lo = pThis->aCommandBuffer[2]; 2303 2303 GCPhysFifoBuf = (RTGCPHYS)ADDR_TO_U32(addr); 2304 2304 Log(("Read busmaster FIFO at: %04X\n", ADDR_TO_U32(addr))); 2305 blPhysWrite(pDevIns, p BusLogic, GCPhysFifoBuf, &pBusLogic->LocalRam.u8View[64], 64);2305 blPhysWrite(pDevIns, pThis, GCPhysFifoBuf, &pThis->LocalRam.u8View[64], 64); 2306 2306 break; 2307 2307 } 2308 2308 default: 2309 AssertMsgFailed(("Invalid command %#x\n", p BusLogic->uOperationCode));2309 AssertMsgFailed(("Invalid command %#x\n", pThis->uOperationCode)); 2310 2310 RT_FALL_THRU(); 2311 2311 case BUSLOGICCOMMAND_EXT_BIOS_INFO: … … 2314 2314 * we pretend being 154xB compatible. Just mark the command as invalid. 2315 2315 */ 2316 Log(("Command %#x not valid for this adapter\n", p BusLogic->uOperationCode));2317 p BusLogic->cbReplyParametersLeft = 0;2318 p BusLogic->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; 2319 2319 break; 2320 2320 case BUSLOGICCOMMAND_EXECUTE_MAILBOX_COMMAND: /* Should be handled already. */ … … 2322 2322 } 2323 2323 2324 Log(("uOperationCode=%#x, cbReplyParametersLeft=%d\n", p BusLogic->uOperationCode, pBusLogic->cbReplyParametersLeft));2324 Log(("uOperationCode=%#x, cbReplyParametersLeft=%d\n", pThis->uOperationCode, pThis->cbReplyParametersLeft)); 2325 2325 2326 2326 /* Fail command if too much parameter data requested. */ 2327 if ((p BusLogic->cbCommandParametersLeft + pBusLogic->iParameter) > sizeof(pBusLogic->aCommandBuffer))2328 { 2329 Log(("Invalid command parameter length (%u)\n", p BusLogic->cbCommandParametersLeft));2330 p BusLogic->cbReplyParametersLeft = 0;2331 p BusLogic->cbCommandParametersLeft = 0;2332 p BusLogic->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; 2333 2333 } 2334 2334 2335 2335 /* Set the data in ready bit in the status register in case the command has a reply. */ 2336 if (p BusLogic->cbReplyParametersLeft)2337 p BusLogic->regStatus |= BL_STAT_DIRRDY;2338 else if (!p BusLogic->cbCommandParametersLeft)2339 buslogicCommandComplete(pDevIns, p BusLogic, fSuppressIrq);2336 if (pThis->cbReplyParametersLeft) 2337 pThis->regStatus |= BL_STAT_DIRRDY; 2338 else if (!pThis->cbCommandParametersLeft) 2339 buslogicCommandComplete(pDevIns, pThis, fSuppressIrq); 2340 2340 2341 2341 return rc; … … 2347 2347 * @returns VBox status code. 2348 2348 * @param pDevIns The device instance. 2349 * @param p BusLogicPointer to the shared BusLogic instance data.2349 * @param pThis Pointer to the shared BusLogic instance data. 2350 2350 * @param iRegister The index of the register to read. 2351 2351 * @param pu32 Where to store the register content. 2352 2352 */ 2353 static int buslogicRegisterRead(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, unsigned iRegister, uint32_t *pu32)2353 static int buslogicRegisterRead(PPDMDEVINS pDevIns, PBUSLOGIC pThis, unsigned iRegister, uint32_t *pu32) 2354 2354 { 2355 2355 static const char s_szAhaSig[] = "ADAP"; … … 2360 2360 case BUSLOGIC_REGISTER_STATUS: 2361 2361 { 2362 *pu32 = p BusLogic->regStatus;2362 *pu32 = pThis->regStatus; 2363 2363 2364 2364 /* If the diagnostic active bit is set, we are in a guest-initiated … … 2369 2369 * the DIAG bit at all. 2370 2370 */ 2371 if (p BusLogic->regStatus & BL_STAT_DACT)2371 if (pThis->regStatus & BL_STAT_DACT) 2372 2372 { 2373 2373 uint64_t u64AccessTime = PDMDevHlpTMTimeVirtGetNano(pDevIns); 2374 2374 2375 p BusLogic->regStatus &= ~BL_STAT_DACT;2376 p BusLogic->regStatus |= BL_STAT_HARDY;2377 2378 if (u64AccessTime - p BusLogic->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) 2379 2379 { 2380 2380 /* If reset already expired, let the guest see that right away. */ 2381 *pu32 = p BusLogic->regStatus;2382 p BusLogic->u64ResetTime = 0;2381 *pu32 = pThis->regStatus; 2382 pThis->u64ResetTime = 0; 2383 2383 } 2384 2384 } … … 2387 2387 case BUSLOGIC_REGISTER_DATAIN: 2388 2388 { 2389 if (p BusLogic->fUseLocalRam)2390 *pu32 = p BusLogic->LocalRam.u8View[pBusLogic->iReply];2389 if (pThis->fUseLocalRam) 2390 *pu32 = pThis->LocalRam.u8View[pThis->iReply]; 2391 2391 else 2392 *pu32 = p BusLogic->aReplyBuffer[pBusLogic->iReply];2392 *pu32 = pThis->aReplyBuffer[pThis->iReply]; 2393 2393 2394 2394 /* Careful about underflow - guest can read data register even if 2395 2395 * no data is available. 2396 2396 */ 2397 if (p BusLogic->cbReplyParametersLeft)2397 if (pThis->cbReplyParametersLeft) 2398 2398 { 2399 p BusLogic->iReply++;2400 p BusLogic->cbReplyParametersLeft--;2401 if (!p BusLogic->cbReplyParametersLeft)2399 pThis->iReply++; 2400 pThis->cbReplyParametersLeft--; 2401 if (!pThis->cbReplyParametersLeft) 2402 2402 { 2403 2403 /* … … 2406 2406 * NB: Some commands do not set the CMDC bit / raise completion interrupt. 2407 2407 */ 2408 if (p BusLogic->uOperationCode == BUSLOGICCOMMAND_FETCH_HOST_ADAPTER_LOCAL_RAM)2409 buslogicCommandComplete(pDevIns, p BusLogic, true /* fSuppressIrq */);2408 if (pThis->uOperationCode == BUSLOGICCOMMAND_FETCH_HOST_ADAPTER_LOCAL_RAM) 2409 buslogicCommandComplete(pDevIns, pThis, true /* fSuppressIrq */); 2410 2410 else 2411 buslogicCommandComplete(pDevIns, p BusLogic, false);2411 buslogicCommandComplete(pDevIns, pThis, false); 2412 2412 } 2413 2413 } 2414 2414 LogFlowFunc(("data=%02x, iReply=%d, cbReplyParametersLeft=%u\n", *pu32, 2415 p BusLogic->iReply, pBusLogic->cbReplyParametersLeft));2415 pThis->iReply, pThis->cbReplyParametersLeft)); 2416 2416 break; 2417 2417 } 2418 2418 case BUSLOGIC_REGISTER_INTERRUPT: 2419 2419 { 2420 *pu32 = p BusLogic->regInterrupt;2420 *pu32 = pThis->regInterrupt; 2421 2421 break; 2422 2422 } 2423 2423 case BUSLOGIC_REGISTER_GEOMETRY: 2424 2424 { 2425 if (p BusLogic->uDevType == DEV_AHA_1540B)2425 if (pThis->uDevType == DEV_AHA_1540B) 2426 2426 { 2427 uint8_t off = p BusLogic->uAhaSigIdx & 3;2427 uint8_t off = pThis->uAhaSigIdx & 3; 2428 2428 *pu32 = s_szAhaSig[off]; 2429 p BusLogic->uAhaSigIdx = (off + 1) & 3;2429 pThis->uAhaSigIdx = (off + 1) & 3; 2430 2430 } 2431 2431 else 2432 *pu32 = p BusLogic->regGeometry;2432 *pu32 = pThis->regGeometry; 2433 2433 break; 2434 2434 } … … 2448 2448 * @returns VBox status code. 2449 2449 * @param pDevIns The PDM device instance. 2450 * @param p BusLogicPointer to the shared BusLogic instance data.2450 * @param pThis Pointer to the shared BusLogic instance data. 2451 2451 * @param iRegister The index of the register to read. 2452 2452 * @param uVal The value to write. 2453 2453 */ 2454 static int buslogicRegisterWrite(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, unsigned iRegister, uint8_t uVal)2454 static int buslogicRegisterWrite(PPDMDEVINS pDevIns, PBUSLOGIC pThis, unsigned iRegister, uint8_t uVal) 2455 2455 { 2456 2456 int rc = VINF_SUCCESS; … … 2466 2466 2467 2467 LogRel(("BusLogic: %s reset\n", fHardReset ? "hard" : "soft")); 2468 buslogicR3InitiateReset(pDevIns, p BusLogic, PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC), fHardReset);2468 buslogicR3InitiateReset(pDevIns, pThis, PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC), fHardReset); 2469 2469 #else 2470 2470 rc = VINF_IOM_R3_IOPORT_WRITE; … … 2473 2473 } 2474 2474 2475 rc = PDMDevHlpCritSectEnter(pDevIns, &p BusLogic->CritSectIntr, VINF_IOM_R3_IOPORT_WRITE);2475 rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->CritSectIntr, VINF_IOM_R3_IOPORT_WRITE); 2476 2476 if (rc != VINF_SUCCESS) 2477 2477 return rc; 2478 2478 2479 2479 #ifdef LOG_ENABLED 2480 uint32_t cMailboxesReady = ASMAtomicXchgU32(&p BusLogic->cInMailboxesReadyIfLogEnabled, 0);2480 uint32_t cMailboxesReady = ASMAtomicXchgU32(&pThis->cInMailboxesReadyIfLogEnabled, 0); 2481 2481 Log(("%u incoming mailboxes were ready when this interrupt was cleared\n", cMailboxesReady)); 2482 2482 #endif 2483 2483 2484 2484 if (uVal & BL_CTRL_RINT) 2485 buslogicClearInterrupt(pDevIns, p BusLogic);2486 2487 PDMDevHlpCritSectLeave(pDevIns, &p BusLogic->CritSectIntr);2485 buslogicClearInterrupt(pDevIns, pThis); 2486 2487 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSectIntr); 2488 2488 2489 2489 break; … … 2492 2492 { 2493 2493 /* Fast path for mailbox execution command. */ 2494 if ((uVal == BUSLOGICCOMMAND_EXECUTE_MAILBOX_COMMAND) && (p BusLogic->uOperationCode == 0xff))2494 if ((uVal == BUSLOGICCOMMAND_EXECUTE_MAILBOX_COMMAND) && (pThis->uOperationCode == 0xff)) 2495 2495 { 2496 2496 /// @todo Should fail if BL_STAT_INREQ is set 2497 2497 /* If there are no mailboxes configured, don't even try to do anything. */ 2498 if (p BusLogic->cMailbox)2498 if (pThis->cMailbox) 2499 2499 { 2500 ASMAtomicIncU32(&p BusLogic->cMailboxesReady);2501 if (!ASMAtomicXchgBool(&p BusLogic->fNotificationSent, true))2500 ASMAtomicIncU32(&pThis->cMailboxesReady); 2501 if (!ASMAtomicXchgBool(&pThis->fNotificationSent, true)) 2502 2502 { 2503 2503 /* Wake up the worker thread. */ 2504 int rc2 = PDMDevHlpSUPSemEventSignal(pDevIns, p BusLogic->hEvtProcess);2504 int rc2 = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtProcess); 2505 2505 AssertRC(rc2); 2506 2506 } … … 2514 2514 * If not we initialize executing a new command. 2515 2515 */ 2516 if (p BusLogic->uOperationCode == 0xff)2516 if (pThis->uOperationCode == 0xff) 2517 2517 { 2518 p BusLogic->uOperationCode = uVal;2519 p BusLogic->iParameter = 0;2518 pThis->uOperationCode = uVal; 2519 pThis->iParameter = 0; 2520 2520 2521 2521 /* Mark host adapter as busy and clear the invalid status bit. */ 2522 p BusLogic->regStatus &= ~(BL_STAT_HARDY | BL_STAT_CMDINV);2522 pThis->regStatus &= ~(BL_STAT_HARDY | BL_STAT_CMDINV); 2523 2523 2524 2524 /* Get the number of bytes for parameters from the command code. */ 2525 switch (p BusLogic->uOperationCode)2525 switch (pThis->uOperationCode) 2526 2526 { 2527 2527 case BUSLOGICCOMMAND_TEST_CMDC_INTERRUPT: … … 2534 2534 case BUSLOGICCOMMAND_INQUIRE_INSTALLED_DEVICES_ID_8_TO_15: 2535 2535 case BUSLOGICCOMMAND_INQUIRE_TARGET_DEVICES: 2536 p BusLogic->cbCommandParametersLeft = 0;2536 pThis->cbCommandParametersLeft = 0; 2537 2537 break; 2538 2538 case BUSLOGICCOMMAND_MODIFY_IO_ADDRESS: … … 2541 2541 case BUSLOGICCOMMAND_INQUIRE_HOST_ADAPTER_MODEL_NUMBER: 2542 2542 /* These commands are not on AHA-154x, some Adaptec drivers (ASPI4DOS.SYS) test them. */ 2543 if (p BusLogic->uDevType == DEV_AHA_1540B)2543 if (pThis->uDevType == DEV_AHA_1540B) 2544 2544 { 2545 p BusLogic->cbCommandParametersLeft = 0;2545 pThis->cbCommandParametersLeft = 0; 2546 2546 break; 2547 2547 } … … 2556 2556 case BUSLOGICCOMMAND_SET_TIME_OFF_BUS: 2557 2557 case BUSLOGICCOMMAND_SET_BUS_TRANSFER_RATE: 2558 p BusLogic->cbCommandParametersLeft = 1;2558 pThis->cbCommandParametersLeft = 1; 2559 2559 break; 2560 2560 case BUSLOGICCOMMAND_FETCH_HOST_ADAPTER_LOCAL_RAM: 2561 p BusLogic->cbCommandParametersLeft = 2;2561 pThis->cbCommandParametersLeft = 2; 2562 2562 break; 2563 2563 case BUSLOGICCOMMAND_READ_BUSMASTER_CHIP_FIFO: 2564 2564 case BUSLOGICCOMMAND_WRITE_BUSMASTER_CHIP_FIFO: 2565 p BusLogic->cbCommandParametersLeft = 3;2565 pThis->cbCommandParametersLeft = 3; 2566 2566 break; 2567 2567 case BUSLOGICCOMMAND_SET_SCSI_SELECTION_TIMEOUT: 2568 p BusLogic->cbCommandParametersLeft = 4;2568 pThis->cbCommandParametersLeft = 4; 2569 2569 break; 2570 2570 case BUSLOGICCOMMAND_INITIALIZE_MAILBOX: 2571 p BusLogic->cbCommandParametersLeft = sizeof(RequestInitMbx);2571 pThis->cbCommandParametersLeft = sizeof(RequestInitMbx); 2572 2572 break; 2573 2573 case BUSLOGICCOMMAND_INITIALIZE_EXTENDED_MAILBOX: 2574 2574 /* Some Adaptec drivers (ASPI4DOS.SYS) test this command. */ 2575 if (p BusLogic->uDevType == DEV_AHA_1540B)2575 if (pThis->uDevType == DEV_AHA_1540B) 2576 2576 { 2577 p BusLogic->cbCommandParametersLeft = 0;2577 pThis->cbCommandParametersLeft = 0; 2578 2578 break; 2579 2579 } 2580 p BusLogic->cbCommandParametersLeft = sizeof(RequestInitializeExtendedMailbox);2580 pThis->cbCommandParametersLeft = sizeof(RequestInitializeExtendedMailbox); 2581 2581 break; 2582 2582 case BUSLOGICCOMMAND_SET_ADAPTER_OPTIONS: 2583 2583 /* There must be at least one byte following this command. */ 2584 p BusLogic->cbCommandParametersLeft = 1;2584 pThis->cbCommandParametersLeft = 1; 2585 2585 break; 2586 2586 case BUSLOGICCOMMAND_EXECUTE_SCSI_COMMAND: 2587 2587 /* 12 bytes + variable-length CDB. */ 2588 p BusLogic->cbCommandParametersLeft = 12;2588 pThis->cbCommandParametersLeft = 12; 2589 2589 break; 2590 2590 case BUSLOGICCOMMAND_EXT_BIOS_INFO: 2591 2591 case BUSLOGICCOMMAND_UNLOCK_MAILBOX: 2592 2592 /* Invalid commands. */ 2593 p BusLogic->cbCommandParametersLeft = 0;2593 pThis->cbCommandParametersLeft = 0; 2594 2594 break; 2595 2595 case BUSLOGICCOMMAND_EXECUTE_MAILBOX_COMMAND: /* Should not come here anymore. */ … … 2602 2602 #ifndef IN_RING3 2603 2603 /* This command must be executed in R3 as it rehooks the ISA I/O port. */ 2604 if (p BusLogic->uOperationCode == BUSLOGICCOMMAND_MODIFY_IO_ADDRESS)2604 if (pThis->uOperationCode == BUSLOGICCOMMAND_MODIFY_IO_ADDRESS) 2605 2605 { 2606 2606 rc = VINF_IOM_R3_IOPORT_WRITE; … … 2614 2614 * function. 2615 2615 */ 2616 p BusLogic->aCommandBuffer[pBusLogic->iParameter] = uVal;2617 p BusLogic->iParameter++;2618 p BusLogic->cbCommandParametersLeft--;2616 pThis->aCommandBuffer[pThis->iParameter] = uVal; 2617 pThis->iParameter++; 2618 pThis->cbCommandParametersLeft--; 2619 2619 } 2620 2620 2621 2621 /* Start execution of command if there are no parameters left. */ 2622 if (!p BusLogic->cbCommandParametersLeft)2622 if (!pThis->cbCommandParametersLeft) 2623 2623 { 2624 rc = buslogicProcessCommand(pDevIns, p BusLogic);2624 rc = buslogicProcessCommand(pDevIns, pThis); 2625 2625 AssertMsgRC(rc, ("Processing command failed rc=%Rrc\n", rc)); 2626 2626 } … … 2632 2632 */ 2633 2633 case BUSLOGIC_REGISTER_INTERRUPT: 2634 if (p BusLogic->uDevType == DEV_AHA_1540B)2634 if (pThis->uDevType == DEV_AHA_1540B) 2635 2635 break; 2636 p BusLogic->regInterrupt = uVal;2636 pThis->regInterrupt = uVal; 2637 2637 break; 2638 2638 2639 2639 case BUSLOGIC_REGISTER_GEOMETRY: 2640 if (p BusLogic->uDevType == DEV_AHA_1540B)2640 if (pThis->uDevType == DEV_AHA_1540B) 2641 2641 break; 2642 p BusLogic->regGeometry = uVal;2642 pThis->regGeometry = uVal; 2643 2643 break; 2644 2644 … … 2681 2681 buslogicIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 2682 2682 { 2683 PBUSLOGIC p BusLogic= PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);2683 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 2684 2684 unsigned iRegister = offPort % 4; 2685 2685 RT_NOREF(pvUser, cb); … … 2687 2687 ASSERT_GUEST(cb == 1); 2688 2688 2689 return buslogicRegisterRead(pDevIns, p BusLogic, iRegister, pu32);2689 return buslogicRegisterRead(pDevIns, pThis, iRegister, pu32); 2690 2690 } 2691 2691 … … 2696 2696 buslogicIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 2697 2697 { 2698 PBUSLOGIC p BusLogic= PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);2698 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 2699 2699 unsigned iRegister = offPort % 4; 2700 2700 RT_NOREF(pvUser, cb); … … 2702 2702 ASSERT_GUEST(cb == 1); 2703 2703 2704 int rc = buslogicRegisterWrite(pDevIns, p BusLogic, iRegister, (uint8_t)u32);2704 int rc = buslogicRegisterWrite(pDevIns, pThis, iRegister, (uint8_t)u32); 2705 2705 2706 2706 Log2(("#%d %s: pvUser=%#p cb=%d u32=%#x offPort=%#x rc=%Rrc\n", … … 2877 2877 * @returns nothing. 2878 2878 * @param pDevIns The device instance. 2879 * @param p BusLogicPointer to the shared BusLogic instance data.2879 * @param pThis Pointer to the shared BusLogic instance data. 2880 2880 * @param uBaseCode Encoded ISA I/O base; only low 3 bits are used. 2881 2881 */ 2882 static int buslogicR3RegisterISARange(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, uint8_t uBaseCode)2882 static int buslogicR3RegisterISARange(PPDMDEVINS pDevIns, PBUSLOGIC pThis, uint8_t uBaseCode) 2883 2883 { 2884 2884 uint8_t uCode = uBaseCode & MAX_ISA_BASE; … … 2889 2889 2890 2890 /* Check if the same port range actually changed. */ 2891 if (uNewBase != p BusLogic->IOISABase)2891 if (uNewBase != pThis->IOISABase) 2892 2892 { 2893 2893 /* Unmap the old range, if necessary. */ 2894 if (p BusLogic->IOISABase)2895 { 2896 rc = PDMDevHlpIoPortUnmap(pDevIns, p BusLogic->hIoPortsIsa);2894 if (pThis->IOISABase) 2895 { 2896 rc = PDMDevHlpIoPortUnmap(pDevIns, pThis->hIoPortsIsa); 2897 2897 AssertRC(rc); 2898 2898 } 2899 2899 if (RT_SUCCESS(rc)) 2900 2900 { 2901 p BusLogic->IOISABase = 0; /* First mark as unregistered. */2902 p BusLogic->uISABaseCode = ISA_BASE_DISABLED;2901 pThis->IOISABase = 0; /* First mark as unregistered. */ 2902 pThis->uISABaseCode = ISA_BASE_DISABLED; 2903 2903 2904 2904 if (uNewBase) 2905 2905 { 2906 2906 /* Register the new range if requested. */ 2907 rc = PDMDevHlpIoPortMap(pDevIns, p BusLogic->hIoPortsIsa, uNewBase);2907 rc = PDMDevHlpIoPortMap(pDevIns, pThis->hIoPortsIsa, uNewBase); 2908 2908 if (RT_SUCCESS(rc)) 2909 2909 { 2910 p BusLogic->IOISABase = uNewBase;2911 p BusLogic->uISABaseCode = uCode;2910 pThis->IOISABase = uNewBase; 2911 pThis->uISABaseCode = uCode; 2912 2912 } 2913 2913 } … … 3134 3134 } 3135 3135 3136 static int buslogicR3DeviceSCSIRequestSetup(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, PBUSLOGICCC pThisCC, RTGCPHYS GCPhysAddrCCB)3136 static int buslogicR3DeviceSCSIRequestSetup(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PBUSLOGICCC pThisCC, RTGCPHYS GCPhysAddrCCB) 3137 3137 { 3138 3138 int rc = VINF_SUCCESS; … … 3145 3145 &CCBGuest, sizeof(CCB32)); 3146 3146 3147 uTargetIdCCB = p BusLogic->fMbxIs24Bit ? CCBGuest.o.uTargetId : CCBGuest.n.uTargetId;3147 uTargetIdCCB = pThis->fMbxIs24Bit ? CCBGuest.o.uTargetId : CCBGuest.n.uTargetId; 3148 3148 if (RT_LIKELY(uTargetIdCCB < RT_ELEMENTS(pThisCC->aDeviceStates))) 3149 3149 { … … 3151 3151 3152 3152 #ifdef LOG_ENABLED 3153 buslogicR3DumpCCBInfo(&CCBGuest, p BusLogic->fMbxIs24Bit);3153 buslogicR3DumpCCBInfo(&CCBGuest, pThis->fMbxIs24Bit); 3154 3154 #endif 3155 3155 … … 3167 3167 pReq->fBIOS = false; 3168 3168 pReq->hIoReq = hIoReq; 3169 pReq->fIs24Bit = p BusLogic->fMbxIs24Bit;3169 pReq->fIs24Bit = pThis->fMbxIs24Bit; 3170 3170 3171 3171 /* Make a copy of the CCB */ … … 3199 3199 &pReq->u8ScsiSts, 30 * RT_MS_1SEC); 3200 3200 if (rc != VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS) 3201 buslogicR3ReqComplete(pDevIns, p BusLogic, pThisCC, pReq, rc);3201 buslogicR3ReqComplete(pDevIns, pThis, pThisCC, pReq, rc); 3202 3202 } 3203 3203 else 3204 buslogicR3SendIncomingMailbox(pDevIns, p BusLogic, GCPhysAddrCCB, &CCBGuest,3204 buslogicR3SendIncomingMailbox(pDevIns, pThis, GCPhysAddrCCB, &CCBGuest, 3205 3205 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_SCSI_SELECTION_TIMEOUT, 3206 3206 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD, … … 3208 3208 } 3209 3209 else 3210 buslogicR3SendIncomingMailbox(pDevIns, p BusLogic, GCPhysAddrCCB, &CCBGuest,3210 buslogicR3SendIncomingMailbox(pDevIns, pThis, GCPhysAddrCCB, &CCBGuest, 3211 3211 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_SCSI_SELECTION_TIMEOUT, 3212 3212 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD, … … 3214 3214 } 3215 3215 else 3216 buslogicR3SendIncomingMailbox(pDevIns, p BusLogic, GCPhysAddrCCB, &CCBGuest,3216 buslogicR3SendIncomingMailbox(pDevIns, pThis, GCPhysAddrCCB, &CCBGuest, 3217 3217 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_INVALID_COMMAND_PARAMETER, 3218 3218 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD, … … 3222 3222 } 3223 3223 3224 static int buslogicR3DeviceSCSIRequestAbort(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, RTGCPHYS GCPhysAddrCCB)3224 static int buslogicR3DeviceSCSIRequestAbort(PPDMDEVINS pDevIns, PBUSLOGIC pThis, RTGCPHYS GCPhysAddrCCB) 3225 3225 { 3226 3226 uint8_t uTargetIdCCB; … … 3230 3230 &CCBGuest, sizeof(CCB32)); 3231 3231 3232 uTargetIdCCB = p BusLogic->fMbxIs24Bit ? CCBGuest.o.uTargetId : CCBGuest.n.uTargetId;3233 if (RT_LIKELY(uTargetIdCCB < RT_ELEMENTS(p BusLogic->afDevicePresent)))3234 buslogicR3SendIncomingMailbox(pDevIns, p BusLogic, 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, 3235 3235 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_ABORT_QUEUE_GENERATED, 3236 3236 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD, 3237 3237 BUSLOGIC_MAILBOX_INCOMING_COMPLETION_ABORTED_NOT_FOUND); 3238 3238 else 3239 buslogicR3SendIncomingMailbox(pDevIns, p BusLogic, GCPhysAddrCCB, &CCBGuest,3239 buslogicR3SendIncomingMailbox(pDevIns, pThis, GCPhysAddrCCB, &CCBGuest, 3240 3240 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_INVALID_COMMAND_PARAMETER, 3241 3241 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD, … … 3250 3250 * 3251 3251 * @returns Mailbox guest physical address. 3252 * @param pDevIns 3253 * @param p BusLogicPointer to the shared BusLogic instance data.3254 * @param pMbx 3255 */ 3256 static RTGCPHYS buslogicR3ReadOutgoingMailbox(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, 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 */ 3256 static RTGCPHYS buslogicR3ReadOutgoingMailbox(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PMailbox32 pMbx) 3257 3257 { 3258 3258 RTGCPHYS GCMailbox; 3259 3259 3260 if (p BusLogic->fMbxIs24Bit)3260 if (pThis->fMbxIs24Bit) 3261 3261 { 3262 3262 Mailbox24 Mbx24; 3263 3263 3264 GCMailbox = p BusLogic->GCPhysAddrMailboxOutgoingBase + (pBusLogic->uMailboxOutgoingPositionCurrent * sizeof(Mailbox24));3264 GCMailbox = pThis->GCPhysAddrMailboxOutgoingBase + (pThis->uMailboxOutgoingPositionCurrent * sizeof(Mailbox24)); 3265 3265 PDMDevHlpPhysRead(pDevIns, GCMailbox, &Mbx24, sizeof(Mailbox24)); 3266 3266 pMbx->u32PhysAddrCCB = ADDR_TO_U32(Mbx24.aPhysAddrCCB); … … 3269 3269 else 3270 3270 { 3271 GCMailbox = p BusLogic->GCPhysAddrMailboxOutgoingBase + (pBusLogic->uMailboxOutgoingPositionCurrent * sizeof(Mailbox32));3271 GCMailbox = pThis->GCPhysAddrMailboxOutgoingBase + (pThis->uMailboxOutgoingPositionCurrent * sizeof(Mailbox32)); 3272 3272 PDMDevHlpPhysRead(pDevIns, GCMailbox, pMbx, sizeof(Mailbox32)); 3273 3273 } … … 3280 3280 * 3281 3281 * @returns VBox status code. 3282 * @param pDevIns 3283 * @param p BusLogicPointer to the shared BusLogic instance data.3284 * @param pThisCC 3285 */ 3286 static int buslogicR3ProcessMailboxNext(PPDMDEVINS pDevIns, PBUSLOGIC p BusLogic, 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 */ 3286 static int buslogicR3ProcessMailboxNext(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PBUSLOGICCC pThisCC) 3287 3287 { 3288 3288 RTGCPHYS GCPhysAddrMailboxCurrent; … … 3290 3290 int rc = VINF_SUCCESS; 3291 3291 3292 if (!p BusLogic->fStrictRoundRobinMode)3292 if (!pThis->fStrictRoundRobinMode) 3293 3293 { 3294 3294 /* Search for a filled mailbox - stop if we have scanned all mailboxes. */ 3295 uint8_t uMailboxPosCur = p BusLogic->uMailboxOutgoingPositionCurrent;3295 uint8_t uMailboxPosCur = pThis->uMailboxOutgoingPositionCurrent; 3296 3296 3297 3297 do 3298 3298 { 3299 3299 /* Fetch mailbox from guest memory. */ 3300 GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pDevIns, p BusLogic, &MailboxGuest);3300 GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pDevIns, pThis, &MailboxGuest); 3301 3301 3302 3302 /* Check the next mailbox. */ 3303 buslogicR3OutgoingMailboxAdvance(p BusLogic);3303 buslogicR3OutgoingMailboxAdvance(pThis); 3304 3304 } while ( MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_FREE 3305 && uMailboxPosCur != p BusLogic->uMailboxOutgoingPositionCurrent);3305 && uMailboxPosCur != pThis->uMailboxOutgoingPositionCurrent); 3306 3306 } 3307 3307 else 3308 3308 { 3309 3309 /* Fetch mailbox from guest memory. */ 3310 GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pDevIns, p BusLogic, &MailboxGuest);3310 GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pDevIns, pThis, &MailboxGuest); 3311 3311 } 3312 3312 … … 3323 3323 } 3324 3324 3325 LogFlow(("Got loaded mailbox at slot %u, CCB phys %RGp\n", p BusLogic->uMailboxOutgoingPositionCurrent, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB));3325 LogFlow(("Got loaded mailbox at slot %u, CCB phys %RGp\n", pThis->uMailboxOutgoingPositionCurrent, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB)); 3326 3326 #ifdef LOG_ENABLED 3327 3327 buslogicR3DumpMailboxInfo(&MailboxGuest, true); … … 3330 3330 /* We got the mailbox, mark it as free in the guest. */ 3331 3331 uint8_t uActionCode = BUSLOGIC_MAILBOX_OUTGOING_ACTION_FREE; 3332 unsigned uCodeOffs = p BusLogic->fMbxIs24Bit ? RT_OFFSETOF(Mailbox24, uCmdState) : RT_OFFSETOF(Mailbox32, u.out.uActionCode);3333 blPhysWrite(pDevIns, p BusLogic, 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)); 3334 3334 3335 3335 if (MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_START_COMMAND) 3336 rc = buslogicR3DeviceSCSIRequestSetup(pDevIns, p BusLogic, pThisCC, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB);3336 rc = buslogicR3DeviceSCSIRequestSetup(pDevIns, pThis, pThisCC, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB); 3337 3337 else if (MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_ABORT_COMMAND) 3338 3338 { 3339 3339 LogFlow(("Aborting mailbox\n")); 3340 rc = buslogicR3DeviceSCSIRequestAbort(pDevIns, p BusLogic, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB);3340 rc = buslogicR3DeviceSCSIRequestAbort(pDevIns, pThis, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB); 3341 3341 } 3342 3342 else … … 3346 3346 3347 3347 /* Advance to the next mailbox. */ 3348 if (p BusLogic->fStrictRoundRobinMode)3349 buslogicR3OutgoingMailboxAdvance(p BusLogic);3348 if (pThis->fStrictRoundRobinMode) 3349 buslogicR3OutgoingMailboxAdvance(pThis); 3350 3350 3351 3351 return rc; … … 3369 3369 static DECLCALLBACK(int) buslogicR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 3370 3370 { 3371 PBUSLOGIC p BusLogic= PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);3371 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 3372 3372 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3373 3373 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; … … 3388 3388 } 3389 3389 /* Now the main device state. */ 3390 pHlp->pfnSSMPutU8 (pSSM, p BusLogic->regStatus);3391 pHlp->pfnSSMPutU8 (pSSM, p BusLogic->regInterrupt);3392 pHlp->pfnSSMPutU8 (pSSM, p BusLogic->regGeometry);3393 pHlp->pfnSSMPutMem (pSSM, &p BusLogic->LocalRam, sizeof(pBusLogic->LocalRam));3394 pHlp->pfnSSMPutU8 (pSSM, p BusLogic->uOperationCode);3395 pHlp->pfnSSMPutMem (pSSM, &p BusLogic->aCommandBuffer, sizeof(pBusLogic->aCommandBuffer));3396 pHlp->pfnSSMPutU8 (pSSM, p BusLogic->iParameter);3397 pHlp->pfnSSMPutU8 (pSSM, p BusLogic->cbCommandParametersLeft);3398 pHlp->pfnSSMPutBool (pSSM, p BusLogic->fUseLocalRam);3399 pHlp->pfnSSMPutMem (pSSM, p BusLogic->aReplyBuffer, sizeof(pBusLogic->aReplyBuffer));3400 pHlp->pfnSSMPutU8 (pSSM, p BusLogic->iReply);3401 pHlp->pfnSSMPutU8 (pSSM, p BusLogic->cbReplyParametersLeft);3402 pHlp->pfnSSMPutBool (pSSM, p BusLogic->fIRQEnabled);3403 pHlp->pfnSSMPutU8 (pSSM, p BusLogic->uISABaseCode);3404 pHlp->pfnSSMPutU32 (pSSM, p BusLogic->cMailbox);3405 pHlp->pfnSSMPutBool (pSSM, p BusLogic->fMbxIs24Bit);3406 pHlp->pfnSSMPutGCPhys(pSSM, p BusLogic->GCPhysAddrMailboxOutgoingBase);3407 pHlp->pfnSSMPutU32 (pSSM, p BusLogic->uMailboxOutgoingPositionCurrent);3408 pHlp->pfnSSMPutU32 (pSSM, p BusLogic->cMailboxesReady);3409 pHlp->pfnSSMPutBool (pSSM, p BusLogic->fNotificationSent);3410 pHlp->pfnSSMPutGCPhys(pSSM, p BusLogic->GCPhysAddrMailboxIncomingBase);3411 pHlp->pfnSSMPutU32 (pSSM, p BusLogic->uMailboxIncomingPositionCurrent);3412 pHlp->pfnSSMPutBool (pSSM, p BusLogic->fStrictRoundRobinMode);3413 pHlp->pfnSSMPutBool (pSSM, p BusLogic->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); 3414 3414 3415 3415 vboxscsiR3SaveExec(pDevIns->pHlpR3, &pThisCC->VBoxSCSI, pSSM); … … 3489 3489 static DECLCALLBACK(int) buslogicR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 3490 3490 { 3491 PBUSLOGIC p BusLogic= PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);3492 PBUSLOGICCC pThisCC 3493 PCPDMDEVHLPR3 pHlp 3494 int rc 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; 3495 3495 3496 3496 /* We support saved states only from this and older versions. */ … … 3519 3519 3520 3520 /* Now the main device state. */ 3521 pHlp->pfnSSMGetU8V (pSSM, &p BusLogic->regStatus);3522 pHlp->pfnSSMGetU8V (pSSM, &p BusLogic->regInterrupt);3523 pHlp->pfnSSMGetU8V (pSSM, &p BusLogic->regGeometry);3524 pHlp->pfnSSMGetMem (pSSM, &p BusLogic->LocalRam, sizeof(pBusLogic->LocalRam));3525 pHlp->pfnSSMGetU8 (pSSM, &p BusLogic->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); 3526 3526 if (uVersion > BUSLOGIC_SAVED_STATE_MINOR_PRE_CMDBUF_RESIZE) 3527 pHlp->pfnSSMGetMem(pSSM, &p BusLogic->aCommandBuffer, sizeof(pBusLogic->aCommandBuffer));3527 pHlp->pfnSSMGetMem(pSSM, &pThis->aCommandBuffer, sizeof(pThis->aCommandBuffer)); 3528 3528 else 3529 pHlp->pfnSSMGetMem(pSSM, &p BusLogic->aCommandBuffer, BUSLOGIC_COMMAND_SIZE_OLD);3530 pHlp->pfnSSMGetU8 (pSSM, &p BusLogic->iParameter);3531 pHlp->pfnSSMGetU8 (pSSM, &p BusLogic->cbCommandParametersLeft);3532 pHlp->pfnSSMGetBool (pSSM, &p BusLogic->fUseLocalRam);3533 pHlp->pfnSSMGetMem (pSSM, p BusLogic->aReplyBuffer, sizeof(pBusLogic->aReplyBuffer));3534 pHlp->pfnSSMGetU8 (pSSM, &p BusLogic->iReply);3535 pHlp->pfnSSMGetU8 (pSSM, &p BusLogic->cbReplyParametersLeft);3536 pHlp->pfnSSMGetBool (pSSM, &p BusLogic->fIRQEnabled);3537 pHlp->pfnSSMGetU8 (pSSM, &p BusLogic->uISABaseCode);3538 pHlp->pfnSSMGetU32 (pSSM, &p BusLogic->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); 3539 3539 if (uVersion > BUSLOGIC_SAVED_STATE_MINOR_PRE_24BIT_MBOX) 3540 pHlp->pfnSSMGetBool(pSSM, &p BusLogic->fMbxIs24Bit);3541 pHlp->pfnSSMGetGCPhys(pSSM, &p BusLogic->GCPhysAddrMailboxOutgoingBase);3542 pHlp->pfnSSMGetU32 (pSSM, &p BusLogic->uMailboxOutgoingPositionCurrent);3543 pHlp->pfnSSMGetU32V (pSSM, &p BusLogic->cMailboxesReady);3544 pHlp->pfnSSMGetBoolV (pSSM, &p BusLogic->fNotificationSent);3545 pHlp->pfnSSMGetGCPhys(pSSM, &p BusLogic->GCPhysAddrMailboxIncomingBase);3546 pHlp->pfnSSMGetU32 (pSSM, &p BusLogic->uMailboxIncomingPositionCurrent);3547 pHlp->pfnSSMGetBool (pSSM, &p BusLogic->fStrictRoundRobinMode);3548 pHlp->pfnSSMGetBool (pSSM, &p BusLogic->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); 3549 3549 3550 3550 rc = vboxscsiR3LoadExec(pDevIns->pHlpR3, &pThisCC->VBoxSCSI, pSSM); … … 4080 4080 { 4081 4081 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); 4082 PBUSLOGIC 4082 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 4083 4083 4084 4084 PDMDevHlpCritSectDelete(pDevIns, &pThis->CritSectIntr);
Note:
See TracChangeset
for help on using the changeset viewer.