VirtualBox

Changeset 81781 in vbox


Ignore:
Timestamp:
Nov 11, 2019 9:57:39 PM (5 years ago)
Author:
vboxsync
Message:

DevLsiLogicSCSI: Split device state structures. bugref:9218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevLsiLogicSCSI.cpp

    r81777 r81781  
    8181*********************************************************************************************************************************/
    8282
    83 /** Pointer to the device instance data of the LsiLogic emulation. */
     83/** Pointer to the shared instance data for the LsiLogic emulation. */
    8484typedef struct LSILOGICSCSI *PLSILOGICSCSI;
    8585
     
    8989 *
    9090 * @returns nothing.
    91  * @param   pThis    The LsiLogic controller instance.
    92  * @param   GCPhys   The guest physical address of the memory buffer.
    93  * @param   pSgBuf   The pointer to the host R3 S/G buffer.
    94  * @param   cbCopy   How many bytes to copy between the two buffers.
    95  * @param   pcbSkip  Initially contains the amount of bytes to skip
    96  *                   starting from the guest physical address before
    97  *                   accessing the S/G buffer and start copying data.
    98  *                   On return this contains the remaining amount if
    99  *                   cbCopy < *pcbSkip or 0 otherwise.
    100  */
    101 typedef DECLCALLBACK(void) LSILOGICR3MEMCOPYCALLBACK(PLSILOGICSCSI pThis, RTGCPHYS GCPhys, PRTSGBUF pSgBuf, size_t cbCopy,
    102                                                      size_t *pcbSkip);
     91 * @param   pDevIns     The device instance.
     92 * @param   GCPhys      The guest physical address of the memory buffer.
     93 * @param   pSgBuf      The pointer to the host R3 S/G buffer.
     94 * @param   cbCopy      How many bytes to copy between the two buffers.
     95 * @param   pcbSkip     Initially contains the amount of bytes to skip
     96 *                      starting from the guest physical address before
     97 *                      accessing the S/G buffer and start copying data.
     98 *                      On return this contains the remaining amount if
     99 *                      cbCopy < *pcbSkip or 0 otherwise.
     100 */
     101typedef DECLCALLBACK(void) LSILOGICR3MEMCOPYCALLBACK(PPDMDEVINS pDevIns, RTGCPHYS GCPhys,
     102                                                     PRTSGBUF pSgBuf, size_t cbCopy, size_t *pcbSkip);
    103103/** Pointer to a memory copy buffer callback. */
    104104typedef LSILOGICR3MEMCOPYCALLBACK *PLSILOGICR3MEMCOPYCALLBACK;
     
    148148typedef struct LSILOGICDEVICE
    149149{
    150     /** Pointer to the owning lsilogic device instance. - R3 pointer */
    151     R3PTRTYPE(PLSILOGICSCSI)    pLsiLogicR3;
     150    /** Pointer to the owning lsilogic device instance - R3 pointer */
     151    PPDMDEVINSR3                pDevIns;
    152152
    153153    /** LUN of the device. */
     
    155155    /** Number of outstanding tasks on the port. */
    156156    volatile uint32_t           cOutstandingRequests;
    157 
    158 #if HC_ARCH_BITS == 64
    159     uint32_t                    Alignment0;
    160 #endif
    161157
    162158    /** Our base interface. */
     
    176172    /** The status LED state for this device. */
    177173    PDMLED                      Led;
    178 
     174    /** Device name. */
     175    char                        szName[16];
    179176} LSILOGICDEVICE;
    180177/** Pointer to a device state. */
     
    190187typedef struct LSILOGICSCSI
    191188{
    192     /** Pointer to the device instance. - R3 ptr. */
    193     PPDMDEVINSR3                pDevInsR3;
    194     /** Pointer to the device instance. - R0 ptr. */
    195     PPDMDEVINSR0                pDevInsR0;
    196     /** Pointer to the device instance. - RC ptr. */
    197     PPDMDEVINSRC                pDevInsRC;
    198 
    199     /** Flag whether the GC part of the device is enabled. */
    200     bool                        fGCEnabled;
    201     /** Flag whether the R0 part of the device is enabled. */
    202     bool                        fR0Enabled;
    203     bool                        afPaddingMinus1[2+4];
    204 
    205189    /** The state the controller is currently in. */
    206190    LSILOGICSTATE               enmState;
     
    220204    /** Number of device states allocated. */
    221205    uint32_t                    cDeviceStates;
    222 
    223     /** States for attached devices. */
    224     R3PTRTYPE(PLSILOGICDEVICE)  paDeviceStates;
    225 #if HC_ARCH_BITS == 32
    226     RTR3PTR                     R3PtrPadding0;
    227 #endif
     206    uint32_t                    u32Padding1;
    228207
    229208    /** Interrupt mask. */
     
    250229    /** The fault code of the I/O controller if we are in the fault state. */
    251230    uint16_t                    u16IOCFaultCode;
    252     uint16_t                    u16Padding0b;
     231    uint16_t                    u16Padding2;
    253232
    254233    /** Upper 32 bits of the message frame address to locate requests in guest memory. */
     
    305284    volatile uint32_t           uRequestQueueNextAddressRead;
    306285
     286    /** Indicates that PDMDevHlpAsyncNotificationCompleted should be called when
     287     * a port is entering the idle state. */
     288    bool volatile               fSignalIdle;
     289    /** Flag whether the worker thread is sleeping. */
     290    volatile bool               fWrkThreadSleeping;
     291    /** Flag whether a request from the BIOS is pending which the
     292     * worker thread needs to process. */
     293    volatile bool               fBiosReqPending;
     294    bool                        fPadding3;
     295
     296    /** Current address to read from or write to in the diagnostic memory region. */
     297    uint32_t                    u32DiagMemAddr;
     298
    307299    /** Emulated controller type */
    308300    LSILOGICCTRLTYPE            enmCtrlType;
     
    312304    /** Number of ports this controller has. */
    313305    uint8_t                     cPorts;
    314 
    315     /** BIOS emulation. */
    316     VBOXSCSI                    VBoxSCSI;
    317 
     306    uint8_t                     afPadding4;
     307
     308    /** The event semaphore the processing thread waits on. */
     309    SUPSEMEVENT                 hEvtProcess;
     310
     311    /** PCI Region \#0: I/O ports register access. */
     312    IOMIOPORTHANDLE             hIoPortsReg;
     313    /** PCI Region \#1: MMIO register access. */
     314    IOMMMIOHANDLE               hMmioReg;
     315    /** PCI Region \#2: MMIO diag. */
     316    IOMMMIOHANDLE               hMmioDiag;
     317    /** ISA Ports for the BIOS (when booting is configured). */
     318    IOMIOPORTHANDLE             hIoPortsBios;
     319} LSILOGICSCSI;
     320AssertCompileMemberAlignment(LSILOGICSCSI, ReplyPostQueueCritSect, 8);
     321
     322/**
     323 * Ring-3 instance data for the LsiLogic emulation.
     324 */
     325typedef struct LSILOGICSCSIR3
     326{
     327    /** States for attached devices. */
     328    R3PTRTYPE(PLSILOGICDEVICE)  paDeviceStates;
    318329    /** Status LUN: The base interface. */
    319330    PDMIBASE                    IBase;
     
    327338    R3PTRTYPE(PMptConfigurationPagesSupported) pConfigurationPages;
    328339
    329     /** Indicates that PDMDevHlpAsyncNotificationCompleted should be called when
    330      * a port is entering the idle state. */
    331     bool volatile               fSignalIdle;
    332     /** Flag whether we have tasks which need to be processed again- */
    333     bool volatile               fRedo;
    334     /** Flag whether the worker thread is sleeping. */
    335     volatile bool               fWrkThreadSleeping;
    336     /** Flag whether a request from the BIOS is pending which the
    337      * worker thread needs to process. */
    338     volatile bool               fBiosReqPending;
    339 #if HC_ARCH_BITS == 64
    340     /** Alignment padding. */
    341     bool                        afPadding2[4];
    342 #endif
    343     /** List of tasks which can be redone. */
    344     R3PTRTYPE(volatile PLSILOGICREQ) pTasksRedoHead;
    345 
    346     /** Current address to read from or write to in the diagnostic memory region. */
    347     uint32_t                    u32DiagMemAddr;
     340    /** BIOS emulation. */
     341    VBOXSCSI                    VBoxSCSI;
     342
    348343    /** Current size of the memory regions. */
    349344    uint32_t                    cbMemRegns;
    350 
    351 #if HC_ARCH_BITS ==32
    352345    uint32_t                    u32Padding3;
    353 #endif
    354 
    355     union
    356     {
    357         /** List of memory regions - PLSILOGICMEMREGN. */
    358         RTLISTANCHOR            ListMemRegns;
    359         uint8_t                 u8Padding[2 * sizeof(RTUINTPTR)];
    360     };
     346
     347    /** List of memory regions - PLSILOGICMEMREGN. */
     348    RTLISTANCHORR3              ListMemRegns;
    361349
    362350    /** Worker thread. */
    363351    R3PTRTYPE(PPDMTHREAD)       pThreadWrk;
    364     /** The event semaphore the processing thread waits on. */
    365     SUPSEMEVENT                 hEvtProcess;
    366 
    367     /** PCI Region \#0: I/O ports register access. */
    368     IOMIOPORTHANDLE             hIoPortsReg;
    369     /** PCI Region \#1: MMIO register access. */
    370     IOMMMIOHANDLE               hMmioReg;
    371     /** PCI Region \#2: MMIO diag. */
    372     IOMMMIOHANDLE               hMmioDiag;
    373     /** ISA Ports for the BIOS (when booting is configured). */
    374     IOMIOPORTHANDLE             hIoPortsBios;
    375 } LSILOGISCSI;
     352
     353    /** The device instace - only for getting bearings in interface methods. */
     354    PPDMDEVINSR3                pDevIns;
     355} LSILOGICSCSIR3;
     356/** Pointer to the ring-3 instance data for the LsiLogic emulation. */
     357typedef LSILOGICSCSIR3 *PLSILOGICSCSIR3;
     358
     359
     360/**
     361 * Ring-0 instance data for the LsiLogic emulation.
     362 */
     363typedef struct LSILOGICSCSIR0
     364{
     365    uint64_t                    u64Unused;
     366} LSILOGICSCSIR0;
     367/** Pointer to the ring-0 instance data for the LsiLogic emulation. */
     368typedef LSILOGICSCSIR0 *PLSILOGICSCSIR0;
     369
     370
     371/**
     372 * Raw-mode instance data for the LsiLogic emulation.
     373 */
     374typedef struct LSILOGICSCSIRC
     375{
     376    uint64_t                    u64Unused;
     377} LSILOGICSCSIRC;
     378/** Pointer to the raw-mode instance data for the LsiLogic emulation. */
     379typedef LSILOGICSCSIRC *PLSILOGICSCSIRC;
     380
     381
     382/** The current context instance data for the LsiLogic emulation. */
     383typedef CTX_SUFF(LSILOGICSCSI)  LSILOGICSCSICC;
     384/** Pointer to the current context instance data for the LsiLogic emulation. */
     385typedef CTX_SUFF(PLSILOGICSCSI) PLSILOGICSCSICC;
    376386
    377387
     
    414424RT_C_DECLS_BEGIN
    415425#ifdef IN_RING3
    416 static void lsilogicR3InitializeConfigurationPages(PLSILOGICSCSI pThis);
    417 static void lsilogicR3ConfigurationPagesFree(PLSILOGICSCSI pThis);
    418 static int  lsilogicR3ProcessConfigurationRequest(PLSILOGICSCSI pThis, PMptConfigurationRequest pConfigurationReq,
    419                                                   PMptConfigurationReply pReply);
     426static void lsilogicR3InitializeConfigurationPages(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC);
     427static void lsilogicR3ConfigurationPagesFree(PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC);
     428static int  lsilogicR3ProcessConfigurationRequest(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC,
     429                                                  PMptConfigurationRequest pConfigurationReq, PMptConfigurationReply pReply);
    420430#endif
    421431RT_C_DECLS_END
     
    433443 *
    434444 * @returns nothing.
    435  * @param   pThis       Pointer to the LsiLogic device state.
    436  */
    437 static void lsilogicUpdateInterrupt(PLSILOGICSCSI pThis)
     445 * @param   pDevIns     The device instance.
     446 * @param   pThis       Pointer to the shared LsiLogic device state.
     447 */
     448static void lsilogicUpdateInterrupt(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis)
    438449{
    439450    uint32_t uIntSts;
     
    449460    {
    450461        LogFlowFunc(("Setting interrupt\n"));
    451         PDMDevHlpPCISetIrq(pThis->CTX_SUFF(pDevIns), 0, 1);
     462        PDMDevHlpPCISetIrq(pDevIns, 0, 1);
    452463    }
    453464    else
    454465    {
    455466        LogFlowFunc(("Clearing interrupt\n"));
    456         PDMDevHlpPCISetIrq(pThis->CTX_SUFF(pDevIns), 0, 0);
     467        PDMDevHlpPCISetIrq(pDevIns, 0, 0);
    457468    }
    458469}
     
    463474 *
    464475 * @returns nothing.
    465  * @param   pThis       Pointer to the LsiLogic device state.
     476 * @param   pDevIns     The device instance.
     477 * @param   pThis       Pointer to the shared LsiLogic device state.
    466478 * @param   uStatus     The status bit to set.
    467479 */
    468 DECLINLINE(void) lsilogicSetInterrupt(PLSILOGICSCSI pThis, uint32_t uStatus)
     480DECLINLINE(void) lsilogicSetInterrupt(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, uint32_t uStatus)
    469481{
    470482    ASMAtomicOrU32(&pThis->uInterruptStatus, uStatus);
    471     lsilogicUpdateInterrupt(pThis);
     483    lsilogicUpdateInterrupt(pDevIns, pThis);
    472484}
    473485
     
    477489 *
    478490 * @returns nothing.
    479  * @param   pThis       Pointer to the LsiLogic device state.
     491 * @param   pDevIns     The device instance.
     492 * @param   pThis       Pointer to the shared LsiLogic device state.
    480493 * @param   uStatus     The status bit to set.
    481494 */
    482 DECLINLINE(void) lsilogicClearInterrupt(PLSILOGICSCSI pThis, uint32_t uStatus)
     495DECLINLINE(void) lsilogicClearInterrupt(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, uint32_t uStatus)
    483496{
    484497    ASMAtomicAndU32(&pThis->uInterruptStatus, ~uStatus);
    485     lsilogicUpdateInterrupt(pThis);
     498    lsilogicUpdateInterrupt(pDevIns, pThis);
    486499}
    487500
     
    492505 *
    493506 * @returns nothing
    494  * @param   pThis           Pointer to the LsiLogic device state.
     507 * @param   pThis           Pointer to the shared LsiLogic device state.
    495508 * @param   uIOCFaultCode   Fault code to set.
    496509 */
     
    513526 *
    514527 * @returns Number of frames in the reply free queue.
    515  * @param   pThis    Pointer to the LsiLogic device state.
     528 * @param   pThis    Pointer to the shared LsiLogic device state.
    516529 */
    517530DECLINLINE(uint32_t) lsilogicReplyFreeQueueGetFrameCount(PLSILOGICSCSI pThis)
     
    533546 *
    534547 * @returns Number of frames in the reply free queue.
    535  * @param   pThis    Pointer to the LsiLogic device state.
     548 * @param   pThis    Pointer to the shared LsiLogic device state.
    536549 */
    537550DECLINLINE(uint32_t) lsilogicReplyPostQueueGetFrameCount(PLSILOGICSCSI pThis)
     
    552565 *
    553566 * @returns VBox status code.
    554  * @param   pThis       Pointer to the LsiLogic device state.
    555  */
    556 static int lsilogicR3HardReset(PLSILOGICSCSI pThis)
     567 * @param   pDevIns     The device instance.
     568 * @param   pThis       Pointer to the shared LsiLogic device state.
     569 * @param   pThisCC     Pointer to the ring-3 LsiLogic device state.
     570 */
     571static int lsilogicR3HardReset(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC)
    557572{
    558573    pThis->enmState = LSILOGICSTATE_RESET;
     
    564579    /* Reset interrupt states. */
    565580    pThis->uInterruptStatus = 0;
    566     lsilogicUpdateInterrupt(pThis);
     581    lsilogicUpdateInterrupt(pDevIns, pThis);
    567582
    568583    /* Reset the queues. */
     
    586601    pThis->u32DiagMemAddr = 0;
    587602
    588     lsilogicR3ConfigurationPagesFree(pThis);
    589     lsilogicR3InitializeConfigurationPages(pThis);
     603    lsilogicR3ConfigurationPagesFree(pThis, pThisCC);
     604    lsilogicR3InitializeConfigurationPages(pDevIns, pThis, pThisCC);
    590605
    591606    /* Mark that we finished performing the reset. */
     
    598613 *
    599614 * @returns nothing.
    600  * @param pThis    The LsiLogic controller instance
    601  */
    602 static void lsilogicR3ConfigurationPagesFree(PLSILOGICSCSI pThis)
    603 {
    604 
    605     if (pThis->pConfigurationPages)
     615 * @param   pThis    Pointer to the shared LsiLogic device state.
     616 * @param   pThisCC  Pointer to the ring-3 LsiLogic device state.
     617 */
     618static void lsilogicR3ConfigurationPagesFree(PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC)
     619{
     620
     621    if (pThisCC->pConfigurationPages)
    606622    {
    607623        /* Destroy device list if we emulate a SAS controller. */
    608624        if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    609625        {
    610             PMptConfigurationPagesSas pSasPages = &pThis->pConfigurationPages->u.SasPages;
     626            PMptConfigurationPagesSas pSasPages = &pThisCC->pConfigurationPages->u.SasPages;
    611627            PMptSASDevice pSASDeviceCurr = pSasPages->pSASDeviceHead;
    612628
     
    628644        }
    629645
    630         RTMemFree(pThis->pConfigurationPages);
     646        RTMemFree(pThisCC->pConfigurationPages);
    631647    }
    632648}
     
    636652 *
    637653 * @returns nothing
    638  * @param   pThis               Pointer to the LsiLogic device state.
     654 * @param   pDevIns             The device instance.
     655 * @param   pThis               Pointer to the shared LsiLogic device state.
    639656 * @param   u32MessageContext   The message context ID to post.
    640657 */
    641 static void lsilogicR3FinishContextReply(PLSILOGICSCSI pThis, uint32_t u32MessageContext)
     658static void lsilogicR3FinishContextReply(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, uint32_t u32MessageContext)
    642659{
    643660    int rc;
     
    648665
    649666    /* Write message context ID into reply post queue. */
    650     rc = PDMDevHlpCritSectEnter(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect, VINF_SUCCESS);
     667    rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->ReplyPostQueueCritSect, VINF_SUCCESS);
    651668    AssertRC(rc);
    652669
     
    656673        /* Set error code. */
    657674        lsilogicSetIOCFaultCode(pThis, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
    658         PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect);
     675        PDMDevHlpCritSectLeave(pDevIns, &pThis->ReplyPostQueueCritSect);
    659676        return;
    660677    }
     
    666683
    667684    /* Set interrupt. */
    668     lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
    669 
    670     PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect);
     685    lsilogicSetInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
     686
     687    PDMDevHlpCritSectLeave(pDevIns, &pThis->ReplyPostQueueCritSect);
    671688}
    672689
     
    676693 *
    677694 * @returns nothing
    678  * @param   pThis           Pointer to the LsiLogic device state.
     695 * @param   pDevIns         The device instance.
     696 * @param   pThis           Pointer to the shared LsiLogic device state.
    679697 * @param   pReply          Pointer to the reply message.
    680698 * @param   fForceReplyFifo Flag whether the use of the reply post fifo is forced.
    681699 */
    682 static void lsilogicFinishAddressReply(PLSILOGICSCSI pThis, PMptReplyUnion pReply, bool fForceReplyFifo)
     700static void lsilogicFinishAddressReply(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, PMptReplyUnion pReply, bool fForceReplyFifo)
    683701{
    684702    /*
     
    693711        Log(("%s: cReplySize=%u\n", __FUNCTION__, pThis->cReplySize));
    694712        pThis->uNextReplyEntryRead = 0;
    695         lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
     713        lsilogicSetInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
    696714    }
    697715    else
     
    705723        int rc;
    706724        /* Grab a free reply message from the queue. */
    707         rc = PDMDevHlpCritSectEnter(pThis->CTX_SUFF(pDevIns), &pThis->ReplyFreeQueueCritSect, VINF_SUCCESS);
     725        rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->ReplyFreeQueueCritSect, VINF_SUCCESS);
    708726        AssertRC(rc);
    709727
     
    713731            /* Set error code. */
    714732            lsilogicSetIOCFaultCode(pThis, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
    715             PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyFreeQueueCritSect);
     733            PDMDevHlpCritSectLeave(pDevIns, &pThis->ReplyFreeQueueCritSect);
    716734            return;
    717735        }
     
    722740        pThis->uReplyFreeQueueNextAddressRead %= pThis->cReplyQueueEntries;
    723741
    724         PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyFreeQueueCritSect);
     742        PDMDevHlpCritSectLeave(pDevIns, &pThis->ReplyFreeQueueCritSect);
    725743
    726744        /* Build 64bit physical address. */
     
    729747
    730748        /* Write reply to guest memory. */
    731         PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhysReplyMessage, pReply, cbReplyCopied);
     749        PDMDevHlpPCIPhysWrite(pDevIns, GCPhysReplyMessage, pReply, cbReplyCopied);
    732750
    733751        /* Write low 32bits of reply frame into post reply queue. */
    734         rc = PDMDevHlpCritSectEnter(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect, VINF_SUCCESS);
     752        rc = PDMDevHlpCritSectEnter(pDevIns, &pThis->ReplyPostQueueCritSect, VINF_SUCCESS);
    735753        AssertRC(rc);
    736754
     
    740758            /* Set error code. */
    741759            lsilogicSetIOCFaultCode(pThis, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
    742             PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect);
     760            PDMDevHlpCritSectLeave(pDevIns, &pThis->ReplyPostQueueCritSect);
    743761            return;
    744762        }
     
    753771        {
    754772            pThis->enmDoorbellState = LSILOGICDOORBELLSTATE_NOT_IN_USE;
    755             lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
     773            lsilogicSetInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
    756774        }
    757775
    758776        /* Set interrupt. */
    759         lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
    760 
    761         PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect);
     777        lsilogicSetInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
     778
     779        PDMDevHlpCritSectLeave(pDevIns, &pThis->ReplyPostQueueCritSect);
    762780# else
    763781        AssertMsgFailed(("This is not allowed to happen.\n"));
     
    771789 *
    772790 * @returns Pointer to memory region or NULL if not found.
    773  * @param   pThis           Pointer to the LsiLogic device state.
     791 * @param   pThisCC         Pointer to the ring-3 LsiLogic device state.
    774792 * @param   u32Addr         The 32bit address to search for.
    775793 */
    776 static PLSILOGICMEMREGN lsilogicR3MemRegionFindByAddr(PLSILOGICSCSI pThis, uint32_t u32Addr)
     794static PLSILOGICMEMREGN lsilogicR3MemRegionFindByAddr(PLSILOGICSCSICC pThisCC, uint32_t u32Addr)
    777795{
    778796    PLSILOGICMEMREGN pRegion = NULL;
    779797
    780798    PLSILOGICMEMREGN pIt;
    781     RTListForEach(&pThis->ListMemRegns, pIt, LSILOGICMEMREGN, NodeList)
     799    RTListForEach(&pThisCC->ListMemRegns, pIt, LSILOGICMEMREGN, NodeList)
    782800    {
    783801        if (   u32Addr >= pIt->u32AddrStart
     
    796814 *
    797815 * @returns nothing.
    798  * @param   pThis           Pointer to the LsiLogic device state.
    799  */
    800 static void lsilogicR3MemRegionsFree(PLSILOGICSCSI pThis)
     816 * @param   pThisCC         Pointer to the ring-3 LsiLogic device state.
     817 */
     818static void lsilogicR3MemRegionsFree(PLSILOGICSCSICC pThisCC)
    801819{
    802820    PLSILOGICMEMREGN pItNext;
    803821
    804822    PLSILOGICMEMREGN pIt;
    805     RTListForEachSafe(&pThis->ListMemRegns, pIt, pItNext, LSILOGICMEMREGN, NodeList)
     823    RTListForEachSafe(&pThisCC->ListMemRegns, pIt, pItNext, LSILOGICMEMREGN, NodeList)
    806824    {
    807825        RTListNodeRemove(&pIt->NodeList);
    808826        RTMemFree(pIt);
    809827    }
    810     pThis->cbMemRegns = 0;
     828    pThisCC->cbMemRegns = 0;
    811829}
    812830
     
    815833 *
    816834 * @returns nothing.
    817  * @param   pThis           Pointer to the LsiLogic device state.
     835 * @param   pThisCC         Pointer to the ring-3 LsiLogic device state.
    818836 * @param   pRegion         The region to insert.
    819837 */
    820 static void lsilogicR3MemRegionInsert(PLSILOGICSCSI pThis, PLSILOGICMEMREGN pRegion)
     838static void lsilogicR3MemRegionInsert(PLSILOGICSCSICC pThisCC, PLSILOGICMEMREGN pRegion)
    821839{
    822840    bool fInserted = false;
     
    824842    /* Insert at the right position. */
    825843    PLSILOGICMEMREGN pIt;
    826     RTListForEach(&pThis->ListMemRegns, pIt, LSILOGICMEMREGN, NodeList)
     844    RTListForEach(&pThisCC->ListMemRegns, pIt, LSILOGICMEMREGN, NodeList)
    827845    {
    828846        if (pRegion->u32AddrEnd < pIt->u32AddrStart)
     
    834852    }
    835853    if (!fInserted)
    836         RTListAppend(&pThis->ListMemRegns, &pRegion->NodeList);
     854        RTListAppend(&pThisCC->ListMemRegns, &pRegion->NodeList);
    837855}
    838856
     
    841859 *
    842860 * @returns Number of memory regions.
    843  * @param   pThis           Pointer to the LsiLogic device state.
    844  */
    845 static uint32_t lsilogicR3MemRegionsCount(PLSILOGICSCSI pThis)
     861 * @param   pThisCC         Pointer to the ring-3 LsiLogic device state.
     862 */
     863static uint32_t lsilogicR3MemRegionsCount(PLSILOGICSCSICC pThisCC)
    846864{
    847865    uint32_t cRegions = 0;
    848866
    849867    PLSILOGICMEMREGN pIt;
    850     RTListForEach(&pThis->ListMemRegns, pIt, LSILOGICMEMREGN, NodeList)
     868    RTListForEach(&pThisCC->ListMemRegns, pIt, LSILOGICMEMREGN, NodeList)
    851869    {
    852870        cRegions++;
     
    860878 *
    861879 * @returns nothing.
    862  * @param   pThis           Pointer to the LsiLogic device state.
     880 * @param   pThis           Pointer to the shared LsiLogic device state.
     881 * @param   pThisCC         Pointer to the ring-3 LsiLogic device state.
    863882 * @param   u32Data         Data to write.
    864883 */
    865 static void lsilogicR3DiagRegDataWrite(PLSILOGICSCSI pThis, uint32_t u32Data)
    866 {
    867     PLSILOGICMEMREGN pRegion = lsilogicR3MemRegionFindByAddr(pThis, pThis->u32DiagMemAddr);
     884static void lsilogicR3DiagRegDataWrite(PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC, uint32_t u32Data)
     885{
     886    PLSILOGICMEMREGN pRegion = lsilogicR3MemRegionFindByAddr(pThisCC, pThis->u32DiagMemAddr);
    868887
    869888    if (pRegion)
     
    884903        /* Create new region, first check whether we can extend another region. */
    885904        PLSILOGICMEMREGN pIt;
    886         RTListForEach(&pThis->ListMemRegns, pIt, LSILOGICMEMREGN, NodeList)
     905        RTListForEach(&pThisCC->ListMemRegns, pIt, LSILOGICMEMREGN, NodeList)
    887906        {
    888907            if (pThis->u32DiagMemAddr == pIt->u32AddrEnd + sizeof(uint32_t))
     
    901920            uint32_t cRegionSizeNew = cRegionSizeOld + 512;
    902921
    903             if (pThis->cbMemRegns + 512 * sizeof(uint32_t) < LSILOGIC_MEMORY_REGIONS_MAX)
     922            if (pThisCC->cbMemRegns + 512 * sizeof(uint32_t) < LSILOGIC_MEMORY_REGIONS_MAX)
    904923            {
    905924                PLSILOGICMEMREGN pRegionNew;
     
    911930                    pRegion->au32Data[cRegionSizeOld] = u32Data;
    912931                    pRegion->u32AddrEnd = pRegion->u32AddrStart + (cRegionSizeNew - 1) * sizeof(uint32_t);
    913                     pThis->cbMemRegns += 512 * sizeof(uint32_t);
     932                    pThisCC->cbMemRegns += 512 * sizeof(uint32_t);
    914933                }
    915934                /* else: Silently fail, there is nothing we can do here and the guest might work nevertheless. */
    916935
    917                 lsilogicR3MemRegionInsert(pThis, pRegion);
     936                lsilogicR3MemRegionInsert(pThisCC, pRegion);
    918937            }
    919938        }
    920939        else
    921940        {
    922             if (pThis->cbMemRegns + 512 * sizeof(uint32_t) < LSILOGIC_MEMORY_REGIONS_MAX)
     941            if (pThisCC->cbMemRegns + 512 * sizeof(uint32_t) < LSILOGIC_MEMORY_REGIONS_MAX)
    923942            {
    924943                /* Create completely new. */
     
    929948                    pRegion->u32AddrEnd   = pRegion->u32AddrStart + (512 - 1) * sizeof(uint32_t);
    930949                    pRegion->au32Data[0]  = u32Data;
    931                     pThis->cbMemRegns += 512 * sizeof(uint32_t);
    932 
    933                     lsilogicR3MemRegionInsert(pThis, pRegion);
     950                    pThisCC->cbMemRegns += 512 * sizeof(uint32_t);
     951
     952                    lsilogicR3MemRegionInsert(pThisCC, pRegion);
    934953                }
    935954                /* else: Silently fail, there is nothing we can do here and the guest might work nevertheless. */
     
    947966 *
    948967 * @returns nothing.
    949  * @param   pThis           Pointer to the LsiLogic device state.
     968 * @param   pThis           Pointer to the shared LsiLogic device state.
     969 * @param   pThisCC         Pointer to the ring-3 LsiLogic device state.
    950970 * @param   pu32Data        Where to store the data.
    951971 */
    952 static void lsilogicR3DiagRegDataRead(PLSILOGICSCSI pThis, uint32_t *pu32Data)
    953 {
    954     PLSILOGICMEMREGN pRegion = lsilogicR3MemRegionFindByAddr(pThis, pThis->u32DiagMemAddr);
     972static void lsilogicR3DiagRegDataRead(PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC, uint32_t *pu32Data)
     973{
     974    PLSILOGICMEMREGN pRegion = lsilogicR3MemRegionFindByAddr(pThisCC, pThis->u32DiagMemAddr);
    955975
    956976    if (pRegion)
     
    976996 *
    977997 * @returns nothing.
    978  * @param   pThis           Pointer to the LsiLogic device state.
     998 * @param   pThis           Pointer to the shared LsiLogic device state.
    979999 * @param   u32Addr         Address to write.
    9801000 */
     
    9881008 *
    9891009 * @returns nothing.
    990  * @param   pThis           Pointer to the LsiLogic device state.
     1010 * @param   pThis           Pointer to the shared LsiLogic device state.
    9911011 * @param   pu32Addr        Where to store the current address.
    9921012 */
     
    10001020 *
    10011021 * @returns VBox status code.
    1002  * @param   pThis       Pointer to the LsiLogic device state.
     1022 * @param   pDevIns     The device instance.
     1023 * @param   pThis       Pointer to the shared LsiLogic device state.
     1024 * @param   pThisCC     Pointer to the ring-3 LsiLogic device state.
    10031025 * @param   pMessageHdr Pointer to the message header of the request.
    10041026 * @param   pReply      Pointer to the reply.
    10051027 */
    1006 static int lsilogicR3ProcessMessageRequest(PLSILOGICSCSI pThis, PMptMessageHdr pMessageHdr, PMptReplyUnion pReply)
     1028static int lsilogicR3ProcessMessageRequest(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC,
     1029                                           PMptMessageHdr pMessageHdr, PMptReplyUnion pReply)
    10071030{
    10081031    int rc = VINF_SUCCESS;
     
    10961119
    10971120            /* Check for a valid firmware image in the IOC memory which was downlaoded by tzhe guest earlier. */
    1098             PLSILOGICMEMREGN pRegion = lsilogicR3MemRegionFindByAddr(pThis, LSILOGIC_FWIMGHDR_LOAD_ADDRESS);
     1121            PLSILOGICMEMREGN pRegion = lsilogicR3MemRegionFindByAddr(pThisCC, LSILOGIC_FWIMGHDR_LOAD_ADDRESS);
    10991122
    11001123            if (pRegion)
     
    12111234            PMptConfigurationRequest pConfigurationReq = (PMptConfigurationRequest)pMessageHdr;
    12121235
    1213             rc = lsilogicR3ProcessConfigurationRequest(pThis, pConfigurationReq, &pReply->Configuration);
     1236            rc = lsilogicR3ProcessConfigurationRequest(pDevIns, pThis, pThisCC, pConfigurationReq, &pReply->Configuration);
    12141237            AssertRC(rc);
    12151238            break;
     
    12411264    pReply->Header.u32MessageContext = pMessageHdr->u32MessageContext;
    12421265
    1243     lsilogicFinishAddressReply(pThis, pReply, fForceReplyPostFifo);
     1266    lsilogicFinishAddressReply(pDevIns, pThis, pReply, fForceReplyPostFifo);
    12441267    return rc;
    12451268}
     
    12521275 * @returns Strict VBox status code.
    12531276 * @param   pDevIns     The devie instance.
    1254  * @param   pThis       Pointer to the LsiLogic device state.
     1277 * @param   pThis       Pointer to the shared LsiLogic device state.
    12551278 * @param   offReg      Offset of the register to write.
    12561279 * @param   u32         The value being written.
     
    13341357                        /* Reset interrupt status. */
    13351358                        pThis->uInterruptStatus = 0;
    1336                         lsilogicUpdateInterrupt(pThis);
     1359                        lsilogicUpdateInterrupt(pDevIns, pThis);
    13371360
    13381361                        /* Reset the queues. */
     
    13571380                        pThis->enmDoorbellState = LSILOGICDOORBELLSTATE_FN_HANDSHAKE;
    13581381                        /* Update the interrupt status to notify the guest that a doorbell function was started. */
    1359                         lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
     1382                        lsilogicSetInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
    13601383                        break;
    13611384                    }
     
    13641387                        pThis->enmDoorbellState = LSILOGICDOORBELLSTATE_RFR_FRAME_COUNT_LOW;
    13651388                        /* Update the interrupt status to notify the guest that a doorbell function was started. */
    1366                         lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
     1389                        lsilogicSetInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
    13671390                        break;
    13681391                    }
     
    13901413                if (pThis->iMessage == pThis->cMessage)
    13911414                {
    1392                     int rc = lsilogicR3ProcessMessageRequest(pThis, (PMptMessageHdr)pThis->aMessage, &pThis->ReplyBuffer);
     1415                    int rc = lsilogicR3ProcessMessageRequest(pDevIns, pThis, PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC),
     1416                                                             (PMptMessageHdr)pThis->aMessage, &pThis->ReplyBuffer);
    13931417                    AssertRC(rc);
    13941418                }
     
    14341458            }
    14351459
    1436             lsilogicUpdateInterrupt(pThis);
     1460            lsilogicUpdateInterrupt(pDevIns, pThis);
    14371461            break;
    14381462        }
     
    14401464        {
    14411465            ASMAtomicWriteU32(&pThis->uInterruptMask, u32 & LSILOGIC_REG_HOST_INTR_MASK_W_MASK);
    1442             lsilogicUpdateInterrupt(pThis);
     1466            lsilogicUpdateInterrupt(pDevIns, pThis);
    14431467            break;
    14441468        }
     
    14791503#else
    14801504                if (u32 & LSILOGIC_REG_HOST_DIAGNOSTIC_RESET_ADAPTER)
    1481                     lsilogicR3HardReset(pThis);
     1505                    lsilogicR3HardReset(pDevIns, pThis, PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC));
    14821506                else if (u32 & LSILOGIC_REG_HOST_DIAGNOSTIC_DIAG_RW_ENABLE)
    14831507                    pThis->fDiagRegsEnabled = true;
     
    14931517                return VINF_IOM_R3_MMIO_WRITE;
    14941518#else
    1495                 lsilogicR3DiagRegDataWrite(pThis, u32);
     1519                lsilogicR3DiagRegDataWrite(pThis, PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC), u32);
    14961520#endif
    14971521            }
     
    15231547 * @returns VBox status code.
    15241548 * @param   pDevIns     The device instance.
    1525  * @param   pThis       Pointer to the LsiLogic device state.
     1549 * @param   pThis       Pointer to the shared LsiLogic device state.
    15261550 * @param   offReg      Offset of the register to read.
    15271551 * @param   pu32        Where to store the content of the register.
     
    15561580                /* The reply post queue is empty. Reset interrupt. */
    15571581                u32 = UINT32_C(0xffffffff);
    1558                 lsilogicClearInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
     1582                lsilogicClearInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
    15591583            }
    15601584            PDMDevHlpCritSectLeave(pDevIns, &pThis->ReplyPostQueueCritSect);
     
    15831607                    if (pThis->uNextReplyEntryRead < pThis->cReplySize)
    15841608                        u32 |= pThis->ReplyBuffer.au16Reply[pThis->uNextReplyEntryRead++];
    1585                     lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
     1609                    lsilogicSetInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
    15861610                    break;
    15871611                case LSILOGICDOORBELLSTATE_RFR_FRAME_COUNT_LOW:
     
    15911615                    u32 |= cReplyFrames & UINT32_C(0xffff);
    15921616                    pThis->enmDoorbellState = LSILOGICDOORBELLSTATE_RFR_FRAME_COUNT_HIGH;
    1593                     lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
     1617                    lsilogicSetInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
    15941618                    break;
    15951619                }
     
    16001624                    u32 |= cReplyFrames >> 16;
    16011625                    pThis->enmDoorbellState = LSILOGICDOORBELLSTATE_RFR_NEXT_FRAME_LOW;
    1602                     lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
     1626                    lsilogicSetInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
    16031627                    break;
    16041628                }
     
    16081632                        u32 |= pThis->aReplyFreeQueue[pThis->uReplyFreeQueueNextAddressRead] & UINT32_C(0xffff);
    16091633                        pThis->enmDoorbellState = LSILOGICDOORBELLSTATE_RFR_NEXT_FRAME_HIGH;
    1610                         lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
     1634                        lsilogicSetInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
    16111635                    }
    16121636                    break;
     
    16161640                    pThis->uReplyFreeQueueNextAddressRead %= pThis->cReplyQueueEntries;
    16171641                    pThis->enmDoorbellState = LSILOGICDOORBELLSTATE_RFR_NEXT_FRAME_LOW;
    1618                     lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
     1642                    lsilogicSetInterrupt(pDevIns, pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
    16191643                    break;
    16201644                default:
     
    16491673                return VINF_IOM_R3_MMIO_READ;
    16501674#else
    1651                 lsilogicR3DiagRegDataRead(pThis, &u32);
     1675                lsilogicR3DiagRegDataRead(pThis, PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC), &u32);
    16521676#endif
    16531677            }
     
    18531877 * @copydoc LSILOGICR3MEMCOPYCALLBACK
    18541878 */
    1855 static DECLCALLBACK(void) lsilogicR3CopyBufferFromGuestWorker(PLSILOGICSCSI pThis, RTGCPHYS GCPhys, PRTSGBUF pSgBuf,
    1856                                                               size_t cbCopy, size_t *pcbSkip)
     1879static DECLCALLBACK(void) lsilogicR3CopyBufferFromGuestWorker(PPDMDEVINS pDevIns, RTGCPHYS GCPhys,
     1880                                                              PRTSGBUF pSgBuf, size_t cbCopy, size_t *pcbSkip)
    18571881{
    18581882    size_t cbSkipped = RT_MIN(cbCopy, *pcbSkip);
     
    18671891
    18681892        AssertPtr(pvSeg);
    1869         PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), GCPhys, pvSeg, cbSeg);
     1893        PDMDevHlpPhysRead(pDevIns, GCPhys, pvSeg, cbSeg);
    18701894        GCPhys += cbSeg;
    18711895        cbCopy -= cbSeg;
     
    18781902 * @copydoc LSILOGICR3MEMCOPYCALLBACK
    18791903 */
    1880 static DECLCALLBACK(void) lsilogicR3CopyBufferToGuestWorker(PLSILOGICSCSI pThis, RTGCPHYS GCPhys, PRTSGBUF pSgBuf,
    1881                                                             size_t cbCopy, size_t *pcbSkip)
     1904static DECLCALLBACK(void) lsilogicR3CopyBufferToGuestWorker(PPDMDEVINS pDevIns, RTGCPHYS GCPhys,
     1905                                                            PRTSGBUF pSgBuf, size_t cbCopy, size_t *pcbSkip)
    18821906{
    18831907    size_t cbSkipped = RT_MIN(cbCopy, *pcbSkip);
     
    18921916
    18931917        AssertPtr(pvSeg);
    1894         PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhys, pvSeg, cbSeg);
     1918        PDMDevHlpPCIPhysWrite(pDevIns, GCPhys, pvSeg, cbSeg);
    18951919        GCPhys += cbSeg;
    18961920        cbCopy -= cbSeg;
     
    19021926 *
    19031927 * @returns The amout of bytes actually copied.
    1904  * @param   pThis                  Pointer to the LsiLogic device state.
    1905  * @param   pLsiReq                LSI request state.
    1906  * @param   pfnCopyWorker          The copy method to apply for each guest buffer.
    1907  * @param   pSgBuf                 The host S/G buffer.
    1908  * @param   cbSkip                 How many bytes to skip in advance before starting to copy.
    1909  * @param   cbCopy                 How many bytes to copy.
    1910  */
    1911 static size_t lsilogicSgBufWalker(PLSILOGICSCSI pThis, PLSILOGICREQ pLsiReq,
     1928 * @param   pDevIns         The device instance.
     1929 * @param   pLsiReq         LSI request state.
     1930 * @param   pfnCopyWorker   The copy method to apply for each guest buffer.
     1931 * @param   pSgBuf          The host S/G buffer.
     1932 * @param   cbSkip          How many bytes to skip in advance before starting to
     1933 *                          copy.
     1934 * @param   cbCopy          How many bytes to copy.
     1935 */
     1936static size_t lsilogicSgBufWalker(PPDMDEVINS pDevIns, PLSILOGICREQ pLsiReq,
    19121937                                  PLSILOGICR3MEMCOPYCALLBACK pfnCopyWorker,
    19131938                                  PRTSGBUF pSgBuf, size_t cbSkip, size_t cbCopy)
     
    19171942    RTGCPHYS GCPhysSegmentStart = pLsiReq->GCPhysSgStart;
    19181943    uint32_t cChainOffsetNext = pLsiReq->cChainOffset;
    1919     PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
    19201944    size_t cbCopied = 0;
    19211945
     
    19651989                GCPhysSgEntryNext += sizeof(MptSGEntrySimple32);
    19661990
    1967             pfnCopyWorker(pThis, GCPhysAddrDataBuffer, pSgBuf, cbCopyThis, &cbSkip);
     1991            pfnCopyWorker(pDevIns, GCPhysAddrDataBuffer, pSgBuf, cbCopyThis, &cbSkip);
    19681992            cbCopy -= cbCopyThis;
    19691993            cbCopied += cbCopyThis;
     
    20062030 *
    20072031 * @returns Amount of bytes copied to the guest.
    2008  * @param   pThis          The LsiLogic controller device instance.
    2009  * @param   pReq           Request structure.
    2010  * @param   pSgBuf         The S/G buffer to copy from.
    2011  * @param   cbSkip         How many bytes to skip in advance before starting to copy.
    2012  * @param   cbCopy         How many bytes to copy.
    2013  */
    2014 static size_t lsilogicR3CopySgBufToGuest(PLSILOGICSCSI pThis, PLSILOGICREQ pReq, PRTSGBUF pSgBuf,
     2032 * @param   pDevIns     The device instance.
     2033 * @param   pReq        Request structure.
     2034 * @param   pSgBuf      The S/G buffer to copy from.
     2035 * @param   cbSkip      How many bytes to skip in advance before starting to copy.
     2036 * @param   cbCopy      How many bytes to copy.
     2037 */
     2038static size_t lsilogicR3CopySgBufToGuest(PPDMDEVINS pDevIns, PLSILOGICREQ pReq, PRTSGBUF pSgBuf,
    20152039                                         size_t cbSkip, size_t cbCopy)
    20162040{
    2017     return lsilogicSgBufWalker(pThis, pReq, lsilogicR3CopyBufferToGuestWorker,
    2018                                pSgBuf, cbSkip, cbCopy);
     2041    return lsilogicSgBufWalker(pDevIns, pReq, lsilogicR3CopyBufferToGuestWorker, pSgBuf, cbSkip, cbCopy);
    20192042}
    20202043
     
    20232046 *
    20242047 * @returns Amount of bytes copied from the guest.
    2025  * @param   pThis          The LsiLogic controller device instance.
    2026  * @param   pReq           Request structure.
    2027  * @param   pSgBuf         The S/G buffer to copy into.
    2028  * @param   cbSkip         How many bytes to skip in advance before starting to copy.
    2029  * @param   cbCopy         How many bytes to copy.
    2030  */
    2031 static size_t lsilogicR3CopySgBufFromGuest(PLSILOGICSCSI pThis, PLSILOGICREQ pReq, PRTSGBUF pSgBuf,
     2048 * @param   pDevIns     The device instance.
     2049 * @param   pReq        Request structure.
     2050 * @param   pSgBuf      The S/G buffer to copy into.
     2051 * @param   cbSkip      How many bytes to skip in advance before starting to copy.
     2052 * @param   cbCopy      How many bytes to copy.
     2053 */
     2054static size_t lsilogicR3CopySgBufFromGuest(PPDMDEVINS pDevIns, PLSILOGICREQ pReq, PRTSGBUF pSgBuf,
    20322055                                           size_t cbSkip, size_t cbCopy)
    20332056{
    2034     return lsilogicSgBufWalker(pThis, pReq, lsilogicR3CopyBufferFromGuestWorker,
    2035                                pSgBuf, cbSkip, cbCopy);
     2057    return lsilogicSgBufWalker(pDevIns, pReq, lsilogicR3CopyBufferFromGuestWorker, pSgBuf, cbSkip, cbCopy);
    20362058}
    20372059
     
    21082130 *
    21092131 * @returns nothing.
    2110  * @param   pThis                  Pointer to the LsiLogic device state.
    2111  * @param   pReq                   The request to complete.
    2112  * @param   rcReq                  Status code of the request.
    2113  */
    2114 static void lsilogicR3ReqComplete(PLSILOGICSCSI pThis, PLSILOGICREQ pReq, int rcReq)
     2132 * @param   pDevIns     The device instance.
     2133 * @param   pThisCC     Pointer to the ring-3 LsiLogic device state.
     2134 * @param   pThis       Pointer to the shared LsiLogic device state.
     2135 * @param   pReq        The request to complete.
     2136 * @param   rcReq       Status code of the request.
     2137 */
     2138static void lsilogicR3ReqComplete(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC, PLSILOGICREQ pReq, int rcReq)
    21152139{
    21162140    PLSILOGICDEVICE pTgtDev = pReq->pTargetDevice;
    21172141
    2118     if (RT_UNLIKELY(pReq->fBIOS))
    2119     {
    2120         uint8_t u8ScsiSts = pReq->u8ScsiSts;
    2121         pTgtDev->pDrvMediaEx->pfnIoReqFree(pTgtDev->pDrvMediaEx, pReq->hIoReq);
    2122         int rc = vboxscsiRequestFinished(&pThis->VBoxSCSI, u8ScsiSts);
    2123         AssertMsgRC(rc, ("Finishing BIOS SCSI request failed rc=%Rrc\n", rc));
    2124     }
    2125     else
     2142    if (!pReq->fBIOS)
    21262143    {
    21272144        RTGCPHYS GCPhysAddrSenseBuffer;
     
    21312148
    21322149        /* Copy the sense buffer over. */
    2133         PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhysAddrSenseBuffer, pReq->abSenseBuffer,
     2150        PDMDevHlpPCIPhysWrite(pDevIns, GCPhysAddrSenseBuffer, pReq->abSenseBuffer,
    21342151                              RT_UNLIKELY(  pReq->GuestRequest.SCSIIO.u8SenseBufferLength
    21352152                                          < sizeof(pReq->abSenseBuffer))
     
    21432160            /* Free the request before posting completion. */
    21442161            pTgtDev->pDrvMediaEx->pfnIoReqFree(pTgtDev->pDrvMediaEx, pReq->hIoReq);
    2145             lsilogicR3FinishContextReply(pThis, u32MsgCtx);
     2162            lsilogicR3FinishContextReply(pDevIns, pThis, u32MsgCtx);
    21462163        }
    21472164        else
     
    21692186            /* Free the request before posting completion. */
    21702187            pTgtDev->pDrvMediaEx->pfnIoReqFree(pTgtDev->pDrvMediaEx, pReq->hIoReq);
    2171             lsilogicFinishAddressReply(pThis, &IOCReply, false);
    2172         }
     2188            lsilogicFinishAddressReply(pDevIns, pThis, &IOCReply, false);
     2189        }
     2190    }
     2191    else
     2192    {
     2193        uint8_t u8ScsiSts = pReq->u8ScsiSts;
     2194        pTgtDev->pDrvMediaEx->pfnIoReqFree(pTgtDev->pDrvMediaEx, pReq->hIoReq);
     2195        int rc = vboxscsiRequestFinished(&pThisCC->VBoxSCSI, u8ScsiSts);
     2196        AssertMsgRC(rc, ("Finishing BIOS SCSI request failed rc=%Rrc\n", rc));
    21732197    }
    21742198
     
    21762200
    21772201    if (pTgtDev->cOutstandingRequests == 0 && pThis->fSignalIdle)
    2178         PDMDevHlpAsyncNotificationCompleted(pThis->pDevInsR3);
     2202        PDMDevHlpAsyncNotificationCompleted(pDevIns);
    21792203}
    21802204
     
    21872211 *
    21882212 * @returns VBox status code.
    2189  * @param   pThis                  Pointer to the LsiLogic device state.
    2190  * @param   GCPhysMessageFrameAddr Guest physical address where the request is located.
    2191  * @param   pGuestReq              The request read fro th guest memory.
    2192  */
    2193 static int lsilogicR3ProcessSCSIIORequest(PLSILOGICSCSI pThis, RTGCPHYS GCPhysMessageFrameAddr,
    2194                                           PMptRequestUnion pGuestReq)
     2213 * @param   pDevIns                 The device instance.
     2214 * @param   pThis                   Pointer to the shared LsiLogic device state.
     2215 * @param   pThisCC                 Pointer to the ring-3 LsiLogic device state.
     2216 * @param   GCPhysMessageFrameAddr  Guest physical address where the request is located.
     2217 * @param   pGuestReq               The request read fro th guest memory.
     2218 */
     2219static int lsilogicR3ProcessSCSIIORequest(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC,
     2220                                          RTGCPHYS GCPhysMessageFrameAddr, PMptRequestUnion pGuestReq)
    21952221{
    21962222    MptReplyUnion IOCReply;
     
    22042230                  && (pGuestReq->SCSIIO.u8Bus == 0)))
    22052231    {
    2206         PLSILOGICDEVICE pTgtDev = &pThis->paDeviceStates[pGuestReq->SCSIIO.u8TargetID];
     2232        PLSILOGICDEVICE pTgtDev = &pThisCC->paDeviceStates[pGuestReq->SCSIIO.u8TargetID];
    22072233
    22082234        if (pTgtDev->pDrvBase)
     
    22502276                                                               &pLsiReq->u8ScsiSts, 30 * RT_MS_1SEC);
    22512277                if (rc != VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS)
    2252                     lsilogicR3ReqComplete(pThis, pLsiReq, rc);
     2278                    lsilogicR3ReqComplete(pDevIns, pThis, pThisCC, pLsiReq, rc);
    22532279
    22542280                return VINF_SUCCESS;
     
    22762302    if (g_cLogged++ < MAX_REL_LOG_ERRORS)
    22772303    {
    2278         LogRel(("LsiLogic#%d: %d/%d (Bus/Target) doesn't exist\n", pThis->CTX_SUFF(pDevIns)->iInstance,
     2304        LogRel(("LsiLogic#%d: %d/%d (Bus/Target) doesn't exist\n", pDevIns->iInstance,
    22792305                pGuestReq->SCSIIO.u8TargetID, pGuestReq->SCSIIO.u8Bus));
    22802306        /* Log the CDB too  */
    22812307        LogRel(("LsiLogic#%d: Guest issued CDB {%#x",
    2282                 pThis->CTX_SUFF(pDevIns)->iInstance, pGuestReq->SCSIIO.au8CDB[0]));
     2308                pDevIns->iInstance, pGuestReq->SCSIIO.au8CDB[0]));
    22832309        for (unsigned i = 1; i < pGuestReq->SCSIIO.u8CDBLength; i++)
    22842310            LogRel((", %#x", pGuestReq->SCSIIO.au8CDB[i]));
     
    23012327    IOCReply.SCSIIOError.u32ResponseInfo     = 0;
    23022328
    2303     lsilogicFinishAddressReply(pThis, &IOCReply, false);
     2329    lsilogicFinishAddressReply(pDevIns, pThis, &IOCReply, false);
    23042330
    23052331    return rc;
     
    23142340{
    23152341    PLSILOGICDEVICE pTgtDev = RT_FROM_MEMBER(pInterface, LSILOGICDEVICE, IMediaPort);
    2316     PPDMDEVINS pDevIns = pTgtDev->CTX_SUFF(pLsiLogic)->CTX_SUFF(pDevIns);
     2342    PPDMDEVINS pDevIns = pTgtDev->pDevIns;
    23172343
    23182344    AssertPtrReturn(ppcszController, VERR_INVALID_POINTER);
     
    23372363    RT_NOREF1(hIoReq);
    23382364    PLSILOGICDEVICE pTgtDev = RT_FROM_MEMBER(pInterface, LSILOGICDEVICE, IMediaExPort);
    2339     PLSILOGICREQ pReq = (PLSILOGICREQ)pvIoReqAlloc;
     2365    PPDMDEVINS      pDevIns = pTgtDev->pDevIns;
     2366    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     2367    PLSILOGICREQ    pReq    = (PLSILOGICREQ)pvIoReqAlloc;
    23402368
    23412369    size_t cbCopied = 0;
    2342     if (RT_UNLIKELY(pReq->fBIOS))
    2343         cbCopied = vboxscsiCopyToBuf(&pTgtDev->CTX_SUFF(pLsiLogic)->VBoxSCSI, pSgBuf, offDst, cbCopy);
     2370    if (!pReq->fBIOS)
     2371        cbCopied = lsilogicR3CopySgBufToGuest(pDevIns, pReq, pSgBuf, offDst, cbCopy);
    23442372    else
    2345         cbCopied = lsilogicR3CopySgBufToGuest(pTgtDev->CTX_SUFF(pLsiLogic), pReq, pSgBuf, offDst, cbCopy);
     2373        cbCopied = vboxscsiCopyToBuf(&pThisCC->VBoxSCSI, pSgBuf, offDst, cbCopy);
    23462374    return cbCopied == cbCopy ? VINF_SUCCESS : VERR_PDM_MEDIAEX_IOBUF_OVERFLOW;
    23472375}
     
    23562384    RT_NOREF1(hIoReq);
    23572385    PLSILOGICDEVICE pTgtDev = RT_FROM_MEMBER(pInterface, LSILOGICDEVICE, IMediaExPort);
    2358     PLSILOGICREQ pReq = (PLSILOGICREQ)pvIoReqAlloc;
     2386    PPDMDEVINS      pDevIns = pTgtDev->pDevIns;
     2387    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     2388    PLSILOGICREQ    pReq    = (PLSILOGICREQ)pvIoReqAlloc;
    23592389
    23602390    size_t cbCopied = 0;
    2361     if (RT_UNLIKELY(pReq->fBIOS))
    2362         cbCopied = vboxscsiCopyFromBuf(&pTgtDev->CTX_SUFF(pLsiLogic)->VBoxSCSI, pSgBuf, offSrc, cbCopy);
     2391    if (!pReq->fBIOS)
     2392        cbCopied = lsilogicR3CopySgBufFromGuest(pDevIns, pReq, pSgBuf, offSrc, cbCopy);
    23632393    else
    2364         cbCopied = lsilogicR3CopySgBufFromGuest(pTgtDev->CTX_SUFF(pLsiLogic), pReq, pSgBuf, offSrc, cbCopy);
     2394        cbCopied = vboxscsiCopyFromBuf(&pThisCC->VBoxSCSI, pSgBuf, offSrc, cbCopy);
    23652395    return cbCopied == cbCopy ? VINF_SUCCESS : VERR_PDM_MEDIAEX_IOBUF_UNDERRUN;
    23662396}
     
    23742404    RT_NOREF(hIoReq);
    23752405    PLSILOGICDEVICE pTgtDev = RT_FROM_MEMBER(pInterface, LSILOGICDEVICE, IMediaExPort);
    2376     lsilogicR3ReqComplete(pTgtDev->CTX_SUFF(pLsiLogic), (PLSILOGICREQ)pvIoReqAlloc, rcReq);
     2406    PPDMDEVINS      pDevIns = pTgtDev->pDevIns;
     2407    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     2408    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     2409    lsilogicR3ReqComplete(pDevIns, pThis, pThisCC, (PLSILOGICREQ)pvIoReqAlloc, rcReq);
    23772410    return VINF_SUCCESS;
    23782411}
     
    23922425        {
    23932426            /* Make sure the request is not accounted for so the VM can suspend successfully. */
     2427            PPDMDEVINS pDevIns = pTgtDev->pDevIns;
     2428            PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    23942429            uint32_t cTasksActive = ASMAtomicDecU32(&pTgtDev->cOutstandingRequests);
    2395             if (!cTasksActive && pTgtDev->CTX_SUFF(pLsiLogic)->fSignalIdle)
    2396                 PDMDevHlpAsyncNotificationCompleted(pTgtDev->CTX_SUFF(pLsiLogic)->pDevInsR3);
     2430            if (!cTasksActive && pThis->fSignalIdle)
     2431                PDMDevHlpAsyncNotificationCompleted(pDevIns);
    23972432            break;
    23982433        }
     
    24122447{
    24132448    PLSILOGICDEVICE pTgtDev = RT_FROM_MEMBER(pInterface, LSILOGICDEVICE, IMediaExPort);
    2414     PLSILOGICSCSI pThis = pTgtDev->CTX_SUFF(pLsiLogic);
    2415 
    2416     if (pThis->pMediaNotify)
    2417     {
    2418         int rc = VMR3ReqCallNoWait(PDMDevHlpGetVM(pThis->CTX_SUFF(pDevIns)), VMCPUID_ANY,
    2419                                    (PFNRT)pThis->pMediaNotify->pfnEjected, 2,
    2420                                    pThis->pMediaNotify, pTgtDev->iLUN);
     2449    PPDMDEVINS      pDevIns = pTgtDev->pDevIns;
     2450    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     2451
     2452    if (pThisCC->pMediaNotify)
     2453    {
     2454        int rc = VMR3ReqCallNoWait(PDMDevHlpGetVM(pDevIns), VMCPUID_ANY,
     2455                                   (PFNRT)pThisCC->pMediaNotify->pfnEjected, 2,
     2456                                   pThisCC->pMediaNotify, pTgtDev->iLUN);
    24212457        AssertRC(rc);
    24222458    }
     
    24302466 * @returns VINF_SUCCESS if successful
    24312467 *          VERR_NOT_FOUND if the requested page could be found.
    2432  * @param   pThis         The LsiLogic controller instance data.
     2468 * @param   pThis         Pointer to the shared LsiLogic device state. data.
    24332469 * @param   pPages        The pages supported by the controller.
    24342470 * @param   u8PageNumber  Number of the page to get.
     
    24882524 * @returns VINF_SUCCESS if successful
    24892525 *          VERR_NOT_FOUND if the requested page could be found.
    2490  * @param   pThis         The LsiLogic controller instance data.
     2526 * @param   pThis         Pointer to the shared LsiLogic device state. data.
    24912527 * @param   pPages        The pages supported by the controller.
    24922528 * @param   u8PageNumber  Number of the page to get.
     
    25512587 * @returns VINF_SUCCESS if successful
    25522588 *          VERR_NOT_FOUND if the requested page could be found.
    2553  * @param   pThis         The LsiLogic controller instance data.
     2589 * @param   pThis         Pointer to the shared LsiLogic device state. data.
    25542590 * @param   pPages        The pages supported by the controller.
    25552591 * @param   u8PageNumber  Number of the page to get.
     
    26432679 * @returns VINF_SUCCESS if successful
    26442680 *          VERR_NOT_FOUND if the requested page could be found.
    2645  * @param   pThis         The LsiLogic controller instance data.
     2681 * @param   pThis         Pointer to the shared LsiLogic device state. data.
    26462682 * @param   pPages        The pages supported by the controller.
    26472683 * @param   u8PageNumber  Number of the page to get.
     
    26912727 * @returns VINF_SUCCESS if successful
    26922728 *          VERR_NOT_FOUND if the requested page could be found.
    2693  * @param   pThis         The LsiLogic controller instance data.
     2729 * @param   pThis         Pointer to the shared LsiLogic device state. data.
    26942730 * @param   pPages        The pages supported by the controller.
    26952731 * @param   u8Port        The port to retrieve the page for.
     
    27442780 * @returns VINF_SUCCESS if successful
    27452781 *          VERR_NOT_FOUND if the requested page could be found.
    2746  * @param   pThis         The LsiLogic controller instance data.
     2782 * @param   pThis         Pointer to the shared LsiLogic device state. data.
    27472783 * @param   pPages        The pages supported by the controller.
    27482784 * @param   u8Bus         The bus the device is on the page should be returned.
     
    27992835}
    28002836
    2801 static int lsilogicR3ConfigurationSASIOUnitPageGetFromNumber(PLSILOGICSCSI pThis,
    2802                                                              PMptConfigurationPagesSupported pPages,
     2837static int lsilogicR3ConfigurationSASIOUnitPageGetFromNumber(PMptConfigurationPagesSupported pPages,
    28032838                                                             uint8_t u8PageNumber,
    28042839                                                             PMptExtendedConfigurationPageHeader *ppPageHeader,
    28052840                                                             uint8_t **ppbPageData, size_t *pcbPage)
    28062841{
    2807     RT_NOREF(pThis);
    28082842    int rc = VINF_SUCCESS;
    28092843
     
    28372871}
    28382872
    2839 static int lsilogicR3ConfigurationSASPHYPageGetFromNumber(PLSILOGICSCSI pThis,
    2840                                                           PMptConfigurationPagesSupported pPages,
     2873static int lsilogicR3ConfigurationSASPHYPageGetFromNumber(PMptConfigurationPagesSupported pPages,
    28412874                                                          uint8_t u8PageNumber,
    28422875                                                          MptConfigurationPageAddress PageAddress,
     
    28442877                                                          uint8_t **ppbPageData, size_t *pcbPage)
    28452878{
    2846     RT_NOREF(pThis);
    28472879    int rc = VINF_SUCCESS;
    28482880    uint8_t uAddressForm = MPT_CONFIGURATION_PAGE_ADDRESS_GET_SAS_FORM(PageAddress);
     
    29012933}
    29022934
    2903 static int lsilogicR3ConfigurationSASDevicePageGetFromNumber(PLSILOGICSCSI pThis,
    2904                                                              PMptConfigurationPagesSupported pPages,
     2935static int lsilogicR3ConfigurationSASDevicePageGetFromNumber(PMptConfigurationPagesSupported pPages,
    29052936                                                             uint8_t u8PageNumber,
    29062937                                                             MptConfigurationPageAddress PageAddress,
     
    29082939                                                             uint8_t **ppbPageData, size_t *pcbPage)
    29092940{
    2910     RT_NOREF(pThis);
    29112941    int rc = VINF_SUCCESS;
    29122942    uint8_t uAddressForm = MPT_CONFIGURATION_PAGE_ADDRESS_GET_SAS_FORM(PageAddress);
     
    29973027 * @returns VINF_SUCCESS if successful
    29983028 *          VERR_NOT_FOUND if the requested page could be found.
    2999  * @param   pThis               Pointer to the LsiLogic device state.
     3029 * @param   pThisCC             Pointer to the ring-3 LsiLogic device state.
    30003030 * @param   pConfigurationReq   The configuration request.
    30013031 * @param   ppPageHeader        Where to return the pointer to the page header on success.
     
    30033033 * @param   pcbPage             Where to store the size of the page in bytes.
    30043034 */
    3005 static int lsilogicR3ConfigurationPageGetExtended(PLSILOGICSCSI pThis, PMptConfigurationRequest pConfigurationReq,
     3035static int lsilogicR3ConfigurationPageGetExtended(PLSILOGICSCSICC pThisCC, PMptConfigurationRequest pConfigurationReq,
    30063036                                                  PMptExtendedConfigurationPageHeader *ppPageHeader,
    30073037                                                  uint8_t **ppbPageData, size_t *pcbPage)
     
    30173047        case MPT_CONFIGURATION_PAGE_TYPE_EXTENDED_SASIOUNIT:
    30183048        {
    3019             rc = lsilogicR3ConfigurationSASIOUnitPageGetFromNumber(pThis,
    3020                                                                  pThis->pConfigurationPages,
    3021                                                                  pConfigurationReq->u8PageNumber,
    3022                                                                  ppPageHeader, ppbPageData, pcbPage);
     3049            rc = lsilogicR3ConfigurationSASIOUnitPageGetFromNumber(pThisCC->pConfigurationPages,
     3050                                                                   pConfigurationReq->u8PageNumber,
     3051                                                                   ppPageHeader, ppbPageData, pcbPage);
    30233052            break;
    30243053        }
    30253054        case MPT_CONFIGURATION_PAGE_TYPE_EXTENDED_SASPHYS:
    30263055        {
    3027             rc = lsilogicR3ConfigurationSASPHYPageGetFromNumber(pThis,
    3028                                                               pThis->pConfigurationPages,
    3029                                                               pConfigurationReq->u8PageNumber,
    3030                                                               pConfigurationReq->PageAddress,
    3031                                                               ppPageHeader, ppbPageData, pcbPage);
     3056            rc = lsilogicR3ConfigurationSASPHYPageGetFromNumber(pThisCC->pConfigurationPages,
     3057                                                                pConfigurationReq->u8PageNumber,
     3058                                                                pConfigurationReq->PageAddress,
     3059                                                                ppPageHeader, ppbPageData, pcbPage);
    30323060            break;
    30333061        }
    30343062        case MPT_CONFIGURATION_PAGE_TYPE_EXTENDED_SASDEVICE:
    30353063        {
    3036             rc = lsilogicR3ConfigurationSASDevicePageGetFromNumber(pThis,
    3037                                                                  pThis->pConfigurationPages,
    3038                                                                  pConfigurationReq->u8PageNumber,
    3039                                                                  pConfigurationReq->PageAddress,
    3040                                                                  ppPageHeader, ppbPageData, pcbPage);
     3064            rc = lsilogicR3ConfigurationSASDevicePageGetFromNumber(pThisCC->pConfigurationPages,
     3065                                                                   pConfigurationReq->u8PageNumber,
     3066                                                                   pConfigurationReq->PageAddress,
     3067                                                                   ppPageHeader, ppbPageData, pcbPage);
    30413068            break;
    30423069        }
     
    30543081 *
    30553082 * @returns VBox status code.
    3056  * @param   pThis               Pointer to the LsiLogic device state.
     3083 * @param   pDevIns             The device instance.
     3084 * @param   pThis               Pointer to the shared LsiLogic device state.
     3085 * @param   pThisCC             Pointer to the ring-3 LsiLogic device state.
    30573086 * @param   pConfigurationReq   Pointer to the request structure.
    30583087 * @param   pReply              Pointer to the reply message frame
    30593088 */
    3060 static int lsilogicR3ProcessConfigurationRequest(PLSILOGICSCSI pThis, PMptConfigurationRequest pConfigurationReq,
    3061                                                  PMptConfigurationReply pReply)
     3089static int lsilogicR3ProcessConfigurationRequest(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC,
     3090                                                 PMptConfigurationRequest pConfigurationReq, PMptConfigurationReply pReply)
    30623091{
    30633092    int                                 rc             = VINF_SUCCESS;
     
    30933122            /* Get the page data. */
    30943123            rc = lsilogicR3ConfigurationIOUnitPageGetFromNumber(pThis,
    3095                                                               pThis->pConfigurationPages,
     3124                                                                pThisCC->pConfigurationPages,
     3125                                                                pConfigurationReq->u8PageNumber,
     3126                                                                &pPageHeader, &pbPageData, &cbPage);
     3127            break;
     3128        }
     3129        case MPT_CONFIGURATION_PAGE_TYPE_IOC:
     3130        {
     3131            /* Get the page data. */
     3132            rc = lsilogicR3ConfigurationIOCPageGetFromNumber(pThis,
     3133                                                             pThisCC->pConfigurationPages,
     3134                                                             pConfigurationReq->u8PageNumber,
     3135                                                             &pPageHeader, &pbPageData, &cbPage);
     3136            break;
     3137        }
     3138        case MPT_CONFIGURATION_PAGE_TYPE_MANUFACTURING:
     3139        {
     3140            /* Get the page data. */
     3141            rc = lsilogicR3ConfigurationManufacturingPageGetFromNumber(pThis,
     3142                                                                       pThisCC->pConfigurationPages,
     3143                                                                       pConfigurationReq->u8PageNumber,
     3144                                                                       &pPageHeader, &pbPageData, &cbPage);
     3145            break;
     3146        }
     3147        case MPT_CONFIGURATION_PAGE_TYPE_SCSI_SPI_PORT:
     3148        {
     3149            /* Get the page data. */
     3150            rc = lsilogicR3ConfigurationSCSISPIPortPageGetFromNumber(pThis,
     3151                                                                     pThisCC->pConfigurationPages,
     3152                                                                     pConfigurationReq->PageAddress.MPIPortNumber.u8PortNumber,
     3153                                                                     pConfigurationReq->u8PageNumber,
     3154                                                                     &pPageHeader, &pbPageData, &cbPage);
     3155            break;
     3156        }
     3157        case MPT_CONFIGURATION_PAGE_TYPE_SCSI_SPI_DEVICE:
     3158        {
     3159            /* Get the page data. */
     3160            rc = lsilogicR3ConfigurationSCSISPIDevicePageGetFromNumber(pThis,
     3161                                                                       pThisCC->pConfigurationPages,
     3162                                                                       pConfigurationReq->PageAddress.BusAndTargetId.u8Bus,
     3163                                                                       pConfigurationReq->PageAddress.BusAndTargetId.u8TargetID,
     3164                                                                       pConfigurationReq->u8PageNumber,
     3165                                                                       &pPageHeader, &pbPageData, &cbPage);
     3166            break;
     3167        }
     3168        case MPT_CONFIGURATION_PAGE_TYPE_BIOS:
     3169        {
     3170            rc = lsilogicR3ConfigurationBiosPageGetFromNumber(pThis,
     3171                                                              pThisCC->pConfigurationPages,
    30963172                                                              pConfigurationReq->u8PageNumber,
    30973173                                                              &pPageHeader, &pbPageData, &cbPage);
    30983174            break;
    30993175        }
    3100         case MPT_CONFIGURATION_PAGE_TYPE_IOC:
    3101         {
    3102             /* Get the page data. */
    3103             rc = lsilogicR3ConfigurationIOCPageGetFromNumber(pThis,
    3104                                                            pThis->pConfigurationPages,
    3105                                                            pConfigurationReq->u8PageNumber,
    3106                                                            &pPageHeader, &pbPageData, &cbPage);
    3107             break;
    3108         }
    3109         case MPT_CONFIGURATION_PAGE_TYPE_MANUFACTURING:
    3110         {
    3111             /* Get the page data. */
    3112             rc = lsilogicR3ConfigurationManufacturingPageGetFromNumber(pThis,
    3113                                                                      pThis->pConfigurationPages,
    3114                                                                      pConfigurationReq->u8PageNumber,
    3115                                                                      &pPageHeader, &pbPageData, &cbPage);
    3116             break;
    3117         }
    3118         case MPT_CONFIGURATION_PAGE_TYPE_SCSI_SPI_PORT:
    3119         {
    3120             /* Get the page data. */
    3121             rc = lsilogicR3ConfigurationSCSISPIPortPageGetFromNumber(pThis,
    3122                                                                    pThis->pConfigurationPages,
    3123                                                                    pConfigurationReq->PageAddress.MPIPortNumber.u8PortNumber,
    3124                                                                    pConfigurationReq->u8PageNumber,
    3125                                                                    &pPageHeader, &pbPageData, &cbPage);
    3126             break;
    3127         }
    3128         case MPT_CONFIGURATION_PAGE_TYPE_SCSI_SPI_DEVICE:
    3129         {
    3130             /* Get the page data. */
    3131             rc = lsilogicR3ConfigurationSCSISPIDevicePageGetFromNumber(pThis,
    3132                                                                      pThis->pConfigurationPages,
    3133                                                                      pConfigurationReq->PageAddress.BusAndTargetId.u8Bus,
    3134                                                                      pConfigurationReq->PageAddress.BusAndTargetId.u8TargetID,
    3135                                                                      pConfigurationReq->u8PageNumber,
    3136                                                                      &pPageHeader, &pbPageData, &cbPage);
    3137             break;
    3138         }
    3139         case MPT_CONFIGURATION_PAGE_TYPE_BIOS:
    3140         {
    3141             rc = lsilogicR3ConfigurationBiosPageGetFromNumber(pThis,
    3142                                                             pThis->pConfigurationPages,
    3143                                                             pConfigurationReq->u8PageNumber,
    3144                                                             &pPageHeader, &pbPageData, &cbPage);
    3145             break;
    3146         }
    31473176        case MPT_CONFIGURATION_PAGE_TYPE_EXTENDED:
    31483177        {
    3149             rc = lsilogicR3ConfigurationPageGetExtended(pThis,
    3150                                                       pConfigurationReq,
    3151                                                       &pExtPageHeader, &pbPageData, &cbPage);
     3178            rc = lsilogicR3ConfigurationPageGetExtended(pThisCC,
     3179                                                        pConfigurationReq,
     3180                                                        &pExtPageHeader, &pbPageData, &cbPage);
    31523181            break;
    31533182        }
     
    32123241                    GCPhysAddrPageBuffer |= (uint64_t)pConfigurationReq->SimpleSGElement.u32DataBufferAddressHigh << 32;
    32133242
    3214                 PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhysAddrPageBuffer, pbPageData, RT_MIN(cbBuffer, cbPage));
     3243                PDMDevHlpPCIPhysWrite(pDevIns, GCPhysAddrPageBuffer, pbPageData, RT_MIN(cbBuffer, cbPage));
    32153244            }
    32163245            break;
     
    32283257                LogFlow(("cbBuffer=%u cbPage=%u\n", cbBuffer, cbPage));
    32293258
    3230                 PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), GCPhysAddrPageBuffer, pbPageData,
     3259                PDMDevHlpPhysRead(pDevIns, GCPhysAddrPageBuffer, pbPageData,
    32313260                                  RT_MIN(cbBuffer, cbPage));
    32323261            }
     
    32443273 *
    32453274 * @returns nothing
    3246  * @param   pThis       Pointer to the LsiLogic device state.
    3247  */
    3248 static void lsilogicR3InitializeConfigurationPagesSpi(PLSILOGICSCSI pThis)
    3249 {
    3250     PMptConfigurationPagesSpi pPages = &pThis->pConfigurationPages->u.SpiPages;
     3275 * @param   pThis       Pointer to the shared LsiLogic device state.
     3276 * @param   pThisCC     Pointer to the ring-3 LsiLogic device state.
     3277 */
     3278static void lsilogicR3InitializeConfigurationPagesSpi(PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC)
     3279{
     3280    PMptConfigurationPagesSpi pPages = &pThisCC->pConfigurationPages->u.SpiPages;
    32513281
    32523282    AssertMsg(pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI, ("Controller is not the SPI SCSI one\n"));
     
    33353365 *
    33363366 * @returns the handle.
    3337  * @param   pThis       Pointer to the LsiLogic device state.
     3367 * @param   pThis       Pointer to the shared LsiLogic device state.
    33383368 */
    33393369DECLINLINE(uint16_t) lsilogicGetHandle(PLSILOGICSCSI pThis)
     
    33683398 *
    33693399 * @returns nothing
    3370  * @param   pThis       Pointer to the LsiLogic device state.
    3371  */
    3372 static void lsilogicR3InitializeConfigurationPagesSas(PLSILOGICSCSI pThis)
    3373 {
    3374     PMptConfigurationPagesSas pPages = &pThis->pConfigurationPages->u.SasPages;
     3400 * @param   pThis       Pointer to the shared LsiLogic device state.
     3401 * @param   pThisCC     Pointer to the ring-3 LsiLogic device state.
     3402 */
     3403static void lsilogicR3InitializeConfigurationPagesSas(PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC)
     3404{
     3405    PMptConfigurationPagesSas pPages = &pThisCC->pConfigurationPages->u.SasPages;
    33753406
    33763407    AssertMsg(pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS, ("Controller is not the SAS SCSI one\n"));
     
    34803511
    34813512        /* Settings for present devices. */
    3482         if (pThis->paDeviceStates[i].pDrvBase)
     3513        if (pThisCC->paDeviceStates[i].pDrvBase)
    34833514        {
    34843515            uint16_t u16DeviceHandle = lsilogicGetHandle(pThis);
     
    35643595 *
    35653596 * @returns nothing
    3566  * @param   pThis       Pointer to the LsiLogic device state.
    3567  */
    3568 static void lsilogicR3InitializeConfigurationPages(PLSILOGICSCSI pThis)
     3597 * @param   pDevIns     The device instance.
     3598 * @param   pThis       Pointer to the shared LsiLogic device state.
     3599 * @param   pThisCC     Pointer to the ring-3 LsiLogic device state.
     3600 */
     3601static void lsilogicR3InitializeConfigurationPages(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC)
    35693602{
    35703603    /* Initialize the common pages. */
    35713604    PMptConfigurationPagesSupported pPages = (PMptConfigurationPagesSupported)RTMemAllocZ(sizeof(MptConfigurationPagesSupported));
    3572 
    3573     pThis->pConfigurationPages = pPages;
     3605    /** @todo r=bird: Missing alloc failure check.   Why do we allocate this
     3606     *        structure? It's fixed size... */
     3607
     3608    pThisCC->pConfigurationPages = pPages;
    35743609
    35753610    LogFlowFunc(("pThis=%#p\n", pThis));
     
    36823717    pPages->IOUnitPage2.u.fields.aAdapterOrder[0].fAdapterEmbedded = true;
    36833718    pPages->IOUnitPage2.u.fields.aAdapterOrder[0].u8PCIBusNumber = 0;
    3684     pPages->IOUnitPage2.u.fields.aAdapterOrder[0].u8PCIDevFn     = pThis->CTX_SUFF(pDevIns)->apPciDevs[0]->uDevFn;
     3719    pPages->IOUnitPage2.u.fields.aAdapterOrder[0].u8PCIDevFn     = pDevIns->apPciDevs[0]->uDevFn;
    36853720
    36863721    /* I/O Unit page 3. */
     
    37693804
    37703805    if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
    3771         lsilogicR3InitializeConfigurationPagesSpi(pThis);
     3806        lsilogicR3InitializeConfigurationPagesSpi(pThis, pThisCC);
    37723807    else if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    3773         lsilogicR3InitializeConfigurationPagesSas(pThis);
     3808        lsilogicR3InitializeConfigurationPagesSas(pThis, pThisCC);
    37743809    else
    37753810        AssertMsgFailed(("Invalid controller type %d\n", pThis->enmCtrlType));
     
    37813816 * @returns VBox status code.
    37823817 *
    3783  * @param   pThis           Pointer to the LsiLogic device state.
     3818 * @param   pThis           Pointer to the shared LsiLogic device state.
    37843819 * @param   pcszCtrlType    The string to use.
    37853820 */
     
    38093844{
    38103845    RT_NOREF(pvUser, cb);
    3811     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     3846    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
    38123847
    38133848    ASSERT_GUEST(cb == 1);
    38143849
    3815     int rc = vboxscsiReadRegister(&pThis->VBoxSCSI, offPort, pu32);
     3850    int rc = vboxscsiReadRegister(&pThisCC->VBoxSCSI, offPort, pu32);
    38163851    AssertMsg(rc == VINF_SUCCESS, ("Unexpected BIOS register read status: %Rrc\n", rc));
    38173852
     
    38253860 *
    38263861 * @returns VBox status code.
    3827  * @param   pThis       Pointer to the LsiLogic device state.
    3828  */
    3829 static int lsilogicR3PrepareBiosScsiRequest(PLSILOGICSCSI pThis)
     3862 * @param   pThis       Pointer to the shared LsiLogic device state.
     3863 */
     3864static int lsilogicR3PrepareBiosScsiRequest(PLSILOGICSCSI pThis, PLSILOGICSCSICC pThisCC)
    38303865{
    38313866    int rc;
     
    38363871    size_t cbBuf;
    38373872
    3838     rc = vboxscsiSetupRequest(&pThis->VBoxSCSI, &uLun, &pbCdb, &cbCdb, &cbBuf, &uTargetDevice);
     3873    rc = vboxscsiSetupRequest(&pThisCC->VBoxSCSI, &uLun, &pbCdb, &cbCdb, &cbBuf, &uTargetDevice);
    38393874    AssertMsgRCReturn(rc, ("Setting up SCSI request failed rc=%Rrc\n", rc), rc);
    38403875
    38413876    if (   uTargetDevice < pThis->cDeviceStates
    3842         && pThis->paDeviceStates[uTargetDevice].pDrvBase)
    3843     {
    3844         PLSILOGICDEVICE pTgtDev = &pThis->paDeviceStates[uTargetDevice];
     3877        && pThisCC->paDeviceStates[uTargetDevice].pDrvBase)
     3878    {
     3879        PLSILOGICDEVICE pTgtDev = &pThisCC->paDeviceStates[uTargetDevice];
    38453880        PDMMEDIAEXIOREQ hIoReq;
    38463881        PLSILOGICREQ pReq;
     
    38633898            uint8_t u8ScsiSts = pReq->u8ScsiSts;
    38643899            pTgtDev->pDrvMediaEx->pfnIoReqFree(pTgtDev->pDrvMediaEx, pReq->hIoReq);
    3865             rc = vboxscsiRequestFinished(&pThis->VBoxSCSI, u8ScsiSts);
     3900            rc = vboxscsiRequestFinished(&pThisCC->VBoxSCSI, u8ScsiSts);
    38663901        }
    38673902        else if (rc == VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS)
     
    38813916    ScsiInquiryData.u3PeripheralQualifier = SCSI_INQUIRY_DATA_PERIPHERAL_QUALIFIER_NOT_CONNECTED_NOT_SUPPORTED;
    38823917
    3883     memcpy(pThis->VBoxSCSI.pbBuf, &ScsiInquiryData, 5);
    3884 
    3885     rc = vboxscsiRequestFinished(&pThis->VBoxSCSI, SCSI_STATUS_OK);
     3918    memcpy(pThisCC->VBoxSCSI.pbBuf, &ScsiInquiryData, 5);
     3919
     3920    rc = vboxscsiRequestFinished(&pThisCC->VBoxSCSI, SCSI_STATUS_OK);
    38863921    AssertMsgRCReturn(rc, ("Finishing BIOS SCSI request failed rc=%Rrc\n", rc), rc);
    38873922
     
    38953930lsilogicR3IsaIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT offPort, uint32_t u32, unsigned cb)
    38963931{
     3932    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     3933    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     3934    Log2(("#%d %s: pvUser=%#p cb=%d u32=%#x offPort=%#x\n", pDevIns->iInstance, __FUNCTION__, pvUser, cb, u32, offPort));
    38973935    RT_NOREF(pvUser, cb);
    3898     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    3899     Log2(("#%d %s: pvUser=%#p cb=%d u32=%#x offPort=%#x\n", pDevIns->iInstance, __FUNCTION__, pvUser, cb, u32, offPort));
    39003936
    39013937    ASSERT_GUEST(cb == 1);
     
    39083944        return VINF_SUCCESS;
    39093945
    3910     int rc = vboxscsiWriteRegister(&pThis->VBoxSCSI, offPort, (uint8_t)u32);
     3946    int rc = vboxscsiWriteRegister(&pThisCC->VBoxSCSI, offPort, (uint8_t)u32);
    39113947    if (rc == VERR_MORE_DATA)
    39123948    {
     
    39303966                                                              uint8_t const *pbSrc, uint32_t *pcTransfers, unsigned cb)
    39313967{
     3968    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     3969    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     3970    Log2(("#%d %s: pvUser=%#p cb=%d offPort=%#x\n", pDevIns->iInstance, __FUNCTION__, pvUser, cb, offPort));
    39323971    RT_NOREF(pvUser);
    3933     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    3934     Log2(("#%d %s: pvUser=%#p cb=%d offPort=%#x\n", pDevIns->iInstance, __FUNCTION__, pvUser, cb, offPort));
    3935 
    3936     int rc = vboxscsiWriteString(pDevIns, &pThis->VBoxSCSI, offPort, pbSrc, pcTransfers, cb);
     3972
     3973    int rc = vboxscsiWriteString(pDevIns, &pThisCC->VBoxSCSI, offPort, pbSrc, pcTransfers, cb);
    39373974    if (rc == VERR_MORE_DATA)
    39383975    {
     
    39403977        /* Notify the worker thread that there are pending requests. */
    39413978        LogFlowFunc(("Signal event semaphore\n"));
    3942         rc = PDMDevHlpSUPSemEventSignal(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess);
     3979        rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtProcess);
    39433980        AssertRC(rc);
    39443981    }
     
    39563993                                                             uint8_t *pbDst, uint32_t *pcTransfers, unsigned cb)
    39573994{
     3995    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     3996    LogFlowFunc(("#%d %s: pvUser=%#p cb=%d offPort=%#x\n", pDevIns->iInstance, __FUNCTION__, pvUser, cb, offPort));
    39583997    RT_NOREF(pvUser);
    3959     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    3960     LogFlowFunc(("#%d %s: pvUser=%#p cb=%d offPort=%#x\n", pDevIns->iInstance, __FUNCTION__, pvUser, cb, offPort));
    3961 
    3962     int rc = vboxscsiReadString(pDevIns, &pThis->VBoxSCSI, offPort, pbDst, pcTransfers, cb);
     3998
     3999    int rc = vboxscsiReadString(pDevIns, &pThisCC->VBoxSCSI, offPort, pbDst, pcTransfers, cb);
    39634000    AssertMsg(rc == VINF_SUCCESS, ("Unexpected BIOS register read status: %Rrc\n", rc));
    39644001    return rc;
     
    39704007static DECLCALLBACK(void) lsilogicR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    39714008{
    3972     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    3973     bool          fVerbose = false;
     4009    PLSILOGICSCSI   pThis    = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4010    PLSILOGICSCSICC pThisCC  = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
    39744011
    39754012    /*
    39764013     * Parse args.
    39774014     */
    3978     if (pszArgs)
    3979         fVerbose = strstr(pszArgs, "verbose") != NULL;
     4015    bool const fVerbose = pszArgs && strstr(pszArgs, "verbose") != NULL;
    39804016
    39814017    /*
     
    39844020    pHlp->pfnPrintf(pHlp,
    39854021                    "%s#%d: port=%04x mmio=%RGp max-devices=%u GC=%RTbool R0=%RTbool\n",
    3986                     pDevIns->pReg->szName,
    3987                     pDevIns->iInstance,
     4022                    pDevIns->pReg->szName, pDevIns->iInstance,
    39884023                    PDMDevHlpIoPortGetMappingAddress(pDevIns, pThis->hIoPortsReg),
    39894024                    PDMDevHlpMmioGetMappingAddress(pDevIns, pThis->hMmioReg),
    3990                     pThis->cDeviceStates,
    3991                     pThis->fGCEnabled ? true : false,
    3992                     pThis->fR0Enabled ? true : false);
     4025                    pThis->cDeviceStates, pDevIns->fRCEnabled, pDevIns->fR0Enabled);
    39934026
    39944027    /*
     
    40474080    for (unsigned i = 0; i < pThis->cDeviceStates; i++)
    40484081    {
    4049         PLSILOGICDEVICE pDevice = &pThis->paDeviceStates[i];
     4082        PLSILOGICDEVICE pDevice = &pThisCC->paDeviceStates[i];
    40504083
    40514084        pHlp->pfnPrintf(pHlp, "\n");
     
    40574090
    40584091
    4059 /* The worker thread. */
     4092/**
     4093 * @callback_method_impl{FNPDMTHREADDEV}
     4094 */
    40604095static DECLCALLBACK(int) lsilogicR3Worker(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
    40614096{
    4062     PLSILOGICSCSI pThis = (PLSILOGICSCSI)pThread->pvUser;
    4063     int rc = VINF_SUCCESS;
     4097    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4098    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     4099    int             rc      = VINF_SUCCESS;
    40644100
    40654101    if (pThread->enmState == PDMTHREADSTATE_INITIALIZING)
     
    40734109        {
    40744110            Assert(ASMAtomicReadBool(&pThis->fWrkThreadSleeping));
    4075             rc = PDMDevHlpSUPSemEventWaitNoResume(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess, RT_INDEFINITE_WAIT);
     4111            rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->hEvtProcess, RT_INDEFINITE_WAIT);
    40764112            AssertLogRelMsgReturn(RT_SUCCESS(rc) || rc == VERR_INTERRUPTED, ("%Rrc\n", rc), rc);
    40774113            if (RT_UNLIKELY(pThread->enmState != PDMTHREADSTATE_RUNNING))
     
    40864122        if (ASMAtomicReadBool(&pThis->fBiosReqPending))
    40874123        {
    4088             rc = lsilogicR3PrepareBiosScsiRequest(pThis);
     4124            rc = lsilogicR3PrepareBiosScsiRequest(pThis, pThisCC);
    40894125            AssertRC(rc);
    40904126            ASMAtomicXchgBool(&pThis->fBiosReqPending, false);
     
    41574193                if (GuestRequest.Header.u8Function == MPT_MESSAGE_HDR_FUNCTION_SCSI_IO_REQUEST)
    41584194                {
    4159                    rc = lsilogicR3ProcessSCSIIORequest(pThis, GCPhysMessageFrameAddr, &GuestRequest);
     4195                   rc = lsilogicR3ProcessSCSIIORequest(pDevIns, pThis, pThisCC, GCPhysMessageFrameAddr, &GuestRequest);
    41604196                   AssertRC(rc);
    41614197                }
     
    41634199                {
    41644200                    MptReplyUnion Reply;
    4165                     rc = lsilogicR3ProcessMessageRequest(pThis, &GuestRequest.Header, &Reply);
     4201                    rc = lsilogicR3ProcessMessageRequest(pDevIns, pThis, pThisCC, &GuestRequest.Header, &Reply);
    41664202                    AssertRC(rc);
    41674203                }
     
    41784214
    41794215/**
    4180  * Unblock the worker thread so it can respond to a state change.
    4181  *
    4182  * @returns VBox status code.
    4183  * @param   pDevIns     The pcnet device instance.
    4184  * @param   pThread     The send thread.
     4216 * @callback_method_impl{FNPDMTHREADWAKEUPDEV}
    41854217 */
    41864218static DECLCALLBACK(int) lsilogicR3WorkerWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
     
    41884220    RT_NOREF(pThread);
    41894221    PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    4190     return PDMDevHlpSUPSemEventSignal(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess);
     4222    return PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtProcess);
    41914223}
    41924224
     
    41974229 *
    41984230 * @returns nothing.
    4199  * @param   pThis       Pointer to the LsiLogic device state.
    4200  */
    4201 static void lsilogicR3Kick(PLSILOGICSCSI pThis)
     4231 * @param   pDevIns     The device instance.
     4232 * @param   pThis       Pointer to the shared LsiLogic device state.
     4233 */
     4234static void lsilogicR3Kick(PPDMDEVINS pDevIns, PLSILOGICSCSI pThis)
    42024235{
    42034236    if (pThis->fNotificationSent)
     
    42054238        /* Notify the worker thread that there are pending requests. */
    42064239        LogFlowFunc(("Signal event semaphore\n"));
    4207         int rc = PDMDevHlpSUPSemEventSignal(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess);
     4240        int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtProcess);
    42084241        AssertRC(rc);
    42094242    }
     
    42214254{
    42224255    RT_NOREF(uPass);
    4223     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    4224     PCPDMDEVHLPR3 pHlp  = pDevIns->pHlpR3;
     4256    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4257    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     4258    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
    42254259
    42264260    pHlp->pfnSSMPutU32(pSSM, pThis->enmCtrlType);
     
    42304264    /* Save the device config. */
    42314265    for (unsigned i = 0; i < pThis->cDeviceStates; i++)
    4232         pHlp->pfnSSMPutBool(pSSM, pThis->paDeviceStates[i].pDrvBase != NULL);
     4266        pHlp->pfnSSMPutBool(pSSM, pThisCC->paDeviceStates[i].pDrvBase != NULL);
    42334267
    42344268    return VINF_SSM_DONT_CALL_AGAIN;
     
    42404274static DECLCALLBACK(int) lsilogicR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    42414275{
    4242     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    4243     PCPDMDEVHLPR3 pHlp  = pDevIns->pHlpR3;
     4276    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4277    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     4278    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
    42444279
    42454280    /* Every device first. */
     
    42474282    for (unsigned i = 0; i < pThis->cDeviceStates; i++)
    42484283    {
    4249         PLSILOGICDEVICE pDevice = &pThis->paDeviceStates[i];
     4284        PLSILOGICDEVICE pDevice = &pThisCC->paDeviceStates[i];
    42504285
    42514286        AssertMsg(!pDevice->cOutstandingRequests,
     
    42794314                    {
    42804315                        AssertMsg(!pReq->pRedoNext, ("Only one BIOS task can be active!\n"));
    4281                         vboxscsiSetRequestRedo(&pThis->VBoxSCSI);
     4316                        vboxscsiSetRequestRedo(&pThisCC->VBoxSCSI);
    42824317                    }
    42834318
     
    43374372    /* Save diagnostic memory register and data regions. */
    43384373    pHlp->pfnSSMPutU32(pSSM, pThis->u32DiagMemAddr);
    4339     pHlp->pfnSSMPutU32(pSSM, lsilogicR3MemRegionsCount(pThis));
     4374    pHlp->pfnSSMPutU32(pSSM, lsilogicR3MemRegionsCount(pThisCC));
    43404375
    43414376    PLSILOGICMEMREGN pIt;
    4342     RTListForEach(&pThis->ListMemRegns, pIt, LSILOGICMEMREGN, NodeList)
     4377    RTListForEach(&pThisCC->ListMemRegns, pIt, LSILOGICMEMREGN, NodeList)
    43434378    {
    43444379        pHlp->pfnSSMPutU32(pSSM, pIt->u32AddrStart);
     
    43474382    }
    43484383
    4349     PMptConfigurationPagesSupported pPages = pThis->pConfigurationPages;
     4384    PMptConfigurationPagesSupported pPages = pThisCC->pConfigurationPages;
    43504385
    43514386    pHlp->pfnSSMPutMem(pSSM, &pPages->ManufacturingPage0, sizeof(MptConfigurationPageManufacturing0));
     
    44264461        AssertMsgFailed(("Invalid controller type %d\n", pThis->enmCtrlType));
    44274462
    4428     vboxscsiR3SaveExec(pHlp, &pThis->VBoxSCSI, pSSM);
     4463    vboxscsiR3SaveExec(pHlp, &pThisCC->VBoxSCSI, pSSM);
    44294464    return pHlp->pfnSSMPutU32(pSSM, UINT32_MAX);
    44304465}
     
    44384473    PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    44394474
    4440     lsilogicR3Kick(pThis);
     4475    lsilogicR3Kick(pDevIns, pThis);
    44414476    return VINF_SUCCESS;
    44424477}
     
    44474482static DECLCALLBACK(int) lsilogicR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    44484483{
    4449     PLSILOGICSCSI   pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    4450     PCPDMDEVHLPR3   pHlp  = pDevIns->pHlpR3;
     4484    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4485    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     4486    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
    44514487    int             rc;
    44524488
     
    44864522            rc = pHlp->pfnSSMGetBool(pSSM, &fPresent);
    44874523            AssertRCReturn(rc, rc);
    4488             if (fPresent != (pThis->paDeviceStates[i].pDrvBase != NULL))
     4524            if (fPresent != (pThisCC->paDeviceStates[i].pDrvBase != NULL))
    44894525                return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, N_("Target %u config mismatch: config=%RTbool state=%RTbool"),
    4490                                                i, pThis->paDeviceStates[i].pDrvBase != NULL, fPresent);
     4526                                               i, pThisCC->paDeviceStates[i].pDrvBase != NULL, fPresent);
    44914527        }
    44924528    }
     
    44974533    for (unsigned i = 0; i < pThis->cDeviceStates; i++)
    44984534    {
    4499         PLSILOGICDEVICE pDevice = &pThis->paDeviceStates[i];
     4535        PLSILOGICDEVICE pDevice = &pThisCC->paDeviceStates[i];
    45004536
    45014537        AssertMsg(!pDevice->cOutstandingRequests,
     
    45684604    pHlp->pfnSSMGetU32V(pSSM, &pThis->uRequestQueueNextAddressRead);
    45694605
    4570     PMptConfigurationPagesSupported pPages = pThis->pConfigurationPages;
     4606    PMptConfigurationPagesSupported pPages = pThisCC->pConfigurationPages;
    45714607
    45724608    if (uVersion <= LSILOGIC_SAVED_STATE_VERSION_PRE_SAS)
     
    46444680                    pRegion->u32AddrEnd = u32AddrEnd;
    46454681                    pHlp->pfnSSMGetMem(pSSM, &pRegion->au32Data[0], cRegion * sizeof(uint32_t));
    4646                     lsilogicR3MemRegionInsert(pThis, pRegion);
    4647                     pThis->cbMemRegns += cRegion * sizeof(uint32_t);
     4682                    lsilogicR3MemRegionInsert(pThisCC, pRegion);
     4683                    pThisCC->cbMemRegns += cRegion * sizeof(uint32_t);
    46484684                }
    46494685                else
     
    47624798    }
    47634799
    4764     rc = vboxscsiR3LoadExec(pHlp, &pThis->VBoxSCSI, pSSM);
     4800    rc = vboxscsiR3LoadExec(pHlp, &pThisCC->VBoxSCSI, pSSM);
    47654801    if (RT_FAILURE(rc))
    47664802    {
     
    48304866static DECLCALLBACK(int) lsilogicR3StatusQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
    48314867{
    4832     PLSILOGICSCSI pThis = RT_FROM_MEMBER(pInterface, LSILOGICSCSI, ILeds);
     4868    PLSILOGICSCSICC pThisCC = RT_FROM_MEMBER(pInterface, LSILOGICSCSICC, ILeds);
     4869    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pThisCC->pDevIns, PLSILOGICSCSI);
    48334870    if (iLUN < pThis->cDeviceStates)
    48344871    {
    4835         *ppLed = &pThis->paDeviceStates[iLUN].Led;
     4872        *ppLed = &pThisCC->paDeviceStates[iLUN].Led;
    48364873        Assert((*ppLed)->u32Magic == PDMLED_MAGIC);
    48374874        return VINF_SUCCESS;
     
    48454882static DECLCALLBACK(void *) lsilogicR3StatusQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    48464883{
    4847     PLSILOGICSCSI pThis = RT_FROM_MEMBER(pInterface, LSILOGICSCSI, IBase);
    4848     PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
    4849     PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->ILeds);
     4884    PLSILOGICSCSICC pThisCC = RT_FROM_MEMBER(pInterface, LSILOGICSCSICC, IBase);
     4885    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->IBase);
     4886    PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThisCC->ILeds);
    48504887    return NULL;
    48514888}
     
    48664903static bool lsilogicR3AllAsyncIOIsFinished(PPDMDEVINS pDevIns)
    48674904{
    4868     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4905    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4906    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
    48694907
    48704908    for (uint32_t i = 0; i < pThis->cDeviceStates; i++)
    48714909    {
    4872         PLSILOGICDEVICE pThisDevice = &pThis->paDeviceStates[i];
     4910        PLSILOGICDEVICE pThisDevice = &pThisCC->paDeviceStates[i];
    48734911        if (pThisDevice->pDrvBase)
    48744912        {
     
    49004938static void lsilogicR3SuspendOrPowerOff(PPDMDEVINS pDevIns)
    49014939{
    4902     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4940    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4941    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
    49034942
    49044943    ASMAtomicWriteBool(&pThis->fSignalIdle, true);
     
    49144953    for (uint32_t i = 0; i < pThis->cDeviceStates; i++)
    49154954    {
    4916         PLSILOGICDEVICE pThisDevice = &pThis->paDeviceStates[i];
     4955        PLSILOGICDEVICE pThisDevice = &pThisCC->paDeviceStates[i];
    49174956        if (pThisDevice->pDrvMediaEx)
    49184957            pThisDevice->pDrvMediaEx->pfnNotifySuspend(pThisDevice->pDrvMediaEx);
     
    49384977    Log(("lsilogicR3Resume\n"));
    49394978
    4940     lsilogicR3Kick(pThis);
     4979    lsilogicR3Kick(pDevIns, pThis);
    49414980}
    49424981
     
    49494988static DECLCALLBACK(void) lsilogicR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    49504989{
     4990    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4991    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     4992    Log(("%s: iLUN=%#x\n", __FUNCTION__, iLUN));
    49514993    RT_NOREF(fFlags);
    4952     PLSILOGICSCSI   pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    4953     PLSILOGICDEVICE pDevice = &pThis->paDeviceStates[iLUN];
     4994
     4995    AssertMsg(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG, ("LsiLogic: Device does not support hotplugging\n"));
    49544996
    49554997    if (iLUN >= pThis->cDeviceStates)
    49564998        return;
    4957 
    4958     AssertMsg(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,
    4959               ("LsiLogic: Device does not support hotplugging\n"));
    4960 
    4961     Log(("%s:\n", __FUNCTION__));
    49624999
    49635000    /*
    49645001     * Zero some important members.
    49655002     */
     5003    PLSILOGICDEVICE pDevice = &pThisCC->paDeviceStates[iLUN];
    49665004    pDevice->pDrvBase = NULL;
    49675005    pDevice->pDrvMedia = NULL;
     
    49745012static DECLCALLBACK(int)  lsilogicR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    49755013{
    4976     PLSILOGICSCSI   pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    4977     PLSILOGICDEVICE pDevice = &pThis->paDeviceStates[iLUN];
     5014    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     5015    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     5016    PLSILOGICDEVICE pDevice = &pThisCC->paDeviceStates[iLUN];
    49785017    int rc;
    49795018
     
    50335072static void lsilogicR3ResetCommon(PPDMDEVINS pDevIns)
    50345073{
    5035     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     5074    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     5075    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
    50365076    int rc;
    50375077
    5038     rc = lsilogicR3HardReset(pThis);
     5078    rc = lsilogicR3HardReset(pDevIns, pThis, pThisCC);
    50395079    AssertRC(rc);
    50405080
    5041     vboxscsiInitialize(&pThis->VBoxSCSI);
     5081    vboxscsiInitialize(&pThisCC->VBoxSCSI);
    50425082}
    50435083
     
    50765116
    50775117/**
    5078  * @interface_method_impl{PDMDEVREG,pfnRelocate}
    5079  */
    5080 static DECLCALLBACK(void) lsilogicR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    5081 {
    5082     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    5083     pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    5084     RT_NOREF(offDelta);
    5085 }
    5086 
    5087 /**
    50885118 * @interface_method_impl{PDMDEVREG,pfnPowerOff}
    50895119 */
     
    51005130{
    51015131    PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
    5102     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     5132    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     5133    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
    51035134
    51045135    PDMDevHlpCritSectDelete(pDevIns, &pThis->ReplyFreeQueueCritSect);
     
    51075138    PDMDevHlpCritSectDelete(pDevIns, &pThis->ReplyFreeQueueWriteCritSect);
    51085139
    5109     RTMemFree(pThis->paDeviceStates);
    5110     pThis->paDeviceStates = NULL;
     5140    RTMemFree(pThisCC->paDeviceStates);
     5141    pThisCC->paDeviceStates = NULL;
    51115142
    51125143    if (pThis->hEvtProcess != NIL_SUPSEMEVENT)
    51135144    {
    5114         PDMDevHlpSUPSemEventClose(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess);
     5145        PDMDevHlpSUPSemEventClose(pDevIns, pThis->hEvtProcess);
    51155146        pThis->hEvtProcess = NIL_SUPSEMEVENT;
    51165147    }
    51175148
    5118     lsilogicR3ConfigurationPagesFree(pThis);
    5119     lsilogicR3MemRegionsFree(pThis);
     5149    lsilogicR3ConfigurationPagesFree(pThis, pThisCC);
     5150    lsilogicR3MemRegionsFree(pThisCC);
    51205151
    51215152    return VINF_SUCCESS;
     
    51285159{
    51295160    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    5130     PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    5131     PCPDMDEVHLPR3 pHlp  = pDevIns->pHlpR3;
    5132     int           rc    = VINF_SUCCESS;
     5161    PLSILOGICSCSI   pThis   = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
     5162    PLSILOGICSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PLSILOGICSCSICC);
     5163    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
     5164    int             rc      = VINF_SUCCESS;
    51335165
    51345166    /*
     
    51375169    pThis->hEvtProcess = NIL_SUPSEMEVENT;
    51385170    pThis->fBiosReqPending = false;
    5139     RTListInit(&pThis->ListMemRegns);
     5171    RTListInit(&pThisCC->ListMemRegns);
    51405172    pThis->hMmioReg = NIL_IOMMMIOHANDLE;
    51415173    pThis->hMmioDiag = NIL_IOMMMIOHANDLE;
    51425174    pThis->hIoPortsReg = NIL_IOMIOPORTHANDLE;
    51435175    pThis->hIoPortsBios = NIL_IOMIOPORTHANDLE;
     5176    pThisCC->pDevIns = pDevIns;
     5177    pThisCC->IBase.pfnQueryInterface = lsilogicR3StatusQueryInterface;
     5178    pThisCC->ILeds.pfnQueryStatusLed = lsilogicR3StatusQueryStatusLed;
     5179
    51445180
    51455181    /*
     
    51535189                                  "Bootable",
    51545190                                  "");
    5155 
    5156     pThis->fGCEnabled = pDevIns->fRCEnabled;
    5157     pThis->fR0Enabled = pDevIns->fR0Enabled;
    51585191
    51595192    rc = pHlp->pfnCFGMQueryU32Def(pCfg, "ReplyQueueDepth",
     
    52475280    PDMPciDevSetCapabilityList(pPciDev,         0x80);
    52485281# endif
    5249 
    5250     pThis->pDevInsR3 = pDevIns;
    5251     pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    5252     pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    5253     pThis->IBase.pfnQueryInterface = lsilogicR3StatusQueryInterface;
    5254     pThis->ILeds.pfnQueryStatusLed = lsilogicR3StatusQueryStatusLed;
    52555282
    52565283    /*
     
    53675394     * Create event semaphore and worker thread.
    53685395     */
    5369     rc = PDMDevHlpThreadCreate(pDevIns, &pThis->pThreadWrk, pThis, lsilogicR3Worker,
     5396    rc = PDMDevHlpThreadCreate(pDevIns, &pThisCC->pThreadWrk, pThis, lsilogicR3Worker,
    53705397                               lsilogicR3WorkerWakeUp, 0, RTTHREADTYPE_IO, szDevTag);
    53715398    if (RT_FAILURE(rc))
     
    53735400                                   N_("LsiLogic: Failed to create worker thread %s"), szDevTag);
    53745401
    5375     rc = PDMDevHlpSUPSemEventCreate(pThis->CTX_SUFF(pDevIns), &pThis->hEvtProcess);
     5402    rc = PDMDevHlpSUPSemEventCreate(pDevIns, &pThis->hEvtProcess);
    53765403    if (RT_FAILURE(rc))
    53775404        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
     
    53815408     * Allocate device states.
    53825409     */
    5383     pThis->paDeviceStates = (PLSILOGICDEVICE)RTMemAllocZ(sizeof(LSILOGICDEVICE) * pThis->cDeviceStates);
    5384     if (!pThis->paDeviceStates)
     5410    pThisCC->paDeviceStates = (PLSILOGICDEVICE)RTMemAllocZ(sizeof(LSILOGICDEVICE) * pThis->cDeviceStates);
     5411    if (!pThisCC->paDeviceStates)
    53855412        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to allocate memory for device states"));
    53865413
    53875414    for (unsigned i = 0; i < pThis->cDeviceStates; i++)
    53885415    {
    5389         PLSILOGICDEVICE pDevice = &pThis->paDeviceStates[i];
     5416        PLSILOGICDEVICE pDevice = &pThisCC->paDeviceStates[i];
    53905417
    53915418        /* Initialize static parts of the device. */
    53925419        pDevice->iLUN                                    = i;
    5393         pDevice->pLsiLogicR3                             = pThis;
     5420        pDevice->pDevIns                                 = pDevIns;
    53945421        pDevice->Led.u32Magic                            = PDMLED_MAGIC;
    53955422        pDevice->IBase.pfnQueryInterface                 = lsilogicR3DeviceQueryInterface;
     
    54035430        pDevice->IMediaExPort.pfnMediumEjected           = lsilogicR3MediumEjected;
    54045431        pDevice->ILed.pfnQueryStatusLed                  = lsilogicR3DeviceQueryStatusLed;
    5405 
    5406         char *pszName;
    5407         if (RTStrAPrintf(&pszName, "Device%u", i) <= 0)
    5408             AssertLogRelFailedReturn(VERR_NO_MEMORY);
     5432        RTStrPrintf(pDevice->szName, sizeof(pDevice->szName), "Device%u", i);
    54095433
    54105434        /* Attach SCSI driver. */
    5411         rc = PDMDevHlpDriverAttach(pDevIns, pDevice->iLUN, &pDevice->IBase, &pDevice->pDrvBase, pszName);
     5435        rc = PDMDevHlpDriverAttach(pDevIns, pDevice->iLUN, &pDevice->IBase, &pDevice->pDrvBase, pDevice->szName);
    54125436        if (RT_SUCCESS(rc))
    54135437        {
     
    54345458            pDevice->pDrvBase = NULL;
    54355459            rc = VINF_SUCCESS;
    5436             Log(("LsiLogic: no driver attached to device %s\n", pszName));
     5460            Log(("LsiLogic: no driver attached to device %s\n", pDevice->szName));
    54375461        }
    54385462        else
    54395463        {
    5440             AssertLogRelMsgFailed(("LsiLogic: Failed to attach %s\n", pszName));
     5464            AssertLogRelMsgFailed(("LsiLogic: Failed to attach %s\n", pDevice->szName));
    54415465            return rc;
    54425466        }
     
    54475471     */
    54485472    PPDMIBASE pBase;
    5449     rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis->IBase, &pBase, "Status Port");
     5473    rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThisCC->IBase, &pBase, "Status Port");
    54505474    if (RT_SUCCESS(rc))
    54515475    {
    5452         pThis->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
    5453         pThis->pMediaNotify = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIANOTIFY);
     5476        pThisCC->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
     5477        pThisCC->pMediaNotify = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIANOTIFY);
    54545478    }
    54555479    else
     
    54595483
    54605484    /* Initialize the SCSI emulation for the BIOS. */
    5461     rc = vboxscsiInitialize(&pThis->VBoxSCSI);
     5485    rc = vboxscsiInitialize(&pThisCC->VBoxSCSI);
    54625486    AssertRC(rc);
    54635487
     
    55045528
    55055529    /* Perform hard reset. */
    5506     rc = lsilogicR3HardReset(pThis);
     5530    rc = lsilogicR3HardReset(pDevIns, pThis, pThisCC);
    55075531    AssertRC(rc);
    55085532
     
    55475571    /* .uReserved0 = */             0,
    55485572    /* .szName = */                 "lsilogicscsi",
    5549     /* .fFlags = */                 PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ |
    5550                                     PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION | PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION,
     5573    /* .fFlags = */                 PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_NEW_STYLE
     5574                                    | PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION | PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION,
    55515575    /* .fClass = */                 PDM_DEVREG_CLASS_STORAGE,
    55525576    /* .cMaxInstances = */          ~0U,
    55535577    /* .uSharedVersion = */         42,
    55545578    /* .cbInstanceShared = */       sizeof(LSILOGICSCSI),
    5555     /* .cbInstanceCC = */           0,
    5556     /* .cbInstanceRC = */           0,
     5579    /* .cbInstanceCC = */           sizeof(LSILOGICSCSICC),
     5580    /* .cbInstanceRC = */           sizeof(LSILOGICSCSIRC),
    55575581    /* .cMaxPciDevices = */         1,
    55585582    /* .cMaxMsixVectors = */        0,
     
    55635587    /* .pfnConstruct = */           lsilogicR3Construct,
    55645588    /* .pfnDestruct = */            lsilogicR3Destruct,
    5565     /* .pfnRelocate = */            lsilogicR3Relocate,
     5589    /* .pfnRelocate = */            NULL,
    55665590    /* .pfnMemSetup = */            NULL,
    55675591    /* .pfnPowerOn = */             NULL,
     
    56285652    /* .uSharedVersion = */         42,
    56295653    /* .cbInstanceShared = */       sizeof(LSILOGICSCSI),
    5630     /* .cbInstanceCC = */           0,
    5631     /* .cbInstanceRC = */           0,
     5654    /* .cbInstanceCC = */           sizeof(LSILOGICSCSICC),
     5655    /* .cbInstanceRC = */           sizeof(LSILOGICSCSIRC),
    56325656    /* .cMaxPciDevices = */         1,
    56335657    /* .cMaxMsixVectors = */        0,
     
    56385662    /* .pfnConstruct = */           lsilogicR3Construct,
    56395663    /* .pfnDestruct = */            lsilogicR3Destruct,
    5640     /* .pfnRelocate = */            lsilogicR3Relocate,
     5664    /* .pfnRelocate = */            NULL,
    56415665    /* .pfnMemSetup = */            NULL,
    56425666    /* .pfnPowerOn = */             NULL,
Note: See TracChangeset for help on using the changeset viewer.

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