vbox的更動 11269 路徑 trunk/src/VBox/Devices/Storage
- 時間撮記:
- 2008-8-8 下午04:24:48 (16 年 以前)
- 位置:
- trunk/src/VBox/Devices/Storage
- 檔案:
-
- 修改 6 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Devices/Storage/DevATA.cpp
r11267 r11269 3032 3032 * @returns true on success. 3033 3033 * @returns false when the thread is still processing. 3034 * @param p DataPointer to the controller data.3034 * @param pThis Pointer to the controller data. 3035 3035 * @param cMillies How long to wait (total). 3036 3036 */ … … 4372 4372 { 4373 4373 uint32_t i = (uint32_t)(uintptr_t)pvUser; 4374 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4375 PATACONTROLLER pCtl = &p Data->aCts[i];4374 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4375 PATACONTROLLER pCtl = &pThis->aCts[i]; 4376 4376 int rc; 4377 4377 … … 4406 4406 { 4407 4407 uint32_t i = (uint32_t)(uintptr_t)pvUser; 4408 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4409 PATACONTROLLER pCtl = &p Data->aCts[i];4408 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4409 PATACONTROLLER pCtl = &pThis->aCts[i]; 4410 4410 int rc; 4411 4411 … … 4452 4452 static DECLCALLBACK(int) ataBMDMAIORangeMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType) 4453 4453 { 4454 PCIATAState *p Data= PCIDEV_2_PCIATASTATE(pPciDev);4454 PCIATAState *pThis = PCIDEV_2_PCIATASTATE(pPciDev); 4455 4455 int rc = VINF_SUCCESS; 4456 4456 Assert(enmType == PCI_ADDRESS_SPACE_IO); … … 4459 4459 4460 4460 /* Register the port range. */ 4461 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)4461 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 4462 4462 { 4463 4463 int rc2 = PDMDevHlpIOPortRegister(pPciDev->pDevIns, (RTIOPORT)GCPhysAddress + i * 8, 8, … … 4467 4467 rc = rc2; 4468 4468 4469 if (p Data->fGCEnabled)4469 if (pThis->fGCEnabled) 4470 4470 { 4471 4471 rc2 = PDMDevHlpIOPortRegisterGC(pPciDev->pDevIns, (RTIOPORT)GCPhysAddress + i * 8, 8, … … 4475 4475 rc = rc2; 4476 4476 } 4477 if (p Data->fR0Enabled)4477 if (pThis->fR0Enabled) 4478 4478 { 4479 4479 rc2 = PDMDevHlpIOPortRegisterR0(pPciDev->pDevIns, (RTIOPORT)GCPhysAddress + i * 8, 8, … … 4496 4496 static DECLCALLBACK(void) ataReset(PPDMDEVINS pDevIns) 4497 4497 { 4498 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4499 4500 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)4501 { 4502 p Data->aCts[i].iSelectedIf = 0;4503 p Data->aCts[i].iAIOIf = 0;4504 p Data->aCts[i].BmDma.u8Cmd = 0;4498 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4499 4500 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 4501 { 4502 pThis->aCts[i].iSelectedIf = 0; 4503 pThis->aCts[i].iAIOIf = 0; 4504 pThis->aCts[i].BmDma.u8Cmd = 0; 4505 4505 /* Report that both drives present on the bus are in DMA mode. This 4506 4506 * pretends that there is a BIOS that has set it up. Normal reset 4507 4507 * default is 0x00. */ 4508 p Data->aCts[i].BmDma.u8Status = (pData->aCts[i].aIfs[0].pDrvBase != NULL ? BM_STATUS_D0DMA : 0)4509 | (p Data->aCts[i].aIfs[1].pDrvBase != NULL ? BM_STATUS_D1DMA : 0);4510 p Data->aCts[i].BmDma.pvAddr = 0;4511 4512 p Data->aCts[i].fReset = true;4513 p Data->aCts[i].fRedo = false;4514 p Data->aCts[i].fRedoIdle = false;4515 ataAsyncIOClearRequests(&p Data->aCts[i]);4508 pThis->aCts[i].BmDma.u8Status = (pThis->aCts[i].aIfs[0].pDrvBase != NULL ? BM_STATUS_D0DMA : 0) 4509 | (pThis->aCts[i].aIfs[1].pDrvBase != NULL ? BM_STATUS_D1DMA : 0); 4510 pThis->aCts[i].BmDma.pvAddr = 0; 4511 4512 pThis->aCts[i].fReset = true; 4513 pThis->aCts[i].fRedo = false; 4514 pThis->aCts[i].fRedoIdle = false; 4515 ataAsyncIOClearRequests(&pThis->aCts[i]); 4516 4516 Log2(("%s: Ctl#%d: message to async I/O thread, reset controller\n", __FUNCTION__, i)); 4517 ataAsyncIOPutRequest(&p Data->aCts[i], &ataResetARequest);4518 ataAsyncIOPutRequest(&p Data->aCts[i], &ataResetCRequest);4519 if (!ataWaitForAsyncIOIsIdle(&p Data->aCts[i], 30000))4517 ataAsyncIOPutRequest(&pThis->aCts[i], &ataResetARequest); 4518 ataAsyncIOPutRequest(&pThis->aCts[i], &ataResetCRequest); 4519 if (!ataWaitForAsyncIOIsIdle(&pThis->aCts[i], 30000)) 4520 4520 AssertReleaseMsgFailed(("Async I/O thread busy after reset\n")); 4521 4521 4522 for (uint32_t j = 0; j < RT_ELEMENTS(p Data->aCts[i].aIfs); j++)4523 ataResetDevice(&p Data->aCts[i].aIfs[j]);4522 for (uint32_t j = 0; j < RT_ELEMENTS(pThis->aCts[i].aIfs); j++) 4523 ataResetDevice(&pThis->aCts[i].aIfs[j]); 4524 4524 } 4525 4525 } … … 4538 4538 static DECLCALLBACK(void *) ataStatus_QueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface) 4539 4539 { 4540 PCIATAState *p Data= PDMIBASE_2_PCIATASTATE(pInterface);4540 PCIATAState *pThis = PDMIBASE_2_PCIATASTATE(pInterface); 4541 4541 switch (enmInterface) 4542 4542 { 4543 4543 case PDMINTERFACE_BASE: 4544 return &p Data->IBase;4544 return &pThis->IBase; 4545 4545 case PDMINTERFACE_LED_PORTS: 4546 return &p Data->ILeds;4546 return &pThis->ILeds; 4547 4547 default: 4548 4548 return NULL; … … 4563 4563 static DECLCALLBACK(int) ataStatus_QueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed) 4564 4564 { 4565 PCIATAState *p Data= PDMILEDPORTS_2_PCIATASTATE(pInterface);4565 PCIATAState *pThis = PDMILEDPORTS_2_PCIATASTATE(pInterface); 4566 4566 if (iLUN >= 0 && iLUN <= 4) 4567 4567 { 4568 4568 switch (iLUN) 4569 4569 { 4570 case 0: *ppLed = &p Data->aCts[0].aIfs[0].Led; break;4571 case 1: *ppLed = &p Data->aCts[0].aIfs[1].Led; break;4572 case 2: *ppLed = &p Data->aCts[1].aIfs[0].Led; break;4573 case 3: *ppLed = &p Data->aCts[1].aIfs[1].Led; break;4570 case 0: *ppLed = &pThis->aCts[0].aIfs[0].Led; break; 4571 case 1: *ppLed = &pThis->aCts[0].aIfs[1].Led; break; 4572 case 2: *ppLed = &pThis->aCts[1].aIfs[0].Led; break; 4573 case 3: *ppLed = &pThis->aCts[1].aIfs[1].Led; break; 4574 4574 } 4575 4575 Assert((*ppLed)->u32Magic == PDMLED_MAGIC); … … 4618 4618 { 4619 4619 uint32_t i = (uint32_t)(uintptr_t)pvUser; 4620 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4621 PATACONTROLLER pCtl = &p Data->aCts[i];4620 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4621 PATACONTROLLER pCtl = &pThis->aCts[i]; 4622 4622 int rc = VINF_SUCCESS; 4623 4623 … … 4650 4650 { 4651 4651 uint32_t i = (uint32_t)(uintptr_t)pvUser; 4652 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4653 PATACONTROLLER pCtl = &p Data->aCts[i];4652 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4653 PATACONTROLLER pCtl = &pThis->aCts[i]; 4654 4654 int rc = VINF_SUCCESS; 4655 4655 … … 4687 4687 { 4688 4688 uint32_t i = (uint32_t)(uintptr_t)pvUser; 4689 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4690 PATACONTROLLER pCtl = &p Data->aCts[i];4689 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4690 PATACONTROLLER pCtl = &pThis->aCts[i]; 4691 4691 int rc = VINF_SUCCESS; 4692 4692 … … 4744 4744 { 4745 4745 uint32_t i = (uint32_t)(uintptr_t)pvUser; 4746 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4747 PATACONTROLLER pCtl = &p Data->aCts[i];4746 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4747 PATACONTROLLER pCtl = &pThis->aCts[i]; 4748 4748 int rc; 4749 4749 … … 4801 4801 { 4802 4802 uint32_t i = (uint32_t)(uintptr_t)pvUser; 4803 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4804 PATACONTROLLER pCtl = &p Data->aCts[i];4803 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4804 PATACONTROLLER pCtl = &pThis->aCts[i]; 4805 4805 int rc; 4806 4806 … … 4825 4825 { 4826 4826 uint32_t i = (uint32_t)(uintptr_t)pvUser; 4827 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4828 PATACONTROLLER pCtl = &p Data->aCts[i];4827 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4828 PATACONTROLLER pCtl = &pThis->aCts[i]; 4829 4829 int rc; 4830 4830 … … 4850 4850 * @returns true on success. 4851 4851 * @returns false when one or more threads is still processing. 4852 * @param p DataPointer to the instance data.4852 * @param pThis Pointer to the instance data. 4853 4853 * @param cMillies How long to wait (total). 4854 4854 */ 4855 4855 static bool ataWaitForAllAsyncIOIsIdle(PPDMDEVINS pDevIns, unsigned cMillies) 4856 4856 { 4857 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4857 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4858 4858 bool fVMLocked; 4859 4859 uint64_t u64Start; … … 4879 4879 /* Check all async I/O threads. */ 4880 4880 fAllIdle = true; 4881 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)4882 { 4883 pCtl = &p Data->aCts[i];4881 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 4882 { 4883 pCtl = &pThis->aCts[i]; 4884 4884 fAllIdle &= ataAsyncIOIsIdle(pCtl, false); 4885 4885 if (!fAllIdle) … … 4918 4918 static DECLCALLBACK(void) ataRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta) 4919 4919 { 4920 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4921 4922 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)4923 { 4924 p Data->aCts[i].pDevInsRC += offDelta;4925 p Data->aCts[i].aIfs[0].pDevInsRC += offDelta;4926 p Data->aCts[i].aIfs[0].pControllerRC += offDelta;4927 ataRelocBuffer(pDevIns, &p Data->aCts[i].aIfs[0]);4928 p Data->aCts[i].aIfs[1].pDevInsRC += offDelta;4929 p Data->aCts[i].aIfs[1].pControllerRC += offDelta;4930 ataRelocBuffer(pDevIns, &p Data->aCts[i].aIfs[1]);4920 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4921 4922 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 4923 { 4924 pThis->aCts[i].pDevInsRC += offDelta; 4925 pThis->aCts[i].aIfs[0].pDevInsRC += offDelta; 4926 pThis->aCts[i].aIfs[0].pControllerRC += offDelta; 4927 ataRelocBuffer(pDevIns, &pThis->aCts[i].aIfs[0]); 4928 pThis->aCts[i].aIfs[1].pDevInsRC += offDelta; 4929 pThis->aCts[i].aIfs[1].pControllerRC += offDelta; 4930 ataRelocBuffer(pDevIns, &pThis->aCts[i].aIfs[1]); 4931 4931 } 4932 4932 } … … 4943 4943 static DECLCALLBACK(int) ataDestruct(PPDMDEVINS pDevIns) 4944 4944 { 4945 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);4945 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 4946 4946 int rc; 4947 4947 … … 4951 4951 * Terminate all async helper threads 4952 4952 */ 4953 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)4954 { 4955 if (p Data->aCts[i].AsyncIOThread != NIL_RTTHREAD)4956 { 4957 ASMAtomicXchgU32(&p Data->aCts[i].fShutdown, true);4958 rc = RTSemEventSignal(p Data->aCts[i].AsyncIOSem);4953 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 4954 { 4955 if (pThis->aCts[i].AsyncIOThread != NIL_RTTHREAD) 4956 { 4957 ASMAtomicXchgU32(&pThis->aCts[i].fShutdown, true); 4958 rc = RTSemEventSignal(pThis->aCts[i].AsyncIOSem); 4959 4959 AssertRC(rc); 4960 4960 } … … 4967 4967 if (ataWaitForAllAsyncIOIsIdle(pDevIns, 20000)) 4968 4968 { 4969 for (unsigned i = 0; i < RT_ELEMENTS(p Data->aCts); i++)4970 { 4971 rc = RTThreadWait(p Data->aCts[i].AsyncIOThread, 30000 /* 30 s*/, NULL);4969 for (unsigned i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 4970 { 4971 rc = RTThreadWait(pThis->aCts[i].AsyncIOThread, 30000 /* 30 s*/, NULL); 4972 4972 AssertMsg(RT_SUCCESS(rc) || rc == VERR_INVALID_HANDLE, ("rc=%Rrc i=%d\n", rc, i)); 4973 4973 } … … 4979 4979 * Now the request mutexes are no longer needed. Free resources. 4980 4980 */ 4981 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)4982 { 4983 if (p Data->aCts[i].AsyncIORequestMutex != NIL_RTSEMEVENT)4984 { 4985 RTSemMutexDestroy(p Data->aCts[i].AsyncIORequestMutex);4986 p Data->aCts[i].AsyncIORequestMutex = NIL_RTSEMEVENT;4981 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 4982 { 4983 if (pThis->aCts[i].AsyncIORequestMutex != NIL_RTSEMEVENT) 4984 { 4985 RTSemMutexDestroy(pThis->aCts[i].AsyncIORequestMutex); 4986 pThis->aCts[i].AsyncIORequestMutex = NIL_RTSEMEVENT; 4987 4987 } 4988 4988 } … … 5233 5233 static DECLCALLBACK(void) ataResume(PPDMDEVINS pDevIns) 5234 5234 { 5235 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);5235 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 5236 5236 int rc; 5237 5237 5238 5238 Log(("%s:\n", __FUNCTION__)); 5239 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)5240 { 5241 if (p Data->aCts[i].fRedo && pData->aCts[i].fRedoIdle)5242 { 5243 rc = RTSemEventSignal(p Data->aCts[i].SuspendIOSem);5239 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 5240 { 5241 if (pThis->aCts[i].fRedo && pThis->aCts[i].fRedoIdle) 5242 { 5243 rc = RTSemEventSignal(pThis->aCts[i].SuspendIOSem); 5244 5244 AssertRC(rc); 5245 5245 } … … 5273 5273 static DECLCALLBACK(int) ataSaveLoadPrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 5274 5274 { 5275 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);5275 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 5276 5276 5277 5277 /* sanity - the suspend notification will wait on the async stuff. */ 5278 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)5279 { 5280 Assert(ataAsyncIOIsIdle(&p Data->aCts[i], false));5281 if (!ataAsyncIOIsIdle(&p Data->aCts[i], false))5278 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 5279 { 5280 Assert(ataAsyncIOIsIdle(&pThis->aCts[i], false)); 5281 if (!ataAsyncIOIsIdle(&pThis->aCts[i], false)) 5282 5282 return VERR_SSM_IDE_ASYNC_TIMEOUT; 5283 5283 } … … 5295 5295 static DECLCALLBACK(int) ataSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle) 5296 5296 { 5297 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);5298 5299 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)5300 { 5301 SSMR3PutU8(pSSMHandle, p Data->aCts[i].iSelectedIf);5302 SSMR3PutU8(pSSMHandle, p Data->aCts[i].iAIOIf);5303 SSMR3PutU8(pSSMHandle, p Data->aCts[i].uAsyncIOState);5304 SSMR3PutBool(pSSMHandle, p Data->aCts[i].fChainedTransfer);5305 SSMR3PutBool(pSSMHandle, p Data->aCts[i].fReset);5306 SSMR3PutBool(pSSMHandle, p Data->aCts[i].fRedo);5307 SSMR3PutBool(pSSMHandle, p Data->aCts[i].fRedoIdle);5308 SSMR3PutBool(pSSMHandle, p Data->aCts[i].fRedoDMALastDesc);5309 SSMR3PutMem(pSSMHandle, &p Data->aCts[i].BmDma, sizeof(pData->aCts[i].BmDma));5310 SSMR3PutGCPhys32(pSSMHandle, p Data->aCts[i].pFirstDMADesc);5311 SSMR3PutGCPhys32(pSSMHandle, p Data->aCts[i].pLastDMADesc);5312 SSMR3PutGCPhys32(pSSMHandle, p Data->aCts[i].pRedoDMABuffer);5313 SSMR3PutU32(pSSMHandle, p Data->aCts[i].cbRedoDMABuffer);5314 5315 for (uint32_t j = 0; j < RT_ELEMENTS(p Data->aCts[i].aIfs); j++)5316 { 5317 SSMR3PutBool(pSSMHandle, p Data->aCts[i].aIfs[j].fLBA48);5318 SSMR3PutBool(pSSMHandle, p Data->aCts[i].aIfs[j].fATAPI);5319 SSMR3PutBool(pSSMHandle, p Data->aCts[i].aIfs[j].fIrqPending);5320 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].cMultSectors);5321 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].PCHSGeometry.cCylinders);5322 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].PCHSGeometry.cHeads);5323 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].PCHSGeometry.cSectors);5324 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].cSectorsPerIRQ);5325 SSMR3PutU64(pSSMHandle, p Data->aCts[i].aIfs[j].cTotalSectors);5326 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegFeature);5327 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegFeatureHOB);5328 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegError);5329 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegNSector);5330 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegNSectorHOB);5331 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegSector);5332 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegSectorHOB);5333 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegLCyl);5334 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegLCylHOB);5335 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegHCyl);5336 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegHCylHOB);5337 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegSelect);5338 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegStatus);5339 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegCommand);5340 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATARegDevCtl);5341 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATATransferMode);5342 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uTxDir);5343 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].iBeginTransfer);5344 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].iSourceSink);5345 SSMR3PutBool(pSSMHandle, p Data->aCts[i].aIfs[j].fDMA);5346 SSMR3PutBool(pSSMHandle, p Data->aCts[i].aIfs[j].fATAPITransfer);5347 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].cbTotalTransfer);5348 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].cbElementaryTransfer);5349 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].iIOBufferCur);5350 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].iIOBufferEnd);5351 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].iIOBufferPIODataStart);5352 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].iIOBufferPIODataEnd);5353 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].iATAPILBA);5354 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].cbATAPISector);5355 SSMR3PutMem(pSSMHandle, &p Data->aCts[i].aIfs[j].aATAPICmd, sizeof(pData->aCts[i].aIfs[j].aATAPICmd));5356 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATAPISenseKey);5357 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].uATAPIASC);5358 SSMR3PutU8(pSSMHandle, p Data->aCts[i].aIfs[j].cNotifiedMediaChange);5359 SSMR3PutMem(pSSMHandle, &p Data->aCts[i].aIfs[j].Led, sizeof(pData->aCts[i].aIfs[j].Led));5360 SSMR3PutU32(pSSMHandle, p Data->aCts[i].aIfs[j].cbIOBuffer);5361 if (p Data->aCts[i].aIfs[j].cbIOBuffer)5362 SSMR3PutMem(pSSMHandle, p Data->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer), pData->aCts[i].aIfs[j].cbIOBuffer);5297 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 5298 5299 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 5300 { 5301 SSMR3PutU8(pSSMHandle, pThis->aCts[i].iSelectedIf); 5302 SSMR3PutU8(pSSMHandle, pThis->aCts[i].iAIOIf); 5303 SSMR3PutU8(pSSMHandle, pThis->aCts[i].uAsyncIOState); 5304 SSMR3PutBool(pSSMHandle, pThis->aCts[i].fChainedTransfer); 5305 SSMR3PutBool(pSSMHandle, pThis->aCts[i].fReset); 5306 SSMR3PutBool(pSSMHandle, pThis->aCts[i].fRedo); 5307 SSMR3PutBool(pSSMHandle, pThis->aCts[i].fRedoIdle); 5308 SSMR3PutBool(pSSMHandle, pThis->aCts[i].fRedoDMALastDesc); 5309 SSMR3PutMem(pSSMHandle, &pThis->aCts[i].BmDma, sizeof(pThis->aCts[i].BmDma)); 5310 SSMR3PutGCPhys32(pSSMHandle, pThis->aCts[i].pFirstDMADesc); 5311 SSMR3PutGCPhys32(pSSMHandle, pThis->aCts[i].pLastDMADesc); 5312 SSMR3PutGCPhys32(pSSMHandle, pThis->aCts[i].pRedoDMABuffer); 5313 SSMR3PutU32(pSSMHandle, pThis->aCts[i].cbRedoDMABuffer); 5314 5315 for (uint32_t j = 0; j < RT_ELEMENTS(pThis->aCts[i].aIfs); j++) 5316 { 5317 SSMR3PutBool(pSSMHandle, pThis->aCts[i].aIfs[j].fLBA48); 5318 SSMR3PutBool(pSSMHandle, pThis->aCts[i].aIfs[j].fATAPI); 5319 SSMR3PutBool(pSSMHandle, pThis->aCts[i].aIfs[j].fIrqPending); 5320 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].cMultSectors); 5321 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].PCHSGeometry.cCylinders); 5322 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].PCHSGeometry.cHeads); 5323 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].PCHSGeometry.cSectors); 5324 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].cSectorsPerIRQ); 5325 SSMR3PutU64(pSSMHandle, pThis->aCts[i].aIfs[j].cTotalSectors); 5326 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegFeature); 5327 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegFeatureHOB); 5328 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegError); 5329 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegNSector); 5330 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegNSectorHOB); 5331 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegSector); 5332 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegSectorHOB); 5333 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegLCyl); 5334 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegLCylHOB); 5335 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegHCyl); 5336 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegHCylHOB); 5337 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegSelect); 5338 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegStatus); 5339 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegCommand); 5340 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATARegDevCtl); 5341 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATATransferMode); 5342 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uTxDir); 5343 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].iBeginTransfer); 5344 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].iSourceSink); 5345 SSMR3PutBool(pSSMHandle, pThis->aCts[i].aIfs[j].fDMA); 5346 SSMR3PutBool(pSSMHandle, pThis->aCts[i].aIfs[j].fATAPITransfer); 5347 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].cbTotalTransfer); 5348 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].cbElementaryTransfer); 5349 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].iIOBufferCur); 5350 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].iIOBufferEnd); 5351 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].iIOBufferPIODataStart); 5352 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].iIOBufferPIODataEnd); 5353 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].iATAPILBA); 5354 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].cbATAPISector); 5355 SSMR3PutMem(pSSMHandle, &pThis->aCts[i].aIfs[j].aATAPICmd, sizeof(pThis->aCts[i].aIfs[j].aATAPICmd)); 5356 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATAPISenseKey); 5357 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].uATAPIASC); 5358 SSMR3PutU8(pSSMHandle, pThis->aCts[i].aIfs[j].cNotifiedMediaChange); 5359 SSMR3PutMem(pSSMHandle, &pThis->aCts[i].aIfs[j].Led, sizeof(pThis->aCts[i].aIfs[j].Led)); 5360 SSMR3PutU32(pSSMHandle, pThis->aCts[i].aIfs[j].cbIOBuffer); 5361 if (pThis->aCts[i].aIfs[j].cbIOBuffer) 5362 SSMR3PutMem(pSSMHandle, pThis->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer), pThis->aCts[i].aIfs[j].cbIOBuffer); 5363 5363 else 5364 Assert(p Data->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer) == NULL);5365 } 5366 } 5367 SSMR3PutBool(pSSMHandle, p Data->fPIIX4);5364 Assert(pThis->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer) == NULL); 5365 } 5366 } 5367 SSMR3PutBool(pSSMHandle, pThis->fPIIX4); 5368 5368 5369 5369 return SSMR3PutU32(pSSMHandle, ~0); /* sanity/terminator */ … … 5381 5381 static DECLCALLBACK(int) ataLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, uint32_t u32Version) 5382 5382 { 5383 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);5383 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 5384 5384 int rc; 5385 5385 uint32_t u32; … … 5394 5394 * Restore valid parts of the PCIATAState structure 5395 5395 */ 5396 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)5396 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 5397 5397 { 5398 5398 /* integrity check */ 5399 if (!ataAsyncIOIsIdle(&p Data->aCts[i], false))5399 if (!ataAsyncIOIsIdle(&pThis->aCts[i], false)) 5400 5400 { 5401 5401 AssertMsgFailed(("Async I/O for controller %d is active\n", i)); … … 5404 5404 } 5405 5405 5406 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].iSelectedIf);5407 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].iAIOIf);5408 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].uAsyncIOState);5409 SSMR3GetBool(pSSMHandle, &p Data->aCts[i].fChainedTransfer);5410 SSMR3GetBool(pSSMHandle, (bool *)&p Data->aCts[i].fReset);5411 SSMR3GetBool(pSSMHandle, (bool *)&p Data->aCts[i].fRedo);5412 SSMR3GetBool(pSSMHandle, (bool *)&p Data->aCts[i].fRedoIdle);5413 SSMR3GetBool(pSSMHandle, (bool *)&p Data->aCts[i].fRedoDMALastDesc);5414 SSMR3GetMem(pSSMHandle, &p Data->aCts[i].BmDma, sizeof(pData->aCts[i].BmDma));5415 SSMR3GetGCPhys32(pSSMHandle, &p Data->aCts[i].pFirstDMADesc);5416 SSMR3GetGCPhys32(pSSMHandle, &p Data->aCts[i].pLastDMADesc);5417 SSMR3GetGCPhys32(pSSMHandle, &p Data->aCts[i].pRedoDMABuffer);5418 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].cbRedoDMABuffer);5419 5420 for (uint32_t j = 0; j < RT_ELEMENTS(p Data->aCts[i].aIfs); j++)5421 { 5422 SSMR3GetBool(pSSMHandle, &p Data->aCts[i].aIfs[j].fLBA48);5423 SSMR3GetBool(pSSMHandle, &p Data->aCts[i].aIfs[j].fATAPI);5424 SSMR3GetBool(pSSMHandle, &p Data->aCts[i].aIfs[j].fIrqPending);5425 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].cMultSectors);5426 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].PCHSGeometry.cCylinders);5427 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].PCHSGeometry.cHeads);5428 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].PCHSGeometry.cSectors);5429 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].cSectorsPerIRQ);5430 SSMR3GetU64(pSSMHandle, &p Data->aCts[i].aIfs[j].cTotalSectors);5431 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegFeature);5432 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegFeatureHOB);5433 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegError);5434 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegNSector);5435 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegNSectorHOB);5436 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegSector);5437 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegSectorHOB);5438 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegLCyl);5439 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegLCylHOB);5440 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegHCyl);5441 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegHCylHOB);5442 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegSelect);5443 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegStatus);5444 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegCommand);5445 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATARegDevCtl);5446 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATATransferMode);5447 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uTxDir);5448 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].iBeginTransfer);5449 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].iSourceSink);5450 SSMR3GetBool(pSSMHandle, &p Data->aCts[i].aIfs[j].fDMA);5451 SSMR3GetBool(pSSMHandle, &p Data->aCts[i].aIfs[j].fATAPITransfer);5452 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].cbTotalTransfer);5453 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].cbElementaryTransfer);5454 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].iIOBufferCur);5455 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].iIOBufferEnd);5456 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].iIOBufferPIODataStart);5457 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].iIOBufferPIODataEnd);5458 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].iATAPILBA);5459 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].cbATAPISector);5460 SSMR3GetMem(pSSMHandle, &p Data->aCts[i].aIfs[j].aATAPICmd, sizeof(pData->aCts[i].aIfs[j].aATAPICmd));5461 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATAPISenseKey);5462 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].uATAPIASC);5463 SSMR3GetU8(pSSMHandle, &p Data->aCts[i].aIfs[j].cNotifiedMediaChange);5464 SSMR3GetMem(pSSMHandle, &p Data->aCts[i].aIfs[j].Led, sizeof(pData->aCts[i].aIfs[j].Led));5465 SSMR3GetU32(pSSMHandle, &p Data->aCts[i].aIfs[j].cbIOBuffer);5466 if (p Data->aCts[i].aIfs[j].cbIOBuffer)5406 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].iSelectedIf); 5407 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].iAIOIf); 5408 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].uAsyncIOState); 5409 SSMR3GetBool(pSSMHandle, &pThis->aCts[i].fChainedTransfer); 5410 SSMR3GetBool(pSSMHandle, (bool *)&pThis->aCts[i].fReset); 5411 SSMR3GetBool(pSSMHandle, (bool *)&pThis->aCts[i].fRedo); 5412 SSMR3GetBool(pSSMHandle, (bool *)&pThis->aCts[i].fRedoIdle); 5413 SSMR3GetBool(pSSMHandle, (bool *)&pThis->aCts[i].fRedoDMALastDesc); 5414 SSMR3GetMem(pSSMHandle, &pThis->aCts[i].BmDma, sizeof(pThis->aCts[i].BmDma)); 5415 SSMR3GetGCPhys32(pSSMHandle, &pThis->aCts[i].pFirstDMADesc); 5416 SSMR3GetGCPhys32(pSSMHandle, &pThis->aCts[i].pLastDMADesc); 5417 SSMR3GetGCPhys32(pSSMHandle, &pThis->aCts[i].pRedoDMABuffer); 5418 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].cbRedoDMABuffer); 5419 5420 for (uint32_t j = 0; j < RT_ELEMENTS(pThis->aCts[i].aIfs); j++) 5421 { 5422 SSMR3GetBool(pSSMHandle, &pThis->aCts[i].aIfs[j].fLBA48); 5423 SSMR3GetBool(pSSMHandle, &pThis->aCts[i].aIfs[j].fATAPI); 5424 SSMR3GetBool(pSSMHandle, &pThis->aCts[i].aIfs[j].fIrqPending); 5425 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].cMultSectors); 5426 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].PCHSGeometry.cCylinders); 5427 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].PCHSGeometry.cHeads); 5428 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].PCHSGeometry.cSectors); 5429 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].cSectorsPerIRQ); 5430 SSMR3GetU64(pSSMHandle, &pThis->aCts[i].aIfs[j].cTotalSectors); 5431 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegFeature); 5432 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegFeatureHOB); 5433 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegError); 5434 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegNSector); 5435 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegNSectorHOB); 5436 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegSector); 5437 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegSectorHOB); 5438 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegLCyl); 5439 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegLCylHOB); 5440 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegHCyl); 5441 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegHCylHOB); 5442 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegSelect); 5443 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegStatus); 5444 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegCommand); 5445 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATARegDevCtl); 5446 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATATransferMode); 5447 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uTxDir); 5448 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].iBeginTransfer); 5449 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].iSourceSink); 5450 SSMR3GetBool(pSSMHandle, &pThis->aCts[i].aIfs[j].fDMA); 5451 SSMR3GetBool(pSSMHandle, &pThis->aCts[i].aIfs[j].fATAPITransfer); 5452 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].cbTotalTransfer); 5453 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].cbElementaryTransfer); 5454 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].iIOBufferCur); 5455 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].iIOBufferEnd); 5456 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].iIOBufferPIODataStart); 5457 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].iIOBufferPIODataEnd); 5458 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].iATAPILBA); 5459 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].cbATAPISector); 5460 SSMR3GetMem(pSSMHandle, &pThis->aCts[i].aIfs[j].aATAPICmd, sizeof(pThis->aCts[i].aIfs[j].aATAPICmd)); 5461 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATAPISenseKey); 5462 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].uATAPIASC); 5463 SSMR3GetU8(pSSMHandle, &pThis->aCts[i].aIfs[j].cNotifiedMediaChange); 5464 SSMR3GetMem(pSSMHandle, &pThis->aCts[i].aIfs[j].Led, sizeof(pThis->aCts[i].aIfs[j].Led)); 5465 SSMR3GetU32(pSSMHandle, &pThis->aCts[i].aIfs[j].cbIOBuffer); 5466 if (pThis->aCts[i].aIfs[j].cbIOBuffer) 5467 5467 { 5468 if (p Data->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer))5469 SSMR3GetMem(pSSMHandle, p Data->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer), pData->aCts[i].aIfs[j].cbIOBuffer);5468 if (pThis->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer)) 5469 SSMR3GetMem(pSSMHandle, pThis->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer), pThis->aCts[i].aIfs[j].cbIOBuffer); 5470 5470 else 5471 5471 { … … 5476 5476 /* skip the buffer if we're loading for the debugger / animator. */ 5477 5477 uint8_t u8Ignored; 5478 size_t cbLeft = p Data->aCts[i].aIfs[j].cbIOBuffer;5478 size_t cbLeft = pThis->aCts[i].aIfs[j].cbIOBuffer; 5479 5479 while (cbLeft-- > 0) 5480 5480 SSMR3GetU8(pSSMHandle, &u8Ignored); … … 5482 5482 } 5483 5483 else 5484 Assert(p Data->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer) == NULL);5485 } 5486 } 5487 SSMR3GetBool(pSSMHandle, &p Data->fPIIX4);5484 Assert(pThis->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer) == NULL); 5485 } 5486 } 5487 SSMR3GetBool(pSSMHandle, &pThis->fPIIX4); 5488 5488 5489 5489 rc = SSMR3GetU32(pSSMHandle, &u32); … … 5516 5516 static DECLCALLBACK(int) ataConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfgHandle) 5517 5517 { 5518 PCIATAState *p Data= PDMINS_2_DATA(pDevIns, PCIATAState *);5518 PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *); 5519 5519 PPDMIBASE pBase; 5520 5520 int rc; … … 5528 5528 * Initialize NIL handle values (for the destructor). 5529 5529 */ 5530 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)5531 { 5532 p Data->aCts[i].AsyncIOSem = NIL_RTSEMEVENT;5533 p Data->aCts[i].SuspendIOSem = NIL_RTSEMEVENT;5534 p Data->aCts[i].AsyncIORequestMutex = NIL_RTSEMEVENT;5530 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 5531 { 5532 pThis->aCts[i].AsyncIOSem = NIL_RTSEMEVENT; 5533 pThis->aCts[i].SuspendIOSem = NIL_RTSEMEVENT; 5534 pThis->aCts[i].AsyncIORequestMutex = NIL_RTSEMEVENT; 5535 5535 } 5536 5536 … … 5561 5561 Assert(DelayIRQMillies < 50); 5562 5562 5563 rc = CFGMR3QueryBoolDef(pCfgHandle, "PIIX4", &p Data->fPIIX4, false);5563 rc = CFGMR3QueryBoolDef(pCfgHandle, "PIIX4", &pThis->fPIIX4, false); 5564 5564 if (RT_FAILURE(rc)) 5565 5565 return PDMDEV_SET_ERROR(pDevIns, rc, 5566 5566 N_("PIIX3 configuration error: failed to read PIIX4 as boolean")); 5567 Log(("%s: fPIIX4=%d\n", __FUNCTION__, p Data->fPIIX4));5567 Log(("%s: fPIIX4=%d\n", __FUNCTION__, pThis->fPIIX4)); 5568 5568 5569 5569 /* … … 5571 5571 */ 5572 5572 /* Status LUN. */ 5573 p Data->IBase.pfnQueryInterface = ataStatus_QueryInterface;5574 p Data->ILeds.pfnQueryStatusLed = ataStatus_QueryStatusLed;5573 pThis->IBase.pfnQueryInterface = ataStatus_QueryInterface; 5574 pThis->ILeds.pfnQueryStatusLed = ataStatus_QueryStatusLed; 5575 5575 5576 5576 /* PCI configuration space. */ 5577 PCIDevSetVendorId(&p Data->dev, 0x8086); /* Intel */5578 if (p Data->fPIIX4)5579 { 5580 PCIDevSetDeviceId(&p Data->dev, 0x7111); /* PIIX4 IDE */5581 PCIDevSetRevisionId(&p Data->dev, 0x01); /* PIIX4E */5582 p Data->dev.config[0x48] = 0x00; /* UDMACTL */5583 p Data->dev.config[0x4A] = 0x00; /* UDMATIM */5584 p Data->dev.config[0x4B] = 0x00;5577 PCIDevSetVendorId(&pThis->dev, 0x8086); /* Intel */ 5578 if (pThis->fPIIX4) 5579 { 5580 PCIDevSetDeviceId(&pThis->dev, 0x7111); /* PIIX4 IDE */ 5581 PCIDevSetRevisionId(&pThis->dev, 0x01); /* PIIX4E */ 5582 pThis->dev.config[0x48] = 0x00; /* UDMACTL */ 5583 pThis->dev.config[0x4A] = 0x00; /* UDMATIM */ 5584 pThis->dev.config[0x4B] = 0x00; 5585 5585 } 5586 5586 else 5587 PCIDevSetDeviceId(&p Data->dev, 0x7010); /* PIIX3 IDE */5588 PCIDevSetCommand( &p Data->dev, PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS | PCI_COMMAND_BUSMASTER);5589 PCIDevSetClassProg( &p Data->dev, 0x8a); /* programming interface = PCI_IDE bus master is supported */5590 PCIDevSetClassSub( &p Data->dev, 0x01); /* class_sub = PCI_IDE */5591 PCIDevSetClassBase( &p Data->dev, 0x01); /* class_base = PCI_mass_storage */5592 PCIDevSetHeaderType(&p Data->dev, 0x00);5593 5594 p Data->pDevIns = pDevIns;5595 p Data->fGCEnabled = fGCEnabled;5596 p Data->fR0Enabled = fR0Enabled;5597 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)5598 { 5599 p Data->aCts[i].pDevInsR3 = pDevIns;5600 p Data->aCts[i].pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);5601 p Data->aCts[i].pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);5602 p Data->aCts[i].DelayIRQMillies = (uint32_t)DelayIRQMillies;5603 for (uint32_t j = 0; j < RT_ELEMENTS(p Data->aCts[i].aIfs); j++)5604 { 5605 p Data->aCts[i].aIfs[j].iLUN = i * RT_ELEMENTS(pData->aCts) + j;5606 p Data->aCts[i].aIfs[j].pDevInsR3 = pDevIns;5607 p Data->aCts[i].aIfs[j].pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);5608 p Data->aCts[i].aIfs[j].pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);5609 p Data->aCts[i].aIfs[j].pControllerR3 = &pData->aCts[i];5610 p Data->aCts[i].aIfs[j].pControllerR0 = MMHyperR3ToR0(PDMDevHlpGetVM(pDevIns), &pData->aCts[i]);5611 p Data->aCts[i].aIfs[j].pControllerRC = MMHyperR3ToRC(PDMDevHlpGetVM(pDevIns), &pData->aCts[i]);5612 p Data->aCts[i].aIfs[j].IBase.pfnQueryInterface = ataQueryInterface;5613 p Data->aCts[i].aIfs[j].IMountNotify.pfnMountNotify = ataMountNotify;5614 p Data->aCts[i].aIfs[j].IMountNotify.pfnUnmountNotify = ataUnmountNotify;5615 p Data->aCts[i].aIfs[j].Led.u32Magic = PDMLED_MAGIC;5616 } 5617 } 5618 5619 Assert(RT_ELEMENTS(p Data->aCts) == 2);5620 p Data->aCts[0].irq = 14;5621 p Data->aCts[0].IOPortBase1 = 0x1f0;5622 p Data->aCts[0].IOPortBase2 = 0x3f6;5623 p Data->aCts[1].irq = 15;5624 p Data->aCts[1].IOPortBase1 = 0x170;5625 p Data->aCts[1].IOPortBase2 = 0x376;5587 PCIDevSetDeviceId(&pThis->dev, 0x7010); /* PIIX3 IDE */ 5588 PCIDevSetCommand( &pThis->dev, PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS | PCI_COMMAND_BUSMASTER); 5589 PCIDevSetClassProg( &pThis->dev, 0x8a); /* programming interface = PCI_IDE bus master is supported */ 5590 PCIDevSetClassSub( &pThis->dev, 0x01); /* class_sub = PCI_IDE */ 5591 PCIDevSetClassBase( &pThis->dev, 0x01); /* class_base = PCI_mass_storage */ 5592 PCIDevSetHeaderType(&pThis->dev, 0x00); 5593 5594 pThis->pDevIns = pDevIns; 5595 pThis->fGCEnabled = fGCEnabled; 5596 pThis->fR0Enabled = fR0Enabled; 5597 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 5598 { 5599 pThis->aCts[i].pDevInsR3 = pDevIns; 5600 pThis->aCts[i].pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 5601 pThis->aCts[i].pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 5602 pThis->aCts[i].DelayIRQMillies = (uint32_t)DelayIRQMillies; 5603 for (uint32_t j = 0; j < RT_ELEMENTS(pThis->aCts[i].aIfs); j++) 5604 { 5605 pThis->aCts[i].aIfs[j].iLUN = i * RT_ELEMENTS(pThis->aCts) + j; 5606 pThis->aCts[i].aIfs[j].pDevInsR3 = pDevIns; 5607 pThis->aCts[i].aIfs[j].pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 5608 pThis->aCts[i].aIfs[j].pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 5609 pThis->aCts[i].aIfs[j].pControllerR3 = &pThis->aCts[i]; 5610 pThis->aCts[i].aIfs[j].pControllerR0 = MMHyperR3ToR0(PDMDevHlpGetVM(pDevIns), &pThis->aCts[i]); 5611 pThis->aCts[i].aIfs[j].pControllerRC = MMHyperR3ToRC(PDMDevHlpGetVM(pDevIns), &pThis->aCts[i]); 5612 pThis->aCts[i].aIfs[j].IBase.pfnQueryInterface = ataQueryInterface; 5613 pThis->aCts[i].aIfs[j].IMountNotify.pfnMountNotify = ataMountNotify; 5614 pThis->aCts[i].aIfs[j].IMountNotify.pfnUnmountNotify = ataUnmountNotify; 5615 pThis->aCts[i].aIfs[j].Led.u32Magic = PDMLED_MAGIC; 5616 } 5617 } 5618 5619 Assert(RT_ELEMENTS(pThis->aCts) == 2); 5620 pThis->aCts[0].irq = 14; 5621 pThis->aCts[0].IOPortBase1 = 0x1f0; 5622 pThis->aCts[0].IOPortBase2 = 0x3f6; 5623 pThis->aCts[1].irq = 15; 5624 pThis->aCts[1].IOPortBase1 = 0x170; 5625 pThis->aCts[1].IOPortBase2 = 0x376; 5626 5626 5627 5627 /* … … 5630 5630 * device the slot next to itself. 5631 5631 */ 5632 rc = PDMDevHlpPCIRegister(pDevIns, &p Data->dev);5632 rc = PDMDevHlpPCIRegister(pDevIns, &pThis->dev); 5633 5633 if (RT_FAILURE(rc)) 5634 5634 return PDMDEV_SET_ERROR(pDevIns, rc, 5635 5635 N_("PIIX3 cannot register PCI device")); 5636 AssertMsg(p Data->dev.devfn == 9 || iInstance != 0, ("pData->dev.devfn=%d\n", pData->dev.devfn));5636 AssertMsg(pThis->dev.devfn == 9 || iInstance != 0, ("pThis->dev.devfn=%d\n", pThis->dev.devfn)); 5637 5637 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 4, 0x10, PCI_ADDRESS_SPACE_IO, ataBMDMAIORangeMap); 5638 5638 if (RT_FAILURE(rc)) … … 5644 5644 * The ports are all hardcoded and enforced by the PIIX3 host bridge controller. 5645 5645 */ 5646 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)5647 { 5648 rc = PDMDevHlpIOPortRegister(pDevIns, p Data->aCts[i].IOPortBase1, 8, (RTHCPTR)i,5646 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 5647 { 5648 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->aCts[i].IOPortBase1, 8, (RTHCPTR)i, 5649 5649 ataIOPortWrite1, ataIOPortRead1, ataIOPortWriteStr1, ataIOPortReadStr1, "ATA I/O Base 1"); 5650 5650 if (RT_FAILURE(rc)) … … 5653 5653 if (fGCEnabled) 5654 5654 { 5655 rc = PDMDevHlpIOPortRegisterGC(pDevIns, p Data->aCts[i].IOPortBase1, 8, (RTGCPTR)i,5655 rc = PDMDevHlpIOPortRegisterGC(pDevIns, pThis->aCts[i].IOPortBase1, 8, (RTGCPTR)i, 5656 5656 "ataIOPortWrite1", "ataIOPortRead1", "ataIOPortWriteStr1", "ataIOPortReadStr1", "ATA I/O Base 1"); 5657 5657 if (RT_FAILURE(rc)) … … 5662 5662 { 5663 5663 #if 1 5664 rc = PDMDevHlpIOPortRegisterR0(pDevIns, p Data->aCts[i].IOPortBase1, 8, (RTR0PTR)i,5664 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->aCts[i].IOPortBase1, 8, (RTR0PTR)i, 5665 5665 "ataIOPortWrite1", "ataIOPortRead1", NULL, NULL, "ATA I/O Base 1"); 5666 5666 #else 5667 rc = PDMDevHlpIOPortRegisterR0(pDevIns, p Data->aCts[i].IOPortBase1, 8, (RTR0PTR)i,5667 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->aCts[i].IOPortBase1, 8, (RTR0PTR)i, 5668 5668 "ataIOPortWrite1", "ataIOPortRead1", "ataIOPortWriteStr1", "ataIOPortReadStr1", "ATA I/O Base 1"); 5669 5669 #endif … … 5672 5672 } 5673 5673 5674 rc = PDMDevHlpIOPortRegister(pDevIns, p Data->aCts[i].IOPortBase2, 1, (RTHCPTR)i,5674 rc = PDMDevHlpIOPortRegister(pDevIns, pThis->aCts[i].IOPortBase2, 1, (RTHCPTR)i, 5675 5675 ataIOPortWrite2, ataIOPortRead2, NULL, NULL, "ATA I/O Base 2"); 5676 5676 if (RT_FAILURE(rc)) … … 5679 5679 if (fGCEnabled) 5680 5680 { 5681 rc = PDMDevHlpIOPortRegisterGC(pDevIns, p Data->aCts[i].IOPortBase2, 1, (RTGCPTR)i,5681 rc = PDMDevHlpIOPortRegisterGC(pDevIns, pThis->aCts[i].IOPortBase2, 1, (RTGCPTR)i, 5682 5682 "ataIOPortWrite2", "ataIOPortRead2", NULL, NULL, "ATA I/O Base 2"); 5683 5683 if (RT_FAILURE(rc)) … … 5686 5686 if (fR0Enabled) 5687 5687 { 5688 rc = PDMDevHlpIOPortRegisterR0(pDevIns, p Data->aCts[i].IOPortBase2, 1, (RTR0PTR)i,5688 rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->aCts[i].IOPortBase2, 1, (RTR0PTR)i, 5689 5689 "ataIOPortWrite2", "ataIOPortRead2", NULL, NULL, "ATA I/O Base 2"); 5690 5690 if (RT_FAILURE(rc)) … … 5692 5692 } 5693 5693 5694 for (uint32_t j = 0; j < RT_ELEMENTS(p Data->aCts[i].aIfs); j++)5695 { 5696 ATADevState *pIf = &p Data->aCts[i].aIfs[j];5694 for (uint32_t j = 0; j < RT_ELEMENTS(pThis->aCts[i].aIfs); j++) 5695 { 5696 ATADevState *pIf = &pThis->aCts[i].aIfs[j]; 5697 5697 PDMDevHlpSTAMRegisterF(pDevIns, &pIf->StatATADMA, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of ATA DMA transfers.", "/Devices/ATA%d/Unit%d/DMA", i, j); 5698 5698 PDMDevHlpSTAMRegisterF(pDevIns, &pIf->StatATAPIO, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of ATA PIO transfers.", "/Devices/ATA%d/Unit%d/PIO", i, j); … … 5715 5715 } 5716 5716 #ifdef VBOX_WITH_STATISTICS /** @todo release too. */ 5717 PDMDevHlpSTAMRegisterF(pDevIns, &p Data->aCts[i].StatAsyncOps, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "The number of async operations.", "/Devices/ATA%d/Async/Operations", i);5717 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->aCts[i].StatAsyncOps, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "The number of async operations.", "/Devices/ATA%d/Async/Operations", i); 5718 5718 /** @todo STAMUNIT_MICROSECS */ 5719 PDMDevHlpSTAMRegisterF(pDevIns, &p Data->aCts[i].StatAsyncMinWait, STAMTYPE_U64_RESET, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE, "Minimum wait in microseconds.", "/Devices/ATA%d/Async/MinWait", i);5720 PDMDevHlpSTAMRegisterF(pDevIns, &p Data->aCts[i].StatAsyncMaxWait, STAMTYPE_U64_RESET, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE, "Maximum wait in microseconds.", "/Devices/ATA%d/Async/MaxWait", i);5721 PDMDevHlpSTAMRegisterF(pDevIns, &p Data->aCts[i].StatAsyncTimeUS, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE, "Total time spent in microseconds.","/Devices/ATA%d/Async/TotalTimeUS", i);5722 PDMDevHlpSTAMRegisterF(pDevIns, &p Data->aCts[i].StatAsyncTime, STAMTYPE_PROFILE_ADV, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling of async operations.", "/Devices/ATA%d/Async/Time", i);5723 PDMDevHlpSTAMRegisterF(pDevIns, &p Data->aCts[i].StatLockWait, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling of locks.", "/Devices/ATA%d/Async/LockWait", i);5719 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->aCts[i].StatAsyncMinWait, STAMTYPE_U64_RESET, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE, "Minimum wait in microseconds.", "/Devices/ATA%d/Async/MinWait", i); 5720 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->aCts[i].StatAsyncMaxWait, STAMTYPE_U64_RESET, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE, "Maximum wait in microseconds.", "/Devices/ATA%d/Async/MaxWait", i); 5721 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->aCts[i].StatAsyncTimeUS, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE, "Total time spent in microseconds.","/Devices/ATA%d/Async/TotalTimeUS", i); 5722 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->aCts[i].StatAsyncTime, STAMTYPE_PROFILE_ADV, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling of async operations.", "/Devices/ATA%d/Async/Time", i); 5723 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->aCts[i].StatLockWait, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling of locks.", "/Devices/ATA%d/Async/LockWait", i); 5724 5724 #endif /* VBOX_WITH_STATISTICS */ 5725 5725 … … 5727 5727 char szName[24]; 5728 5728 RTStrPrintf(szName, sizeof(szName), "ATA%d", i); 5729 rc = PDMDevHlpCritSectInit(pDevIns, &p Data->aCts[i].lock, szName);5729 rc = PDMDevHlpCritSectInit(pDevIns, &pThis->aCts[i].lock, szName); 5730 5730 if (RT_FAILURE(rc)) 5731 5731 return PDMDEV_SET_ERROR(pDevIns, rc, N_("PIIX3 cannot initialize critical section")); … … 5735 5735 * Attach status driver (optional). 5736 5736 */ 5737 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &p Data->IBase, &pBase, "Status Port");5737 rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis->IBase, &pBase, "Status Port"); 5738 5738 if (RT_SUCCESS(rc)) 5739 p Data->pLedsConnector = (PDMILEDCONNECTORS *)pBase->pfnQueryInterface(pBase, PDMINTERFACE_LED_CONNECTORS);5739 pThis->pLedsConnector = (PDMILEDCONNECTORS *)pBase->pfnQueryInterface(pBase, PDMINTERFACE_LED_CONNECTORS); 5740 5740 else if (rc != VERR_PDM_NO_ATTACHED_DRIVER) 5741 5741 { … … 5748 5748 */ 5749 5749 uint32_t cbTotalBuffer = 0; 5750 for (uint32_t i = 0; i < RT_ELEMENTS(p Data->aCts); i++)5751 { 5752 PATACONTROLLER pCtl = &p Data->aCts[i];5750 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++) 5751 { 5752 PATACONTROLLER pCtl = &pThis->aCts[i]; 5753 5753 5754 5754 /* … … 5770 5770 for (uint32_t j = 0; j < RT_ELEMENTS(pCtl->aIfs); j++) 5771 5771 { 5772 static const char *s_apszDescs[RT_ELEMENTS(p Data->aCts)][RT_ELEMENTS(pCtl->aIfs)] =5772 static const char *s_apszDescs[RT_ELEMENTS(pThis->aCts)][RT_ELEMENTS(pCtl->aIfs)] = 5773 5773 { 5774 5774 { "Primary Master", "Primary Slave" }, … … 5814 5814 5815 5815 rc = PDMDevHlpSSMRegister(pDevIns, pDevIns->pDevReg->szDeviceName, iInstance, 5816 ATA_SAVED_STATE_VERSION, sizeof(*p Data) + cbTotalBuffer,5816 ATA_SAVED_STATE_VERSION, sizeof(*pThis) + cbTotalBuffer, 5817 5817 ataSaveLoadPrep, ataSaveExec, NULL, 5818 5818 ataSaveLoadPrep, ataLoadExec, NULL); -
trunk/src/VBox/Devices/Storage/DrvBlock.cpp
r11267 r11269 127 127 static DECLCALLBACK(int) drvblockRead(PPDMIBLOCK pInterface, uint64_t off, void *pvBuf, size_t cbRead) 128 128 { 129 PDRVBLOCK p Data= PDMIBLOCK_2_DRVBLOCK(pInterface);130 131 /* 132 * Check the state. 133 */ 134 if (!p Data->pDrvMedia)129 PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface); 130 131 /* 132 * Check the state. 133 */ 134 if (!pThis->pDrvMedia) 135 135 { 136 136 AssertMsgFailed(("Invalid state! Not mounted!\n")); … … 138 138 } 139 139 140 int rc = p Data->pDrvMedia->pfnRead(pData->pDrvMedia, off, pvBuf, cbRead);140 int rc = pThis->pDrvMedia->pfnRead(pThis->pDrvMedia, off, pvBuf, cbRead); 141 141 return rc; 142 142 } … … 146 146 static DECLCALLBACK(int) drvblockWrite(PPDMIBLOCK pInterface, uint64_t off, const void *pvBuf, size_t cbWrite) 147 147 { 148 PDRVBLOCK p Data= PDMIBLOCK_2_DRVBLOCK(pInterface);149 150 /* 151 * Check the state. 152 */ 153 if (!p Data->pDrvMedia)148 PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface); 149 150 /* 151 * Check the state. 152 */ 153 if (!pThis->pDrvMedia) 154 154 { 155 155 AssertMsgFailed(("Invalid state! Not mounted!\n")); … … 157 157 } 158 158 159 int rc = p Data->pDrvMedia->pfnWrite(pData->pDrvMedia, off, pvBuf, cbWrite);159 int rc = pThis->pDrvMedia->pfnWrite(pThis->pDrvMedia, off, pvBuf, cbWrite); 160 160 #ifdef VBOX_PERIODIC_FLUSH 161 if (p Data->cbFlushInterval)162 { 163 p Data->cbDataWritten += cbWrite;164 if (p Data->cbDataWritten > pData->cbFlushInterval)161 if (pThis->cbFlushInterval) 162 { 163 pThis->cbDataWritten += cbWrite; 164 if (pThis->cbDataWritten > pThis->cbFlushInterval) 165 165 { 166 p Data->cbDataWritten = 0;167 p Data->pDrvMedia->pfnFlush(pData->pDrvMedia);166 pThis->cbDataWritten = 0; 167 pThis->pDrvMedia->pfnFlush(pThis->pDrvMedia); 168 168 } 169 169 } … … 177 177 static DECLCALLBACK(int) drvblockFlush(PPDMIBLOCK pInterface) 178 178 { 179 PDRVBLOCK p Data= PDMIBLOCK_2_DRVBLOCK(pInterface);180 181 /* 182 * Check the state. 183 */ 184 if (!p Data->pDrvMedia)179 PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface); 180 181 /* 182 * Check the state. 183 */ 184 if (!pThis->pDrvMedia) 185 185 { 186 186 AssertMsgFailed(("Invalid state! Not mounted!\n")); … … 189 189 190 190 #ifdef VBOX_IGNORE_FLUSH 191 if (p Data->fIgnoreFlush)191 if (pThis->fIgnoreFlush) 192 192 return VINF_SUCCESS; 193 193 #endif /* VBOX_IGNORE_FLUSH */ 194 194 195 int rc = p Data->pDrvMedia->pfnFlush(pData->pDrvMedia);195 int rc = pThis->pDrvMedia->pfnFlush(pThis->pDrvMedia); 196 196 if (rc == VERR_NOT_IMPLEMENTED) 197 197 rc = VINF_SUCCESS; … … 203 203 static DECLCALLBACK(bool) drvblockIsReadOnly(PPDMIBLOCK pInterface) 204 204 { 205 PDRVBLOCK p Data= PDMIBLOCK_2_DRVBLOCK(pInterface);206 207 /* 208 * Check the state. 209 */ 210 if (!p Data->pDrvMedia)205 PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface); 206 207 /* 208 * Check the state. 209 */ 210 if (!pThis->pDrvMedia) 211 211 return false; 212 212 213 bool fRc = p Data->pDrvMedia->pfnIsReadOnly(pData->pDrvMedia);213 bool fRc = pThis->pDrvMedia->pfnIsReadOnly(pThis->pDrvMedia); 214 214 return fRc; 215 215 } … … 219 219 static DECLCALLBACK(uint64_t) drvblockGetSize(PPDMIBLOCK pInterface) 220 220 { 221 PDRVBLOCK p Data= PDMIBLOCK_2_DRVBLOCK(pInterface);222 223 /* 224 * Check the state. 225 */ 226 if (!p Data->pDrvMedia)221 PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface); 222 223 /* 224 * Check the state. 225 */ 226 if (!pThis->pDrvMedia) 227 227 return 0; 228 228 229 uint64_t cb = p Data->pDrvMedia->pfnGetSize(pData->pDrvMedia);229 uint64_t cb = pThis->pDrvMedia->pfnGetSize(pThis->pDrvMedia); 230 230 LogFlow(("drvblockGetSize: returns %llu\n", cb)); 231 231 return cb; … … 236 236 static DECLCALLBACK(PDMBLOCKTYPE) drvblockGetType(PPDMIBLOCK pInterface) 237 237 { 238 PDRVBLOCK p Data= PDMIBLOCK_2_DRVBLOCK(pInterface);239 LogFlow(("drvblockGetType: returns %d\n", p Data->enmType));240 return p Data->enmType;238 PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface); 239 LogFlow(("drvblockGetType: returns %d\n", pThis->enmType)); 240 return pThis->enmType; 241 241 } 242 242 … … 245 245 static DECLCALLBACK(int) drvblockGetUuid(PPDMIBLOCK pInterface, PRTUUID pUuid) 246 246 { 247 PDRVBLOCK p Data= PDMIBLOCK_2_DRVBLOCK(pInterface);247 PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface); 248 248 249 249 /* 250 250 * Copy the uuid. 251 251 */ 252 *pUuid = p Data->Uuid;252 *pUuid = pThis->Uuid; 253 253 return VINF_SUCCESS; 254 254 } … … 262 262 static DECLCALLBACK(int) drvblockAsyncReadStart(PPDMIBLOCKASYNC pInterface, uint64_t off, PPDMDATASEG pSeg, unsigned cSeg, size_t cbRead, void *pvUser) 263 263 { 264 PDRVBLOCK p Data= PDMIBLOCKASYNC_2_DRVBLOCK(pInterface);265 266 /* 267 * Check the state. 268 */ 269 if (!p Data->pDrvMediaAsync)264 PDRVBLOCK pThis = PDMIBLOCKASYNC_2_DRVBLOCK(pInterface); 265 266 /* 267 * Check the state. 268 */ 269 if (!pThis->pDrvMediaAsync) 270 270 { 271 271 AssertMsgFailed(("Invalid state! Not mounted!\n")); … … 273 273 } 274 274 275 int rc = p Data->pDrvMediaAsync->pfnStartRead(pData->pDrvMediaAsync, off, pSeg, cSeg, cbRead, pvUser);275 int rc = pThis->pDrvMediaAsync->pfnStartRead(pThis->pDrvMediaAsync, off, pSeg, cSeg, cbRead, pvUser); 276 276 return rc; 277 277 } … … 281 281 static DECLCALLBACK(int) drvblockAsyncWriteStart(PPDMIBLOCKASYNC pInterface, uint64_t off, PPDMDATASEG pSeg, unsigned cSeg, size_t cbWrite, void *pvUser) 282 282 { 283 PDRVBLOCK p Data= PDMIBLOCKASYNC_2_DRVBLOCK(pInterface);284 285 /* 286 * Check the state. 287 */ 288 if (!p Data->pDrvMediaAsync)283 PDRVBLOCK pThis = PDMIBLOCKASYNC_2_DRVBLOCK(pInterface); 284 285 /* 286 * Check the state. 287 */ 288 if (!pThis->pDrvMediaAsync) 289 289 { 290 290 AssertMsgFailed(("Invalid state! Not mounted!\n")); … … 292 292 } 293 293 294 int rc = p Data->pDrvMediaAsync->pfnStartWrite(pData->pDrvMediaAsync, off, pSeg, cSeg, cbWrite, pvUser);294 int rc = pThis->pDrvMediaAsync->pfnStartWrite(pThis->pDrvMediaAsync, off, pSeg, cSeg, cbWrite, pvUser); 295 295 296 296 return rc; … … 304 304 static DECLCALLBACK(int) drvblockAsyncTransferCompleteNotify(PPDMIMEDIAASYNCPORT pInterface, void *pvUser) 305 305 { 306 PDRVBLOCK p Data= PDMIMEDIAASYNCPORT_2_DRVBLOCK(pInterface);307 308 return p Data->pDrvBlockAsyncPort->pfnTransferCompleteNotify(pData->pDrvBlockAsyncPort, pvUser);306 PDRVBLOCK pThis = PDMIMEDIAASYNCPORT_2_DRVBLOCK(pInterface); 307 308 return pThis->pDrvBlockAsyncPort->pfnTransferCompleteNotify(pThis->pDrvBlockAsyncPort, pvUser); 309 309 } 310 310 … … 318 318 static DECLCALLBACK(int) drvblockGetPCHSGeometry(PPDMIBLOCKBIOS pInterface, PPDMMEDIAGEOMETRY pPCHSGeometry) 319 319 { 320 PDRVBLOCK p Data= PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);321 322 /* 323 * Check the state. 324 */ 325 if (!p Data->pDrvMedia)320 PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface); 321 322 /* 323 * Check the state. 324 */ 325 if (!pThis->pDrvMedia) 326 326 return VERR_PDM_MEDIA_NOT_MOUNTED; 327 327 … … 329 329 * Use configured/cached values if present. 330 330 */ 331 if ( p Data->PCHSGeometry.cCylinders > 0332 && p Data->PCHSGeometry.cHeads > 0333 && p Data->PCHSGeometry.cSectors > 0)334 { 335 *pPCHSGeometry = p Data->PCHSGeometry;336 LogFlow(("%s: returns VINF_SUCCESS {%d,%d,%d}\n", __FUNCTION__, p Data->PCHSGeometry.cCylinders, pData->PCHSGeometry.cHeads, pData->PCHSGeometry.cSectors));331 if ( pThis->PCHSGeometry.cCylinders > 0 332 && pThis->PCHSGeometry.cHeads > 0 333 && pThis->PCHSGeometry.cSectors > 0) 334 { 335 *pPCHSGeometry = pThis->PCHSGeometry; 336 LogFlow(("%s: returns VINF_SUCCESS {%d,%d,%d}\n", __FUNCTION__, pThis->PCHSGeometry.cCylinders, pThis->PCHSGeometry.cHeads, pThis->PCHSGeometry.cSectors)); 337 337 return VINF_SUCCESS; 338 338 } … … 341 341 * Call media. 342 342 */ 343 int rc = p Data->pDrvMedia->pfnBiosGetPCHSGeometry(pData->pDrvMedia, &pData->PCHSGeometry);343 int rc = pThis->pDrvMedia->pfnBiosGetPCHSGeometry(pThis->pDrvMedia, &pThis->PCHSGeometry); 344 344 345 345 if (RT_SUCCESS(rc)) 346 346 { 347 *pPCHSGeometry = p Data->PCHSGeometry;348 LogFlow(("%s: returns %Vrc {%d,%d,%d}\n", __FUNCTION__, rc, p Data->PCHSGeometry.cCylinders, pData->PCHSGeometry.cHeads, pData->PCHSGeometry.cSectors));347 *pPCHSGeometry = pThis->PCHSGeometry; 348 LogFlow(("%s: returns %Vrc {%d,%d,%d}\n", __FUNCTION__, rc, pThis->PCHSGeometry.cCylinders, pThis->PCHSGeometry.cHeads, pThis->PCHSGeometry.cSectors)); 349 349 } 350 350 else if (rc == VERR_NOT_IMPLEMENTED) … … 361 361 { 362 362 LogFlow(("%s: cCylinders=%d cHeads=%d cSectors=%d\n", __FUNCTION__, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors)); 363 PDRVBLOCK p Data= PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);364 365 /* 366 * Check the state. 367 */ 368 if (!p Data->pDrvMedia)363 PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface); 364 365 /* 366 * Check the state. 367 */ 368 if (!pThis->pDrvMedia) 369 369 { 370 370 AssertMsgFailed(("Invalid state! Not mounted!\n")); … … 375 375 * Call media. Ignore the not implemented return code. 376 376 */ 377 int rc = p Data->pDrvMedia->pfnBiosSetPCHSGeometry(pData->pDrvMedia, pPCHSGeometry);377 int rc = pThis->pDrvMedia->pfnBiosSetPCHSGeometry(pThis->pDrvMedia, pPCHSGeometry); 378 378 379 379 if ( RT_SUCCESS(rc) 380 380 || rc == VERR_NOT_IMPLEMENTED) 381 381 { 382 p Data->PCHSGeometry = *pPCHSGeometry;382 pThis->PCHSGeometry = *pPCHSGeometry; 383 383 rc = VINF_SUCCESS; 384 384 } … … 390 390 static DECLCALLBACK(int) drvblockGetLCHSGeometry(PPDMIBLOCKBIOS pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry) 391 391 { 392 PDRVBLOCK p Data= PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);393 394 /* 395 * Check the state. 396 */ 397 if (!p Data->pDrvMedia)392 PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface); 393 394 /* 395 * Check the state. 396 */ 397 if (!pThis->pDrvMedia) 398 398 return VERR_PDM_MEDIA_NOT_MOUNTED; 399 399 … … 401 401 * Use configured/cached values if present. 402 402 */ 403 if ( p Data->LCHSGeometry.cCylinders > 0404 && p Data->LCHSGeometry.cHeads > 0405 && p Data->LCHSGeometry.cSectors > 0)406 { 407 *pLCHSGeometry = p Data->LCHSGeometry;408 LogFlow(("%s: returns VINF_SUCCESS {%d,%d,%d}\n", __FUNCTION__, p Data->LCHSGeometry.cCylinders, pData->LCHSGeometry.cHeads, pData->LCHSGeometry.cSectors));403 if ( pThis->LCHSGeometry.cCylinders > 0 404 && pThis->LCHSGeometry.cHeads > 0 405 && pThis->LCHSGeometry.cSectors > 0) 406 { 407 *pLCHSGeometry = pThis->LCHSGeometry; 408 LogFlow(("%s: returns VINF_SUCCESS {%d,%d,%d}\n", __FUNCTION__, pThis->LCHSGeometry.cCylinders, pThis->LCHSGeometry.cHeads, pThis->LCHSGeometry.cSectors)); 409 409 return VINF_SUCCESS; 410 410 } … … 413 413 * Call media. 414 414 */ 415 int rc = p Data->pDrvMedia->pfnBiosGetLCHSGeometry(pData->pDrvMedia, &pData->LCHSGeometry);415 int rc = pThis->pDrvMedia->pfnBiosGetLCHSGeometry(pThis->pDrvMedia, &pThis->LCHSGeometry); 416 416 417 417 if (RT_SUCCESS(rc)) 418 418 { 419 *pLCHSGeometry = p Data->LCHSGeometry;420 LogFlow(("%s: returns %Vrc {%d,%d,%d}\n", __FUNCTION__, rc, p Data->LCHSGeometry.cCylinders, pData->LCHSGeometry.cHeads, pData->LCHSGeometry.cSectors));419 *pLCHSGeometry = pThis->LCHSGeometry; 420 LogFlow(("%s: returns %Vrc {%d,%d,%d}\n", __FUNCTION__, rc, pThis->LCHSGeometry.cCylinders, pThis->LCHSGeometry.cHeads, pThis->LCHSGeometry.cSectors)); 421 421 } 422 422 else if (rc == VERR_NOT_IMPLEMENTED) … … 433 433 { 434 434 LogFlow(("%s: cCylinders=%d cHeads=%d cSectors=%d\n", __FUNCTION__, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors)); 435 PDRVBLOCK p Data= PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);436 437 /* 438 * Check the state. 439 */ 440 if (!p Data->pDrvMedia)435 PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface); 436 437 /* 438 * Check the state. 439 */ 440 if (!pThis->pDrvMedia) 441 441 { 442 442 AssertMsgFailed(("Invalid state! Not mounted!\n")); … … 447 447 * Call media. Ignore the not implemented return code. 448 448 */ 449 int rc = p Data->pDrvMedia->pfnBiosSetLCHSGeometry(pData->pDrvMedia, pLCHSGeometry);449 int rc = pThis->pDrvMedia->pfnBiosSetLCHSGeometry(pThis->pDrvMedia, pLCHSGeometry); 450 450 451 451 if ( RT_SUCCESS(rc) 452 452 || rc == VERR_NOT_IMPLEMENTED) 453 453 { 454 p Data->LCHSGeometry = *pLCHSGeometry;454 pThis->LCHSGeometry = *pLCHSGeometry; 455 455 rc = VINF_SUCCESS; 456 456 } … … 462 462 static DECLCALLBACK(bool) drvblockIsVisible(PPDMIBLOCKBIOS pInterface) 463 463 { 464 PDRVBLOCK p Data= PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);465 LogFlow(("drvblockIsVisible: returns %d\n", p Data->fBiosVisible));466 return p Data->fBiosVisible;464 PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface); 465 LogFlow(("drvblockIsVisible: returns %d\n", pThis->fBiosVisible)); 466 return pThis->fBiosVisible; 467 467 } 468 468 … … 471 471 static DECLCALLBACK(PDMBLOCKTYPE) drvblockBiosGetType(PPDMIBLOCKBIOS pInterface) 472 472 { 473 PDRVBLOCK p Data= PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);474 LogFlow(("drvblockBiosGetType: returns %d\n", p Data->enmType));475 return p Data->enmType;473 PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface); 474 LogFlow(("drvblockBiosGetType: returns %d\n", pThis->enmType)); 475 return pThis->enmType; 476 476 } 477 477 … … 488 488 { 489 489 LogFlow(("drvblockMount: pszFilename=%p:{%s} pszCoreDriver=%p:{%s}\n", pszFilename, pszFilename, pszCoreDriver, pszCoreDriver)); 490 PDRVBLOCK p Data= PDMIMOUNT_2_DRVBLOCK(pInterface);490 PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface); 491 491 492 492 /* 493 493 * Validate state. 494 494 */ 495 if (p Data->pDrvMedia)495 if (pThis->pDrvMedia) 496 496 { 497 497 AssertMsgFailed(("Already mounted\n")); … … 504 504 if (pszFilename) 505 505 { 506 int rc = p Data->pDrvIns->pDrvHlp->pfnMountPrepare(pData->pDrvIns, pszFilename, pszCoreDriver);506 int rc = pThis->pDrvIns->pDrvHlp->pfnMountPrepare(pThis->pDrvIns, pszFilename, pszCoreDriver); 507 507 if (RT_FAILURE(rc)) 508 508 { … … 516 516 */ 517 517 PPDMIBASE pBase; 518 int rc = p Data->pDrvIns->pDrvHlp->pfnAttach(pData->pDrvIns, &pBase);518 int rc = pThis->pDrvIns->pDrvHlp->pfnAttach(pThis->pDrvIns, &pBase); 519 519 if (RT_FAILURE(rc)) 520 520 { … … 523 523 } 524 524 525 p Data->pDrvMedia = (PPDMIMEDIA)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA);526 if (p Data->pDrvMedia)525 pThis->pDrvMedia = (PPDMIMEDIA)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA); 526 if (pThis->pDrvMedia) 527 527 { 528 528 /* 529 529 * Initialize state. 530 530 */ 531 p Data->fLocked = false;532 p Data->PCHSGeometry.cCylinders = 0;533 p Data->PCHSGeometry.cHeads = 0;534 p Data->PCHSGeometry.cSectors = 0;535 p Data->LCHSGeometry.cCylinders = 0;536 p Data->LCHSGeometry.cHeads = 0;537 p Data->LCHSGeometry.cSectors = 0;531 pThis->fLocked = false; 532 pThis->PCHSGeometry.cCylinders = 0; 533 pThis->PCHSGeometry.cHeads = 0; 534 pThis->PCHSGeometry.cSectors = 0; 535 pThis->LCHSGeometry.cCylinders = 0; 536 pThis->LCHSGeometry.cHeads = 0; 537 pThis->LCHSGeometry.cSectors = 0; 538 538 #ifdef VBOX_PERIODIC_FLUSH 539 p Data->cbDataWritten = 0;539 pThis->cbDataWritten = 0; 540 540 #endif /* VBOX_PERIODIC_FLUSH */ 541 541 … … 543 543 * Notify driver/device above us. 544 544 */ 545 if (p Data->pDrvMountNotify)546 p Data->pDrvMountNotify->pfnMountNotify(pData->pDrvMountNotify);545 if (pThis->pDrvMountNotify) 546 pThis->pDrvMountNotify->pfnMountNotify(pThis->pDrvMountNotify); 547 547 Log(("drvblockMount: Success\n")); 548 548 return VINF_SUCCESS; … … 555 555 */ 556 556 AssertMsgFailed(("No media interface!\n")); 557 int rc2 = p Data->pDrvIns->pDrvHlp->pfnDetach(pData->pDrvIns);557 int rc2 = pThis->pDrvIns->pDrvHlp->pfnDetach(pThis->pDrvIns); 558 558 AssertRC(rc2); 559 p Data->pDrvMedia = NULL;559 pThis->pDrvMedia = NULL; 560 560 return rc; 561 561 } … … 565 565 static DECLCALLBACK(int) drvblockUnmount(PPDMIMOUNT pInterface, bool fForce) 566 566 { 567 PDRVBLOCK p Data= PDMIMOUNT_2_DRVBLOCK(pInterface);567 PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface); 568 568 569 569 /* 570 570 * Validate state. 571 571 */ 572 if (!p Data->pDrvMedia)572 if (!pThis->pDrvMedia) 573 573 { 574 574 Log(("drvblockUmount: Not mounted\n")); 575 575 return VERR_PDM_MEDIA_NOT_MOUNTED; 576 576 } 577 if (p Data->fLocked && !fForce)577 if (pThis->fLocked && !fForce) 578 578 { 579 579 Log(("drvblockUmount: Locked\n")); … … 582 582 583 583 /* Media is no longer locked even if it was previously. */ 584 p Data->fLocked = false;584 pThis->fLocked = false; 585 585 586 586 /* 587 587 * Detach the media driver and query it's interface. 588 588 */ 589 int rc = p Data->pDrvIns->pDrvHlp->pfnDetach(pData->pDrvIns);589 int rc = pThis->pDrvIns->pDrvHlp->pfnDetach(pThis->pDrvIns); 590 590 if (RT_FAILURE(rc)) 591 591 { … … 593 593 return rc; 594 594 } 595 Assert(!p Data->pDrvMedia);595 Assert(!pThis->pDrvMedia); 596 596 597 597 /* 598 598 * Notify driver/device above us. 599 599 */ 600 if (p Data->pDrvMountNotify)601 p Data->pDrvMountNotify->pfnUnmountNotify(pData->pDrvMountNotify);600 if (pThis->pDrvMountNotify) 601 pThis->pDrvMountNotify->pfnUnmountNotify(pThis->pDrvMountNotify); 602 602 Log(("drvblockUnmount: success\n")); 603 603 return VINF_SUCCESS; … … 608 608 static DECLCALLBACK(bool) drvblockIsMounted(PPDMIMOUNT pInterface) 609 609 { 610 PDRVBLOCK p Data= PDMIMOUNT_2_DRVBLOCK(pInterface);611 return p Data->pDrvMedia != NULL;610 PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface); 611 return pThis->pDrvMedia != NULL; 612 612 } 613 613 … … 615 615 static DECLCALLBACK(int) drvblockLock(PPDMIMOUNT pInterface) 616 616 { 617 PDRVBLOCK p Data= PDMIMOUNT_2_DRVBLOCK(pInterface);618 Log(("drvblockLock: %d -> %d\n", p Data->fLocked, true));619 p Data->fLocked = true;617 PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface); 618 Log(("drvblockLock: %d -> %d\n", pThis->fLocked, true)); 619 pThis->fLocked = true; 620 620 return VINF_SUCCESS; 621 621 } … … 624 624 static DECLCALLBACK(int) drvblockUnlock(PPDMIMOUNT pInterface) 625 625 { 626 PDRVBLOCK p Data= PDMIMOUNT_2_DRVBLOCK(pInterface);627 Log(("drvblockUnlock: %d -> %d\n", p Data->fLocked, false));628 p Data->fLocked = false;626 PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface); 627 Log(("drvblockUnlock: %d -> %d\n", pThis->fLocked, false)); 628 pThis->fLocked = false; 629 629 return VINF_SUCCESS; 630 630 } … … 633 633 static DECLCALLBACK(bool) drvblockIsLocked(PPDMIMOUNT pInterface) 634 634 { 635 PDRVBLOCK p Data= PDMIMOUNT_2_DRVBLOCK(pInterface);636 return p Data->fLocked;635 PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface); 636 return pThis->fLocked; 637 637 } 638 638 … … 644 644 { 645 645 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); 646 PDRVBLOCK p Data= PDMINS_2_DATA(pDrvIns, PDRVBLOCK);646 PDRVBLOCK pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK); 647 647 switch (enmInterface) 648 648 { … … 650 650 return &pDrvIns->IBase; 651 651 case PDMINTERFACE_BLOCK: 652 return &p Data->IBlock;652 return &pThis->IBlock; 653 653 case PDMINTERFACE_BLOCK_BIOS: 654 return p Data->fBiosVisible ? &pData->IBlockBios : NULL;654 return pThis->fBiosVisible ? &pThis->IBlockBios : NULL; 655 655 case PDMINTERFACE_MOUNT: 656 return p Data->fMountable ? &pData->IMount : NULL;656 return pThis->fMountable ? &pThis->IMount : NULL; 657 657 case PDMINTERFACE_BLOCK_ASYNC: 658 return p Data->pDrvMediaAsync ? &pData->IBlockAsync : NULL;658 return pThis->pDrvMediaAsync ? &pThis->IBlockAsync : NULL; 659 659 case PDMINTERFACE_MEDIA_ASYNC_PORT: 660 return p Data->pDrvBlockAsyncPort ? &pData->IMediaAsyncPort : NULL;660 return pThis->pDrvBlockAsyncPort ? &pThis->IMediaAsyncPort : NULL; 661 661 default: 662 662 return NULL; … … 670 670 static DECLCALLBACK(void) drvblockDetach(PPDMDRVINS pDrvIns) 671 671 { 672 PDRVBLOCK p Data= PDMINS_2_DATA(pDrvIns, PDRVBLOCK);673 p Data->pDrvMedia = NULL;674 p Data->pDrvMediaAsync = NULL;672 PDRVBLOCK pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK); 673 pThis->pDrvMedia = NULL; 674 pThis->pDrvMediaAsync = NULL; 675 675 } 676 676 … … 683 683 static DECLCALLBACK(void) drvblockReset(PPDMDRVINS pDrvIns) 684 684 { 685 PDRVBLOCK p Data= PDMINS_2_DATA(pDrvIns, PDRVBLOCK);686 687 p Data->fLocked = false;685 PDRVBLOCK pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK); 686 687 pThis->fLocked = false; 688 688 } 689 689 … … 700 700 static DECLCALLBACK(int) drvblockConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle) 701 701 { 702 PDRVBLOCK p Data= PDMINS_2_DATA(pDrvIns, PDRVBLOCK);702 PDRVBLOCK pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK); 703 703 LogFlow(("drvblockConstruct: iInstance=%d\n", pDrvIns->iInstance)); 704 704 … … 716 716 * Initialize most of the data members. 717 717 */ 718 p Data->pDrvIns = pDrvIns;718 pThis->pDrvIns = pDrvIns; 719 719 720 720 /* IBase. */ … … 722 722 723 723 /* IBlock. */ 724 p Data->IBlock.pfnRead = drvblockRead;725 p Data->IBlock.pfnWrite = drvblockWrite;726 p Data->IBlock.pfnFlush = drvblockFlush;727 p Data->IBlock.pfnIsReadOnly = drvblockIsReadOnly;728 p Data->IBlock.pfnGetSize = drvblockGetSize;729 p Data->IBlock.pfnGetType = drvblockGetType;730 p Data->IBlock.pfnGetUuid = drvblockGetUuid;724 pThis->IBlock.pfnRead = drvblockRead; 725 pThis->IBlock.pfnWrite = drvblockWrite; 726 pThis->IBlock.pfnFlush = drvblockFlush; 727 pThis->IBlock.pfnIsReadOnly = drvblockIsReadOnly; 728 pThis->IBlock.pfnGetSize = drvblockGetSize; 729 pThis->IBlock.pfnGetType = drvblockGetType; 730 pThis->IBlock.pfnGetUuid = drvblockGetUuid; 731 731 732 732 /* IBlockBios. */ 733 p Data->IBlockBios.pfnGetPCHSGeometry = drvblockGetPCHSGeometry;734 p Data->IBlockBios.pfnSetPCHSGeometry = drvblockSetPCHSGeometry;735 p Data->IBlockBios.pfnGetLCHSGeometry = drvblockGetLCHSGeometry;736 p Data->IBlockBios.pfnSetLCHSGeometry = drvblockSetLCHSGeometry;737 p Data->IBlockBios.pfnIsVisible = drvblockIsVisible;738 p Data->IBlockBios.pfnGetType = drvblockBiosGetType;733 pThis->IBlockBios.pfnGetPCHSGeometry = drvblockGetPCHSGeometry; 734 pThis->IBlockBios.pfnSetPCHSGeometry = drvblockSetPCHSGeometry; 735 pThis->IBlockBios.pfnGetLCHSGeometry = drvblockGetLCHSGeometry; 736 pThis->IBlockBios.pfnSetLCHSGeometry = drvblockSetLCHSGeometry; 737 pThis->IBlockBios.pfnIsVisible = drvblockIsVisible; 738 pThis->IBlockBios.pfnGetType = drvblockBiosGetType; 739 739 740 740 /* IMount. */ 741 p Data->IMount.pfnMount = drvblockMount;742 p Data->IMount.pfnUnmount = drvblockUnmount;743 p Data->IMount.pfnIsMounted = drvblockIsMounted;744 p Data->IMount.pfnLock = drvblockLock;745 p Data->IMount.pfnUnlock = drvblockUnlock;746 p Data->IMount.pfnIsLocked = drvblockIsLocked;741 pThis->IMount.pfnMount = drvblockMount; 742 pThis->IMount.pfnUnmount = drvblockUnmount; 743 pThis->IMount.pfnIsMounted = drvblockIsMounted; 744 pThis->IMount.pfnLock = drvblockLock; 745 pThis->IMount.pfnUnlock = drvblockUnlock; 746 pThis->IMount.pfnIsLocked = drvblockIsLocked; 747 747 748 748 /* IBlockAsync. */ 749 p Data->IBlockAsync.pfnStartRead = drvblockAsyncReadStart;750 p Data->IBlockAsync.pfnStartWrite = drvblockAsyncWriteStart;749 pThis->IBlockAsync.pfnStartRead = drvblockAsyncReadStart; 750 pThis->IBlockAsync.pfnStartWrite = drvblockAsyncWriteStart; 751 751 752 752 /* IMediaAsyncPort. */ 753 p Data->IMediaAsyncPort.pfnTransferCompleteNotify = drvblockAsyncTransferCompleteNotify;753 pThis->IMediaAsyncPort.pfnTransferCompleteNotify = drvblockAsyncTransferCompleteNotify; 754 754 755 755 /* 756 756 * Get the IBlockPort & IMountNotify interfaces of the above driver/device. 757 757 */ 758 p Data->pDrvBlockPort = (PPDMIBLOCKPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_BLOCK_PORT);759 if (!p Data->pDrvBlockPort)758 pThis->pDrvBlockPort = (PPDMIBLOCKPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_BLOCK_PORT); 759 if (!pThis->pDrvBlockPort) 760 760 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE, 761 761 N_("No block port interface above")); 762 762 763 763 /* Try to get the optional async block port interface above. */ 764 p Data->pDrvBlockAsyncPort = (PPDMIBLOCKASYNCPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_BLOCK_ASYNC_PORT);765 766 p Data->pDrvMountNotify = (PPDMIMOUNTNOTIFY)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_MOUNT_NOTIFY);764 pThis->pDrvBlockAsyncPort = (PPDMIBLOCKASYNCPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_BLOCK_ASYNC_PORT); 765 766 pThis->pDrvMountNotify = (PPDMIMOUNTNOTIFY)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_MOUNT_NOTIFY); 767 767 768 768 /* … … 775 775 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_BLOCK_NO_TYPE, N_("Failed to obtain the type")); 776 776 if (!strcmp(psz, "HardDisk")) 777 p Data->enmType = PDMBLOCKTYPE_HARD_DISK;777 pThis->enmType = PDMBLOCKTYPE_HARD_DISK; 778 778 else if (!strcmp(psz, "DVD")) 779 p Data->enmType = PDMBLOCKTYPE_DVD;779 pThis->enmType = PDMBLOCKTYPE_DVD; 780 780 else if (!strcmp(psz, "CDROM")) 781 p Data->enmType = PDMBLOCKTYPE_CDROM;781 pThis->enmType = PDMBLOCKTYPE_CDROM; 782 782 else if (!strcmp(psz, "Floppy 2.88")) 783 p Data->enmType = PDMBLOCKTYPE_FLOPPY_2_88;783 pThis->enmType = PDMBLOCKTYPE_FLOPPY_2_88; 784 784 else if (!strcmp(psz, "Floppy 1.44")) 785 p Data->enmType = PDMBLOCKTYPE_FLOPPY_1_44;785 pThis->enmType = PDMBLOCKTYPE_FLOPPY_1_44; 786 786 else if (!strcmp(psz, "Floppy 1.20")) 787 p Data->enmType = PDMBLOCKTYPE_FLOPPY_1_20;787 pThis->enmType = PDMBLOCKTYPE_FLOPPY_1_20; 788 788 else if (!strcmp(psz, "Floppy 720")) 789 p Data->enmType = PDMBLOCKTYPE_FLOPPY_720;789 pThis->enmType = PDMBLOCKTYPE_FLOPPY_720; 790 790 else if (!strcmp(psz, "Floppy 360")) 791 p Data->enmType = PDMBLOCKTYPE_FLOPPY_360;791 pThis->enmType = PDMBLOCKTYPE_FLOPPY_360; 792 792 else 793 793 { … … 797 797 return VERR_PDM_BLOCK_UNKNOWN_TYPE; 798 798 } 799 Log2(("drvblockConstruct: enmType=%d\n", p Data->enmType));799 Log2(("drvblockConstruct: enmType=%d\n", pThis->enmType)); 800 800 MMR3HeapFree(psz); psz = NULL; 801 801 802 802 /* Mountable */ 803 rc = CFGMR3QueryBoolDef(pCfgHandle, "Mountable", &p Data->fMountable, false);803 rc = CFGMR3QueryBoolDef(pCfgHandle, "Mountable", &pThis->fMountable, false); 804 804 if (RT_FAILURE(rc)) 805 805 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Mountable\" from the config")); 806 806 807 807 /* Locked */ 808 rc = CFGMR3QueryBoolDef(pCfgHandle, "Locked", &p Data->fLocked, false);808 rc = CFGMR3QueryBoolDef(pCfgHandle, "Locked", &pThis->fLocked, false); 809 809 if (RT_FAILURE(rc)) 810 810 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Locked\" from the config")); 811 811 812 812 /* BIOS visible */ 813 rc = CFGMR3QueryBoolDef(pCfgHandle, "BIOSVisible", &p Data->fBiosVisible, true);813 rc = CFGMR3QueryBoolDef(pCfgHandle, "BIOSVisible", &pThis->fBiosVisible, true); 814 814 if (RT_FAILURE(rc)) 815 815 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"BIOSVisible\" from the config")); … … 818 818 819 819 /* Cylinders */ 820 rc = CFGMR3QueryU32Def(pCfgHandle, "Cylinders", &p Data->LCHSGeometry.cCylinders, 0);820 rc = CFGMR3QueryU32Def(pCfgHandle, "Cylinders", &pThis->LCHSGeometry.cCylinders, 0); 821 821 if (RT_FAILURE(rc)) 822 822 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Cylinders\" from the config")); 823 823 824 824 /* Heads */ 825 rc = CFGMR3QueryU32Def(pCfgHandle, "Heads", &p Data->LCHSGeometry.cHeads, 0);825 rc = CFGMR3QueryU32Def(pCfgHandle, "Heads", &pThis->LCHSGeometry.cHeads, 0); 826 826 if (RT_FAILURE(rc)) 827 827 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Heads\" from the config")); 828 828 829 829 /* Sectors */ 830 rc = CFGMR3QueryU32Def(pCfgHandle, "Sectors", &p Data->LCHSGeometry.cSectors, 0);830 rc = CFGMR3QueryU32Def(pCfgHandle, "Sectors", &pThis->LCHSGeometry.cSectors, 0); 831 831 if (RT_FAILURE(rc)) 832 832 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Sectors\" from the config")); … … 835 835 rc = CFGMR3QueryStringAlloc(pCfgHandle, "Uuid", &psz); 836 836 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 837 RTUuidClear(&p Data->Uuid);837 RTUuidClear(&pThis->Uuid); 838 838 else if (RT_SUCCESS(rc)) 839 839 { 840 rc = RTUuidFromStr(&p Data->Uuid, psz);840 rc = RTUuidFromStr(&pThis->Uuid, psz); 841 841 if (RT_FAILURE(rc)) 842 842 { … … 852 852 853 853 #ifdef VBOX_PERIODIC_FLUSH 854 rc = CFGMR3QueryU32Def(pCfgHandle, "FlushInterval", &p Data->cbFlushInterval, 0);854 rc = CFGMR3QueryU32Def(pCfgHandle, "FlushInterval", &pThis->cbFlushInterval, 0); 855 855 if (RT_FAILURE(rc)) 856 856 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"FlushInterval\" from the config")); … … 858 858 859 859 #ifdef VBOX_IGNORE_FLUSH 860 rc = CFGMR3QueryBoolDef(pCfgHandle, "IgnoreFlush", &p Data->fIgnoreFlush, true);860 rc = CFGMR3QueryBoolDef(pCfgHandle, "IgnoreFlush", &pThis->fIgnoreFlush, true); 861 861 if (RT_FAILURE(rc)) 862 862 return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"IgnoreFlush\" from the config")); … … 869 869 rc = pDrvIns->pDrvHlp->pfnAttach(pDrvIns, &pBase); 870 870 if ( rc == VERR_PDM_NO_ATTACHED_DRIVER 871 && p Data->enmType != PDMBLOCKTYPE_HARD_DISK)871 && pThis->enmType != PDMBLOCKTYPE_HARD_DISK) 872 872 return VINF_SUCCESS; 873 873 if (RT_FAILURE(rc)) … … 876 876 return rc; 877 877 } 878 p Data->pDrvMedia = (PPDMIMEDIA)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA);879 if (!p Data->pDrvMedia)878 pThis->pDrvMedia = (PPDMIMEDIA)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA); 879 if (!pThis->pDrvMedia) 880 880 return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_BELOW, 881 881 N_("No media or async media interface below")); 882 882 883 883 /* Try to get the optional async interface. */ 884 p Data->pDrvMediaAsync = (PPDMIMEDIAASYNC)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA_ASYNC);885 886 if (RTUuidIsNull(&p Data->Uuid))887 { 888 if (p Data->enmType == PDMBLOCKTYPE_HARD_DISK)889 p Data->pDrvMedia->pfnGetUuid(pData->pDrvMedia, &pData->Uuid);884 pThis->pDrvMediaAsync = (PPDMIMEDIAASYNC)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA_ASYNC); 885 886 if (RTUuidIsNull(&pThis->Uuid)) 887 { 888 if (pThis->enmType == PDMBLOCKTYPE_HARD_DISK) 889 pThis->pDrvMedia->pfnGetUuid(pThis->pDrvMedia, &pThis->Uuid); 890 890 } 891 891 -
trunk/src/VBox/Devices/Storage/DrvMediaISO.cpp
r11267 r11269 99 99 static DECLCALLBACK(int) drvMediaISOConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle) 100 100 { 101 PDRVMEDIAISO p Data= PDMINS_2_DATA(pDrvIns, PDRVMEDIAISO);101 PDRVMEDIAISO pThis = PDMINS_2_DATA(pDrvIns, PDRVMEDIAISO); 102 102 103 103 /* 104 104 * Init the static parts. 105 105 */ 106 p Data->pDrvIns = pDrvIns;107 p Data->File = NIL_RTFILE;106 pThis->pDrvIns = pDrvIns; 107 pThis->File = NIL_RTFILE; 108 108 /* IBase */ 109 109 pDrvIns->IBase.pfnQueryInterface = drvMediaISOQueryInterface; 110 110 /* IMedia */ 111 p Data->IMedia.pfnRead = drvMediaISORead;112 p Data->IMedia.pfnWrite = drvMediaISOWrite;113 p Data->IMedia.pfnFlush = drvMediaISOFlush;114 p Data->IMedia.pfnGetSize = drvMediaISOGetSize;115 p Data->IMedia.pfnGetUuid = drvMediaISOGetUuid;116 p Data->IMedia.pfnIsReadOnly = drvMediaISOIsReadOnly;117 p Data->IMedia.pfnBiosGetPCHSGeometry = drvMediaISOBiosGetPCHSGeometry;118 p Data->IMedia.pfnBiosSetPCHSGeometry = drvMediaISOBiosSetPCHSGeometry;119 p Data->IMedia.pfnBiosGetLCHSGeometry = drvMediaISOBiosGetLCHSGeometry;120 p Data->IMedia.pfnBiosSetLCHSGeometry = drvMediaISOBiosSetLCHSGeometry;111 pThis->IMedia.pfnRead = drvMediaISORead; 112 pThis->IMedia.pfnWrite = drvMediaISOWrite; 113 pThis->IMedia.pfnFlush = drvMediaISOFlush; 114 pThis->IMedia.pfnGetSize = drvMediaISOGetSize; 115 pThis->IMedia.pfnGetUuid = drvMediaISOGetUuid; 116 pThis->IMedia.pfnIsReadOnly = drvMediaISOIsReadOnly; 117 pThis->IMedia.pfnBiosGetPCHSGeometry = drvMediaISOBiosGetPCHSGeometry; 118 pThis->IMedia.pfnBiosSetPCHSGeometry = drvMediaISOBiosSetPCHSGeometry; 119 pThis->IMedia.pfnBiosGetLCHSGeometry = drvMediaISOBiosGetLCHSGeometry; 120 pThis->IMedia.pfnBiosSetLCHSGeometry = drvMediaISOBiosSetLCHSGeometry; 121 121 122 122 /* … … 134 134 * Open the image. 135 135 */ 136 rc = RTFileOpen(&p Data->File, pszName,136 rc = RTFileOpen(&pThis->File, pszName, 137 137 RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 138 138 if (RT_SUCCESS(rc)) 139 139 { 140 140 LogFlow(("drvMediaISOConstruct: ISO image '%s' opened successfully.\n", pszName)); 141 p Data->pszFilename = pszName;141 pThis->pszFilename = pszName; 142 142 } 143 143 else … … 161 161 static DECLCALLBACK(void) drvMediaISODestruct(PPDMDRVINS pDrvIns) 162 162 { 163 PDRVMEDIAISO p Data= PDMINS_2_DATA(pDrvIns, PDRVMEDIAISO);164 LogFlow(("drvMediaISODestruct: '%s'\n", p Data->pszFilename));165 166 if (p Data->File != NIL_RTFILE)167 { 168 RTFileClose(p Data->File);169 p Data->File = NIL_RTFILE;170 } 171 if (p Data->pszFilename)172 MMR3HeapFree(p Data->pszFilename);163 PDRVMEDIAISO pThis = PDMINS_2_DATA(pDrvIns, PDRVMEDIAISO); 164 LogFlow(("drvMediaISODestruct: '%s'\n", pThis->pszFilename)); 165 166 if (pThis->File != NIL_RTFILE) 167 { 168 RTFileClose(pThis->File); 169 pThis->File = NIL_RTFILE; 170 } 171 if (pThis->pszFilename) 172 MMR3HeapFree(pThis->pszFilename); 173 173 } 174 174 … … 177 177 static DECLCALLBACK(uint64_t) drvMediaISOGetSize(PPDMIMEDIA pInterface) 178 178 { 179 PDRVMEDIAISO p Data= PDMIMEDIA_2_DRVMEDIAISO(pInterface);180 LogFlow(("drvMediaISOGetSize: '%s'\n", p Data->pszFilename));179 PDRVMEDIAISO pThis = PDMIMEDIA_2_DRVMEDIAISO(pInterface); 180 LogFlow(("drvMediaISOGetSize: '%s'\n", pThis->pszFilename)); 181 181 182 182 uint64_t cbFile; 183 int rc = RTFileGetSize(p Data->File, &cbFile);183 int rc = RTFileGetSize(pThis->File, &cbFile); 184 184 if (RT_SUCCESS(rc)) 185 185 { 186 LogFlow(("drvMediaISOGetSize: returns %lld (%s)\n", cbFile, p Data->pszFilename));186 LogFlow(("drvMediaISOGetSize: returns %lld (%s)\n", cbFile, pThis->pszFilename)); 187 187 return cbFile; 188 188 } 189 189 190 AssertMsgFailed(("Error querying ISO file size, rc=%Vrc. (%s)\n", rc, p Data->pszFilename));190 AssertMsgFailed(("Error querying ISO file size, rc=%Vrc. (%s)\n", rc, pThis->pszFilename)); 191 191 return 0; 192 192 } … … 228 228 static DECLCALLBACK(int) drvMediaISORead(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead) 229 229 { 230 PDRVMEDIAISO p Data= PDMIMEDIA_2_DRVMEDIAISO(pInterface);231 LogFlow(("drvMediaISORead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", off, pvBuf, cbRead, p Data->pszFilename));232 233 Assert(p Data->File);230 PDRVMEDIAISO pThis = PDMIMEDIA_2_DRVMEDIAISO(pInterface); 231 LogFlow(("drvMediaISORead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", off, pvBuf, cbRead, pThis->pszFilename)); 232 233 Assert(pThis->File); 234 234 Assert(pvBuf); 235 235 … … 237 237 * Seek to the position and read. 238 238 */ 239 int rc = RTFileSeek(p Data->File, off, RTFILE_SEEK_BEGIN, NULL);239 int rc = RTFileSeek(pThis->File, off, RTFILE_SEEK_BEGIN, NULL); 240 240 if (RT_SUCCESS(rc)) 241 241 { 242 rc = RTFileRead(p Data->File, pvBuf, cbRead, NULL);242 rc = RTFileRead(pThis->File, pvBuf, cbRead, NULL); 243 243 if (RT_SUCCESS(rc)) 244 244 { 245 245 Log2(("drvMediaISORead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n" 246 246 "%16.*Vhxd\n", 247 off, pvBuf, cbRead, p Data->pszFilename,247 off, pvBuf, cbRead, pThis->pszFilename, 248 248 cbRead, pvBuf)); 249 249 } 250 250 else 251 251 AssertMsgFailed(("RTFileRead(%d, %p, %#x) -> %Vrc (off=%#llx '%s')\n", 252 p Data->File, pvBuf, cbRead, rc, off, pData->pszFilename));252 pThis->File, pvBuf, cbRead, rc, off, pThis->pszFilename)); 253 253 } 254 254 else 255 AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", p Data->File, off, rc));255 AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", pThis->File, off, rc)); 256 256 LogFlow(("drvMediaISORead: returns %Vrc\n", rc)); 257 257 return rc; … … 302 302 { 303 303 PPDMDRVINS pDrvIns = PDMIBASE_2_DRVINS(pInterface); 304 PDRVMEDIAISO p Data= PDMINS_2_DATA(pDrvIns, PDRVMEDIAISO);304 PDRVMEDIAISO pThis = PDMINS_2_DATA(pDrvIns, PDRVMEDIAISO); 305 305 switch (enmInterface) 306 306 { … … 308 308 return &pDrvIns->IBase; 309 309 case PDMINTERFACE_MEDIA: 310 return &p Data->IMedia;310 return &pThis->IMedia; 311 311 default: 312 312 return NULL; -
trunk/src/VBox/Devices/Storage/DrvRawImage.cpp
r11267 r11269 102 102 static DECLCALLBACK(int) drvRawImageConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle) 103 103 { 104 PDRVRAWIMAGE p Data= PDMINS_2_DATA(pDrvIns, PDRVRAWIMAGE);104 PDRVRAWIMAGE pThis = PDMINS_2_DATA(pDrvIns, PDRVRAWIMAGE); 105 105 106 106 /* 107 107 * Init the static parts. 108 108 */ 109 p Data->pDrvIns = pDrvIns;110 p Data->File = NIL_RTFILE;109 pThis->pDrvIns = pDrvIns; 110 pThis->File = NIL_RTFILE; 111 111 /* IBase */ 112 112 pDrvIns->IBase.pfnQueryInterface = drvRawImageQueryInterface; 113 113 /* IMedia */ 114 p Data->IMedia.pfnRead = drvRawImageRead;115 p Data->IMedia.pfnWrite = drvRawImageWrite;116 p Data->IMedia.pfnFlush = drvRawImageFlush;117 p Data->IMedia.pfnGetSize = drvRawImageGetSize;118 p Data->IMedia.pfnGetUuid = drvRawImageGetUuid;119 p Data->IMedia.pfnIsReadOnly = drvRawImageIsReadOnly;120 p Data->IMedia.pfnBiosGetPCHSGeometry = drvRawImageBiosGetPCHSGeometry;121 p Data->IMedia.pfnBiosSetPCHSGeometry = drvRawImageBiosSetPCHSGeometry;122 p Data->IMedia.pfnBiosGetLCHSGeometry = drvRawImageBiosGetLCHSGeometry;123 p Data->IMedia.pfnBiosSetLCHSGeometry = drvRawImageBiosSetLCHSGeometry;114 pThis->IMedia.pfnRead = drvRawImageRead; 115 pThis->IMedia.pfnWrite = drvRawImageWrite; 116 pThis->IMedia.pfnFlush = drvRawImageFlush; 117 pThis->IMedia.pfnGetSize = drvRawImageGetSize; 118 pThis->IMedia.pfnGetUuid = drvRawImageGetUuid; 119 pThis->IMedia.pfnIsReadOnly = drvRawImageIsReadOnly; 120 pThis->IMedia.pfnBiosGetPCHSGeometry = drvRawImageBiosGetPCHSGeometry; 121 pThis->IMedia.pfnBiosSetPCHSGeometry = drvRawImageBiosSetPCHSGeometry; 122 pThis->IMedia.pfnBiosGetLCHSGeometry = drvRawImageBiosGetLCHSGeometry; 123 pThis->IMedia.pfnBiosSetLCHSGeometry = drvRawImageBiosSetLCHSGeometry; 124 124 125 125 /* … … 140 140 * Open the image. 141 141 */ 142 rc = RTFileOpen(&p Data->File, pszName,142 rc = RTFileOpen(&pThis->File, pszName, 143 143 RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 144 144 if (RT_SUCCESS(rc)) 145 145 { 146 146 LogFlow(("drvRawImageConstruct: Raw image '%s' opened successfully.\n", pszName)); 147 p Data->pszFilename = pszName;148 p Data->fReadOnly = false;147 pThis->pszFilename = pszName; 148 pThis->fReadOnly = false; 149 149 } 150 150 else 151 151 { 152 rc = RTFileOpen(&p Data->File, pszName,152 rc = RTFileOpen(&pThis->File, pszName, 153 153 RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 154 154 if (RT_SUCCESS(rc)) 155 155 { 156 156 LogFlow(("drvRawImageConstruct: Raw image '%s' opened successfully.\n", pszName)); 157 p Data->pszFilename = pszName;158 p Data->fReadOnly = true;157 pThis->pszFilename = pszName; 158 pThis->fReadOnly = true; 159 159 } 160 160 else … … 179 179 static DECLCALLBACK(void) drvRawImageDestruct(PPDMDRVINS pDrvIns) 180 180 { 181 PDRVRAWIMAGE p Data= PDMINS_2_DATA(pDrvIns, PDRVRAWIMAGE);182 LogFlow(("drvRawImageDestruct: '%s'\n", p Data->pszFilename));183 184 if (p Data->File != NIL_RTFILE)185 { 186 RTFileClose(p Data->File);187 p Data->File = NIL_RTFILE;188 } 189 if (p Data->pszFilename)190 MMR3HeapFree(p Data->pszFilename);181 PDRVRAWIMAGE pThis = PDMINS_2_DATA(pDrvIns, PDRVRAWIMAGE); 182 LogFlow(("drvRawImageDestruct: '%s'\n", pThis->pszFilename)); 183 184 if (pThis->File != NIL_RTFILE) 185 { 186 RTFileClose(pThis->File); 187 pThis->File = NIL_RTFILE; 188 } 189 if (pThis->pszFilename) 190 MMR3HeapFree(pThis->pszFilename); 191 191 } 192 192 … … 195 195 static DECLCALLBACK(uint64_t) drvRawImageGetSize(PPDMIMEDIA pInterface) 196 196 { 197 PDRVRAWIMAGE p Data= PDMIMEDIA_2_DRVRAWIMAGE(pInterface);198 LogFlow(("drvRawImageGetSize: '%s'\n", p Data->pszFilename));197 PDRVRAWIMAGE pThis = PDMIMEDIA_2_DRVRAWIMAGE(pInterface); 198 LogFlow(("drvRawImageGetSize: '%s'\n", pThis->pszFilename)); 199 199 200 200 uint64_t cbFile; 201 int rc = RTFileGetSize(p Data->File, &cbFile);201 int rc = RTFileGetSize(pThis->File, &cbFile); 202 202 if (RT_SUCCESS(rc)) 203 203 { 204 LogFlow(("drvRawImageGetSize: returns %lld (%s)\n", cbFile, p Data->pszFilename));204 LogFlow(("drvRawImageGetSize: returns %lld (%s)\n", cbFile, pThis->pszFilename)); 205 205 return cbFile; 206 206 } 207 207 208 AssertMsgFailed(("Error querying Raw image file size, rc=%Vrc. (%s)\n", rc, p Data->pszFilename));208 AssertMsgFailed(("Error querying Raw image file size, rc=%Vrc. (%s)\n", rc, pThis->pszFilename)); 209 209 return 0; 210 210 } … … 246 246 static DECLCALLBACK(int) drvRawImageRead(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead) 247 247 { 248 PDRVRAWIMAGE p Data= PDMIMEDIA_2_DRVRAWIMAGE(pInterface);249 LogFlow(("drvRawImageRead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", off, pvBuf, cbRead, p Data->pszFilename));250 251 Assert(p Data->File);248 PDRVRAWIMAGE pThis = PDMIMEDIA_2_DRVRAWIMAGE(pInterface); 249 LogFlow(("drvRawImageRead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", off, pvBuf, cbRead, pThis->pszFilename)); 250 251 Assert(pThis->File); 252 252 Assert(pvBuf); 253 253 … … 255 255 * Seek to the position and read. 256 256 */ 257 int rc = RTFileSeek(p Data->File, off, RTFILE_SEEK_BEGIN, NULL);257 int rc = RTFileSeek(pThis->File, off, RTFILE_SEEK_BEGIN, NULL); 258 258 if (RT_SUCCESS(rc)) 259 259 { 260 rc = RTFileRead(p Data->File, pvBuf, cbRead, NULL);260 rc = RTFileRead(pThis->File, pvBuf, cbRead, NULL); 261 261 if (RT_SUCCESS(rc)) 262 262 { 263 263 Log2(("drvRawImageRead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n" 264 264 "%16.*Vhxd\n", 265 off, pvBuf, cbRead, p Data->pszFilename,265 off, pvBuf, cbRead, pThis->pszFilename, 266 266 cbRead, pvBuf)); 267 267 } 268 268 else 269 269 AssertMsgFailed(("RTFileRead(%d, %p, %#x) -> %Vrc (off=%#llx '%s')\n", 270 p Data->File, pvBuf, cbRead, rc, off, pData->pszFilename));270 pThis->File, pvBuf, cbRead, rc, off, pThis->pszFilename)); 271 271 } 272 272 else 273 AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", p Data->File, off, rc));273 AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", pThis->File, off, rc)); 274 274 LogFlow(("drvRawImageRead: returns %Vrc\n", rc)); 275 275 return rc; … … 280 280 static DECLCALLBACK(int) drvRawImageWrite(PPDMIMEDIA pInterface, uint64_t off, const void *pvBuf, size_t cbWrite) 281 281 { 282 PDRVRAWIMAGE p Data= PDMIMEDIA_2_DRVRAWIMAGE(pInterface);283 LogFlow(("drvRawImageWrite: off=%#llx pvBuf=%p cbWrite=%#x (%s)\n", off, pvBuf, cbWrite, p Data->pszFilename));284 285 Assert(p Data->File);282 PDRVRAWIMAGE pThis = PDMIMEDIA_2_DRVRAWIMAGE(pInterface); 283 LogFlow(("drvRawImageWrite: off=%#llx pvBuf=%p cbWrite=%#x (%s)\n", off, pvBuf, cbWrite, pThis->pszFilename)); 284 285 Assert(pThis->File); 286 286 Assert(pvBuf); 287 287 … … 289 289 * Seek to the position and write. 290 290 */ 291 int rc = RTFileSeek(p Data->File, off, RTFILE_SEEK_BEGIN, NULL);291 int rc = RTFileSeek(pThis->File, off, RTFILE_SEEK_BEGIN, NULL); 292 292 if (RT_SUCCESS(rc)) 293 293 { 294 rc = RTFileWrite(p Data->File, pvBuf, cbWrite, NULL);294 rc = RTFileWrite(pThis->File, pvBuf, cbWrite, NULL); 295 295 if (RT_SUCCESS(rc)) 296 296 { 297 297 Log2(("drvRawImageWrite: off=%#llx pvBuf=%p cbWrite=%#x (%s)\n" 298 298 "%16.*Vhxd\n", 299 off, pvBuf, cbWrite, p Data->pszFilename,299 off, pvBuf, cbWrite, pThis->pszFilename, 300 300 cbWrite, pvBuf)); 301 301 } 302 302 else 303 303 AssertMsgFailed(("RTFileWrite(%d, %p, %#x) -> %Vrc (off=%#llx '%s')\n", 304 p Data->File, pvBuf, cbWrite, rc, off, pData->pszFilename));304 pThis->File, pvBuf, cbWrite, rc, off, pThis->pszFilename)); 305 305 } 306 306 else 307 AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", p Data->File, off, rc));307 AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", pThis->File, off, rc)); 308 308 LogFlow(("drvRawImageWrite: returns %Vrc\n", rc)); 309 309 return rc; … … 314 314 static DECLCALLBACK(int) drvRawImageFlush(PPDMIMEDIA pInterface) 315 315 { 316 PDRVRAWIMAGE p Data= PDMIMEDIA_2_DRVRAWIMAGE(pInterface);317 LogFlow(("drvRawImageFlush: (%s)\n", p Data->pszFilename));318 319 Assert(p Data->File != NIL_RTFILE);320 int rc = RTFileFlush(p Data->File);316 PDRVRAWIMAGE pThis = PDMIMEDIA_2_DRVRAWIMAGE(pInterface); 317 LogFlow(("drvRawImageFlush: (%s)\n", pThis->pszFilename)); 318 319 Assert(pThis->File != NIL_RTFILE); 320 int rc = RTFileFlush(pThis->File); 321 321 LogFlow(("drvRawImageFlush: returns %Vrc\n", rc)); 322 322 return rc; … … 335 335 static DECLCALLBACK(bool) drvRawImageIsReadOnly(PPDMIMEDIA pInterface) 336 336 { 337 PDRVRAWIMAGE p Data= PDMIMEDIA_2_DRVRAWIMAGE(pInterface);338 return p Data->fReadOnly;337 PDRVRAWIMAGE pThis = PDMIMEDIA_2_DRVRAWIMAGE(pInterface); 338 return pThis->fReadOnly; 339 339 } 340 340 … … 352 352 { 353 353 PPDMDRVINS pDrvIns = PDMIBASE_2_DRVINS(pInterface); 354 PDRVRAWIMAGE p Data= PDMINS_2_DATA(pDrvIns, PDRVRAWIMAGE);354 PDRVRAWIMAGE pThis = PDMINS_2_DATA(pDrvIns, PDRVRAWIMAGE); 355 355 switch (enmInterface) 356 356 { … … 358 358 return &pDrvIns->IBase; 359 359 case PDMINTERFACE_MEDIA: 360 return &p Data->IMedia;360 return &pThis->IMedia; 361 361 default: 362 362 return NULL; -
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r11267 r11269 276 276 LogFlow(("%s: off=%#llx pvBuf=%p cbRead=%d\n", __FUNCTION__, 277 277 off, pvBuf, cbRead)); 278 PVBOXDISK p Data= PDMIMEDIA_2_VBOXDISK(pInterface);279 int rc = VDRead(p Data->pDisk, off, pvBuf, cbRead);278 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 279 int rc = VDRead(pThis->pDisk, off, pvBuf, cbRead); 280 280 if (RT_SUCCESS(rc)) 281 281 Log2(("%s: off=%#llx pvBuf=%p cbRead=%d %.*Vhxd\n", __FUNCTION__, … … 292 292 LogFlow(("%s: off=%#llx pvBuf=%p cbWrite=%d\n", __FUNCTION__, 293 293 off, pvBuf, cbWrite)); 294 PVBOXDISK p Data= PDMIMEDIA_2_VBOXDISK(pInterface);294 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 295 295 Log2(("%s: off=%#llx pvBuf=%p cbWrite=%d %.*Vhxd\n", __FUNCTION__, 296 296 off, pvBuf, cbWrite, cbWrite, pvBuf)); 297 int rc = VDWrite(p Data->pDisk, off, pvBuf, cbWrite);297 int rc = VDWrite(pThis->pDisk, off, pvBuf, cbWrite); 298 298 LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc)); 299 299 return rc; … … 304 304 { 305 305 LogFlow(("%s:\n", __FUNCTION__)); 306 PVBOXDISK p Data= PDMIMEDIA_2_VBOXDISK(pInterface);307 int rc = VDFlush(p Data->pDisk);306 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 307 int rc = VDFlush(pThis->pDisk); 308 308 LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc)); 309 309 return rc; … … 314 314 { 315 315 LogFlow(("%s:\n", __FUNCTION__)); 316 PVBOXDISK p Data= PDMIMEDIA_2_VBOXDISK(pInterface);317 uint64_t cb = VDGetSize(p Data->pDisk, VD_LAST_IMAGE);316 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 317 uint64_t cb = VDGetSize(pThis->pDisk, VD_LAST_IMAGE); 318 318 LogFlow(("%s: returns %#llx (%llu)\n", __FUNCTION__, cb, cb)); 319 319 return cb; … … 324 324 { 325 325 LogFlow(("%s:\n", __FUNCTION__)); 326 PVBOXDISK p Data= PDMIMEDIA_2_VBOXDISK(pInterface);327 bool f = VDIsReadOnly(p Data->pDisk);326 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 327 bool f = VDIsReadOnly(pThis->pDisk); 328 328 LogFlow(("%s: returns %d\n", __FUNCTION__, f)); 329 329 return f; … … 335 335 { 336 336 LogFlow(("%s:\n", __FUNCTION__)); 337 PVBOXDISK p Data= PDMIMEDIA_2_VBOXDISK(pInterface);338 int rc = VDGetPCHSGeometry(p Data->pDisk, VD_LAST_IMAGE, pPCHSGeometry);337 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 338 int rc = VDGetPCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pPCHSGeometry); 339 339 if (RT_FAILURE(rc)) 340 340 { … … 353 353 LogFlow(("%s: CHS=%d/%d/%d\n", __FUNCTION__, 354 354 pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors)); 355 PVBOXDISK p Data= PDMIMEDIA_2_VBOXDISK(pInterface);356 int rc = VDSetPCHSGeometry(p Data->pDisk, VD_LAST_IMAGE, pPCHSGeometry);355 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 356 int rc = VDSetPCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pPCHSGeometry); 357 357 LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc)); 358 358 return rc; … … 364 364 { 365 365 LogFlow(("%s:\n", __FUNCTION__)); 366 PVBOXDISK p Data= PDMIMEDIA_2_VBOXDISK(pInterface);367 int rc = VDGetLCHSGeometry(p Data->pDisk, VD_LAST_IMAGE, pLCHSGeometry);366 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 367 int rc = VDGetLCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pLCHSGeometry); 368 368 if (RT_FAILURE(rc)) 369 369 { … … 382 382 LogFlow(("%s: CHS=%d/%d/%d\n", __FUNCTION__, 383 383 pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors)); 384 PVBOXDISK p Data= PDMIMEDIA_2_VBOXDISK(pInterface);385 int rc = VDSetLCHSGeometry(p Data->pDisk, VD_LAST_IMAGE, pLCHSGeometry);384 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 385 int rc = VDSetLCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pLCHSGeometry); 386 386 LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc)); 387 387 return rc; … … 392 392 { 393 393 LogFlow(("%s:\n", __FUNCTION__)); 394 PVBOXDISK p Data= PDMIMEDIA_2_VBOXDISK(pInterface);395 int rc = VDGetUuid(p Data->pDisk, 0, pUuid);394 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 395 int rc = VDGetUuid(pThis->pDisk, 0, pUuid); 396 396 LogFlow(("%s: returns %Vrc ({%Vuuid})\n", __FUNCTION__, rc, pUuid)); 397 397 return rc; … … 408 408 LogFlow(("%s: uOffset=%#llx paSeg=%#p cSeg=%u cbRead=%d\n pvUser=%#p", __FUNCTION__, 409 409 uOffset, paSeg, cSeg, cbRead, pvUser)); 410 PVBOXDISK p Data= PDMIMEDIAASYNC_2_VBOXDISK(pInterface);411 int rc = VDAsyncRead(p Data->pDisk, uOffset, cbRead, paSeg, cSeg, pvUser);410 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 411 int rc = VDAsyncRead(pThis->pDisk, uOffset, cbRead, paSeg, cSeg, pvUser); 412 412 LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc)); 413 413 return rc; … … 420 420 LogFlow(("%s: uOffset=%#llx paSeg=%#p cSeg=%u cbWrite=%d\n pvUser=%#p", __FUNCTION__, 421 421 uOffset, paSeg, cSeg, cbWrite, pvUser)); 422 PVBOXDISK p Data= PDMIMEDIAASYNC_2_VBOXDISK(pInterface);423 int rc = VDAsyncWrite(p Data->pDisk, uOffset, cbWrite, paSeg, cSeg, pvUser);422 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 423 int rc = VDAsyncWrite(pThis->pDisk, uOffset, cbWrite, paSeg, cSeg, pvUser); 424 424 LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc)); 425 425 return rc; … … 432 432 static DECLCALLBACK(int) drvvdTasksCompleteNotify(PPDMITRANSPORTASYNCPORT pInterface, void *pvUser) 433 433 { 434 PVBOXDISK p Data= PDMITRANSPORTASYNCPORT_2_VBOXDISK(pInterface);434 PVBOXDISK pThis = PDMITRANSPORTASYNCPORT_2_VBOXDISK(pInterface); 435 435 PDRVVDASYNCTASK pDrvVDAsyncTask = (PDRVVDASYNCTASK)pvUser; 436 436 int rc = VINF_VDI_ASYNC_IO_FINISHED; … … 443 443 if (rc == VINF_VDI_ASYNC_IO_FINISHED) 444 444 { 445 rc = p Data->pDrvMediaAsyncPort->pfnTransferCompleteNotify(pData->pDrvMediaAsyncPort, pDrvVDAsyncTask->pvUserCaller);445 rc = pThis->pDrvMediaAsyncPort->pfnTransferCompleteNotify(pThis->pDrvMediaAsyncPort, pDrvVDAsyncTask->pvUserCaller); 446 446 } 447 447 else if (rc == VERR_VDI_ASYNC_IO_IN_PROGRESS) 448 448 rc = VINF_SUCCESS; 449 449 450 rc = RTCacheInsert(p Data->pCache, pDrvVDAsyncTask);450 rc = RTCacheInsert(pThis->pCache, pDrvVDAsyncTask); 451 451 AssertRC(rc); 452 452 … … 464 464 { 465 465 PPDMDRVINS pDrvIns = PDMIBASE_2_DRVINS(pInterface); 466 PVBOXDISK p Data= PDMINS_2_DATA(pDrvIns, PVBOXDISK);466 PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK); 467 467 switch (enmInterface) 468 468 { … … 470 470 return &pDrvIns->IBase; 471 471 case PDMINTERFACE_MEDIA: 472 return &p Data->IMedia;472 return &pThis->IMedia; 473 473 case PDMINTERFACE_MEDIA_ASYNC: 474 return p Data->fAsyncIOSupported ? &pData->IMediaAsync : NULL;474 return pThis->fAsyncIOSupported ? &pThis->IMediaAsync : NULL; 475 475 case PDMINTERFACE_TRANSPORT_ASYNC_PORT: 476 return &p Data->ITransportAsyncPort;476 return &pThis->ITransportAsyncPort; 477 477 default: 478 478 return NULL; … … 500 500 { 501 501 LogFlow(("%s:\n", __FUNCTION__)); 502 PVBOXDISK p Data= PDMINS_2_DATA(pDrvIns, PVBOXDISK);502 PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK); 503 503 int rc = VINF_SUCCESS; 504 504 char *pszName = NULL; /**< The path of the disk image file. */ … … 511 511 */ 512 512 pDrvIns->IBase.pfnQueryInterface = drvvdQueryInterface; 513 p Data->pDrvIns = pDrvIns;514 p Data->fTempReadOnly = false;515 p Data->pDisk = NULL;513 pThis->pDrvIns = pDrvIns; 514 pThis->fTempReadOnly = false; 515 pThis->pDisk = NULL; 516 516 517 517 /* IMedia */ 518 p Data->IMedia.pfnRead = drvvdRead;519 p Data->IMedia.pfnWrite = drvvdWrite;520 p Data->IMedia.pfnFlush = drvvdFlush;521 p Data->IMedia.pfnGetSize = drvvdGetSize;522 p Data->IMedia.pfnIsReadOnly = drvvdIsReadOnly;523 p Data->IMedia.pfnBiosGetPCHSGeometry = drvvdBiosGetPCHSGeometry;524 p Data->IMedia.pfnBiosSetPCHSGeometry = drvvdBiosSetPCHSGeometry;525 p Data->IMedia.pfnBiosGetLCHSGeometry = drvvdBiosGetLCHSGeometry;526 p Data->IMedia.pfnBiosSetLCHSGeometry = drvvdBiosSetLCHSGeometry;527 p Data->IMedia.pfnGetUuid = drvvdGetUuid;518 pThis->IMedia.pfnRead = drvvdRead; 519 pThis->IMedia.pfnWrite = drvvdWrite; 520 pThis->IMedia.pfnFlush = drvvdFlush; 521 pThis->IMedia.pfnGetSize = drvvdGetSize; 522 pThis->IMedia.pfnIsReadOnly = drvvdIsReadOnly; 523 pThis->IMedia.pfnBiosGetPCHSGeometry = drvvdBiosGetPCHSGeometry; 524 pThis->IMedia.pfnBiosSetPCHSGeometry = drvvdBiosSetPCHSGeometry; 525 pThis->IMedia.pfnBiosGetLCHSGeometry = drvvdBiosGetLCHSGeometry; 526 pThis->IMedia.pfnBiosSetLCHSGeometry = drvvdBiosSetLCHSGeometry; 527 pThis->IMedia.pfnGetUuid = drvvdGetUuid; 528 528 529 529 /* IMediaAsync */ 530 p Data->IMediaAsync.pfnStartRead = drvvdStartRead;531 p Data->IMediaAsync.pfnStartWrite = drvvdStartWrite;530 pThis->IMediaAsync.pfnStartRead = drvvdStartRead; 531 pThis->IMediaAsync.pfnStartWrite = drvvdStartWrite; 532 532 533 533 /* ITransportAsyncPort */ 534 p Data->ITransportAsyncPort.pfnTaskCompleteNotify = drvvdTasksCompleteNotify;534 pThis->ITransportAsyncPort.pfnTaskCompleteNotify = drvvdTasksCompleteNotify; 535 535 536 536 /* Initialize supported VD interfaces. */ 537 p Data->VDIErrorCallbacks.cbSize = sizeof(VDINTERFACEERROR);538 p Data->VDIErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;539 p Data->VDIErrorCallbacks.pfnError = drvvdErrorCallback;540 541 rc = VDInterfaceCreate(&p Data->VDIError, "DrvVD_VDIError", VDINTERFACETYPE_ERROR,542 &p Data->VDIErrorCallbacks, pDrvIns, NULL);537 pThis->VDIErrorCallbacks.cbSize = sizeof(VDINTERFACEERROR); 538 pThis->VDIErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR; 539 pThis->VDIErrorCallbacks.pfnError = drvvdErrorCallback; 540 541 rc = VDInterfaceCreate(&pThis->VDIError, "DrvVD_VDIError", VDINTERFACETYPE_ERROR, 542 &pThis->VDIErrorCallbacks, pDrvIns, NULL); 543 543 AssertRC(rc); 544 544 545 p Data->VDIAsyncIOCallbacks.cbSize = sizeof(VDINTERFACEASYNCIO);546 p Data->VDIAsyncIOCallbacks.enmInterface = VDINTERFACETYPE_ASYNCIO;547 p Data->VDIAsyncIOCallbacks.pfnOpen = drvvdAsyncIOOpen;548 p Data->VDIAsyncIOCallbacks.pfnClose = drvvdAsyncIOClose;549 p Data->VDIAsyncIOCallbacks.pfnRead = drvvdAsyncIORead;550 p Data->VDIAsyncIOCallbacks.pfnWrite = drvvdAsyncIOWrite;551 p Data->VDIAsyncIOCallbacks.pfnFlush = drvvdAsyncIOFlush;552 p Data->VDIAsyncIOCallbacks.pfnPrepareRead = drvvdAsyncIOPrepareRead;553 p Data->VDIAsyncIOCallbacks.pfnPrepareWrite = drvvdAsyncIOPrepareWrite;554 p Data->VDIAsyncIOCallbacks.pfnTasksSubmit = drvvdAsyncIOTasksSubmit;555 556 rc = VDInterfaceCreate(&p Data->VDIAsyncIO, "DrvVD_AsyncIO", VDINTERFACETYPE_ASYNCIO,557 &p Data->VDIAsyncIOCallbacks, pData, &pData->VDIError);545 pThis->VDIAsyncIOCallbacks.cbSize = sizeof(VDINTERFACEASYNCIO); 546 pThis->VDIAsyncIOCallbacks.enmInterface = VDINTERFACETYPE_ASYNCIO; 547 pThis->VDIAsyncIOCallbacks.pfnOpen = drvvdAsyncIOOpen; 548 pThis->VDIAsyncIOCallbacks.pfnClose = drvvdAsyncIOClose; 549 pThis->VDIAsyncIOCallbacks.pfnRead = drvvdAsyncIORead; 550 pThis->VDIAsyncIOCallbacks.pfnWrite = drvvdAsyncIOWrite; 551 pThis->VDIAsyncIOCallbacks.pfnFlush = drvvdAsyncIOFlush; 552 pThis->VDIAsyncIOCallbacks.pfnPrepareRead = drvvdAsyncIOPrepareRead; 553 pThis->VDIAsyncIOCallbacks.pfnPrepareWrite = drvvdAsyncIOPrepareWrite; 554 pThis->VDIAsyncIOCallbacks.pfnTasksSubmit = drvvdAsyncIOTasksSubmit; 555 556 rc = VDInterfaceCreate(&pThis->VDIAsyncIO, "DrvVD_AsyncIO", VDINTERFACETYPE_ASYNCIO, 557 &pThis->VDIAsyncIOCallbacks, pThis, &pThis->VDIError); 558 558 AssertRC(rc); 559 559 560 p Data->VDIConfigCallbacks.cbSize = sizeof(VDINTERFACECONFIG);561 p Data->VDIConfigCallbacks.enmInterface = VDINTERFACETYPE_CONFIG;562 p Data->VDIConfigCallbacks.pfnAreValuesValid = drvvdCfgAreValuesValid;563 p Data->VDIConfigCallbacks.pfnQueryType = drvvdCfgQueryType;564 p Data->VDIConfigCallbacks.pfnQuerySize = drvvdCfgQuerySize;565 p Data->VDIConfigCallbacks.pfnQueryInteger = drvvdCfgQueryInteger;566 p Data->VDIConfigCallbacks.pfnQueryIntegerDef = drvvdCfgQueryIntegerDef;567 p Data->VDIConfigCallbacks.pfnQueryString = drvvdCfgQueryString;568 p Data->VDIConfigCallbacks.pfnQueryStringDef = drvvdCfgQueryStringDef;569 p Data->VDIConfigCallbacks.pfnQueryBytes = drvvdCfgQueryBytes;560 pThis->VDIConfigCallbacks.cbSize = sizeof(VDINTERFACECONFIG); 561 pThis->VDIConfigCallbacks.enmInterface = VDINTERFACETYPE_CONFIG; 562 pThis->VDIConfigCallbacks.pfnAreValuesValid = drvvdCfgAreValuesValid; 563 pThis->VDIConfigCallbacks.pfnQueryType = drvvdCfgQueryType; 564 pThis->VDIConfigCallbacks.pfnQuerySize = drvvdCfgQuerySize; 565 pThis->VDIConfigCallbacks.pfnQueryInteger = drvvdCfgQueryInteger; 566 pThis->VDIConfigCallbacks.pfnQueryIntegerDef = drvvdCfgQueryIntegerDef; 567 pThis->VDIConfigCallbacks.pfnQueryString = drvvdCfgQueryString; 568 pThis->VDIConfigCallbacks.pfnQueryStringDef = drvvdCfgQueryStringDef; 569 pThis->VDIConfigCallbacks.pfnQueryBytes = drvvdCfgQueryBytes; 570 570 571 571 /** @todo TEMP! this isn't really correct - this needs to be made per image, … … 573 573 * At the moment this is harmless, as iSCSI can only be used as a base 574 574 * image, and no other backend uses the private data for these callbacks. */ 575 rc = VDInterfaceCreate(&p Data->VDIConfig, "DrvVD_Config", VDINTERFACETYPE_CONFIG,576 &p Data->VDIConfigCallbacks, NULL /**< @todo TEMP */, &pData->VDIAsyncIO);575 rc = VDInterfaceCreate(&pThis->VDIConfig, "DrvVD_Config", VDINTERFACETYPE_CONFIG, 576 &pThis->VDIConfigCallbacks, NULL /**< @todo TEMP */, &pThis->VDIAsyncIO); 577 577 AssertRC(rc); 578 578 579 579 /* Try to attach async media port interface above.*/ 580 p Data->pDrvMediaAsyncPort = (PPDMIMEDIAASYNCPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_MEDIA_ASYNC_PORT);580 pThis->pDrvMediaAsyncPort = (PPDMIMEDIAASYNCPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_MEDIA_ASYNC_PORT); 581 581 582 582 /* … … 584 584 * async interface. 585 585 */ 586 if (p Data->pDrvMediaAsyncPort)586 if (pThis->pDrvMediaAsyncPort) 587 587 { 588 588 /* Try to attach the driver. */ … … 596 596 * Revert to non async I/O. 597 597 */ 598 p Data->pDrvMediaAsyncPort = NULL;598 pThis->pDrvMediaAsyncPort = NULL; 599 599 } 600 600 else if (RT_FAILURE(rc)) … … 605 605 { 606 606 /* Success query the async transport interface. */ 607 p Data->pDrvTransportAsync = (PPDMITRANSPORTASYNC)pBase->pfnQueryInterface(pBase, PDMINTERFACE_TRANSPORT_ASYNC);608 if (!p Data->pDrvTransportAsync)607 pThis->pDrvTransportAsync = (PPDMITRANSPORTASYNC)pBase->pfnQueryInterface(pBase, PDMINTERFACE_TRANSPORT_ASYNC); 608 if (!pThis->pDrvTransportAsync) 609 609 { 610 610 /* Whoops. */ … … 659 659 { 660 660 /** @todo TEMP! later the iSCSI config callbacks won't be included here */ 661 rc = VDCreate(&p Data->VDIConfig, &pData->pDisk);661 rc = VDCreate(&pThis->VDIConfig, &pThis->pDisk); 662 662 /* Error message is already set correctly. */ 663 663 } … … 717 717 { 718 718 PCFGMNODE pCfg = CFGMR3GetChild(pCurNode, "VDConfig"); 719 p Data->VDIConfig.pvUser = pCfg; /**< @todo TEMP! */719 pThis->VDIConfig.pvUser = pCfg; /**< @todo TEMP! */ 720 720 } 721 721 … … 730 730 if (fHonorZeroWrites) 731 731 uOpenFlags |= VD_OPEN_FLAGS_HONOR_ZEROES; 732 if (p Data->pDrvMediaAsyncPort)732 if (pThis->pDrvMediaAsyncPort) 733 733 uOpenFlags |= VD_OPEN_FLAGS_ASYNC_IO; 734 734 735 735 /** Try to open backend in asyc I/O mode first. */ 736 rc = VDOpen(p Data->pDisk, pszFormat, pszName, uOpenFlags);736 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags); 737 737 if (rc == VERR_NOT_SUPPORTED) 738 738 { 739 739 /* Seems async I/O is not supported by the backend, open in normal mode. */ 740 740 uOpenFlags &= ~VD_OPEN_FLAGS_ASYNC_IO; 741 rc = VDOpen(p Data->pDisk, pszFormat, pszName, uOpenFlags);741 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags); 742 742 } 743 743 … … 745 745 Log(("%s: %d - Opened '%s' in %s mode\n", __FUNCTION__, 746 746 iLevel, pszName, 747 VDIsReadOnly(p Data->pDisk) ? "read-only" : "read-write"));747 VDIsReadOnly(pThis->pDisk) ? "read-only" : "read-write")); 748 748 else 749 749 { … … 765 765 if (RT_FAILURE(rc)) 766 766 { 767 if (VALID_PTR(p Data->pDisk))768 { 769 VDDestroy(p Data->pDisk);770 p Data->pDisk = NULL;767 if (VALID_PTR(pThis->pDisk)) 768 { 769 VDDestroy(pThis->pDisk); 770 pThis->pDisk = NULL; 771 771 } 772 772 if (VALID_PTR(pszName)) … … 780 780 * it. 781 781 */ 782 p Data->fAsyncIOSupported = true;783 for (unsigned i = 0; i < VDGetCount(p Data->pDisk); i++)782 pThis->fAsyncIOSupported = true; 783 for (unsigned i = 0; i < VDGetCount(pThis->pDisk); i++) 784 784 { 785 785 VDBACKENDINFO vdBackendInfo; 786 786 787 rc = VDBackendInfoSingle(p Data->pDisk, i, &vdBackendInfo);787 rc = VDBackendInfoSingle(pThis->pDisk, i, &vdBackendInfo); 788 788 AssertRC(rc); 789 789 … … 794 794 * Check if current file is supported with async I/O) 795 795 */ 796 rc = VDImageIsAsyncIOSupported(p Data->pDisk, i, &pData->fAsyncIOSupported);796 rc = VDImageIsAsyncIOSupported(pThis->pDisk, i, &pThis->fAsyncIOSupported); 797 797 AssertRC(rc); 798 798 … … 802 802 * at least one does not support it. 803 803 */ 804 if (!p Data->fAsyncIOSupported)804 if (!pThis->fAsyncIOSupported) 805 805 break; 806 806 } 807 807 else 808 808 { 809 p Data->fAsyncIOSupported = false;809 pThis->fAsyncIOSupported = false; 810 810 break; 811 811 } … … 813 813 814 814 /* Create cache if async I/O is supported. */ 815 if (p Data->fAsyncIOSupported)816 { 817 rc = RTCacheCreate(&p Data->pCache, 0, sizeof(DRVVDASYNCTASK), RTOBJCACHE_PROTECT_INSERT);815 if (pThis->fAsyncIOSupported) 816 { 817 rc = RTCacheCreate(&pThis->pCache, 0, sizeof(DRVVDASYNCTASK), RTOBJCACHE_PROTECT_INSERT); 818 818 AssertMsg(RT_SUCCESS(rc), ("Failed to create cache rc=%Vrc\n", rc)); 819 819 } … … 834 834 { 835 835 int rc; 836 PVBOXDISK p Data= PDMINS_2_DATA(pDrvIns, PVBOXDISK);837 LogFlow(("%s:\n", __FUNCTION__)); 838 839 if (p Data->pCache)840 { 841 rc = RTCacheDestroy(p Data->pCache);836 PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK); 837 LogFlow(("%s:\n", __FUNCTION__)); 838 839 if (pThis->pCache) 840 { 841 rc = RTCacheDestroy(pThis->pCache); 842 842 AssertRC(rc); 843 843 } … … 855 855 { 856 856 LogFlow(("%s:\n", __FUNCTION__)); 857 PVBOXDISK p Data= PDMINS_2_DATA(pDrvIns, PVBOXDISK);858 if (!VDIsReadOnly(p Data->pDisk))857 PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK); 858 if (!VDIsReadOnly(pThis->pDisk)) 859 859 { 860 860 unsigned uOpenFlags; 861 int rc = VDGetOpenFlags(p Data->pDisk, VD_LAST_IMAGE, &uOpenFlags);861 int rc = VDGetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, &uOpenFlags); 862 862 AssertRC(rc); 863 863 uOpenFlags |= VD_OPEN_FLAGS_READONLY; 864 rc = VDSetOpenFlags(p Data->pDisk, VD_LAST_IMAGE, uOpenFlags);864 rc = VDSetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, uOpenFlags); 865 865 AssertRC(rc); 866 p Data->fTempReadOnly = true;866 pThis->fTempReadOnly = true; 867 867 } 868 868 } … … 877 877 { 878 878 LogFlow(("%s:\n", __FUNCTION__)); 879 PVBOXDISK p Data= PDMINS_2_DATA(pDrvIns, PVBOXDISK);880 if (p Data->fTempReadOnly)879 PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK); 880 if (pThis->fTempReadOnly) 881 881 { 882 882 unsigned uOpenFlags; 883 int rc = VDGetOpenFlags(p Data->pDisk, VD_LAST_IMAGE, &uOpenFlags);883 int rc = VDGetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, &uOpenFlags); 884 884 AssertRC(rc); 885 885 uOpenFlags &= ~VD_OPEN_FLAGS_READONLY; 886 rc = VDSetOpenFlags(p Data->pDisk, VD_LAST_IMAGE, uOpenFlags);886 rc = VDSetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, uOpenFlags); 887 887 AssertRC(rc); 888 p Data->fTempReadOnly = false;888 pThis->fTempReadOnly = false; 889 889 } 890 890 } … … 893 893 { 894 894 LogFlow(("%s:\n", __FUNCTION__)); 895 PVBOXDISK p Data= PDMINS_2_DATA(pDrvIns, PVBOXDISK);895 PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK); 896 896 897 897 /* … … 900 900 * async transport driver is destructed. 901 901 */ 902 int rc = VDCloseAll(p Data->pDisk);902 int rc = VDCloseAll(pThis->pDisk); 903 903 AssertRC(rc); 904 904 } -
trunk/src/VBox/Devices/Storage/VBoxHDD.cpp
r11267 r11269 56 56 static DECLCALLBACK(uint64_t) vdiGetSize(PPDMIMEDIA pInterface) 57 57 { 58 PVDIDISK p Data= PDMIMEDIA_2_VDIDISK(pInterface);59 uint64_t cb = VDIDiskGetSize(p Data);58 PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface); 59 uint64_t cb = VDIDiskGetSize(pThis); 60 60 LogFlow(("vdiGetSize: returns %#llx (%llu)\n", cb, cb)); 61 61 return cb; … … 94 94 static DECLCALLBACK(int) vdiBiosGetLCHSGeometry(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry) 95 95 { 96 PVDIDISK p Data= PDMIMEDIA_2_VDIDISK(pInterface);97 int rc = VDIDiskGetLCHSGeometry(p Data, pLCHSGeometry);96 PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface); 97 int rc = VDIDiskGetLCHSGeometry(pThis, pLCHSGeometry); 98 98 if (RT_SUCCESS(rc)) 99 99 { … … 113 113 static DECLCALLBACK(int) vdiBiosSetLCHSGeometry(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pLCHSGeometry) 114 114 { 115 PVDIDISK p Data= PDMIMEDIA_2_VDIDISK(pInterface);116 int rc = VDIDiskSetLCHSGeometry(p Data, pLCHSGeometry);115 PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface); 116 int rc = VDIDiskSetLCHSGeometry(pThis, pLCHSGeometry); 117 117 LogFlow(("%s: returns %Vrc (%d,%d,%d)\n", __FUNCTION__, rc, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors)); 118 118 return rc; … … 128 128 { 129 129 LogFlow(("vdiRead: off=%#llx pvBuf=%p cbRead=%d\n", off, pvBuf, cbRead)); 130 PVDIDISK p Data= PDMIMEDIA_2_VDIDISK(pInterface);131 int rc = VDIDiskRead(p Data, off, pvBuf, cbRead);130 PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface); 131 int rc = VDIDiskRead(pThis, off, pvBuf, cbRead); 132 132 if (RT_SUCCESS(rc)) 133 133 Log2(("vdiRead: off=%#llx pvBuf=%p cbRead=%d\n" … … 147 147 { 148 148 LogFlow(("vdiWrite: off=%#llx pvBuf=%p cbWrite=%d\n", off, pvBuf, cbWrite)); 149 PVDIDISK p Data= PDMIMEDIA_2_VDIDISK(pInterface);149 PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface); 150 150 Log2(("vdiWrite: off=%#llx pvBuf=%p cbWrite=%d\n" 151 151 "%.*Vhxd\n", 152 152 off, pvBuf, cbWrite, cbWrite, pvBuf)); 153 int rc = VDIDiskWrite(p Data, off, pvBuf, cbWrite);153 int rc = VDIDiskWrite(pThis, off, pvBuf, cbWrite); 154 154 LogFlow(("vdiWrite: returns %Vrc\n", rc)); 155 155 return rc; … … 165 165 { 166 166 LogFlow(("vdiFlush:\n")); 167 PVDIDISK p Data= PDMIMEDIA_2_VDIDISK(pInterface);168 VDIFlushImage(p Data->pLast);167 PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface); 168 VDIFlushImage(pThis->pLast); 169 169 int rc = VINF_SUCCESS; 170 170 LogFlow(("vdiFlush: returns %Vrc\n", rc)); … … 176 176 static DECLCALLBACK(int) vdiGetUuid(PPDMIMEDIA pInterface, PRTUUID pUuid) 177 177 { 178 PVDIDISK p Data= PDMIMEDIA_2_VDIDISK(pInterface);179 int rc = VDIDiskGetImageUuid(p Data, 0, pUuid);178 PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface); 179 int rc = VDIDiskGetImageUuid(pThis, 0, pUuid); 180 180 LogFlow(("vdiGetUuid: returns %Vrc ({%Vuuid})\n", rc, pUuid)); 181 181 return rc; … … 186 186 static DECLCALLBACK(bool) vdiIsReadOnly(PPDMIMEDIA pInterface) 187 187 { 188 PVDIDISK p Data= PDMIMEDIA_2_VDIDISK(pInterface);189 LogFlow(("vdiIsReadOnly: returns %d\n", VDIDiskIsReadOnly(p Data)));190 return VDIDiskIsReadOnly(p Data);188 PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface); 189 LogFlow(("vdiIsReadOnly: returns %d\n", VDIDiskIsReadOnly(pThis))); 190 return VDIDiskIsReadOnly(pThis); 191 191 } 192 192 … … 204 204 { 205 205 PPDMDRVINS pDrvIns = PDMIBASE_2_DRVINS(pInterface); 206 PVDIDISK p Data= PDMINS_2_DATA(pDrvIns, PVDIDISK);206 PVDIDISK pThis = PDMINS_2_DATA(pDrvIns, PVDIDISK); 207 207 switch (enmInterface) 208 208 { … … 210 210 return &pDrvIns->IBase; 211 211 case PDMINTERFACE_MEDIA: 212 return &p Data->IMedia;212 return &pThis->IMedia; 213 213 default: 214 214 return NULL; … … 227 227 LogFlow(("vdiSuspend:\n")); 228 228 #if 1 //#ifdef DEBUG_dmik 229 PVDIDISK p Data= PDMINS_2_DATA(pDrvIns, PVDIDISK);230 if (!(p Data->pLast->fOpen & VDI_OPEN_FLAGS_READONLY))231 { 232 int rc = vdiChangeImageMode(p Data->pLast, false);229 PVDIDISK pThis = PDMINS_2_DATA(pDrvIns, PVDIDISK); 230 if (!(pThis->pLast->fOpen & VDI_OPEN_FLAGS_READONLY)) 231 { 232 int rc = vdiChangeImageMode(pThis->pLast, false); 233 233 AssertRC(rc); 234 234 } … … 248 248 LogFlow(("vdiSuspend:\n")); 249 249 #if 1 // #ifdef DEBUG_dmik 250 PVDIDISK p Data= PDMINS_2_DATA(pDrvIns, PVDIDISK);251 if (!(p Data->pLast->fOpen & VDI_OPEN_FLAGS_READONLY))252 { 253 int rc = vdiChangeImageMode(p Data->pLast, true);250 PVDIDISK pThis = PDMINS_2_DATA(pDrvIns, PVDIDISK); 251 if (!(pThis->pLast->fOpen & VDI_OPEN_FLAGS_READONLY)) 252 { 253 int rc = vdiChangeImageMode(pThis->pLast, true); 254 254 AssertRC(rc); 255 255 } … … 269 269 { 270 270 LogFlow(("vdiDestruct:\n")); 271 PVDIDISK p Data= PDMINS_2_DATA(pDrvIns, PVDIDISK);272 VDIDiskCloseAllImages(p Data);271 PVDIDISK pThis = PDMINS_2_DATA(pDrvIns, PVDIDISK); 272 VDIDiskCloseAllImages(pThis); 273 273 } 274 274 … … 287 287 { 288 288 LogFlow(("vdiConstruct:\n")); 289 PVDIDISK p Data= PDMINS_2_DATA(pDrvIns, PVDIDISK);289 PVDIDISK pThis = PDMINS_2_DATA(pDrvIns, PVDIDISK); 290 290 char *pszName; /**< The path of the disk image file. */ 291 291 bool fReadOnly; /**< True if the media is readonly. */ … … 296 296 */ 297 297 pDrvIns->IBase.pfnQueryInterface = vdiQueryInterface; 298 p Data->pDrvIns = pDrvIns;299 300 vdiInitVDIDisk(p Data);298 pThis->pDrvIns = pDrvIns; 299 300 vdiInitVDIDisk(pThis); 301 301 302 302 /* IMedia */ 303 p Data->IMedia.pfnRead = vdiRead;304 p Data->IMedia.pfnWrite = vdiWrite;305 p Data->IMedia.pfnFlush = vdiFlush;306 p Data->IMedia.pfnGetSize = vdiGetSize;307 p Data->IMedia.pfnGetUuid = vdiGetUuid;308 p Data->IMedia.pfnIsReadOnly = vdiIsReadOnly;309 p Data->IMedia.pfnBiosGetPCHSGeometry = vdiBiosGetPCHSGeometry;310 p Data->IMedia.pfnBiosSetPCHSGeometry = vdiBiosSetPCHSGeometry;311 p Data->IMedia.pfnBiosGetLCHSGeometry = vdiBiosGetLCHSGeometry;312 p Data->IMedia.pfnBiosSetLCHSGeometry = vdiBiosSetLCHSGeometry;303 pThis->IMedia.pfnRead = vdiRead; 304 pThis->IMedia.pfnWrite = vdiWrite; 305 pThis->IMedia.pfnFlush = vdiFlush; 306 pThis->IMedia.pfnGetSize = vdiGetSize; 307 pThis->IMedia.pfnGetUuid = vdiGetUuid; 308 pThis->IMedia.pfnIsReadOnly = vdiIsReadOnly; 309 pThis->IMedia.pfnBiosGetPCHSGeometry = vdiBiosGetPCHSGeometry; 310 pThis->IMedia.pfnBiosSetPCHSGeometry = vdiBiosSetPCHSGeometry; 311 pThis->IMedia.pfnBiosGetLCHSGeometry = vdiBiosGetLCHSGeometry; 312 pThis->IMedia.pfnBiosSetLCHSGeometry = vdiBiosSetLCHSGeometry; 313 313 314 314 /* … … 371 371 * Open the image. 372 372 */ 373 rc = VDIDiskOpenImage(p Data, pszName, fReadOnly ? VDI_OPEN_FLAGS_READONLY373 rc = VDIDiskOpenImage(pThis, pszName, fReadOnly ? VDI_OPEN_FLAGS_READONLY 374 374 : VDI_OPEN_FLAGS_NORMAL); 375 375 if (RT_SUCCESS(rc)) 376 376 Log(("vdiConstruct: %d - Opened '%s' in %s mode\n", 377 iLevel, pszName, VDIDiskIsReadOnly(p Data) ? "read-only" : "read-write"));377 iLevel, pszName, VDIDiskIsReadOnly(pThis) ? "read-only" : "read-write")); 378 378 else 379 379 AssertMsgFailed(("Failed to open image '%s' rc=%Vrc\n", pszName, rc)); … … 387 387 /* If any of the images has the flag set, handle zero writes like normal. */ 388 388 if (RT_SUCCESS(rc)) 389 p Data->fHonorZeroWrites = fHonorZeroWrites;389 pThis->fHonorZeroWrites = fHonorZeroWrites; 390 390 391 391 /* On failure, vdiDestruct will be called, so no need to clean up here. */
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器