Changeset 81828 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- Nov 13, 2019 3:30:50 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevBusLogic.cpp
r81812 r81828 95 95 typedef struct BUSLOGICDEVICE 96 96 { 97 /** Pointer to the owning buslogic device instance. - R3 pointer */ 98 R3PTRTYPE(struct BUSLOGIC *) pBusLogicR3; 99 /** Pointer to the owning buslogic device instance. - R0 pointer */ 100 R0PTRTYPE(struct BUSLOGIC *) pBusLogicR0; 101 /** Pointer to the owning buslogic device instance. - RC pointer */ 102 RCPTRTYPE(struct BUSLOGIC *) pBusLogicRC; 97 /** The ring-3 device instance (for getting our bearings when arriving in an 98 * interface method). */ 99 PPDMDEVINSR3 pDevIns; 103 100 104 101 /** LUN of the device. */ 105 102 uint32_t iLUN; 106 103 107 /** Flag whether device is present. */ 104 /** Flag whether device is present. 105 * @note This is mirrored in BUSLOGIC::afDevicePresent. */ 108 106 bool fPresent; 109 bool afAlignment[ HC_ARCH_BITS == 64 ? 3 : 7];107 bool afAlignment[3]; 110 108 111 109 /** Our base interface. */ … … 327 325 /** 328 326 * The shared BusLogic device emulation state. 329 *330 * @implements PDMILEDPORTS331 327 */ 332 328 typedef struct BUSLOGIC 333 329 { 334 /** Pointer to the device instance - HC ptr */335 PPDMDEVINSR3 pDevInsR3;336 /** Pointer to the device instance - R0 ptr */337 PPDMDEVINSR0 pDevInsR0;338 /** Pointer to the device instance - RC ptr. */339 PPDMDEVINSRC pDevInsRC;340 341 /** Whether R0 is enabled. */342 bool fR0Enabled;343 /** Whether RC is enabled. */344 bool fGCEnabled;345 bool afPadding[2];346 347 330 /** Status register - Readonly. */ 348 331 volatile uint8_t regStatus; … … 354 337 uint8_t uPendingIntr; 355 338 356 /** Local RAM for the fetch hostadapter local RAM request.357 * I don't know how big the buffer really is but the maximum358 * seems to be 256 bytes because the offset and count field in the command request359 * are only one byte big.360 */361 HostAdapterLocalRam LocalRam;362 363 339 /** Command code the guest issued. */ 364 340 uint8_t uOperationCode; 365 /** Buffer for the command parameters the adapter is currently receiving from the guest.366 * Size of the largest command which is possible.367 */368 uint8_t aCommandBuffer[BUSLOGIC_COMMAND_SIZE_MAX]; /* Size of the biggest request. */369 341 /** Current position in the command buffer. */ 370 342 uint8_t iParameter; 371 343 /** Parameters left until the command is complete. */ 372 344 uint8_t cbCommandParametersLeft; 373 374 /** Whether we are using the RAM or reply buffer. */ 375 bool fUseLocalRam; 376 /** Buffer to store reply data from the controller to the guest. */ 377 uint8_t aReplyBuffer[BUSLOGIC_REPLY_SIZE_MAX]; /* Size of the biggest reply. */ 378 /** Position in the buffer we are reading next. */ 345 /** Buffer for the command parameters the adapter is currently receiving from the guest. 346 * Size of the largest command which is possible. */ 347 uint8_t aCommandBuffer[BUSLOGIC_COMMAND_SIZE_MAX]; /* Size of the biggest request. */ 348 349 /** Only for LOG_ENABLED builds! */ 350 volatile uint32_t cInMailboxesReadyIfLogEnabled; 351 352 /** Position in the buffer we are reading next. 353 * @note aligned on 64 byte boundrary for cache-line mojo. Means IOISABase 354 * is at offset 130. */ 379 355 uint8_t iReply; 380 356 /** Bytes left until the reply buffer is empty. */ 381 357 uint8_t cbReplyParametersLeft; 358 /** Buffer to store reply data from the controller to the guest. */ 359 uint8_t aReplyBuffer[BUSLOGIC_REPLY_SIZE_MAX]; /* Size of the biggest reply. */ 360 361 /** ISA I/O port base (disabled if zero). */ 362 RTIOPORT IOISABase; 363 /** Default ISA I/O port base in FW-compatible format. */ 364 uint8_t uDefaultISABaseCode; 365 /** Emulated device type. */ 366 uint8_t uDevType; 367 368 /** Signature index for Adaptec models. */ 369 uint8_t uAhaSigIdx; 370 371 /** Whether we are using the RAM or reply buffer. */ 372 bool fUseLocalRam; 382 373 383 374 /** Flag whether IRQs are enabled. */ … … 390 381 uint8_t uIsaIrq; 391 382 392 /** ISA I/O port base (disabled if zero). */393 RTIOPORT IOISABase;394 /** Default ISA I/O port base in FW-compatible format. */395 uint8_t uDefaultISABaseCode;396 /** Emulated device type. */397 uint8_t uDevType;398 399 /** Signature index for Adaptec models. */400 uint8_t uAhaSigIdx;401 uint8_t Alignment[7];402 403 383 /** Number of mailboxes the guest set up. */ 404 384 uint32_t cMailbox; 405 385 406 #if HC_ARCH_BITS == 64 407 uint32_t Alignment0; 408 #endif 409 410 /** Time when HBA reset was last initiated. */ /**< @todo does this need to be saved? */ 411 uint64_t u64ResetTime; 386 /** Time when HBA reset was last initiated. */ 387 uint64_t u64ResetTime; /**< @todo does this need to be saved? */ 412 388 /** Physical base address of the outgoing mailboxes. */ 413 389 RTGCPHYS GCPhysAddrMailboxOutgoingBase; … … 419 395 volatile bool fNotificationSent; 420 396 421 #if HC_ARCH_BITS == 64422 uint32_t Alignment1;423 #endif424 425 /** Physical base address of the incoming mailboxes. */426 RTGCPHYS GCPhysAddrMailboxIncomingBase;427 /** Current incoming mailbox position. */428 uint32_t uMailboxIncomingPositionCurrent;429 430 397 /** Whether strict round robin is enabled. */ 431 398 bool fStrictRoundRobinMode; 432 399 /** Whether the extended LUN CCB format is enabled for 32 possible logical units. */ 433 400 bool fExtendedLunCCBFormat; 434 bool afAlignment2[2]; 401 bool fAlignment2; 402 403 /** Current incoming mailbox position. */ 404 uint32_t uMailboxIncomingPositionCurrent; 405 /** Physical base address of the incoming mailboxes. */ 406 RTGCPHYS GCPhysAddrMailboxIncomingBase; 435 407 436 408 /** Critical section protecting access to the interrupt status register. */ 437 409 PDMCRITSECT CritSectIntr; 410 411 /** Device presence indicators. 412 * @note Copy of BUSLOGICDEVICE::fPresent accessible from ring-0. */ 413 bool afDevicePresent[BUSLOGIC_MAX_DEVICES]; 414 415 /** The event semaphore the processing thread waits on. */ 416 SUPSEMEVENT hEvtProcess; 417 418 /** ISA compatibility I/O ports. */ 419 IOMIOPORTHANDLE hIoPortsIsa; 420 /** BIOS I/O ports for booting, optional. */ 421 IOMIOPORTHANDLE hIoPortsBios; 422 /** PCI Region \#0: I/O ports. */ 423 IOMIOPORTHANDLE hIoPortsPci; 424 /** PCI Region \#1: MMIO (32 bytes, but probably rounded up to 4KB). */ 425 IOMMMIOHANDLE hMmio; 426 427 /** Local RAM for the fetch hostadapter local RAM request. 428 * I don't know how big the buffer really is but the maximum 429 * seems to be 256 bytes because the offset and count field in the command request 430 * are only one byte big. 431 */ 432 HostAdapterLocalRam LocalRam; 433 } BUSLOGIC; 434 /** Pointer to the shared BusLogic device emulation state. */ 435 typedef BUSLOGIC *PBUSLOGIC; 436 437 438 /** 439 * The ring-3 BusLogic device emulation state. 440 * 441 * @implements PDMILEDPORTS 442 */ 443 typedef struct BUSLOGICR3 444 { 445 /** The device instance - only for getting our bearings in interface methods. */ 446 PPDMDEVINSR3 pDevIns; 438 447 439 448 /** Device state for BIOS access. */ … … 453 462 R3PTRTYPE(PPDMIMEDIANOTIFY) pMediaNotify; 454 463 455 #if HC_ARCH_BITS == 64456 uint32_t Alignment3;457 #endif458 459 464 /** Indicates that PDMDevHlpAsyncNotificationCompleted should be called when 460 465 * a port is entering the idle state. */ … … 468 473 /** Worker thread. */ 469 474 R3PTRTYPE(PPDMTHREAD) pThreadWrk; 470 /** The event semaphore the processing thread waits on. */471 SUPSEMEVENT hEvtProcess;472 475 473 476 /** Pointer to the array of addresses to redo. */ … … 475 478 /** Number of addresses the redo array holds. */ 476 479 uint32_t cReqsRedo; 477 478 #ifdef LOG_ENABLED 479 volatile uint32_t cInMailboxesReady; 480 #else 481 # if HC_ARCH_BITS == 64 482 uint32_t Alignment4; 483 # endif 484 #endif 485 486 /** ISA compatibility I/O ports. */ 487 IOMIOPORTHANDLE hIoPortsIsa; 488 /** BIOS I/O ports for booting, optional. */ 489 IOMIOPORTHANDLE hIoPortsBios; 490 /** PCI Region \#0: I/O ports. */ 491 IOMIOPORTHANDLE hIoPortsPci; 492 /** PCI Region \#1: MMIO (32 bytes, but probably rounded up to 4KB). */ 493 IOMMMIOHANDLE hMmio; 494 } BUSLOGIC; 495 /** Pointer to the shared BusLogic device emulation state. */ 496 typedef BUSLOGIC *PBUSLOGIC; 480 } BUSLOGICR3; 481 /** Pointer to the ring-3 BusLogic device emulation state. */ 482 typedef BUSLOGICR3 *PBUSLOGICR3; 483 484 485 /** 486 * The ring-0 BusLogic device emulation state. 487 */ 488 typedef struct BUSLOGICR0 489 { 490 uint64_t uUnused; 491 } BUSLOGICR0; 492 /** Pointer to the ring-0 BusLogic device emulation state. */ 493 typedef BUSLOGICR0 *PBUSLOGICR0; 494 495 496 /** 497 * The raw-mode BusLogic device emulation state. 498 */ 499 typedef struct BUSLOGICRC 500 { 501 uint64_t uUnused; 502 } BUSLOGICRC; 503 /** Pointer to the raw-mode BusLogic device emulation state. */ 504 typedef BUSLOGICRC *PBUSLOGICRC; 505 506 507 /** The current context BusLogic device emulation state. */ 508 typedef CTX_SUFF(BUSLOGIC) BUSLOGICCC; 509 /** Pointer to the current context BusLogic device emulation state. */ 510 typedef CTX_SUFF(PBUSLOGIC) PBUSLOGICCC; 497 511 498 512 … … 991 1005 * 992 1006 * @returns nothing. 993 * @param pThis The BusLogic controller instance. 994 * @param GCPhys The guest physical address of the memory buffer. 995 * @param pSgBuf The pointer to the host R3 S/G buffer. 996 * @param cbCopy How many bytes to copy between the two buffers. 997 * @param pcbSkip Initially contains the amount of bytes to skip 998 * starting from the guest physical address before 999 * accessing the S/G buffer and start copying data. 1000 * On return this contains the remaining amount if 1001 * cbCopy < *pcbSkip or 0 otherwise. 1002 */ 1003 typedef DECLCALLBACK(void) BUSLOGICR3MEMCOPYCALLBACK(PBUSLOGIC pThis, RTGCPHYS GCPhys, PRTSGBUF pSgBuf, size_t cbCopy, 1004 size_t *pcbSkip); 1007 * @param pDevIns The device instance. 1008 * @param pThis The BusLogic controller instance. 1009 * @param GCPhys The guest physical address of the memory buffer. 1010 * @param pSgBuf The pointer to the host R3 S/G buffer. 1011 * @param cbCopy How many bytes to copy between the two buffers. 1012 * @param pcbSkip Initially contains the amount of bytes to skip 1013 * starting from the guest physical address before 1014 * accessing the S/G buffer and start copying data. 1015 * On return this contains the remaining amount if 1016 * cbCopy < *pcbSkip or 0 otherwise. 1017 */ 1018 typedef DECLCALLBACK(void) FNBUSLOGICR3MEMCOPYCALLBACK(PPDMDEVINS pDevIns, PBUSLOGIC pThis, RTGCPHYS GCPhys, 1019 PRTSGBUF pSgBuf, size_t cbCopy, size_t *pcbSkip); 1005 1020 /** Pointer to a memory copy buffer callback. */ 1006 typedef BUSLOGICR3MEMCOPYCALLBACK *PBUSLOGICR3MEMCOPYCALLBACK;1021 typedef FNBUSLOGICR3MEMCOPYCALLBACK *PFNBUSLOGICR3MEMCOPYCALLBACK; 1007 1022 #endif 1008 1023 … … 1022 1037 * 1023 1038 * @returns nothing. 1024 * @param pBusLogic Pointer to the BusLogic device instance. 1039 * @param pDevIns The device instance. 1040 * @param pBusLogic Pointer to the shared BusLogic instance data. 1025 1041 * @param fSuppressIrq Flag to suppress IRQ generation regardless of fIRQEnabled 1026 1042 * @param uIrqType Type of interrupt being generated. 1027 1043 */ 1028 static void buslogicSetInterrupt(P BUSLOGIC pBusLogic, bool fSuppressIrq, uint8_t uIrqType)1044 static void buslogicSetInterrupt(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, bool fSuppressIrq, uint8_t uIrqType) 1029 1045 { 1030 1046 LogFlowFunc(("pBusLogic=%#p\n", pBusLogic)); … … 1051 1067 { 1052 1068 if (!pBusLogic->uIsaIrq) 1053 PDMDevHlpPCISetIrq(p BusLogic->CTX_SUFF(pDevIns), 0, 1);1069 PDMDevHlpPCISetIrq(pDevIns, 0, 1); 1054 1070 else 1055 PDMDevHlpISASetIrq(p BusLogic->CTX_SUFF(pDevIns), pBusLogic->uIsaIrq, 1);1071 PDMDevHlpISASetIrq(pDevIns, pBusLogic->uIsaIrq, 1); 1056 1072 } 1057 1073 } … … 1061 1077 * 1062 1078 * @returns nothing. 1063 * @param pBusLogic Pointer to the BusLogic device instance. 1064 */ 1065 static void buslogicClearInterrupt(PBUSLOGIC pBusLogic) 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) 1066 1083 { 1067 1084 LogFlowFunc(("pBusLogic=%#p, clearing %#02x (pending %#02x)\n", … … 1070 1087 pBusLogic->regStatus &= ~BL_STAT_CMDINV; 1071 1088 if (!pBusLogic->uIsaIrq) 1072 PDMDevHlpPCISetIrq(p BusLogic->CTX_SUFF(pDevIns), 0, 0);1089 PDMDevHlpPCISetIrq(pDevIns, 0, 0); 1073 1090 else 1074 PDMDevHlpISASetIrq(p BusLogic->CTX_SUFF(pDevIns), pBusLogic->uIsaIrq, 0);1091 PDMDevHlpISASetIrq(pDevIns, pBusLogic->uIsaIrq, 0); 1075 1092 /* If there's another pending interrupt, report it now. */ 1076 1093 if (pBusLogic->uPendingIntr) 1077 1094 { 1078 buslogicSetInterrupt(p BusLogic, false, pBusLogic->uPendingIntr);1095 buslogicSetInterrupt(pDevIns, pBusLogic, false, pBusLogic->uPendingIntr); 1079 1096 pBusLogic->uPendingIntr = 0; 1080 1097 } … … 1127 1144 * 1128 1145 * @returns VBox status code. 1129 * @param pBusLogic Pointer to the BusLogic device instance. 1130 * @param fResetIO Flag determining whether ISA I/O should be reset. 1131 */ 1132 static int buslogicR3HwReset(PBUSLOGIC pBusLogic, bool fResetIO) 1146 * @param pDevIns The device instance. 1147 * @param pBusLogic Pointer to the shared BusLogic instance data. 1148 * @param pThisCC Pointer to the ring-3 BusLogic instance data. 1149 * @param fResetIO Flag determining whether ISA I/O should be reset. 1150 */ 1151 static int buslogicR3HwReset(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, PBUSLOGICCC pThisCC, bool fResetIO) 1133 1152 { 1134 1153 LogFlowFunc(("pBusLogic=%#p\n", pBusLogic)); … … 1149 1168 /* Clear any active/pending interrupts. */ 1150 1169 pBusLogic->uPendingIntr = 0; 1151 buslogicClearInterrupt(p BusLogic);1170 buslogicClearInterrupt(pDevIns, pBusLogic); 1152 1171 1153 1172 /* Guest-initiated HBA reset does not affect ISA port I/O. */ 1154 1173 if (fResetIO) 1155 buslogicR3RegisterISARange(p BusLogic->CTX_SUFF(pDevIns), pBusLogic, pBusLogic->uDefaultISABaseCode);1174 buslogicR3RegisterISARange(pDevIns, pBusLogic, pBusLogic->uDefaultISABaseCode); 1156 1175 buslogicR3InitializeLocalRam(pBusLogic); 1157 vboxscsiInitialize(&p BusLogic->VBoxSCSI);1176 vboxscsiInitialize(&pThisCC->VBoxSCSI); 1158 1177 1159 1178 return VINF_SUCCESS; … … 1166 1185 * 1167 1186 * @returns nothing. 1168 * @param pBusLogic Pointer to the BusLogic device instance 1187 * @param pDevIns The device instance. 1188 * @param pBusLogic Pointer to the shared BusLogic instance data. 1169 1189 * @param fSuppressIrq Flag to suppress IRQ generation regardless of current state 1170 1190 */ 1171 static void buslogicCommandComplete(P BUSLOGIC pBusLogic, bool fSuppressIrq)1191 static void buslogicCommandComplete(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, bool fSuppressIrq) 1172 1192 { 1173 1193 LogFlowFunc(("pBusLogic=%#p\n", pBusLogic)); … … 1183 1203 /* Notify that the command is complete. */ 1184 1204 pBusLogic->regStatus &= ~BL_STAT_DIRRDY; 1185 buslogicSetInterrupt(p BusLogic, fSuppressIrq, BL_INTR_CMDC);1205 buslogicSetInterrupt(pDevIns, pBusLogic, fSuppressIrq, BL_INTR_CMDC); 1186 1206 } 1187 1207 … … 1194 1214 * 1195 1215 * @returns nothing. 1196 * @param pThis Pointer to the BusLogic device instance 1216 * @param pDevIns The device instance. 1217 * @param pThis Pointer to the shared BusLogic instance data. 1197 1218 * @param GCPhys Guest physical memory address 1198 1219 * @param pvBuf Host side buffer address 1199 1220 * @param cbWrite Number of bytes to write 1200 1221 */ 1201 static void blPhysWrite(P BUSLOGIC pThis, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)1222 static void blPhysWrite(PPDMDEVINS pDevIns, PBUSLOGIC pThis, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite) 1202 1223 { 1203 1224 if (!pThis->uIsaIrq) 1204 PDMDevHlpPCIPhysWrite(p This->CTX_SUFF(pDevIns), GCPhys, pvBuf, cbWrite);1225 PDMDevHlpPCIPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite); 1205 1226 else 1206 PDMDevHlpPhysWrite(p This->CTX_SUFF(pDevIns), GCPhys, pvBuf, cbWrite);1227 PDMDevHlpPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite); 1207 1228 } 1208 1229 … … 1213 1234 * 1214 1235 * @returns nothing 1215 * @param pBusLogic Pointer to the BusLogic device instance. 1236 * @param pDevIns The device instance. 1237 * @param pBusLogic Pointer to the shared BusLogic instance data. 1238 * @param pThisCC Pointer to the ring-3 BusLogic instance data. 1216 1239 * @param fHardReset Flag initiating a hard (vs. soft) reset. 1217 1240 */ 1218 static void buslogicR3InitiateReset(P BUSLOGIC pBusLogic, bool fHardReset)1241 static void buslogicR3InitiateReset(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, PBUSLOGICCC pThisCC, bool fHardReset) 1219 1242 { 1220 1243 LogFlowFunc(("pBusLogic=%#p fHardReset=%d\n", pBusLogic, fHardReset)); 1221 1244 1222 buslogicR3HwReset(p BusLogic, false);1245 buslogicR3HwReset(pDevIns, pBusLogic, pThisCC, false); 1223 1246 1224 1247 if (fHardReset) … … 1229 1252 1230 1253 /* Remember when the guest initiated a reset (after we're done resetting). */ 1231 pBusLogic->u64ResetTime = PDMDevHlpTMTimeVirtGetNano(p BusLogic->CTX_SUFF(pDevIns));1254 pBusLogic->u64ResetTime = PDMDevHlpTMTimeVirtGetNano(pDevIns); 1232 1255 } 1233 1256 } … … 1238 1261 * 1239 1262 * @returns nothing. 1240 * @param pBusLogic Pointer to the BusLogic device instance. 1241 * @param GCPhysAddrCCB The physical guest address of the CCB the mailbox is for. 1242 * @param pCCBGuest The command control block. 1243 * @param uHostAdapterStatus The host adapter status code to set. 1244 * @param uDeviceStatus The target device status to set. 1245 * @param uMailboxCompletionCode Completion status code to set in the mailbox. 1246 */ 1247 static void buslogicR3SendIncomingMailbox(PBUSLOGIC pBusLogic, RTGCPHYS GCPhysAddrCCB, 1263 * @param pDevIns The device instance. 1264 * @param pBusLogic Pointer to the shared BusLogic instance data. 1265 * @param GCPhysAddrCCB The physical guest address of the CCB the mailbox is for. 1266 * @param pCCBGuest The command control block. 1267 * @param uHostAdapterStatus The host adapter status code to set. 1268 * @param uDeviceStatus The target device status to set. 1269 * @param uMailboxCompletionCode Completion status code to set in the mailbox. 1270 */ 1271 static void buslogicR3SendIncomingMailbox(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, RTGCPHYS GCPhysAddrCCB, 1248 1272 PCCBU pCCBGuest, uint8_t uHostAdapterStatus, 1249 1273 uint8_t uDeviceStatus, uint8_t uMailboxCompletionCode) … … 1256 1280 MbxIn.u.in.uCompletionCode = uMailboxCompletionCode; 1257 1281 1258 int rc = PDMDevHlpCritSectEnter(p BusLogic->CTX_SUFF(pDevIns), &pBusLogic->CritSectIntr, VINF_SUCCESS);1282 int rc = PDMDevHlpCritSectEnter(pDevIns, &pBusLogic->CritSectIntr, VINF_SUCCESS); 1259 1283 AssertRC(rc); 1260 1284 … … 1272 1296 pCCBGuest->c.uDeviceStatus = uDeviceStatus; 1273 1297 /* Rewrite CCB up to the CDB; perhaps more than necessary. */ 1274 blPhysWrite(p BusLogic, GCPhysAddrCCB, pCCBGuest, RT_UOFFSETOF(CCBC, abCDB));1298 blPhysWrite(pDevIns, pBusLogic, GCPhysAddrCCB, pCCBGuest, RT_UOFFSETOF(CCBC, abCDB)); 1275 1299 } 1276 1300 … … 1278 1302 uint8_t uCode; 1279 1303 unsigned uCodeOffs = pBusLogic->fMbxIs24Bit ? RT_OFFSETOF(Mailbox24, uCmdState) : RT_OFFSETOF(Mailbox32, u.out.uActionCode); 1280 PDMDevHlpPhysRead(p BusLogic->CTX_SUFF(pDevIns), GCPhysAddrMailboxIncoming + uCodeOffs, &uCode, sizeof(uCode));1304 PDMDevHlpPhysRead(pDevIns, GCPhysAddrMailboxIncoming + uCodeOffs, &uCode, sizeof(uCode)); 1281 1305 Assert(uCode == BUSLOGIC_MAILBOX_INCOMING_COMPLETION_FREE); 1282 1306 # endif … … 1290 1314 U32_TO_ADDR(Mbx24.aPhysAddrCCB, MbxIn.u32PhysAddrCCB); 1291 1315 Log(("24-bit mailbox: completion code=%u, CCB at %RGp\n", Mbx24.uCmdState, (RTGCPHYS)ADDR_TO_U32(Mbx24.aPhysAddrCCB))); 1292 blPhysWrite(p BusLogic, GCPhysAddrMailboxIncoming, &Mbx24, sizeof(Mailbox24));1316 blPhysWrite(pDevIns, pBusLogic, GCPhysAddrMailboxIncoming, &Mbx24, sizeof(Mailbox24)); 1293 1317 } 1294 1318 else 1295 1319 { 1296 1320 Log(("32-bit mailbox: completion code=%u, CCB at %RGp\n", MbxIn.u.in.uCompletionCode, GCPhysAddrCCB)); 1297 blPhysWrite(p BusLogic, GCPhysAddrMailboxIncoming, &MbxIn, sizeof(Mailbox32));1321 blPhysWrite(pDevIns, pBusLogic, GCPhysAddrMailboxIncoming, &MbxIn, sizeof(Mailbox32)); 1298 1322 } 1299 1323 … … 1304 1328 1305 1329 # ifdef LOG_ENABLED 1306 ASMAtomicIncU32(&pBusLogic->cInMailboxesReady );1330 ASMAtomicIncU32(&pBusLogic->cInMailboxesReadyIfLogEnabled); 1307 1331 # endif 1308 1332 1309 buslogicSetInterrupt(p BusLogic, false, BL_INTR_IMBL);1310 1311 PDMDevHlpCritSectLeave(p BusLogic->CTX_SUFF(pDevIns), &pBusLogic->CritSectIntr);1333 buslogicSetInterrupt(pDevIns, pBusLogic, false, BL_INTR_IMBL); 1334 1335 PDMDevHlpCritSectLeave(pDevIns, &pBusLogic->CritSectIntr); 1312 1336 } 1313 1337 … … 1497 1521 * Copy from guest to host memory worker. 1498 1522 * 1499 * @copydoc BUSLOGICR3MEMCOPYCALLBACK 1500 */ 1501 static DECLCALLBACK(void) buslogicR3CopyBufferFromGuestWorker(PBUSLOGIC pThis, RTGCPHYS GCPhys, PRTSGBUF pSgBuf, 1502 size_t cbCopy, size_t *pcbSkip) 1503 { 1523 * @copydoc FNBUSLOGICR3MEMCOPYCALLBACK 1524 */ 1525 static DECLCALLBACK(void) buslogicR3CopyBufferFromGuestWorker(PPDMDEVINS pDevIns, PBUSLOGIC pThis, RTGCPHYS GCPhys, 1526 PRTSGBUF pSgBuf, size_t cbCopy, size_t *pcbSkip) 1527 { 1528 RT_NOREF(pThis); 1529 1504 1530 size_t cbSkipped = RT_MIN(cbCopy, *pcbSkip); 1505 1531 cbCopy -= cbSkipped; … … 1513 1539 1514 1540 AssertPtr(pvSeg); 1515 PDMDevHlpPhysRead(p This->CTX_SUFF(pDevIns), GCPhys, pvSeg, cbSeg);1541 PDMDevHlpPhysRead(pDevIns, GCPhys, pvSeg, cbSeg); 1516 1542 GCPhys += cbSeg; 1517 1543 cbCopy -= cbSeg; … … 1522 1548 * Copy from host to guest memory worker. 1523 1549 * 1524 * @copydoc BUSLOGICR3MEMCOPYCALLBACK1525 */ 1526 static DECLCALLBACK(void) buslogicR3CopyBufferToGuestWorker(P BUSLOGIC pThis, RTGCPHYS GCPhys, PRTSGBUF pSgBuf,1527 size_t cbCopy, size_t *pcbSkip)1550 * @copydoc FNBUSLOGICR3MEMCOPYCALLBACK 1551 */ 1552 static DECLCALLBACK(void) buslogicR3CopyBufferToGuestWorker(PPDMDEVINS pDevIns, PBUSLOGIC pThis, RTGCPHYS GCPhys, 1553 PRTSGBUF pSgBuf, size_t cbCopy, size_t *pcbSkip) 1528 1554 { 1529 1555 size_t cbSkipped = RT_MIN(cbCopy, *pcbSkip); … … 1538 1564 1539 1565 AssertPtr(pvSeg); 1540 blPhysWrite(p This, GCPhys, pvSeg, cbSeg);1566 blPhysWrite(pDevIns, pThis, GCPhys, pvSeg, cbSeg); 1541 1567 GCPhys += cbSeg; 1542 1568 cbCopy -= cbSeg; … … 1548 1574 * 1549 1575 * @returns The amout of bytes actually copied. 1550 * @param pThis Pointer to the Buslogic device state. 1551 * @param pReq Pointe to the request state. 1552 * @param pfnCopyWorker The copy method to apply for each guest buffer. 1553 * @param pSgBuf The host S/G buffer. 1554 * @param cbSkip How many bytes to skip in advance before starting to copy. 1555 * @param cbCopy How many bytes to copy. 1556 */ 1557 static size_t buslogicR3SgBufWalker(PBUSLOGIC pThis, PBUSLOGICREQ pReq, 1558 PBUSLOGICR3MEMCOPYCALLBACK pfnCopyWorker, 1576 * @param pDevIns The device instance. 1577 * @param pThis Pointer to the Buslogic device state. 1578 * @param pReq Pointe to the request state. 1579 * @param pfnCopyWorker The copy method to apply for each guest buffer. 1580 * @param pSgBuf The host S/G buffer. 1581 * @param cbSkip How many bytes to skip in advance before starting to copy. 1582 * @param cbCopy How many bytes to copy. 1583 */ 1584 static size_t buslogicR3SgBufWalker(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PBUSLOGICREQ pReq, 1585 PFNBUSLOGICR3MEMCOPYCALLBACK pfnCopyWorker, 1559 1586 PRTSGBUF pSgBuf, size_t cbSkip, size_t cbCopy) 1560 1587 { 1561 PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);1562 1588 uint32_t cbDataCCB; 1563 1589 uint32_t u32PhysAddrCCB; … … 1629 1655 Log(("%s: GCPhysAddrDataBase=%RGp cbCopyThis=%zu\n", __FUNCTION__, GCPhysAddrDataBase, cbCopyThis)); 1630 1656 1631 pfnCopyWorker(p This, GCPhysAddrDataBase, pSgBuf, cbCopyThis, &cbSkip);1657 pfnCopyWorker(pDevIns, pThis, GCPhysAddrDataBase, pSgBuf, cbCopyThis, &cbSkip); 1632 1658 cbCopied += cbCopyThis; 1633 1659 cbCopy -= cbCopyThis; … … 1654 1680 1655 1681 /* Copy the data into the guest memory. */ 1656 pfnCopyWorker(p This, GCPhysAddrDataBase, pSgBuf, RT_MIN(cbDataCCB, cbCopy), &cbSkip);1682 pfnCopyWorker(pDevIns, pThis, GCPhysAddrDataBase, pSgBuf, RT_MIN(cbDataCCB, cbCopy), &cbSkip); 1657 1683 cbCopied += RT_MIN(cbDataCCB, cbCopy); 1658 1684 } … … 1666 1692 * 1667 1693 * @returns Amount of bytes copied to the guest. 1668 * @param p This The BusLogic controllerdevice instance.1669 * @param p Req Request structure.1670 * @param p SgBuf The S/G buffer to copy from.1671 * @param cbSkip How many bytes to skip in advance before starting to copy.1672 * @param cb Copy How many bytesto copy.1673 * /1674 static size_t buslogicR3CopySgBufToGuest(PBUSLOGIC pThis, PBUSLOGICREQ pReq, PRTSGBUF pSgBuf, 1675 size_t cbSkip, size_t cbCopy) 1676 { 1677 return buslogicR3SgBufWalker(pThis, pReq, buslogicR3CopyBufferToGuestWorker, 1678 1694 * @param pDevIns The device instance. 1695 * @param pThis Pointer to the shared BusLogic instance data. 1696 * @param pReq Request structure. 1697 * @param pSgBuf The S/G buffer to copy from. 1698 * @param cbSkip How many bytes to skip in advance before starting to copy. 1699 * @param cbCopy How many bytes to copy. 1700 */ 1701 static size_t buslogicR3CopySgBufToGuest(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PBUSLOGICREQ pReq, 1702 PRTSGBUF pSgBuf, size_t cbSkip, size_t cbCopy) 1703 { 1704 return buslogicR3SgBufWalker(pDevIns, pThis, pReq, buslogicR3CopyBufferToGuestWorker, pSgBuf, cbSkip, cbCopy); 1679 1705 } 1680 1706 … … 1683 1709 * 1684 1710 * @returns Amount of bytes copied from the guest. 1685 * @param p This The BusLogic controllerdevice instance.1686 * @param p Req Request structure.1687 * @param p SgBuf The S/G buffer to copy into.1688 * @param cbSkip How many bytes to skip in advance before starting to copy.1689 * @param cb Copy How many bytesto copy.1690 * /1691 static size_t buslogicR3CopySgBufFromGuest(PBUSLOGIC pThis, PBUSLOGICREQ pReq, PRTSGBUF pSgBuf, 1692 size_t cbSkip, size_t cbCopy) 1693 { 1694 return buslogicR3SgBufWalker(pThis, pReq, buslogicR3CopyBufferFromGuestWorker, 1695 1711 * @param pDevIns The device instance. 1712 * @param pThis Pointer to the shared BusLogic instance data. 1713 * @param pReq Request structure. 1714 * @param pSgBuf The S/G buffer to copy into. 1715 * @param cbSkip How many bytes to skip in advance before starting to copy. 1716 * @param cbCopy How many bytes to copy. 1717 */ 1718 static size_t buslogicR3CopySgBufFromGuest(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PBUSLOGICREQ pReq, 1719 PRTSGBUF pSgBuf, size_t cbSkip, size_t cbCopy) 1720 { 1721 return buslogicR3SgBufWalker(pDevIns, pThis, pReq, buslogicR3CopyBufferFromGuestWorker, pSgBuf, cbSkip, cbCopy); 1696 1722 } 1697 1723 … … 1726 1752 if (fCopy && cbSenseBuffer) 1727 1753 { 1728 PBUSLOGIC pThis = pReq->pTargetDevice->CTX_SUFF(pBusLogic); 1754 PPDMDEVINS pDevIns = pReq->pTargetDevice->pDevIns; 1755 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 1729 1756 RTGCPHYS GCPhysAddrSenseBuffer; 1730 1757 … … 1742 1769 1743 1770 Log3(("%s: sense buffer: %.*Rhxs\n", __FUNCTION__, cbSenseBuffer, pReq->pbSenseBuffer)); 1744 blPhysWrite(p This, GCPhysAddrSenseBuffer, pReq->pbSenseBuffer, cbSenseBuffer);1771 blPhysWrite(pDevIns, pThis, GCPhysAddrSenseBuffer, pReq->pbSenseBuffer, cbSenseBuffer); 1745 1772 } 1746 1773 … … 1777 1804 * @returns VBox status code. 1778 1805 * @param pDevIns The PDM device instance. 1779 * @param pBusLogic Pointer to the BusLogic device instance.1806 * @param pBusLogic Pointer to the shared BusLogic instance data. 1780 1807 */ 1781 1808 static int buslogicProcessCommand(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic) … … 1819 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. */ 1820 1847 Log(("ISA I/O for PCI (code %x)\n", pBusLogic->aCommandBuffer[0])); 1821 buslogicR3RegisterISARange(p BusLogic->CTX_SUFF(pDevIns), pBusLogic, pBusLogic->aCommandBuffer[0]);1848 buslogicR3RegisterISARange(pDevIns, pBusLogic, pBusLogic->aCommandBuffer[0]); 1822 1849 pBusLogic->cbReplyParametersLeft = 0; 1823 1850 fSuppressIrq = true; … … 2142 2169 for (int i = 0; i < 8; ++i) 2143 2170 { 2144 if (pBusLogic->a DeviceStates[i].fPresent)2171 if (pBusLogic->afDevicePresent[i]) 2145 2172 pBusLogic->aReplyBuffer[i] = 1; 2146 2173 } … … 2153 2180 for (int i = 0; i < 8; ++i) 2154 2181 { 2155 if (pBusLogic->a DeviceStates[i + 8].fPresent)2182 if (pBusLogic->afDevicePresent[i + 8]) 2156 2183 pBusLogic->aReplyBuffer[i] = 1; 2157 2184 } … … 2163 2190 uint16_t u16TargetsPresentMask = 0; 2164 2191 2165 for (uint8_t i = 0; i < RT_ELEMENTS(pBusLogic->a DeviceStates); i++)2192 for (uint8_t i = 0; i < RT_ELEMENTS(pBusLogic->afDevicePresent); i++) 2166 2193 { 2167 if (pBusLogic->a DeviceStates[i].fPresent)2194 if (pBusLogic->afDevicePresent[i]) 2168 2195 u16TargetsPresentMask |= (1 << i); 2169 2196 } … … 2261 2288 GCPhysFifoBuf = (RTGCPHYS)ADDR_TO_U32(addr); 2262 2289 Log(("Write busmaster FIFO at: %04X\n", ADDR_TO_U32(addr))); 2263 PDMDevHlpPhysRead(p BusLogic->CTX_SUFF(pDevIns), GCPhysFifoBuf,2290 PDMDevHlpPhysRead(pDevIns, GCPhysFifoBuf, 2264 2291 &pBusLogic->LocalRam.u8View[64], 64); 2265 2292 break; … … 2276 2303 GCPhysFifoBuf = (RTGCPHYS)ADDR_TO_U32(addr); 2277 2304 Log(("Read busmaster FIFO at: %04X\n", ADDR_TO_U32(addr))); 2278 blPhysWrite(p BusLogic, GCPhysFifoBuf, &pBusLogic->LocalRam.u8View[64], 64);2305 blPhysWrite(pDevIns, pBusLogic, GCPhysFifoBuf, &pBusLogic->LocalRam.u8View[64], 64); 2279 2306 break; 2280 2307 } … … 2310 2337 pBusLogic->regStatus |= BL_STAT_DIRRDY; 2311 2338 else if (!pBusLogic->cbCommandParametersLeft) 2312 buslogicCommandComplete(p BusLogic, fSuppressIrq);2339 buslogicCommandComplete(pDevIns, pBusLogic, fSuppressIrq); 2313 2340 2314 2341 return rc; … … 2319 2346 * 2320 2347 * @returns VBox status code. 2321 * @param pBusLogic Pointer to the BusLogic instance data. 2322 * @param iRegister The index of the register to read. 2323 * @param pu32 Where to store the register content. 2324 */ 2325 static int buslogicRegisterRead(PBUSLOGIC pBusLogic, unsigned iRegister, uint32_t *pu32) 2326 { 2327 static const char achAhaSig[] = "ADAP"; 2348 * @param pDevIns The device instance. 2349 * @param pBusLogic Pointer to the shared BusLogic instance data. 2350 * @param iRegister The index of the register to read. 2351 * @param pu32 Where to store the register content. 2352 */ 2353 static int buslogicRegisterRead(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, unsigned iRegister, uint32_t *pu32) 2354 { 2355 static const char s_szAhaSig[] = "ADAP"; 2328 2356 int rc = VINF_SUCCESS; 2329 2357 … … 2343 2371 if (pBusLogic->regStatus & BL_STAT_DACT) 2344 2372 { 2345 uint64_t u64AccessTime = PDMDevHlpTMTimeVirtGetNano(p BusLogic->CTX_SUFF(pDevIns));2373 uint64_t u64AccessTime = PDMDevHlpTMTimeVirtGetNano(pDevIns); 2346 2374 2347 2375 pBusLogic->regStatus &= ~BL_STAT_DACT; … … 2379 2407 */ 2380 2408 if (pBusLogic->uOperationCode == BUSLOGICCOMMAND_FETCH_HOST_ADAPTER_LOCAL_RAM) 2381 buslogicCommandComplete(p BusLogic, true /* fSuppressIrq */);2409 buslogicCommandComplete(pDevIns, pBusLogic, true /* fSuppressIrq */); 2382 2410 else 2383 buslogicCommandComplete(p BusLogic, false);2411 buslogicCommandComplete(pDevIns, pBusLogic, false); 2384 2412 } 2385 2413 } … … 2397 2425 if (pBusLogic->uDevType == DEV_AHA_1540B) 2398 2426 { 2399 *pu32 = achAhaSig[pBusLogic->uAhaSigIdx]; 2400 pBusLogic->uAhaSigIdx = (pBusLogic->uAhaSigIdx + 1) & 3; 2427 uint8_t off = pBusLogic->uAhaSigIdx & 3; 2428 *pu32 = s_szAhaSig[off]; 2429 pBusLogic->uAhaSigIdx = (off + 1) & 3; 2401 2430 } 2402 2431 else … … 2419 2448 * @returns VBox status code. 2420 2449 * @param pDevIns The PDM device instance. 2421 * @param pBusLogic Pointer to the BusLogic instance data.2450 * @param pBusLogic Pointer to the shared BusLogic instance data. 2422 2451 * @param iRegister The index of the register to read. 2423 2452 * @param uVal The value to write. … … 2437 2466 2438 2467 LogRel(("BusLogic: %s reset\n", fHardReset ? "hard" : "soft")); 2439 buslogicR3InitiateReset(p BusLogic, fHardReset);2468 buslogicR3InitiateReset(pDevIns, pBusLogic, PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC), fHardReset); 2440 2469 #else 2441 2470 rc = VINF_IOM_R3_IOPORT_WRITE; … … 2449 2478 2450 2479 #ifdef LOG_ENABLED 2451 uint32_t cMailboxesReady = ASMAtomicXchgU32(&pBusLogic->cInMailboxesReady , 0);2480 uint32_t cMailboxesReady = ASMAtomicXchgU32(&pBusLogic->cInMailboxesReadyIfLogEnabled, 0); 2452 2481 Log(("%u incoming mailboxes were ready when this interrupt was cleared\n", cMailboxesReady)); 2453 2482 #endif 2454 2483 2455 2484 if (uVal & BL_CTRL_RINT) 2456 buslogicClearInterrupt(p BusLogic);2485 buslogicClearInterrupt(pDevIns, pBusLogic); 2457 2486 2458 2487 PDMDevHlpCritSectLeave(pDevIns, &pBusLogic->CritSectIntr); … … 2658 2687 ASSERT_GUEST(cb == 1); 2659 2688 2660 return buslogicRegisterRead(p BusLogic, iRegister, pu32);2689 return buslogicRegisterRead(pDevIns, pBusLogic, iRegister, pu32); 2661 2690 } 2662 2691 … … 2683 2712 #ifdef IN_RING3 2684 2713 2685 static int buslogicR3PrepareBIOSSCSIRequest(PBUSLOGIC pThis)2714 static int buslogicR3PrepareBIOSSCSIRequest(PBUSLOGICCC pThisCC) 2686 2715 { 2687 2716 uint32_t uTargetDevice; … … 2691 2720 size_t cbBuf; 2692 2721 2693 int rc = vboxscsiSetupRequest(&pThis ->VBoxSCSI, &uLun, &pbCdb, &cbCdb, &cbBuf, &uTargetDevice);2722 int rc = vboxscsiSetupRequest(&pThisCC->VBoxSCSI, &uLun, &pbCdb, &cbCdb, &cbBuf, &uTargetDevice); 2694 2723 AssertMsgRCReturn(rc, ("Setting up SCSI request failed rc=%Rrc\n", rc), rc); 2695 2724 2696 if ( uTargetDevice < RT_ELEMENTS(pThis ->aDeviceStates)2697 && pThis ->aDeviceStates[uTargetDevice].pDrvBase)2698 { 2699 PBUSLOGICDEVICE pTgtDev = &pThis ->aDeviceStates[uTargetDevice];2725 if ( uTargetDevice < RT_ELEMENTS(pThisCC->aDeviceStates) 2726 && pThisCC->aDeviceStates[uTargetDevice].pDrvBase) 2727 { 2728 PBUSLOGICDEVICE pTgtDev = &pThisCC->aDeviceStates[uTargetDevice]; 2700 2729 PDMMEDIAEXIOREQ hIoReq; 2701 2730 PBUSLOGICREQ pReq; … … 2718 2747 uint8_t u8ScsiSts = pReq->u8ScsiSts; 2719 2748 pTgtDev->pDrvMediaEx->pfnIoReqFree(pTgtDev->pDrvMediaEx, pReq->hIoReq); 2720 rc = vboxscsiRequestFinished(&pThis ->VBoxSCSI, u8ScsiSts);2749 rc = vboxscsiRequestFinished(&pThisCC->VBoxSCSI, u8ScsiSts); 2721 2750 } 2722 2751 else if (rc == VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS) … … 2736 2765 ScsiInquiryData.u3PeripheralQualifier = SCSI_INQUIRY_DATA_PERIPHERAL_QUALIFIER_NOT_CONNECTED_NOT_SUPPORTED; 2737 2766 2738 memcpy(pThis ->VBoxSCSI.pbBuf, &ScsiInquiryData, 5);2739 2740 rc = vboxscsiRequestFinished(&pThis ->VBoxSCSI, SCSI_STATUS_OK);2767 memcpy(pThisCC->VBoxSCSI.pbBuf, &ScsiInquiryData, 5); 2768 2769 rc = vboxscsiRequestFinished(&pThisCC->VBoxSCSI, SCSI_STATUS_OK); 2741 2770 AssertMsgRCReturn(rc, ("Finishing BIOS SCSI request failed rc=%Rrc\n", rc), rc); 2742 2771 … … 2751 2780 buslogicR3BiosIoPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t *pu32, unsigned cb) 2752 2781 { 2753 PBUSLOGIC pBusLogic = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);2782 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 2754 2783 RT_NOREF(pvUser, cb); 2755 2784 2756 2785 ASSERT_GUEST(cb == 1); 2757 2786 2758 int rc = vboxscsiReadRegister(&p BusLogic->VBoxSCSI, offPort, pu32);2787 int rc = vboxscsiReadRegister(&pThisCC->VBoxSCSI, offPort, pu32); 2759 2788 2760 2789 //Log2(("%s: pu32=%p:{%.*Rhxs} iRegister=%d rc=%Rrc\n", __FUNCTION__, pu32, 1, pu32, offPort, rc)); … … 2769 2798 buslogicR3BiosIoPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb) 2770 2799 { 2771 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 2800 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 2801 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 2772 2802 Log2(("#%d %s: pvUser=%#p cb=%d u32=%#x offPort=%#x\n", pDevIns->iInstance, __FUNCTION__, pvUser, cb, u32, offPort)); 2773 2803 RT_NOREF(pvUser, cb); … … 2777 2807 * because it should not happen. 2778 2808 */ 2779 if (ASMAtomicReadBool(&pThis ->fBiosReqPending))2809 if (ASMAtomicReadBool(&pThisCC->fBiosReqPending)) 2780 2810 return VINF_SUCCESS; 2781 2811 2782 2812 ASSERT_GUEST(cb == 1); 2783 2813 2784 int rc = vboxscsiWriteRegister(&pThis ->VBoxSCSI, offPort, (uint8_t)u32);2814 int rc = vboxscsiWriteRegister(&pThisCC->VBoxSCSI, offPort, (uint8_t)u32); 2785 2815 if (rc == VERR_MORE_DATA) 2786 2816 { 2787 ASMAtomicXchgBool(&pThis ->fBiosReqPending, true);2817 ASMAtomicXchgBool(&pThisCC->fBiosReqPending, true); 2788 2818 /* Wake up the worker thread now that there are pending requests. */ 2789 2819 int rc2 = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtProcess); … … 2803 2833 uint8_t const *pbSrc, uint32_t *pcTransfers, unsigned cb) 2804 2834 { 2805 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 2835 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 2836 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 2806 2837 Log2(("#%d %s: pvUser=%#p cb=%d offPort=%#x\n", pDevIns->iInstance, __FUNCTION__, pvUser, cb, offPort)); 2807 2838 RT_NOREF(pvUser); … … 2811 2842 * because it should not happen. 2812 2843 */ 2813 if (ASMAtomicReadBool(&pThis ->fBiosReqPending))2844 if (ASMAtomicReadBool(&pThisCC->fBiosReqPending)) 2814 2845 return VINF_SUCCESS; 2815 2846 2816 int rc = vboxscsiWriteString(pDevIns, &pThis ->VBoxSCSI, offPort, pbSrc, pcTransfers, cb);2847 int rc = vboxscsiWriteString(pDevIns, &pThisCC->VBoxSCSI, offPort, pbSrc, pcTransfers, cb); 2817 2848 if (rc == VERR_MORE_DATA) 2818 2849 { 2819 ASMAtomicXchgBool(&pThis ->fBiosReqPending, true);2850 ASMAtomicXchgBool(&pThisCC->fBiosReqPending, true); 2820 2851 /* Wake up the worker thread now taht there are pending requests. */ 2821 2852 int rc2 = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtProcess); … … 2834 2865 uint8_t *pbDst, uint32_t *pcTransfers, unsigned cb) 2835 2866 { 2836 PBUSLOGIC pBusLogic = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);2867 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 2837 2868 LogFlowFunc(("#%d %s: pvUser=%#p cb=%d offPort=%#x\n", pDevIns->iInstance, __FUNCTION__, pvUser, cb, offPort)); 2838 2869 RT_NOREF(pvUser); 2839 2870 2840 return vboxscsiReadString(pDevIns, &p BusLogic->VBoxSCSI, offPort, pbDst, pcTransfers, cb);2871 return vboxscsiReadString(pDevIns, &pThisCC->VBoxSCSI, offPort, pbDst, pcTransfers, cb); 2841 2872 } 2842 2873 … … 2846 2877 * @returns nothing. 2847 2878 * @param pDevIns The device instance. 2848 * @param pBusLogic Pointer to the BusLogic device instance.2879 * @param pBusLogic Pointer to the shared BusLogic instance data. 2849 2880 * @param uBaseCode Encoded ISA I/O base; only low 3 bits are used. 2850 2881 */ … … 2901 2932 2902 2933 2903 static int buslogicR3ReqComplete(P BUSLOGIC pThis, PBUSLOGICREQ pReq, int rcReq)2934 static int buslogicR3ReqComplete(PPDMDEVINS pDevIns, PBUSLOGIC pThis, PBUSLOGICCC pThisCC, PBUSLOGICREQ pReq, int rcReq) 2904 2935 { 2905 2936 RT_NOREF(rcReq); … … 2914 2945 uint8_t u8ScsiSts = pReq->u8ScsiSts; 2915 2946 pTgtDev->pDrvMediaEx->pfnIoReqFree(pTgtDev->pDrvMediaEx, pReq->hIoReq); 2916 int rc = vboxscsiRequestFinished(&pThis ->VBoxSCSI, u8ScsiSts);2947 int rc = vboxscsiRequestFinished(&pThisCC->VBoxSCSI, u8ScsiSts); 2917 2948 AssertMsgRC(rc, ("Finishing BIOS SCSI request failed rc=%Rrc\n", rc)); 2918 2949 } … … 2951 2982 pTgtDev->pDrvMediaEx->pfnIoReqFree(pTgtDev->pDrvMediaEx, pReq->hIoReq); 2952 2983 if (u8ScsiSts == SCSI_STATUS_OK) 2953 buslogicR3SendIncomingMailbox(p This, GCPhysAddrCCB, &CCBGuest,2954 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_CMD_COMPLETED,2955 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD,2956 BUSLOGIC_MAILBOX_INCOMING_COMPLETION_WITHOUT_ERROR);2984 buslogicR3SendIncomingMailbox(pDevIns, pThis, GCPhysAddrCCB, &CCBGuest, 2985 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_CMD_COMPLETED, 2986 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD, 2987 BUSLOGIC_MAILBOX_INCOMING_COMPLETION_WITHOUT_ERROR); 2957 2988 else if (u8ScsiSts == SCSI_STATUS_CHECK_CONDITION) 2958 buslogicR3SendIncomingMailbox(p This, GCPhysAddrCCB, &CCBGuest,2959 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_CMD_COMPLETED,2960 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_CHECK_CONDITION,2961 BUSLOGIC_MAILBOX_INCOMING_COMPLETION_WITH_ERROR);2989 buslogicR3SendIncomingMailbox(pDevIns, pThis, GCPhysAddrCCB, &CCBGuest, 2990 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_CMD_COMPLETED, 2991 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_CHECK_CONDITION, 2992 BUSLOGIC_MAILBOX_INCOMING_COMPLETION_WITH_ERROR); 2962 2993 else 2963 2994 AssertMsgFailed(("invalid completion status %u\n", u8ScsiSts)); … … 2968 2999 } 2969 3000 2970 if (pTgtDev->cOutstandingRequests == 0 && pThis ->fSignalIdle)2971 PDMDevHlpAsyncNotificationCompleted(p This->pDevInsR3);3001 if (pTgtDev->cOutstandingRequests == 0 && pThisCC->fSignalIdle) 3002 PDMDevHlpAsyncNotificationCompleted(pDevIns); 2972 3003 2973 3004 return VINF_SUCCESS; … … 2980 3011 uint32_t *piInstance, uint32_t *piLUN) 2981 3012 { 2982 PBUSLOGICDEVICE p BusLogicDevice= RT_FROM_MEMBER(pInterface, BUSLOGICDEVICE, IMediaPort);2983 PPDMDEVINS pDevIns = pBusLogicDevice->CTX_SUFF(pBusLogic)->CTX_SUFF(pDevIns);3013 PBUSLOGICDEVICE pTgtDev = RT_FROM_MEMBER(pInterface, BUSLOGICDEVICE, IMediaPort); 3014 PPDMDEVINS pDevIns = pTgtDev->pDevIns; 2984 3015 2985 3016 AssertPtrReturn(ppcszController, VERR_INVALID_POINTER); … … 2989 3020 *ppcszController = pDevIns->pReg->szName; 2990 3021 *piInstance = pDevIns->iInstance; 2991 *piLUN = p BusLogicDevice->iLUN;3022 *piLUN = pTgtDev->iLUN; 2992 3023 2993 3024 return VINF_SUCCESS; … … 3001 3032 size_t cbCopy) 3002 3033 { 3003 RT_NOREF1(hIoReq);3004 3034 PBUSLOGICDEVICE pTgtDev = RT_FROM_MEMBER(pInterface, BUSLOGICDEVICE, IMediaExPort); 3005 PBUSLOGICREQ pReq = (PBUSLOGICREQ)pvIoReqAlloc; 3035 PPDMDEVINS pDevIns = pTgtDev->pDevIns; 3036 PBUSLOGICREQ pReq = (PBUSLOGICREQ)pvIoReqAlloc; 3037 RT_NOREF(hIoReq); 3006 3038 3007 3039 size_t cbCopied = 0; 3008 if (RT_ UNLIKELY(pReq->fBIOS))3009 cbCopied = vboxscsiCopyToBuf(&pTgtDev->CTX_SUFF(pBusLogic)->VBoxSCSI, pSgBuf, offDst, cbCopy);3040 if (RT_LIKELY(!pReq->fBIOS)) 3041 cbCopied = buslogicR3CopySgBufToGuest(pDevIns, PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC), pReq, pSgBuf, offDst, cbCopy); 3010 3042 else 3011 cbCopied = buslogicR3CopySgBufToGuest(pTgtDev->CTX_SUFF(pBusLogic), pReq, pSgBuf, offDst, cbCopy); 3043 { 3044 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3045 cbCopied = vboxscsiCopyToBuf(&pThisCC->VBoxSCSI, pSgBuf, offDst, cbCopy); 3046 } 3012 3047 return cbCopied == cbCopy ? VINF_SUCCESS : VERR_PDM_MEDIAEX_IOBUF_OVERFLOW; 3013 3048 } … … 3020 3055 size_t cbCopy) 3021 3056 { 3022 RT_NOREF 1(hIoReq);3057 RT_NOREF(hIoReq); 3023 3058 PBUSLOGICDEVICE pTgtDev = RT_FROM_MEMBER(pInterface, BUSLOGICDEVICE, IMediaExPort); 3024 PBUSLOGICREQ pReq = (PBUSLOGICREQ)pvIoReqAlloc; 3059 PPDMDEVINS pDevIns = pTgtDev->pDevIns; 3060 PBUSLOGICREQ pReq = (PBUSLOGICREQ)pvIoReqAlloc; 3025 3061 3026 3062 size_t cbCopied = 0; 3027 if (RT_ UNLIKELY(pReq->fBIOS))3028 cbCopied = vboxscsiCopyFromBuf(&pTgtDev->CTX_SUFF(pBusLogic)->VBoxSCSI, pSgBuf, offSrc, cbCopy);3063 if (RT_LIKELY(!pReq->fBIOS)) 3064 cbCopied = buslogicR3CopySgBufFromGuest(pDevIns, PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC), pReq, pSgBuf, offSrc, cbCopy); 3029 3065 else 3030 cbCopied = buslogicR3CopySgBufFromGuest(pTgtDev->CTX_SUFF(pBusLogic), pReq, pSgBuf, offSrc, cbCopy); 3066 { 3067 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3068 cbCopied = vboxscsiCopyFromBuf(&pThisCC->VBoxSCSI, pSgBuf, offSrc, cbCopy); 3069 } 3031 3070 return cbCopied == cbCopy ? VINF_SUCCESS : VERR_PDM_MEDIAEX_IOBUF_UNDERRUN; 3032 3071 } … … 3040 3079 RT_NOREF(hIoReq); 3041 3080 PBUSLOGICDEVICE pTgtDev = RT_FROM_MEMBER(pInterface, BUSLOGICDEVICE, IMediaExPort); 3042 buslogicR3ReqComplete(pTgtDev->CTX_SUFF(pBusLogic), (PBUSLOGICREQ)pvIoReqAlloc, rcReq); 3081 PPDMDEVINS pDevIns = pTgtDev->pDevIns; 3082 buslogicR3ReqComplete(pDevIns, PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC), PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC), 3083 (PBUSLOGICREQ)pvIoReqAlloc, rcReq); 3043 3084 return VINF_SUCCESS; 3044 3085 } … … 3050 3091 void *pvIoReqAlloc, PDMMEDIAEXIOREQSTATE enmState) 3051 3092 { 3052 RT_NOREF 3(hIoReq, pvIoReqAlloc, enmState);3093 RT_NOREF(hIoReq, pvIoReqAlloc, enmState); 3053 3094 PBUSLOGICDEVICE pTgtDev = RT_FROM_MEMBER(pInterface, BUSLOGICDEVICE, IMediaExPort); 3054 3095 … … 3057 3098 case PDMMEDIAEXIOREQSTATE_SUSPENDED: 3058 3099 { 3100 PPDMDEVINS pDevIns = pTgtDev->pDevIns; 3101 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3102 3059 3103 /* Make sure the request is not accounted for so the VM can suspend successfully. */ 3060 3104 uint32_t cTasksActive = ASMAtomicDecU32(&pTgtDev->cOutstandingRequests); 3061 if (!cTasksActive && pT gtDev->CTX_SUFF(pBusLogic)->fSignalIdle)3062 PDMDevHlpAsyncNotificationCompleted(p TgtDev->CTX_SUFF(pBusLogic)->pDevInsR3);3105 if (!cTasksActive && pThisCC->fSignalIdle) 3106 PDMDevHlpAsyncNotificationCompleted(pDevIns); 3063 3107 break; 3064 3108 } … … 3078 3122 { 3079 3123 PBUSLOGICDEVICE pTgtDev = RT_FROM_MEMBER(pInterface, BUSLOGICDEVICE, IMediaExPort); 3080 PBUSLOGIC pThis = pTgtDev->CTX_SUFF(pBusLogic); 3081 3082 if (pThis->pMediaNotify) 3083 { 3084 int rc = VMR3ReqCallNoWait(PDMDevHlpGetVM(pThis->CTX_SUFF(pDevIns)), VMCPUID_ANY, 3085 (PFNRT)pThis->pMediaNotify->pfnEjected, 2, 3086 pThis->pMediaNotify, pTgtDev->iLUN); 3124 PPDMDEVINS pDevIns = pTgtDev->pDevIns; 3125 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3126 3127 if (pThisCC->pMediaNotify) 3128 { 3129 int rc = VMR3ReqCallNoWait(PDMDevHlpGetVM(pDevIns), VMCPUID_ANY, 3130 (PFNRT)pThisCC->pMediaNotify->pfnEjected, 2, 3131 pThisCC->pMediaNotify, pTgtDev->iLUN); 3087 3132 AssertRC(rc); 3088 3133 } 3089 3134 } 3090 3135 3091 static int buslogicR3DeviceSCSIRequestSetup(P BUSLOGIC pBusLogic, RTGCPHYS GCPhysAddrCCB)3136 static int buslogicR3DeviceSCSIRequestSetup(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, PBUSLOGICCC pThisCC, RTGCPHYS GCPhysAddrCCB) 3092 3137 { 3093 3138 int rc = VINF_SUCCESS; … … 3097 3142 /* Fetch the CCB from guest memory. */ 3098 3143 /** @todo How much do we really have to read? */ 3099 PDMDevHlpPhysRead(p BusLogic->CTX_SUFF(pDevIns), GCPhysAddrCCB,3144 PDMDevHlpPhysRead(pDevIns, GCPhysAddrCCB, 3100 3145 &CCBGuest, sizeof(CCB32)); 3101 3146 3102 3147 uTargetIdCCB = pBusLogic->fMbxIs24Bit ? CCBGuest.o.uTargetId : CCBGuest.n.uTargetId; 3103 if (RT_LIKELY(uTargetIdCCB < RT_ELEMENTS(p BusLogic->aDeviceStates)))3104 { 3105 PBUSLOGICDEVICE pTgtDev = &p BusLogic->aDeviceStates[uTargetIdCCB];3148 if (RT_LIKELY(uTargetIdCCB < RT_ELEMENTS(pThisCC->aDeviceStates))) 3149 { 3150 PBUSLOGICDEVICE pTgtDev = &pThisCC->aDeviceStates[uTargetIdCCB]; 3106 3151 3107 3152 #ifdef LOG_ENABLED … … 3132 3177 3133 3178 size_t cbBuf = 0; 3134 rc = buslogicR3QueryDataBufferSize(p BusLogic->CTX_SUFF(pDevIns), &pReq->CCBGuest, pReq->fIs24Bit, &cbBuf);3179 rc = buslogicR3QueryDataBufferSize(pDevIns, &pReq->CCBGuest, pReq->fIs24Bit, &cbBuf); 3135 3180 AssertRC(rc); 3136 3181 … … 3154 3199 &pReq->u8ScsiSts, 30 * RT_MS_1SEC); 3155 3200 if (rc != VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS) 3156 buslogicR3ReqComplete(p BusLogic, pReq, rc);3201 buslogicR3ReqComplete(pDevIns, pBusLogic, pThisCC, pReq, rc); 3157 3202 } 3158 3203 else 3159 buslogicR3SendIncomingMailbox(p BusLogic, GCPhysAddrCCB, &CCBGuest,3204 buslogicR3SendIncomingMailbox(pDevIns, pBusLogic, GCPhysAddrCCB, &CCBGuest, 3160 3205 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_SCSI_SELECTION_TIMEOUT, 3161 3206 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD, … … 3163 3208 } 3164 3209 else 3165 buslogicR3SendIncomingMailbox(p BusLogic, GCPhysAddrCCB, &CCBGuest,3210 buslogicR3SendIncomingMailbox(pDevIns, pBusLogic, GCPhysAddrCCB, &CCBGuest, 3166 3211 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_SCSI_SELECTION_TIMEOUT, 3167 3212 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD, … … 3169 3214 } 3170 3215 else 3171 buslogicR3SendIncomingMailbox(p BusLogic, GCPhysAddrCCB, &CCBGuest,3216 buslogicR3SendIncomingMailbox(pDevIns, pBusLogic, GCPhysAddrCCB, &CCBGuest, 3172 3217 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_INVALID_COMMAND_PARAMETER, 3173 3218 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD, … … 3177 3222 } 3178 3223 3179 static int buslogicR3DeviceSCSIRequestAbort(PBUSLOGIC pBusLogic, RTGCPHYS GCPhysAddrCCB) 3180 { 3181 int rc = VINF_SUCCESS; 3224 static int buslogicR3DeviceSCSIRequestAbort(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, RTGCPHYS GCPhysAddrCCB) 3225 { 3182 3226 uint8_t uTargetIdCCB; 3183 3227 CCBU CCBGuest; 3184 3228 3185 PDMDevHlpPhysRead(p BusLogic->CTX_SUFF(pDevIns), GCPhysAddrCCB,3229 PDMDevHlpPhysRead(pDevIns, GCPhysAddrCCB, 3186 3230 &CCBGuest, sizeof(CCB32)); 3187 3231 3188 3232 uTargetIdCCB = pBusLogic->fMbxIs24Bit ? CCBGuest.o.uTargetId : CCBGuest.n.uTargetId; 3189 if (RT_LIKELY(uTargetIdCCB < RT_ELEMENTS(pBusLogic->a DeviceStates)))3190 buslogicR3SendIncomingMailbox(p BusLogic, GCPhysAddrCCB, &CCBGuest,3233 if (RT_LIKELY(uTargetIdCCB < RT_ELEMENTS(pBusLogic->afDevicePresent))) 3234 buslogicR3SendIncomingMailbox(pDevIns, pBusLogic, GCPhysAddrCCB, &CCBGuest, 3191 3235 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_ABORT_QUEUE_GENERATED, 3192 3236 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD, 3193 3237 BUSLOGIC_MAILBOX_INCOMING_COMPLETION_ABORTED_NOT_FOUND); 3194 3238 else 3195 buslogicR3SendIncomingMailbox(p BusLogic, GCPhysAddrCCB, &CCBGuest,3239 buslogicR3SendIncomingMailbox(pDevIns, pBusLogic, GCPhysAddrCCB, &CCBGuest, 3196 3240 BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_INVALID_COMMAND_PARAMETER, 3197 3241 BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD, 3198 3242 BUSLOGIC_MAILBOX_INCOMING_COMPLETION_WITH_ERROR); 3199 3243 3200 return rc;3244 return VINF_SUCCESS; 3201 3245 } 3202 3246 … … 3206 3250 * 3207 3251 * @returns Mailbox guest physical address. 3208 * @param pBusLogic Pointer to the BusLogic instance data.3252 * @param pBusLogic Pointer to the shared BusLogic instance data. 3209 3253 * @param pMbx Pointer to the mailbox to read into. 3210 3254 */ 3211 static RTGCPHYS buslogicR3ReadOutgoingMailbox(P BUSLOGIC pBusLogic, PMailbox32 pMbx)3255 static RTGCPHYS buslogicR3ReadOutgoingMailbox(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, PMailbox32 pMbx) 3212 3256 { 3213 3257 RTGCPHYS GCMailbox; … … 3218 3262 3219 3263 GCMailbox = pBusLogic->GCPhysAddrMailboxOutgoingBase + (pBusLogic->uMailboxOutgoingPositionCurrent * sizeof(Mailbox24)); 3220 PDMDevHlpPhysRead(p BusLogic->CTX_SUFF(pDevIns), GCMailbox, &Mbx24, sizeof(Mailbox24));3264 PDMDevHlpPhysRead(pDevIns, GCMailbox, &Mbx24, sizeof(Mailbox24)); 3221 3265 pMbx->u32PhysAddrCCB = ADDR_TO_U32(Mbx24.aPhysAddrCCB); 3222 3266 pMbx->u.out.uActionCode = Mbx24.uCmdState; … … 3225 3269 { 3226 3270 GCMailbox = pBusLogic->GCPhysAddrMailboxOutgoingBase + (pBusLogic->uMailboxOutgoingPositionCurrent * sizeof(Mailbox32)); 3227 PDMDevHlpPhysRead(p BusLogic->CTX_SUFF(pDevIns), GCMailbox, pMbx, sizeof(Mailbox32));3271 PDMDevHlpPhysRead(pDevIns, GCMailbox, pMbx, sizeof(Mailbox32)); 3228 3272 } 3229 3273 … … 3235 3279 * 3236 3280 * @returns VBox status code. 3237 * @param pBusLogic Pointer to the BusLogic instance data. 3238 */ 3239 static int buslogicR3ProcessMailboxNext(PBUSLOGIC pBusLogic) 3281 * @param pDevIns The device instance. 3282 * @param pBusLogic Pointer to the shared BusLogic instance data. 3283 * @param pThisCC Pointer to the ring-3 BusLogic instance data. 3284 */ 3285 static int buslogicR3ProcessMailboxNext(PPDMDEVINS pDevIns, PBUSLOGIC pBusLogic, PBUSLOGICCC pThisCC) 3240 3286 { 3241 3287 RTGCPHYS GCPhysAddrMailboxCurrent; … … 3251 3297 { 3252 3298 /* Fetch mailbox from guest memory. */ 3253 GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(p BusLogic, &MailboxGuest);3299 GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pDevIns, pBusLogic, &MailboxGuest); 3254 3300 3255 3301 /* Check the next mailbox. */ … … 3261 3307 { 3262 3308 /* Fetch mailbox from guest memory. */ 3263 GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(p BusLogic, &MailboxGuest);3309 GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pDevIns, pBusLogic, &MailboxGuest); 3264 3310 } 3265 3311 … … 3284 3330 uint8_t uActionCode = BUSLOGIC_MAILBOX_OUTGOING_ACTION_FREE; 3285 3331 unsigned uCodeOffs = pBusLogic->fMbxIs24Bit ? RT_OFFSETOF(Mailbox24, uCmdState) : RT_OFFSETOF(Mailbox32, u.out.uActionCode); 3286 blPhysWrite(p BusLogic, GCPhysAddrMailboxCurrent + uCodeOffs, &uActionCode, sizeof(uActionCode));3332 blPhysWrite(pDevIns, pBusLogic, GCPhysAddrMailboxCurrent + uCodeOffs, &uActionCode, sizeof(uActionCode)); 3287 3333 3288 3334 if (MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_START_COMMAND) 3289 rc = buslogicR3DeviceSCSIRequestSetup(p BusLogic, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB);3335 rc = buslogicR3DeviceSCSIRequestSetup(pDevIns, pBusLogic, pThisCC, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB); 3290 3336 else if (MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_ABORT_COMMAND) 3291 3337 { 3292 3338 LogFlow(("Aborting mailbox\n")); 3293 rc = buslogicR3DeviceSCSIRequestAbort(p BusLogic, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB);3339 rc = buslogicR3DeviceSCSIRequestAbort(pDevIns, pBusLogic, (RTGCPHYS)MailboxGuest.u32PhysAddrCCB); 3294 3340 } 3295 3341 else … … 3308 3354 static DECLCALLBACK(int) buslogicR3LiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass) 3309 3355 { 3356 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3357 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3310 3358 RT_NOREF(uPass); 3311 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);3312 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;3313 3359 3314 3360 /* Save the device config. */ 3315 for (unsigned i = 0; i < RT_ELEMENTS(pThis ->aDeviceStates); i++)3316 pHlp->pfnSSMPutBool(pSSM, pThis ->aDeviceStates[i].fPresent);3361 for (unsigned i = 0; i < RT_ELEMENTS(pThisCC->aDeviceStates); i++) 3362 pHlp->pfnSSMPutBool(pSSM, pThisCC->aDeviceStates[i].fPresent); 3317 3363 3318 3364 return VINF_SSM_DONT_CALL_AGAIN; … … 3322 3368 static DECLCALLBACK(int) buslogicR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 3323 3369 { 3324 PBUSLOGIC pBusLogic = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 3325 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3370 PBUSLOGIC pBusLogic = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 3371 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3372 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3326 3373 uint32_t cReqsSuspended = 0; 3327 3374 3328 3375 /* Every device first. */ 3329 for (unsigned i = 0; i < RT_ELEMENTS(p BusLogic->aDeviceStates); i++)3330 { 3331 PBUSLOGICDEVICE pDevice = &p BusLogic->aDeviceStates[i];3376 for (unsigned i = 0; i < RT_ELEMENTS(pThisCC->aDeviceStates); i++) 3377 { 3378 PBUSLOGICDEVICE pDevice = &pThisCC->aDeviceStates[i]; 3332 3379 3333 3380 AssertMsg(!pDevice->cOutstandingRequests, … … 3365 3412 pHlp->pfnSSMPutBool (pSSM, pBusLogic->fExtendedLunCCBFormat); 3366 3413 3367 vboxscsiR3SaveExec(pDevIns->pHlpR3, &p BusLogic->VBoxSCSI, pSSM);3414 vboxscsiR3SaveExec(pDevIns->pHlpR3, &pThisCC->VBoxSCSI, pSSM); 3368 3415 3369 3416 pHlp->pfnSSMPutU32(pSSM, cReqsSuspended); 3370 3417 3371 3418 /* Save the physical CCB address of all suspended requests. */ 3372 for (unsigned i = 0; i < RT_ELEMENTS(p BusLogic->aDeviceStates) && cReqsSuspended; i++)3373 { 3374 PBUSLOGICDEVICE pDevice = &p BusLogic->aDeviceStates[i];3419 for (unsigned i = 0; i < RT_ELEMENTS(pThisCC->aDeviceStates) && cReqsSuspended; i++) 3420 { 3421 PBUSLOGICDEVICE pDevice = &pThisCC->aDeviceStates[i]; 3375 3422 if (pDevice->fPresent) 3376 3423 { … … 3408 3455 static DECLCALLBACK(int) buslogicR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 3409 3456 { 3457 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 3458 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3410 3459 RT_NOREF(pSSM); 3411 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);3412 3460 3413 3461 buslogicR3RegisterISARange(pDevIns, pThis, pThis->uISABaseCode); 3414 3462 3415 3463 /* Kick of any requests we might need to redo. */ 3416 if (pThis ->VBoxSCSI.fBusy)3464 if (pThisCC->VBoxSCSI.fBusy) 3417 3465 { 3418 3466 3419 3467 /* The BIOS had a request active when we got suspended. Resume it. */ 3420 int rc = buslogicR3PrepareBIOSSCSIRequest(pThis );3468 int rc = buslogicR3PrepareBIOSSCSIRequest(pThisCC); 3421 3469 AssertRC(rc); 3422 3470 } 3423 else if (pThis ->cReqsRedo)3424 { 3425 for (unsigned i = 0; i < pThis ->cReqsRedo; i++)3426 { 3427 int rc = buslogicR3DeviceSCSIRequestSetup(p This, pThis->paGCPhysAddrCCBRedo[i]);3471 else if (pThisCC->cReqsRedo) 3472 { 3473 for (unsigned i = 0; i < pThisCC->cReqsRedo; i++) 3474 { 3475 int rc = buslogicR3DeviceSCSIRequestSetup(pDevIns, pThis, pThisCC, pThisCC->paGCPhysAddrCCBRedo[i]); 3428 3476 AssertRC(rc); 3429 3477 } 3430 3478 3431 RTMemFree(pThis ->paGCPhysAddrCCBRedo);3432 pThis ->paGCPhysAddrCCBRedo = NULL;3433 pThis ->cReqsRedo = 0;3479 RTMemFree(pThisCC->paGCPhysAddrCCBRedo); 3480 pThisCC->paGCPhysAddrCCBRedo = NULL; 3481 pThisCC->cReqsRedo = 0; 3434 3482 } 3435 3483 … … 3441 3489 { 3442 3490 PBUSLOGIC pBusLogic = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 3443 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3444 int rc = VINF_SUCCESS; 3491 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3492 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 3493 int rc = VINF_SUCCESS; 3445 3494 3446 3495 /* We support saved states only from this and older versions. */ … … 3449 3498 3450 3499 /* Every device first. */ 3451 for (unsigned i = 0; i < RT_ELEMENTS(p BusLogic->aDeviceStates); i++)3452 { 3453 PBUSLOGICDEVICE pDevice = &p BusLogic->aDeviceStates[i];3500 for (unsigned i = 0; i < RT_ELEMENTS(pThisCC->aDeviceStates); i++) 3501 { 3502 PBUSLOGICDEVICE pDevice = &pThisCC->aDeviceStates[i]; 3454 3503 3455 3504 AssertMsg(!pDevice->cOutstandingRequests, … … 3498 3547 pHlp->pfnSSMGetBool (pSSM, &pBusLogic->fExtendedLunCCBFormat); 3499 3548 3500 rc = vboxscsiR3LoadExec(pDevIns->pHlpR3, &p BusLogic->VBoxSCSI, pSSM);3549 rc = vboxscsiR3LoadExec(pDevIns->pHlpR3, &pThisCC->VBoxSCSI, pSSM); 3501 3550 if (RT_FAILURE(rc)) 3502 3551 { 3503 3552 LogRel(("BusLogic: Failed to restore BIOS state: %Rrc.\n", rc)); 3504 return PDMDEV_SET_ERROR(pDevIns, rc, 3505 N_("BusLogic: Failed to restore BIOS state\n")); 3553 return PDMDEV_SET_ERROR(pDevIns, rc, N_("BusLogic: Failed to restore BIOS state\n")); 3506 3554 } 3507 3555 … … 3515 3563 if (cTasks) 3516 3564 { 3517 p BusLogic->paGCPhysAddrCCBRedo = (PRTGCPHYS)RTMemAllocZ(cTasks * sizeof(RTGCPHYS));3518 if (RT_LIKELY(p BusLogic->paGCPhysAddrCCBRedo))3565 pThisCC->paGCPhysAddrCCBRedo = (PRTGCPHYS)RTMemAllocZ(cTasks * sizeof(RTGCPHYS)); 3566 if (RT_LIKELY(pThisCC->paGCPhysAddrCCBRedo)) 3519 3567 { 3520 p BusLogic->cReqsRedo = cTasks;3568 pThisCC->cReqsRedo = cTasks; 3521 3569 3522 3570 for (uint32_t i = 0; i < cTasks; i++) … … 3525 3573 3526 3574 rc = pHlp->pfnSSMGetU32(pSSM, &u32PhysAddrCCB); 3527 if (RT_FAILURE(rc)) 3528 break; 3529 3530 pBusLogic->paGCPhysAddrCCBRedo[i] = u32PhysAddrCCB; 3575 AssertRCBreak(rc); 3576 3577 pThisCC->paGCPhysAddrCCBRedo[i] = u32PhysAddrCCB; 3531 3578 } 3532 3579 } … … 3591 3638 static DECLCALLBACK(int) buslogicR3StatusQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed) 3592 3639 { 3593 PBUSLOGIC pBusLogic = RT_FROM_MEMBER(pInterface, BUSLOGIC, ILeds);3640 PBUSLOGICCC pThisCC = RT_FROM_MEMBER(pInterface, BUSLOGICCC, ILeds); 3594 3641 if (iLUN < BUSLOGIC_MAX_DEVICES) 3595 3642 { 3596 *ppLed = &p BusLogic->aDeviceStates[iLUN].Led;3643 *ppLed = &pThisCC->aDeviceStates[iLUN].Led; 3597 3644 Assert((*ppLed)->u32Magic == PDMLED_MAGIC); 3598 3645 return VINF_SUCCESS; … … 3606 3653 static DECLCALLBACK(void *) buslogicR3StatusQueryInterface(PPDMIBASE pInterface, const char *pszIID) 3607 3654 { 3608 PBUSLOGIC pThis = RT_FROM_MEMBER(pInterface, BUSLOGIC, IBase);3609 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis ->IBase);3610 PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis ->ILeds);3655 PBUSLOGICCC pThisCC = RT_FROM_MEMBER(pInterface, BUSLOGICCC, IBase); 3656 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->IBase); 3657 PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThisCC->ILeds); 3611 3658 return NULL; 3612 3659 } 3613 3660 3614 3661 /** 3615 * The worker thread processing requests from the guest. 3616 * 3617 * @returns VBox status code. 3618 * @param pDevIns The device instance. 3619 * @param pThread The thread structure. 3662 * @callback_method_impl{FNPDMTHREADWAKEUPDEV} 3620 3663 */ 3621 3664 static DECLCALLBACK(int) buslogicR3Worker(PPDMDEVINS pDevIns, PPDMTHREAD pThread) 3622 3665 { 3623 RT_NOREF(pDevIns); 3624 PBUSLOGIC pThis = (PBUSLOGIC)pThread->pvUser; 3625 int rc = VINF_SUCCESS; 3666 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 3667 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3626 3668 3627 3669 if (pThread->enmState == PDMTHREADSTATE_INITIALIZING) … … 3630 3672 while (pThread->enmState == PDMTHREADSTATE_RUNNING) 3631 3673 { 3632 ASMAtomicWriteBool(&pThis->fWrkThreadSleeping, true); 3674 int rc; 3675 3676 ASMAtomicWriteBool(&pThisCC->fWrkThreadSleeping, true); 3633 3677 bool fNotificationSent = ASMAtomicXchgBool(&pThis->fNotificationSent, false); 3634 3678 if (!fNotificationSent) 3635 3679 { 3636 Assert(ASMAtomicReadBool(&pThis ->fWrkThreadSleeping));3680 Assert(ASMAtomicReadBool(&pThisCC->fWrkThreadSleeping)); 3637 3681 rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->hEvtProcess, RT_INDEFINITE_WAIT); 3638 3682 AssertLogRelMsgReturn(RT_SUCCESS(rc) || rc == VERR_INTERRUPTED, ("%Rrc\n", rc), rc); … … 3643 3687 } 3644 3688 3645 ASMAtomicWriteBool(&pThis ->fWrkThreadSleeping, false);3689 ASMAtomicWriteBool(&pThisCC->fWrkThreadSleeping, false); 3646 3690 3647 3691 /* Check whether there is a BIOS request pending and process it first. */ 3648 if (ASMAtomicReadBool(&pThis ->fBiosReqPending))3649 { 3650 rc = buslogicR3PrepareBIOSSCSIRequest(pThis );3692 if (ASMAtomicReadBool(&pThisCC->fBiosReqPending)) 3693 { 3694 rc = buslogicR3PrepareBIOSSCSIRequest(pThisCC); 3651 3695 AssertRC(rc); 3652 ASMAtomicXchgBool(&pThis ->fBiosReqPending, false);3696 ASMAtomicXchgBool(&pThisCC->fBiosReqPending, false); 3653 3697 } 3654 3698 else … … 3659 3703 do 3660 3704 { 3661 rc = buslogicR3ProcessMailboxNext(p This);3705 rc = buslogicR3ProcessMailboxNext(pDevIns, pThis, pThisCC); 3662 3706 AssertMsg(RT_SUCCESS(rc) || rc == VERR_NO_DATA, ("Processing mailbox failed rc=%Rrc\n", rc)); 3663 3707 } while (RT_SUCCESS(rc)); … … 3670 3714 3671 3715 /** 3672 * Unblock the worker thread so it can respond to a state change. 3673 * 3674 * @returns VBox status code. 3675 * @param pDevIns The device instance. 3676 * @param pThread The send thread. 3716 * @callback_method_impl{FNPDMTHREADWAKEUPDEV} 3677 3717 */ 3678 3718 static DECLCALLBACK(int) buslogicR3WorkerWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread) … … 3715 3755 PDMDevHlpMmioGetMappingAddress(pDevIns, pThis->hMmio), 3716 3756 PCIDevGetInterruptLine(pDevIns->apPciDevs[0])); 3717 pHlp->pfnPrintf(pHlp, "GC=%RTbool R0=%RTbool\n", 3718 !!pThis->fGCEnabled, !!pThis->fR0Enabled); 3757 pHlp->pfnPrintf(pHlp, "RC=%RTbool R0=%RTbool\n", pDevIns->fRCEnabled, pDevIns->fR0Enabled); 3719 3758 3720 3759 /* Print mailbox state. */ … … 3753 3792 for (i = 0; i < pThis->cMailbox; ++i) 3754 3793 { 3755 PDMDevHlpPhysRead(p This->CTX_SUFF(pDevIns), GCMailbox, &Mbx24, sizeof(Mailbox24));3794 PDMDevHlpPhysRead(pDevIns, GCMailbox, &Mbx24, sizeof(Mailbox24)); 3756 3795 pHlp->pfnPrintf(pHlp, " slot %03d: CCB at %06X action code %02X", i, ADDR_TO_U32(Mbx24.aPhysAddrCCB), Mbx24.uCmdState); 3757 3796 pHlp->pfnPrintf(pHlp, "%s\n", pThis->uMailboxOutgoingPositionCurrent == i ? " *" : ""); … … 3764 3803 for (i = 0; i < pThis->cMailbox; ++i) 3765 3804 { 3766 PDMDevHlpPhysRead(p This->CTX_SUFF(pDevIns), GCMailbox, &Mbx24, sizeof(Mailbox24));3805 PDMDevHlpPhysRead(pDevIns, GCMailbox, &Mbx24, sizeof(Mailbox24)); 3767 3806 pHlp->pfnPrintf(pHlp, " slot %03d: CCB at %06X completion code %02X", i, ADDR_TO_U32(Mbx24.aPhysAddrCCB), Mbx24.uCmdState); 3768 3807 pHlp->pfnPrintf(pHlp, "%s\n", pThis->uMailboxIncomingPositionCurrent == i ? " *" : ""); … … 3780 3819 for (i = 0; i < pThis->cMailbox; ++i) 3781 3820 { 3782 PDMDevHlpPhysRead(p This->CTX_SUFF(pDevIns), GCMailbox, &Mbx32, sizeof(Mailbox32));3821 PDMDevHlpPhysRead(pDevIns, GCMailbox, &Mbx32, sizeof(Mailbox32)); 3783 3822 pHlp->pfnPrintf(pHlp, " slot %03d: CCB at %08X action code %02X", i, Mbx32.u32PhysAddrCCB, Mbx32.u.out.uActionCode); 3784 3823 pHlp->pfnPrintf(pHlp, "%s\n", pThis->uMailboxOutgoingPositionCurrent == i ? " *" : ""); … … 3791 3830 for (i = 0; i < pThis->cMailbox; ++i) 3792 3831 { 3793 PDMDevHlpPhysRead(p This->CTX_SUFF(pDevIns), GCMailbox, &Mbx32, sizeof(Mailbox32));3832 PDMDevHlpPhysRead(pDevIns, GCMailbox, &Mbx32, sizeof(Mailbox32)); 3794 3833 pHlp->pfnPrintf(pHlp, " slot %03d: CCB at %08X completion code %02X BTSTAT %02X SDSTAT %02X", i, 3795 3834 Mbx32.u32PhysAddrCCB, Mbx32.u.in.uCompletionCode, Mbx32.u.in.uHostAdapterStatus, Mbx32.u.in.uTargetDeviceStatus); … … 3814 3853 static bool buslogicR3AllAsyncIOIsFinished(PPDMDEVINS pDevIns) 3815 3854 { 3816 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);3817 3818 for (uint32_t i = 0; i < RT_ELEMENTS(pThis ->aDeviceStates); i++)3819 { 3820 PBUSLOGICDEVICE pThisDevice = &pThis ->aDeviceStates[i];3855 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3856 3857 for (uint32_t i = 0; i < RT_ELEMENTS(pThisCC->aDeviceStates); i++) 3858 { 3859 PBUSLOGICDEVICE pThisDevice = &pThisCC->aDeviceStates[i]; 3821 3860 if (pThisDevice->pDrvBase) 3822 3861 { … … 3840 3879 return false; 3841 3880 3842 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC);3843 ASMAtomicWriteBool(&pThis ->fSignalIdle, false);3881 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3882 ASMAtomicWriteBool(&pThisCC->fSignalIdle, false); 3844 3883 return true; 3845 3884 } … … 3850 3889 static void buslogicR3SuspendOrPowerOff(PPDMDEVINS pDevIns) 3851 3890 { 3852 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 3853 3854 ASMAtomicWriteBool(&pThis->fSignalIdle, true); 3891 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 3892 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3893 3894 ASMAtomicWriteBool(&pThisCC->fSignalIdle, true); 3855 3895 if (!buslogicR3AllAsyncIOIsFinished(pDevIns)) 3856 3896 PDMDevHlpSetAsyncNotification(pDevIns, buslogicR3IsAsyncSuspendOrPowerOffDone); 3857 3897 else 3858 3898 { 3859 ASMAtomicWriteBool(&pThis ->fSignalIdle, false);3899 ASMAtomicWriteBool(&pThisCC->fSignalIdle, false); 3860 3900 AssertMsg(!pThis->fNotificationSent, ("The PDM Queue should be empty at this point\n")); 3861 } 3862 3863 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aDeviceStates); i++) 3864 { 3865 PBUSLOGICDEVICE pThisDevice = &pThis->aDeviceStates[i]; 3901 RT_NOREF(pThis); 3902 } 3903 3904 for (uint32_t i = 0; i < RT_ELEMENTS(pThisCC->aDeviceStates); i++) 3905 { 3906 PBUSLOGICDEVICE pThisDevice = &pThisCC->aDeviceStates[i]; 3866 3907 if (pThisDevice->pDrvMediaEx) 3867 3908 pThisDevice->pDrvMediaEx->pfnNotifySuspend(pThisDevice->pDrvMediaEx); … … 3892 3933 static DECLCALLBACK(void) buslogicR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 3893 3934 { 3935 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 3936 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3937 PBUSLOGICDEVICE pDevice = &pThisCC->aDeviceStates[iLUN]; 3938 Log(("%s:\n", __FUNCTION__)); 3894 3939 RT_NOREF(fFlags); 3895 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 3896 PBUSLOGICDEVICE pDevice = &pThis->aDeviceStates[iLUN]; 3897 3898 Log(("%s:\n", __FUNCTION__)); 3940 3899 3941 3900 3942 AssertMsg(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG, … … 3904 3946 * Zero some important members. 3905 3947 */ 3948 pThis->afDevicePresent[iLUN] = false; 3906 3949 pDevice->fPresent = false; 3907 3950 pDevice->pDrvBase = NULL; … … 3923 3966 { 3924 3967 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 3925 PBUSLOGICDEVICE pDevice = &pThis->aDeviceStates[iLUN]; 3968 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3969 PBUSLOGICDEVICE pDevice = &pThisCC->aDeviceStates[iLUN]; 3926 3970 int rc; 3927 3971 … … 3959 4003 rc); 3960 4004 4005 pThis->afDevicePresent[iLUN] = true; 3961 4006 pDevice->fPresent = true; 3962 4007 } … … 3966 4011 if (RT_FAILURE(rc)) 3967 4012 { 4013 pThis->afDevicePresent[iLUN] = false; 3968 4014 pDevice->fPresent = false; 3969 4015 pDevice->pDrvBase = NULL; … … 3982 4028 static DECLCALLBACK(bool) buslogicR3IsAsyncResetDone(PPDMDEVINS pDevIns) 3983 4029 { 3984 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 4030 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 4031 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 3985 4032 3986 4033 if (!buslogicR3AllAsyncIOIsFinished(pDevIns)) 3987 4034 return false; 3988 ASMAtomicWriteBool(&pThis ->fSignalIdle, false);3989 3990 buslogicR3HwReset(p This, true);4035 ASMAtomicWriteBool(&pThisCC->fSignalIdle, false); 4036 4037 buslogicR3HwReset(pDevIns, pThis, pThisCC, true); 3991 4038 return true; 3992 4039 } … … 3997 4044 static DECLCALLBACK(void) buslogicR3Reset(PPDMDEVINS pDevIns) 3998 4045 { 3999 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 4000 4001 ASMAtomicWriteBool(&pThis->fSignalIdle, true); 4046 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 4047 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 4048 4049 ASMAtomicWriteBool(&pThisCC->fSignalIdle, true); 4002 4050 if (!buslogicR3AllAsyncIOIsFinished(pDevIns)) 4003 4051 PDMDevHlpSetAsyncNotification(pDevIns, buslogicR3IsAsyncResetDone); 4004 4052 else 4005 4053 { 4006 ASMAtomicWriteBool(&pThis->fSignalIdle, false); 4007 buslogicR3HwReset(pThis, true); 4008 } 4009 } 4010 4011 static DECLCALLBACK(void) buslogicR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 4012 { 4013 RT_NOREF(offDelta); 4014 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 4015 4016 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 4017 4018 for (uint32_t i = 0; i < BUSLOGIC_MAX_DEVICES; i++) 4019 { 4020 PBUSLOGICDEVICE pDevice = &pThis->aDeviceStates[i]; 4021 4022 pDevice->pBusLogicRC = PDMINS_2_DATA_RCPTR(pDevIns); 4023 } 4024 4054 ASMAtomicWriteBool(&pThisCC->fSignalIdle, false); 4055 buslogicR3HwReset(pDevIns, pThis, pThisCC, true); 4056 } 4025 4057 } 4026 4058 … … 4066 4098 { 4067 4099 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 4068 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 4069 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 4100 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 4101 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 4102 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 4070 4103 4071 4104 /* 4072 4105 * Init instance data (do early because of constructor). 4073 4106 */ 4074 pThis->pDevInsR3 = pDevIns; 4075 pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 4076 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 4077 pThis->IBase.pfnQueryInterface = buslogicR3StatusQueryInterface; 4078 pThis->ILeds.pfnQueryStatusLed = buslogicR3StatusQueryStatusLed; 4107 pThisCC->pDevIns = pDevIns; 4108 pThisCC->IBase.pfnQueryInterface = buslogicR3StatusQueryInterface; 4109 pThisCC->ILeds.pfnQueryStatusLed = buslogicR3StatusQueryStatusLed; 4079 4110 4080 4111 PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0]; … … 4100 4131 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "Bootable|AdapterType|ISACompat", ""); 4101 4132 4102 pThis->fGCEnabled = pDevIns->fRCEnabled;4103 pThis->fR0Enabled = pDevIns->fR0Enabled;4104 4105 4133 bool fBootable = true; 4106 4134 int rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "Bootable", &fBootable, true); … … 4214 4242 RTStrPrintf(szDevTag, sizeof(szDevTag), "BUSLOGIC-%u", iInstance); 4215 4243 4216 rc = PDMDevHlpThreadCreate(pDevIns, &pThis ->pThreadWrk, pThis, buslogicR3Worker,4244 rc = PDMDevHlpThreadCreate(pDevIns, &pThisCC->pThreadWrk, pThis, buslogicR3Worker, 4217 4245 buslogicR3WorkerWakeUp, 0, RTTHREADTYPE_IO, szDevTag); 4218 4246 if (RT_FAILURE(rc)) … … 4221 4249 4222 4250 /* Initialize per device state. */ 4223 for (unsigned i = 0; i < RT_ELEMENTS(pThis ->aDeviceStates); i++)4224 { 4225 PBUSLOGICDEVICE pDevice = &pThis ->aDeviceStates[i];4251 for (unsigned i = 0; i < RT_ELEMENTS(pThisCC->aDeviceStates); i++) 4252 { 4253 PBUSLOGICDEVICE pDevice = &pThisCC->aDeviceStates[i]; 4226 4254 4227 4255 /* Initialize static parts of the device. */ 4228 4256 pDevice->iLUN = i; 4229 pDevice->pBusLogicR3 = pThis; 4230 pDevice->pBusLogicR0 = PDMINS_2_DATA_R0PTR(pDevIns); 4231 pDevice->pBusLogicRC = PDMINS_2_DATA_RCPTR(pDevIns); 4257 pDevice->pDevIns = pDevIns; 4232 4258 pDevice->Led.u32Magic = PDMLED_MAGIC; 4233 4259 pDevice->IBase.pfnQueryInterface = buslogicR3DeviceQueryInterface; … … 4265 4291 pDevice->iLUN); 4266 4292 4293 pThis->afDevicePresent[i] = true; 4267 4294 pDevice->fPresent = true; 4268 4295 } 4269 4296 else if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 4270 4297 { 4298 pThis->afDevicePresent[i] = false; 4271 4299 pDevice->fPresent = false; 4272 4300 pDevice->pDrvBase = NULL; … … 4287 4315 */ 4288 4316 PPDMIBASE pBase; 4289 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis ->IBase, &pBase, "Status Port");4317 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThisCC->IBase, &pBase, "Status Port"); 4290 4318 if (RT_SUCCESS(rc)) 4291 4319 { 4292 pThis->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS); 4293 pThis->pMediaNotify = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIANOTIFY); 4294 } 4295 else if (rc != VERR_PDM_NO_ATTACHED_DRIVER) 4296 { 4297 AssertMsgFailed(("Failed to attach to status driver. rc=%Rrc\n", rc)); 4298 return PDMDEV_SET_ERROR(pDevIns, rc, N_("BusLogic cannot attach to status driver")); 4299 } 4320 pThisCC->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS); 4321 pThisCC->pMediaNotify = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIANOTIFY); 4322 } 4323 else 4324 AssertMsgReturn(rc == VERR_PDM_NO_ATTACHED_DRIVER, ("Failed to attach to status driver. rc=%Rrc\n", rc), 4325 PDMDEV_SET_ERROR(pDevIns, rc, N_("BusLogic cannot attach to status driver"))); 4300 4326 4301 4327 rc = PDMDevHlpSSMRegisterEx(pDevIns, BUSLOGIC_SAVED_STATE_MINOR_VERSION, sizeof(*pThis), NULL, … … 4313 4339 PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, "BusLogic HBA info", buslogicR3Info); 4314 4340 4315 rc = buslogicR3HwReset(p This, true);4341 rc = buslogicR3HwReset(pDevIns, pThis, pThisCC, true); 4316 4342 AssertMsgRC(rc, ("hardware reset of BusLogic host adapter failed rc=%Rrc\n", rc)); 4317 4343 … … 4349 4375 /* .uReserved0 = */ 0, 4350 4376 /* .szName = */ "buslogic", 4351 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | 4352 PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION | PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION |4353 PDM_DEVREG_FLAGS_FIRST_RESET_NOTIFICATION,4377 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_NEW_STYLE 4378 | PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION | PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION 4379 | PDM_DEVREG_FLAGS_FIRST_RESET_NOTIFICATION, 4354 4380 /* .fClass = */ PDM_DEVREG_CLASS_STORAGE, 4355 4381 /* .cMaxInstances = */ ~0U, 4356 4382 /* .uSharedVersion = */ 42, 4357 4383 /* .cbInstanceShared = */ sizeof(BUSLOGIC), 4358 /* .cbInstanceCC = */ 0,4359 /* .cbInstanceRC = */ 0,4384 /* .cbInstanceCC = */ sizeof(BUSLOGICCC), 4385 /* .cbInstanceRC = */ sizeof(BUSLOGICRC), 4360 4386 /* .cMaxPciDevices = */ 1, 4361 4387 /* .cMaxMsixVectors = */ 0, … … 4366 4392 /* .pfnConstruct = */ buslogicR3Construct, 4367 4393 /* .pfnDestruct = */ buslogicR3Destruct, 4368 /* .pfnRelocate = */ buslogicR3Relocate,4394 /* .pfnRelocate = */ NULL, 4369 4395 /* .pfnMemSetup = */ NULL, 4370 4396 /* .pfnPowerOn = */ NULL,
Note:
See TracChangeset
for help on using the changeset viewer.