VirtualBox

vbox的更動 11269 路徑 trunk/src/VBox/Devices/Storage


忽略:
時間撮記:
2008-8-8 下午04:24:48 (16 年 以前)
作者:
vboxsync
訊息:

Devices: pData -> pThis.

位置:
trunk/src/VBox/Devices/Storage
檔案:
修改 6 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/Storage/DevATA.cpp

    r11267 r11269  
    30323032 * @returns true on success.
    30333033 * @returns false when the thread is still processing.
    3034  * @param   pData       Pointer to the controller data.
     3034 * @param   pThis       Pointer to the controller data.
    30353035 * @param   cMillies    How long to wait (total).
    30363036 */
     
    43724372{
    43734373    uint32_t       i = (uint32_t)(uintptr_t)pvUser;
    4374     PCIATAState   *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
    4375     PATACONTROLLER pCtl = &pData->aCts[i];
     4374    PCIATAState   *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
     4375    PATACONTROLLER pCtl = &pThis->aCts[i];
    43764376    int rc;
    43774377
     
    44064406{
    44074407    uint32_t       i = (uint32_t)(uintptr_t)pvUser;
    4408     PCIATAState   *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
    4409     PATACONTROLLER pCtl = &pData->aCts[i];
     4408    PCIATAState   *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
     4409    PATACONTROLLER pCtl = &pThis->aCts[i];
    44104410    int rc;
    44114411
     
    44524452static DECLCALLBACK(int) ataBMDMAIORangeMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
    44534453{
    4454     PCIATAState *pData = PCIDEV_2_PCIATASTATE(pPciDev);
     4454    PCIATAState *pThis = PCIDEV_2_PCIATASTATE(pPciDev);
    44554455    int         rc = VINF_SUCCESS;
    44564456    Assert(enmType == PCI_ADDRESS_SPACE_IO);
     
    44594459
    44604460    /* Register the port range. */
    4461     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
     4461    for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++)
    44624462    {
    44634463        int rc2 = PDMDevHlpIOPortRegister(pPciDev->pDevIns, (RTIOPORT)GCPhysAddress + i * 8, 8,
     
    44674467            rc = rc2;
    44684468
    4469         if (pData->fGCEnabled)
     4469        if (pThis->fGCEnabled)
    44704470        {
    44714471            rc2 = PDMDevHlpIOPortRegisterGC(pPciDev->pDevIns, (RTIOPORT)GCPhysAddress + i * 8, 8,
     
    44754475                rc = rc2;
    44764476        }
    4477         if (pData->fR0Enabled)
     4477        if (pThis->fR0Enabled)
    44784478        {
    44794479            rc2 = PDMDevHlpIOPortRegisterR0(pPciDev->pDevIns, (RTIOPORT)GCPhysAddress + i * 8, 8,
     
    44964496static DECLCALLBACK(void)  ataReset(PPDMDEVINS pDevIns)
    44974497{
    4498     PCIATAState *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
    4499 
    4500     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    4501     {
    4502         pData->aCts[i].iSelectedIf = 0;
    4503         pData->aCts[i].iAIOIf = 0;
    4504         pData->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;
    45054505        /* Report that both drives present on the bus are in DMA mode. This
    45064506         * pretends that there is a BIOS that has set it up. Normal reset
    45074507         * default is 0x00. */
    4508         pData->aCts[i].BmDma.u8Status =   (pData->aCts[i].aIfs[0].pDrvBase != NULL ? BM_STATUS_D0DMA : 0)
    4509                                         | (pData->aCts[i].aIfs[1].pDrvBase != NULL ? BM_STATUS_D1DMA : 0);
    4510         pData->aCts[i].BmDma.pvAddr = 0;
    4511 
    4512         pData->aCts[i].fReset = true;
    4513         pData->aCts[i].fRedo = false;
    4514         pData->aCts[i].fRedoIdle = false;
    4515         ataAsyncIOClearRequests(&pData->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]);
    45164516        Log2(("%s: Ctl#%d: message to async I/O thread, reset controller\n", __FUNCTION__, i));
    4517         ataAsyncIOPutRequest(&pData->aCts[i], &ataResetARequest);
    4518         ataAsyncIOPutRequest(&pData->aCts[i], &ataResetCRequest);
    4519         if (!ataWaitForAsyncIOIsIdle(&pData->aCts[i], 30000))
     4517        ataAsyncIOPutRequest(&pThis->aCts[i], &ataResetARequest);
     4518        ataAsyncIOPutRequest(&pThis->aCts[i], &ataResetCRequest);
     4519        if (!ataWaitForAsyncIOIsIdle(&pThis->aCts[i], 30000))
    45204520            AssertReleaseMsgFailed(("Async I/O thread busy after reset\n"));
    45214521
    4522         for (uint32_t j = 0; j < RT_ELEMENTS(pData->aCts[i].aIfs); j++)
    4523             ataResetDevice(&pData->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]);
    45244524    }
    45254525}
     
    45384538static DECLCALLBACK(void *) ataStatus_QueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
    45394539{
    4540     PCIATAState *pData = PDMIBASE_2_PCIATASTATE(pInterface);
     4540    PCIATAState *pThis = PDMIBASE_2_PCIATASTATE(pInterface);
    45414541    switch (enmInterface)
    45424542    {
    45434543        case PDMINTERFACE_BASE:
    4544             return &pData->IBase;
     4544            return &pThis->IBase;
    45454545        case PDMINTERFACE_LED_PORTS:
    4546             return &pData->ILeds;
     4546            return &pThis->ILeds;
    45474547        default:
    45484548            return NULL;
     
    45634563static DECLCALLBACK(int) ataStatus_QueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
    45644564{
    4565     PCIATAState *pData = PDMILEDPORTS_2_PCIATASTATE(pInterface);
     4565    PCIATAState *pThis = PDMILEDPORTS_2_PCIATASTATE(pInterface);
    45664566    if (iLUN >= 0 && iLUN <= 4)
    45674567    {
    45684568        switch (iLUN)
    45694569        {
    4570             case 0: *ppLed = &pData->aCts[0].aIfs[0].Led; break;
    4571             case 1: *ppLed = &pData->aCts[0].aIfs[1].Led; break;
    4572             case 2: *ppLed = &pData->aCts[1].aIfs[0].Led; break;
    4573             case 3: *ppLed = &pData->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;
    45744574        }
    45754575        Assert((*ppLed)->u32Magic == PDMLED_MAGIC);
     
    46184618{
    46194619    uint32_t       i = (uint32_t)(uintptr_t)pvUser;
    4620     PCIATAState   *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
    4621     PATACONTROLLER pCtl = &pData->aCts[i];
     4620    PCIATAState   *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
     4621    PATACONTROLLER pCtl = &pThis->aCts[i];
    46224622    int            rc = VINF_SUCCESS;
    46234623
     
    46504650{
    46514651    uint32_t       i = (uint32_t)(uintptr_t)pvUser;
    4652     PCIATAState   *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
    4653     PATACONTROLLER pCtl = &pData->aCts[i];
     4652    PCIATAState   *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
     4653    PATACONTROLLER pCtl = &pThis->aCts[i];
    46544654    int            rc = VINF_SUCCESS;
    46554655
     
    46874687{
    46884688    uint32_t       i = (uint32_t)(uintptr_t)pvUser;
    4689     PCIATAState   *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
    4690     PATACONTROLLER pCtl = &pData->aCts[i];
     4689    PCIATAState   *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
     4690    PATACONTROLLER pCtl = &pThis->aCts[i];
    46914691    int            rc = VINF_SUCCESS;
    46924692
     
    47444744{
    47454745    uint32_t       i = (uint32_t)(uintptr_t)pvUser;
    4746     PCIATAState   *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
    4747     PATACONTROLLER pCtl = &pData->aCts[i];
     4746    PCIATAState   *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
     4747    PATACONTROLLER pCtl = &pThis->aCts[i];
    47484748    int            rc;
    47494749
     
    48014801{
    48024802    uint32_t       i = (uint32_t)(uintptr_t)pvUser;
    4803     PCIATAState   *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
    4804     PATACONTROLLER pCtl = &pData->aCts[i];
     4803    PCIATAState   *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
     4804    PATACONTROLLER pCtl = &pThis->aCts[i];
    48054805    int rc;
    48064806
     
    48254825{
    48264826    uint32_t       i = (uint32_t)(uintptr_t)pvUser;
    4827     PCIATAState   *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
    4828     PATACONTROLLER pCtl = &pData->aCts[i];
     4827    PCIATAState   *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
     4828    PATACONTROLLER pCtl = &pThis->aCts[i];
    48294829    int            rc;
    48304830
     
    48504850 * @returns true on success.
    48514851 * @returns false when one or more threads is still processing.
    4852  * @param   pData       Pointer to the instance data.
     4852 * @param   pThis       Pointer to the instance data.
    48534853 * @param   cMillies    How long to wait (total).
    48544854 */
    48554855static bool ataWaitForAllAsyncIOIsIdle(PPDMDEVINS pDevIns, unsigned cMillies)
    48564856{
    4857     PCIATAState    *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
     4857    PCIATAState    *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
    48584858    bool            fVMLocked;
    48594859    uint64_t        u64Start;
     
    48794879        /* Check all async I/O threads. */
    48804880        fAllIdle = true;
    4881         for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    4882         {
    4883             pCtl = &pData->aCts[i];
     4881        for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++)
     4882        {
     4883            pCtl = &pThis->aCts[i];
    48844884            fAllIdle &= ataAsyncIOIsIdle(pCtl, false);
    48854885            if (!fAllIdle)
     
    49184918static DECLCALLBACK(void) ataRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    49194919{
    4920     PCIATAState *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
    4921 
    4922     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    4923     {
    4924         pData->aCts[i].pDevInsRC += offDelta;
    4925         pData->aCts[i].aIfs[0].pDevInsRC += offDelta;
    4926         pData->aCts[i].aIfs[0].pControllerRC += offDelta;
    4927         ataRelocBuffer(pDevIns, &pData->aCts[i].aIfs[0]);
    4928         pData->aCts[i].aIfs[1].pDevInsRC += offDelta;
    4929         pData->aCts[i].aIfs[1].pControllerRC += offDelta;
    4930         ataRelocBuffer(pDevIns, &pData->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]);
    49314931    }
    49324932}
     
    49434943static DECLCALLBACK(int) ataDestruct(PPDMDEVINS pDevIns)
    49444944{
    4945     PCIATAState    *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
     4945    PCIATAState    *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
    49464946    int             rc;
    49474947
     
    49514951     * Terminate all async helper threads
    49524952     */
    4953     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    4954     {
    4955         if (pData->aCts[i].AsyncIOThread != NIL_RTTHREAD)
    4956         {
    4957             ASMAtomicXchgU32(&pData->aCts[i].fShutdown, true);
    4958             rc = RTSemEventSignal(pData->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);
    49594959            AssertRC(rc);
    49604960        }
     
    49674967    if (ataWaitForAllAsyncIOIsIdle(pDevIns, 20000))
    49684968    {
    4969         for (unsigned i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    4970         {
    4971             rc = RTThreadWait(pData->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);
    49724972            AssertMsg(RT_SUCCESS(rc) || rc == VERR_INVALID_HANDLE, ("rc=%Rrc i=%d\n", rc, i));
    49734973        }
     
    49794979     * Now the request mutexes are no longer needed. Free resources.
    49804980     */
    4981     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    4982     {
    4983         if (pData->aCts[i].AsyncIORequestMutex != NIL_RTSEMEVENT)
    4984         {
    4985             RTSemMutexDestroy(pData->aCts[i].AsyncIORequestMutex);
    4986             pData->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;
    49874987        }
    49884988    }
     
    52335233static DECLCALLBACK(void) ataResume(PPDMDEVINS pDevIns)
    52345234{
    5235     PCIATAState    *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
     5235    PCIATAState    *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
    52365236    int             rc;
    52375237
    52385238    Log(("%s:\n", __FUNCTION__));
    5239     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    5240     {
    5241         if (pData->aCts[i].fRedo && pData->aCts[i].fRedoIdle)
    5242         {
    5243             rc = RTSemEventSignal(pData->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);
    52445244            AssertRC(rc);
    52455245        }
     
    52735273static DECLCALLBACK(int) ataSaveLoadPrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    52745274{
    5275     PCIATAState    *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
     5275    PCIATAState    *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
    52765276
    52775277    /* sanity - the suspend notification will wait on the async stuff. */
    5278     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    5279     {
    5280         Assert(ataAsyncIOIsIdle(&pData->aCts[i], false));
    5281         if (!ataAsyncIOIsIdle(&pData->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))
    52825282            return VERR_SSM_IDE_ASYNC_TIMEOUT;
    52835283    }
     
    52955295static DECLCALLBACK(int) ataSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
    52965296{
    5297     PCIATAState    *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
    5298 
    5299     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    5300     {
    5301         SSMR3PutU8(pSSMHandle, pData->aCts[i].iSelectedIf);
    5302         SSMR3PutU8(pSSMHandle, pData->aCts[i].iAIOIf);
    5303         SSMR3PutU8(pSSMHandle, pData->aCts[i].uAsyncIOState);
    5304         SSMR3PutBool(pSSMHandle, pData->aCts[i].fChainedTransfer);
    5305         SSMR3PutBool(pSSMHandle, pData->aCts[i].fReset);
    5306         SSMR3PutBool(pSSMHandle, pData->aCts[i].fRedo);
    5307         SSMR3PutBool(pSSMHandle, pData->aCts[i].fRedoIdle);
    5308         SSMR3PutBool(pSSMHandle, pData->aCts[i].fRedoDMALastDesc);
    5309         SSMR3PutMem(pSSMHandle, &pData->aCts[i].BmDma, sizeof(pData->aCts[i].BmDma));
    5310         SSMR3PutGCPhys32(pSSMHandle, pData->aCts[i].pFirstDMADesc);
    5311         SSMR3PutGCPhys32(pSSMHandle, pData->aCts[i].pLastDMADesc);
    5312         SSMR3PutGCPhys32(pSSMHandle, pData->aCts[i].pRedoDMABuffer);
    5313         SSMR3PutU32(pSSMHandle, pData->aCts[i].cbRedoDMABuffer);
    5314 
    5315         for (uint32_t j = 0; j < RT_ELEMENTS(pData->aCts[i].aIfs); j++)
    5316         {
    5317             SSMR3PutBool(pSSMHandle, pData->aCts[i].aIfs[j].fLBA48);
    5318             SSMR3PutBool(pSSMHandle, pData->aCts[i].aIfs[j].fATAPI);
    5319             SSMR3PutBool(pSSMHandle, pData->aCts[i].aIfs[j].fIrqPending);
    5320             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].cMultSectors);
    5321             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].PCHSGeometry.cCylinders);
    5322             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].PCHSGeometry.cHeads);
    5323             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].PCHSGeometry.cSectors);
    5324             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].cSectorsPerIRQ);
    5325             SSMR3PutU64(pSSMHandle, pData->aCts[i].aIfs[j].cTotalSectors);
    5326             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegFeature);
    5327             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegFeatureHOB);
    5328             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegError);
    5329             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegNSector);
    5330             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegNSectorHOB);
    5331             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegSector);
    5332             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegSectorHOB);
    5333             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegLCyl);
    5334             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegLCylHOB);
    5335             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegHCyl);
    5336             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegHCylHOB);
    5337             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegSelect);
    5338             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegStatus);
    5339             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegCommand);
    5340             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATARegDevCtl);
    5341             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATATransferMode);
    5342             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uTxDir);
    5343             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].iBeginTransfer);
    5344             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].iSourceSink);
    5345             SSMR3PutBool(pSSMHandle, pData->aCts[i].aIfs[j].fDMA);
    5346             SSMR3PutBool(pSSMHandle, pData->aCts[i].aIfs[j].fATAPITransfer);
    5347             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].cbTotalTransfer);
    5348             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].cbElementaryTransfer);
    5349             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].iIOBufferCur);
    5350             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].iIOBufferEnd);
    5351             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].iIOBufferPIODataStart);
    5352             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].iIOBufferPIODataEnd);
    5353             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].iATAPILBA);
    5354             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].cbATAPISector);
    5355             SSMR3PutMem(pSSMHandle, &pData->aCts[i].aIfs[j].aATAPICmd, sizeof(pData->aCts[i].aIfs[j].aATAPICmd));
    5356             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATAPISenseKey);
    5357             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].uATAPIASC);
    5358             SSMR3PutU8(pSSMHandle, pData->aCts[i].aIfs[j].cNotifiedMediaChange);
    5359             SSMR3PutMem(pSSMHandle, &pData->aCts[i].aIfs[j].Led, sizeof(pData->aCts[i].aIfs[j].Led));
    5360             SSMR3PutU32(pSSMHandle, pData->aCts[i].aIfs[j].cbIOBuffer);
    5361             if (pData->aCts[i].aIfs[j].cbIOBuffer)
    5362                 SSMR3PutMem(pSSMHandle, pData->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);
    53635363            else
    5364                 Assert(pData->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer) == NULL);
    5365         }
    5366     }
    5367     SSMR3PutBool(pSSMHandle, pData->fPIIX4);
     5364                Assert(pThis->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer) == NULL);
     5365        }
     5366    }
     5367    SSMR3PutBool(pSSMHandle, pThis->fPIIX4);
    53685368
    53695369    return SSMR3PutU32(pSSMHandle, ~0); /* sanity/terminator */
     
    53815381static DECLCALLBACK(int) ataLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, uint32_t u32Version)
    53825382{
    5383     PCIATAState    *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
     5383    PCIATAState    *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
    53845384    int             rc;
    53855385    uint32_t        u32;
     
    53945394     * Restore valid parts of the PCIATAState structure
    53955395     */
    5396     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
     5396    for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++)
    53975397    {
    53985398        /* integrity check */
    5399         if (!ataAsyncIOIsIdle(&pData->aCts[i], false))
     5399        if (!ataAsyncIOIsIdle(&pThis->aCts[i], false))
    54005400        {
    54015401            AssertMsgFailed(("Async I/O for controller %d is active\n", i));
     
    54045404        }
    54055405
    5406         SSMR3GetU8(pSSMHandle, &pData->aCts[i].iSelectedIf);
    5407         SSMR3GetU8(pSSMHandle, &pData->aCts[i].iAIOIf);
    5408         SSMR3GetU8(pSSMHandle, &pData->aCts[i].uAsyncIOState);
    5409         SSMR3GetBool(pSSMHandle, &pData->aCts[i].fChainedTransfer);
    5410         SSMR3GetBool(pSSMHandle, (bool *)&pData->aCts[i].fReset);
    5411         SSMR3GetBool(pSSMHandle, (bool *)&pData->aCts[i].fRedo);
    5412         SSMR3GetBool(pSSMHandle, (bool *)&pData->aCts[i].fRedoIdle);
    5413         SSMR3GetBool(pSSMHandle, (bool *)&pData->aCts[i].fRedoDMALastDesc);
    5414         SSMR3GetMem(pSSMHandle, &pData->aCts[i].BmDma, sizeof(pData->aCts[i].BmDma));
    5415         SSMR3GetGCPhys32(pSSMHandle, &pData->aCts[i].pFirstDMADesc);
    5416         SSMR3GetGCPhys32(pSSMHandle, &pData->aCts[i].pLastDMADesc);
    5417         SSMR3GetGCPhys32(pSSMHandle, &pData->aCts[i].pRedoDMABuffer);
    5418         SSMR3GetU32(pSSMHandle, &pData->aCts[i].cbRedoDMABuffer);
    5419 
    5420         for (uint32_t j = 0; j < RT_ELEMENTS(pData->aCts[i].aIfs); j++)
    5421         {
    5422             SSMR3GetBool(pSSMHandle, &pData->aCts[i].aIfs[j].fLBA48);
    5423             SSMR3GetBool(pSSMHandle, &pData->aCts[i].aIfs[j].fATAPI);
    5424             SSMR3GetBool(pSSMHandle, &pData->aCts[i].aIfs[j].fIrqPending);
    5425             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].cMultSectors);
    5426             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].PCHSGeometry.cCylinders);
    5427             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].PCHSGeometry.cHeads);
    5428             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].PCHSGeometry.cSectors);
    5429             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].cSectorsPerIRQ);
    5430             SSMR3GetU64(pSSMHandle, &pData->aCts[i].aIfs[j].cTotalSectors);
    5431             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegFeature);
    5432             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegFeatureHOB);
    5433             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegError);
    5434             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegNSector);
    5435             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegNSectorHOB);
    5436             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegSector);
    5437             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegSectorHOB);
    5438             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegLCyl);
    5439             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegLCylHOB);
    5440             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegHCyl);
    5441             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegHCylHOB);
    5442             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegSelect);
    5443             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegStatus);
    5444             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegCommand);
    5445             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATARegDevCtl);
    5446             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATATransferMode);
    5447             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uTxDir);
    5448             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].iBeginTransfer);
    5449             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].iSourceSink);
    5450             SSMR3GetBool(pSSMHandle, &pData->aCts[i].aIfs[j].fDMA);
    5451             SSMR3GetBool(pSSMHandle, &pData->aCts[i].aIfs[j].fATAPITransfer);
    5452             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].cbTotalTransfer);
    5453             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].cbElementaryTransfer);
    5454             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].iIOBufferCur);
    5455             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].iIOBufferEnd);
    5456             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].iIOBufferPIODataStart);
    5457             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].iIOBufferPIODataEnd);
    5458             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].iATAPILBA);
    5459             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].cbATAPISector);
    5460             SSMR3GetMem(pSSMHandle, &pData->aCts[i].aIfs[j].aATAPICmd, sizeof(pData->aCts[i].aIfs[j].aATAPICmd));
    5461             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATAPISenseKey);
    5462             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].uATAPIASC);
    5463             SSMR3GetU8(pSSMHandle, &pData->aCts[i].aIfs[j].cNotifiedMediaChange);
    5464             SSMR3GetMem(pSSMHandle, &pData->aCts[i].aIfs[j].Led, sizeof(pData->aCts[i].aIfs[j].Led));
    5465             SSMR3GetU32(pSSMHandle, &pData->aCts[i].aIfs[j].cbIOBuffer);
    5466             if (pData->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)
    54675467            {
    5468                 if (pData->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer))
    5469                     SSMR3GetMem(pSSMHandle, pData->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);
    54705470                else
    54715471                {
     
    54765476                    /* skip the buffer if we're loading for the debugger / animator. */
    54775477                    uint8_t u8Ignored;
    5478                     size_t cbLeft = pData->aCts[i].aIfs[j].cbIOBuffer;
     5478                    size_t cbLeft = pThis->aCts[i].aIfs[j].cbIOBuffer;
    54795479                    while (cbLeft-- > 0)
    54805480                        SSMR3GetU8(pSSMHandle, &u8Ignored);
     
    54825482            }
    54835483            else
    5484                 Assert(pData->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer) == NULL);
    5485         }
    5486     }
    5487     SSMR3GetBool(pSSMHandle, &pData->fPIIX4);
     5484                Assert(pThis->aCts[i].aIfs[j].CTX_SUFF(pbIOBuffer) == NULL);
     5485        }
     5486    }
     5487    SSMR3GetBool(pSSMHandle, &pThis->fPIIX4);
    54885488
    54895489    rc = SSMR3GetU32(pSSMHandle, &u32);
     
    55165516static DECLCALLBACK(int)   ataConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfgHandle)
    55175517{
    5518     PCIATAState    *pData = PDMINS_2_DATA(pDevIns, PCIATAState *);
     5518    PCIATAState    *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
    55195519    PPDMIBASE       pBase;
    55205520    int             rc;
     
    55285528     * Initialize NIL handle values (for the destructor).
    55295529     */
    5530     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    5531     {
    5532         pData->aCts[i].AsyncIOSem = NIL_RTSEMEVENT;
    5533         pData->aCts[i].SuspendIOSem = NIL_RTSEMEVENT;
    5534         pData->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;
    55355535    }
    55365536
     
    55615561    Assert(DelayIRQMillies < 50);
    55625562
    5563     rc = CFGMR3QueryBoolDef(pCfgHandle, "PIIX4", &pData->fPIIX4, false);
     5563    rc = CFGMR3QueryBoolDef(pCfgHandle, "PIIX4", &pThis->fPIIX4, false);
    55645564    if (RT_FAILURE(rc))
    55655565        return PDMDEV_SET_ERROR(pDevIns, rc,
    55665566                                N_("PIIX3 configuration error: failed to read PIIX4 as boolean"));
    5567     Log(("%s: fPIIX4=%d\n", __FUNCTION__, pData->fPIIX4));
     5567    Log(("%s: fPIIX4=%d\n", __FUNCTION__, pThis->fPIIX4));
    55685568
    55695569    /*
     
    55715571     */
    55725572    /* Status LUN. */
    5573     pData->IBase.pfnQueryInterface = ataStatus_QueryInterface;
    5574     pData->ILeds.pfnQueryStatusLed = ataStatus_QueryStatusLed;
     5573    pThis->IBase.pfnQueryInterface = ataStatus_QueryInterface;
     5574    pThis->ILeds.pfnQueryStatusLed = ataStatus_QueryStatusLed;
    55755575
    55765576    /* PCI configuration space. */
    5577     PCIDevSetVendorId(&pData->dev, 0x8086); /* Intel */
    5578     if (pData->fPIIX4)
    5579     {
    5580         PCIDevSetDeviceId(&pData->dev, 0x7111); /* PIIX4 IDE */
    5581         PCIDevSetRevisionId(&pData->dev, 0x01); /* PIIX4E */
    5582         pData->dev.config[0x48] = 0x00; /* UDMACTL */
    5583         pData->dev.config[0x4A] = 0x00; /* UDMATIM */
    5584         pData->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;
    55855585    }
    55865586    else
    5587         PCIDevSetDeviceId(&pData->dev, 0x7010); /* PIIX3 IDE */
    5588     PCIDevSetCommand(   &pData->dev, PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS | PCI_COMMAND_BUSMASTER);
    5589     PCIDevSetClassProg( &pData->dev, 0x8a); /* programming interface = PCI_IDE bus master is supported */
    5590     PCIDevSetClassSub(  &pData->dev, 0x01); /* class_sub = PCI_IDE */
    5591     PCIDevSetClassBase( &pData->dev, 0x01); /* class_base = PCI_mass_storage */
    5592     PCIDevSetHeaderType(&pData->dev, 0x00);
    5593 
    5594     pData->pDevIns          = pDevIns;
    5595     pData->fGCEnabled       = fGCEnabled;
    5596     pData->fR0Enabled       = fR0Enabled;
    5597     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    5598     {
    5599         pData->aCts[i].pDevInsR3 = pDevIns;
    5600         pData->aCts[i].pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    5601         pData->aCts[i].pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    5602         pData->aCts[i].DelayIRQMillies = (uint32_t)DelayIRQMillies;
    5603         for (uint32_t j = 0; j < RT_ELEMENTS(pData->aCts[i].aIfs); j++)
    5604         {
    5605             pData->aCts[i].aIfs[j].iLUN = i * RT_ELEMENTS(pData->aCts) + j;
    5606             pData->aCts[i].aIfs[j].pDevInsR3 = pDevIns;
    5607             pData->aCts[i].aIfs[j].pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    5608             pData->aCts[i].aIfs[j].pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    5609             pData->aCts[i].aIfs[j].pControllerR3 = &pData->aCts[i];
    5610             pData->aCts[i].aIfs[j].pControllerR0 = MMHyperR3ToR0(PDMDevHlpGetVM(pDevIns), &pData->aCts[i]);
    5611             pData->aCts[i].aIfs[j].pControllerRC = MMHyperR3ToRC(PDMDevHlpGetVM(pDevIns), &pData->aCts[i]);
    5612             pData->aCts[i].aIfs[j].IBase.pfnQueryInterface = ataQueryInterface;
    5613             pData->aCts[i].aIfs[j].IMountNotify.pfnMountNotify = ataMountNotify;
    5614             pData->aCts[i].aIfs[j].IMountNotify.pfnUnmountNotify = ataUnmountNotify;
    5615             pData->aCts[i].aIfs[j].Led.u32Magic = PDMLED_MAGIC;
    5616         }
    5617     }
    5618 
    5619     Assert(RT_ELEMENTS(pData->aCts) == 2);
    5620     pData->aCts[0].irq          = 14;
    5621     pData->aCts[0].IOPortBase1  = 0x1f0;
    5622     pData->aCts[0].IOPortBase2  = 0x3f6;
    5623     pData->aCts[1].irq          = 15;
    5624     pData->aCts[1].IOPortBase1  = 0x170;
    5625     pData->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;
    56265626
    56275627    /*
     
    56305630     *      device the slot next to itself.
    56315631     */
    5632     rc = PDMDevHlpPCIRegister(pDevIns, &pData->dev);
     5632    rc = PDMDevHlpPCIRegister(pDevIns, &pThis->dev);
    56335633    if (RT_FAILURE(rc))
    56345634        return PDMDEV_SET_ERROR(pDevIns, rc,
    56355635                                N_("PIIX3 cannot register PCI device"));
    5636     AssertMsg(pData->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));
    56375637    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 4, 0x10, PCI_ADDRESS_SPACE_IO, ataBMDMAIORangeMap);
    56385638    if (RT_FAILURE(rc))
     
    56445644     * The ports are all hardcoded and enforced by the PIIX3 host bridge controller.
    56455645     */
    5646     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    5647     {
    5648         rc = PDMDevHlpIOPortRegister(pDevIns, pData->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,
    56495649                                     ataIOPortWrite1, ataIOPortRead1, ataIOPortWriteStr1, ataIOPortReadStr1, "ATA I/O Base 1");
    56505650        if (RT_FAILURE(rc))
     
    56535653        if (fGCEnabled)
    56545654        {
    5655             rc = PDMDevHlpIOPortRegisterGC(pDevIns, pData->aCts[i].IOPortBase1, 8, (RTGCPTR)i,
     5655            rc = PDMDevHlpIOPortRegisterGC(pDevIns, pThis->aCts[i].IOPortBase1, 8, (RTGCPTR)i,
    56565656                                           "ataIOPortWrite1", "ataIOPortRead1", "ataIOPortWriteStr1", "ataIOPortReadStr1", "ATA I/O Base 1");
    56575657            if (RT_FAILURE(rc))
     
    56625662        {
    56635663#if 1
    5664             rc = PDMDevHlpIOPortRegisterR0(pDevIns, pData->aCts[i].IOPortBase1, 8, (RTR0PTR)i,
     5664            rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->aCts[i].IOPortBase1, 8, (RTR0PTR)i,
    56655665                                           "ataIOPortWrite1", "ataIOPortRead1", NULL, NULL, "ATA I/O Base 1");
    56665666#else
    5667             rc = PDMDevHlpIOPortRegisterR0(pDevIns, pData->aCts[i].IOPortBase1, 8, (RTR0PTR)i,
     5667            rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->aCts[i].IOPortBase1, 8, (RTR0PTR)i,
    56685668                                           "ataIOPortWrite1", "ataIOPortRead1", "ataIOPortWriteStr1", "ataIOPortReadStr1", "ATA I/O Base 1");
    56695669#endif
     
    56725672        }
    56735673
    5674         rc = PDMDevHlpIOPortRegister(pDevIns, pData->aCts[i].IOPortBase2, 1, (RTHCPTR)i,
     5674        rc = PDMDevHlpIOPortRegister(pDevIns, pThis->aCts[i].IOPortBase2, 1, (RTHCPTR)i,
    56755675                                     ataIOPortWrite2, ataIOPortRead2, NULL, NULL, "ATA I/O Base 2");
    56765676        if (RT_FAILURE(rc))
     
    56795679        if (fGCEnabled)
    56805680        {
    5681             rc = PDMDevHlpIOPortRegisterGC(pDevIns, pData->aCts[i].IOPortBase2, 1, (RTGCPTR)i,
     5681            rc = PDMDevHlpIOPortRegisterGC(pDevIns, pThis->aCts[i].IOPortBase2, 1, (RTGCPTR)i,
    56825682                                           "ataIOPortWrite2", "ataIOPortRead2", NULL, NULL, "ATA I/O Base 2");
    56835683            if (RT_FAILURE(rc))
     
    56865686        if (fR0Enabled)
    56875687        {
    5688             rc = PDMDevHlpIOPortRegisterR0(pDevIns, pData->aCts[i].IOPortBase2, 1, (RTR0PTR)i,
     5688            rc = PDMDevHlpIOPortRegisterR0(pDevIns, pThis->aCts[i].IOPortBase2, 1, (RTR0PTR)i,
    56895689                                           "ataIOPortWrite2", "ataIOPortRead2", NULL, NULL, "ATA I/O Base 2");
    56905690            if (RT_FAILURE(rc))
     
    56925692        }
    56935693
    5694         for (uint32_t j = 0; j < RT_ELEMENTS(pData->aCts[i].aIfs); j++)
    5695         {
    5696             ATADevState *pIf = &pData->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];
    56975697            PDMDevHlpSTAMRegisterF(pDevIns, &pIf->StatATADMA,       STAMTYPE_COUNTER,    STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,       "Number of ATA DMA transfers.", "/Devices/ATA%d/Unit%d/DMA", i, j);
    56985698            PDMDevHlpSTAMRegisterF(pDevIns, &pIf->StatATAPIO,       STAMTYPE_COUNTER,    STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES,       "Number of ATA PIO transfers.", "/Devices/ATA%d/Unit%d/PIO", i, j);
     
    57155715        }
    57165716#ifdef VBOX_WITH_STATISTICS /** @todo release too. */
    5717         PDMDevHlpSTAMRegisterF(pDevIns, &pData->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);
    57185718        /** @todo STAMUNIT_MICROSECS */
    5719         PDMDevHlpSTAMRegisterF(pDevIns, &pData->aCts[i].StatAsyncMinWait, STAMTYPE_U64_RESET, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE,         "Minimum wait in microseconds.",    "/Devices/ATA%d/Async/MinWait", i);
    5720         PDMDevHlpSTAMRegisterF(pDevIns, &pData->aCts[i].StatAsyncMaxWait, STAMTYPE_U64_RESET, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE,         "Maximum wait in microseconds.",    "/Devices/ATA%d/Async/MaxWait", i);
    5721         PDMDevHlpSTAMRegisterF(pDevIns, &pData->aCts[i].StatAsyncTimeUS,    STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_NONE,         "Total time spent in microseconds.","/Devices/ATA%d/Async/TotalTimeUS", i);
    5722         PDMDevHlpSTAMRegisterF(pDevIns, &pData->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, &pData->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);
    57245724#endif /* VBOX_WITH_STATISTICS */
    57255725
     
    57275727        char szName[24];
    57285728        RTStrPrintf(szName, sizeof(szName), "ATA%d", i);
    5729         rc = PDMDevHlpCritSectInit(pDevIns, &pData->aCts[i].lock, szName);
     5729        rc = PDMDevHlpCritSectInit(pDevIns, &pThis->aCts[i].lock, szName);
    57305730        if (RT_FAILURE(rc))
    57315731            return PDMDEV_SET_ERROR(pDevIns, rc, N_("PIIX3 cannot initialize critical section"));
     
    57355735     * Attach status driver (optional).
    57365736     */
    5737     rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pData->IBase, &pBase, "Status Port");
     5737    rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis->IBase, &pBase, "Status Port");
    57385738    if (RT_SUCCESS(rc))
    5739         pData->pLedsConnector = (PDMILEDCONNECTORS *)pBase->pfnQueryInterface(pBase, PDMINTERFACE_LED_CONNECTORS);
     5739        pThis->pLedsConnector = (PDMILEDCONNECTORS *)pBase->pfnQueryInterface(pBase, PDMINTERFACE_LED_CONNECTORS);
    57405740    else if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
    57415741    {
     
    57485748     */
    57495749    uint32_t cbTotalBuffer = 0;
    5750     for (uint32_t i = 0; i < RT_ELEMENTS(pData->aCts); i++)
    5751     {
    5752         PATACONTROLLER pCtl = &pData->aCts[i];
     5750    for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++)
     5751    {
     5752        PATACONTROLLER pCtl = &pThis->aCts[i];
    57535753
    57545754        /*
     
    57705770        for (uint32_t j = 0; j < RT_ELEMENTS(pCtl->aIfs); j++)
    57715771        {
    5772             static const char *s_apszDescs[RT_ELEMENTS(pData->aCts)][RT_ELEMENTS(pCtl->aIfs)] =
     5772            static const char *s_apszDescs[RT_ELEMENTS(pThis->aCts)][RT_ELEMENTS(pCtl->aIfs)] =
    57735773            {
    57745774                { "Primary Master", "Primary Slave" },
     
    58145814
    58155815    rc = PDMDevHlpSSMRegister(pDevIns, pDevIns->pDevReg->szDeviceName, iInstance,
    5816                               ATA_SAVED_STATE_VERSION, sizeof(*pData) + cbTotalBuffer,
     5816                              ATA_SAVED_STATE_VERSION, sizeof(*pThis) + cbTotalBuffer,
    58175817                              ataSaveLoadPrep, ataSaveExec, NULL,
    58185818                              ataSaveLoadPrep, ataLoadExec, NULL);
  • trunk/src/VBox/Devices/Storage/DrvBlock.cpp

    r11267 r11269  
    127127static DECLCALLBACK(int) drvblockRead(PPDMIBLOCK pInterface, uint64_t off, void *pvBuf, size_t cbRead)
    128128{
    129     PDRVBLOCK pData = PDMIBLOCK_2_DRVBLOCK(pInterface);
    130 
    131     /*
    132      * Check the state.
    133      */
    134     if (!pData->pDrvMedia)
     129    PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
     130
     131    /*
     132     * Check the state.
     133     */
     134    if (!pThis->pDrvMedia)
    135135    {
    136136        AssertMsgFailed(("Invalid state! Not mounted!\n"));
     
    138138    }
    139139
    140     int rc = pData->pDrvMedia->pfnRead(pData->pDrvMedia, off, pvBuf, cbRead);
     140    int rc = pThis->pDrvMedia->pfnRead(pThis->pDrvMedia, off, pvBuf, cbRead);
    141141    return rc;
    142142}
     
    146146static DECLCALLBACK(int) drvblockWrite(PPDMIBLOCK pInterface, uint64_t off, const void *pvBuf, size_t cbWrite)
    147147{
    148     PDRVBLOCK pData = PDMIBLOCK_2_DRVBLOCK(pInterface);
    149 
    150     /*
    151      * Check the state.
    152      */
    153     if (!pData->pDrvMedia)
     148    PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
     149
     150    /*
     151     * Check the state.
     152     */
     153    if (!pThis->pDrvMedia)
    154154    {
    155155        AssertMsgFailed(("Invalid state! Not mounted!\n"));
     
    157157    }
    158158
    159     int rc = pData->pDrvMedia->pfnWrite(pData->pDrvMedia, off, pvBuf, cbWrite);
     159    int rc = pThis->pDrvMedia->pfnWrite(pThis->pDrvMedia, off, pvBuf, cbWrite);
    160160#ifdef VBOX_PERIODIC_FLUSH
    161     if (pData->cbFlushInterval)
    162     {
    163         pData->cbDataWritten += cbWrite;
    164         if (pData->cbDataWritten > pData->cbFlushInterval)
     161    if (pThis->cbFlushInterval)
     162    {
     163        pThis->cbDataWritten += cbWrite;
     164        if (pThis->cbDataWritten > pThis->cbFlushInterval)
    165165        {
    166             pData->cbDataWritten = 0;
    167             pData->pDrvMedia->pfnFlush(pData->pDrvMedia);
     166            pThis->cbDataWritten = 0;
     167            pThis->pDrvMedia->pfnFlush(pThis->pDrvMedia);
    168168        }
    169169    }
     
    177177static DECLCALLBACK(int) drvblockFlush(PPDMIBLOCK pInterface)
    178178{
    179     PDRVBLOCK pData = PDMIBLOCK_2_DRVBLOCK(pInterface);
    180 
    181     /*
    182      * Check the state.
    183      */
    184     if (!pData->pDrvMedia)
     179    PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
     180
     181    /*
     182     * Check the state.
     183     */
     184    if (!pThis->pDrvMedia)
    185185    {
    186186        AssertMsgFailed(("Invalid state! Not mounted!\n"));
     
    189189
    190190#ifdef VBOX_IGNORE_FLUSH
    191     if (pData->fIgnoreFlush)
     191    if (pThis->fIgnoreFlush)
    192192        return VINF_SUCCESS;
    193193#endif /* VBOX_IGNORE_FLUSH */
    194194
    195     int rc = pData->pDrvMedia->pfnFlush(pData->pDrvMedia);
     195    int rc = pThis->pDrvMedia->pfnFlush(pThis->pDrvMedia);
    196196    if (rc == VERR_NOT_IMPLEMENTED)
    197197        rc = VINF_SUCCESS;
     
    203203static DECLCALLBACK(bool) drvblockIsReadOnly(PPDMIBLOCK pInterface)
    204204{
    205     PDRVBLOCK pData = PDMIBLOCK_2_DRVBLOCK(pInterface);
    206 
    207     /*
    208      * Check the state.
    209      */
    210     if (!pData->pDrvMedia)
     205    PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
     206
     207    /*
     208     * Check the state.
     209     */
     210    if (!pThis->pDrvMedia)
    211211        return false;
    212212
    213     bool fRc = pData->pDrvMedia->pfnIsReadOnly(pData->pDrvMedia);
     213    bool fRc = pThis->pDrvMedia->pfnIsReadOnly(pThis->pDrvMedia);
    214214    return fRc;
    215215}
     
    219219static DECLCALLBACK(uint64_t) drvblockGetSize(PPDMIBLOCK pInterface)
    220220{
    221     PDRVBLOCK pData = PDMIBLOCK_2_DRVBLOCK(pInterface);
    222 
    223     /*
    224      * Check the state.
    225      */
    226     if (!pData->pDrvMedia)
     221    PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
     222
     223    /*
     224     * Check the state.
     225     */
     226    if (!pThis->pDrvMedia)
    227227        return 0;
    228228
    229     uint64_t cb = pData->pDrvMedia->pfnGetSize(pData->pDrvMedia);
     229    uint64_t cb = pThis->pDrvMedia->pfnGetSize(pThis->pDrvMedia);
    230230    LogFlow(("drvblockGetSize: returns %llu\n", cb));
    231231    return cb;
     
    236236static DECLCALLBACK(PDMBLOCKTYPE) drvblockGetType(PPDMIBLOCK pInterface)
    237237{
    238     PDRVBLOCK pData = PDMIBLOCK_2_DRVBLOCK(pInterface);
    239     LogFlow(("drvblockGetType: returns %d\n", pData->enmType));
    240     return pData->enmType;
     238    PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
     239    LogFlow(("drvblockGetType: returns %d\n", pThis->enmType));
     240    return pThis->enmType;
    241241}
    242242
     
    245245static DECLCALLBACK(int) drvblockGetUuid(PPDMIBLOCK pInterface, PRTUUID pUuid)
    246246{
    247     PDRVBLOCK pData = PDMIBLOCK_2_DRVBLOCK(pInterface);
     247    PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
    248248
    249249    /*
    250250     * Copy the uuid.
    251251     */
    252     *pUuid = pData->Uuid;
     252    *pUuid = pThis->Uuid;
    253253    return VINF_SUCCESS;
    254254}
     
    262262static DECLCALLBACK(int) drvblockAsyncReadStart(PPDMIBLOCKASYNC pInterface, uint64_t off, PPDMDATASEG pSeg, unsigned cSeg, size_t cbRead, void *pvUser)
    263263{
    264     PDRVBLOCK pData = PDMIBLOCKASYNC_2_DRVBLOCK(pInterface);
    265 
    266     /*
    267      * Check the state.
    268      */
    269     if (!pData->pDrvMediaAsync)
     264    PDRVBLOCK pThis = PDMIBLOCKASYNC_2_DRVBLOCK(pInterface);
     265
     266    /*
     267     * Check the state.
     268     */
     269    if (!pThis->pDrvMediaAsync)
    270270    {
    271271        AssertMsgFailed(("Invalid state! Not mounted!\n"));
     
    273273    }
    274274
    275     int rc = pData->pDrvMediaAsync->pfnStartRead(pData->pDrvMediaAsync, off, pSeg, cSeg, cbRead, pvUser);
     275    int rc = pThis->pDrvMediaAsync->pfnStartRead(pThis->pDrvMediaAsync, off, pSeg, cSeg, cbRead, pvUser);
    276276    return rc;
    277277}
     
    281281static DECLCALLBACK(int) drvblockAsyncWriteStart(PPDMIBLOCKASYNC pInterface, uint64_t off, PPDMDATASEG pSeg, unsigned cSeg, size_t cbWrite, void *pvUser)
    282282{
    283     PDRVBLOCK pData = PDMIBLOCKASYNC_2_DRVBLOCK(pInterface);
    284 
    285     /*
    286      * Check the state.
    287      */
    288     if (!pData->pDrvMediaAsync)
     283    PDRVBLOCK pThis = PDMIBLOCKASYNC_2_DRVBLOCK(pInterface);
     284
     285    /*
     286     * Check the state.
     287     */
     288    if (!pThis->pDrvMediaAsync)
    289289    {
    290290        AssertMsgFailed(("Invalid state! Not mounted!\n"));
     
    292292    }
    293293
    294     int rc = pData->pDrvMediaAsync->pfnStartWrite(pData->pDrvMediaAsync, off, pSeg, cSeg, cbWrite, pvUser);
     294    int rc = pThis->pDrvMediaAsync->pfnStartWrite(pThis->pDrvMediaAsync, off, pSeg, cSeg, cbWrite, pvUser);
    295295
    296296    return rc;
     
    304304static DECLCALLBACK(int) drvblockAsyncTransferCompleteNotify(PPDMIMEDIAASYNCPORT pInterface, void *pvUser)
    305305{
    306     PDRVBLOCK pData = PDMIMEDIAASYNCPORT_2_DRVBLOCK(pInterface);
    307 
    308     return pData->pDrvBlockAsyncPort->pfnTransferCompleteNotify(pData->pDrvBlockAsyncPort, pvUser);
     306    PDRVBLOCK pThis = PDMIMEDIAASYNCPORT_2_DRVBLOCK(pInterface);
     307
     308    return pThis->pDrvBlockAsyncPort->pfnTransferCompleteNotify(pThis->pDrvBlockAsyncPort, pvUser);
    309309}
    310310
     
    318318static DECLCALLBACK(int) drvblockGetPCHSGeometry(PPDMIBLOCKBIOS pInterface, PPDMMEDIAGEOMETRY pPCHSGeometry)
    319319{
    320     PDRVBLOCK pData = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
    321 
    322     /*
    323      * Check the state.
    324      */
    325     if (!pData->pDrvMedia)
     320    PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
     321
     322    /*
     323     * Check the state.
     324     */
     325    if (!pThis->pDrvMedia)
    326326        return VERR_PDM_MEDIA_NOT_MOUNTED;
    327327
     
    329329     * Use configured/cached values if present.
    330330     */
    331     if (    pData->PCHSGeometry.cCylinders > 0
    332         &&  pData->PCHSGeometry.cHeads > 0
    333         &&  pData->PCHSGeometry.cSectors > 0)
    334     {
    335         *pPCHSGeometry = pData->PCHSGeometry;
    336         LogFlow(("%s: returns VINF_SUCCESS {%d,%d,%d}\n", __FUNCTION__, pData->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));
    337337        return VINF_SUCCESS;
    338338    }
     
    341341     * Call media.
    342342     */
    343     int rc = pData->pDrvMedia->pfnBiosGetPCHSGeometry(pData->pDrvMedia, &pData->PCHSGeometry);
     343    int rc = pThis->pDrvMedia->pfnBiosGetPCHSGeometry(pThis->pDrvMedia, &pThis->PCHSGeometry);
    344344
    345345    if (RT_SUCCESS(rc))
    346346    {
    347         *pPCHSGeometry = pData->PCHSGeometry;
    348         LogFlow(("%s: returns %Vrc {%d,%d,%d}\n", __FUNCTION__, rc, pData->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));
    349349    }
    350350    else if (rc == VERR_NOT_IMPLEMENTED)
     
    361361{
    362362    LogFlow(("%s: cCylinders=%d cHeads=%d cSectors=%d\n", __FUNCTION__, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
    363     PDRVBLOCK pData = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
    364 
    365     /*
    366      * Check the state.
    367      */
    368     if (!pData->pDrvMedia)
     363    PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
     364
     365    /*
     366     * Check the state.
     367     */
     368    if (!pThis->pDrvMedia)
    369369    {
    370370        AssertMsgFailed(("Invalid state! Not mounted!\n"));
     
    375375     * Call media. Ignore the not implemented return code.
    376376     */
    377     int rc = pData->pDrvMedia->pfnBiosSetPCHSGeometry(pData->pDrvMedia, pPCHSGeometry);
     377    int rc = pThis->pDrvMedia->pfnBiosSetPCHSGeometry(pThis->pDrvMedia, pPCHSGeometry);
    378378
    379379    if (    RT_SUCCESS(rc)
    380380        ||  rc == VERR_NOT_IMPLEMENTED)
    381381    {
    382         pData->PCHSGeometry = *pPCHSGeometry;
     382        pThis->PCHSGeometry = *pPCHSGeometry;
    383383        rc = VINF_SUCCESS;
    384384    }
     
    390390static DECLCALLBACK(int) drvblockGetLCHSGeometry(PPDMIBLOCKBIOS pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry)
    391391{
    392     PDRVBLOCK pData = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
    393 
    394     /*
    395      * Check the state.
    396      */
    397     if (!pData->pDrvMedia)
     392    PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
     393
     394    /*
     395     * Check the state.
     396     */
     397    if (!pThis->pDrvMedia)
    398398        return VERR_PDM_MEDIA_NOT_MOUNTED;
    399399
     
    401401     * Use configured/cached values if present.
    402402     */
    403     if (    pData->LCHSGeometry.cCylinders > 0
    404         &&  pData->LCHSGeometry.cHeads > 0
    405         &&  pData->LCHSGeometry.cSectors > 0)
    406     {
    407         *pLCHSGeometry = pData->LCHSGeometry;
    408         LogFlow(("%s: returns VINF_SUCCESS {%d,%d,%d}\n", __FUNCTION__, pData->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));
    409409        return VINF_SUCCESS;
    410410    }
     
    413413     * Call media.
    414414     */
    415     int rc = pData->pDrvMedia->pfnBiosGetLCHSGeometry(pData->pDrvMedia, &pData->LCHSGeometry);
     415    int rc = pThis->pDrvMedia->pfnBiosGetLCHSGeometry(pThis->pDrvMedia, &pThis->LCHSGeometry);
    416416
    417417    if (RT_SUCCESS(rc))
    418418    {
    419         *pLCHSGeometry = pData->LCHSGeometry;
    420         LogFlow(("%s: returns %Vrc {%d,%d,%d}\n", __FUNCTION__, rc, pData->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));
    421421    }
    422422    else if (rc == VERR_NOT_IMPLEMENTED)
     
    433433{
    434434    LogFlow(("%s: cCylinders=%d cHeads=%d cSectors=%d\n", __FUNCTION__, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
    435     PDRVBLOCK pData = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
    436 
    437     /*
    438      * Check the state.
    439      */
    440     if (!pData->pDrvMedia)
     435    PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
     436
     437    /*
     438     * Check the state.
     439     */
     440    if (!pThis->pDrvMedia)
    441441    {
    442442        AssertMsgFailed(("Invalid state! Not mounted!\n"));
     
    447447     * Call media. Ignore the not implemented return code.
    448448     */
    449     int rc = pData->pDrvMedia->pfnBiosSetLCHSGeometry(pData->pDrvMedia, pLCHSGeometry);
     449    int rc = pThis->pDrvMedia->pfnBiosSetLCHSGeometry(pThis->pDrvMedia, pLCHSGeometry);
    450450
    451451    if (    RT_SUCCESS(rc)
    452452        ||  rc == VERR_NOT_IMPLEMENTED)
    453453    {
    454         pData->LCHSGeometry = *pLCHSGeometry;
     454        pThis->LCHSGeometry = *pLCHSGeometry;
    455455        rc = VINF_SUCCESS;
    456456    }
     
    462462static DECLCALLBACK(bool) drvblockIsVisible(PPDMIBLOCKBIOS pInterface)
    463463{
    464     PDRVBLOCK pData = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
    465     LogFlow(("drvblockIsVisible: returns %d\n", pData->fBiosVisible));
    466     return pData->fBiosVisible;
     464    PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
     465    LogFlow(("drvblockIsVisible: returns %d\n", pThis->fBiosVisible));
     466    return pThis->fBiosVisible;
    467467}
    468468
     
    471471static DECLCALLBACK(PDMBLOCKTYPE) drvblockBiosGetType(PPDMIBLOCKBIOS pInterface)
    472472{
    473     PDRVBLOCK pData = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
    474     LogFlow(("drvblockBiosGetType: returns %d\n", pData->enmType));
    475     return pData->enmType;
     473    PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
     474    LogFlow(("drvblockBiosGetType: returns %d\n", pThis->enmType));
     475    return pThis->enmType;
    476476}
    477477
     
    488488{
    489489    LogFlow(("drvblockMount: pszFilename=%p:{%s} pszCoreDriver=%p:{%s}\n", pszFilename, pszFilename, pszCoreDriver, pszCoreDriver));
    490     PDRVBLOCK pData = PDMIMOUNT_2_DRVBLOCK(pInterface);
     490    PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
    491491
    492492    /*
    493493     * Validate state.
    494494     */
    495     if (pData->pDrvMedia)
     495    if (pThis->pDrvMedia)
    496496    {
    497497        AssertMsgFailed(("Already mounted\n"));
     
    504504    if (pszFilename)
    505505    {
    506         int rc = pData->pDrvIns->pDrvHlp->pfnMountPrepare(pData->pDrvIns, pszFilename, pszCoreDriver);
     506        int rc = pThis->pDrvIns->pDrvHlp->pfnMountPrepare(pThis->pDrvIns, pszFilename, pszCoreDriver);
    507507        if (RT_FAILURE(rc))
    508508        {
     
    516516     */
    517517    PPDMIBASE pBase;
    518     int rc = pData->pDrvIns->pDrvHlp->pfnAttach(pData->pDrvIns, &pBase);
     518    int rc = pThis->pDrvIns->pDrvHlp->pfnAttach(pThis->pDrvIns, &pBase);
    519519    if (RT_FAILURE(rc))
    520520    {
     
    523523    }
    524524
    525     pData->pDrvMedia = (PPDMIMEDIA)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA);
    526     if (pData->pDrvMedia)
     525    pThis->pDrvMedia = (PPDMIMEDIA)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA);
     526    if (pThis->pDrvMedia)
    527527    {
    528528        /*
    529529         * Initialize state.
    530530         */
    531         pData->fLocked = false;
    532         pData->PCHSGeometry.cCylinders  = 0;
    533         pData->PCHSGeometry.cHeads      = 0;
    534         pData->PCHSGeometry.cSectors    = 0;
    535         pData->LCHSGeometry.cCylinders  = 0;
    536         pData->LCHSGeometry.cHeads      = 0;
    537         pData->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;
    538538#ifdef VBOX_PERIODIC_FLUSH
    539         pData->cbDataWritten = 0;
     539        pThis->cbDataWritten = 0;
    540540#endif /* VBOX_PERIODIC_FLUSH */
    541541
     
    543543         * Notify driver/device above us.
    544544         */
    545         if (pData->pDrvMountNotify)
    546             pData->pDrvMountNotify->pfnMountNotify(pData->pDrvMountNotify);
     545        if (pThis->pDrvMountNotify)
     546            pThis->pDrvMountNotify->pfnMountNotify(pThis->pDrvMountNotify);
    547547        Log(("drvblockMount: Success\n"));
    548548        return VINF_SUCCESS;
     
    555555     */
    556556    AssertMsgFailed(("No media interface!\n"));
    557     int rc2 = pData->pDrvIns->pDrvHlp->pfnDetach(pData->pDrvIns);
     557    int rc2 = pThis->pDrvIns->pDrvHlp->pfnDetach(pThis->pDrvIns);
    558558    AssertRC(rc2);
    559     pData->pDrvMedia = NULL;
     559    pThis->pDrvMedia = NULL;
    560560    return rc;
    561561}
     
    565565static DECLCALLBACK(int) drvblockUnmount(PPDMIMOUNT pInterface, bool fForce)
    566566{
    567     PDRVBLOCK pData = PDMIMOUNT_2_DRVBLOCK(pInterface);
     567    PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
    568568
    569569    /*
    570570     * Validate state.
    571571     */
    572     if (!pData->pDrvMedia)
     572    if (!pThis->pDrvMedia)
    573573    {
    574574        Log(("drvblockUmount: Not mounted\n"));
    575575        return VERR_PDM_MEDIA_NOT_MOUNTED;
    576576    }
    577     if (pData->fLocked && !fForce)
     577    if (pThis->fLocked && !fForce)
    578578    {
    579579        Log(("drvblockUmount: Locked\n"));
     
    582582
    583583    /* Media is no longer locked even if it was previously. */
    584     pData->fLocked = false;
     584    pThis->fLocked = false;
    585585
    586586    /*
    587587     * Detach the media driver and query it's interface.
    588588     */
    589     int rc = pData->pDrvIns->pDrvHlp->pfnDetach(pData->pDrvIns);
     589    int rc = pThis->pDrvIns->pDrvHlp->pfnDetach(pThis->pDrvIns);
    590590    if (RT_FAILURE(rc))
    591591    {
     
    593593        return rc;
    594594    }
    595     Assert(!pData->pDrvMedia);
     595    Assert(!pThis->pDrvMedia);
    596596
    597597    /*
    598598     * Notify driver/device above us.
    599599     */
    600     if (pData->pDrvMountNotify)
    601         pData->pDrvMountNotify->pfnUnmountNotify(pData->pDrvMountNotify);
     600    if (pThis->pDrvMountNotify)
     601        pThis->pDrvMountNotify->pfnUnmountNotify(pThis->pDrvMountNotify);
    602602    Log(("drvblockUnmount: success\n"));
    603603    return VINF_SUCCESS;
     
    608608static DECLCALLBACK(bool) drvblockIsMounted(PPDMIMOUNT pInterface)
    609609{
    610     PDRVBLOCK pData = PDMIMOUNT_2_DRVBLOCK(pInterface);
    611     return pData->pDrvMedia != NULL;
     610    PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
     611    return pThis->pDrvMedia != NULL;
    612612}
    613613
     
    615615static DECLCALLBACK(int) drvblockLock(PPDMIMOUNT pInterface)
    616616{
    617     PDRVBLOCK pData = PDMIMOUNT_2_DRVBLOCK(pInterface);
    618     Log(("drvblockLock: %d -> %d\n", pData->fLocked, true));
    619     pData->fLocked = true;
     617    PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
     618    Log(("drvblockLock: %d -> %d\n", pThis->fLocked, true));
     619    pThis->fLocked = true;
    620620    return VINF_SUCCESS;
    621621}
     
    624624static DECLCALLBACK(int) drvblockUnlock(PPDMIMOUNT pInterface)
    625625{
    626     PDRVBLOCK pData = PDMIMOUNT_2_DRVBLOCK(pInterface);
    627     Log(("drvblockUnlock: %d -> %d\n", pData->fLocked, false));
    628     pData->fLocked = false;
     626    PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
     627    Log(("drvblockUnlock: %d -> %d\n", pThis->fLocked, false));
     628    pThis->fLocked = false;
    629629    return VINF_SUCCESS;
    630630}
     
    633633static DECLCALLBACK(bool) drvblockIsLocked(PPDMIMOUNT pInterface)
    634634{
    635     PDRVBLOCK pData = PDMIMOUNT_2_DRVBLOCK(pInterface);
    636     return pData->fLocked;
     635    PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
     636    return pThis->fLocked;
    637637}
    638638
     
    644644{
    645645    PPDMDRVINS  pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
    646     PDRVBLOCK   pData = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
     646    PDRVBLOCK   pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
    647647    switch (enmInterface)
    648648    {
     
    650650            return &pDrvIns->IBase;
    651651        case PDMINTERFACE_BLOCK:
    652             return &pData->IBlock;
     652            return &pThis->IBlock;
    653653        case PDMINTERFACE_BLOCK_BIOS:
    654             return pData->fBiosVisible ? &pData->IBlockBios : NULL;
     654            return pThis->fBiosVisible ? &pThis->IBlockBios : NULL;
    655655        case PDMINTERFACE_MOUNT:
    656             return pData->fMountable ? &pData->IMount : NULL;
     656            return pThis->fMountable ? &pThis->IMount : NULL;
    657657        case PDMINTERFACE_BLOCK_ASYNC:
    658             return pData->pDrvMediaAsync ? &pData->IBlockAsync : NULL;
     658            return pThis->pDrvMediaAsync ? &pThis->IBlockAsync : NULL;
    659659        case PDMINTERFACE_MEDIA_ASYNC_PORT:
    660             return pData->pDrvBlockAsyncPort ? &pData->IMediaAsyncPort : NULL;
     660            return pThis->pDrvBlockAsyncPort ? &pThis->IMediaAsyncPort : NULL;
    661661        default:
    662662            return NULL;
     
    670670static DECLCALLBACK(void)  drvblockDetach(PPDMDRVINS pDrvIns)
    671671{
    672     PDRVBLOCK pData = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
    673     pData->pDrvMedia = NULL;
    674     pData->pDrvMediaAsync = NULL;
     672    PDRVBLOCK pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
     673    pThis->pDrvMedia = NULL;
     674    pThis->pDrvMediaAsync = NULL;
    675675}
    676676
     
    683683static DECLCALLBACK(void)  drvblockReset(PPDMDRVINS pDrvIns)
    684684{
    685     PDRVBLOCK pData = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
    686 
    687     pData->fLocked = false;
     685    PDRVBLOCK pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
     686
     687    pThis->fLocked = false;
    688688}
    689689
     
    700700static DECLCALLBACK(int) drvblockConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
    701701{
    702     PDRVBLOCK pData = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
     702    PDRVBLOCK pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
    703703    LogFlow(("drvblockConstruct: iInstance=%d\n", pDrvIns->iInstance));
    704704
     
    716716     * Initialize most of the data members.
    717717     */
    718     pData->pDrvIns                          = pDrvIns;
     718    pThis->pDrvIns                          = pDrvIns;
    719719
    720720    /* IBase. */
     
    722722
    723723    /* IBlock. */
    724     pData->IBlock.pfnRead                   = drvblockRead;
    725     pData->IBlock.pfnWrite                  = drvblockWrite;
    726     pData->IBlock.pfnFlush                  = drvblockFlush;
    727     pData->IBlock.pfnIsReadOnly             = drvblockIsReadOnly;
    728     pData->IBlock.pfnGetSize                = drvblockGetSize;
    729     pData->IBlock.pfnGetType                = drvblockGetType;
    730     pData->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;
    731731
    732732    /* IBlockBios. */
    733     pData->IBlockBios.pfnGetPCHSGeometry    = drvblockGetPCHSGeometry;
    734     pData->IBlockBios.pfnSetPCHSGeometry    = drvblockSetPCHSGeometry;
    735     pData->IBlockBios.pfnGetLCHSGeometry    = drvblockGetLCHSGeometry;
    736     pData->IBlockBios.pfnSetLCHSGeometry    = drvblockSetLCHSGeometry;
    737     pData->IBlockBios.pfnIsVisible          = drvblockIsVisible;
    738     pData->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;
    739739
    740740    /* IMount. */
    741     pData->IMount.pfnMount                  = drvblockMount;
    742     pData->IMount.pfnUnmount                = drvblockUnmount;
    743     pData->IMount.pfnIsMounted              = drvblockIsMounted;
    744     pData->IMount.pfnLock                   = drvblockLock;
    745     pData->IMount.pfnUnlock                 = drvblockUnlock;
    746     pData->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;
    747747
    748748    /* IBlockAsync. */
    749     pData->IBlockAsync.pfnStartRead         = drvblockAsyncReadStart;
    750     pData->IBlockAsync.pfnStartWrite        = drvblockAsyncWriteStart;
     749    pThis->IBlockAsync.pfnStartRead         = drvblockAsyncReadStart;
     750    pThis->IBlockAsync.pfnStartWrite        = drvblockAsyncWriteStart;
    751751
    752752    /* IMediaAsyncPort. */
    753     pData->IMediaAsyncPort.pfnTransferCompleteNotify  = drvblockAsyncTransferCompleteNotify;
     753    pThis->IMediaAsyncPort.pfnTransferCompleteNotify  = drvblockAsyncTransferCompleteNotify;
    754754
    755755    /*
    756756     * Get the IBlockPort & IMountNotify interfaces of the above driver/device.
    757757     */
    758     pData->pDrvBlockPort = (PPDMIBLOCKPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_BLOCK_PORT);
    759     if (!pData->pDrvBlockPort)
     758    pThis->pDrvBlockPort = (PPDMIBLOCKPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_BLOCK_PORT);
     759    if (!pThis->pDrvBlockPort)
    760760        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
    761761                                N_("No block port interface above"));
    762762
    763763    /* Try to get the optional async block port interface above. */
    764     pData->pDrvBlockAsyncPort = (PPDMIBLOCKASYNCPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_BLOCK_ASYNC_PORT);
    765 
    766     pData->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);
    767767
    768768    /*
     
    775775        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_BLOCK_NO_TYPE, N_("Failed to obtain the type"));
    776776    if (!strcmp(psz, "HardDisk"))
    777         pData->enmType = PDMBLOCKTYPE_HARD_DISK;
     777        pThis->enmType = PDMBLOCKTYPE_HARD_DISK;
    778778    else if (!strcmp(psz, "DVD"))
    779         pData->enmType = PDMBLOCKTYPE_DVD;
     779        pThis->enmType = PDMBLOCKTYPE_DVD;
    780780    else if (!strcmp(psz, "CDROM"))
    781         pData->enmType = PDMBLOCKTYPE_CDROM;
     781        pThis->enmType = PDMBLOCKTYPE_CDROM;
    782782    else if (!strcmp(psz, "Floppy 2.88"))
    783         pData->enmType = PDMBLOCKTYPE_FLOPPY_2_88;
     783        pThis->enmType = PDMBLOCKTYPE_FLOPPY_2_88;
    784784    else if (!strcmp(psz, "Floppy 1.44"))
    785         pData->enmType = PDMBLOCKTYPE_FLOPPY_1_44;
     785        pThis->enmType = PDMBLOCKTYPE_FLOPPY_1_44;
    786786    else if (!strcmp(psz, "Floppy 1.20"))
    787         pData->enmType = PDMBLOCKTYPE_FLOPPY_1_20;
     787        pThis->enmType = PDMBLOCKTYPE_FLOPPY_1_20;
    788788    else if (!strcmp(psz, "Floppy 720"))
    789         pData->enmType = PDMBLOCKTYPE_FLOPPY_720;
     789        pThis->enmType = PDMBLOCKTYPE_FLOPPY_720;
    790790    else if (!strcmp(psz, "Floppy 360"))
    791         pData->enmType = PDMBLOCKTYPE_FLOPPY_360;
     791        pThis->enmType = PDMBLOCKTYPE_FLOPPY_360;
    792792    else
    793793    {
     
    797797        return VERR_PDM_BLOCK_UNKNOWN_TYPE;
    798798    }
    799     Log2(("drvblockConstruct: enmType=%d\n", pData->enmType));
     799    Log2(("drvblockConstruct: enmType=%d\n", pThis->enmType));
    800800    MMR3HeapFree(psz); psz = NULL;
    801801
    802802    /* Mountable */
    803     rc = CFGMR3QueryBoolDef(pCfgHandle, "Mountable", &pData->fMountable, false);
     803    rc = CFGMR3QueryBoolDef(pCfgHandle, "Mountable", &pThis->fMountable, false);
    804804    if (RT_FAILURE(rc))
    805805        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Mountable\" from the config"));
    806806
    807807    /* Locked */
    808     rc = CFGMR3QueryBoolDef(pCfgHandle, "Locked", &pData->fLocked, false);
     808    rc = CFGMR3QueryBoolDef(pCfgHandle, "Locked", &pThis->fLocked, false);
    809809    if (RT_FAILURE(rc))
    810810        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Locked\" from the config"));
    811811
    812812    /* BIOS visible */
    813     rc = CFGMR3QueryBoolDef(pCfgHandle, "BIOSVisible", &pData->fBiosVisible, true);
     813    rc = CFGMR3QueryBoolDef(pCfgHandle, "BIOSVisible", &pThis->fBiosVisible, true);
    814814    if (RT_FAILURE(rc))
    815815        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"BIOSVisible\" from the config"));
     
    818818
    819819    /* Cylinders */
    820     rc = CFGMR3QueryU32Def(pCfgHandle, "Cylinders", &pData->LCHSGeometry.cCylinders, 0);
     820    rc = CFGMR3QueryU32Def(pCfgHandle, "Cylinders", &pThis->LCHSGeometry.cCylinders, 0);
    821821    if (RT_FAILURE(rc))
    822822        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Cylinders\" from the config"));
    823823
    824824    /* Heads */
    825     rc = CFGMR3QueryU32Def(pCfgHandle, "Heads", &pData->LCHSGeometry.cHeads, 0);
     825    rc = CFGMR3QueryU32Def(pCfgHandle, "Heads", &pThis->LCHSGeometry.cHeads, 0);
    826826    if (RT_FAILURE(rc))
    827827        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Heads\" from the config"));
    828828
    829829    /* Sectors */
    830     rc = CFGMR3QueryU32Def(pCfgHandle, "Sectors", &pData->LCHSGeometry.cSectors, 0);
     830    rc = CFGMR3QueryU32Def(pCfgHandle, "Sectors", &pThis->LCHSGeometry.cSectors, 0);
    831831    if (RT_FAILURE(rc))
    832832        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Sectors\" from the config"));
     
    835835    rc = CFGMR3QueryStringAlloc(pCfgHandle, "Uuid", &psz);
    836836    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    837         RTUuidClear(&pData->Uuid);
     837        RTUuidClear(&pThis->Uuid);
    838838    else if (RT_SUCCESS(rc))
    839839    {
    840         rc = RTUuidFromStr(&pData->Uuid, psz);
     840        rc = RTUuidFromStr(&pThis->Uuid, psz);
    841841        if (RT_FAILURE(rc))
    842842        {
     
    852852
    853853#ifdef VBOX_PERIODIC_FLUSH
    854     rc = CFGMR3QueryU32Def(pCfgHandle, "FlushInterval", &pData->cbFlushInterval, 0);
     854    rc = CFGMR3QueryU32Def(pCfgHandle, "FlushInterval", &pThis->cbFlushInterval, 0);
    855855    if (RT_FAILURE(rc))
    856856        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"FlushInterval\" from the config"));
     
    858858
    859859#ifdef VBOX_IGNORE_FLUSH
    860     rc = CFGMR3QueryBoolDef(pCfgHandle, "IgnoreFlush", &pData->fIgnoreFlush, true);
     860    rc = CFGMR3QueryBoolDef(pCfgHandle, "IgnoreFlush", &pThis->fIgnoreFlush, true);
    861861    if (RT_FAILURE(rc))
    862862        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"IgnoreFlush\" from the config"));
     
    869869    rc = pDrvIns->pDrvHlp->pfnAttach(pDrvIns, &pBase);
    870870    if (    rc == VERR_PDM_NO_ATTACHED_DRIVER
    871         &&  pData->enmType != PDMBLOCKTYPE_HARD_DISK)
     871        &&  pThis->enmType != PDMBLOCKTYPE_HARD_DISK)
    872872        return VINF_SUCCESS;
    873873    if (RT_FAILURE(rc))
     
    876876        return rc;
    877877    }
    878     pData->pDrvMedia = (PPDMIMEDIA)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA);
    879     if (!pData->pDrvMedia)
     878    pThis->pDrvMedia = (PPDMIMEDIA)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA);
     879    if (!pThis->pDrvMedia)
    880880        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_BELOW,
    881881                                N_("No media or async media interface below"));
    882882
    883883    /* Try to get the optional async interface. */
    884     pData->pDrvMediaAsync = (PPDMIMEDIAASYNC)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA_ASYNC);
    885 
    886     if (RTUuidIsNull(&pData->Uuid))
    887     {
    888         if (pData->enmType == PDMBLOCKTYPE_HARD_DISK)
    889             pData->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);
    890890    }
    891891
  • trunk/src/VBox/Devices/Storage/DrvMediaISO.cpp

    r11267 r11269  
    9999static DECLCALLBACK(int) drvMediaISOConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
    100100{
    101     PDRVMEDIAISO pData = PDMINS_2_DATA(pDrvIns, PDRVMEDIAISO);
     101    PDRVMEDIAISO pThis = PDMINS_2_DATA(pDrvIns, PDRVMEDIAISO);
    102102
    103103    /*
    104104     * Init the static parts.
    105105     */
    106     pData->pDrvIns                      = pDrvIns;
    107     pData->File                         = NIL_RTFILE;
     106    pThis->pDrvIns                      = pDrvIns;
     107    pThis->File                         = NIL_RTFILE;
    108108    /* IBase */
    109109    pDrvIns->IBase.pfnQueryInterface    = drvMediaISOQueryInterface;
    110110    /* IMedia */
    111     pData->IMedia.pfnRead               = drvMediaISORead;
    112     pData->IMedia.pfnWrite              = drvMediaISOWrite;
    113     pData->IMedia.pfnFlush              = drvMediaISOFlush;
    114     pData->IMedia.pfnGetSize            = drvMediaISOGetSize;
    115     pData->IMedia.pfnGetUuid            = drvMediaISOGetUuid;
    116     pData->IMedia.pfnIsReadOnly         = drvMediaISOIsReadOnly;
    117     pData->IMedia.pfnBiosGetPCHSGeometry = drvMediaISOBiosGetPCHSGeometry;
    118     pData->IMedia.pfnBiosSetPCHSGeometry = drvMediaISOBiosSetPCHSGeometry;
    119     pData->IMedia.pfnBiosGetLCHSGeometry = drvMediaISOBiosGetLCHSGeometry;
    120     pData->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;
    121121
    122122    /*
     
    134134     * Open the image.
    135135     */
    136     rc = RTFileOpen(&pData->File, pszName,
     136    rc = RTFileOpen(&pThis->File, pszName,
    137137                    RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    138138    if (RT_SUCCESS(rc))
    139139    {
    140140        LogFlow(("drvMediaISOConstruct: ISO image '%s' opened successfully.\n", pszName));
    141         pData->pszFilename = pszName;
     141        pThis->pszFilename = pszName;
    142142    }
    143143    else
     
    161161static DECLCALLBACK(void) drvMediaISODestruct(PPDMDRVINS pDrvIns)
    162162{
    163     PDRVMEDIAISO pData = PDMINS_2_DATA(pDrvIns, PDRVMEDIAISO);
    164     LogFlow(("drvMediaISODestruct: '%s'\n", pData->pszFilename));
    165 
    166     if (pData->File != NIL_RTFILE)
    167     {
    168         RTFileClose(pData->File);
    169         pData->File = NIL_RTFILE;
    170     }
    171     if (pData->pszFilename)
    172         MMR3HeapFree(pData->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);
    173173}
    174174
     
    177177static DECLCALLBACK(uint64_t) drvMediaISOGetSize(PPDMIMEDIA pInterface)
    178178{
    179     PDRVMEDIAISO pData = PDMIMEDIA_2_DRVMEDIAISO(pInterface);
    180     LogFlow(("drvMediaISOGetSize: '%s'\n", pData->pszFilename));
     179    PDRVMEDIAISO pThis = PDMIMEDIA_2_DRVMEDIAISO(pInterface);
     180    LogFlow(("drvMediaISOGetSize: '%s'\n", pThis->pszFilename));
    181181
    182182    uint64_t cbFile;
    183     int rc = RTFileGetSize(pData->File, &cbFile);
     183    int rc = RTFileGetSize(pThis->File, &cbFile);
    184184    if (RT_SUCCESS(rc))
    185185    {
    186         LogFlow(("drvMediaISOGetSize: returns %lld (%s)\n", cbFile, pData->pszFilename));
     186        LogFlow(("drvMediaISOGetSize: returns %lld (%s)\n", cbFile, pThis->pszFilename));
    187187        return cbFile;
    188188    }
    189189
    190     AssertMsgFailed(("Error querying ISO file size, rc=%Vrc. (%s)\n", rc, pData->pszFilename));
     190    AssertMsgFailed(("Error querying ISO file size, rc=%Vrc. (%s)\n", rc, pThis->pszFilename));
    191191    return 0;
    192192}
     
    228228static DECLCALLBACK(int) drvMediaISORead(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead)
    229229{
    230     PDRVMEDIAISO pData = PDMIMEDIA_2_DRVMEDIAISO(pInterface);
    231     LogFlow(("drvMediaISORead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", off, pvBuf, cbRead, pData->pszFilename));
    232 
    233     Assert(pData->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);
    234234    Assert(pvBuf);
    235235
     
    237237     * Seek to the position and read.
    238238     */
    239     int rc = RTFileSeek(pData->File, off, RTFILE_SEEK_BEGIN, NULL);
     239    int rc = RTFileSeek(pThis->File, off, RTFILE_SEEK_BEGIN, NULL);
    240240    if (RT_SUCCESS(rc))
    241241    {
    242         rc = RTFileRead(pData->File, pvBuf, cbRead, NULL);
     242        rc = RTFileRead(pThis->File, pvBuf, cbRead, NULL);
    243243        if (RT_SUCCESS(rc))
    244244        {
    245245            Log2(("drvMediaISORead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n"
    246246                  "%16.*Vhxd\n",
    247                   off, pvBuf, cbRead, pData->pszFilename,
     247                  off, pvBuf, cbRead, pThis->pszFilename,
    248248                  cbRead, pvBuf));
    249249        }
    250250        else
    251251            AssertMsgFailed(("RTFileRead(%d, %p, %#x) -> %Vrc (off=%#llx '%s')\n",
    252                              pData->File, pvBuf, cbRead, rc, off, pData->pszFilename));
     252                             pThis->File, pvBuf, cbRead, rc, off, pThis->pszFilename));
    253253    }
    254254    else
    255         AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", pData->File, off, rc));
     255        AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", pThis->File, off, rc));
    256256    LogFlow(("drvMediaISORead: returns %Vrc\n", rc));
    257257    return rc;
     
    302302{
    303303    PPDMDRVINS pDrvIns = PDMIBASE_2_DRVINS(pInterface);
    304     PDRVMEDIAISO pData = PDMINS_2_DATA(pDrvIns, PDRVMEDIAISO);
     304    PDRVMEDIAISO pThis = PDMINS_2_DATA(pDrvIns, PDRVMEDIAISO);
    305305    switch (enmInterface)
    306306    {
     
    308308            return &pDrvIns->IBase;
    309309        case PDMINTERFACE_MEDIA:
    310             return &pData->IMedia;
     310            return &pThis->IMedia;
    311311        default:
    312312            return NULL;
  • trunk/src/VBox/Devices/Storage/DrvRawImage.cpp

    r11267 r11269  
    102102static DECLCALLBACK(int) drvRawImageConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
    103103{
    104     PDRVRAWIMAGE pData = PDMINS_2_DATA(pDrvIns, PDRVRAWIMAGE);
     104    PDRVRAWIMAGE pThis = PDMINS_2_DATA(pDrvIns, PDRVRAWIMAGE);
    105105
    106106    /*
    107107     * Init the static parts.
    108108     */
    109     pData->pDrvIns                      = pDrvIns;
    110     pData->File                         = NIL_RTFILE;
     109    pThis->pDrvIns                      = pDrvIns;
     110    pThis->File                         = NIL_RTFILE;
    111111    /* IBase */
    112112    pDrvIns->IBase.pfnQueryInterface    = drvRawImageQueryInterface;
    113113    /* IMedia */
    114     pData->IMedia.pfnRead               = drvRawImageRead;
    115     pData->IMedia.pfnWrite              = drvRawImageWrite;
    116     pData->IMedia.pfnFlush              = drvRawImageFlush;
    117     pData->IMedia.pfnGetSize            = drvRawImageGetSize;
    118     pData->IMedia.pfnGetUuid            = drvRawImageGetUuid;
    119     pData->IMedia.pfnIsReadOnly         = drvRawImageIsReadOnly;
    120     pData->IMedia.pfnBiosGetPCHSGeometry = drvRawImageBiosGetPCHSGeometry;
    121     pData->IMedia.pfnBiosSetPCHSGeometry = drvRawImageBiosSetPCHSGeometry;
    122     pData->IMedia.pfnBiosGetLCHSGeometry = drvRawImageBiosGetLCHSGeometry;
    123     pData->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;
    124124
    125125    /*
     
    140140     * Open the image.
    141141     */
    142     rc = RTFileOpen(&pData->File, pszName,
     142    rc = RTFileOpen(&pThis->File, pszName,
    143143                    RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    144144    if (RT_SUCCESS(rc))
    145145    {
    146146        LogFlow(("drvRawImageConstruct: Raw image '%s' opened successfully.\n", pszName));
    147         pData->pszFilename = pszName;
    148         pData->fReadOnly = false;
     147        pThis->pszFilename = pszName;
     148        pThis->fReadOnly = false;
    149149    }
    150150    else
    151151    {
    152         rc = RTFileOpen(&pData->File, pszName,
     152        rc = RTFileOpen(&pThis->File, pszName,
    153153                        RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    154154        if (RT_SUCCESS(rc))
    155155        {
    156156            LogFlow(("drvRawImageConstruct: Raw image '%s' opened successfully.\n", pszName));
    157             pData->pszFilename = pszName;
    158             pData->fReadOnly = true;
     157            pThis->pszFilename = pszName;
     158            pThis->fReadOnly = true;
    159159        }
    160160        else
     
    179179static DECLCALLBACK(void) drvRawImageDestruct(PPDMDRVINS pDrvIns)
    180180{
    181     PDRVRAWIMAGE pData = PDMINS_2_DATA(pDrvIns, PDRVRAWIMAGE);
    182     LogFlow(("drvRawImageDestruct: '%s'\n", pData->pszFilename));
    183 
    184     if (pData->File != NIL_RTFILE)
    185     {
    186         RTFileClose(pData->File);
    187         pData->File = NIL_RTFILE;
    188     }
    189     if (pData->pszFilename)
    190         MMR3HeapFree(pData->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);
    191191}
    192192
     
    195195static DECLCALLBACK(uint64_t) drvRawImageGetSize(PPDMIMEDIA pInterface)
    196196{
    197     PDRVRAWIMAGE pData = PDMIMEDIA_2_DRVRAWIMAGE(pInterface);
    198     LogFlow(("drvRawImageGetSize: '%s'\n", pData->pszFilename));
     197    PDRVRAWIMAGE pThis = PDMIMEDIA_2_DRVRAWIMAGE(pInterface);
     198    LogFlow(("drvRawImageGetSize: '%s'\n", pThis->pszFilename));
    199199
    200200    uint64_t cbFile;
    201     int rc = RTFileGetSize(pData->File, &cbFile);
     201    int rc = RTFileGetSize(pThis->File, &cbFile);
    202202    if (RT_SUCCESS(rc))
    203203    {
    204         LogFlow(("drvRawImageGetSize: returns %lld (%s)\n", cbFile, pData->pszFilename));
     204        LogFlow(("drvRawImageGetSize: returns %lld (%s)\n", cbFile, pThis->pszFilename));
    205205        return cbFile;
    206206    }
    207207
    208     AssertMsgFailed(("Error querying Raw image file size, rc=%Vrc. (%s)\n", rc, pData->pszFilename));
     208    AssertMsgFailed(("Error querying Raw image file size, rc=%Vrc. (%s)\n", rc, pThis->pszFilename));
    209209    return 0;
    210210}
     
    246246static DECLCALLBACK(int) drvRawImageRead(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead)
    247247{
    248     PDRVRAWIMAGE pData = PDMIMEDIA_2_DRVRAWIMAGE(pInterface);
    249     LogFlow(("drvRawImageRead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", off, pvBuf, cbRead, pData->pszFilename));
    250 
    251     Assert(pData->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);
    252252    Assert(pvBuf);
    253253
     
    255255     * Seek to the position and read.
    256256     */
    257     int rc = RTFileSeek(pData->File, off, RTFILE_SEEK_BEGIN, NULL);
     257    int rc = RTFileSeek(pThis->File, off, RTFILE_SEEK_BEGIN, NULL);
    258258    if (RT_SUCCESS(rc))
    259259    {
    260         rc = RTFileRead(pData->File, pvBuf, cbRead, NULL);
     260        rc = RTFileRead(pThis->File, pvBuf, cbRead, NULL);
    261261        if (RT_SUCCESS(rc))
    262262        {
    263263            Log2(("drvRawImageRead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n"
    264264                  "%16.*Vhxd\n",
    265                   off, pvBuf, cbRead, pData->pszFilename,
     265                  off, pvBuf, cbRead, pThis->pszFilename,
    266266                  cbRead, pvBuf));
    267267        }
    268268        else
    269269            AssertMsgFailed(("RTFileRead(%d, %p, %#x) -> %Vrc (off=%#llx '%s')\n",
    270                              pData->File, pvBuf, cbRead, rc, off, pData->pszFilename));
     270                             pThis->File, pvBuf, cbRead, rc, off, pThis->pszFilename));
    271271    }
    272272    else
    273         AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", pData->File, off, rc));
     273        AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", pThis->File, off, rc));
    274274    LogFlow(("drvRawImageRead: returns %Vrc\n", rc));
    275275    return rc;
     
    280280static DECLCALLBACK(int) drvRawImageWrite(PPDMIMEDIA pInterface, uint64_t off, const void *pvBuf, size_t cbWrite)
    281281{
    282     PDRVRAWIMAGE pData = PDMIMEDIA_2_DRVRAWIMAGE(pInterface);
    283     LogFlow(("drvRawImageWrite: off=%#llx pvBuf=%p cbWrite=%#x (%s)\n", off, pvBuf, cbWrite, pData->pszFilename));
    284 
    285     Assert(pData->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);
    286286    Assert(pvBuf);
    287287
     
    289289     * Seek to the position and write.
    290290     */
    291     int rc = RTFileSeek(pData->File, off, RTFILE_SEEK_BEGIN, NULL);
     291    int rc = RTFileSeek(pThis->File, off, RTFILE_SEEK_BEGIN, NULL);
    292292    if (RT_SUCCESS(rc))
    293293    {
    294         rc = RTFileWrite(pData->File, pvBuf, cbWrite, NULL);
     294        rc = RTFileWrite(pThis->File, pvBuf, cbWrite, NULL);
    295295        if (RT_SUCCESS(rc))
    296296        {
    297297            Log2(("drvRawImageWrite: off=%#llx pvBuf=%p cbWrite=%#x (%s)\n"
    298298                  "%16.*Vhxd\n",
    299                   off, pvBuf, cbWrite, pData->pszFilename,
     299                  off, pvBuf, cbWrite, pThis->pszFilename,
    300300                  cbWrite, pvBuf));
    301301        }
    302302        else
    303303            AssertMsgFailed(("RTFileWrite(%d, %p, %#x) -> %Vrc (off=%#llx '%s')\n",
    304                              pData->File, pvBuf, cbWrite, rc, off, pData->pszFilename));
     304                             pThis->File, pvBuf, cbWrite, rc, off, pThis->pszFilename));
    305305    }
    306306    else
    307         AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", pData->File, off, rc));
     307        AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Vrc\n", pThis->File, off, rc));
    308308    LogFlow(("drvRawImageWrite: returns %Vrc\n", rc));
    309309    return rc;
     
    314314static DECLCALLBACK(int) drvRawImageFlush(PPDMIMEDIA pInterface)
    315315{
    316     PDRVRAWIMAGE pData = PDMIMEDIA_2_DRVRAWIMAGE(pInterface);
    317     LogFlow(("drvRawImageFlush: (%s)\n", pData->pszFilename));
    318 
    319     Assert(pData->File != NIL_RTFILE);
    320     int rc = RTFileFlush(pData->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);
    321321    LogFlow(("drvRawImageFlush: returns %Vrc\n", rc));
    322322    return rc;
     
    335335static DECLCALLBACK(bool) drvRawImageIsReadOnly(PPDMIMEDIA pInterface)
    336336{
    337     PDRVRAWIMAGE pData = PDMIMEDIA_2_DRVRAWIMAGE(pInterface);
    338     return pData->fReadOnly;
     337    PDRVRAWIMAGE pThis = PDMIMEDIA_2_DRVRAWIMAGE(pInterface);
     338    return pThis->fReadOnly;
    339339}
    340340
     
    352352{
    353353    PPDMDRVINS pDrvIns = PDMIBASE_2_DRVINS(pInterface);
    354     PDRVRAWIMAGE pData = PDMINS_2_DATA(pDrvIns, PDRVRAWIMAGE);
     354    PDRVRAWIMAGE pThis = PDMINS_2_DATA(pDrvIns, PDRVRAWIMAGE);
    355355    switch (enmInterface)
    356356    {
     
    358358            return &pDrvIns->IBase;
    359359        case PDMINTERFACE_MEDIA:
    360             return &pData->IMedia;
     360            return &pThis->IMedia;
    361361        default:
    362362            return NULL;
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r11267 r11269  
    276276    LogFlow(("%s: off=%#llx pvBuf=%p cbRead=%d\n", __FUNCTION__,
    277277             off, pvBuf, cbRead));
    278     PVBOXDISK pData = PDMIMEDIA_2_VBOXDISK(pInterface);
    279     int rc = VDRead(pData->pDisk, off, pvBuf, cbRead);
     278    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
     279    int rc = VDRead(pThis->pDisk, off, pvBuf, cbRead);
    280280    if (RT_SUCCESS(rc))
    281281        Log2(("%s: off=%#llx pvBuf=%p cbRead=%d %.*Vhxd\n", __FUNCTION__,
     
    292292    LogFlow(("%s: off=%#llx pvBuf=%p cbWrite=%d\n", __FUNCTION__,
    293293             off, pvBuf, cbWrite));
    294     PVBOXDISK pData = PDMIMEDIA_2_VBOXDISK(pInterface);
     294    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
    295295    Log2(("%s: off=%#llx pvBuf=%p cbWrite=%d %.*Vhxd\n", __FUNCTION__,
    296296          off, pvBuf, cbWrite, cbWrite, pvBuf));
    297     int rc = VDWrite(pData->pDisk, off, pvBuf, cbWrite);
     297    int rc = VDWrite(pThis->pDisk, off, pvBuf, cbWrite);
    298298    LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc));
    299299    return rc;
     
    304304{
    305305    LogFlow(("%s:\n", __FUNCTION__));
    306     PVBOXDISK pData = PDMIMEDIA_2_VBOXDISK(pInterface);
    307     int rc = VDFlush(pData->pDisk);
     306    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
     307    int rc = VDFlush(pThis->pDisk);
    308308    LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc));
    309309    return rc;
     
    314314{
    315315    LogFlow(("%s:\n", __FUNCTION__));
    316     PVBOXDISK pData = PDMIMEDIA_2_VBOXDISK(pInterface);
    317     uint64_t cb = VDGetSize(pData->pDisk, VD_LAST_IMAGE);
     316    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
     317    uint64_t cb = VDGetSize(pThis->pDisk, VD_LAST_IMAGE);
    318318    LogFlow(("%s: returns %#llx (%llu)\n", __FUNCTION__, cb, cb));
    319319    return cb;
     
    324324{
    325325    LogFlow(("%s:\n", __FUNCTION__));
    326     PVBOXDISK pData = PDMIMEDIA_2_VBOXDISK(pInterface);
    327     bool f = VDIsReadOnly(pData->pDisk);
     326    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
     327    bool f = VDIsReadOnly(pThis->pDisk);
    328328    LogFlow(("%s: returns %d\n", __FUNCTION__, f));
    329329    return f;
     
    335335{
    336336    LogFlow(("%s:\n", __FUNCTION__));
    337     PVBOXDISK pData = PDMIMEDIA_2_VBOXDISK(pInterface);
    338     int rc = VDGetPCHSGeometry(pData->pDisk, VD_LAST_IMAGE, pPCHSGeometry);
     337    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
     338    int rc = VDGetPCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pPCHSGeometry);
    339339    if (RT_FAILURE(rc))
    340340    {
     
    353353    LogFlow(("%s: CHS=%d/%d/%d\n", __FUNCTION__,
    354354             pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
    355     PVBOXDISK pData = PDMIMEDIA_2_VBOXDISK(pInterface);
    356     int rc = VDSetPCHSGeometry(pData->pDisk, VD_LAST_IMAGE, pPCHSGeometry);
     355    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
     356    int rc = VDSetPCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pPCHSGeometry);
    357357    LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc));
    358358    return rc;
     
    364364{
    365365    LogFlow(("%s:\n", __FUNCTION__));
    366     PVBOXDISK pData = PDMIMEDIA_2_VBOXDISK(pInterface);
    367     int rc = VDGetLCHSGeometry(pData->pDisk, VD_LAST_IMAGE, pLCHSGeometry);
     366    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
     367    int rc = VDGetLCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pLCHSGeometry);
    368368    if (RT_FAILURE(rc))
    369369    {
     
    382382    LogFlow(("%s: CHS=%d/%d/%d\n", __FUNCTION__,
    383383             pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
    384     PVBOXDISK pData = PDMIMEDIA_2_VBOXDISK(pInterface);
    385     int rc = VDSetLCHSGeometry(pData->pDisk, VD_LAST_IMAGE, pLCHSGeometry);
     384    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
     385    int rc = VDSetLCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pLCHSGeometry);
    386386    LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc));
    387387    return rc;
     
    392392{
    393393    LogFlow(("%s:\n", __FUNCTION__));
    394     PVBOXDISK pData = PDMIMEDIA_2_VBOXDISK(pInterface);
    395     int rc = VDGetUuid(pData->pDisk, 0, pUuid);
     394    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
     395    int rc = VDGetUuid(pThis->pDisk, 0, pUuid);
    396396    LogFlow(("%s: returns %Vrc ({%Vuuid})\n", __FUNCTION__, rc, pUuid));
    397397    return rc;
     
    408408     LogFlow(("%s: uOffset=%#llx paSeg=%#p cSeg=%u cbRead=%d\n pvUser=%#p", __FUNCTION__,
    409409             uOffset, paSeg, cSeg, cbRead, pvUser));
    410     PVBOXDISK pData = PDMIMEDIAASYNC_2_VBOXDISK(pInterface);
    411     int rc = VDAsyncRead(pData->pDisk, uOffset, cbRead, paSeg, cSeg, pvUser);
     410    PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface);
     411    int rc = VDAsyncRead(pThis->pDisk, uOffset, cbRead, paSeg, cSeg, pvUser);
    412412    LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc));
    413413    return rc;
     
    420420     LogFlow(("%s: uOffset=%#llx paSeg=%#p cSeg=%u cbWrite=%d\n pvUser=%#p", __FUNCTION__,
    421421             uOffset, paSeg, cSeg, cbWrite, pvUser));
    422     PVBOXDISK pData = PDMIMEDIAASYNC_2_VBOXDISK(pInterface);
    423     int rc = VDAsyncWrite(pData->pDisk, uOffset, cbWrite, paSeg, cSeg, pvUser);
     422    PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface);
     423    int rc = VDAsyncWrite(pThis->pDisk, uOffset, cbWrite, paSeg, cSeg, pvUser);
    424424    LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc));
    425425    return rc;
     
    432432static DECLCALLBACK(int) drvvdTasksCompleteNotify(PPDMITRANSPORTASYNCPORT pInterface, void *pvUser)
    433433{
    434     PVBOXDISK pData = PDMITRANSPORTASYNCPORT_2_VBOXDISK(pInterface);
     434    PVBOXDISK pThis = PDMITRANSPORTASYNCPORT_2_VBOXDISK(pInterface);
    435435    PDRVVDASYNCTASK pDrvVDAsyncTask = (PDRVVDASYNCTASK)pvUser;
    436436    int rc = VINF_VDI_ASYNC_IO_FINISHED;
     
    443443    if (rc == VINF_VDI_ASYNC_IO_FINISHED)
    444444    {
    445         rc = pData->pDrvMediaAsyncPort->pfnTransferCompleteNotify(pData->pDrvMediaAsyncPort, pDrvVDAsyncTask->pvUserCaller);
     445        rc = pThis->pDrvMediaAsyncPort->pfnTransferCompleteNotify(pThis->pDrvMediaAsyncPort, pDrvVDAsyncTask->pvUserCaller);
    446446    }
    447447    else if (rc == VERR_VDI_ASYNC_IO_IN_PROGRESS)
    448448        rc = VINF_SUCCESS;
    449449
    450     rc = RTCacheInsert(pData->pCache, pDrvVDAsyncTask);
     450    rc = RTCacheInsert(pThis->pCache, pDrvVDAsyncTask);
    451451    AssertRC(rc);
    452452
     
    464464{
    465465    PPDMDRVINS pDrvIns = PDMIBASE_2_DRVINS(pInterface);
    466     PVBOXDISK pData = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
     466    PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
    467467    switch (enmInterface)
    468468    {
     
    470470            return &pDrvIns->IBase;
    471471        case PDMINTERFACE_MEDIA:
    472             return &pData->IMedia;
     472            return &pThis->IMedia;
    473473        case PDMINTERFACE_MEDIA_ASYNC:
    474             return pData->fAsyncIOSupported ? &pData->IMediaAsync : NULL;
     474            return pThis->fAsyncIOSupported ? &pThis->IMediaAsync : NULL;
    475475        case PDMINTERFACE_TRANSPORT_ASYNC_PORT:
    476             return &pData->ITransportAsyncPort;
     476            return &pThis->ITransportAsyncPort;
    477477        default:
    478478            return NULL;
     
    500500{
    501501    LogFlow(("%s:\n", __FUNCTION__));
    502     PVBOXDISK pData = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
     502    PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
    503503    int rc = VINF_SUCCESS;
    504504    char *pszName = NULL;   /**< The path of the disk image file. */
     
    511511     */
    512512    pDrvIns->IBase.pfnQueryInterface    = drvvdQueryInterface;
    513     pData->pDrvIns                      = pDrvIns;
    514     pData->fTempReadOnly                = false;
    515     pData->pDisk                        = NULL;
     513    pThis->pDrvIns                      = pDrvIns;
     514    pThis->fTempReadOnly                = false;
     515    pThis->pDisk                        = NULL;
    516516
    517517    /* IMedia */
    518     pData->IMedia.pfnRead               = drvvdRead;
    519     pData->IMedia.pfnWrite              = drvvdWrite;
    520     pData->IMedia.pfnFlush              = drvvdFlush;
    521     pData->IMedia.pfnGetSize            = drvvdGetSize;
    522     pData->IMedia.pfnIsReadOnly         = drvvdIsReadOnly;
    523     pData->IMedia.pfnBiosGetPCHSGeometry = drvvdBiosGetPCHSGeometry;
    524     pData->IMedia.pfnBiosSetPCHSGeometry = drvvdBiosSetPCHSGeometry;
    525     pData->IMedia.pfnBiosGetLCHSGeometry = drvvdBiosGetLCHSGeometry;
    526     pData->IMedia.pfnBiosSetLCHSGeometry = drvvdBiosSetLCHSGeometry;
    527     pData->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;
    528528
    529529    /* IMediaAsync */
    530     pData->IMediaAsync.pfnStartRead       = drvvdStartRead;
    531     pData->IMediaAsync.pfnStartWrite      = drvvdStartWrite;
     530    pThis->IMediaAsync.pfnStartRead       = drvvdStartRead;
     531    pThis->IMediaAsync.pfnStartWrite      = drvvdStartWrite;
    532532
    533533    /* ITransportAsyncPort */
    534     pData->ITransportAsyncPort.pfnTaskCompleteNotify  = drvvdTasksCompleteNotify;
     534    pThis->ITransportAsyncPort.pfnTaskCompleteNotify  = drvvdTasksCompleteNotify;
    535535
    536536    /* Initialize supported VD interfaces. */
    537     pData->VDIErrorCallbacks.cbSize       = sizeof(VDINTERFACEERROR);
    538     pData->VDIErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
    539     pData->VDIErrorCallbacks.pfnError     = drvvdErrorCallback;
    540 
    541     rc = VDInterfaceCreate(&pData->VDIError, "DrvVD_VDIError", VDINTERFACETYPE_ERROR,
    542                            &pData->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);
    543543    AssertRC(rc);
    544544
    545     pData->VDIAsyncIOCallbacks.cbSize                  = sizeof(VDINTERFACEASYNCIO);
    546     pData->VDIAsyncIOCallbacks.enmInterface            = VDINTERFACETYPE_ASYNCIO;
    547     pData->VDIAsyncIOCallbacks.pfnOpen                 = drvvdAsyncIOOpen;
    548     pData->VDIAsyncIOCallbacks.pfnClose                = drvvdAsyncIOClose;
    549     pData->VDIAsyncIOCallbacks.pfnRead                 = drvvdAsyncIORead;
    550     pData->VDIAsyncIOCallbacks.pfnWrite                = drvvdAsyncIOWrite;
    551     pData->VDIAsyncIOCallbacks.pfnFlush                = drvvdAsyncIOFlush;
    552     pData->VDIAsyncIOCallbacks.pfnPrepareRead          = drvvdAsyncIOPrepareRead;
    553     pData->VDIAsyncIOCallbacks.pfnPrepareWrite         = drvvdAsyncIOPrepareWrite;
    554     pData->VDIAsyncIOCallbacks.pfnTasksSubmit          = drvvdAsyncIOTasksSubmit;
    555 
    556     rc = VDInterfaceCreate(&pData->VDIAsyncIO, "DrvVD_AsyncIO", VDINTERFACETYPE_ASYNCIO,
    557                            &pData->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);
    558558    AssertRC(rc);
    559559
    560     pData->VDIConfigCallbacks.cbSize                = sizeof(VDINTERFACECONFIG);
    561     pData->VDIConfigCallbacks.enmInterface          = VDINTERFACETYPE_CONFIG;
    562     pData->VDIConfigCallbacks.pfnAreValuesValid     = drvvdCfgAreValuesValid;
    563     pData->VDIConfigCallbacks.pfnQueryType          = drvvdCfgQueryType;
    564     pData->VDIConfigCallbacks.pfnQuerySize          = drvvdCfgQuerySize;
    565     pData->VDIConfigCallbacks.pfnQueryInteger       = drvvdCfgQueryInteger;
    566     pData->VDIConfigCallbacks.pfnQueryIntegerDef    = drvvdCfgQueryIntegerDef;
    567     pData->VDIConfigCallbacks.pfnQueryString        = drvvdCfgQueryString;
    568     pData->VDIConfigCallbacks.pfnQueryStringDef     = drvvdCfgQueryStringDef;
    569     pData->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;
    570570
    571571    /** @todo TEMP! this isn't really correct - this needs to be made per image,
     
    573573     * At the moment this is harmless, as iSCSI can only be used as a base
    574574     * image, and no other backend uses the private data for these callbacks. */
    575     rc = VDInterfaceCreate(&pData->VDIConfig, "DrvVD_Config", VDINTERFACETYPE_CONFIG,
    576                            &pData->VDIConfigCallbacks, NULL /**< @todo TEMP */, &pData->VDIAsyncIO);
     575    rc = VDInterfaceCreate(&pThis->VDIConfig, "DrvVD_Config", VDINTERFACETYPE_CONFIG,
     576                           &pThis->VDIConfigCallbacks, NULL /**< @todo TEMP */, &pThis->VDIAsyncIO);
    577577    AssertRC(rc);
    578578
    579579    /* Try to attach async media port interface above.*/
    580     pData->pDrvMediaAsyncPort = (PPDMIMEDIAASYNCPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_MEDIA_ASYNC_PORT);
     580    pThis->pDrvMediaAsyncPort = (PPDMIMEDIAASYNCPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_MEDIA_ASYNC_PORT);
    581581
    582582    /*
     
    584584     * async interface.
    585585     */
    586     if (pData->pDrvMediaAsyncPort)
     586    if (pThis->pDrvMediaAsyncPort)
    587587    {
    588588        /* Try to attach the driver. */
     
    596596             * Revert to non async I/O.
    597597             */
    598             pData->pDrvMediaAsyncPort = NULL;
     598            pThis->pDrvMediaAsyncPort = NULL;
    599599        }
    600600        else if (RT_FAILURE(rc))
     
    605605        {
    606606            /* Success query the async transport interface. */
    607             pData->pDrvTransportAsync = (PPDMITRANSPORTASYNC)pBase->pfnQueryInterface(pBase, PDMINTERFACE_TRANSPORT_ASYNC);
    608             if (!pData->pDrvTransportAsync)
     607            pThis->pDrvTransportAsync = (PPDMITRANSPORTASYNC)pBase->pfnQueryInterface(pBase, PDMINTERFACE_TRANSPORT_ASYNC);
     608            if (!pThis->pDrvTransportAsync)
    609609            {
    610610                /* Whoops. */
     
    659659    {
    660660        /** @todo TEMP! later the iSCSI config callbacks won't be included here */
    661         rc = VDCreate(&pData->VDIConfig, &pData->pDisk);
     661        rc = VDCreate(&pThis->VDIConfig, &pThis->pDisk);
    662662        /* Error message is already set correctly. */
    663663    }
     
    717717        {
    718718            PCFGMNODE pCfg = CFGMR3GetChild(pCurNode, "VDConfig");
    719             pData->VDIConfig.pvUser = pCfg; /**< @todo TEMP! */
     719            pThis->VDIConfig.pvUser = pCfg; /**< @todo TEMP! */
    720720        }
    721721
     
    730730        if (fHonorZeroWrites)
    731731            uOpenFlags |= VD_OPEN_FLAGS_HONOR_ZEROES;
    732         if (pData->pDrvMediaAsyncPort)
     732        if (pThis->pDrvMediaAsyncPort)
    733733            uOpenFlags |= VD_OPEN_FLAGS_ASYNC_IO;
    734734
    735735        /** Try to open backend in asyc I/O mode first. */
    736         rc = VDOpen(pData->pDisk, pszFormat, pszName, uOpenFlags);
     736        rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags);
    737737        if (rc == VERR_NOT_SUPPORTED)
    738738        {
    739739            /* Seems async I/O is not supported by the backend, open in normal mode. */
    740740            uOpenFlags &= ~VD_OPEN_FLAGS_ASYNC_IO;
    741             rc = VDOpen(pData->pDisk, pszFormat, pszName, uOpenFlags);
     741            rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags);
    742742        }
    743743
     
    745745            Log(("%s: %d - Opened '%s' in %s mode\n", __FUNCTION__,
    746746                 iLevel, pszName,
    747                  VDIsReadOnly(pData->pDisk) ? "read-only" : "read-write"));
     747                 VDIsReadOnly(pThis->pDisk) ? "read-only" : "read-write"));
    748748        else
    749749        {
     
    765765    if (RT_FAILURE(rc))
    766766    {
    767         if (VALID_PTR(pData->pDisk))
    768         {
    769             VDDestroy(pData->pDisk);
    770             pData->pDisk = NULL;
     767        if (VALID_PTR(pThis->pDisk))
     768        {
     769            VDDestroy(pThis->pDisk);
     770            pThis->pDisk = NULL;
    771771        }
    772772        if (VALID_PTR(pszName))
     
    780780     * it.
    781781     */
    782     pData->fAsyncIOSupported = true;
    783     for (unsigned i = 0; i < VDGetCount(pData->pDisk); i++)
     782    pThis->fAsyncIOSupported = true;
     783    for (unsigned i = 0; i < VDGetCount(pThis->pDisk); i++)
    784784    {
    785785        VDBACKENDINFO vdBackendInfo;
    786786
    787         rc = VDBackendInfoSingle(pData->pDisk, i, &vdBackendInfo);
     787        rc = VDBackendInfoSingle(pThis->pDisk, i, &vdBackendInfo);
    788788        AssertRC(rc);
    789789
     
    794794             * Check if current file is supported with async I/O)
    795795             */
    796             rc = VDImageIsAsyncIOSupported(pData->pDisk, i, &pData->fAsyncIOSupported);
     796            rc = VDImageIsAsyncIOSupported(pThis->pDisk, i, &pThis->fAsyncIOSupported);
    797797            AssertRC(rc);
    798798
     
    802802             * at least one does not support it.
    803803             */
    804             if (!pData->fAsyncIOSupported)
     804            if (!pThis->fAsyncIOSupported)
    805805                break;
    806806        }
    807807        else
    808808        {
    809             pData->fAsyncIOSupported = false;
     809            pThis->fAsyncIOSupported = false;
    810810            break;
    811811        }
     
    813813
    814814    /* Create cache if async I/O is supported. */
    815     if (pData->fAsyncIOSupported)
    816     {
    817         rc = RTCacheCreate(&pData->pCache, 0, sizeof(DRVVDASYNCTASK), RTOBJCACHE_PROTECT_INSERT);
     815    if (pThis->fAsyncIOSupported)
     816    {
     817        rc = RTCacheCreate(&pThis->pCache, 0, sizeof(DRVVDASYNCTASK), RTOBJCACHE_PROTECT_INSERT);
    818818        AssertMsg(RT_SUCCESS(rc), ("Failed to create cache rc=%Vrc\n", rc));
    819819    }
     
    834834{
    835835    int rc;
    836     PVBOXDISK pData = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
    837     LogFlow(("%s:\n", __FUNCTION__));
    838 
    839     if (pData->pCache)
    840     {
    841         rc = RTCacheDestroy(pData->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);
    842842        AssertRC(rc);
    843843    }
     
    855855{
    856856    LogFlow(("%s:\n", __FUNCTION__));
    857     PVBOXDISK pData = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
    858     if (!VDIsReadOnly(pData->pDisk))
     857    PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
     858    if (!VDIsReadOnly(pThis->pDisk))
    859859    {
    860860        unsigned uOpenFlags;
    861         int rc = VDGetOpenFlags(pData->pDisk, VD_LAST_IMAGE, &uOpenFlags);
     861        int rc = VDGetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, &uOpenFlags);
    862862        AssertRC(rc);
    863863        uOpenFlags |= VD_OPEN_FLAGS_READONLY;
    864         rc = VDSetOpenFlags(pData->pDisk, VD_LAST_IMAGE, uOpenFlags);
     864        rc = VDSetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, uOpenFlags);
    865865        AssertRC(rc);
    866         pData->fTempReadOnly = true;
     866        pThis->fTempReadOnly = true;
    867867    }
    868868}
     
    877877{
    878878    LogFlow(("%s:\n", __FUNCTION__));
    879     PVBOXDISK pData = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
    880     if (pData->fTempReadOnly)
     879    PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
     880    if (pThis->fTempReadOnly)
    881881    {
    882882        unsigned uOpenFlags;
    883         int rc = VDGetOpenFlags(pData->pDisk, VD_LAST_IMAGE, &uOpenFlags);
     883        int rc = VDGetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, &uOpenFlags);
    884884        AssertRC(rc);
    885885        uOpenFlags &= ~VD_OPEN_FLAGS_READONLY;
    886         rc = VDSetOpenFlags(pData->pDisk, VD_LAST_IMAGE, uOpenFlags);
     886        rc = VDSetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, uOpenFlags);
    887887        AssertRC(rc);
    888         pData->fTempReadOnly = false;
     888        pThis->fTempReadOnly = false;
    889889    }
    890890}
     
    893893{
    894894    LogFlow(("%s:\n", __FUNCTION__));
    895     PVBOXDISK pData = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
     895    PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
    896896
    897897    /*
     
    900900     * async transport driver is destructed.
    901901     */
    902     int rc = VDCloseAll(pData->pDisk);
     902    int rc = VDCloseAll(pThis->pDisk);
    903903    AssertRC(rc);
    904904}
  • trunk/src/VBox/Devices/Storage/VBoxHDD.cpp

    r11267 r11269  
    5656static DECLCALLBACK(uint64_t) vdiGetSize(PPDMIMEDIA pInterface)
    5757{
    58     PVDIDISK pData = PDMIMEDIA_2_VDIDISK(pInterface);
    59     uint64_t cb = VDIDiskGetSize(pData);
     58    PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface);
     59    uint64_t cb = VDIDiskGetSize(pThis);
    6060    LogFlow(("vdiGetSize: returns %#llx (%llu)\n", cb, cb));
    6161    return cb;
     
    9494static DECLCALLBACK(int) vdiBiosGetLCHSGeometry(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry)
    9595{
    96     PVDIDISK pData = PDMIMEDIA_2_VDIDISK(pInterface);
    97     int rc = VDIDiskGetLCHSGeometry(pData, pLCHSGeometry);
     96    PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface);
     97    int rc = VDIDiskGetLCHSGeometry(pThis, pLCHSGeometry);
    9898    if (RT_SUCCESS(rc))
    9999    {
     
    113113static DECLCALLBACK(int) vdiBiosSetLCHSGeometry(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pLCHSGeometry)
    114114{
    115     PVDIDISK pData = PDMIMEDIA_2_VDIDISK(pInterface);
    116     int rc = VDIDiskSetLCHSGeometry(pData, pLCHSGeometry);
     115    PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface);
     116    int rc = VDIDiskSetLCHSGeometry(pThis, pLCHSGeometry);
    117117    LogFlow(("%s: returns %Vrc (%d,%d,%d)\n", __FUNCTION__, rc, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
    118118    return rc;
     
    128128{
    129129    LogFlow(("vdiRead: off=%#llx pvBuf=%p cbRead=%d\n", off, pvBuf, cbRead));
    130     PVDIDISK pData = PDMIMEDIA_2_VDIDISK(pInterface);
    131     int rc = VDIDiskRead(pData, off, pvBuf, cbRead);
     130    PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface);
     131    int rc = VDIDiskRead(pThis, off, pvBuf, cbRead);
    132132    if (RT_SUCCESS(rc))
    133133        Log2(("vdiRead: off=%#llx pvBuf=%p cbRead=%d\n"
     
    147147{
    148148    LogFlow(("vdiWrite: off=%#llx pvBuf=%p cbWrite=%d\n", off, pvBuf, cbWrite));
    149     PVDIDISK pData = PDMIMEDIA_2_VDIDISK(pInterface);
     149    PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface);
    150150    Log2(("vdiWrite: off=%#llx pvBuf=%p cbWrite=%d\n"
    151151          "%.*Vhxd\n",
    152152          off, pvBuf, cbWrite, cbWrite, pvBuf));
    153     int rc = VDIDiskWrite(pData, off, pvBuf, cbWrite);
     153    int rc = VDIDiskWrite(pThis, off, pvBuf, cbWrite);
    154154    LogFlow(("vdiWrite: returns %Vrc\n", rc));
    155155    return rc;
     
    165165{
    166166    LogFlow(("vdiFlush:\n"));
    167     PVDIDISK pData = PDMIMEDIA_2_VDIDISK(pInterface);
    168     VDIFlushImage(pData->pLast);
     167    PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface);
     168    VDIFlushImage(pThis->pLast);
    169169    int rc = VINF_SUCCESS;
    170170    LogFlow(("vdiFlush: returns %Vrc\n", rc));
     
    176176static DECLCALLBACK(int) vdiGetUuid(PPDMIMEDIA pInterface, PRTUUID pUuid)
    177177{
    178     PVDIDISK pData = PDMIMEDIA_2_VDIDISK(pInterface);
    179     int rc = VDIDiskGetImageUuid(pData, 0, pUuid);
     178    PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface);
     179    int rc = VDIDiskGetImageUuid(pThis, 0, pUuid);
    180180    LogFlow(("vdiGetUuid: returns %Vrc ({%Vuuid})\n", rc, pUuid));
    181181    return rc;
     
    186186static DECLCALLBACK(bool) vdiIsReadOnly(PPDMIMEDIA pInterface)
    187187{
    188     PVDIDISK pData = PDMIMEDIA_2_VDIDISK(pInterface);
    189     LogFlow(("vdiIsReadOnly: returns %d\n", VDIDiskIsReadOnly(pData)));
    190     return VDIDiskIsReadOnly(pData);
     188    PVDIDISK pThis = PDMIMEDIA_2_VDIDISK(pInterface);
     189    LogFlow(("vdiIsReadOnly: returns %d\n", VDIDiskIsReadOnly(pThis)));
     190    return VDIDiskIsReadOnly(pThis);
    191191}
    192192
     
    204204{
    205205    PPDMDRVINS pDrvIns = PDMIBASE_2_DRVINS(pInterface);
    206     PVDIDISK pData = PDMINS_2_DATA(pDrvIns, PVDIDISK);
     206    PVDIDISK pThis = PDMINS_2_DATA(pDrvIns, PVDIDISK);
    207207    switch (enmInterface)
    208208    {
     
    210210            return &pDrvIns->IBase;
    211211        case PDMINTERFACE_MEDIA:
    212             return &pData->IMedia;
     212            return &pThis->IMedia;
    213213        default:
    214214            return NULL;
     
    227227    LogFlow(("vdiSuspend:\n"));
    228228#if 1 //#ifdef DEBUG_dmik
    229     PVDIDISK pData = PDMINS_2_DATA(pDrvIns, PVDIDISK);
    230     if (!(pData->pLast->fOpen & VDI_OPEN_FLAGS_READONLY))
    231     {
    232         int rc = vdiChangeImageMode(pData->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);
    233233        AssertRC(rc);
    234234    }
     
    248248    LogFlow(("vdiSuspend:\n"));
    249249#if 1 // #ifdef DEBUG_dmik
    250     PVDIDISK pData = PDMINS_2_DATA(pDrvIns, PVDIDISK);
    251     if (!(pData->pLast->fOpen & VDI_OPEN_FLAGS_READONLY))
    252     {
    253         int rc = vdiChangeImageMode(pData->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);
    254254        AssertRC(rc);
    255255    }
     
    269269{
    270270    LogFlow(("vdiDestruct:\n"));
    271     PVDIDISK pData = PDMINS_2_DATA(pDrvIns, PVDIDISK);
    272     VDIDiskCloseAllImages(pData);
     271    PVDIDISK pThis = PDMINS_2_DATA(pDrvIns, PVDIDISK);
     272    VDIDiskCloseAllImages(pThis);
    273273}
    274274
     
    287287{
    288288    LogFlow(("vdiConstruct:\n"));
    289     PVDIDISK pData = PDMINS_2_DATA(pDrvIns, PVDIDISK);
     289    PVDIDISK pThis = PDMINS_2_DATA(pDrvIns, PVDIDISK);
    290290    char *pszName;      /**< The path of the disk image file. */
    291291    bool fReadOnly;     /**< True if the media is readonly. */
     
    296296     */
    297297    pDrvIns->IBase.pfnQueryInterface    = vdiQueryInterface;
    298     pData->pDrvIns = pDrvIns;
    299 
    300     vdiInitVDIDisk(pData);
     298    pThis->pDrvIns = pDrvIns;
     299
     300    vdiInitVDIDisk(pThis);
    301301
    302302    /* IMedia */
    303     pData->IMedia.pfnRead               = vdiRead;
    304     pData->IMedia.pfnWrite              = vdiWrite;
    305     pData->IMedia.pfnFlush              = vdiFlush;
    306     pData->IMedia.pfnGetSize            = vdiGetSize;
    307     pData->IMedia.pfnGetUuid            = vdiGetUuid;
    308     pData->IMedia.pfnIsReadOnly         = vdiIsReadOnly;
    309     pData->IMedia.pfnBiosGetPCHSGeometry = vdiBiosGetPCHSGeometry;
    310     pData->IMedia.pfnBiosSetPCHSGeometry = vdiBiosSetPCHSGeometry;
    311     pData->IMedia.pfnBiosGetLCHSGeometry = vdiBiosGetLCHSGeometry;
    312     pData->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;
    313313
    314314    /*
     
    371371         * Open the image.
    372372         */
    373         rc = VDIDiskOpenImage(pData, pszName, fReadOnly ? VDI_OPEN_FLAGS_READONLY
     373        rc = VDIDiskOpenImage(pThis, pszName, fReadOnly ? VDI_OPEN_FLAGS_READONLY
    374374                                                        : VDI_OPEN_FLAGS_NORMAL);
    375375        if (RT_SUCCESS(rc))
    376376            Log(("vdiConstruct: %d - Opened '%s' in %s mode\n",
    377                  iLevel, pszName, VDIDiskIsReadOnly(pData) ? "read-only" : "read-write"));
     377                 iLevel, pszName, VDIDiskIsReadOnly(pThis) ? "read-only" : "read-write"));
    378378        else
    379379            AssertMsgFailed(("Failed to open image '%s' rc=%Vrc\n", pszName, rc));
     
    387387    /* If any of the images has the flag set, handle zero writes like normal. */
    388388    if (RT_SUCCESS(rc))
    389         pData->fHonorZeroWrites = fHonorZeroWrites;
     389        pThis->fHonorZeroWrites = fHonorZeroWrites;
    390390
    391391    /* On failure, vdiDestruct will be called, so no need to clean up here. */
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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