VirtualBox

Changeset 44694 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Feb 14, 2013 6:49:30 PM (12 years ago)
Author:
vboxsync
Message:

DevLsiLogicSCSI.cpp: Fixed a number of missing DECLCALLBACKS. Marked ring-3 methods with R3 in the prefix. Use pThis instead of pLsiLogic like most other devices. Doxygen cleanups. Maybe one or two other things.

File:
1 edited

Legend:

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

    r44571 r44694  
    11/* $Id$ */
    22/** @file
    3  * VBox storage devices: LsiLogic LSI53c1030 SCSI controller.
     3 * DevLsiLogicSCSI - LsiLogic LSI53c1030 SCSI controller.
    44 */
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 //#define DEBUG
     18/*******************************************************************************
     19*   Header Files                                                               *
     20*******************************************************************************/
    1921#define LOG_GROUP LOG_GROUP_DEV_LSILOGICSCSI
    2022#include <VBox/vmm/pdmdev.h>
     
    3840#include "VBoxDD.h"
    3941
     42
     43/*******************************************************************************
     44*   Defined Constants And Macros                                               *
     45*******************************************************************************/
    4046/** The current saved state version. */
    4147#define LSILOGIC_SAVED_STATE_VERSION          3
     
    4955#define MAX_REL_LOG_ERRORS 1024
    5056
     57#define LSILOGIC_RTGCPHYS_FROM_U32(Hi, Lo)         ( (RTGCPHYS)RT_MAKE_U64(Lo, Hi) )
     58
     59
     60/*******************************************************************************
     61*   Structures and Typedefs                                                    *
     62*******************************************************************************/
    5163/**
    5264 * Reply data.
     
    6274    /** Different views to the reply depending on the request type. */
    6375    MptReplyUnion Reply;
    64 } LSILOGICSCSIREPLY, *PLSILOGICSCSIREPLY;
     76} LSILOGICSCSIREPLY;
     77/** Pointer to reply data. */
     78typedef LSILOGICSCSIREPLY *PLSILOGICSCSIREPLY;
    6579
    6680/**
     
    7791
    7892    /** LUN of the device. */
    79     RTUINT                        iLUN;
     93    uint32_t                      iLUN;
    8094    /** Number of outstanding tasks on the port. */
    8195    volatile uint32_t             cOutstandingRequests;
     
    98112    PDMLED                        Led;
    99113
    100 } LSILOGICDEVICE, *PLSILOGICDEVICE;
     114} LSILOGICDEVICE;
     115/** Pointer to a device state. */
     116typedef LSILOGICDEVICE *PLSILOGICDEVICE;
    101117
    102118/** Pointer to a task state. */
     
    104120
    105121/**
    106  * Device instance data for the emulated
    107  * SCSI controller.
     122 * Device instance data for the emulated SCSI controller.
    108123 */
    109124typedef struct LSILOGICSCSI
     
    154169
    155170    /** Number of device states allocated. */
    156     uint32_t                   cDeviceStates;
     171    uint32_t             cDeviceStates;
    157172
    158173#if HC_ARCH_BITS == 64
     
    295310    R3PTRTYPE(volatile PLSILOGICTASKSTATE) pTasksRedoHead;
    296311
    297 } LSILOGISCSI, *PLSILOGICSCSI;
     312} LSILOGISCSI;
     313/** Pointer to the device instance data of the LsiLogic emulation. */
     314typedef LSILOGICSCSI *PLSILOGICSCSI;
    298315
    299316/**
     
    321338        RTGCPHYS        GCPhysAddrBufferUnaligned;
    322339    } u;
    323 } LSILOGICTASKSTATESGENTRY, *PLSILOGICTASKSTATESGENTRY;
     340} LSILOGICTASKSTATESGENTRY;
     341/** Pointer to a scatter/gather list entry. */
     342typedef LSILOGICTASKSTATESGENTRY *PLSILOGICTASKSTATESGENTRY;
    324343
    325344/**
     
    368387} LSILOGICTASKSTATE;
    369388
     389
    370390#ifndef VBOX_DEVICE_STRUCT_TESTCASE
    371391
     392/*******************************************************************************
     393*   Internal Functions                                                         *
     394*******************************************************************************/
    372395RT_C_DECLS_BEGIN
    373396#ifdef IN_RING3
    374 static void lsilogicInitializeConfigurationPages(PLSILOGICSCSI pLsiLogic);
    375 static void lsilogicConfigurationPagesFree(PLSILOGICSCSI pThis);
    376 static int lsilogicProcessConfigurationRequest(PLSILOGICSCSI pLsiLogic, PMptConfigurationRequest pConfigurationReq,
    377                                                PMptConfigurationReply pReply);
     397static void lsilogicR3InitializeConfigurationPages(PLSILOGICSCSI pThis);
     398static void lsilogicR3ConfigurationPagesFree(PLSILOGICSCSI pThis);
     399static int  lsilogicR3ProcessConfigurationRequest(PLSILOGICSCSI pThis, PMptConfigurationRequest pConfigurationReq,
     400                                                  PMptConfigurationReply pReply);
    378401#endif
    379402RT_C_DECLS_END
    380403
    381 #define PDMIBASE_2_PLSILOGICDEVICE(pInterface)     ( (PLSILOGICDEVICE)((uintptr_t)(pInterface) - RT_OFFSETOF(LSILOGICDEVICE, IBase)) )
    382 #define PDMISCSIPORT_2_PLSILOGICDEVICE(pInterface) ( (PLSILOGICDEVICE)((uintptr_t)(pInterface) - RT_OFFSETOF(LSILOGICDEVICE, ISCSIPort)) )
    383 #define PDMILEDPORTS_2_PLSILOGICDEVICE(pInterface) ( (PLSILOGICDEVICE)((uintptr_t)(pInterface) - RT_OFFSETOF(LSILOGICDEVICE, ILed)) )
    384 #define LSILOGIC_RTGCPHYS_FROM_U32(Hi, Lo)         ( (RTGCPHYS)RT_MAKE_U64(Lo, Hi) )
    385 #define PDMIBASE_2_PLSILOGICSCSI(pInterface)       ( (PLSILOGICSCSI)((uintptr_t)(pInterface) - RT_OFFSETOF(LSILOGICSCSI, IBase)) )
    386 #define PDMILEDPORTS_2_PLSILOGICSCSI(pInterface)   ( (PLSILOGICSCSI)((uintptr_t)(pInterface) - RT_OFFSETOF(LSILOGICSCSI, ILeds)) )
    387 
     404
     405/*******************************************************************************
     406*   Global Variables                                                           *
     407*******************************************************************************/
    388408/** Key sequence the guest has to write to enable access
    389409 * to diagnostic memory. */
     
    394414 *
    395415 * @returns nothing.
    396  * @param   pThis    Pointer to the device instance data.
     416 * @param   pThis       Pointer to the LsiLogic device state.
    397417 */
    398418static void lsilogicUpdateInterrupt(PLSILOGICSCSI pThis)
     
    424444 *
    425445 * @returns nothing.
    426  * @param   pLsiLogic    Pointer to the device instance.
    427  * @param   uStatus      The status bit to set.
    428  */
    429 DECLINLINE(void) lsilogicSetInterrupt(PLSILOGICSCSI pLsiLogic, uint32_t uStatus)
    430 {
    431     ASMAtomicOrU32(&pLsiLogic->uInterruptStatus, uStatus);
    432     lsilogicUpdateInterrupt(pLsiLogic);
     446 * @param   pThis       Pointer to the LsiLogic device state.
     447 * @param   uStatus     The status bit to set.
     448 */
     449DECLINLINE(void) lsilogicSetInterrupt(PLSILOGICSCSI pThis, uint32_t uStatus)
     450{
     451    ASMAtomicOrU32(&pThis->uInterruptStatus, uStatus);
     452    lsilogicUpdateInterrupt(pThis);
    433453}
    434454
     
    438458 *
    439459 * @returns nothing.
    440  * @param   pLsiLogic    Pointer to the device instance.
    441  * @param   uStatus      The status bit to set.
    442  */
    443 DECLINLINE(void) lsilogicClearInterrupt(PLSILOGICSCSI pLsiLogic, uint32_t uStatus)
    444 {
    445     ASMAtomicAndU32(&pLsiLogic->uInterruptStatus, ~uStatus);
    446     lsilogicUpdateInterrupt(pLsiLogic);
     460 * @param   pThis       Pointer to the LsiLogic device state.
     461 * @param   uStatus     The status bit to set.
     462 */
     463DECLINLINE(void) lsilogicClearInterrupt(PLSILOGICSCSI pThis, uint32_t uStatus)
     464{
     465    ASMAtomicAndU32(&pThis->uInterruptStatus, ~uStatus);
     466    lsilogicUpdateInterrupt(pThis);
    447467}
    448468
     
    451471 *
    452472 * @returns nothing
    453  * @param   pLsiLogic        Pointer to the controller device instance.
    454  * @param   uIOCFaultCode    Fault code to set.
    455  */
    456 DECLINLINE(void) lsilogicSetIOCFaultCode(PLSILOGICSCSI pLsiLogic, uint16_t uIOCFaultCode)
    457 {
    458     if (pLsiLogic->enmState != LSILOGICSTATE_FAULT)
     473 * @param   pThis           Pointer to the LsiLogic device state.
     474 * @param   uIOCFaultCode   Fault code to set.
     475 */
     476DECLINLINE(void) lsilogicSetIOCFaultCode(PLSILOGICSCSI pThis, uint16_t uIOCFaultCode)
     477{
     478    if (pThis->enmState != LSILOGICSTATE_FAULT)
    459479    {
    460480        Log(("%s: Setting I/O controller into FAULT state: uIOCFaultCode=%u\n", __FUNCTION__, uIOCFaultCode));
    461         pLsiLogic->enmState        = LSILOGICSTATE_FAULT;
    462         pLsiLogic->u16IOCFaultCode = uIOCFaultCode;
     481        pThis->enmState        = LSILOGICSTATE_FAULT;
     482        pThis->u16IOCFaultCode = uIOCFaultCode;
    463483    }
    464484    else
     
    469489
    470490#ifdef IN_RING3
     491
    471492/**
    472493 * Performs a hard reset on the controller.
    473494 *
    474495 * @returns VBox status code.
    475  * @param   pThis    Pointer to the device instance to initialize.
    476  */
    477 static int lsilogicHardReset(PLSILOGICSCSI pThis)
     496 * @param   pThis       Pointer to the LsiLogic device state.
     497 */
     498static int lsilogicR3HardReset(PLSILOGICSCSI pThis)
    478499{
    479500    pThis->enmState = LSILOGICSTATE_RESET;
     
    504525    /** @todo: Put stuff to reset here. */
    505526
    506     lsilogicConfigurationPagesFree(pThis);
    507     lsilogicInitializeConfigurationPages(pThis);
     527    lsilogicR3ConfigurationPagesFree(pThis);
     528    lsilogicR3InitializeConfigurationPages(pThis);
    508529
    509530    /* Mark that we finished performing the reset. */
     
    518539 * @param pThis    The LsiLogic controller instance
    519540 */
    520 static void lsilogicConfigurationPagesFree(PLSILOGICSCSI pThis)
     541static void lsilogicR3ConfigurationPagesFree(PLSILOGICSCSI pThis)
    521542{
    522543
     
    554575 *
    555576 * @returns nothing
    556  * @param   pLsiLogic            Pointer to the device instance
    557  * @param   u32MessageContext    The message context ID to post.
    558  */
    559 static void lsilogicFinishContextReply(PLSILOGICSCSI pLsiLogic, uint32_t u32MessageContext)
     577 * @param   pThis               Pointer to the LsiLogic device state.
     578 * @param   u32MessageContext   The message context ID to post.
     579 */
     580static void lsilogicR3FinishContextReply(PLSILOGICSCSI pThis, uint32_t u32MessageContext)
    560581{
    561582    int rc;
    562583
    563     LogFlowFunc(("pLsiLogic=%#p u32MessageContext=%#x\n", pLsiLogic, u32MessageContext));
    564 
    565     AssertMsg(!pLsiLogic->fDoorbellInProgress, ("We are in a doorbell function\n"));
     584    LogFlowFunc(("pThis=%#p u32MessageContext=%#x\n", pThis, u32MessageContext));
     585
     586    AssertMsg(!pThis->fDoorbellInProgress, ("We are in a doorbell function\n"));
    566587
    567588    /* Write message context ID into reply post queue. */
    568     rc = PDMCritSectEnter(&pLsiLogic->ReplyPostQueueCritSect, VINF_SUCCESS);
     589    rc = PDMCritSectEnter(&pThis->ReplyPostQueueCritSect, VINF_SUCCESS);
    569590    AssertRC(rc);
    570591
    571 #if 0
     592# if 0
    572593    /* Check for a entry in the queue. */
    573     if (RT_UNLIKELY(pLsiLogic->uReplyPostQueueNextAddressRead != pLsiLogic->uReplyPostQueueNextEntryFreeWrite))
     594    if (RT_UNLIKELY(pThis->uReplyPostQueueNextAddressRead != pThis->uReplyPostQueueNextEntryFreeWrite))
    574595    {
    575596        /* Set error code. */
    576         lsilogicSetIOCFaultCode(pLsiLogic, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
    577         PDMCritSectLeave(&pLsiLogic->ReplyPostQueueCritSect);
     597        lsilogicSetIOCFaultCode(pThis, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
     598        PDMCritSectLeave(&pThis->ReplyPostQueueCritSect);
    578599        return;
    579600    }
    580 #endif
     601# endif
    581602
    582603    /* We have a context reply. */
    583     ASMAtomicWriteU32(&pLsiLogic->CTX_SUFF(pReplyPostQueueBase)[pLsiLogic->uReplyPostQueueNextEntryFreeWrite], u32MessageContext);
    584     ASMAtomicIncU32(&pLsiLogic->uReplyPostQueueNextEntryFreeWrite);
    585     pLsiLogic->uReplyPostQueueNextEntryFreeWrite %= pLsiLogic->cReplyQueueEntries;
     604    ASMAtomicWriteU32(&pThis->CTX_SUFF(pReplyPostQueueBase)[pThis->uReplyPostQueueNextEntryFreeWrite], u32MessageContext);
     605    ASMAtomicIncU32(&pThis->uReplyPostQueueNextEntryFreeWrite);
     606    pThis->uReplyPostQueueNextEntryFreeWrite %= pThis->cReplyQueueEntries;
    586607
    587608    /* Set interrupt. */
    588     lsilogicSetInterrupt(pLsiLogic, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
    589 
    590     PDMCritSectLeave(&pLsiLogic->ReplyPostQueueCritSect);
    591 }
    592 
    593 static void lsilogicTaskStateClear(PLSILOGICTASKSTATE pTaskState)
     609    lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
     610
     611    PDMCritSectLeave(&pThis->ReplyPostQueueCritSect);
     612}
     613
     614static void lsilogicR3TaskStateClear(PLSILOGICTASKSTATE pTaskState)
    594615{
    595616    RTMemFree(pTaskState->pSGListHead);
     
    607628}
    608629
    609 static int lsilogicTaskStateCtor(RTMEMCACHE hMemCache, void *pvObj, void *pvUser)
     630/**
     631 * @callback_method_impl{FNMEMCACHECTOR}
     632 */
     633static DECLCALLBACK(int) lsilogicR3TaskStateCtor(RTMEMCACHE hMemCache, void *pvObj, void *pvUser)
    610634{
    611635    memset(pvObj, 0, sizeof(LSILOGICTASKSTATE));
     
    613637}
    614638
    615 static void lsilogicTaskStateDtor(RTMEMCACHE hMemCache, void *pvObj, void *pvUser)
     639/**
     640 * @callback_method_impl{FNMEMCACHEDTOR}
     641 */
     642static DECLCALLBACK(void) lsilogicR3TaskStateDtor(RTMEMCACHE hMemCache, void *pvObj, void *pvUser)
    616643{
    617644    PLSILOGICTASKSTATE pTaskState = (PLSILOGICTASKSTATE)pvObj;
    618     lsilogicTaskStateClear(pTaskState);
     645    lsilogicR3TaskStateClear(pTaskState);
    619646}
    620647
     
    625652 *
    626653 * @returns nothing
    627  * @param   pLsiLogic       Pointer to the device instance
     654 * @param   pThis           Pointer to the LsiLogic device state.
    628655 * @param   pReply          Pointer to the reply message.
    629656 * @param   fForceReplyFifo Flag whether the use of the reply post fifo is forced.
    630657 */
    631 static void lsilogicFinishAddressReply(PLSILOGICSCSI pLsiLogic, PMptReplyUnion pReply, bool fForceReplyFifo)
     658static void lsilogicFinishAddressReply(PLSILOGICSCSI pThis, PMptReplyUnion pReply, bool fForceReplyFifo)
    632659{
    633660    /*
     
    636663     * we are ready to send the reply.
    637664     */
    638     if (pLsiLogic->fDoorbellInProgress && !fForceReplyFifo)
     665    if (pThis->fDoorbellInProgress && !fForceReplyFifo)
    639666    {
    640667        /* Set size of the reply in 16bit words. The size in the reply is in 32bit dwords. */
    641         pLsiLogic->cReplySize = pReply->Header.u8MessageLength * 2;
    642         Log(("%s: cReplySize=%u\n", __FUNCTION__, pLsiLogic->cReplySize));
    643         pLsiLogic->uNextReplyEntryRead = 0;
    644         lsilogicSetInterrupt(pLsiLogic, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
     668        pThis->cReplySize = pReply->Header.u8MessageLength * 2;
     669        Log(("%s: cReplySize=%u\n", __FUNCTION__, pThis->cReplySize));
     670        pThis->uNextReplyEntryRead = 0;
     671        lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
    645672    }
    646673    else
     
    654681        int rc;
    655682        /* Grab a free reply message from the queue. */
    656         rc = PDMCritSectEnter(&pLsiLogic->ReplyFreeQueueCritSect, VINF_SUCCESS);
     683        rc = PDMCritSectEnter(&pThis->ReplyFreeQueueCritSect, VINF_SUCCESS);
    657684        AssertRC(rc);
    658685
    659686#if 0
    660687        /* Check for a free reply frame. */
    661         if (RT_UNLIKELY(pLsiLogic->uReplyFreeQueueNextAddressRead != pLsiLogic->uReplyFreeQueueNextEntryFreeWrite))
     688        if (RT_UNLIKELY(pThis->uReplyFreeQueueNextAddressRead != pThis->uReplyFreeQueueNextEntryFreeWrite))
    662689        {
    663690            /* Set error code. */
    664             lsilogicSetIOCFaultCode(pLsiLogic, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
    665             PDMCritSectLeave(&pLsiLogic->ReplyFreeQueueCritSect);
     691            lsilogicSetIOCFaultCode(pThis, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
     692            PDMCritSectLeave(&pThis->ReplyFreeQueueCritSect);
    666693            return;
    667694        }
    668695#endif
    669696
    670         uint32_t u32ReplyFrameAddressLow = pLsiLogic->CTX_SUFF(pReplyFreeQueueBase)[pLsiLogic->uReplyFreeQueueNextAddressRead];
    671 
    672         pLsiLogic->uReplyFreeQueueNextAddressRead++;
    673         pLsiLogic->uReplyFreeQueueNextAddressRead %= pLsiLogic->cReplyQueueEntries;
    674 
    675         PDMCritSectLeave(&pLsiLogic->ReplyFreeQueueCritSect);
     697        uint32_t u32ReplyFrameAddressLow = pThis->CTX_SUFF(pReplyFreeQueueBase)[pThis->uReplyFreeQueueNextAddressRead];
     698
     699        pThis->uReplyFreeQueueNextAddressRead++;
     700        pThis->uReplyFreeQueueNextAddressRead %= pThis->cReplyQueueEntries;
     701
     702        PDMCritSectLeave(&pThis->ReplyFreeQueueCritSect);
    676703
    677704        /* Build 64bit physical address. */
    678         RTGCPHYS GCPhysReplyMessage = LSILOGIC_RTGCPHYS_FROM_U32(pLsiLogic->u32HostMFAHighAddr, u32ReplyFrameAddressLow);
    679         size_t cbReplyCopied = (pLsiLogic->cbReplyFrame < sizeof(MptReplyUnion)) ? pLsiLogic->cbReplyFrame : sizeof(MptReplyUnion);
     705        RTGCPHYS GCPhysReplyMessage = LSILOGIC_RTGCPHYS_FROM_U32(pThis->u32HostMFAHighAddr, u32ReplyFrameAddressLow);
     706        size_t cbReplyCopied = (pThis->cbReplyFrame < sizeof(MptReplyUnion)) ? pThis->cbReplyFrame : sizeof(MptReplyUnion);
    680707
    681708        /* Write reply to guest memory. */
    682         PDMDevHlpPhysWrite(pLsiLogic->CTX_SUFF(pDevIns), GCPhysReplyMessage, pReply, cbReplyCopied);
     709        PDMDevHlpPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhysReplyMessage, pReply, cbReplyCopied);
    683710
    684711        /* Write low 32bits of reply frame into post reply queue. */
    685         rc = PDMCritSectEnter(&pLsiLogic->ReplyPostQueueCritSect, VINF_SUCCESS);
     712        rc = PDMCritSectEnter(&pThis->ReplyPostQueueCritSect, VINF_SUCCESS);
    686713        AssertRC(rc);
    687714
    688715#if 0
    689716        /* Check for a entry in the queue. */
    690         if (RT_UNLIKELY(pLsiLogic->uReplyPostQueueNextAddressRead != pLsiLogic->uReplyPostQueueNextEntryFreeWrite))
     717        if (RT_UNLIKELY(pThis->uReplyPostQueueNextAddressRead != pThis->uReplyPostQueueNextEntryFreeWrite))
    691718        {
    692719            /* Set error code. */
    693             lsilogicSetIOCFaultCode(pLsiLogic, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
    694             PDMCritSectLeave(&pLsiLogic->ReplyPostQueueCritSect);
     720            lsilogicSetIOCFaultCode(pThis, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
     721            PDMCritSectLeave(&pThis->ReplyPostQueueCritSect);
    695722            return;
    696723        }
     
    698725
    699726        /* We have a address reply. Set the 31th bit to indicate that. */
    700         ASMAtomicWriteU32(&pLsiLogic->CTX_SUFF(pReplyPostQueueBase)[pLsiLogic->uReplyPostQueueNextEntryFreeWrite],
     727        ASMAtomicWriteU32(&pThis->CTX_SUFF(pReplyPostQueueBase)[pThis->uReplyPostQueueNextEntryFreeWrite],
    701728                          RT_BIT(31) | (u32ReplyFrameAddressLow >> 1));
    702         ASMAtomicIncU32(&pLsiLogic->uReplyPostQueueNextEntryFreeWrite);
    703         pLsiLogic->uReplyPostQueueNextEntryFreeWrite %= pLsiLogic->cReplyQueueEntries;
     729        ASMAtomicIncU32(&pThis->uReplyPostQueueNextEntryFreeWrite);
     730        pThis->uReplyPostQueueNextEntryFreeWrite %= pThis->cReplyQueueEntries;
    704731
    705732        if (fForceReplyFifo)
    706733        {
    707             pLsiLogic->fDoorbellInProgress = false;
    708             lsilogicSetInterrupt(pLsiLogic, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
     734            pThis->fDoorbellInProgress = false;
     735            lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_SYSTEM_DOORBELL);
    709736        }
    710737
    711738        /* Set interrupt. */
    712         lsilogicSetInterrupt(pLsiLogic, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
    713 
    714         PDMCritSectLeave(&pLsiLogic->ReplyPostQueueCritSect);
     739        lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
     740
     741        PDMCritSectLeave(&pThis->ReplyPostQueueCritSect);
    715742#else
    716743        AssertMsgFailed(("This is not allowed to happen.\n"));
     
    724751 *
    725752 * @returns VBox status code.
    726  * @param   pLsiLogic    Pointer to the device instance.
    727  * @param   pMessageHdr  Pointer to the message header of the request.
    728  * @param   pReply       Pointer to the reply.
    729  */
    730 static int lsilogicProcessMessageRequest(PLSILOGICSCSI pLsiLogic, PMptMessageHdr pMessageHdr, PMptReplyUnion pReply)
     753 * @param   pThis       Pointer to the LsiLogic device state.
     754 * @param   pMessageHdr Pointer to the message header of the request.
     755 * @param   pReply      Pointer to the reply.
     756 */
     757static int lsilogicR3ProcessMessageRequest(PLSILOGICSCSI pThis, PMptMessageHdr pMessageHdr, PMptReplyUnion pReply)
    731758{
    732759    int rc = VINF_SUCCESS;
    733760    bool fForceReplyPostFifo = false;
    734761
    735 #ifdef DEBUG
     762# ifdef LOG_ENABLED
    736763    if (pMessageHdr->u8Function < RT_ELEMENTS(g_apszMPTFunctionNames))
    737764        Log(("Message request function: %s\n", g_apszMPTFunctionNames[pMessageHdr->u8Function]));
    738765    else
    739766        Log(("Message request function: <unknown>\n"));
    740 #endif
     767# endif
    741768
    742769    memset(pReply, 0, sizeof(MptReplyUnion));
     
    766793
    767794            /* Update configuration values. */
    768             pLsiLogic->enmWhoInit             = (LSILOGICWHOINIT)pIOCInitReq->u8WhoInit;
    769             pLsiLogic->cbReplyFrame           = pIOCInitReq->u16ReplyFrameSize;
    770             pLsiLogic->cMaxBuses              = pIOCInitReq->u8MaxBuses;
    771             pLsiLogic->cMaxDevices            = pIOCInitReq->u8MaxDevices;
    772             pLsiLogic->u32HostMFAHighAddr     = pIOCInitReq->u32HostMfaHighAddr;
    773             pLsiLogic->u32SenseBufferHighAddr = pIOCInitReq->u32SenseBufferHighAddr;
    774 
    775             if (pLsiLogic->enmState == LSILOGICSTATE_READY)
     795            pThis->enmWhoInit             = (LSILOGICWHOINIT)pIOCInitReq->u8WhoInit;
     796            pThis->cbReplyFrame           = pIOCInitReq->u16ReplyFrameSize;
     797            pThis->cMaxBuses              = pIOCInitReq->u8MaxBuses;
     798            pThis->cMaxDevices            = pIOCInitReq->u8MaxDevices;
     799            pThis->u32HostMFAHighAddr     = pIOCInitReq->u32HostMfaHighAddr;
     800            pThis->u32SenseBufferHighAddr = pIOCInitReq->u32SenseBufferHighAddr;
     801
     802            if (pThis->enmState == LSILOGICSTATE_READY)
    776803            {
    777                 pLsiLogic->enmState = LSILOGICSTATE_OPERATIONAL;
     804                pThis->enmState = LSILOGICSTATE_OPERATIONAL;
    778805            }
    779806
    780807            /* Return reply. */
    781808            pReply->IOCInit.u8MessageLength = 5;
    782             pReply->IOCInit.u8WhoInit       = pLsiLogic->enmWhoInit;
    783             pReply->IOCInit.u8MaxDevices    = pLsiLogic->cMaxDevices;
    784             pReply->IOCInit.u8MaxBuses      = pLsiLogic->cMaxBuses;
     809            pReply->IOCInit.u8WhoInit       = pThis->enmWhoInit;
     810            pReply->IOCInit.u8MaxDevices    = pThis->cMaxDevices;
     811            pReply->IOCInit.u8MaxBuses      = pThis->cMaxBuses;
    785812            break;
    786813        }
     
    789816            pReply->IOCFacts.u8MessageLength      = 15;     /* 15 32bit dwords. */
    790817
    791             if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
     818            if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
    792819            {
    793820                pReply->IOCFacts.u16MessageVersion    = 0x0102; /* Version from the specification. */
    794                 pReply->IOCFacts.u8NumberOfPorts      = pLsiLogic->cPorts;
     821                pReply->IOCFacts.u8NumberOfPorts      = pThis->cPorts;
    795822            }
    796             else if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
     823            else if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    797824            {
    798825                pReply->IOCFacts.u16MessageVersion    = 0x0105; /* Version from the specification. */
    799                 pReply->IOCFacts.u8NumberOfPorts      = pLsiLogic->cPorts;
     826                pReply->IOCFacts.u8NumberOfPorts      = pThis->cPorts;
    800827            }
    801828            else
    802                 AssertMsgFailed(("Invalid controller type %d\n", pLsiLogic->enmCtrlType));
     829                AssertMsgFailed(("Invalid controller type %d\n", pThis->enmCtrlType));
    803830
    804831            pReply->IOCFacts.u8IOCNumber          = 0;      /* PCI function number. */
    805832            pReply->IOCFacts.u16IOCExceptions     = 0;
    806833            pReply->IOCFacts.u8MaxChainDepth      = LSILOGICSCSI_MAXIMUM_CHAIN_DEPTH;
    807             pReply->IOCFacts.u8WhoInit            = pLsiLogic->enmWhoInit;
     834            pReply->IOCFacts.u8WhoInit            = pThis->enmWhoInit;
    808835            pReply->IOCFacts.u8BlockSize          = 12;     /* Block size in 32bit dwords. This is the largest request we can get (SCSI I/O). */
    809836            pReply->IOCFacts.u8Flags              = 0;      /* Bit 0 is set if the guest must upload the FW prior to using the controller. Obviously not needed here. */
    810             pReply->IOCFacts.u16ReplyQueueDepth   = pLsiLogic->cReplyQueueEntries - 1; /* One entry is always free. */
     837            pReply->IOCFacts.u16ReplyQueueDepth   = pThis->cReplyQueueEntries - 1; /* One entry is always free. */
    811838            pReply->IOCFacts.u16RequestFrameSize  = 128;    /* @todo Figure out where it is needed. */
    812839            pReply->IOCFacts.u16ProductID         = 0xcafe; /* Our own product ID :) */
    813             pReply->IOCFacts.u32CurrentHostMFAHighAddr = pLsiLogic->u32HostMFAHighAddr;
    814             pReply->IOCFacts.u16GlobalCredits     = pLsiLogic->cRequestQueueEntries - 1; /* One entry is always free. */
     840            pReply->IOCFacts.u32CurrentHostMFAHighAddr = pThis->u32HostMFAHighAddr;
     841            pReply->IOCFacts.u16GlobalCredits     = pThis->cRequestQueueEntries - 1; /* One entry is always free. */
    815842
    816843            pReply->IOCFacts.u8EventState         = 0; /* Event notifications not enabled. */
    817             pReply->IOCFacts.u32CurrentSenseBufferHighAddr = pLsiLogic->u32SenseBufferHighAddr;
    818             pReply->IOCFacts.u16CurReplyFrameSize = pLsiLogic->cbReplyFrame;
    819             pReply->IOCFacts.u8MaxDevices         = pLsiLogic->cMaxDevices;
    820             pReply->IOCFacts.u8MaxBuses           = pLsiLogic->cMaxBuses;
     844            pReply->IOCFacts.u32CurrentSenseBufferHighAddr = pThis->u32SenseBufferHighAddr;
     845            pReply->IOCFacts.u16CurReplyFrameSize = pThis->cbReplyFrame;
     846            pReply->IOCFacts.u8MaxDevices         = pThis->cMaxDevices;
     847            pReply->IOCFacts.u8MaxBuses           = pThis->cMaxBuses;
    821848            pReply->IOCFacts.u32FwImageSize       = 0; /* No image needed. */
    822849            pReply->IOCFacts.u32FWVersion         = 0;
     
    830857            pReply->PortFacts.u8PortNumber    = pPortFactsReq->u8PortNumber;
    831858
    832             if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
     859            if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
    833860            {
    834861                /* This controller only supports one bus with bus number 0. */
    835                 if (pPortFactsReq->u8PortNumber >= pLsiLogic->cPorts)
     862                if (pPortFactsReq->u8PortNumber >= pThis->cPorts)
    836863                {
    837864                    pReply->PortFacts.u8PortType = 0; /* Not existant. */
     
    848875                }
    849876            }
    850             else if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
     877            else if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    851878            {
    852                 if (pPortFactsReq->u8PortNumber >= pLsiLogic->cPorts)
     879                if (pPortFactsReq->u8PortNumber >= pThis->cPorts)
    853880                {
    854881                    pReply->PortFacts.u8PortType = 0; /* Not existant. */
     
    857884                {
    858885                    pReply->PortFacts.u8PortType             = 0x30; /* SAS Port. */
    859                     pReply->PortFacts.u16MaxDevices          = pLsiLogic->cPorts;
     886                    pReply->PortFacts.u16MaxDevices          = pThis->cPorts;
    860887                    pReply->PortFacts.u16ProtocolFlags       = RT_BIT(3) | RT_BIT(0); /* SCSI initiator and LUN supported. */
    861                     pReply->PortFacts.u16PortSCSIID          = pLsiLogic->cPorts;
     888                    pReply->PortFacts.u16PortSCSIID          = pThis->cPorts;
    862889                    pReply->PortFacts.u16MaxPersistentIDs    = 0;
    863890                    pReply->PortFacts.u16MaxPostedCmdBuffers = 0; /* Only applies for target mode which we dont support. */
     
    866893            }
    867894            else
    868                 AssertMsgFailed(("Invalid controller type %d\n", pLsiLogic->enmCtrlType));
     895                AssertMsgFailed(("Invalid controller type %d\n", pThis->enmCtrlType));
    869896            break;
    870897        }
     
    886913
    887914            if (pEventNotificationReq->u8Switch)
    888                 pLsiLogic->fEventNotificationEnabled = true;
     915                pThis->fEventNotificationEnabled = true;
    889916            else
    890                 pLsiLogic->fEventNotificationEnabled = false;
     917                pThis->fEventNotificationEnabled = false;
    891918
    892919            pReply->EventNotification.u16EventDataLength = 1; /* 1 32bit D-Word. */
     
    896923            pReply->EventNotification.u32Event           = MPT_EVENT_EVENT_CHANGE;
    897924            pReply->EventNotification.u32EventContext    = 0;
    898             pReply->EventNotification.u32EventData       = pLsiLogic->fEventNotificationEnabled ? 1 : 0;
     925            pReply->EventNotification.u32EventData       = pThis->fEventNotificationEnabled ? 1 : 0;
    899926
    900927            break;
     
    909936            PMptConfigurationRequest pConfigurationReq = (PMptConfigurationRequest)pMessageHdr;
    910937
    911             rc = lsilogicProcessConfigurationRequest(pLsiLogic, pConfigurationReq, &pReply->Configuration);
     938            rc = lsilogicR3ProcessConfigurationRequest(pThis, pConfigurationReq, &pReply->Configuration);
    912939            AssertRC(rc);
    913940            break;
     
    938965    pReply->Header.u32MessageContext = pMessageHdr->u32MessageContext;
    939966
    940     lsilogicFinishAddressReply(pLsiLogic, pReply, fForceReplyPostFifo);
     967    lsilogicFinishAddressReply(pThis, pReply, fForceReplyPostFifo);
    941968    return rc;
    942969}
    943 #endif
     970#endif /* IN_RING3 */
    944971
    945972/**
     
    947974 *
    948975 * @returns VBox status code.
    949  * @param   pThis    Pointer to the LsiLogic SCSI controller instance data.
    950  * @param   uOffset  Offset of the register to write.
    951  * @param   pv       Pointer to the value to write
    952  * @param   cb       Number of bytes to write.
     976 * @param   pThis       Pointer to the LsiLogic device state.
     977 * @param   uOffset     Offset of the register to write.
     978 * @param   pv          Pointer to the value to write
     979 * @param   cb          Number of bytes to write.
    953980 */
    954981static int lsilogicRegisterWrite(PLSILOGICSCSI pThis, uint32_t uOffset, void const *pv, unsigned cb)
     
    10711098                if (pThis->iMessage == pThis->cMessage)
    10721099                {
    1073                     int rc = lsilogicProcessMessageRequest(pThis, (PMptMessageHdr)pThis->aMessage, &pThis->ReplyBuffer);
     1100                    int rc = lsilogicR3ProcessMessageRequest(pThis, (PMptMessageHdr)pThis->aMessage, &pThis->ReplyBuffer);
    10741101                    AssertRC(rc);
    10751102                }
     
    11491176            if (u32 & LSILOGIC_REG_HOST_DIAGNOSTIC_RESET_ADAPTER)
    11501177            {
    1151                 lsilogicHardReset(pThis);
     1178                lsilogicR3HardReset(pThis);
    11521179            }
    11531180            break;
     
    11661193 *
    11671194 * @returns VBox status code.
    1168  * @param   pThis    Pointer to the LsiLogic SCSI controller instance data.
    1169  * @param   uOffset  Offset of the register to read.
    1170  * @param   pv       Where to store the content of the register.
    1171  * @param   cb       Number of bytes to read.
     1195 * @param   pThis       Pointer to the LsiLogic device state.
     1196 * @param   uOffset     Offset of the register to read.
     1197 * @param   pv          Where to store the content of the register.
     1198 * @param   cb          Number of bytes to read.
    11721199 */
    11731200static int lsilogicRegisterRead(PLSILOGICSCSI pThis, uint32_t uOffset, void *pv, unsigned cb)
     
    13731400 * @param   cbCopy        Number of bytes to copy.
    13741401 */
    1375 static void lsilogicScatterGatherListCopyFromBuffer(PLSILOGICTASKSTATE pTaskState, void *pvBuf, size_t cbCopy)
     1402static void lsilogicR3ScatterGatherListCopyFromBuffer(PLSILOGICTASKSTATE pTaskState, void *pvBuf, size_t cbCopy)
    13761403{
    13771404    unsigned cSGEntry = 0;
     
    14081435 *                     to write to which are unaligned.
    14091436 */
    1410 static void lsilogicCopyFromBufferIntoSGList(PPDMDEVINS pDevIns, PLSILOGICTASKSTATESGENTRY pSGInfo)
     1437static void lsilogicR3CopyFromBufferIntoSGList(PPDMDEVINS pDevIns, PLSILOGICTASKSTATESGENTRY pSGInfo)
    14111438{
    14121439    RTGCPHYS GCPhysBuffer = pSGInfo->u.GCPhysAddrBufferUnaligned;
     
    14271454 *                     to read from which are unaligned.
    14281455 */
    1429 static void lsilogicCopyFromSGListIntoBuffer(PPDMDEVINS pDevIns, PLSILOGICTASKSTATESGENTRY pSGInfo)
     1456static void lsilogicR3CopyFromSGListIntoBuffer(PPDMDEVINS pDevIns, PLSILOGICTASKSTATESGENTRY pSGInfo)
    14301457{
    14311458    RTGCPHYS GCPhysBuffer = pSGInfo->u.GCPhysAddrBufferUnaligned;
     
    14371464}
    14381465
    1439 static int lsilogicScatterGatherListAllocate(PLSILOGICTASKSTATE pTaskState, uint32_t cSGList, uint32_t cSGInfo, uint32_t cbUnaligned)
     1466static int lsilogicR3ScatterGatherListAllocate(PLSILOGICTASKSTATE pTaskState, uint32_t cSGList, uint32_t cSGInfo, uint32_t cbUnaligned)
    14401467{
    14411468    if (pTaskState->cSGListSize < cSGList)
     
    15281555
    15291556    /* Make debugging easier. */
    1530 #ifdef DEBUG
     1557# ifdef LOG_ENABLED
    15311558    memset(pTaskState->pSGListHead, 0, pTaskState->cSGListSize * sizeof(RTSGSEG));
    15321559    memset(pTaskState->paSGEntries, 0, pTaskState->cSGInfoSize * sizeof(LSILOGICTASKSTATESGENTRY));
    15331560    if (pTaskState->pvBufferUnaligned)
    15341561        memset(pTaskState->pvBufferUnaligned, 0, pTaskState->cbBufferUnaligned);
    1535 #endif
     1562# endif
    15361563    return VINF_SUCCESS;
    15371564}
     
    15411568 *
    15421569 * @returns nothing.
    1543  * @param   pLsiLogic    Pointer to the LsiLogic SCSI controller.
    1544  * @param   pTaskState   Pointer to the task state.
    1545  */
    1546 static void lsilogicScatterGatherListDestroy(PLSILOGICSCSI pLsiLogic, PLSILOGICTASKSTATE pTaskState)
    1547 {
    1548     PPDMDEVINS                pDevIns     = pLsiLogic->CTX_SUFF(pDevIns);
     1570 * @param   pThis       Pointer to the LsiLogic device state.
     1571 * @param   pTaskState  Pointer to the task state.
     1572 */
     1573static void lsilogicR3ScatterGatherListDestroy(PLSILOGICSCSI pThis, PLSILOGICTASKSTATE pTaskState)
     1574{
     1575    PPDMDEVINS                pDevIns     = pThis->CTX_SUFF(pDevIns);
    15491576    PLSILOGICTASKSTATESGENTRY pSGInfoCurr = pTaskState->paSGEntries;
    15501577
     
    15591586        {
    15601587            /* Copy the data into the guest segments now. */
    1561             lsilogicCopyFromBufferIntoSGList(pLsiLogic->CTX_SUFF(pDevIns), pSGInfoCurr);
     1588            lsilogicR3CopyFromBufferIntoSGList(pThis->CTX_SUFF(pDevIns), pSGInfoCurr);
    15621589        }
    15631590
     
    15671594    /* Free allocated memory if the list was too big too many times. */
    15681595    if (pTaskState->cSGListTooBig >= LSILOGIC_NR_OF_ALLOWED_BIGGER_LISTS)
    1569         lsilogicTaskStateClear(pTaskState);
    1570 }
    1571 
    1572 #ifdef DEBUG
     1596        lsilogicR3TaskStateClear(pTaskState);
     1597}
     1598
     1599# ifdef LOG_ENABLED
    15731600/**
    15741601 * Dump an SG entry.
     
    15791606static void lsilogicDumpSGEntry(PMptSGEntryUnion pSGEntry)
    15801607{
    1581     switch (pSGEntry->Simple32.u2ElementType)
    1582     {
    1583         case MPTSGENTRYTYPE_SIMPLE:
    1584         {
    1585             Log(("%s: Dumping info for SIMPLE SG entry:\n", __FUNCTION__));
    1586             Log(("%s: u24Length=%u\n", __FUNCTION__, pSGEntry->Simple32.u24Length));
    1587             Log(("%s: fEndOfList=%d\n", __FUNCTION__, pSGEntry->Simple32.fEndOfList));
    1588             Log(("%s: f64BitAddress=%d\n", __FUNCTION__, pSGEntry->Simple32.f64BitAddress));
    1589             Log(("%s: fBufferContainsData=%d\n", __FUNCTION__, pSGEntry->Simple32.fBufferContainsData));
    1590             Log(("%s: fLocalAddress=%d\n", __FUNCTION__, pSGEntry->Simple32.fLocalAddress));
    1591             Log(("%s: fEndOfBuffer=%d\n", __FUNCTION__, pSGEntry->Simple32.fEndOfBuffer));
    1592             Log(("%s: fLastElement=%d\n", __FUNCTION__, pSGEntry->Simple32.fLastElement));
    1593             Log(("%s: u32DataBufferAddressLow=%u\n", __FUNCTION__, pSGEntry->Simple32.u32DataBufferAddressLow));
    1594             if (pSGEntry->Simple32.f64BitAddress)
     1608    if (LogIsEnabled())
     1609    {
     1610        switch (pSGEntry->Simple32.u2ElementType)
     1611        {
     1612            case MPTSGENTRYTYPE_SIMPLE:
    15951613            {
    1596                 Log(("%s: u32DataBufferAddressHigh=%u\n", __FUNCTION__, pSGEntry->Simple64.u32DataBufferAddressHigh));
    1597                 Log(("%s: GCDataBufferAddress=%RGp\n", __FUNCTION__,
    1598                     ((uint64_t)pSGEntry->Simple64.u32DataBufferAddressHigh << 32) | pSGEntry->Simple64.u32DataBufferAddressLow));
     1614                Log(("%s: Dumping info for SIMPLE SG entry:\n", __FUNCTION__));
     1615                Log(("%s: u24Length=%u\n", __FUNCTION__, pSGEntry->Simple32.u24Length));
     1616                Log(("%s: fEndOfList=%d\n", __FUNCTION__, pSGEntry->Simple32.fEndOfList));
     1617                Log(("%s: f64BitAddress=%d\n", __FUNCTION__, pSGEntry->Simple32.f64BitAddress));
     1618                Log(("%s: fBufferContainsData=%d\n", __FUNCTION__, pSGEntry->Simple32.fBufferContainsData));
     1619                Log(("%s: fLocalAddress=%d\n", __FUNCTION__, pSGEntry->Simple32.fLocalAddress));
     1620                Log(("%s: fEndOfBuffer=%d\n", __FUNCTION__, pSGEntry->Simple32.fEndOfBuffer));
     1621                Log(("%s: fLastElement=%d\n", __FUNCTION__, pSGEntry->Simple32.fLastElement));
     1622                Log(("%s: u32DataBufferAddressLow=%u\n", __FUNCTION__, pSGEntry->Simple32.u32DataBufferAddressLow));
     1623                if (pSGEntry->Simple32.f64BitAddress)
     1624                {
     1625                    Log(("%s: u32DataBufferAddressHigh=%u\n", __FUNCTION__, pSGEntry->Simple64.u32DataBufferAddressHigh));
     1626                    Log(("%s: GCDataBufferAddress=%RGp\n", __FUNCTION__,
     1627                         ((uint64_t)pSGEntry->Simple64.u32DataBufferAddressHigh << 32)
     1628                         | pSGEntry->Simple64.u32DataBufferAddressLow));
     1629                }
     1630                else
     1631                    Log(("%s: GCDataBufferAddress=%RGp\n", __FUNCTION__, pSGEntry->Simple32.u32DataBufferAddressLow));
     1632
     1633                break;
    15991634            }
    1600             else
    1601                 Log(("%s: GCDataBufferAddress=%RGp\n", __FUNCTION__, pSGEntry->Simple32.u32DataBufferAddressLow));
    1602 
    1603             break;
    1604         }
    1605         case MPTSGENTRYTYPE_CHAIN:
    1606         {
    1607             Log(("%s: Dumping info for CHAIN SG entry:\n", __FUNCTION__));
    1608             Log(("%s: u16Length=%u\n", __FUNCTION__, pSGEntry->Chain.u16Length));
    1609             Log(("%s: u8NExtChainOffset=%d\n", __FUNCTION__, pSGEntry->Chain.u8NextChainOffset));
    1610             Log(("%s: f64BitAddress=%d\n", __FUNCTION__, pSGEntry->Chain.f64BitAddress));
    1611             Log(("%s: fLocalAddress=%d\n", __FUNCTION__, pSGEntry->Chain.fLocalAddress));
    1612             Log(("%s: u32SegmentAddressLow=%u\n", __FUNCTION__, pSGEntry->Chain.u32SegmentAddressLow));
    1613             Log(("%s: u32SegmentAddressHigh=%u\n", __FUNCTION__, pSGEntry->Chain.u32SegmentAddressHigh));
    1614             if (pSGEntry->Chain.f64BitAddress)
    1615                 Log(("%s: GCSegmentAddress=%RGp\n", __FUNCTION__,
    1616                     ((uint64_t)pSGEntry->Chain.u32SegmentAddressHigh << 32) | pSGEntry->Chain.u32SegmentAddressLow));
    1617             else
    1618                 Log(("%s: GCSegmentAddress=%RGp\n", __FUNCTION__, pSGEntry->Chain.u32SegmentAddressLow));
    1619             break;
    1620         }
    1621     }
    1622 }
    1623 #endif
     1635            case MPTSGENTRYTYPE_CHAIN:
     1636            {
     1637                Log(("%s: Dumping info for CHAIN SG entry:\n", __FUNCTION__));
     1638                Log(("%s: u16Length=%u\n", __FUNCTION__, pSGEntry->Chain.u16Length));
     1639                Log(("%s: u8NExtChainOffset=%d\n", __FUNCTION__, pSGEntry->Chain.u8NextChainOffset));
     1640                Log(("%s: f64BitAddress=%d\n", __FUNCTION__, pSGEntry->Chain.f64BitAddress));
     1641                Log(("%s: fLocalAddress=%d\n", __FUNCTION__, pSGEntry->Chain.fLocalAddress));
     1642                Log(("%s: u32SegmentAddressLow=%u\n", __FUNCTION__, pSGEntry->Chain.u32SegmentAddressLow));
     1643                Log(("%s: u32SegmentAddressHigh=%u\n", __FUNCTION__, pSGEntry->Chain.u32SegmentAddressHigh));
     1644                if (pSGEntry->Chain.f64BitAddress)
     1645                    Log(("%s: GCSegmentAddress=%RGp\n", __FUNCTION__,
     1646                        ((uint64_t)pSGEntry->Chain.u32SegmentAddressHigh << 32) | pSGEntry->Chain.u32SegmentAddressLow));
     1647                else
     1648                    Log(("%s: GCSegmentAddress=%RGp\n", __FUNCTION__, pSGEntry->Chain.u32SegmentAddressLow));
     1649                break;
     1650            }
     1651        }
     1652    }
     1653}
     1654# endif /* LOG_ENABLED */
    16241655
    16251656/**
     
    16271658 *
    16281659 * @returns VBox status code.
    1629  * @param   pLsiLogic      Pointer to the LsiLogic SCSI controller.
    1630  * @param   pTaskState     Pointer to the task state.
    1631  * @param   GCPhysSGLStart Guest physical address of the first SG entry.
    1632  * @param   uChainOffset   Offset in bytes from the beginning of the SGL segment to the chain element.
     1660 * @param   pThis           Pointer to the LsiLogic device state.
     1661 * @param   pTaskState      Pointer to the task state.
     1662 * @param   GCPhysSGLStart  Guest physical address of the first SG entry.
     1663 * @param   uChainOffset    Offset in bytes from the beginning of the SGL segment to the chain element.
    16331664 * @thread  EMT
    16341665 */
    1635 static int lsilogicScatterGatherListCreate(PLSILOGICSCSI pLsiLogic, PLSILOGICTASKSTATE pTaskState,
    1636                                            RTGCPHYS GCPhysSGLStart, uint32_t uChainOffset)
     1666static int lsilogicR3ScatterGatherListCreate(PLSILOGICSCSI pThis, PLSILOGICTASKSTATE pTaskState,
     1667                                             RTGCPHYS GCPhysSGLStart, uint32_t uChainOffset)
    16371668{
    16381669    int                        rc           = VINF_SUCCESS;
    1639     PPDMDEVINS                 pDevIns      = pLsiLogic->CTX_SUFF(pDevIns);
     1670    PPDMDEVINS                 pDevIns      = pThis->CTX_SUFF(pDevIns);
    16401671    PVM                        pVM          = PDMDevHlpGetVM(pDevIns);
    16411672    bool                       fUnaligned;     /* Flag whether the current buffer is unaligned. */
     
    16731704
    16741705            /* The number of needed SG entries in R3 is known. Allocate needed memory. */
    1675             rc = lsilogicScatterGatherListAllocate(pTaskState, cSGInfo, cSGInfo, cbUnalignedComplete);
     1706            rc = lsilogicR3ScatterGatherListAllocate(pTaskState, cSGInfo, cSGInfo, cbUnalignedComplete);
    16761707            AssertMsgRC(rc, ("Failed to allocate scatter gather array rc=%Rrc\n", rc));
    16771708
     
    16981729                PDMDevHlpPhysRead(pDevIns, GCPhysSGEntryNext, &SGEntry, sizeof(MptSGEntryUnion));
    16991730
    1700 #ifdef DEBUG
     1731# ifdef LOG_ENABLED
    17011732                lsilogicDumpSGEntry(&SGEntry);
    1702 #endif
     1733# endif
    17031734
    17041735                AssertMsg(SGEntry.Simple32.u2ElementType == MPTSGENTRYTYPE_SIMPLE, ("Invalid SG entry type\n"));
     
    17351766                    pSGInfoCurr->u.GCPhysAddrBufferUnaligned = GCPhysAddrDataBuffer;
    17361767                    if (fBufferContainsData)
    1737                         lsilogicCopyFromSGListIntoBuffer(pDevIns, pSGInfoCurr);
     1768                        lsilogicR3CopyFromSGListIntoBuffer(pDevIns, pSGInfoCurr);
    17381769                    pSGInfoCurr++;
    17391770                }
     
    18291860 * crosses page boundaries.
    18301861 */
    1831 #if 0
     1862# if 0
    18321863/**
    18331864 * Free the sense buffer.
     
    18361867 * @param   pTaskState   Pointer to the task state.
    18371868 */
    1838 static void lsilogicFreeGCSenseBuffer(PLSILOGICSCSI pLsiLogic, PLSILOGICTASKSTATE pTaskState)
    1839 {
    1840     PVM pVM = PDMDevHlpGetVM(pLsiLogic->CTX_SUFF(pDevIns));
     1869static void lsilogicFreeGCSenseBuffer(PLSILOGICSCSI pThis, PLSILOGICTASKSTATE pTaskState)
     1870{
     1871    PVM pVM = PDMDevHlpGetVM(pThis->CTX_SUFF(pDevIns));
    18411872
    18421873    PGMPhysReleasePageMappingLock(pVM, &pTaskState->PageLockSense);
     
    18511882 * @note Current assumption is that the sense buffer is not scattered and does not cross a page boundary.
    18521883 */
    1853 static int lsilogicMapGCSenseBufferIntoR3(PLSILOGICSCSI pLsiLogic, PLSILOGICTASKSTATE pTaskState)
     1884static int lsilogicR3MapGCSenseBufferIntoR3(PLSILOGICSCSI pThis, PLSILOGICTASKSTATE pTaskState)
    18541885{
    18551886    int rc = VINF_SUCCESS;
    1856     PPDMDEVINS pDevIns = pLsiLogic->CTX_SUFF(pDevIns);
     1887    PPDMDEVINS pDevIns = pThis->CTX_SUFF(pDevIns);
    18571888    RTGCPHYS GCPhysAddrSenseBuffer;
    18581889
    18591890    GCPhysAddrSenseBuffer = pTaskState->GuestRequest.SCSIIO.u32SenseBufferLowAddress;
    1860     GCPhysAddrSenseBuffer |= ((uint64_t)pLsiLogic->u32SenseBufferHighAddr << 32);
    1861 
    1862 #ifdef RT_STRICT
     1891    GCPhysAddrSenseBuffer |= ((uint64_t)pThis->u32SenseBufferHighAddr << 32);
     1892
     1893# ifdef RT_STRICT
    18631894    uint32_t cbSenseBuffer = pTaskState->GuestRequest.SCSIIO.u8SenseBufferLength;
    1864 #endif
     1895# endif
    18651896    RTGCPHYS GCPhysAddrSenseBufferBase = PAGE_ADDRESS(GCPhysAddrSenseBuffer);
    18661897
     
    18801911    return rc;
    18811912}
    1882 #endif
    1883 
    1884 #ifdef DEBUG
    1885 static void lsilogicDumpSCSIIORequest(PMptSCSIIORequest pSCSIIORequest)
    1886 {
    1887     Log(("%s: u8TargetID=%d\n", __FUNCTION__, pSCSIIORequest->u8TargetID));
    1888     Log(("%s: u8Bus=%d\n", __FUNCTION__, pSCSIIORequest->u8Bus));
    1889     Log(("%s: u8ChainOffset=%d\n", __FUNCTION__, pSCSIIORequest->u8ChainOffset));
    1890     Log(("%s: u8Function=%d\n", __FUNCTION__, pSCSIIORequest->u8Function));
    1891     Log(("%s: u8CDBLength=%d\n", __FUNCTION__, pSCSIIORequest->u8CDBLength));
    1892     Log(("%s: u8SenseBufferLength=%d\n", __FUNCTION__, pSCSIIORequest->u8SenseBufferLength));
    1893     Log(("%s: u8MessageFlags=%d\n", __FUNCTION__, pSCSIIORequest->u8MessageFlags));
    1894     Log(("%s: u32MessageContext=%#x\n", __FUNCTION__, pSCSIIORequest->u32MessageContext));
    1895     for (unsigned i = 0; i < RT_ELEMENTS(pSCSIIORequest->au8LUN); i++)
    1896         Log(("%s: u8LUN[%d]=%d\n", __FUNCTION__, i, pSCSIIORequest->au8LUN[i]));
    1897     Log(("%s: u32Control=%#x\n", __FUNCTION__, pSCSIIORequest->u32Control));
    1898     for (unsigned i = 0; i < RT_ELEMENTS(pSCSIIORequest->au8CDB); i++)
    1899         Log(("%s: u8CDB[%d]=%d\n", __FUNCTION__, i, pSCSIIORequest->au8CDB[i]));
    1900     Log(("%s: u32DataLength=%#x\n", __FUNCTION__, pSCSIIORequest->u32DataLength));
    1901     Log(("%s: u32SenseBufferLowAddress=%#x\n", __FUNCTION__, pSCSIIORequest->u32SenseBufferLowAddress));
    1902 }
    1903 #endif
    1904 
    1905 static void lsilogicWarningDiskFull(PPDMDEVINS pDevIns)
     1913# endif
     1914
     1915# ifdef LOG_ENABLED
     1916static void lsilogicR3DumpSCSIIORequest(PMptSCSIIORequest pSCSIIORequest)
     1917{
     1918    if (LogIsEnabled())
     1919    {
     1920        Log(("%s: u8TargetID=%d\n", __FUNCTION__, pSCSIIORequest->u8TargetID));
     1921        Log(("%s: u8Bus=%d\n", __FUNCTION__, pSCSIIORequest->u8Bus));
     1922        Log(("%s: u8ChainOffset=%d\n", __FUNCTION__, pSCSIIORequest->u8ChainOffset));
     1923        Log(("%s: u8Function=%d\n", __FUNCTION__, pSCSIIORequest->u8Function));
     1924        Log(("%s: u8CDBLength=%d\n", __FUNCTION__, pSCSIIORequest->u8CDBLength));
     1925        Log(("%s: u8SenseBufferLength=%d\n", __FUNCTION__, pSCSIIORequest->u8SenseBufferLength));
     1926        Log(("%s: u8MessageFlags=%d\n", __FUNCTION__, pSCSIIORequest->u8MessageFlags));
     1927        Log(("%s: u32MessageContext=%#x\n", __FUNCTION__, pSCSIIORequest->u32MessageContext));
     1928        for (unsigned i = 0; i < RT_ELEMENTS(pSCSIIORequest->au8LUN); i++)
     1929            Log(("%s: u8LUN[%d]=%d\n", __FUNCTION__, i, pSCSIIORequest->au8LUN[i]));
     1930        Log(("%s: u32Control=%#x\n", __FUNCTION__, pSCSIIORequest->u32Control));
     1931        for (unsigned i = 0; i < RT_ELEMENTS(pSCSIIORequest->au8CDB); i++)
     1932            Log(("%s: u8CDB[%d]=%d\n", __FUNCTION__, i, pSCSIIORequest->au8CDB[i]));
     1933        Log(("%s: u32DataLength=%#x\n", __FUNCTION__, pSCSIIORequest->u32DataLength));
     1934        Log(("%s: u32SenseBufferLowAddress=%#x\n", __FUNCTION__, pSCSIIORequest->u32SenseBufferLowAddress));
     1935    }
     1936}
     1937# endif
     1938
     1939static void lsilogicR3WarningDiskFull(PPDMDEVINS pDevIns)
    19061940{
    19071941    int rc;
     
    19121946}
    19131947
    1914 static void lsilogicWarningFileTooBig(PPDMDEVINS pDevIns)
     1948static void lsilogicR3WarningFileTooBig(PPDMDEVINS pDevIns)
    19151949{
    19161950    int rc;
     
    19211955}
    19221956
    1923 static void lsilogicWarningISCSI(PPDMDEVINS pDevIns)
     1957static void lsilogicR3WarningISCSI(PPDMDEVINS pDevIns)
    19241958{
    19251959    int rc;
     
    19301964}
    19311965
    1932 static void lsilogicWarningUnknown(PPDMDEVINS pDevIns, int rc)
     1966static void lsilogicR3WarningUnknown(PPDMDEVINS pDevIns, int rc)
    19331967{
    19341968    int rc2;
     
    19391973}
    19401974
    1941 static void lsilogicRedoSetWarning(PLSILOGICSCSI pThis, int rc)
     1975static void lsilogicR3RedoSetWarning(PLSILOGICSCSI pThis, int rc)
    19421976{
    19431977    if (rc == VERR_DISK_FULL)
    1944         lsilogicWarningDiskFull(pThis->CTX_SUFF(pDevIns));
     1978        lsilogicR3WarningDiskFull(pThis->CTX_SUFF(pDevIns));
    19451979    else if (rc == VERR_FILE_TOO_BIG)
    1946         lsilogicWarningFileTooBig(pThis->CTX_SUFF(pDevIns));
     1980        lsilogicR3WarningFileTooBig(pThis->CTX_SUFF(pDevIns));
    19471981    else if (rc == VERR_BROKEN_PIPE || rc == VERR_NET_CONNECTION_REFUSED)
    19481982    {
    19491983        /* iSCSI connection abort (first error) or failure to reestablish
    19501984         * connection (second error). Pause VM. On resume we'll retry. */
    1951         lsilogicWarningISCSI(pThis->CTX_SUFF(pDevIns));
     1985        lsilogicR3WarningISCSI(pThis->CTX_SUFF(pDevIns));
    19521986    }
    19531987    else
    1954         lsilogicWarningUnknown(pThis->CTX_SUFF(pDevIns), rc);
     1988        lsilogicR3WarningUnknown(pThis->CTX_SUFF(pDevIns), rc);
    19551989}
    19561990
     
    19631997 *
    19641998 * @returns VBox status code.
    1965  * @param   pLsiLogic    Pointer to the device instance which sends the request.
    1966  * @param   pTaskState   Pointer to the task state data.
    1967  */
    1968 static int lsilogicProcessSCSIIORequest(PLSILOGICSCSI pLsiLogic, PLSILOGICTASKSTATE pTaskState)
     1999 * @param   pThis       Pointer to the LsiLogic device state.
     2000 * @param   pTaskState  Pointer to the task state data.
     2001 */
     2002static int lsilogicR3ProcessSCSIIORequest(PLSILOGICSCSI pThis, PLSILOGICTASKSTATE pTaskState)
    19692003{
    19702004    int rc = VINF_SUCCESS;
    19712005
    1972 #ifdef DEBUG
    1973     lsilogicDumpSCSIIORequest(&pTaskState->GuestRequest.SCSIIO);
    1974 #endif
     2006# ifdef LOG_ENABLED
     2007    lsilogicR3DumpSCSIIORequest(&pTaskState->GuestRequest.SCSIIO);
     2008# endif
    19752009
    19762010    pTaskState->fBIOS = false;
    19772011
    1978     if (RT_LIKELY(   (pTaskState->GuestRequest.SCSIIO.u8TargetID < pLsiLogic->cDeviceStates)
     2012    if (RT_LIKELY(   (pTaskState->GuestRequest.SCSIIO.u8TargetID < pThis->cDeviceStates)
    19792013                  && (pTaskState->GuestRequest.SCSIIO.u8Bus == 0)))
    19802014    {
    19812015        PLSILOGICDEVICE pTargetDevice;
    1982         pTargetDevice = &pLsiLogic->paDeviceStates[pTaskState->GuestRequest.SCSIIO.u8TargetID];
     2016        pTargetDevice = &pThis->paDeviceStates[pTaskState->GuestRequest.SCSIIO.u8TargetID];
    19832017
    19842018        if (pTargetDevice->pDrvBase)
     
    19922026                uChainOffset = uChainOffset * sizeof(uint32_t) - sizeof(MptSCSIIORequest);
    19932027
    1994             rc = lsilogicScatterGatherListCreate(pLsiLogic, pTaskState,
     2028            rc = lsilogicR3ScatterGatherListCreate(pThis, pTaskState,
    19952029                                                 pTaskState->GCPhysMessageFrameAddr + sizeof(MptSCSIIORequest),
    19962030                                                 uChainOffset);
    19972031            AssertRC(rc);
    19982032
    1999 #if 0
     2033# if 0
    20002034            /* Map sense buffer. */
    2001             rc = lsilogicMapGCSenseBufferIntoR3(pLsiLogic, pTaskState);
     2035            rc = lsilogicR3MapGCSenseBufferIntoR3(pThis, pTaskState);
    20022036            AssertRC(rc);
    2003 #endif
     2037# endif
    20042038
    20052039            /* Setup the SCSI request. */
     
    20502084    if (g_cLogged++ < MAX_REL_LOG_ERRORS)
    20512085    {
    2052         LogRel(("LsiLogic#%d: %d/%d (Bus/Target) doesn't exist\n", pLsiLogic->CTX_SUFF(pDevIns)->iInstance,
     2086        LogRel(("LsiLogic#%d: %d/%d (Bus/Target) doesn't exist\n", pThis->CTX_SUFF(pDevIns)->iInstance,
    20532087                pTaskState->GuestRequest.SCSIIO.u8TargetID, pTaskState->GuestRequest.SCSIIO.u8Bus));
    20542088        /* Log the CDB too  */
    20552089        LogRel(("LsiLogic#%d: Guest issued CDB {%#x",
    2056                 pLsiLogic->CTX_SUFF(pDevIns)->iInstance, pTaskState->GuestRequest.SCSIIO.au8CDB[0]));
     2090                pThis->CTX_SUFF(pDevIns)->iInstance, pTaskState->GuestRequest.SCSIIO.au8CDB[0]));
    20572091        for (unsigned i = 1; i < pTaskState->GuestRequest.SCSIIO.u8CDBLength; i++)
    20582092            LogRel((", %#x", pTaskState->GuestRequest.SCSIIO.au8CDB[i]));
     
    20752109    pTaskState->IOCReply.SCSIIOError.u32ResponseInfo     = 0;
    20762110
    2077     lsilogicFinishAddressReply(pLsiLogic, &pTaskState->IOCReply, false);
    2078     RTMemCacheFree(pLsiLogic->hTaskCache, pTaskState);
     2111    lsilogicFinishAddressReply(pThis, &pTaskState->IOCReply, false);
     2112    RTMemCacheFree(pThis->hTaskCache, pTaskState);
    20792113
    20802114    return rc;
     
    20822116
    20832117
    2084 static DECLCALLBACK(int) lsilogicDeviceSCSIRequestCompleted(PPDMISCSIPORT pInterface, PPDMSCSIREQUEST pSCSIRequest,
    2085                                                             int rcCompletion, bool fRedo, int rcReq)
     2118/**
     2119 * @interface_method_impl{PDMISCSIPORT,pfnSCSIRequestCompleted}
     2120 */
     2121static DECLCALLBACK(int) lsilogicR3DeviceSCSIRequestCompleted(PPDMISCSIPORT pInterface, PPDMSCSIREQUEST pSCSIRequest,
     2122                                                              int rcCompletion, bool fRedo, int rcReq)
    20862123{
    20872124    PLSILOGICTASKSTATE pTaskState      = (PLSILOGICTASKSTATE)pSCSIRequest->pvUser;
    20882125    PLSILOGICDEVICE    pLsiLogicDevice = pTaskState->pTargetDevice;
    2089     PLSILOGICSCSI      pLsiLogic       = pLsiLogicDevice->CTX_SUFF(pLsiLogic);
     2126    PLSILOGICSCSI      pThis       = pLsiLogicDevice->CTX_SUFF(pLsiLogic);
    20902127
    20912128    /* If the task failed but it is possible to redo it again after a suspend
     
    20942131    {
    20952132        if (!pTaskState->fBIOS)
    2096             lsilogicScatterGatherListDestroy(pLsiLogic, pTaskState);
     2133            lsilogicR3ScatterGatherListDestroy(pThis, pTaskState);
    20972134
    20982135        /* Add to the list. */
    20992136        do
    21002137        {
    2101             pTaskState->pRedoNext = ASMAtomicReadPtrT(&pLsiLogic->pTasksRedoHead, PLSILOGICTASKSTATE);
    2102         } while (!ASMAtomicCmpXchgPtr(&pLsiLogic->pTasksRedoHead, pTaskState, pTaskState->pRedoNext));
     2138            pTaskState->pRedoNext = ASMAtomicReadPtrT(&pThis->pTasksRedoHead, PLSILOGICTASKSTATE);
     2139        } while (!ASMAtomicCmpXchgPtr(&pThis->pTasksRedoHead, pTaskState, pTaskState->pRedoNext));
    21032140
    21042141        /* Suspend the VM if not done already. */
    2105         if (!ASMAtomicXchgBool(&pLsiLogic->fRedo, true))
    2106             lsilogicRedoSetWarning(pLsiLogic, rcReq);
     2142        if (!ASMAtomicXchgBool(&pThis->fRedo, true))
     2143            lsilogicR3RedoSetWarning(pThis, rcReq);
    21072144    }
    21082145    else
     
    21102147        if (RT_UNLIKELY(pTaskState->fBIOS))
    21112148        {
    2112             int rc = vboxscsiRequestFinished(&pLsiLogic->VBoxSCSI, pSCSIRequest, rcCompletion);
     2149            int rc = vboxscsiRequestFinished(&pThis->VBoxSCSI, pSCSIRequest, rcCompletion);
    21132150            AssertMsgRC(rc, ("Finishing BIOS SCSI request failed rc=%Rrc\n", rc));
    21142151        }
    21152152        else
    21162153        {
    2117 #if 0
    2118             lsilogicFreeGCSenseBuffer(pLsiLogic, pTaskState);
    2119 #else
     2154# if 0
     2155            lsilogicFreeGCSenseBuffer(pThis, pTaskState);
     2156# else
    21202157            RTGCPHYS GCPhysAddrSenseBuffer;
    21212158
    21222159            GCPhysAddrSenseBuffer = pTaskState->GuestRequest.SCSIIO.u32SenseBufferLowAddress;
    2123             GCPhysAddrSenseBuffer |= ((uint64_t)pLsiLogic->u32SenseBufferHighAddr << 32);
     2160            GCPhysAddrSenseBuffer |= ((uint64_t)pThis->u32SenseBufferHighAddr << 32);
    21242161
    21252162            /* Copy the sense buffer over. */
    2126             PDMDevHlpPhysWrite(pLsiLogic->CTX_SUFF(pDevIns), GCPhysAddrSenseBuffer, pTaskState->abSenseBuffer,
     2163            PDMDevHlpPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhysAddrSenseBuffer, pTaskState->abSenseBuffer,
    21272164                                 RT_UNLIKELY(pTaskState->GuestRequest.SCSIIO.u8SenseBufferLength < pTaskState->PDMScsiRequest.cbSenseBuffer)
    21282165                               ? pTaskState->GuestRequest.SCSIIO.u8SenseBufferLength
    21292166                               : pTaskState->PDMScsiRequest.cbSenseBuffer);
    2130 #endif
    2131             lsilogicScatterGatherListDestroy(pLsiLogic, pTaskState);
     2167# endif
     2168            lsilogicR3ScatterGatherListDestroy(pThis, pTaskState);
    21322169
    21332170
    21342171            if (RT_LIKELY(rcCompletion == SCSI_STATUS_OK))
    2135                 lsilogicFinishContextReply(pLsiLogic, pTaskState->GuestRequest.SCSIIO.u32MessageContext);
     2172                lsilogicR3FinishContextReply(pThis, pTaskState->GuestRequest.SCSIIO.u32MessageContext);
    21362173            else
    21372174            {
     
    21542191                pTaskState->IOCReply.SCSIIOError.u32ResponseInfo     = 0;
    21552192
    2156                 lsilogicFinishAddressReply(pLsiLogic, &pTaskState->IOCReply, true);
     2193                lsilogicFinishAddressReply(pThis, &pTaskState->IOCReply, true);
    21572194            }
    21582195        }
    21592196
    2160         RTMemCacheFree(pLsiLogic->hTaskCache, pTaskState);
     2197        RTMemCacheFree(pThis->hTaskCache, pTaskState);
    21612198    }
    21622199
    21632200    ASMAtomicDecU32(&pLsiLogicDevice->cOutstandingRequests);
    21642201
    2165     if (pLsiLogicDevice->cOutstandingRequests == 0 && pLsiLogic->fSignalIdle)
    2166         PDMDevHlpAsyncNotificationCompleted(pLsiLogic->pDevInsR3);
     2202    if (pLsiLogicDevice->cOutstandingRequests == 0 && pThis->fSignalIdle)
     2203        PDMDevHlpAsyncNotificationCompleted(pThis->pDevInsR3);
    21672204
    21682205    return VINF_SUCCESS;
    21692206}
    21702207
    2171 static DECLCALLBACK(int) lsilogicQueryDeviceLocation(PPDMISCSIPORT pInterface, const char **ppcszController,
    2172                                                      uint32_t *piInstance, uint32_t *piLUN)
    2173 {
    2174     PLSILOGICDEVICE pLsiLogicDevice = PDMISCSIPORT_2_PLSILOGICDEVICE(pInterface);
     2208/**
     2209 * @interface_method_impl{PDMISCSIPORT,pfnQueryDeviceLocation}
     2210 */
     2211static DECLCALLBACK(int) lsilogicR3QueryDeviceLocation(PPDMISCSIPORT pInterface, const char **ppcszController,
     2212                                                       uint32_t *piInstance, uint32_t *piLUN)
     2213{
     2214    PLSILOGICDEVICE pLsiLogicDevice = RT_FROM_MEMBER(pInterface, LSILOGICDEVICE, ISCSIPort);
    21752215    PPDMDEVINS pDevIns = pLsiLogicDevice->CTX_SUFF(pLsiLogic)->CTX_SUFF(pDevIns);
    21762216
     
    21962236 * @param   ppbPageData   Where to store the pointer to the page data.
    21972237 */
    2198 static int lsilogicConfigurationIOUnitPageGetFromNumber(PLSILOGICSCSI pLsiLogic,
    2199                                                         PMptConfigurationPagesSupported pPages,
    2200                                                         uint8_t u8PageNumber,
    2201                                                         PMptConfigurationPageHeader *ppPageHeader,
    2202                                                         uint8_t **ppbPageData, size_t *pcbPage)
     2238static int lsilogicR3ConfigurationIOUnitPageGetFromNumber(PLSILOGICSCSI pThis,
     2239                                                          PMptConfigurationPagesSupported pPages,
     2240                                                          uint8_t u8PageNumber,
     2241                                                          PMptConfigurationPageHeader *ppPageHeader,
     2242                                                          uint8_t **ppbPageData, size_t *pcbPage)
    22032243{
    22042244    int rc = VINF_SUCCESS;
    22052245
    2206     AssertMsg(VALID_PTR(ppPageHeader) && VALID_PTR(ppbPageData), ("Invalid parameters\n"));
    2207 
    2208     switch(u8PageNumber)
     2246    AssertPtr(ppPageHeader); Assert(ppbPageData);
     2247
     2248    switch (u8PageNumber)
    22092249    {
    22102250        case 0:
     
    22502290 * @param   ppbPageData   Where to store the pointer to the page data.
    22512291 */
    2252 static int lsilogicConfigurationIOCPageGetFromNumber(PLSILOGICSCSI pLsiLogic,
    2253                                                      PMptConfigurationPagesSupported pPages,
    2254                                                      uint8_t u8PageNumber,
    2255                                                      PMptConfigurationPageHeader *ppPageHeader,
    2256                                                      uint8_t **ppbPageData, size_t *pcbPage)
     2292static int lsilogicR3ConfigurationIOCPageGetFromNumber(PLSILOGICSCSI pThis,
     2293                                                       PMptConfigurationPagesSupported pPages,
     2294                                                       uint8_t u8PageNumber,
     2295                                                       PMptConfigurationPageHeader *ppPageHeader,
     2296                                                       uint8_t **ppbPageData, size_t *pcbPage)
    22572297{
    22582298    int rc = VINF_SUCCESS;
    22592299
    2260     AssertMsg(VALID_PTR(ppPageHeader) && VALID_PTR(ppbPageData), ("Invalid parameters\n"));
    2261 
    2262     switch(u8PageNumber)
     2300    AssertPtr(ppPageHeader); Assert(ppbPageData);
     2301
     2302    switch (u8PageNumber)
    22632303    {
    22642304        case 0:
     
    23092349 * @param   ppbPageData   Where to store the pointer to the page data.
    23102350 */
    2311 static int lsilogicConfigurationManufacturingPageGetFromNumber(PLSILOGICSCSI pLsiLogic,
    2312                                                                PMptConfigurationPagesSupported pPages,
    2313                                                                uint8_t u8PageNumber,
    2314                                                                PMptConfigurationPageHeader *ppPageHeader,
    2315                                                                uint8_t **ppbPageData, size_t *pcbPage)
     2351static int lsilogicR3ConfigurationManufacturingPageGetFromNumber(PLSILOGICSCSI pThis,
     2352                                                                 PMptConfigurationPagesSupported pPages,
     2353                                                                 uint8_t u8PageNumber,
     2354                                                                 PMptConfigurationPageHeader *ppPageHeader,
     2355                                                                 uint8_t **ppbPageData, size_t *pcbPage)
    23162356{
    23172357    int rc = VINF_SUCCESS;
    23182358
    2319     AssertMsg(VALID_PTR(ppPageHeader) && VALID_PTR(ppbPageData), ("Invalid parameters\n"));
    2320 
    2321     switch(u8PageNumber)
     2359    AssertPtr(ppPageHeader); Assert(ppbPageData);
     2360
     2361    switch (u8PageNumber)
    23222362    {
    23232363        case 0:
     
    23572397            break;
    23582398        case 7:
    2359             if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
     2399            if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    23602400            {
    23612401                *ppPageHeader = &pPages->u.SasPages.pManufacturingPage7->u.fields.Header;
     
    23982438 * @param   ppbPageData   Where to store the pointer to the page data.
    23992439 */
    2400 static int lsilogicConfigurationBiosPageGetFromNumber(PLSILOGICSCSI pLsiLogic,
    2401                                                       PMptConfigurationPagesSupported pPages,
    2402                                                       uint8_t u8PageNumber,
    2403                                                       PMptConfigurationPageHeader *ppPageHeader,
    2404                                                       uint8_t **ppbPageData, size_t *pcbPage)
     2440static int lsilogicR3ConfigurationBiosPageGetFromNumber(PLSILOGICSCSI pThis,
     2441                                                        PMptConfigurationPagesSupported pPages,
     2442                                                        uint8_t u8PageNumber,
     2443                                                        PMptConfigurationPageHeader *ppPageHeader,
     2444                                                        uint8_t **ppbPageData, size_t *pcbPage)
    24052445{
    24062446    int rc = VINF_SUCCESS;
    24072447
    2408     AssertMsg(VALID_PTR(ppPageHeader) && VALID_PTR(ppbPageData), ("Invalid parameters\n"));
    2409 
    2410     switch(u8PageNumber)
     2448    AssertPtr(ppPageHeader); Assert(ppbPageData);
     2449
     2450    switch (u8PageNumber)
    24112451    {
    24122452        case 1:
     
    24422482 * @param   ppbPageData   Where to store the pointer to the page data.
    24432483 */
    2444 static int lsilogicConfigurationSCSISPIPortPageGetFromNumber(PLSILOGICSCSI pLsiLogic,
    2445                                                              PMptConfigurationPagesSupported pPages,
    2446                                                              uint8_t u8Port,
    2447                                                              uint8_t u8PageNumber,
    2448                                                              PMptConfigurationPageHeader *ppPageHeader,
    2449                                                              uint8_t **ppbPageData, size_t *pcbPage)
     2484static int lsilogicR3ConfigurationSCSISPIPortPageGetFromNumber(PLSILOGICSCSI pThis,
     2485                                                               PMptConfigurationPagesSupported pPages,
     2486                                                               uint8_t u8Port,
     2487                                                               uint8_t u8PageNumber,
     2488                                                               PMptConfigurationPageHeader *ppPageHeader,
     2489                                                               uint8_t **ppbPageData, size_t *pcbPage)
    24502490{
    24512491    int rc = VINF_SUCCESS;
    2452 
    2453     AssertMsg(VALID_PTR(ppPageHeader) && VALID_PTR(ppbPageData), ("Invalid parameters\n"));
     2492    AssertPtr(ppPageHeader); Assert(ppbPageData);
     2493
    24542494
    24552495    if (u8Port >= RT_ELEMENTS(pPages->u.SpiPages.aPortPages))
    24562496        return VERR_NOT_FOUND;
    24572497
    2458     switch(u8PageNumber)
     2498    switch (u8PageNumber)
    24592499    {
    24602500        case 0:
     
    24902530 * @param   ppbPageData   Where to store the pointer to the page data.
    24912531 */
    2492 static int lsilogicConfigurationSCSISPIDevicePageGetFromNumber(PLSILOGICSCSI pLsiLogic,
    2493                                                                PMptConfigurationPagesSupported pPages,
    2494                                                                uint8_t u8Bus,
    2495                                                                uint8_t u8TargetID, uint8_t u8PageNumber,
    2496                                                                PMptConfigurationPageHeader *ppPageHeader,
    2497                                                                uint8_t **ppbPageData, size_t *pcbPage)
     2532static int lsilogicR3ConfigurationSCSISPIDevicePageGetFromNumber(PLSILOGICSCSI pThis,
     2533                                                                 PMptConfigurationPagesSupported pPages,
     2534                                                                 uint8_t u8Bus,
     2535                                                                 uint8_t u8TargetID, uint8_t u8PageNumber,
     2536                                                                 PMptConfigurationPageHeader *ppPageHeader,
     2537                                                                 uint8_t **ppbPageData, size_t *pcbPage)
    24982538{
    24992539    int rc = VINF_SUCCESS;
    2500 
    2501     AssertMsg(VALID_PTR(ppPageHeader) && VALID_PTR(ppbPageData), ("Invalid parameters\n"));
     2540    AssertPtr(ppPageHeader); Assert(ppbPageData);
    25022541
    25032542    if (u8Bus >= RT_ELEMENTS(pPages->u.SpiPages.aBuses))
     
    25072546        return VERR_NOT_FOUND;
    25082547
    2509     switch(u8PageNumber)
     2548    switch (u8PageNumber)
    25102549    {
    25112550        case 0:
     
    25362575}
    25372576
    2538 static int lsilogicConfigurationSASIOUnitPageGetFromNumber(PLSILOGICSCSI pLsiLogic,
    2539                                                            PMptConfigurationPagesSupported pPages,
    2540                                                            uint8_t u8PageNumber,
    2541                                                            PMptExtendedConfigurationPageHeader *ppPageHeader,
    2542                                                            uint8_t **ppbPageData, size_t *pcbPage)
     2577static int lsilogicR3ConfigurationSASIOUnitPageGetFromNumber(PLSILOGICSCSI pThis,
     2578                                                             PMptConfigurationPagesSupported pPages,
     2579                                                             uint8_t u8PageNumber,
     2580                                                             PMptExtendedConfigurationPageHeader *ppPageHeader,
     2581                                                             uint8_t **ppbPageData, size_t *pcbPage)
    25432582{
    25442583    int rc = VINF_SUCCESS;
    25452584
    2546     switch(u8PageNumber)
     2585    switch (u8PageNumber)
    25472586    {
    25482587        case 0:
     
    25732612}
    25742613
    2575 static int lsilogicConfigurationSASPHYPageGetFromNumber(PLSILOGICSCSI pLsiLogic,
    2576                                                         PMptConfigurationPagesSupported pPages,
    2577                                                         uint8_t u8PageNumber,
    2578                                                         MptConfigurationPageAddress PageAddress,
    2579                                                         PMptExtendedConfigurationPageHeader *ppPageHeader,
    2580                                                         uint8_t **ppbPageData, size_t *pcbPage)
     2614static int lsilogicR3ConfigurationSASPHYPageGetFromNumber(PLSILOGICSCSI pThis,
     2615                                                          PMptConfigurationPagesSupported pPages,
     2616                                                          uint8_t u8PageNumber,
     2617                                                          MptConfigurationPageAddress PageAddress,
     2618                                                          PMptExtendedConfigurationPageHeader *ppPageHeader,
     2619                                                          uint8_t **ppbPageData, size_t *pcbPage)
    25812620{
    25822621    int rc = VINF_SUCCESS;
     
    26142653    if (pPHYPages)
    26152654    {
    2616         switch(u8PageNumber)
     2655        switch (u8PageNumber)
    26172656        {
    26182657            case 0:
     
    26362675}
    26372676
    2638 static int lsilogicConfigurationSASDevicePageGetFromNumber(PLSILOGICSCSI pLsiLogic,
    2639                                                            PMptConfigurationPagesSupported pPages,
    2640                                                            uint8_t u8PageNumber,
    2641                                                            MptConfigurationPageAddress PageAddress,
    2642                                                            PMptExtendedConfigurationPageHeader *ppPageHeader,
    2643                                                            uint8_t **ppbPageData, size_t *pcbPage)
     2677static int lsilogicR3ConfigurationSASDevicePageGetFromNumber(PLSILOGICSCSI pThis,
     2678                                                             PMptConfigurationPagesSupported pPages,
     2679                                                             uint8_t u8PageNumber,
     2680                                                             MptConfigurationPageAddress PageAddress,
     2681                                                             PMptExtendedConfigurationPageHeader *ppPageHeader,
     2682                                                             uint8_t **ppbPageData, size_t *pcbPage)
    26442683{
    26452684    int rc = VINF_SUCCESS;
     
    27002739    if (pSASDevice)
    27012740    {
    2702         switch(u8PageNumber)
     2741        switch (u8PageNumber)
    27032742        {
    27042743            case 0:
     
    27312770 * @returns VINF_SUCCESS if successful
    27322771 *          VERR_NOT_FOUND if the requested page could be found.
    2733  * @param   pLsiLogic           The LsiLogic controller instance.
     2772 * @param   pThis               Pointer to the LsiLogic device state.
    27342773 * @param   pConfigurationReq   The configuration request.
    27352774 * @param   u8PageNumber        Number of the page to get.
     
    27372776 * @param   ppbPageData         Where to store the pointer to the page data.
    27382777 */
    2739 static int lsilogicConfigurationPageGetExtended(PLSILOGICSCSI pLsiLogic, PMptConfigurationRequest pConfigurationReq,
    2740                                                 PMptExtendedConfigurationPageHeader *ppPageHeader,
    2741                                                 uint8_t **ppbPageData, size_t *pcbPage)
     2778static int lsilogicR3ConfigurationPageGetExtended(PLSILOGICSCSI pThis, PMptConfigurationRequest pConfigurationReq,
     2779                                                  PMptExtendedConfigurationPageHeader *ppPageHeader,
     2780                                                  uint8_t **ppbPageData, size_t *pcbPage)
    27422781{
    27432782    int rc = VINF_SUCCESS;
     
    27512790        case MPT_CONFIGURATION_PAGE_TYPE_EXTENDED_SASIOUNIT:
    27522791        {
    2753             rc = lsilogicConfigurationSASIOUnitPageGetFromNumber(pLsiLogic,
    2754                                                                  pLsiLogic->pConfigurationPages,
     2792            rc = lsilogicR3ConfigurationSASIOUnitPageGetFromNumber(pThis,
     2793                                                                 pThis->pConfigurationPages,
    27552794                                                                 pConfigurationReq->u8PageNumber,
    27562795                                                                 ppPageHeader, ppbPageData, pcbPage);
     
    27592798        case MPT_CONFIGURATION_PAGE_TYPE_EXTENDED_SASPHYS:
    27602799        {
    2761             rc = lsilogicConfigurationSASPHYPageGetFromNumber(pLsiLogic,
    2762                                                               pLsiLogic->pConfigurationPages,
     2800            rc = lsilogicR3ConfigurationSASPHYPageGetFromNumber(pThis,
     2801                                                              pThis->pConfigurationPages,
    27632802                                                              pConfigurationReq->u8PageNumber,
    27642803                                                              pConfigurationReq->PageAddress,
     
    27682807        case MPT_CONFIGURATION_PAGE_TYPE_EXTENDED_SASDEVICE:
    27692808        {
    2770             rc = lsilogicConfigurationSASDevicePageGetFromNumber(pLsiLogic,
    2771                                                                  pLsiLogic->pConfigurationPages,
     2809            rc = lsilogicR3ConfigurationSASDevicePageGetFromNumber(pThis,
     2810                                                                 pThis->pConfigurationPages,
    27722811                                                                 pConfigurationReq->u8PageNumber,
    27732812                                                                 pConfigurationReq->PageAddress,
     
    27882827 *
    27892828 * @returns VBox status code.
    2790  * @param   pLsiLogic             Pointer to the device instance which sends the request.
    2791  * @param   pConfigurationReq     Pointer to the request structure.
    2792  * @param   pReply                Pointer to the reply message frame
    2793  */
    2794 static int lsilogicProcessConfigurationRequest(PLSILOGICSCSI pLsiLogic, PMptConfigurationRequest pConfigurationReq,
    2795                                                PMptConfigurationReply pReply)
     2829 * @param   pThis               Pointer to the LsiLogic device state.
     2830 * @param   pConfigurationReq   Pointer to the request structure.
     2831 * @param   pReply              Pointer to the reply message frame
     2832 */
     2833static int lsilogicR3ProcessConfigurationRequest(PLSILOGICSCSI pThis, PMptConfigurationRequest pConfigurationReq,
     2834                                                 PMptConfigurationReply pReply)
    27962835{
    27972836    int                                 rc             = VINF_SUCCESS;
     
    28032842    size_t                              cbPage = 0;
    28042843
    2805     LogFlowFunc(("pLsiLogic=%#p\n", pLsiLogic));
     2844    LogFlowFunc(("pThis=%#p\n", pThis));
    28062845
    28072846    u8PageType = MPT_CONFIGURATION_PAGE_TYPE_GET(pConfigurationReq->u8PageType);
     
    28262865        {
    28272866            /* Get the page data. */
    2828             rc = lsilogicConfigurationIOUnitPageGetFromNumber(pLsiLogic,
    2829                                                               pLsiLogic->pConfigurationPages,
     2867            rc = lsilogicR3ConfigurationIOUnitPageGetFromNumber(pThis,
     2868                                                              pThis->pConfigurationPages,
    28302869                                                              pConfigurationReq->u8PageNumber,
    28312870                                                              &pPageHeader, &pbPageData, &cbPage);
     
    28352874        {
    28362875            /* Get the page data. */
    2837             rc = lsilogicConfigurationIOCPageGetFromNumber(pLsiLogic,
    2838                                                            pLsiLogic->pConfigurationPages,
     2876            rc = lsilogicR3ConfigurationIOCPageGetFromNumber(pThis,
     2877                                                           pThis->pConfigurationPages,
    28392878                                                           pConfigurationReq->u8PageNumber,
    28402879                                                           &pPageHeader, &pbPageData, &cbPage);
     
    28442883        {
    28452884            /* Get the page data. */
    2846             rc = lsilogicConfigurationManufacturingPageGetFromNumber(pLsiLogic,
    2847                                                                      pLsiLogic->pConfigurationPages,
     2885            rc = lsilogicR3ConfigurationManufacturingPageGetFromNumber(pThis,
     2886                                                                     pThis->pConfigurationPages,
    28482887                                                                     pConfigurationReq->u8PageNumber,
    28492888                                                                     &pPageHeader, &pbPageData, &cbPage);
     
    28532892        {
    28542893            /* Get the page data. */
    2855             rc = lsilogicConfigurationSCSISPIPortPageGetFromNumber(pLsiLogic,
    2856                                                                    pLsiLogic->pConfigurationPages,
     2894            rc = lsilogicR3ConfigurationSCSISPIPortPageGetFromNumber(pThis,
     2895                                                                   pThis->pConfigurationPages,
    28572896                                                                   pConfigurationReq->PageAddress.MPIPortNumber.u8PortNumber,
    28582897                                                                   pConfigurationReq->u8PageNumber,
     
    28632902        {
    28642903            /* Get the page data. */
    2865             rc = lsilogicConfigurationSCSISPIDevicePageGetFromNumber(pLsiLogic,
    2866                                                                      pLsiLogic->pConfigurationPages,
     2904            rc = lsilogicR3ConfigurationSCSISPIDevicePageGetFromNumber(pThis,
     2905                                                                     pThis->pConfigurationPages,
    28672906                                                                     pConfigurationReq->PageAddress.BusAndTargetId.u8Bus,
    28682907                                                                     pConfigurationReq->PageAddress.BusAndTargetId.u8TargetID,
     
    28732912        case MPT_CONFIGURATION_PAGE_TYPE_BIOS:
    28742913        {
    2875             rc = lsilogicConfigurationBiosPageGetFromNumber(pLsiLogic,
    2876                                                             pLsiLogic->pConfigurationPages,
     2914            rc = lsilogicR3ConfigurationBiosPageGetFromNumber(pThis,
     2915                                                            pThis->pConfigurationPages,
    28772916                                                            pConfigurationReq->u8PageNumber,
    28782917                                                            &pPageHeader, &pbPageData, &cbPage);
     
    28812920        case MPT_CONFIGURATION_PAGE_TYPE_EXTENDED:
    28822921        {
    2883             rc = lsilogicConfigurationPageGetExtended(pLsiLogic,
     2922            rc = lsilogicR3ConfigurationPageGetExtended(pThis,
    28842923                                                      pConfigurationReq,
    28852924                                                      &pExtPageHeader, &pbPageData, &cbPage);
     
    29462985                    GCPhysAddrPageBuffer |= (uint64_t)pConfigurationReq->SimpleSGElement.u32DataBufferAddressHigh << 32;
    29472986
    2948                 PDMDevHlpPhysWrite(pLsiLogic->CTX_SUFF(pDevIns), GCPhysAddrPageBuffer, pbPageData,
     2987                PDMDevHlpPhysWrite(pThis->CTX_SUFF(pDevIns), GCPhysAddrPageBuffer, pbPageData,
    29492988                                   RT_MIN(cbBuffer, cbPage));
    29502989            }
     
    29633002                LogFlow(("cbBuffer=%u cbPage=%u\n", cbBuffer, cbPage));
    29643003
    2965                 PDMDevHlpPhysRead(pLsiLogic->CTX_SUFF(pDevIns), GCPhysAddrPageBuffer, pbPageData,
     3004                PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), GCPhysAddrPageBuffer, pbPageData,
    29663005                                  RT_MIN(cbBuffer, cbPage));
    29673006            }
     
    29793018 *
    29803019 * @returns nothing
    2981  * @param   pLsiLogic    Pointer to the Lsilogic SCSI instance.
    2982  */
    2983 static void lsilogicInitializeConfigurationPagesSpi(PLSILOGICSCSI pLsiLogic)
    2984 {
    2985     PMptConfigurationPagesSpi pPages = &pLsiLogic->pConfigurationPages->u.SpiPages;
    2986 
    2987     AssertMsg(pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI, ("Controller is not the SPI SCSI one\n"));
    2988 
    2989     LogFlowFunc(("pLsiLogic=%#p\n", pLsiLogic));
     3020 * @param   pThis       Pointer to the LsiLogic device state.
     3021 */
     3022static void lsilogicR3InitializeConfigurationPagesSpi(PLSILOGICSCSI pThis)
     3023{
     3024    PMptConfigurationPagesSpi pPages = &pThis->pConfigurationPages->u.SpiPages;
     3025
     3026    AssertMsg(pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI, ("Controller is not the SPI SCSI one\n"));
     3027
     3028    LogFlowFunc(("pThis=%#p\n", pThis));
    29903029
    29913030    /* Clear everything first. */
     
    30703109 *
    30713110 * @returns the handle.
    3072  * @param   pThis    The LsiLogic instance.
     3111 * @param   pThis       Pointer to the LsiLogic device state.
    30733112 */
    30743113DECLINLINE(uint16_t) lsilogicGetHandle(PLSILOGICSCSI pThis)
     
    31033142 *
    31043143 * @returns nothing
    3105  * @param   pThis    Pointer to the Lsilogic SCSI instance.
    3106  */
    3107 static void lsilogicInitializeConfigurationPagesSas(PLSILOGICSCSI pThis)
     3144 * @param   pThis       Pointer to the LsiLogic device state.
     3145 */
     3146static void lsilogicR3InitializeConfigurationPagesSas(PLSILOGICSCSI pThis)
    31083147{
    31093148    PMptConfigurationPagesSas pPages = &pThis->pConfigurationPages->u.SasPages;
     
    32993338 *
    33003339 * @returns nothing
    3301  * @param   pLsiLogic    Pointer to the Lsilogic SCSI instance.
    3302  */
    3303 static void lsilogicInitializeConfigurationPages(PLSILOGICSCSI pLsiLogic)
     3340 * @param   pThis       Pointer to the LsiLogic device state.
     3341 */
     3342static void lsilogicR3InitializeConfigurationPages(PLSILOGICSCSI pThis)
    33043343{
    33053344    /* Initialize the common pages. */
    33063345    PMptConfigurationPagesSupported pPages = (PMptConfigurationPagesSupported)RTMemAllocZ(sizeof(MptConfigurationPagesSupported));
    33073346
    3308     pLsiLogic->pConfigurationPages = pPages;
    3309 
    3310     LogFlowFunc(("pLsiLogic=%#p\n", pLsiLogic));
     3347    pThis->pConfigurationPages = pPages;
     3348
     3349    LogFlowFunc(("pThis=%#p\n", pThis));
    33113350
    33123351    /* Clear everything first. */
     
    33333372                                              MPT_CONFIGURATION_PAGE_ATTRIBUTE_PERSISTENT_READONLY);
    33343373
    3335     if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
     3374    if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
    33363375    {
    33373376        pPages->ManufacturingPage2.u.fields.u16PCIDeviceID = LSILOGICSCSI_PCI_SPI_DEVICE_ID;
    33383377        pPages->ManufacturingPage2.u.fields.u8PCIRevisionID = LSILOGICSCSI_PCI_SPI_REVISION_ID;
    33393378    }
    3340     else if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
     3379    else if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    33413380    {
    33423381        pPages->ManufacturingPage2.u.fields.u16PCIDeviceID = LSILOGICSCSI_PCI_SAS_DEVICE_ID;
     
    33493388                                              MPT_CONFIGURATION_PAGE_ATTRIBUTE_PERSISTENT_READONLY);
    33503389
    3351     if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
     3390    if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
    33523391    {
    33533392        pPages->ManufacturingPage3.u.fields.u16PCIDeviceID = LSILOGICSCSI_PCI_SPI_DEVICE_ID;
    33543393        pPages->ManufacturingPage3.u.fields.u8PCIRevisionID = LSILOGICSCSI_PCI_SPI_REVISION_ID;
    33553394    }
    3356     else if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
     3395    else if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    33573396    {
    33583397        pPages->ManufacturingPage3.u.fields.u16PCIDeviceID = LSILOGICSCSI_PCI_SAS_DEVICE_ID;
     
    34173456    pPages->IOUnitPage2.u.fields.aAdapterOrder[0].fAdapterEmbedded = true;
    34183457    pPages->IOUnitPage2.u.fields.aAdapterOrder[0].u8PCIBusNumber = 0;
    3419     pPages->IOUnitPage2.u.fields.aAdapterOrder[0].u8PCIDevFn     = pLsiLogic->PciDev.devfn;
     3458    pPages->IOUnitPage2.u.fields.aAdapterOrder[0].u8PCIDevFn     = pThis->PciDev.devfn;
    34203459
    34213460    /* I/O Unit page 3. */
     
    34373476    pPages->IOCPage0.u.fields.u32FreeNVStore       = 0;
    34383477
    3439     if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
     3478    if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
    34403479    {
    34413480        pPages->IOCPage0.u.fields.u16VendorId          = LSILOGICSCSI_PCI_VENDOR_ID;
     
    34463485        pPages->IOCPage0.u.fields.u16SubsystemId       = LSILOGICSCSI_PCI_SPI_SUBSYSTEM_ID;
    34473486    }
    3448     else if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
     3487    else if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    34493488    {
    34503489        pPages->IOCPage0.u.fields.u16VendorId          = LSILOGICSCSI_PCI_VENDOR_ID;
     
    35033542                                     MPT_CONFIGURATION_PAGE_ATTRIBUTE_CHANGEABLE);
    35043543
    3505     if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
    3506         lsilogicInitializeConfigurationPagesSpi(pLsiLogic);
    3507     else if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    3508         lsilogicInitializeConfigurationPagesSas(pLsiLogic);
     3544    if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
     3545        lsilogicR3InitializeConfigurationPagesSpi(pThis);
     3546    else if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
     3547        lsilogicR3InitializeConfigurationPagesSas(pThis);
    35093548    else
    3510         AssertMsgFailed(("Invalid controller type %d\n", pLsiLogic->enmCtrlType));
    3511 }
    3512 
    3513 /**
    3514  * Transmit queue consumer
    3515  * Queue a new async task.
    3516  *
    3517  * @returns Success indicator.
    3518  *          If false the item will not be removed and the flushing will stop.
    3519  * @param   pDevIns     The device instance.
    3520  * @param   pItem       The item to consume. Upon return this item will be freed.
    3521  */
    3522 static DECLCALLBACK(bool) lsilogicNotifyQueueConsumer(PPDMDEVINS pDevIns, PPDMQUEUEITEMCORE pItem)
    3523 {
    3524     PLSILOGICSCSI pLsiLogic = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     3549        AssertMsgFailed(("Invalid controller type %d\n", pThis->enmCtrlType));
     3550}
     3551
     3552/**
     3553 * @callback_method_impl{FNPDMQUEUEDEV, Transmit queue consumer.}
     3554 */
     3555static DECLCALLBACK(bool) lsilogicR3NotifyQueueConsumer(PPDMDEVINS pDevIns, PPDMQUEUEITEMCORE pItem)
     3556{
     3557    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
    35253558    int rc = VINF_SUCCESS;
    35263559
     
    35283561
    35293562    /* Reset notification event. */
    3530     ASMAtomicXchgBool(&pLsiLogic->fNotificationSend, false);
     3563    ASMAtomicXchgBool(&pThis->fNotificationSend, false);
    35313564
    35323565    /* Only process request which arrived before we received the notification. */
    3533     uint32_t uRequestQueueNextEntryWrite = ASMAtomicReadU32(&pLsiLogic->uRequestQueueNextEntryFreeWrite);
     3566    uint32_t uRequestQueueNextEntryWrite = ASMAtomicReadU32(&pThis->uRequestQueueNextEntryFreeWrite);
    35343567
    35353568    /* Go through the messages now and process them. */
    3536     while (   RT_LIKELY(pLsiLogic->enmState == LSILOGICSTATE_OPERATIONAL)
    3537            && (pLsiLogic->uRequestQueueNextAddressRead != uRequestQueueNextEntryWrite))
    3538     {
    3539         uint32_t  u32RequestMessageFrameDesc = pLsiLogic->CTX_SUFF(pRequestQueueBase)[pLsiLogic->uRequestQueueNextAddressRead];
    3540         RTGCPHYS  GCPhysMessageFrameAddr = LSILOGIC_RTGCPHYS_FROM_U32(pLsiLogic->u32HostMFAHighAddr,
     3569    while (   RT_LIKELY(pThis->enmState == LSILOGICSTATE_OPERATIONAL)
     3570           && (pThis->uRequestQueueNextAddressRead != uRequestQueueNextEntryWrite))
     3571    {
     3572        uint32_t  u32RequestMessageFrameDesc = pThis->CTX_SUFF(pRequestQueueBase)[pThis->uRequestQueueNextAddressRead];
     3573        RTGCPHYS  GCPhysMessageFrameAddr = LSILOGIC_RTGCPHYS_FROM_U32(pThis->u32HostMFAHighAddr,
    35413574                                                                      (u32RequestMessageFrameDesc & ~0x07));
    35423575
     
    35443577
    35453578        /* Get new task state. */
    3546         rc = RTMemCacheAllocEx(pLsiLogic->hTaskCache, (void **)&pTaskState);
     3579        rc = RTMemCacheAllocEx(pThis->hTaskCache, (void **)&pTaskState);
    35473580        AssertRC(rc);
    35483581
     
    35933626            default:
    35943627                AssertMsgFailed(("Unknown function issued %u\n", pTaskState->GuestRequest.Header.u8Function));
    3595                 lsilogicSetIOCFaultCode(pLsiLogic, LSILOGIC_IOCSTATUS_INVALID_FUNCTION);
     3628                lsilogicSetIOCFaultCode(pThis, LSILOGIC_IOCSTATUS_INVALID_FUNCTION);
    35963629        }
    35973630
     
    36043637            if (pTaskState->GuestRequest.Header.u8Function == MPT_MESSAGE_HDR_FUNCTION_SCSI_IO_REQUEST)
    36053638            {
    3606                rc = lsilogicProcessSCSIIORequest(pLsiLogic, pTaskState);
     3639               rc = lsilogicR3ProcessSCSIIORequest(pThis, pTaskState);
    36073640               AssertRC(rc);
    36083641            }
     
    36103643            {
    36113644                MptReplyUnion Reply;
    3612                 rc = lsilogicProcessMessageRequest(pLsiLogic, &pTaskState->GuestRequest.Header, &Reply);
     3645                rc = lsilogicR3ProcessMessageRequest(pThis, &pTaskState->GuestRequest.Header, &Reply);
    36133646                AssertRC(rc);
    3614                 RTMemCacheFree(pLsiLogic->hTaskCache, pTaskState);
     3647                RTMemCacheFree(pThis->hTaskCache, pTaskState);
    36153648            }
    36163649
    3617             pLsiLogic->uRequestQueueNextAddressRead++;
    3618             pLsiLogic->uRequestQueueNextAddressRead %= pLsiLogic->cRequestQueueEntries;
     3650            pThis->uRequestQueueNextAddressRead++;
     3651            pThis->uRequestQueueNextAddressRead %= pThis->cRequestQueueEntries;
    36193652        }
    36203653    }
     
    36283661 * @returns VBox status code.
    36293662 *
    3630  * @param   pThis        The LsiLogic devi state.
    3631  * @param   pcszCtrlType The string to use.
    3632  */
    3633 static int lsilogicGetCtrlTypeFromString(PLSILOGICSCSI pThis, const char *pcszCtrlType)
     3663 * @param   pThis           Pointer to the LsiLogic device state.
     3664 * @param   pcszCtrlType    The string to use.
     3665 */
     3666static int lsilogicR3GetCtrlTypeFromString(PLSILOGICSCSI pThis, const char *pcszCtrlType)
    36343667{
    36353668    int rc = VERR_INVALID_PARAMETER;
     
    36503683
    36513684/**
    3652  * Port I/O Handler for IN operations - legacy port.
    3653  *
    3654  * @returns VBox status code.
    3655  *
    3656  * @param   pDevIns     The device instance.
    3657  * @param   pvUser      User argument.
    3658  * @param   uPort       Port number used for the IN operation.
    3659  * @param   pu32        Where to store the result.
    3660  * @param   cb          Number of bytes read.
    3661  */
    3662 static int  lsilogicIsaIOPortRead (PPDMDEVINS pDevIns, void *pvUser,
    3663                                    RTIOPORT Port, uint32_t *pu32, unsigned cb)
    3664 {
    3665     int rc;
     3685 * @callback_method_impl{FNIOMIOPORTIN, Legacy ISA port.}
     3686 */
     3687static DECLCALLBACK(int) lsilogicR3IsaIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
     3688{
    36663689    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
    36673690
    36683691    Assert(cb == 1);
    36693692
    3670     uint8_t iRegister =   pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI
    3671                         ? Port - LSILOGIC_BIOS_IO_PORT
    3672                         : Port - LSILOGIC_SAS_BIOS_IO_PORT;
    3673     rc = vboxscsiReadRegister(&pThis->VBoxSCSI, iRegister, pu32);
     3693    uint8_t iRegister = pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI
     3694                      ? Port - LSILOGIC_BIOS_IO_PORT
     3695                      : Port - LSILOGIC_SAS_BIOS_IO_PORT;
     3696    int rc = vboxscsiReadRegister(&pThis->VBoxSCSI, iRegister, pu32);
    36743697
    36753698    Log2(("%s: pu32=%p:{%.*Rhxs} iRegister=%d rc=%Rrc\n",
     
    36833706 *
    36843707 * @returns VBox status code.
    3685  * @param   pLsiLogic    Pointer to the LsiLogic device instance.
    3686  */
    3687 static int lsilogicPrepareBIOSSCSIRequest(PLSILOGICSCSI pLsiLogic)
     3708 * @param   pThis       Pointer to the LsiLogic device state.
     3709 */
     3710static int lsilogicR3PrepareBiosScsiRequest(PLSILOGICSCSI pThis)
    36883711{
    36893712    int rc;
     
    36913714    uint32_t           uTargetDevice;
    36923715
    3693     rc = RTMemCacheAllocEx(pLsiLogic->hTaskCache, (void **)&pTaskState);
     3716    rc = RTMemCacheAllocEx(pThis->hTaskCache, (void **)&pTaskState);
    36943717    AssertMsgRCReturn(rc, ("Getting task from cache failed rc=%Rrc\n", rc), rc);
    36953718
    36963719    pTaskState->fBIOS = true;
    36973720
    3698     rc = vboxscsiSetupRequest(&pLsiLogic->VBoxSCSI, &pTaskState->PDMScsiRequest, &uTargetDevice);
     3721    rc = vboxscsiSetupRequest(&pThis->VBoxSCSI, &pTaskState->PDMScsiRequest, &uTargetDevice);
    36993722    AssertMsgRCReturn(rc, ("Setting up SCSI request failed rc=%Rrc\n", rc), rc);
    37003723
    37013724    pTaskState->PDMScsiRequest.pvUser = pTaskState;
    37023725
    3703     if (uTargetDevice < pLsiLogic->cDeviceStates)
    3704     {
    3705         pTaskState->pTargetDevice = &pLsiLogic->paDeviceStates[uTargetDevice];
     3726    if (uTargetDevice < pThis->cDeviceStates)
     3727    {
     3728        pTaskState->pTargetDevice = &pThis->paDeviceStates[uTargetDevice];
    37063729
    37073730        if (pTaskState->pTargetDevice->pDrvBase)
     
    37263749    ScsiInquiryData.u3PeripheralQualifier = SCSI_INQUIRY_DATA_PERIPHERAL_QUALIFIER_NOT_CONNECTED_NOT_SUPPORTED;
    37273750
    3728     memcpy(pLsiLogic->VBoxSCSI.pbBuf, &ScsiInquiryData, 5);
    3729 
    3730     rc = vboxscsiRequestFinished(&pLsiLogic->VBoxSCSI, &pTaskState->PDMScsiRequest, SCSI_STATUS_OK);
     3751    memcpy(pThis->VBoxSCSI.pbBuf, &ScsiInquiryData, 5);
     3752
     3753    rc = vboxscsiRequestFinished(&pThis->VBoxSCSI, &pTaskState->PDMScsiRequest, SCSI_STATUS_OK);
    37313754    AssertMsgRCReturn(rc, ("Finishing BIOS SCSI request failed rc=%Rrc\n", rc), rc);
    37323755
    3733     RTMemCacheFree(pLsiLogic->hTaskCache, pTaskState);
     3756    RTMemCacheFree(pThis->hTaskCache, pTaskState);
    37343757    return rc;
    37353758}
    37363759
    37373760/**
    3738  * Port I/O Handler for OUT operations - legacy port.
    3739  *
    3740  * @returns VBox status code.
    3741  *
    3742  * @param   pDevIns     The device instance.
    3743  * @param   pvUser      User argument.
    3744  * @param   uPort       Port number used for the IN operation.
    3745  * @param   u32         The value to output.
    3746  * @param   cb          The value size in bytes.
    3747  */
    3748 static int lsilogicIsaIOPortWrite (PPDMDEVINS pDevIns, void *pvUser,
    3749                                    RTIOPORT Port, uint32_t u32, unsigned cb)
    3750 {
    3751     int rc;
     3761 * @callback_method_impl{FNIOMIOPORTOUT, Legacy ISA port.}
     3762 */
     3763static DECLCALLBACK(int) lsilogicR3IsaIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
     3764{
    37523765    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
    3753 
    3754     Log2(("#%d %s: pvUser=%#p cb=%d u32=%#x Port=%#x\n",
    3755           pDevIns->iInstance, __FUNCTION__, pvUser, cb, u32, Port));
     3766    Log2(("#%d %s: pvUser=%#p cb=%d u32=%#x Port=%#x\n", pDevIns->iInstance, __FUNCTION__, pvUser, cb, u32, Port));
    37563767
    37573768    Assert(cb == 1);
    37583769
    3759     uint8_t iRegister =   pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI
    3760                         ? Port - LSILOGIC_BIOS_IO_PORT
    3761                         : Port - LSILOGIC_SAS_BIOS_IO_PORT;
    3762     rc = vboxscsiWriteRegister(&pThis->VBoxSCSI, iRegister, (uint8_t)u32);
     3770    uint8_t iRegister = pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI
     3771                      ? Port - LSILOGIC_BIOS_IO_PORT
     3772                      : Port - LSILOGIC_SAS_BIOS_IO_PORT;
     3773    int rc = vboxscsiWriteRegister(&pThis->VBoxSCSI, iRegister, (uint8_t)u32);
    37633774    if (rc == VERR_MORE_DATA)
    37643775    {
    3765         rc = lsilogicPrepareBIOSSCSIRequest(pThis);
     3776        rc = lsilogicR3PrepareBiosScsiRequest(pThis);
    37663777        AssertRC(rc);
    37673778    }
     
    37733784
    37743785/**
    3775  * Port I/O Handler for primary port range OUT string operations.
    3776  * @see FNIOMIOPORTOUTSTRING for details.
    3777  */
    3778 static DECLCALLBACK(int) lsilogicIsaIOPortWriteStr(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfer, unsigned cb)
     3786 * @callback_method_impl{FNIOMIOPORTOUTSTRING,
     3787 * Port I/O Handler for primary port range OUT string operations.}
     3788 */
     3789static DECLCALLBACK(int) lsilogicR3IsaIOPortWriteStr(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port,
     3790                                                     PRTGCPTR pGCPtrSrc, PRTGCUINTREG pcTransfer, unsigned cb)
    37793791{
    37803792    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
    3781     int rc;
    3782 
    3783     Log2(("#%d %s: pvUser=%#p cb=%d Port=%#x\n",
    3784           pDevIns->iInstance, __FUNCTION__, pvUser, cb, Port));
    3785 
    3786     uint8_t iRegister =   pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI
    3787                         ? Port - LSILOGIC_BIOS_IO_PORT
    3788                         : Port - LSILOGIC_SAS_BIOS_IO_PORT;
    3789     rc = vboxscsiWriteString(pDevIns, &pThis->VBoxSCSI, iRegister,
    3790                              pGCPtrSrc, pcTransfer, cb);
     3793    Log2(("#%d %s: pvUser=%#p cb=%d Port=%#x\n", pDevIns->iInstance, __FUNCTION__, pvUser, cb, Port));
     3794
     3795    uint8_t iRegister = pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI
     3796                      ? Port - LSILOGIC_BIOS_IO_PORT
     3797                      : Port - LSILOGIC_SAS_BIOS_IO_PORT;
     3798    int rc = vboxscsiWriteString(pDevIns, &pThis->VBoxSCSI, iRegister, pGCPtrSrc, pcTransfer, cb);
    37913799    if (rc == VERR_MORE_DATA)
    37923800    {
    3793         rc = lsilogicPrepareBIOSSCSIRequest(pThis);
     3801        rc = lsilogicR3PrepareBiosScsiRequest(pThis);
    37943802        AssertRC(rc);
    37953803    }
     
    38013809
    38023810/**
    3803  * Port I/O Handler for primary port range IN string operations.
    3804  * @see FNIOMIOPORTINSTRING for details.
    3805  */
    3806 static DECLCALLBACK(int) lsilogicIsaIOPortReadStr(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfer, unsigned cb)
     3811 * @callback_method_impl{FNIOMIOPORTINSTRING,
     3812 * Port I/O Handler for primary port range IN string operations.}
     3813 */
     3814static DECLCALLBACK(int) lsilogicR3IsaIOPortReadStr(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrDst,
     3815                                                  PRTGCUINTREG pcTransfer, unsigned cb)
    38073816{
    38083817    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     
    38183827}
    38193828
    3820 static DECLCALLBACK(int) lsilogicMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion,
    3821                                      RTGCPHYS GCPhysAddress, uint32_t cb,
    3822                                      PCIADDRESSSPACE enmType)
     3829static DECLCALLBACK(int) lsilogicR3Map(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion,
     3830                                       RTGCPHYS GCPhysAddress, uint32_t cb,
     3831                                       PCIADDRESSSPACE enmType)
    38233832{
    38243833    PPDMDEVINS pDevIns = pPciDev->pDevIns;
     
    39223931
    39233932/**
    3924  * LsiLogic status info callback.
    3925  *
    3926  * @param   pDevIns     The device instance.
    3927  * @param   pHlp        The output helpers.
    3928  * @param   pszArgs     The arguments.
    3929  */
    3930 static DECLCALLBACK(void) lsilogicInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
     3933 * @callback_method_impl{PFNDBGFHANDLERDEV}
     3934 */
     3935static DECLCALLBACK(void) lsilogicR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    39313936{
    39323937    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     
    40204025 * @returns VBox status code.
    40214026 *
    4022  * @param   pThis     The LsiLogic device instance.
    4023  */
    4024 static int lsilogicQueuesAlloc(PLSILOGICSCSI pThis)
     4027 * @param   pThis       Pointer to the LsiLogic device state.
     4028 */
     4029static int lsilogicR3QueuesAlloc(PLSILOGICSCSI pThis)
    40254030{
    40264031    PVM pVM = PDMDevHlpGetVM(pThis->pDevInsR3);
     
    40544059 * @returns nothing.
    40554060 *
    4056  * @param   pThis     The LsiLogic device instance.
    4057  */
    4058 static void lsilogicQueuesFree(PLSILOGICSCSI pThis)
     4061 * @param   pThis       Pointer to the LsiLogic device state.
     4062 */
     4063static void lsilogicR3QueuesFree(PLSILOGICSCSI pThis)
    40594064{
    40604065    PVM pVM = PDMDevHlpGetVM(pThis->pDevInsR3);
     
    40764081 *
    40774082 * @returns nothing.
    4078  * @param   pThis    The LsiLogic device instance.
    4079  */
    4080 static void lsilogicKick(PLSILOGICSCSI pThis)
     4083 * @param   pThis       Pointer to the LsiLogic device state.
     4084 */
     4085static void lsilogicR3Kick(PLSILOGICSCSI pThis)
    40814086{
    40824087    if (pThis->fNotificationSend)
     
    40904095    {
    40914096        /* The BIOS had a request active when we got suspended. Resume it. */
    4092         int rc = lsilogicPrepareBIOSSCSIRequest(pThis);
     4097        int rc = lsilogicR3PrepareBiosScsiRequest(pThis);
    40934098        AssertRC(rc);
    40944099    }
     
    40964101}
    40974102
    4098 static DECLCALLBACK(int) lsilogicLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
     4103
     4104/*
     4105 * Saved state.
     4106 */
     4107
     4108/**
     4109 * @callback_method_impl{FNSSMDEVLIVEEXEC}
     4110 */
     4111static DECLCALLBACK(int) lsilogicR3LiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
    40994112{
    41004113    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     
    41114124}
    41124125
    4113 static DECLCALLBACK(int) lsilogicSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    4114 {
    4115     PLSILOGICSCSI pLsiLogic = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4126/**
     4127 * @callback_method_impl{FNSSMDEVSAVEEXEC}
     4128 */
     4129static DECLCALLBACK(int) lsilogicR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
     4130{
     4131    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
    41164132
    41174133    /* Every device first. */
    4118     lsilogicLiveExec(pDevIns, pSSM, SSM_PASS_FINAL);
    4119     for (unsigned i = 0; i < pLsiLogic->cDeviceStates; i++)
    4120     {
    4121         PLSILOGICDEVICE pDevice = &pLsiLogic->paDeviceStates[i];
     4134    lsilogicR3LiveExec(pDevIns, pSSM, SSM_PASS_FINAL);
     4135    for (unsigned i = 0; i < pThis->cDeviceStates; i++)
     4136    {
     4137        PLSILOGICDEVICE pDevice = &pThis->paDeviceStates[i];
    41224138
    41234139        AssertMsg(!pDevice->cOutstandingRequests,
     
    41264142    }
    41274143    /* Now the main device state. */
    4128     SSMR3PutU32   (pSSM, pLsiLogic->enmState);
    4129     SSMR3PutU32   (pSSM, pLsiLogic->enmWhoInit);
    4130     SSMR3PutBool  (pSSM, pLsiLogic->fDoorbellInProgress);
    4131     SSMR3PutBool  (pSSM, pLsiLogic->fDiagnosticEnabled);
    4132     SSMR3PutBool  (pSSM, pLsiLogic->fNotificationSend);
    4133     SSMR3PutBool  (pSSM, pLsiLogic->fEventNotificationEnabled);
    4134     SSMR3PutU32   (pSSM, pLsiLogic->uInterruptMask);
    4135     SSMR3PutU32   (pSSM, pLsiLogic->uInterruptStatus);
    4136     for (unsigned i = 0; i < RT_ELEMENTS(pLsiLogic->aMessage); i++)
    4137         SSMR3PutU32   (pSSM, pLsiLogic->aMessage[i]);
    4138     SSMR3PutU32   (pSSM, pLsiLogic->iMessage);
    4139     SSMR3PutU32   (pSSM, pLsiLogic->cMessage);
    4140     SSMR3PutMem   (pSSM, &pLsiLogic->ReplyBuffer, sizeof(pLsiLogic->ReplyBuffer));
    4141     SSMR3PutU32   (pSSM, pLsiLogic->uNextReplyEntryRead);
    4142     SSMR3PutU32   (pSSM, pLsiLogic->cReplySize);
    4143     SSMR3PutU16   (pSSM, pLsiLogic->u16IOCFaultCode);
    4144     SSMR3PutU32   (pSSM, pLsiLogic->u32HostMFAHighAddr);
    4145     SSMR3PutU32   (pSSM, pLsiLogic->u32SenseBufferHighAddr);
    4146     SSMR3PutU8    (pSSM, pLsiLogic->cMaxDevices);
    4147     SSMR3PutU8    (pSSM, pLsiLogic->cMaxBuses);
    4148     SSMR3PutU16   (pSSM, pLsiLogic->cbReplyFrame);
    4149     SSMR3PutU32   (pSSM, pLsiLogic->iDiagnosticAccess);
    4150     SSMR3PutU32   (pSSM, pLsiLogic->cReplyQueueEntries);
    4151     SSMR3PutU32   (pSSM, pLsiLogic->cRequestQueueEntries);
    4152     SSMR3PutU32   (pSSM, pLsiLogic->uReplyFreeQueueNextEntryFreeWrite);
    4153     SSMR3PutU32   (pSSM, pLsiLogic->uReplyFreeQueueNextAddressRead);
    4154     SSMR3PutU32   (pSSM, pLsiLogic->uReplyPostQueueNextEntryFreeWrite);
    4155     SSMR3PutU32   (pSSM, pLsiLogic->uReplyPostQueueNextAddressRead);
    4156     SSMR3PutU32   (pSSM, pLsiLogic->uRequestQueueNextEntryFreeWrite);
    4157     SSMR3PutU32   (pSSM, pLsiLogic->uRequestQueueNextAddressRead);
    4158 
    4159     for (unsigned i = 0; i < pLsiLogic->cReplyQueueEntries; i++)
    4160         SSMR3PutU32(pSSM, pLsiLogic->pReplyFreeQueueBaseR3[i]);
    4161     for (unsigned i = 0; i < pLsiLogic->cReplyQueueEntries; i++)
    4162         SSMR3PutU32(pSSM, pLsiLogic->pReplyPostQueueBaseR3[i]);
    4163     for (unsigned i = 0; i < pLsiLogic->cRequestQueueEntries; i++)
    4164         SSMR3PutU32(pSSM, pLsiLogic->pRequestQueueBaseR3[i]);
    4165 
    4166     SSMR3PutU16   (pSSM, pLsiLogic->u16NextHandle);
    4167 
    4168     PMptConfigurationPagesSupported pPages = pLsiLogic->pConfigurationPages;
     4144    SSMR3PutU32   (pSSM, pThis->enmState);
     4145    SSMR3PutU32   (pSSM, pThis->enmWhoInit);
     4146    SSMR3PutBool  (pSSM, pThis->fDoorbellInProgress);
     4147    SSMR3PutBool  (pSSM, pThis->fDiagnosticEnabled);
     4148    SSMR3PutBool  (pSSM, pThis->fNotificationSend);
     4149    SSMR3PutBool  (pSSM, pThis->fEventNotificationEnabled);
     4150    SSMR3PutU32   (pSSM, pThis->uInterruptMask);
     4151    SSMR3PutU32   (pSSM, pThis->uInterruptStatus);
     4152    for (unsigned i = 0; i < RT_ELEMENTS(pThis->aMessage); i++)
     4153        SSMR3PutU32   (pSSM, pThis->aMessage[i]);
     4154    SSMR3PutU32   (pSSM, pThis->iMessage);
     4155    SSMR3PutU32   (pSSM, pThis->cMessage);
     4156    SSMR3PutMem   (pSSM, &pThis->ReplyBuffer, sizeof(pThis->ReplyBuffer));
     4157    SSMR3PutU32   (pSSM, pThis->uNextReplyEntryRead);
     4158    SSMR3PutU32   (pSSM, pThis->cReplySize);
     4159    SSMR3PutU16   (pSSM, pThis->u16IOCFaultCode);
     4160    SSMR3PutU32   (pSSM, pThis->u32HostMFAHighAddr);
     4161    SSMR3PutU32   (pSSM, pThis->u32SenseBufferHighAddr);
     4162    SSMR3PutU8    (pSSM, pThis->cMaxDevices);
     4163    SSMR3PutU8    (pSSM, pThis->cMaxBuses);
     4164    SSMR3PutU16   (pSSM, pThis->cbReplyFrame);
     4165    SSMR3PutU32   (pSSM, pThis->iDiagnosticAccess);
     4166    SSMR3PutU32   (pSSM, pThis->cReplyQueueEntries);
     4167    SSMR3PutU32   (pSSM, pThis->cRequestQueueEntries);
     4168    SSMR3PutU32   (pSSM, pThis->uReplyFreeQueueNextEntryFreeWrite);
     4169    SSMR3PutU32   (pSSM, pThis->uReplyFreeQueueNextAddressRead);
     4170    SSMR3PutU32   (pSSM, pThis->uReplyPostQueueNextEntryFreeWrite);
     4171    SSMR3PutU32   (pSSM, pThis->uReplyPostQueueNextAddressRead);
     4172    SSMR3PutU32   (pSSM, pThis->uRequestQueueNextEntryFreeWrite);
     4173    SSMR3PutU32   (pSSM, pThis->uRequestQueueNextAddressRead);
     4174
     4175    for (unsigned i = 0; i < pThis->cReplyQueueEntries; i++)
     4176        SSMR3PutU32(pSSM, pThis->pReplyFreeQueueBaseR3[i]);
     4177    for (unsigned i = 0; i < pThis->cReplyQueueEntries; i++)
     4178        SSMR3PutU32(pSSM, pThis->pReplyPostQueueBaseR3[i]);
     4179    for (unsigned i = 0; i < pThis->cRequestQueueEntries; i++)
     4180        SSMR3PutU32(pSSM, pThis->pRequestQueueBaseR3[i]);
     4181
     4182    SSMR3PutU16   (pSSM, pThis->u16NextHandle);
     4183
     4184    PMptConfigurationPagesSupported pPages = pThis->pConfigurationPages;
    41694185
    41704186    SSMR3PutMem   (pSSM, &pPages->ManufacturingPage0, sizeof(MptConfigurationPageManufacturing0));
     
    41944210
    41954211    /* Device dependent pages */
    4196     if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
     4212    if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
    41974213    {
    41984214        PMptConfigurationPagesSpi pSpiPages = &pPages->u.SpiPages;
     
    42104226        }
    42114227    }
    4212     else if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
     4228    else if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    42134229    {
    42144230        PMptConfigurationPagesSas pSasPages = &pPages->u.SasPages;
     
    42474263    }
    42484264    else
    4249         AssertMsgFailed(("Invalid controller type %d\n", pLsiLogic->enmCtrlType));
     4265        AssertMsgFailed(("Invalid controller type %d\n", pThis->enmCtrlType));
    42504266
    42514267    /* Now the data for the BIOS interface. */
    4252     SSMR3PutU8    (pSSM, pLsiLogic->VBoxSCSI.regIdentify);
    4253     SSMR3PutU8    (pSSM, pLsiLogic->VBoxSCSI.uTargetDevice);
    4254     SSMR3PutU8    (pSSM, pLsiLogic->VBoxSCSI.uTxDir);
    4255     SSMR3PutU8    (pSSM, pLsiLogic->VBoxSCSI.cbCDB);
    4256     SSMR3PutMem   (pSSM, pLsiLogic->VBoxSCSI.abCDB, sizeof(pLsiLogic->VBoxSCSI.abCDB));
    4257     SSMR3PutU8    (pSSM, pLsiLogic->VBoxSCSI.iCDB);
    4258     SSMR3PutU32   (pSSM, pLsiLogic->VBoxSCSI.cbBuf);
    4259     SSMR3PutU32   (pSSM, pLsiLogic->VBoxSCSI.iBuf);
    4260     SSMR3PutBool  (pSSM, pLsiLogic->VBoxSCSI.fBusy);
    4261     SSMR3PutU8    (pSSM, pLsiLogic->VBoxSCSI.enmState);
    4262     if (pLsiLogic->VBoxSCSI.cbBuf)
    4263         SSMR3PutMem(pSSM, pLsiLogic->VBoxSCSI.pbBuf, pLsiLogic->VBoxSCSI.cbBuf);
     4268    SSMR3PutU8    (pSSM, pThis->VBoxSCSI.regIdentify);
     4269    SSMR3PutU8    (pSSM, pThis->VBoxSCSI.uTargetDevice);
     4270    SSMR3PutU8    (pSSM, pThis->VBoxSCSI.uTxDir);
     4271    SSMR3PutU8    (pSSM, pThis->VBoxSCSI.cbCDB);
     4272    SSMR3PutMem   (pSSM, pThis->VBoxSCSI.abCDB, sizeof(pThis->VBoxSCSI.abCDB));
     4273    SSMR3PutU8    (pSSM, pThis->VBoxSCSI.iCDB);
     4274    SSMR3PutU32   (pSSM, pThis->VBoxSCSI.cbBuf);
     4275    SSMR3PutU32   (pSSM, pThis->VBoxSCSI.iBuf);
     4276    SSMR3PutBool  (pSSM, pThis->VBoxSCSI.fBusy);
     4277    SSMR3PutU8    (pSSM, pThis->VBoxSCSI.enmState);
     4278    if (pThis->VBoxSCSI.cbBuf)
     4279        SSMR3PutMem(pSSM, pThis->VBoxSCSI.pbBuf, pThis->VBoxSCSI.cbBuf);
    42644280
    42654281    return SSMR3PutU32(pSSM, ~0);
    42664282}
    42674283
    4268 static DECLCALLBACK(int) lsilogicLoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
     4284/**
     4285 * @callback_method_impl{FNSSMDEVLOADDONE}
     4286 */
     4287static DECLCALLBACK(int) lsilogicR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    42694288{
    42704289    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
    42714290
    4272     lsilogicKick(pThis);
     4291    lsilogicR3Kick(pThis);
    42734292    return VINF_SUCCESS;
    42744293}
    42754294
    4276 static DECLCALLBACK(int) lsilogicLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    4277 {
    4278     PLSILOGICSCSI   pLsiLogic = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4295/**
     4296 * @callback_method_impl{FNSSMDEVLOADEXEC}
     4297 */
     4298static DECLCALLBACK(int) lsilogicR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
     4299{
     4300    PLSILOGICSCSI   pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
    42794301    int             rc;
    42804302
     
    42974319        AssertRCReturn(rc, rc);
    42984320
    4299         if (enmCtrlType != pLsiLogic->enmCtrlType)
     4321        if (enmCtrlType != pThis->enmCtrlType)
    43004322            return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Target config mismatch (Controller type): config=%d state=%d"),
    4301                                     pLsiLogic->enmCtrlType, enmCtrlType);
    4302         if (cDeviceStates != pLsiLogic->cDeviceStates)
     4323                                    pThis->enmCtrlType, enmCtrlType);
     4324        if (cDeviceStates != pThis->cDeviceStates)
    43034325            return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Target config mismatch (Device states): config=%u state=%u"),
    4304                                     pLsiLogic->cDeviceStates, cDeviceStates);
    4305         if (cPorts != pLsiLogic->cPorts)
     4326                                    pThis->cDeviceStates, cDeviceStates);
     4327        if (cPorts != pThis->cPorts)
    43064328            return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Target config mismatch (Ports): config=%u state=%u"),
    4307                                     pLsiLogic->cPorts, cPorts);
     4329                                    pThis->cPorts, cPorts);
    43084330    }
    43094331    if (uVersion > LSILOGIC_SAVED_STATE_VERSION_VBOX_30)
    43104332    {
    4311         for (unsigned i = 0; i < pLsiLogic->cDeviceStates; i++)
     4333        for (unsigned i = 0; i < pThis->cDeviceStates; i++)
    43124334        {
    43134335            bool fPresent;
    43144336            rc = SSMR3GetBool(pSSM, &fPresent);
    43154337            AssertRCReturn(rc, rc);
    4316             if (fPresent != (pLsiLogic->paDeviceStates[i].pDrvBase != NULL))
     4338            if (fPresent != (pThis->paDeviceStates[i].pDrvBase != NULL))
    43174339                return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Target %u config mismatch: config=%RTbool state=%RTbool"),
    4318                                          i, pLsiLogic->paDeviceStates[i].pDrvBase != NULL, fPresent);
     4340                                         i, pThis->paDeviceStates[i].pDrvBase != NULL, fPresent);
    43194341        }
    43204342    }
     
    43234345
    43244346    /* Every device first. */
    4325     for (unsigned i = 0; i < pLsiLogic->cDeviceStates; i++)
    4326     {
    4327         PLSILOGICDEVICE pDevice = &pLsiLogic->paDeviceStates[i];
     4347    for (unsigned i = 0; i < pThis->cDeviceStates; i++)
     4348    {
     4349        PLSILOGICDEVICE pDevice = &pThis->paDeviceStates[i];
    43284350
    43294351        AssertMsg(!pDevice->cOutstandingRequests,
     
    43324354    }
    43334355    /* Now the main device state. */
    4334     SSMR3GetU32   (pSSM, (uint32_t *)&pLsiLogic->enmState);
    4335     SSMR3GetU32   (pSSM, (uint32_t *)&pLsiLogic->enmWhoInit);
    4336     SSMR3GetBool  (pSSM, &pLsiLogic->fDoorbellInProgress);
    4337     SSMR3GetBool  (pSSM, &pLsiLogic->fDiagnosticEnabled);
    4338     SSMR3GetBool  (pSSM, &pLsiLogic->fNotificationSend);
    4339     SSMR3GetBool  (pSSM, &pLsiLogic->fEventNotificationEnabled);
    4340     SSMR3GetU32   (pSSM, (uint32_t *)&pLsiLogic->uInterruptMask);
    4341     SSMR3GetU32   (pSSM, (uint32_t *)&pLsiLogic->uInterruptStatus);
    4342     for (unsigned i = 0; i < RT_ELEMENTS(pLsiLogic->aMessage); i++)
    4343         SSMR3GetU32   (pSSM, &pLsiLogic->aMessage[i]);
    4344     SSMR3GetU32   (pSSM, &pLsiLogic->iMessage);
    4345     SSMR3GetU32   (pSSM, &pLsiLogic->cMessage);
    4346     SSMR3GetMem   (pSSM, &pLsiLogic->ReplyBuffer, sizeof(pLsiLogic->ReplyBuffer));
    4347     SSMR3GetU32   (pSSM, &pLsiLogic->uNextReplyEntryRead);
    4348     SSMR3GetU32   (pSSM, &pLsiLogic->cReplySize);
    4349     SSMR3GetU16   (pSSM, &pLsiLogic->u16IOCFaultCode);
    4350     SSMR3GetU32   (pSSM, &pLsiLogic->u32HostMFAHighAddr);
    4351     SSMR3GetU32   (pSSM, &pLsiLogic->u32SenseBufferHighAddr);
    4352     SSMR3GetU8    (pSSM, &pLsiLogic->cMaxDevices);
    4353     SSMR3GetU8    (pSSM, &pLsiLogic->cMaxBuses);
    4354     SSMR3GetU16   (pSSM, &pLsiLogic->cbReplyFrame);
    4355     SSMR3GetU32   (pSSM, &pLsiLogic->iDiagnosticAccess);
     4356    SSMR3GetU32   (pSSM, (uint32_t *)&pThis->enmState);
     4357    SSMR3GetU32   (pSSM, (uint32_t *)&pThis->enmWhoInit);
     4358    SSMR3GetBool  (pSSM, &pThis->fDoorbellInProgress);
     4359    SSMR3GetBool  (pSSM, &pThis->fDiagnosticEnabled);
     4360    SSMR3GetBool  (pSSM, &pThis->fNotificationSend);
     4361    SSMR3GetBool  (pSSM, &pThis->fEventNotificationEnabled);
     4362    SSMR3GetU32   (pSSM, (uint32_t *)&pThis->uInterruptMask);
     4363    SSMR3GetU32   (pSSM, (uint32_t *)&pThis->uInterruptStatus);
     4364    for (unsigned i = 0; i < RT_ELEMENTS(pThis->aMessage); i++)
     4365        SSMR3GetU32   (pSSM, &pThis->aMessage[i]);
     4366    SSMR3GetU32   (pSSM, &pThis->iMessage);
     4367    SSMR3GetU32   (pSSM, &pThis->cMessage);
     4368    SSMR3GetMem   (pSSM, &pThis->ReplyBuffer, sizeof(pThis->ReplyBuffer));
     4369    SSMR3GetU32   (pSSM, &pThis->uNextReplyEntryRead);
     4370    SSMR3GetU32   (pSSM, &pThis->cReplySize);
     4371    SSMR3GetU16   (pSSM, &pThis->u16IOCFaultCode);
     4372    SSMR3GetU32   (pSSM, &pThis->u32HostMFAHighAddr);
     4373    SSMR3GetU32   (pSSM, &pThis->u32SenseBufferHighAddr);
     4374    SSMR3GetU8    (pSSM, &pThis->cMaxDevices);
     4375    SSMR3GetU8    (pSSM, &pThis->cMaxBuses);
     4376    SSMR3GetU16   (pSSM, &pThis->cbReplyFrame);
     4377    SSMR3GetU32   (pSSM, &pThis->iDiagnosticAccess);
    43564378
    43574379    uint32_t cReplyQueueEntries, cRequestQueueEntries;
     
    43594381    SSMR3GetU32   (pSSM, &cRequestQueueEntries);
    43604382
    4361     if (   cReplyQueueEntries != pLsiLogic->cReplyQueueEntries
    4362         || cRequestQueueEntries != pLsiLogic->cRequestQueueEntries)
     4383    if (   cReplyQueueEntries != pThis->cReplyQueueEntries
     4384        || cRequestQueueEntries != pThis->cRequestQueueEntries)
    43634385    {
    43644386        LogFlow(("Reallocating queues cReplyQueueEntries=%u cRequestQueuEntries=%u\n",
    43654387                 cReplyQueueEntries, cRequestQueueEntries));
    4366         lsilogicQueuesFree(pLsiLogic);
    4367         pLsiLogic->cReplyQueueEntries = cReplyQueueEntries;
    4368         pLsiLogic->cRequestQueueEntries = cRequestQueueEntries;
    4369         rc = lsilogicQueuesAlloc(pLsiLogic);
     4388        lsilogicR3QueuesFree(pThis);
     4389        pThis->cReplyQueueEntries = cReplyQueueEntries;
     4390        pThis->cRequestQueueEntries = cRequestQueueEntries;
     4391        rc = lsilogicR3QueuesAlloc(pThis);
    43704392        if (RT_FAILURE(rc))
    43714393            return rc;
    43724394    }
    43734395
    4374     SSMR3GetU32   (pSSM, (uint32_t *)&pLsiLogic->uReplyFreeQueueNextEntryFreeWrite);
    4375     SSMR3GetU32   (pSSM, (uint32_t *)&pLsiLogic->uReplyFreeQueueNextAddressRead);
    4376     SSMR3GetU32   (pSSM, (uint32_t *)&pLsiLogic->uReplyPostQueueNextEntryFreeWrite);
    4377     SSMR3GetU32   (pSSM, (uint32_t *)&pLsiLogic->uReplyPostQueueNextAddressRead);
    4378     SSMR3GetU32   (pSSM, (uint32_t *)&pLsiLogic->uRequestQueueNextEntryFreeWrite);
    4379     SSMR3GetU32   (pSSM, (uint32_t *)&pLsiLogic->uRequestQueueNextAddressRead);
    4380 
    4381     PMptConfigurationPagesSupported pPages = pLsiLogic->pConfigurationPages;
     4396    SSMR3GetU32   (pSSM, (uint32_t *)&pThis->uReplyFreeQueueNextEntryFreeWrite);
     4397    SSMR3GetU32   (pSSM, (uint32_t *)&pThis->uReplyFreeQueueNextAddressRead);
     4398    SSMR3GetU32   (pSSM, (uint32_t *)&pThis->uReplyPostQueueNextEntryFreeWrite);
     4399    SSMR3GetU32   (pSSM, (uint32_t *)&pThis->uReplyPostQueueNextAddressRead);
     4400    SSMR3GetU32   (pSSM, (uint32_t *)&pThis->uRequestQueueNextEntryFreeWrite);
     4401    SSMR3GetU32   (pSSM, (uint32_t *)&pThis->uRequestQueueNextAddressRead);
     4402
     4403    PMptConfigurationPagesSupported pPages = pThis->pConfigurationPages;
    43824404
    43834405    if (uVersion <= LSILOGIC_SAVED_STATE_VERSION_PRE_SAS)
     
    43864408        MptConfigurationPagesSupported_SSM_V2 ConfigPagesV2;
    43874409
    4388         if (pLsiLogic->enmCtrlType != LSILOGICCTRLTYPE_SCSI_SPI)
     4410        if (pThis->enmCtrlType != LSILOGICCTRLTYPE_SCSI_SPI)
    43894411            return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch: Expected SPI SCSI controller"));
    43904412
     
    44234445    {
    44244446        /* Queue content */
    4425         for (unsigned i = 0; i < pLsiLogic->cReplyQueueEntries; i++)
    4426             SSMR3GetU32(pSSM, (uint32_t *)&pLsiLogic->pReplyFreeQueueBaseR3[i]);
    4427         for (unsigned i = 0; i < pLsiLogic->cReplyQueueEntries; i++)
    4428             SSMR3GetU32(pSSM, (uint32_t *)&pLsiLogic->pReplyPostQueueBaseR3[i]);
    4429         for (unsigned i = 0; i < pLsiLogic->cRequestQueueEntries; i++)
    4430             SSMR3GetU32(pSSM, (uint32_t *)&pLsiLogic->pRequestQueueBaseR3[i]);
    4431 
    4432         SSMR3GetU16(pSSM, &pLsiLogic->u16NextHandle);
     4447        for (unsigned i = 0; i < pThis->cReplyQueueEntries; i++)
     4448            SSMR3GetU32(pSSM, (uint32_t *)&pThis->pReplyFreeQueueBaseR3[i]);
     4449        for (unsigned i = 0; i < pThis->cReplyQueueEntries; i++)
     4450            SSMR3GetU32(pSSM, (uint32_t *)&pThis->pReplyPostQueueBaseR3[i]);
     4451        for (unsigned i = 0; i < pThis->cRequestQueueEntries; i++)
     4452            SSMR3GetU32(pSSM, (uint32_t *)&pThis->pRequestQueueBaseR3[i]);
     4453
     4454        SSMR3GetU16(pSSM, &pThis->u16NextHandle);
    44334455
    44344456        /* Configuration pages */
     
    44594481
    44604482        /* Device dependent pages */
    4461         if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
     4483        if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
    44624484        {
    44634485            PMptConfigurationPagesSpi pSpiPages = &pPages->u.SpiPages;
     
    44754497            }
    44764498        }
    4477         else if (pLsiLogic->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
     4499        else if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    44784500        {
    44794501            uint32_t cbPage0, cbPage1, cPHYs, cbManufacturingPage7;
     
    45284550        }
    45294551        else
    4530             AssertMsgFailed(("Invalid controller type %d\n", pLsiLogic->enmCtrlType));
     4552            AssertMsgFailed(("Invalid controller type %d\n", pThis->enmCtrlType));
    45314553    }
    45324554
    45334555    /* Now the data for the BIOS interface. */
    4534     SSMR3GetU8  (pSSM, &pLsiLogic->VBoxSCSI.regIdentify);
    4535     SSMR3GetU8  (pSSM, &pLsiLogic->VBoxSCSI.uTargetDevice);
    4536     SSMR3GetU8  (pSSM, &pLsiLogic->VBoxSCSI.uTxDir);
    4537     SSMR3GetU8  (pSSM, &pLsiLogic->VBoxSCSI.cbCDB);
    4538     SSMR3GetMem (pSSM, pLsiLogic->VBoxSCSI.abCDB, sizeof(pLsiLogic->VBoxSCSI.abCDB));
    4539     SSMR3GetU8  (pSSM, &pLsiLogic->VBoxSCSI.iCDB);
    4540     SSMR3GetU32 (pSSM, &pLsiLogic->VBoxSCSI.cbBuf);
    4541     SSMR3GetU32 (pSSM, &pLsiLogic->VBoxSCSI.iBuf);
    4542     SSMR3GetBool(pSSM, (bool *)&pLsiLogic->VBoxSCSI.fBusy);
    4543     SSMR3GetU8  (pSSM, (uint8_t *)&pLsiLogic->VBoxSCSI.enmState);
    4544     if (pLsiLogic->VBoxSCSI.cbBuf)
    4545     {
    4546         pLsiLogic->VBoxSCSI.pbBuf = (uint8_t *)RTMemAllocZ(pLsiLogic->VBoxSCSI.cbBuf);
    4547         if (!pLsiLogic->VBoxSCSI.pbBuf)
     4556    SSMR3GetU8  (pSSM, &pThis->VBoxSCSI.regIdentify);
     4557    SSMR3GetU8  (pSSM, &pThis->VBoxSCSI.uTargetDevice);
     4558    SSMR3GetU8  (pSSM, &pThis->VBoxSCSI.uTxDir);
     4559    SSMR3GetU8  (pSSM, &pThis->VBoxSCSI.cbCDB);
     4560    SSMR3GetMem (pSSM, pThis->VBoxSCSI.abCDB, sizeof(pThis->VBoxSCSI.abCDB));
     4561    SSMR3GetU8  (pSSM, &pThis->VBoxSCSI.iCDB);
     4562    SSMR3GetU32 (pSSM, &pThis->VBoxSCSI.cbBuf);
     4563    SSMR3GetU32 (pSSM, &pThis->VBoxSCSI.iBuf);
     4564    SSMR3GetBool(pSSM, (bool *)&pThis->VBoxSCSI.fBusy);
     4565    SSMR3GetU8  (pSSM, (uint8_t *)&pThis->VBoxSCSI.enmState);
     4566    if (pThis->VBoxSCSI.cbBuf)
     4567    {
     4568        pThis->VBoxSCSI.pbBuf = (uint8_t *)RTMemAllocZ(pThis->VBoxSCSI.cbBuf);
     4569        if (!pThis->VBoxSCSI.pbBuf)
    45484570        {
    45494571            LogRel(("LsiLogic: Out of memory during restore.\n"));
     
    45514573                                    N_("LsiLogic: Out of memory during restore\n"));
    45524574        }
    4553         SSMR3GetMem(pSSM, pLsiLogic->VBoxSCSI.pbBuf, pLsiLogic->VBoxSCSI.cbBuf);
     4575        SSMR3GetMem(pSSM, pThis->VBoxSCSI.pbBuf, pThis->VBoxSCSI.cbBuf);
    45544576    }
    45554577
     
    45634585}
    45644586
    4565 /**
    4566  * Gets the pointer to the status LED of a device - called from the SCSi driver.
     4587
     4588/*
     4589 * The device level IBASE and LED interfaces.
     4590 */
     4591
     4592/**
     4593 * @interface_method_impl{PDMILEDPORTS,pfnQueryInterface, For a SCSI device.}
    45674594 *
    4568  * @returns VBox status code.
    4569  * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    4570  * @param   iLUN            The unit which status LED we desire. Always 0 here as the driver
    4571  *                          doesn't know about other LUN's.
    4572  * @param   ppLed           Where to store the LED pointer.
    4573  */
    4574 static DECLCALLBACK(int) lsilogicDeviceQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
    4575 {
    4576     PLSILOGICDEVICE pDevice = PDMILEDPORTS_2_PLSILOGICDEVICE(pInterface);
     4595 * @remarks Called by the scsi driver, proxying the main calls.
     4596 */
     4597static DECLCALLBACK(int) lsilogicR3DeviceQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
     4598{
     4599    PLSILOGICDEVICE pDevice = RT_FROM_MEMBER(pInterface, LSILOGICDEVICE, ILed);
    45774600    if (iLUN == 0)
    45784601    {
     
    45884611 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    45894612 */
    4590 static DECLCALLBACK(void *) lsilogicDeviceQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    4591 {
    4592     PLSILOGICDEVICE pDevice = PDMIBASE_2_PLSILOGICDEVICE(pInterface);
     4613static DECLCALLBACK(void *) lsilogicR3DeviceQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     4614{
     4615    PLSILOGICDEVICE pDevice = RT_FROM_MEMBER(pInterface, LSILOGICDEVICE, IBase);
    45934616
    45944617    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDevice->IBase);
     
    45974620    return NULL;
    45984621}
     4622
     4623
     4624/*
     4625 * The controller level IBASE and LED interfaces.
     4626 */
    45994627
    46004628/**
     
    46064634 * @param   ppLed           Where to store the LED pointer.
    46074635 */
    4608 static DECLCALLBACK(int) lsilogicStatusQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
    4609 {
    4610     PLSILOGICSCSI pLsiLogic = PDMILEDPORTS_2_PLSILOGICSCSI(pInterface);
    4611     if (iLUN < pLsiLogic->cDeviceStates)
    4612     {
    4613         *ppLed = &pLsiLogic->paDeviceStates[iLUN].Led;
     4636static DECLCALLBACK(int) lsilogicR3StatusQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
     4637{
     4638    PLSILOGICSCSI pThis = RT_FROM_MEMBER(pInterface, LSILOGICSCSI, ILeds);
     4639    if (iLUN < pThis->cDeviceStates)
     4640    {
     4641        *ppLed = &pThis->paDeviceStates[iLUN].Led;
    46144642        Assert((*ppLed)->u32Magic == PDMLED_MAGIC);
    46154643        return VINF_SUCCESS;
     
    46214649 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    46224650 */
    4623 static DECLCALLBACK(void *) lsilogicStatusQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    4624 {
    4625     PLSILOGICSCSI pThis = PDMIBASE_2_PLSILOGICSCSI(pInterface);
     4651static DECLCALLBACK(void *) lsilogicR3StatusQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     4652{
     4653    PLSILOGICSCSI pThis = RT_FROM_MEMBER(pInterface, LSILOGICSCSI, IBase);
    46264654    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
    46274655    PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->ILeds);
     
    46294657}
    46304658
    4631 /* -=-=-=-=- Helper -=-=-=-=- */
     4659
     4660/*
     4661 * The PDM device interface and some helpers.
     4662 */
    46324663
    46334664/**
    46344665 * Checks if all asynchronous I/O is finished.
    46354666 *
    4636  * Used by lsilogicReset, lsilogicSuspend and lsilogicPowerOff.
     4667 * Used by lsilogicR3Reset, lsilogicR3Suspend and lsilogicR3PowerOff.
    46374668 *
    46384669 * @returns true if quiesced, false if busy.
     
    46574688
    46584689/**
    4659  * Callback employed by lsilogicR3Suspend and lsilogicR3PowerOff..
    4660  *
    4661  * @returns true if we've quiesced, false if we're still working.
    4662  * @param   pDevIns     The device instance.
     4690 * @callback_method_impl{FNPDMDEVASYNCNOTIFY,
     4691 * Callback employed by lsilogicR3Suspend and lsilogicR3PowerOff.}
    46634692 */
    46644693static DECLCALLBACK(bool) lsilogicR3IsAsyncSuspendOrPowerOffDone(PPDMDEVINS pDevIns)
     
    47324761
    47334762/**
    4734  * Suspend notification.
    4735  *
    4736  * @param   pDevIns     The device instance data.
    4737  */
    4738 static DECLCALLBACK(void) lsilogicSuspend(PPDMDEVINS pDevIns)
    4739 {
    4740     Log(("lsilogicSuspend\n"));
     4763 * @interface_method_impl{PDMDEVREG,pfnSuspend}
     4764 */
     4765static DECLCALLBACK(void) lsilogicR3Suspend(PPDMDEVINS pDevIns)
     4766{
     4767    Log(("lsilogicR3Suspend\n"));
    47414768    lsilogicR3SuspendOrPowerOff(pDevIns);
    47424769}
    47434770
    47444771/**
    4745  * Resume notification.
    4746  *
    4747  * @param   pDevIns     The device instance data.
    4748  */
    4749 static DECLCALLBACK(void) lsilogicResume(PPDMDEVINS pDevIns)
     4772 * @interface_method_impl{PDMDEVREG,pfnResume}
     4773 */
     4774static DECLCALLBACK(void) lsilogicR3Resume(PPDMDEVINS pDevIns)
    47504775{
    47514776    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
    47524777
    4753     Log(("lsilogicResume\n"));
    4754 
    4755     lsilogicKick(pThis);
    4756 }
    4757 
    4758 /**
    4759  * Detach notification.
     4778    Log(("lsilogicR3Resume\n"));
     4779
     4780    lsilogicR3Kick(pThis);
     4781}
     4782
     4783/**
     4784 * @interface_method_impl{PDMDEVREG,pfnDetach}
    47604785 *
    47614786 * One harddisk at one port has been unplugged.
    47624787 * The VM is suspended at this point.
    4763  *
    4764  * @param   pDevIns     The device instance.
    4765  * @param   iLUN        The logical unit which is being detached.
    4766  * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    4767  */
    4768 static DECLCALLBACK(void) lsilogicDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     4788 */
     4789static DECLCALLBACK(void) lsilogicR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    47694790{
    47704791    PLSILOGICSCSI   pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     
    47874808
    47884809/**
    4789  * Attach command.
    4790  *
    4791  * This is called when we change block driver.
    4792  *
    4793  * @returns VBox status code.
    4794  * @param   pDevIns     The device instance.
    4795  * @param   iLUN        The logical unit which is being detached.
    4796  * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    4797  */
    4798 static DECLCALLBACK(int)  lsilogicAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     4810 * @interface_method_impl{PDMDEVREG,pfnAttach}
     4811 */
     4812static DECLCALLBACK(int)  lsilogicR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    47994813{
    48004814    PLSILOGICSCSI   pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     
    48434857static void lsilogicR3ResetCommon(PPDMDEVINS pDevIns)
    48444858{
    4845     PLSILOGICSCSI pLsiLogic = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4859    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
    48464860    int rc;
    48474861
    4848     rc = lsilogicHardReset(pLsiLogic);
     4862    rc = lsilogicR3HardReset(pThis);
    48494863    AssertRC(rc);
    48504864
    4851     vboxscsiInitialize(&pLsiLogic->VBoxSCSI);
    4852 }
    4853 
    4854 /**
    4855  * Callback employed by lsilogicR3Reset.
    4856  *
    4857  * @returns true if we've quiesced, false if we're still working.
    4858  * @param   pDevIns     The device instance.
     4865    vboxscsiInitialize(&pThis->VBoxSCSI);
     4866}
     4867
     4868/**
     4869 * @callback_method_impl{FNPDMDEVASYNCNOTIFY,
     4870 * Callback employed by lsilogicR3Reset.}
    48594871 */
    48604872static DECLCALLBACK(bool) lsilogicR3IsAsyncResetDone(PPDMDEVINS pDevIns)
     
    48714883
    48724884/**
    4873  * @copydoc FNPDMDEVRESET
    4874  */
    4875 static DECLCALLBACK(void) lsilogicReset(PPDMDEVINS pDevIns)
     4885 * @interface_method_impl{PDMDEVREG,pfnReset}
     4886 */
     4887static DECLCALLBACK(void) lsilogicR3Reset(PPDMDEVINS pDevIns)
    48764888{
    48774889    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     
    48884900
    48894901/**
    4890  * @copydoc FNPDMDEVRELOCATE
    4891  */
    4892 static DECLCALLBACK(void) lsilogicRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
     4902 * @interface_method_impl{PDMDEVREG,pfnRelocate}
     4903 */
     4904static DECLCALLBACK(void) lsilogicR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    48934905{
    48944906    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     
    49044916
    49054917/**
    4906  * @copydoc FNPDMDEVDESTRUCT
    4907  */
    4908 static DECLCALLBACK(int) lsilogicDestruct(PPDMDEVINS pDevIns)
     4918 * @interface_method_impl{PDMDEVREG,pfnPowerOff}
     4919 */
     4920static DECLCALLBACK(void) lsilogicR3PowerOff(PPDMDEVINS pDevIns)
     4921{
     4922    Log(("lsilogicR3PowerOff\n"));
     4923    lsilogicR3SuspendOrPowerOff(pDevIns);
     4924}
     4925
     4926/**
     4927 * @interface_method_impl{PDMDEVREG,pfnDestruct}
     4928 */
     4929static DECLCALLBACK(int) lsilogicR3Destruct(PPDMDEVINS pDevIns)
    49094930{
    49104931    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     
    49144935    PDMR3CritSectDelete(&pThis->ReplyPostQueueCritSect);
    49154936
    4916     if (pThis->paDeviceStates)
    4917         RTMemFree(pThis->paDeviceStates);
     4937    RTMemFree(pThis->paDeviceStates);
     4938    pThis->paDeviceStates = NULL;
    49184939
    49194940    /* Destroy task cache. */
    4920     int rc = VINF_SUCCESS;
    49214941    if (pThis->hTaskCache != NIL_RTMEMCACHE)
    4922         rc = RTMemCacheDestroy(pThis->hTaskCache);
    4923 
    4924     lsilogicConfigurationPagesFree(pThis);
    4925 
    4926     return rc;
    4927 }
    4928 
    4929 /**
    4930  * Poweroff notification.
    4931  *
    4932  * @param   pDevIns Pointer to the device instance
    4933  */
    4934 static DECLCALLBACK(void) lsilogicPowerOff(PPDMDEVINS pDevIns)
    4935 {
    4936     Log(("lsilogicPowerOff\n"));
    4937     lsilogicR3SuspendOrPowerOff(pDevIns);
    4938 }
    4939 
    4940 /**
    4941  * @copydoc FNPDMDEVCONSTRUCT
    4942  */
    4943 static DECLCALLBACK(int) lsilogicConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
     4942    {
     4943        int rc = RTMemCacheDestroy(pThis->hTaskCache); Assert(rc);
     4944        pThis->hTaskCache = NIL_RTMEMCACHE;
     4945    }
     4946
     4947    lsilogicR3ConfigurationPagesFree(pThis);
     4948
     4949    return VINF_SUCCESS;
     4950}
     4951
     4952/**
     4953 * @interface_method_impl{PDMDEVREG,pfnConstruct}
     4954 */
     4955static DECLCALLBACK(int) lsilogicR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
    49444956{
    49454957    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
    49464958    int rc = VINF_SUCCESS;
    4947     char *pszCtrlType = NULL;
    49484959    char  szDevTag[20];
    4949     bool fBootable = true;
    49504960    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
     4961
     4962    /*
     4963     * Initialize enought of the state to make the destructure not trip up.
     4964     */
     4965    pThis->hTaskCache = NIL_RTMEMCACHE;
    49514966
    49524967    /*
     
    49915006    Log(("%s: RequestQueueDepth=%u\n", __FUNCTION__, pThis->cRequestQueueEntries));
    49925007
     5008    char *pszCtrlType;
    49935009    rc = CFGMR3QueryStringAllocDef(pCfg, "ControllerType",
    49945010                                   &pszCtrlType, LSILOGICSCSI_PCI_SPI_CTRLNAME);
     
    49985014    Log(("%s: ControllerType=%s\n", __FUNCTION__, pszCtrlType));
    49995015
    5000     rc = lsilogicGetCtrlTypeFromString(pThis, pszCtrlType);
     5016    rc = lsilogicR3GetCtrlTypeFromString(pThis, pszCtrlType);
    50015017    MMR3HeapFree(pszCtrlType);
    50025018
     
    50255041                                N_("LsiLogic configuration error: failed to read NumPorts as integer"));
    50265042
     5043    bool fBootable;
    50275044    rc = CFGMR3QueryBoolDef(pCfg, "Bootable", &fBootable, true);
    50285045    if (RT_FAILURE(rc))
     
    50545071    PCIDevSetInterruptPin(&pThis->PciDev,   0x01); /* Interrupt pin A */
    50555072
    5056 #ifdef VBOX_WITH_MSI_DEVICES
     5073# ifdef VBOX_WITH_MSI_DEVICES
    50575074    PCIDevSetStatus(&pThis->PciDev,   VBOX_PCI_STATUS_CAP_LIST);
    50585075    PCIDevSetCapabilityList(&pThis->PciDev, 0x80);
    5059 #endif
     5076# endif
    50605077
    50615078    pThis->pDevInsR3 = pDevIns;
    50625079    pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    50635080    pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    5064     pThis->IBase.pfnQueryInterface = lsilogicStatusQueryInterface;
    5065     pThis->ILeds.pfnQueryStatusLed = lsilogicStatusQueryStatusLed;
     5081    pThis->IBase.pfnQueryInterface = lsilogicR3StatusQueryInterface;
     5082    pThis->ILeds.pfnQueryStatusLed = lsilogicR3StatusQueryStatusLed;
    50665083
    50675084    /*
    50685085     * Register the PCI device, it's I/O regions.
    50695086     */
    5070     rc = PDMDevHlpPCIRegister (pDevIns, &pThis->PciDev);
     5087    rc = PDMDevHlpPCIRegister(pDevIns, &pThis->PciDev);
    50715088    if (RT_FAILURE(rc))
    50725089        return rc;
    50735090
    5074 #ifdef VBOX_WITH_MSI_DEVICES
     5091# ifdef VBOX_WITH_MSI_DEVICES
    50755092    PDMMSIREG MsiReg;
    50765093    RT_ZERO(MsiReg);
    50775094    /* use this code for MSI-X support */
    5078 # if 0
     5095#  if 0
    50795096    MsiReg.cMsixVectors    = 1;
    50805097    MsiReg.iMsixCapOffset  = 0x80;
    50815098    MsiReg.iMsixNextOffset = 0x00;
    50825099    MsiReg.iMsixBar        = 3;
    5083 # else
     5100#  else
    50845101    MsiReg.cMsiVectors     = 1;
    50855102    MsiReg.iMsiCapOffset   = 0x80;
    50865103    MsiReg.iMsiNextOffset  = 0x00;
    5087 # endif
     5104#  endif
    50885105    rc = PDMDevHlpPCIRegisterMsi(pDevIns, &MsiReg);
    50895106    if (RT_FAILURE (rc))
     
    50935110        PCIDevSetCapabilityList(&pThis->PciDev, 0x0);
    50945111    }
    5095 #endif
    5096 
    5097     rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, LSILOGIC_PCI_SPACE_IO_SIZE, PCI_ADDRESS_SPACE_IO, lsilogicMap);
     5112# endif
     5113
     5114    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, LSILOGIC_PCI_SPACE_IO_SIZE, PCI_ADDRESS_SPACE_IO, lsilogicR3Map);
    50985115    if (RT_FAILURE(rc))
    50995116        return rc;
    51005117
    5101     rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, LSILOGIC_PCI_SPACE_MEM_SIZE, PCI_ADDRESS_SPACE_MEM, lsilogicMap);
     5118    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, LSILOGIC_PCI_SPACE_MEM_SIZE, PCI_ADDRESS_SPACE_MEM, lsilogicR3Map);
    51025119    if (RT_FAILURE(rc))
    51035120        return rc;
    51045121
    5105     rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, LSILOGIC_PCI_SPACE_MEM_SIZE, PCI_ADDRESS_SPACE_MEM, lsilogicMap);
     5122    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, LSILOGIC_PCI_SPACE_MEM_SIZE, PCI_ADDRESS_SPACE_MEM, lsilogicR3Map);
    51065123    if (RT_FAILURE(rc))
    51075124        return rc;
     
    51115128    RTStrPrintf(szTaggedText, sizeof(szTaggedText), "%s-Task", szDevTag);
    51125129    rc = PDMDevHlpQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 2, 0,
    5113                               lsilogicNotifyQueueConsumer, true,
     5130                              lsilogicR3NotifyQueueConsumer, true,
    51145131                              szTaggedText,
    51155132                              &pThis->pNotificationQueueR3);
     
    51285145     * Allocate memory for the queues.
    51295146     */
    5130     rc = lsilogicQueuesAlloc(pThis);
     5147    rc = lsilogicR3QueuesAlloc(pThis);
    51315148    if (RT_FAILURE(rc))
    51325149        return rc;
     
    51495166     */
    51505167    rc = RTMemCacheCreate(&pThis->hTaskCache, sizeof(LSILOGICTASKSTATE), 0, UINT32_MAX,
    5151                           lsilogicTaskStateCtor, lsilogicTaskStateDtor, NULL, 0);
     5168                          lsilogicR3TaskStateCtor, lsilogicR3TaskStateDtor, NULL, 0);
    51525169    if (RT_FAILURE(rc))
    51535170        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    51785195        pDevice->pLsiLogicR3                       = pThis;
    51795196        pDevice->Led.u32Magic                      = PDMLED_MAGIC;
    5180         pDevice->IBase.pfnQueryInterface           = lsilogicDeviceQueryInterface;
    5181         pDevice->ISCSIPort.pfnSCSIRequestCompleted = lsilogicDeviceSCSIRequestCompleted;
    5182         pDevice->ISCSIPort.pfnQueryDeviceLocation  = lsilogicQueryDeviceLocation;
    5183         pDevice->ILed.pfnQueryStatusLed            = lsilogicDeviceQueryStatusLed;
     5197        pDevice->IBase.pfnQueryInterface           = lsilogicR3DeviceQueryInterface;
     5198        pDevice->ISCSIPort.pfnSCSIRequestCompleted = lsilogicR3DeviceSCSIRequestCompleted;
     5199        pDevice->ISCSIPort.pfnQueryDeviceLocation  = lsilogicR3QueryDeviceLocation;
     5200        pDevice->ILed.pfnQueryStatusLed            = lsilogicR3DeviceQueryStatusLed;
    51845201
    51855202        RTStrPrintf(szName, sizeof(szName), "Device%d", i);
     
    52315248        if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI)
    52325249            rc = PDMDevHlpIOPortRegister(pDevIns, LSILOGIC_BIOS_IO_PORT, 4, NULL,
    5233                                          lsilogicIsaIOPortWrite, lsilogicIsaIOPortRead,
    5234                                          lsilogicIsaIOPortWriteStr, lsilogicIsaIOPortReadStr,
     5250                                         lsilogicR3IsaIOPortWrite, lsilogicR3IsaIOPortRead,
     5251                                         lsilogicR3IsaIOPortWriteStr, lsilogicR3IsaIOPortReadStr,
    52355252                                         "LsiLogic BIOS");
    52365253        else if (pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SAS)
    52375254            rc = PDMDevHlpIOPortRegister(pDevIns, LSILOGIC_SAS_BIOS_IO_PORT, 4, NULL,
    5238                                          lsilogicIsaIOPortWrite, lsilogicIsaIOPortRead,
    5239                                          lsilogicIsaIOPortWriteStr, lsilogicIsaIOPortReadStr,
     5255                                         lsilogicR3IsaIOPortWrite, lsilogicR3IsaIOPortRead,
     5256                                         lsilogicR3IsaIOPortWriteStr, lsilogicR3IsaIOPortReadStr,
    52405257                                         "LsiLogic SAS BIOS");
    52415258        else
     
    52485265    /* Register save state handlers. */
    52495266    rc = PDMDevHlpSSMRegisterEx(pDevIns, LSILOGIC_SAVED_STATE_VERSION, sizeof(*pThis), NULL,
    5250                                 NULL, lsilogicLiveExec, NULL,
    5251                                 NULL, lsilogicSaveExec, NULL,
    5252                                 NULL, lsilogicLoadExec, lsilogicLoadDone);
     5267                                NULL, lsilogicR3LiveExec, NULL,
     5268                                NULL, lsilogicR3SaveExec, NULL,
     5269                                NULL, lsilogicR3LoadExec, lsilogicR3LoadDone);
    52535270    if (RT_FAILURE(rc))
    52545271        return PDMDEV_SET_ERROR(pDevIns, rc, N_("LsiLogic cannot register save state handlers"));
     
    52645281                              pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI
    52655282                              ? "LsiLogic SPI info."
    5266                               : "LsiLogic SAS info.", lsilogicInfo);
     5283                              : "LsiLogic SAS info.", lsilogicR3Info);
    52675284
    52685285    /* Perform hard reset. */
    5269     rc = lsilogicHardReset(pThis);
     5286    rc = lsilogicR3HardReset(pThis);
    52705287    AssertRC(rc);
    52715288
     
    52985315    sizeof(LSILOGICSCSI),
    52995316    /* pfnConstruct */
    5300     lsilogicConstruct,
     5317    lsilogicR3Construct,
    53015318    /* pfnDestruct */
    5302     lsilogicDestruct,
     5319    lsilogicR3Destruct,
    53035320    /* pfnRelocate */
    5304     lsilogicRelocate,
     5321    lsilogicR3Relocate,
    53055322    /* pfnIOCtl */
    53065323    NULL,
     
    53085325    NULL,
    53095326    /* pfnReset */
    5310     lsilogicReset,
     5327    lsilogicR3Reset,
    53115328    /* pfnSuspend */
    5312     lsilogicSuspend,
     5329    lsilogicR3Suspend,
    53135330    /* pfnResume */
    5314     lsilogicResume,
     5331    lsilogicR3Resume,
    53155332    /* pfnAttach */
    5316     lsilogicAttach,
     5333    lsilogicR3Attach,
    53175334    /* pfnDetach */
    5318     lsilogicDetach,
     5335    lsilogicR3Detach,
    53195336    /* pfnQueryInterface. */
    53205337    NULL,
     
    53225339    NULL,
    53235340    /* pfnPowerOff */
    5324     lsilogicPowerOff,
     5341    lsilogicR3PowerOff,
    53255342    /* pfnSoftReset */
    53265343    NULL,
     
    53555372    sizeof(LSILOGICSCSI),
    53565373    /* pfnConstruct */
    5357     lsilogicConstruct,
     5374    lsilogicR3Construct,
    53585375    /* pfnDestruct */
    5359     lsilogicDestruct,
     5376    lsilogicR3Destruct,
    53605377    /* pfnRelocate */
    5361     lsilogicRelocate,
     5378    lsilogicR3Relocate,
    53625379    /* pfnIOCtl */
    53635380    NULL,
     
    53655382    NULL,
    53665383    /* pfnReset */
    5367     lsilogicReset,
     5384    lsilogicR3Reset,
    53685385    /* pfnSuspend */
    5369     lsilogicSuspend,
     5386    lsilogicR3Suspend,
    53705387    /* pfnResume */
    5371     lsilogicResume,
     5388    lsilogicR3Resume,
    53725389    /* pfnAttach */
    5373     lsilogicAttach,
     5390    lsilogicR3Attach,
    53745391    /* pfnDetach */
    5375     lsilogicDetach,
     5392    lsilogicR3Detach,
    53765393    /* pfnQueryInterface. */
    53775394    NULL,
     
    53795396    NULL,
    53805397    /* pfnPowerOff */
    5381     lsilogicPowerOff,
     5398    lsilogicR3PowerOff,
    53825399    /* pfnSoftReset */
    53835400    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