Changeset 82667 in vbox
- Timestamp:
- Jan 8, 2020 10:13:47 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices/Storage
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevBusLogic.cpp
r82179 r82667 1174 1174 buslogicR3RegisterISARange(pDevIns, pThis, pThis->uDefaultISABaseCode); 1175 1175 buslogicR3InitializeLocalRam(pThis); 1176 vboxscsi Initialize(&pThisCC->VBoxSCSI);1176 vboxscsiHwReset(&pThisCC->VBoxSCSI); 1177 1177 1178 1178 return VINF_SUCCESS; … … 4081 4081 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); 4082 4082 PBUSLOGIC pThis = PDMDEVINS_2_DATA(pDevIns, PBUSLOGIC); 4083 PBUSLOGICCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PBUSLOGICCC); 4083 4084 4084 4085 PDMDevHlpCritSectDelete(pDevIns, &pThis->CritSectIntr); … … 4089 4090 pThis->hEvtProcess = NIL_SUPSEMEVENT; 4090 4091 } 4092 4093 vboxscsiDestroy(&pThisCC->VBoxSCSI); 4091 4094 4092 4095 return VINF_SUCCESS; … … 4207 4210 AssertRCReturn(rc, rc); 4208 4211 } 4212 4213 /* Initialize the SCSI emulation for the BIOS. */ 4214 rc = vboxscsiInitialize(&pThisCC->VBoxSCSI); 4215 if (RT_FAILURE(rc)) 4216 return PDMDEV_SET_ERROR(pDevIns, rc, N_("BusLogic failed to initialize BIOS SCSI interface")); 4209 4217 4210 4218 if (fBootable) -
trunk/src/VBox/Devices/Storage/DevLsiLogicSCSI.cpp
r82456 r82667 5080 5080 AssertRC(rc); 5081 5081 5082 vboxscsi Initialize(&pThisCC->VBoxSCSI);5082 vboxscsiHwReset(&pThisCC->VBoxSCSI); 5083 5083 } 5084 5084 … … 5150 5150 lsilogicR3ConfigurationPagesFree(pThis, pThisCC); 5151 5151 lsilogicR3MemRegionsFree(pThisCC); 5152 vboxscsiDestroy(&pThisCC->VBoxSCSI); 5152 5153 5153 5154 return VINF_SUCCESS; … … 5485 5486 /* Initialize the SCSI emulation for the BIOS. */ 5486 5487 rc = vboxscsiInitialize(&pThisCC->VBoxSCSI); 5487 AssertRC(rc); 5488 if (RT_FAILURE(rc)) 5489 return PDMDEV_SET_ERROR(pDevIns, rc, N_("LsiLogic failed to initialize BIOS SCSI interface")); 5488 5490 5489 5491 /* -
trunk/src/VBox/Devices/Storage/VBoxSCSI.cpp
r81773 r82667 70 70 int vboxscsiInitialize(PVBOXSCSI pVBoxSCSI) 71 71 { 72 pVBoxSCSI->pbBuf = NULL; 72 int rc = RTCritSectInit(&pVBoxSCSI->CritSect); 73 if (RT_SUCCESS(rc)) 74 { 75 pVBoxSCSI->pbBuf = NULL; 76 vboxscsiReset(pVBoxSCSI, true /*fEverything*/); 77 } 78 79 return rc; 80 } 81 82 /** 83 * Frees all allocated resources. 84 * 85 * @returns nothing. 86 * @param pVBoxSCSI Pointer to the SCSI state, 87 */ 88 void vboxscsiDestroy(PVBOXSCSI pVBoxSCSI) 89 { 90 if (RTCritSectIsInitialized(&pVBoxSCSI->CritSect)) 91 RTCritSectDelete(&pVBoxSCSI->CritSect); 92 } 93 94 /** 95 * Performs a hardware reset. 96 * 97 * @returns nothing. 98 * @param pVBoxSCSI Pointer to the SCSI state, 99 */ 100 void vboxscsiHwReset(PVBOXSCSI pVBoxSCSI) 101 { 73 102 vboxscsiReset(pVBoxSCSI, true /*fEverything*/); 74 75 return VINF_SUCCESS;76 103 } 77 104 … … 88 115 uint8_t uVal = 0; 89 116 117 RTCritSectEnter(&pVBoxSCSI->CritSect); 90 118 switch (iRegister) 91 119 { … … 138 166 139 167 *pu32Value = uVal; 168 RTCritSectLeave(&pVBoxSCSI->CritSect); 140 169 141 170 return VINF_SUCCESS; … … 156 185 int rc = VINF_SUCCESS; 157 186 187 RTCritSectEnter(&pVBoxSCSI->CritSect); 158 188 switch (iRegister) 159 189 { … … 270 300 } 271 301 302 RTCritSectLeave(&pVBoxSCSI->CritSect); 272 303 return rc; 273 304 } … … 291 322 LogFlowFunc(("pVBoxSCSI=%#p puTargetDevice=%#p\n", pVBoxSCSI, puTargetDevice)); 292 323 324 RTCritSectEnter(&pVBoxSCSI->CritSect); 293 325 AssertMsg(pVBoxSCSI->enmState == VBOXSCSISTATE_COMMAND_READY, ("Invalid state %u\n", pVBoxSCSI->enmState)); 294 326 … … 311 343 *pcbBuf = pVBoxSCSI->cbBuf; 312 344 *puTargetDevice = pVBoxSCSI->uTargetDevice; 345 RTCritSectLeave(&pVBoxSCSI->CritSect); 313 346 314 347 return rc; … … 323 356 LogFlowFunc(("pVBoxSCSI=%#p\n", pVBoxSCSI)); 324 357 358 RTCritSectEnter(&pVBoxSCSI->CritSect); 325 359 if (pVBoxSCSI->uTxDir == VBOXSCSI_TXDIR_TO_DEVICE) 326 360 vboxscsiReset(pVBoxSCSI, false /*fEverything*/); … … 329 363 330 364 ASMAtomicXchgBool(&pVBoxSCSI->fBusy, false); 365 RTCritSectLeave(&pVBoxSCSI->CritSect); 331 366 332 367 return VINF_SUCCESS; … … 338 373 AssertReturn(cbSkip + cbCopy <= pVBoxSCSI->cbBuf, 0); 339 374 375 RTCritSectEnter(&pVBoxSCSI->CritSect); 340 376 void *pvBuf = pVBoxSCSI->pbBuf + cbSkip; 341 return RTSgBufCopyToBuf(pSgBuf, pvBuf, cbCopy); 377 size_t cbCopied = RTSgBufCopyToBuf(pSgBuf, pvBuf, cbCopy); 378 RTCritSectLeave(&pVBoxSCSI->CritSect); 379 380 return cbCopied; 342 381 } 343 382 … … 347 386 AssertReturn(cbSkip + cbCopy <= pVBoxSCSI->cbBuf, 0); 348 387 388 RTCritSectEnter(&pVBoxSCSI->CritSect); 349 389 void *pvBuf = pVBoxSCSI->pbBuf + cbSkip; 350 return RTSgBufCopyFromBuf(pSgBuf, pvBuf, cbCopy); 390 size_t cbCopied = RTSgBufCopyFromBuf(pSgBuf, pvBuf, cbCopy); 391 RTCritSectLeave(&pVBoxSCSI->CritSect); 392 393 return cbCopied; 351 394 } 352 395 … … 376 419 Assert(!pVBoxSCSI->fBusy); 377 420 421 RTCritSectEnter(&pVBoxSCSI->CritSect); 378 422 /* 379 423 * Also ignore attempts to read more data than is available. … … 407 451 } 408 452 *pcTransfers = 0; 453 RTCritSectLeave(&pVBoxSCSI->CritSect); 409 454 410 455 return VINF_SUCCESS; … … 434 479 AssertReturn(pVBoxSCSI->uTxDir == VBOXSCSI_TXDIR_TO_DEVICE, VINF_SUCCESS); 435 480 481 RTCritSectEnter(&pVBoxSCSI->CritSect); 436 482 /* 437 483 * Ignore excess data (not supposed to happen). … … 457 503 AssertFailed(); 458 504 *pcTransfers = 0; 505 RTCritSectLeave(&pVBoxSCSI->CritSect); 459 506 460 507 return rc; -
trunk/src/VBox/Devices/Storage/VBoxSCSI.h
r81765 r82667 73 73 *******************************************************************************/ 74 74 //#define DEBUG 75 #include <iprt/semaphore.h> 75 76 #include <VBox/vmm/pdmdev.h> 76 77 #include <VBox/vmm/pdmstorageifs.h> … … 129 130 /** The state we are in when fetching a command from the BIOS. */ 130 131 VBOXSCSISTATE enmState; 132 /** Critical section protecting the device state. */ 133 RTCRITSECT CritSect; 131 134 } VBOXSCSI, *PVBOXSCSI; 132 135 … … 137 140 RT_C_DECLS_BEGIN 138 141 int vboxscsiInitialize(PVBOXSCSI pVBoxSCSI); 142 void vboxscsiDestroy(PVBOXSCSI pVBoxSCSI); 143 void vboxscsiHwReset(PVBOXSCSI pVBoxSCSI); 139 144 int vboxscsiReadRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint32_t *pu32Value); 140 145 int vboxscsiWriteRegister(PVBOXSCSI pVBoxSCSI, uint8_t iRegister, uint8_t uVal);
Note:
See TracChangeset
for help on using the changeset viewer.