VirtualBox

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


Ignore:
Timestamp:
Feb 4, 2013 8:43:35 PM (12 years ago)
Author:
vboxsync
Message:

DevBusLogic.cpp: Cleanups, two missing callback declarations.

File:
1 edited

Legend:

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

    r44207 r44532  
    11/* $Id$ */
    22/** @file
    3  * VBox storage devices: BusLogic SCSI host adapter BT-958.
     3 * VBox storage devices - BusLogic SCSI host adapter BT-958.
     4 *
     5 * Based on the Multi-Master Ultra SCSI Systems Technical Reference Manual.
    46 */
    57
    68/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     9 * Copyright (C) 2006-2013 Oracle Corporation
    810 *
    911 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1618 */
    1719
    18 /* Based on the Multi-Master Ultra SCSI Systems Technical Reference Manual */
    1920
    2021/*******************************************************************************
    2122*   Header Files                                                               *
    2223*******************************************************************************/
    23 
    2424#define LOG_GROUP LOG_GROUP_DEV_BUSLOGIC
    2525#include <VBox/vmm/pdmdev.h>
     
    4141#include "VBoxDD.h"
    4242
    43 /* Maximum number of attached devices the adapter can handle. */
     43
     44/*******************************************************************************
     45*   Defined Constants And Macros                                               *
     46*******************************************************************************/
     47/** Maximum number of attached devices the adapter can handle. */
    4448#define BUSLOGIC_MAX_DEVICES 16
    4549
    46 /* Maximum number of scatter gather elements this device can handle. */
     50/** Maximum number of scatter gather elements this device can handle. */
    4751#define BUSLOGIC_MAX_SCATTER_GATHER_LIST_SIZE 128
    4852
    49 /* Size of the command buffer. */
     53/** Size of the command buffer. */
    5054#define BUSLOGIC_COMMAND_SIZE_MAX 5
    5155
    52 /* Size of the reply buffer. */
    53 #define BUSLOGIC_REPLY_SIZE_MAX     64
    54 
    55 /*
    56  * Custom fixed I/O ports for BIOS controller access. Note that these should
    57  * not be in the ISA range (below 400h) to avoid conflicts with ISA device
    58  * probing. Addresses in the 300h-340h range should be especially avoided.
    59  */
    60 
     56/** Size of the reply buffer. */
     57#define BUSLOGIC_REPLY_SIZE_MAX 64
     58
     59/** Custom fixed I/O ports for BIOS controller access.
     60 * Note that these should not be in the ISA range (below 400h) to avoid
     61 * conflicts with ISA device probing. Addresses in the 300h-340h range should be
     62 * especially avoided.
     63 */
    6164#define BUSLOGIC_BIOS_IO_PORT   0x430
    6265
     
    6972#define BUSLOGIC_SAVED_STATE_MINOR_PRE_24BIT_MBOX     2
    7073
    71 /** The duration of software-initiated reset. Not documented, set to 50 ms. */
    72 #define BUSLOGIC_RESET_DURATION_NS      (50*1000*1000UL)
    73 
     74/** The duration of software-initiated reset (in nano seconds).
     75 *  Not documented, set to 50 ms. */
     76#define BUSLOGIC_RESET_DURATION_NS      UINT64_C(50000000)
     77
     78
     79/*******************************************************************************
     80*   Structures and Typedefs                                                    *
     81*******************************************************************************/
    7482/**
    7583 * State of a device attached to the buslogic host adapter.
     
    119127} BUSLOGICDEVICE, *PBUSLOGICDEVICE;
    120128
    121 /*
     129/**
    122130 * Commands the BusLogic adapter supports.
    123131 */
     
    184192    uint8_t       aHostAdaptertype[6];
    185193    uint8_t       uReserved1;
    186     bool          fFloppyEnabled:           1;
    187     bool          fFloppySecondary:         1;
    188     bool          fLevelSensitiveInterrupt: 1;
    189     unsigned char uReserved2:               2;
    190     unsigned char uSystemRAMAreForBIOS:     3;
    191     unsigned char uDMAChannel:              7;
    192     bool          fDMAAutoConfiguration:    1;
    193     unsigned char uIrqChannel:              7;
    194     bool          fIrqAutoConfiguration:    1;
     194    bool          fFloppyEnabled :                  1;
     195    bool          fFloppySecondary :                1;
     196    bool          fLevelSensitiveInterrupt :        1;
     197    unsigned char uReserved2 :                      2;
     198    unsigned char uSystemRAMAreForBIOS :            3;
     199    unsigned char uDMAChannel :                     7;
     200    bool          fDMAAutoConfiguration :           1;
     201    unsigned char uIrqChannel :                     7;
     202    bool          fIrqAutoConfiguration :           1;
    195203    uint8_t       uDMATransferRate;
    196204    uint8_t       uSCSIId;
    197     bool          fLowByteTerminated:       1;
    198     bool          fParityCheckingEnabled:   1;
    199     bool          fHighByteTerminated:      1;
    200     bool          fNoisyCablingEnvironment: 1;
    201     bool          fFastSynchronousNeogtiation: 1;
    202     bool          fBusResetEnabled:            1;
    203     bool          fReserved3:                  1;
    204     bool          fActiveNegotiationEnabled:   1;
     205    bool          fLowByteTerminated :              1;
     206    bool          fParityCheckingEnabled :          1;
     207    bool          fHighByteTerminated :             1;
     208    bool          fNoisyCablingEnvironment :        1;
     209    bool          fFastSynchronousNeogtiation :    1;
     210    bool          fBusResetEnabled :                1;
     211    bool          fReserved3 :                      1;
     212    bool          fActiveNegotiationEnabled :       1;
    205213    uint8_t       uBusOnDelay;
    206214    uint8_t       uBusOffDelay;
    207     bool          fHostAdapterBIOSEnabled:     1;
    208     bool          fBIOSRedirectionOfInt19:     1;
    209     bool          fExtendedTranslation:        1;
    210     bool          fMapRemovableAsFixed:        1;
    211     bool          fReserved4:                  1;
    212     bool          fBIOSSupportsMoreThan2Drives: 1;
    213     bool          fBIOSInterruptMode:           1;
    214     bool          fFlopticalSupport:            1;
     215    bool          fHostAdapterBIOSEnabled :         1;
     216    bool          fBIOSRedirectionOfInt19 :         1;
     217    bool          fExtendedTranslation :            1;
     218    bool          fMapRemovableAsFixed :            1;
     219    bool          fReserved4 :                      1;
     220    bool          fBIOSSupportsMoreThan2Drives :    1;
     221    bool          fBIOSInterruptMode :              1;
     222    bool          fFlopticalSupport :               1;
    215223    uint16_t      u16DeviceEnabledMask;
    216224    uint16_t      u16WidePermittedMask;
     
    220228    uint16_t      u16SendStartUnitCommandMask;
    221229    uint16_t      u16IgnoreInBIOSScanMask;
    222     unsigned char uPCIInterruptPin:             2;
    223     unsigned char uHostAdapterIoPortAddress:    2;
    224     bool          fStrictRoundRobinMode:        1;
    225     bool          fVesaBusSpeedGreaterThan33MHz: 1;
    226     bool          fVesaBurstWrite:               1;
    227     bool          fVesaBurstRead:                1;
     230    unsigned char uPCIInterruptPin :                2;
     231    unsigned char uHostAdapterIoPortAddress :       2;
     232    bool          fStrictRoundRobinMode :           1;
     233    bool          fVesaBusSpeedGreaterThan33MHz :  1;
     234    bool          fVesaBurstWrite :                 1;
     235    bool          fVesaBurstRead :                  1;
    228236    uint16_t      u16UltraPermittedMask;
    229237    uint32_t      uReserved5;
    230238    uint8_t       uReserved6;
    231239    uint8_t       uAutoSCSIMaximumLUN;
    232     bool          fReserved7:                    1;
    233     bool          fSCAMDominant:                 1;
    234     bool          fSCAMenabled:                  1;
    235     bool          fSCAMLevel2:                   1;
    236     unsigned char uReserved8:                    4;
    237     bool          fInt13Extension:               1;
    238     bool          fReserved9:                    1;
    239     bool          fCDROMBoot:                    1;
    240     unsigned char uReserved10:                   5;
    241     unsigned char uBootTargetId:                 4;
    242     unsigned char uBootChannel:                  4;
    243     bool          fForceBusDeviceScanningOrder:  1;
    244     unsigned char uReserved11:                   7;
     240    bool          fReserved7 :                      1;
     241    bool          fSCAMDominant :                   1;
     242    bool          fSCAMenabled :                    1;
     243    bool          fSCAMLevel2 :                     1;
     244    unsigned char uReserved8 :                      4;
     245    bool          fInt13Extension :                 1;
     246    bool          fReserved9 :                      1;
     247    bool          fCDROMBoot :                      1;
     248    unsigned char uReserved10 :                     5;
     249    unsigned char uBootTargetId :                   4;
     250    unsigned char uBootChannel :                    4;
     251    bool          fForceBusDeviceScanningOrder :    1;
     252    unsigned char uReserved11 :                     7;
    245253    uint16_t      u16NonTaggedToAlternateLunPermittedMask;
    246254    uint16_t      u16RenegotiateSyncAfterCheckConditionMask;
     
    257265typedef union HostAdapterLocalRam
    258266{
    259     /* Byte view. */
     267    /** Byte view. */
    260268    uint8_t u8View[256];
    261     /* Structured view. */
     269    /** Structured view. */
    262270    struct
    263271    {
     
    271279
    272280
    273 /* Ugly 24-bit big-endian addressing. */
    274 typedef struct {
     281/** Ugly 24-bit big-endian addressing. */
     282typedef struct
     283{
    275284    uint8_t hi;
    276285    uint8_t mid;
     
    284293#define U32_TO_LEN          U32_TO_ADDR
    285294
    286 /* Compatible ISA base I/O port addresses. Disabled if zero. */
     295/** @name Compatible ISA base I/O port addresses. Disabled if zero.
     296 * @{  */
    287297#define NUM_ISA_BASES       8
    288298#define MAX_ISA_BASE        (NUM_ISA_BASES - 1)
    289299#define ISA_BASE_DISABLED   6
    290300
    291 static uint16_t     aISABases[NUM_ISA_BASES] = {
     301static uint16_t const g_aISABases[NUM_ISA_BASES] =
     302{
    292303    0x330, 0x334, 0x230, 0x234, 0x130, 0x134, 0, 0
    293304};
     305/** @}  */
    294306
    295307/** Pointer to a task state structure. */
     
    362374    /** Flag whether the ISA I/O port range is disabled
    363375     * to prevent the BIOS to access the device. */
    364     bool                            fISAEnabled;    //@todo: unused, to be removed
     376    bool                            fISAEnabled;    /**< @todo unused, to be removed */
    365377    /** Flag whether 24-bit mailboxes are in use (default is 32-bit). */
    366     bool                            fMbxIs24Bit;    //@todo: save?
     378    bool                            fMbxIs24Bit;    /**< @todo save? */
    367379    /** ISA I/O port base (encoded in FW-compatible format). */
    368380    uint8_t                         uISABaseCode;
     
    380392#endif
    381393
    382     /** Time when HBA reset was last initiated. */  //@todo: does this need to be saved?
     394    /** Time when HBA reset was last initiated. */  /**< @todo does this need to be saved? */
    383395    uint64_t                        u64ResetTime;
    384396    /** Physical base address of the outgoing mailboxes. */
     
    457469
    458470/** Register offsets in the I/O port space. */
    459 #define BUSLOGIC_REGISTER_CONTROL   0 /* Writeonly */
     471#define BUSLOGIC_REGISTER_CONTROL   0 /**< Writeonly */
    460472/** Fields for the control register. */
    461473# define BUSLOGIC_REGISTER_CONTROL_SCSI_BUSRESET   RT_BIT(4)
     
    464476# define BUSLOGIC_REGISTER_CONTROL_HARD_RESET      RT_BIT(7)
    465477
    466 #define BUSLOGIC_REGISTER_STATUS    0 /* Readonly */
     478#define BUSLOGIC_REGISTER_STATUS    0 /**< Readonly */
    467479/** Fields for the status register. */
    468480# define BUSLOGIC_REGISTER_STATUS_COMMAND_INVALID                 RT_BIT(0)
     
    474486# define BUSLOGIC_REGISTER_STATUS_DIAGNOSTIC_ACTIVE               RT_BIT(7)
    475487
    476 #define BUSLOGIC_REGISTER_COMMAND   1 /* Writeonly */
    477 #define BUSLOGIC_REGISTER_DATAIN    1 /* Readonly */
    478 #define BUSLOGIC_REGISTER_INTERRUPT 2 /* Readonly */
     488#define BUSLOGIC_REGISTER_COMMAND   1 /**< Writeonly */
     489#define BUSLOGIC_REGISTER_DATAIN    1 /**< Readonly */
     490#define BUSLOGIC_REGISTER_INTERRUPT 2 /**< Readonly */
    479491/** Fields for the interrupt register. */
    480492# define BUSLOGIC_REGISTER_INTERRUPT_INCOMING_MAILBOX_LOADED      RT_BIT(0)
     
    487499# define BUSLOGIC_REGISTER_GEOMETRY_EXTENTED_TRANSLATION_ENABLED  RT_BIT(7)
    488500
    489 /* Structure for the INQUIRE_PCI_HOST_ADAPTER_INFORMATION reply. */
     501/** Structure for the INQUIRE_PCI_HOST_ADAPTER_INFORMATION reply. */
    490502typedef struct ReplyInquirePCIHostAdapterInformation
    491503{
    492504    uint8_t       IsaIOPort;
    493505    uint8_t       IRQ;
    494     unsigned char LowByteTerminated:1;
    495     unsigned char HighByteTerminated:1;
    496     unsigned char uReserved:2; /* Reserved. */
    497     unsigned char JP1:1; /* Whatever that means. */
    498     unsigned char JP2:1; /* Whatever that means. */
    499     unsigned char JP3:1; /* Whatever that means. */
     506    unsigned char LowByteTerminated : 1;
     507    unsigned char HighByteTerminated : 1;
     508    unsigned char uReserved : 2; /* Reserved. */
     509    unsigned char JP1 : 1; /* Whatever that means. */
     510    unsigned char JP2 : 1; /* Whatever that means. */
     511    unsigned char JP3 : 1; /* Whatever that means. */
    500512    /** Whether the provided info is valid. */
    501513    unsigned char InformationIsValid: 1;
     
    504516AssertCompileSize(ReplyInquirePCIHostAdapterInformation, 4);
    505517
    506 /* Structure for the INQUIRE_CONFIGURATION reply. */
     518/** Structure for the INQUIRE_CONFIGURATION reply. */
    507519typedef struct ReplyInquireConfiguration
    508520{
    509     unsigned char uReserved1:     5;
    510     bool          fDmaChannel5:   1;
    511     bool          fDmaChannel6:   1;
    512     bool          fDmaChannel7:   1;
    513     bool          fIrqChannel9:   1;
    514     bool          fIrqChannel10:  1;
    515     bool          fIrqChannel11:  1;
    516     bool          fIrqChannel12:  1;
    517     unsigned char uReserved2:     1;
    518     bool          fIrqChannel14:  1;
    519     bool          fIrqChannel15:  1;
    520     unsigned char uReserved3:     1;
    521     unsigned char uHostAdapterId: 4;
    522     unsigned char uReserved4:     4;
     521    unsigned char uReserved1 :     5;
     522    bool          fDmaChannel5 :   1;
     523    bool          fDmaChannel6 :   1;
     524    bool          fDmaChannel7 :   1;
     525    bool          fIrqChannel9 :   1;
     526    bool          fIrqChannel10 :  1;
     527    bool          fIrqChannel11 :  1;
     528    bool          fIrqChannel12 :  1;
     529    unsigned char uReserved2 :     1;
     530    bool          fIrqChannel14 :  1;
     531    bool          fIrqChannel15 :  1;
     532    unsigned char uReserved3 :     1;
     533    unsigned char uHostAdapterId : 4;
     534    unsigned char uReserved4 :     4;
    523535} ReplyInquireConfiguration, *PReplyInquireConfiguration;
    524536AssertCompileSize(ReplyInquireConfiguration, 3);
    525537
    526 /* Structure for the INQUIRE_SETUP_INFORMATION reply. */
     538/** Structure for the INQUIRE_SETUP_INFORMATION reply. */
    527539typedef struct ReplyInquireSetupInformationSynchronousValue
    528540{
    529     unsigned char uOffset:         4;
    530     unsigned char uTransferPeriod: 3;
    531     bool fSynchronous:             1;
     541    unsigned char uOffset :         4;
     542    unsigned char uTransferPeriod : 3;
     543    bool fSynchronous :             1;
    532544}ReplyInquireSetupInformationSynchronousValue, *PReplyInquireSetupInformationSynchronousValue;
    533545AssertCompileSize(ReplyInquireSetupInformationSynchronousValue, 1);
     
    535547typedef struct ReplyInquireSetupInformation
    536548{
    537     bool fSynchronousInitiationEnabled: 1;
    538     bool fParityCheckingEnabled:        1;
    539     unsigned char uReserved1:           6;
     549    bool fSynchronousInitiationEnabled : 1;
     550    bool fParityCheckingEnabled :        1;
     551    unsigned char uReserved1 :           6;
    540552    uint8_t uBusTransferRate;
    541553    uint8_t uPreemptTimeOnBus;
     
    558570AssertCompileSize(ReplyInquireSetupInformation, 34);
    559571
    560 /* Structure for the INQUIRE_EXTENDED_SETUP_INFORMATION. */
     572/** Structure for the INQUIRE_EXTENDED_SETUP_INFORMATION. */
    561573#pragma pack(1)
    562574typedef struct ReplyInquireExtendedSetupInformation
     
    567579    uint8_t       cMailbox;
    568580    uint32_t      uMailboxAddressBase;
    569     unsigned char uReserved1: 2;
    570     bool          fFastEISA: 1;
    571     unsigned char uReserved2: 3;
    572     bool          fLevelSensitiveInterrupt: 1;
    573     unsigned char uReserved3: 1;
     581    unsigned char uReserved1 : 2;
     582    bool          fFastEISA : 1;
     583    unsigned char uReserved2 : 3;
     584    bool          fLevelSensitiveInterrupt : 1;
     585    unsigned char uReserved3 : 1;
    574586    unsigned char aFirmwareRevision[3];
    575     bool          fHostWideSCSI: 1;
    576     bool          fHostDifferentialSCSI: 1;
    577     bool          fHostSupportsSCAM: 1;
    578     bool          fHostUltraSCSI: 1;
    579     bool          fHostSmartTermination: 1;
    580     unsigned char uReserved4: 3;
     587    bool          fHostWideSCSI : 1;
     588    bool          fHostDifferentialSCSI : 1;
     589    bool          fHostSupportsSCAM : 1;
     590    bool          fHostUltraSCSI : 1;
     591    bool          fHostSmartTermination : 1;
     592    unsigned char uReserved4 : 3;
    581593} ReplyInquireExtendedSetupInformation, *PReplyInquireExtendedSetupInformation;
    582594AssertCompileSize(ReplyInquireExtendedSetupInformation, 14);
    583595#pragma pack()
    584596
    585 /* Structure for the INITIALIZE EXTENDED MAILBOX request. */
     597/** Structure for the INITIALIZE EXTENDED MAILBOX request. */
    586598#pragma pack(1)
    587599typedef struct RequestInitializeExtendedMailbox
     
    595607#pragma pack()
    596608
    597 /* Structure for the INITIALIZE MAILBOX request. */
     609/** Structure for the INITIALIZE MAILBOX request. */
    598610typedef struct
    599611{
     
    605617AssertCompileSize(RequestInitMbx, 4);
    606618
    607 /*
     619/**
    608620 * Structure of a mailbox in guest memory.
    609621 * The incoming and outgoing mailbox have the same size
     
    646658AssertCompileSize(Mailbox32, 8);
    647659
    648 /* Old style 24-bit mailbox entry. */
     660/** Old style 24-bit mailbox entry. */
    649661typedef struct Mailbox24
    650662{
     
    656668AssertCompileSize(Mailbox24, 4);
    657669
    658 /*
     670/**
    659671 * Action codes for outgoing mailboxes.
    660672 */
     
    666678};
    667679
    668 /*
     680/**
    669681 * Completion codes for incoming mailboxes.
    670682 */
     
    679691};
    680692
    681 /*
     693/**
    682694 * Host adapter status for incoming mailboxes.
    683695 */
     
    711723};
    712724
    713 /*
     725/**
    714726 * Device status codes for incoming mailboxes.
    715727 */
     
    721733};
    722734
    723 /*
     735/**
    724736 * Opcode types for CCB.
    725737 */
     
    734746};
    735747
    736 /*
     748/**
    737749 * Data transfer direction.
    738750 */
     
    745757};
    746758
    747 /*
     759/**
    748760 * The command control block for a SCSI request.
    749761 */
     
    753765    uint8_t       uOpcode;
    754766    /** Reserved */
    755     unsigned char uReserved1:       3;
     767    unsigned char uReserved1 :      3;
    756768    /** Data direction for the request. */
    757     unsigned char uDataDirection:   2;
     769    unsigned char uDataDirection :  2;
    758770    /** Whether the request is tag queued. */
    759     bool          fTagQueued:       1;
     771    bool          fTagQueued :      1;
    760772    /** Queue tag mode. */
    761     unsigned char uQueueTag:        2;
     773    unsigned char uQueueTag :       2;
    762774    /** Length of the SCSI CDB. */
    763775    uint8_t       cbCDB;
     
    779791    uint8_t       uTargetId;
    780792    /**The LUN in the device. */
    781     unsigned char uLogicalUnit:    5;
     793    unsigned char uLogicalUnit : 5;
    782794    /** Legacy tag. */
    783     bool          fLegacyTagEnable: 1;
     795    bool          fLegacyTagEnable : 1;
    784796    /** Legacy queue tag. */
    785     unsigned char uLegacyQueueTag: 2;
    786     /** The SCSI CDB. */
    787     uint8_t       aCDB[12]; /* A CDB can be 12 bytes long. */
     797    unsigned char uLegacyQueueTag : 2;
     798    /** The SCSI CDB.  (A CDB can be 12 bytes long.) */
     799    uint8_t       aCDB[12];
    788800    /** Reserved. */
    789801    uint8_t       uReserved3[6];
     
    794806
    795807
    796 /*
     808/**
    797809 * The 24-bit command control block.
    798810 */
     
    802814    uint8_t         uOpcode;
    803815    /** The LUN in the device. */
    804     unsigned char   uLogicalUnit 3;
     816    unsigned char   uLogicalUnit : 3;
    805817    /** Data direction for the request. */
    806     unsigned char   uDataDirection: 2;
     818    unsigned char   uDataDirection : 2;
    807819    /** The target device ID. */
    808     unsigned char   uTargetId:      3;
     820    unsigned char   uTargetId : 3;
    809821    /** Length of the SCSI CDB. */
    810822    uint8_t         cbCDB;
     
    827839    /** Two unused bytes. */
    828840    uint8_t         aReserved[2];
    829     /** The SCSI CDB. */
    830     uint8_t         aCDB[12]; /* A CDB can be 12 bytes long. */
     841    /** The SCSI CDB.  (A CDB can be 12 bytes long.)   */
     842    uint8_t         aCDB[12];
    831843} CCB24, *PCCB24;
    832844AssertCompileSize(CCB24, 30);
    833845
    834 /*
     846/**
    835847 * The common 24-bit/32-bit command control block. The 32-bit CCB is laid out
    836848 * such that many fields are in the same location as in the older 24-bit CCB.
     
    841853    uint8_t         uOpcode;
    842854    /** The LUN in the device. */
    843     unsigned char   uPad1:          3;
     855    unsigned char   uPad1 : 3;
    844856    /** Data direction for the request. */
    845     unsigned char   uDataDirection: 2;
     857    unsigned char   uDataDirection : 2;
    846858    /** The target device ID. */
    847     unsigned char   uPad2:          3;
     859    unsigned char   uPad2 : 3;
    848860    /** Length of the SCSI CDB. */
    849861    uint8_t         cbCDB;
     
    872884AssertCompileMemberOffset(CCB32, aCDB, 18);
    873885
    874 /* A union of all CCB types (24-bit/32-bit/common). */
    875 typedef union CCBU {
    876     CCB32    n;     /* New 32-bit CCB. */
    877     CCB24    o;     /* Old 24-bit CCB. */
    878     CCBC     c;     /* Common CCB subset. */
     886/** A union of all CCB types (24-bit/32-bit/common). */
     887typedef union CCBU
     888{
     889    CCB32    n;     /**< New 32-bit CCB. */
     890    CCB24    o;     /**< Old 24-bit CCB. */
     891    CCBC     c;     /**< Common CCB subset. */
    879892} CCBU, *PCCBU;
    880893
    881 /* 32-bit scatter-gather list entry. */
     894/** 32-bit scatter-gather list entry. */
    882895typedef struct SGE32
    883896{
     
    887900AssertCompileSize(SGE32, 8);
    888901
    889 /* 24-bit scatter-gather list entry. */
     902/** 24-bit scatter-gather list entry. */
    890903typedef struct SGE24
    891904{
     
    895908AssertCompileSize(SGE24, 6);
    896909
    897 /*
     910/**
    898911 * The structure for the "Execute SCSI Command" command.
    899912 */
     
    909922    uint8_t         uLogicalUnit;
    910923    /** Reserved */
    911     unsigned char   uReserved1:    3;
     924    unsigned char   uReserved1 : 3;
    912925    /** Data direction for the request. */
    913     unsigned char   uDataDirection: 2;
     926    unsigned char   uDataDirection : 2;
    914927    /** Reserved */
    915     unsigned char   uReserved2:    3;
     928    unsigned char   uReserved2 : 3;
    916929    /** Length of the SCSI CDB. */
    917930    uint8_t         cbCDB;
    918     /** The SCSI CDB. */
    919     uint8_t         aCDB[12]; /* A CDB can be 12 bytes long. */
     931    /** The SCSI CDB.  (A CDB can be 12 bytes long.)   */
     932    uint8_t         aCDB[12];
    920933} ESCMD, *PESCMD;
    921934AssertCompileSize(ESCMD, 24);
    922935
    923 /*
     936/**
    924937 * Task state for a CCB request.
    925938 */
     
    956969#define PDMILEDPORTS_2_PBUSLOGIC(pInterface)       ( (PBUSLOGIC)((uintptr_t)(pInterface) - RT_OFFSETOF(BUSLOGIC, ILeds)) )
    957970
    958 static int buslogicRegisterISARange(PBUSLOGIC pBusLogic, uint8_t uBaseCode);
     971/*******************************************************************************
     972*   Internal Functions                                                         *
     973*******************************************************************************/
     974static int buslogicR3RegisterISARange(PBUSLOGIC pBusLogic, uint8_t uBaseCode);
     975
    959976
    960977/**
     
    10151032 * Advances the mailbox pointer to the next slot.
    10161033 */
    1017 DECLINLINE(void) buslogicOutgoingMailboxAdvance(PBUSLOGIC pBusLogic)
     1034DECLINLINE(void) buslogicR3OutgoingMailboxAdvance(PBUSLOGIC pBusLogic)
    10181035{
    10191036    pBusLogic->uMailboxOutgoingPositionCurrent = (pBusLogic->uMailboxOutgoingPositionCurrent + 1) % pBusLogic->cMailbox;
     
    10261043 * @param   pBusLogic.
    10271044 */
    1028 static void buslogicInitializeLocalRam(PBUSLOGIC pBusLogic)
     1045static void buslogicR3InitializeLocalRam(PBUSLOGIC pBusLogic)
    10291046{
    10301047    /*
     
    10461063    pBusLogic->LocalRam.structured.autoSCSIData.fStrictRoundRobinMode = pBusLogic->fStrictRoundRobinMode;
    10471064    pBusLogic->LocalRam.structured.autoSCSIData.u16UltraPermittedMask = ~0;
    1048     /* @todo calculate checksum? */
     1065    /** @todo calculate checksum? */
    10491066}
    10501067
     
    10561073 * @param   fResetIO  Flag determining whether ISA I/O should be reset.
    10571074 */
    1058 static int buslogicHwReset(PBUSLOGIC pBusLogic, bool fResetIO)
     1075static int buslogicR3HwReset(PBUSLOGIC pBusLogic, bool fResetIO)
    10591076{
    10601077    LogFlowFunc(("pBusLogic=%#p\n", pBusLogic));
     
    10751092    if (fResetIO)
    10761093    {
    1077         buslogicRegisterISARange(pBusLogic, pBusLogic->uDefaultISABaseCode);
    1078     }
    1079     buslogicInitializeLocalRam(pBusLogic);
     1094        buslogicR3RegisterISARange(pBusLogic, pBusLogic->uDefaultISABaseCode);
     1095    }
     1096    buslogicR3InitializeLocalRam(pBusLogic);
    10801097    vboxscsiInitialize(&pBusLogic->VBoxSCSI);
    10811098
    10821099    return VINF_SUCCESS;
    10831100}
    1084 #endif
     1101
     1102#endif /* IN_RING3 */
    10851103
    10861104/**
     
    11121130
    11131131#if defined(IN_RING3)
     1132
    11141133/**
    11151134 * Initiates a hard reset which was issued from the guest.
     
    11191138 * @param   fHardReset  Flag initiating a hard (vs. soft) reset.
    11201139 */
    1121 static void buslogicInitiateReset(PBUSLOGIC pBusLogic, bool fHardReset)
     1140static void buslogicR3InitiateReset(PBUSLOGIC pBusLogic, bool fHardReset)
    11221141{
    11231142    LogFlowFunc(("pBusLogic=%#p fHardReset=%d\n", pBusLogic, fHardReset));
    11241143
    1125     buslogicHwReset(pBusLogic, false);
     1144    buslogicR3HwReset(pBusLogic, false);
    11261145
    11271146    if (fHardReset)
     
    11461165 * @param   uMailboxCompletionCode    Completion status code to set in the mailbox.
    11471166 */
    1148 static void buslogicSendIncomingMailbox(PBUSLOGIC pBusLogic, PBUSLOGICTASKSTATE pTaskState,
    1149                                         uint8_t uHostAdapterStatus, uint8_t uDeviceStatus,
    1150                                         uint8_t uMailboxCompletionCode)
     1167static void buslogicR3SendIncomingMailbox(PBUSLOGIC pBusLogic, PBUSLOGICTASKSTATE pTaskState,
     1168                                          uint8_t uHostAdapterStatus, uint8_t uDeviceStatus,
     1169                                          uint8_t uMailboxCompletionCode)
    11511170{
    11521171    pTaskState->MailboxGuest.u.in.uHostAdapterStatus = uHostAdapterStatus;
     
    11561175    int rc = PDMCritSectEnter(&pBusLogic->CritSectIntr, VINF_SUCCESS);
    11571176    AssertRC(rc);
    1158     RTGCPHYS GCPhysAddrMailboxIncoming;
    11591177    RTGCPHYS GCPhysAddrCCB = pTaskState->MailboxGuest.u32PhysAddrCCB;
    1160 
    1161     GCPhysAddrMailboxIncoming = pBusLogic->GCPhysAddrMailboxIncomingBase + (pBusLogic->uMailboxIncomingPositionCurrent * (pTaskState->fIs24Bit ? sizeof(Mailbox24) : sizeof(Mailbox32)));
     1178    RTGCPHYS GCPhysAddrMailboxIncoming = pBusLogic->GCPhysAddrMailboxIncomingBase
     1179                                       + (   pBusLogic->uMailboxIncomingPositionCurrent
     1180                                          * (pTaskState->fIs24Bit ? sizeof(Mailbox24) : sizeof(Mailbox32)) );
    11621181    LogFlowFunc(("Completing CCB %RGp hstat=%u, dstat=%u, outgoing mailbox at %RGp\n", GCPhysAddrCCB,
    11631182                 uHostAdapterStatus, uDeviceStatus, GCPhysAddrMailboxIncoming));
     
    11661185    pTaskState->CommandControlBlockGuest.c.uHostAdapterStatus = uHostAdapterStatus;
    11671186    pTaskState->CommandControlBlockGuest.c.uDeviceStatus      = uDeviceStatus;
    1168     /* @todo: this is wrong - writing too much! */
     1187    /** @todo this is wrong - writing too much! */
    11691188    PDMDevHlpPhysWrite(pBusLogic->CTX_SUFF(pDevIns), GCPhysAddrCCB, &pTaskState->CommandControlBlockGuest, sizeof(CCBC));
    11701189
    1171 #ifdef RT_STRICT
     1190# ifdef RT_STRICT
    11721191    uint8_t     uCode;
    11731192    unsigned    uCodeOffs = pTaskState->fIs24Bit ? RT_OFFSETOF(Mailbox24, uCmdState) : RT_OFFSETOF(Mailbox32, u.out.uActionCode);
    11741193    PDMDevHlpPhysRead(pBusLogic->CTX_SUFF(pDevIns), GCPhysAddrMailboxIncoming + uCodeOffs, &uCode, sizeof(uCode));
    11751194    Assert(uCode == BUSLOGIC_MAILBOX_INCOMING_COMPLETION_FREE);
    1176 #endif
     1195# endif
    11771196
    11781197    /* Update mailbox. */
     
    11971216        pBusLogic->uMailboxIncomingPositionCurrent = 0;
    11981217
    1199 #ifdef LOG_ENABLED
     1218# ifdef LOG_ENABLED
    12001219    ASMAtomicIncU32(&pBusLogic->cInMailboxesReady);
    1201 #endif
     1220# endif
    12021221
    12031222    buslogicSetInterrupt(pBusLogic, false, BUSLOGIC_REGISTER_INTERRUPT_INCOMING_MAILBOX_LOADED);
     
    12061225}
    12071226
    1208 #if defined(DEBUG)
     1227# ifdef LOG_ENABLED
     1228
    12091229/**
    12101230 * Dumps the content of a mailbox for debugging purposes.
     
    12151235 *                    false if dumping the incoming state.
    12161236 */
    1217 static void buslogicDumpMailboxInfo(PMailbox32 pMailbox, bool fOutgoing)
     1237static void buslogicR3DumpMailboxInfo(PMailbox32 pMailbox, bool fOutgoing)
    12181238{
    12191239    Log(("%s: Dump for %s mailbox:\n", __FUNCTION__, fOutgoing ? "outgoing" : "incoming"));
     
    12381258 * @param   fIs24BitCCB     Flag to determine CCB format.
    12391259 */
    1240 static void buslogicDumpCCBInfo(PCCBU pCCB, bool fIs24BitCCB)
     1260static void buslogicR3DumpCCBInfo(PCCBU pCCB, bool fIs24BitCCB)
    12411261{
    12421262    Log(("%s: Dump for %s Command Control Block:\n", __FUNCTION__, fIs24BitCCB ? "24-bit" : "32-bit"));
     
    12701290        Log(("%s: uCDB[%d]=%u\n", __FUNCTION__, i, pCCB->c.aCDB[i]));
    12711291}
    1272 #endif
     1292
     1293# endif /* LOG_ENABLED */
    12731294
    12741295/**
     
    12801301 * @param   pSGEList      Pointer to 32-bit S/G list storage.
    12811302 */
    1282 
    1283 static void buslogicReadSGEntries(PBUSLOGICTASKSTATE pTaskState, RTGCPHYS GCSGList, uint32_t cEntries, SGE32 *pSGEList)
     1303static void buslogicR3ReadSGEntries(PBUSLOGICTASKSTATE pTaskState, RTGCPHYS GCSGList, uint32_t cEntries, SGE32 *pSGEList)
    12841304{
    12851305    PPDMDEVINS  pDevIns = pTaskState->CTX_SUFF(pTargetDevice)->CTX_SUFF(pBusLogic)->CTX_SUFF(pDevIns);
     
    12921312        Log2(("Converting %u 24-bit S/G entries to 32-bit\n", cEntries));
    12931313        PDMDevHlpPhysRead(pDevIns, GCSGList, &aSGE24, cEntries * sizeof(SGE24));
    1294         for (unsigned i = 0; i < cEntries; ++i)
     1314        for (uint32_t i = 0; i < cEntries; ++i)
    12951315        {
    12961316            pSGEList[i].cbSegment              = LEN_TO_U32(aSGE24[i].acbSegment);
     
    13081328 * @param   pTaskState    Pointer to the task state.
    13091329 */
    1310 static int buslogicDataBufferAlloc(PBUSLOGICTASKSTATE pTaskState)
     1330static int buslogicR3DataBufferAlloc(PBUSLOGICTASKSTATE pTaskState)
    13111331{
    13121332    PPDMDEVINS pDevIns = pTaskState->CTX_SUFF(pTargetDevice)->CTX_SUFF(pBusLogic)->CTX_SUFF(pDevIns);
     
    13291349        && cbDataCCB)
    13301350    {
     1351        /** @todo Check following assumption and what residual means. */
    13311352        /*
    1332          * @todo: Check following assumption and what residual means.
    1333          *
    13341353         * The BusLogic adapter can handle two different data buffer formats.
    13351354         * The first one is that the data pointer entry in the CCB points to
     
    13551374                cScatterGatherGCLeft -= cScatterGatherGCRead;
    13561375
    1357                 buslogicReadSGEntries(pTaskState, GCPhysAddrScatterGatherCurrent, cScatterGatherGCRead, aScatterGatherReadGC);
     1376                buslogicR3ReadSGEntries(pTaskState, GCPhysAddrScatterGatherCurrent, cScatterGatherGCRead, aScatterGatherReadGC);
    13581377
    13591378                for (iScatterGatherEntry = 0; iScatterGatherEntry < cScatterGatherGCRead; iScatterGatherEntry++)
     
    13971416                    cScatterGatherGCLeft -= cScatterGatherGCRead;
    13981417
    1399                     buslogicReadSGEntries(pTaskState, GCPhysAddrScatterGatherCurrent, cScatterGatherGCRead, aScatterGatherReadGC);
     1418                    buslogicR3ReadSGEntries(pTaskState, GCPhysAddrScatterGatherCurrent, cScatterGatherGCRead, aScatterGatherReadGC);
    14001419
    14011420                    for (iScatterGatherEntry = 0; iScatterGatherEntry < cScatterGatherGCRead; iScatterGatherEntry++)
     
    14521471 * @param   pTaskState    Pointer to the task state.
    14531472 */
    1454 static void buslogicDataBufferFree(PBUSLOGICTASKSTATE pTaskState)
     1473static void buslogicR3DataBufferFree(PBUSLOGICTASKSTATE pTaskState)
    14551474{
    14561475    PPDMDEVINS pDevIns = pTaskState->CTX_SUFF(pTargetDevice)->CTX_SUFF(pBusLogic)->CTX_SUFF(pDevIns);
     
    14971516            do
    14981517            {
    1499                 cScatterGatherGCRead =   (cScatterGatherGCLeft < RT_ELEMENTS(aScatterGatherReadGC))
    1500                                         ? cScatterGatherGCLeft
    1501                                         : RT_ELEMENTS(aScatterGatherReadGC);
     1518                cScatterGatherGCRead = (cScatterGatherGCLeft < RT_ELEMENTS(aScatterGatherReadGC))
     1519                                     ? cScatterGatherGCLeft
     1520                                     : RT_ELEMENTS(aScatterGatherReadGC);
    15021521                cScatterGatherGCLeft -= cScatterGatherGCRead;
    15031522
    1504                 buslogicReadSGEntries(pTaskState, GCPhysAddrScatterGatherCurrent, cScatterGatherGCRead, aScatterGatherReadGC);
     1523                buslogicR3ReadSGEntries(pTaskState, GCPhysAddrScatterGatherCurrent, cScatterGatherGCRead, aScatterGatherReadGC);
    15051524
    15061525                for (iScatterGatherEntry = 0; iScatterGatherEntry < cScatterGatherGCRead; iScatterGatherEntry++)
     
    15331552            AssertMsg(GCPhysAddrDataBase != 0, ("Physical address is 0\n"));
    15341553
    1535             Log(("Non scattered buffer:\n"));
     1554            Log(("Non-scattered buffer:\n"));
    15361555            Log(("u32PhysAddrData=%#x\n", u32PhysAddrCCB));
    15371556            Log(("cbData=%u\n", cbDataCCB));
     
    15491568        uint32_t    cbResidual;
    15501569
    1551         //@todo: we need to get the actual transfer length from the VSCSI layer?!
     1570        /** @todo we need to get the actual transfer length from the VSCSI layer?! */
    15521571        cbResidual = 0; //LEN_TO_U32(pTaskState->CCBGuest.acbData) - ???;
    15531572        if (pTaskState->fIs24Bit)
     
    15621581}
    15631582
    1564 /* Convert sense buffer length taking into account shortcut values. */
    1565 static uint32_t buslogicConvertSenseBufferLength(uint32_t cbSense)
     1583/** Convert sense buffer length taking into account shortcut values. */
     1584static uint32_t buslogicR3ConvertSenseBufferLength(uint32_t cbSense)
    15661585{
    15671586    /* Convert special sense buffer length values. */
     
    15831602 * @param   fCopy        If sense data should be copied to guest memory.
    15841603 */
    1585 static void buslogicSenseBufferFree(PBUSLOGICTASKSTATE pTaskState, bool fCopy)
     1604static void buslogicR3SenseBufferFree(PBUSLOGICTASKSTATE pTaskState, bool fCopy)
    15861605{
    15871606    uint32_t    cbSenseBuffer;
    15881607
    1589     cbSenseBuffer = buslogicConvertSenseBufferLength(pTaskState->CommandControlBlockGuest.c.cbSenseData);
     1608    cbSenseBuffer = buslogicR3ConvertSenseBufferLength(pTaskState->CommandControlBlockGuest.c.cbSenseData);
    15901609
    15911610    /* Copy the sense buffer into guest memory if requested. */
     
    16211640 * @note Current assumption is that the sense buffer is not scattered and does not cross a page boundary.
    16221641 */
    1623 static int buslogicSenseBufferAlloc(PBUSLOGICTASKSTATE pTaskState)
     1642static int buslogicR3SenseBufferAlloc(PBUSLOGICTASKSTATE pTaskState)
    16241643{
    16251644    PPDMDEVINS pDevIns = pTaskState->CTX_SUFF(pTargetDevice)->CTX_SUFF(pBusLogic)->CTX_SUFF(pDevIns);
     
    16281647    pTaskState->pbSenseBuffer = NULL;
    16291648
    1630     cbSenseBuffer = buslogicConvertSenseBufferLength(pTaskState->CommandControlBlockGuest.c.cbSenseData);
     1649    cbSenseBuffer = buslogicR3ConvertSenseBufferLength(pTaskState->CommandControlBlockGuest.c.cbSenseData);
    16311650    if (cbSenseBuffer)
    16321651    {
     
    16381657    return VINF_SUCCESS;
    16391658}
     1659
    16401660#endif /* IN_RING3 */
    16411661
     
    16801700#ifdef IN_RING3
    16811701            Log(("ISA I/O for PCI (code %x)\n", pBusLogic->aCommandBuffer[0]));
    1682             buslogicRegisterISARange(pBusLogic, pBusLogic->aCommandBuffer[0]);
     1702            buslogicR3RegisterISARange(pBusLogic, pBusLogic->aCommandBuffer[0]);
    16831703            pBusLogic->cbReplyParametersLeft = 0;
    16841704            fSuppressIrq = true;
     
    17611781             * therefore we log a warning.
    17621782             */
    1763             switch (uPciIrq) {
    1764             case 9:     pReply->fIrqChannel9  = 1; break;
    1765             case 10:    pReply->fIrqChannel10 = 1; break;
    1766             case 11:    pReply->fIrqChannel11 = 1; break;
    1767             case 12:    pReply->fIrqChannel12 = 1; break;
    1768             case 14:    pReply->fIrqChannel14 = 1; break;
    1769             case 15:    pReply->fIrqChannel15 = 1; break;
    1770             default:
    1771                 LogRel(("Warning: PCI IRQ %d cannot be represented as ISA!\n", uPciIrq));
    1772                 break;
     1783            switch (uPciIrq)
     1784            {
     1785                case 9:     pReply->fIrqChannel9  = 1; break;
     1786                case 10:    pReply->fIrqChannel10 = 1; break;
     1787                case 11:    pReply->fIrqChannel11 = 1; break;
     1788                case 12:    pReply->fIrqChannel12 = 1; break;
     1789                case 14:    pReply->fIrqChannel14 = 1; break;
     1790                case 15:    pReply->fIrqChannel15 = 1; break;
     1791                default:
     1792                    LogRel(("Warning: PCI IRQ %d cannot be represented as ISA!\n", uPciIrq));
     1793                    break;
    17731794            }
    17741795            break;
     
    17861807            memset(pReply, 0, sizeof(ReplyInquireExtendedSetupInformation));
    17871808
    1788             //@todo: should this reflect the RAM contents (AutoSCSIRam)?
     1809            /** @todo should this reflect the RAM contents (AutoSCSIRam)? */
    17891810            pReply->uBusType = 'E';         /* EISA style */
    17901811            pReply->u16ScatterGatherLimit = 8192;
     
    19341955
    19351956            for (uint8_t i = 0; i < pBusLogic->cbReplyParametersLeft; i++)
    1936                 pBusLogic->aReplyBuffer[i] = 0; /* @todo Figure if we need something other here. It's not needed for the linux driver */
     1957                pBusLogic->aReplyBuffer[i] = 0; /** @todo Figure if we need something other here. It's not needed for the linux driver */
    19371958
    19381959            break;
     
    21112132
    21122133                LogRel(("BusLogic: %s reset\n", fHardReset ? "hard" : "soft"));
    2113                 buslogicInitiateReset(pBusLogic, fHardReset);
     2134                buslogicR3InitiateReset(pBusLogic, fHardReset);
    21142135#else
    21152136                rc = VINF_IOM_R3_IOPORT_WRITE;
     
    22742295 * @param   cb          Number of bytes read.
    22752296 */
    2276 PDMBOTHCBDECL(int) buslogicMMIORead(PPDMDEVINS pDevIns, void *pvUser,
    2277                                     RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
     2297PDMBOTHCBDECL(int) buslogicMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
    22782298{
    22792299    /* the linux driver does not make use of the MMIO area. */
     
    22932313 * @param   cb          Number of bytes to write.
    22942314 */
    2295 PDMBOTHCBDECL(int) buslogicMMIOWrite(PPDMDEVINS pDevIns, void *pvUser,
    2296                                      RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
     2315PDMBOTHCBDECL(int) buslogicMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
    22972316{
    22982317    /* the linux driver does not make use of the MMIO area. */
     
    23122331 * @param   cb          Number of bytes read.
    23132332 */
    2314 PDMBOTHCBDECL(int) buslogicIOPortRead (PPDMDEVINS pDevIns, void *pvUser,
    2315                                        RTIOPORT Port, uint32_t *pu32, unsigned cb)
     2333PDMBOTHCBDECL(int) buslogicIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    23162334{
    23172335    PBUSLOGIC pBusLogic = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    23342352 * @param   cb          The value size in bytes.
    23352353 */
    2336 PDMBOTHCBDECL(int) buslogicIOPortWrite (PPDMDEVINS pDevIns, void *pvUser,
    2337                                         RTIOPORT Port, uint32_t u32, unsigned cb)
     2354PDMBOTHCBDECL(int) buslogicIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    23382355{
    23392356    PBUSLOGIC pBusLogic = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    23542371#ifdef IN_RING3
    23552372
    2356 static int buslogicPrepareBIOSSCSIRequest(PBUSLOGIC pBusLogic)
     2373static int buslogicR3PrepareBIOSSCSIRequest(PBUSLOGIC pBusLogic)
    23572374{
    23582375    int rc;
     
    24172434 * @param   cb          Number of bytes read.
    24182435 */
    2419 static int  buslogicBIOSIOPortRead(PPDMDEVINS pDevIns, void *pvUser,
    2420                                    RTIOPORT Port, uint32_t *pu32, unsigned cb)
     2436static DECLCALLBACK(int) buslogicR3BiosIoPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
    24212437{
    24222438    int rc;
     
    24442460 * @param   cb          The value size in bytes.
    24452461 */
    2446 static int buslogicBIOSIOPortWrite(PPDMDEVINS pDevIns, void *pvUser,
    2447                                    RTIOPORT Port, uint32_t u32, unsigned cb)
     2462static DECLCALLBACK(int) buslogicR3BiosIoPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
    24482463{
    24492464    int rc;
     
    24582473    if (rc == VERR_MORE_DATA)
    24592474    {
    2460         rc = buslogicPrepareBIOSSCSIRequest(pBusLogic);
     2475        rc = buslogicR3PrepareBIOSSCSIRequest(pBusLogic);
    24612476        AssertRC(rc);
    24622477    }
     
    24712486 * @see FNIOMIOPORTOUTSTRING for details.
    24722487 */
    2473 static DECLCALLBACK(int) buslogicBIOSIOPortWriteStr(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrSrc, PRTGCUINTREG pcTransfer, unsigned cb)
     2488static DECLCALLBACK(int) buslogicR3BiosIoPortWriteStr(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrSrc,
     2489                                                      PRTGCUINTREG pcTransfer, unsigned cb)
    24742490{
    24752491    PBUSLOGIC pBusLogic = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    24832499    if (rc == VERR_MORE_DATA)
    24842500    {
    2485         rc = buslogicPrepareBIOSSCSIRequest(pBusLogic);
     2501        rc = buslogicR3PrepareBIOSSCSIRequest(pBusLogic);
    24862502        AssertRC(rc);
    24872503    }
     
    24962512 * @see FNIOMIOPORTINSTRING for details.
    24972513 */
    2498 static DECLCALLBACK(int) buslogicBIOSIOPortReadStr(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrDst, PRTGCUINTREG pcTransfer, unsigned cb)
     2514static DECLCALLBACK(int) buslogicR3BiosIoPortReadStr(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, RTGCPTR *pGCPtrDst,
     2515                                                     PRTGCUINTREG pcTransfer, unsigned cb)
    24992516{
    25002517    PBUSLOGIC pBusLogic = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    25142531 * @param   uBaseCode       Encoded ISA I/O base; only low 3 bits are used.
    25152532 */
    2516 static int buslogicRegisterISARange(PBUSLOGIC pBusLogic, uint8_t uBaseCode)
     2533static int buslogicR3RegisterISARange(PBUSLOGIC pBusLogic, uint8_t uBaseCode)
    25172534{
    25182535    uint8_t     uCode = uBaseCode & MAX_ISA_BASE;
    2519     uint16_t    uNewBase = aISABases[uCode];
     2536    uint16_t    uNewBase = g_aISABases[uCode];
    25202537    int         rc = VINF_SUCCESS;
    25212538
     
    25662583}
    25672584
    2568 static void buslogicWarningDiskFull(PPDMDEVINS pDevIns)
     2585static void buslogicR3WarningDiskFull(PPDMDEVINS pDevIns)
    25692586{
    25702587    int rc;
     
    25752592}
    25762593
    2577 static void buslogicWarningFileTooBig(PPDMDEVINS pDevIns)
     2594static void buslogicR3WarningFileTooBig(PPDMDEVINS pDevIns)
    25782595{
    25792596    int rc;
     
    25842601}
    25852602
    2586 static void buslogicWarningISCSI(PPDMDEVINS pDevIns)
     2603static void buslogicR3WarningISCSI(PPDMDEVINS pDevIns)
    25872604{
    25882605    int rc;
     
    25932610}
    25942611
    2595 static void buslogicWarningUnknown(PPDMDEVINS pDevIns, int rc)
     2612static void buslogicR3WarningUnknown(PPDMDEVINS pDevIns, int rc)
    25962613{
    25972614    int rc2;
     
    26022619}
    26032620
    2604 static void buslogicRedoSetWarning(PBUSLOGIC pThis, int rc)
     2621static void buslogicR3RedoSetWarning(PBUSLOGIC pThis, int rc)
    26052622{
    26062623    if (rc == VERR_DISK_FULL)
    2607         buslogicWarningDiskFull(pThis->CTX_SUFF(pDevIns));
     2624        buslogicR3WarningDiskFull(pThis->CTX_SUFF(pDevIns));
    26082625    else if (rc == VERR_FILE_TOO_BIG)
    2609         buslogicWarningFileTooBig(pThis->CTX_SUFF(pDevIns));
     2626        buslogicR3WarningFileTooBig(pThis->CTX_SUFF(pDevIns));
    26102627    else if (rc == VERR_BROKEN_PIPE || rc == VERR_NET_CONNECTION_REFUSED)
    26112628    {
    26122629        /* iSCSI connection abort (first error) or failure to reestablish
    26132630         * connection (second error). Pause VM. On resume we'll retry. */
    2614         buslogicWarningISCSI(pThis->CTX_SUFF(pDevIns));
     2631        buslogicR3WarningISCSI(pThis->CTX_SUFF(pDevIns));
    26152632    }
    26162633    else
    2617         buslogicWarningUnknown(pThis->CTX_SUFF(pDevIns), rc);
    2618 }
    2619 
    2620 
    2621 static DECLCALLBACK(int) buslogicMMIOMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion,
    2622                                          RTGCPHYS GCPhysAddress, uint32_t cb,
    2623                                          PCIADDRESSSPACE enmType)
     2634        buslogicR3WarningUnknown(pThis->CTX_SUFF(pDevIns), rc);
     2635}
     2636
     2637
     2638static DECLCALLBACK(int) buslogicR3MmioMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion,
     2639                                           RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
    26242640{
    26252641    PPDMDEVINS pDevIns = pPciDev->pDevIns;
     
    26892705}
    26902706
    2691 static DECLCALLBACK(int) buslogicDeviceSCSIRequestCompleted(PPDMISCSIPORT pInterface, PPDMSCSIREQUEST pSCSIRequest,
    2692                                                             int rcCompletion, bool fRedo, int rcReq)
     2707static DECLCALLBACK(int) buslogicR3DeviceSCSIRequestCompleted(PPDMISCSIPORT pInterface, PPDMSCSIREQUEST pSCSIRequest,
     2708                                                              int rcCompletion, bool fRedo, int rcReq)
    26932709{
    26942710    int rc;
     
    27052721        if (!pTaskState->fBIOS)
    27062722        {
    2707             buslogicDataBufferFree(pTaskState);
     2723            buslogicR3DataBufferFree(pTaskState);
    27082724
    27092725            if (pTaskState->pbSenseBuffer)
    2710                 buslogicSenseBufferFree(pTaskState, false /* fCopy */);
     2726                buslogicR3SenseBufferFree(pTaskState, false /* fCopy */);
    27112727        }
    27122728
     
    27192735        /* Suspend the VM if not done already. */
    27202736        if (!ASMAtomicXchgBool(&pBusLogic->fRedo, true))
    2721             buslogicRedoSetWarning(pBusLogic, rcReq);
     2737            buslogicR3RedoSetWarning(pBusLogic, rcReq);
    27222738    }
    27232739    else
     
    27302746        else
    27312747        {
    2732             buslogicDataBufferFree(pTaskState);
     2748            buslogicR3DataBufferFree(pTaskState);
    27332749
    27342750            if (pTaskState->pbSenseBuffer)
    2735                 buslogicSenseBufferFree(pTaskState, (rcCompletion != SCSI_STATUS_OK));
     2751                buslogicR3SenseBufferFree(pTaskState, (rcCompletion != SCSI_STATUS_OK));
    27362752
    27372753            if (rcCompletion == SCSI_STATUS_OK)
    2738                 buslogicSendIncomingMailbox(pBusLogic, pTaskState,
     2754                buslogicR3SendIncomingMailbox(pBusLogic, pTaskState,
    27392755                                            BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_CMD_COMPLETED,
    27402756                                            BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD,
    27412757                                            BUSLOGIC_MAILBOX_INCOMING_COMPLETION_WITHOUT_ERROR);
    27422758            else if (rcCompletion == SCSI_STATUS_CHECK_CONDITION)
    2743                 buslogicSendIncomingMailbox(pBusLogic, pTaskState,
     2759                buslogicR3SendIncomingMailbox(pBusLogic, pTaskState,
    27442760                                            BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_CMD_COMPLETED,
    27452761                                            BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_CHECK_CONDITION,
     
    27482764                AssertMsgFailed(("invalid completion status %d\n", rcCompletion));
    27492765        }
    2750 #ifdef DEBUG
    2751             buslogicDumpCCBInfo(&pTaskState->CommandControlBlockGuest, pTaskState->fIs24Bit);
     2766#ifdef LOG_ENABLED
     2767            buslogicR3DumpCCBInfo(&pTaskState->CommandControlBlockGuest, pTaskState->fIs24Bit);
    27522768#endif
    27532769
     
    27622778}
    27632779
    2764 static DECLCALLBACK(int) buslogicQueryDeviceLocation(PPDMISCSIPORT pInterface, const char **ppcszController,
    2765                                                      uint32_t *piInstance, uint32_t *piLUN)
     2780static DECLCALLBACK(int) buslogicR3QueryDeviceLocation(PPDMISCSIPORT pInterface, const char **ppcszController,
     2781                                                       uint32_t *piInstance, uint32_t *piLUN)
    27662782{
    27672783    PBUSLOGICDEVICE pBusLogicDevice = PDMISCSIPORT_2_PBUSLOGICDEVICE(pInterface);
     
    27792795}
    27802796
    2781 static int buslogicDeviceSCSIRequestSetup(PBUSLOGIC pBusLogic, PBUSLOGICTASKSTATE pTaskState)
     2797static int buslogicR3DeviceSCSIRequestSetup(PBUSLOGIC pBusLogic, PBUSLOGICTASKSTATE pTaskState)
    27822798{
    27832799    int rc = VINF_SUCCESS;
     
    27862802
    27872803    /* Fetch the CCB from guest memory. */
    2788     //@todo: How much do we really have to read?
     2804    /** @todo How much do we really have to read? */
    27892805    RTGCPHYS GCPhysAddrCCB = (RTGCPHYS)pTaskState->MailboxGuest.u32PhysAddrCCB;
    27902806    PDMDevHlpPhysRead(pBusLogic->CTX_SUFF(pDevIns), GCPhysAddrCCB,
     
    27952811    pTaskState->CTX_SUFF(pTargetDevice) = pTargetDevice;
    27962812
    2797 #ifdef DEBUG
    2798     buslogicDumpCCBInfo(&pTaskState->CommandControlBlockGuest, pTaskState->fIs24Bit);
     2813#ifdef LOG_ENABLED
     2814    buslogicR3DumpCCBInfo(&pTaskState->CommandControlBlockGuest, pTaskState->fIs24Bit);
    27992815#endif
    28002816
    28012817    /* Alloc required buffers. */
    2802     rc = buslogicDataBufferAlloc(pTaskState);
     2818    rc = buslogicR3DataBufferAlloc(pTaskState);
    28032819    AssertMsgRC(rc, ("Alloc failed rc=%Rrc\n", rc));
    28042820
    2805     rc = buslogicSenseBufferAlloc(pTaskState);
     2821    rc = buslogicR3SenseBufferAlloc(pTaskState);
    28062822    AssertMsgRC(rc, ("Mapping sense buffer failed rc=%Rrc\n", rc));
    28072823
     
    28092825    if (!pBusLogic->aDeviceStates[uTargetIdCCB].fPresent)
    28102826    {
    2811         buslogicDataBufferFree(pTaskState);
     2827        buslogicR3DataBufferFree(pTaskState);
    28122828
    28132829        if (pTaskState->pbSenseBuffer)
    2814             buslogicSenseBufferFree(pTaskState, true);
    2815 
    2816         buslogicSendIncomingMailbox(pBusLogic, pTaskState,
     2830            buslogicR3SenseBufferFree(pTaskState, true);
     2831
     2832        buslogicR3SendIncomingMailbox(pBusLogic, pTaskState,
    28172833                                    BUSLOGIC_MAILBOX_INCOMING_ADAPTER_STATUS_SCSI_SELECTION_TIMEOUT,
    28182834                                    BUSLOGIC_MAILBOX_INCOMING_DEVICE_STATUS_OPERATION_GOOD,
     
    28522868            pTaskState->PDMScsiRequest.paScatterGatherHead   = NULL;
    28532869        }
    2854         pTaskState->PDMScsiRequest.cbSenseBuffer         = buslogicConvertSenseBufferLength(pTaskState->CommandControlBlockGuest.c.cbSenseData);
     2870        pTaskState->PDMScsiRequest.cbSenseBuffer         = buslogicR3ConvertSenseBufferLength(pTaskState->CommandControlBlockGuest.c.cbSenseData);
    28552871        pTaskState->PDMScsiRequest.pbSenseBuffer         = pTaskState->pbSenseBuffer;
    28562872        pTaskState->PDMScsiRequest.pvUser                = pTaskState;
     
    28722888 * @param   pTaskStat    Pointer to the task state being set up.
    28732889 */
    2874 static RTGCPHYS buslogicReadOutgoingMailbox(PBUSLOGIC pBusLogic, PBUSLOGICTASKSTATE pTaskState)
     2890static RTGCPHYS buslogicR3ReadOutgoingMailbox(PBUSLOGIC pBusLogic, PBUSLOGICTASKSTATE pTaskState)
    28752891{
    28762892    RTGCPHYS    GCMailbox;
     
    29002916 * @param   pBusLogic    Pointer to the BusLogic instance data.
    29012917 */
    2902 static int buslogicProcessMailboxNext(PBUSLOGIC pBusLogic)
     2918static int buslogicR3ProcessMailboxNext(PBUSLOGIC pBusLogic)
    29032919{
    29042920    PBUSLOGICTASKSTATE pTaskState = NULL;
     
    29212937        {
    29222938            /* Fetch mailbox from guest memory. */
    2923             GCPhysAddrMailboxCurrent = buslogicReadOutgoingMailbox(pBusLogic,pTaskState);
     2939            GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pBusLogic,pTaskState);
    29242940
    29252941            /* Check the next mailbox. */
    2926             buslogicOutgoingMailboxAdvance(pBusLogic);
     2942            buslogicR3OutgoingMailboxAdvance(pBusLogic);
    29272943        } while (   pTaskState->MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_FREE
    29282944                 && uMailboxPosCur != pBusLogic->uMailboxOutgoingPositionCurrent);
     
    29312947    {
    29322948        /* Fetch mailbox from guest memory. */
    2933         GCPhysAddrMailboxCurrent = buslogicReadOutgoingMailbox(pBusLogic,pTaskState);
     2949        GCPhysAddrMailboxCurrent = buslogicR3ReadOutgoingMailbox(pBusLogic,pTaskState);
    29342950    }
    29352951
     
    29482964
    29492965    LogFlow(("Got loaded mailbox at slot %u, CCB phys %RGp\n", pBusLogic->uMailboxOutgoingPositionCurrent, (RTGCPHYS)pTaskState->MailboxGuest.u32PhysAddrCCB));
    2950 #ifdef DEBUG
    2951     buslogicDumpMailboxInfo(&pTaskState->MailboxGuest, true);
     2966#ifdef LOG_ENABLED
     2967    buslogicR3DumpMailboxInfo(&pTaskState->MailboxGuest, true);
    29522968#endif
    29532969
     
    29582974
    29592975    if (pTaskState->MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_START_COMMAND)
    2960         rc = buslogicDeviceSCSIRequestSetup(pBusLogic, pTaskState);
     2976        rc = buslogicR3DeviceSCSIRequestSetup(pBusLogic, pTaskState);
    29612977    else if (pTaskState->MailboxGuest.u.out.uActionCode == BUSLOGIC_MAILBOX_OUTGOING_ACTION_ABORT_COMMAND)
    29622978    {
     
    29702986    /* Advance to the next mailbox. */
    29712987    if (pBusLogic->fStrictRoundRobinMode)
    2972         buslogicOutgoingMailboxAdvance(pBusLogic);
     2988        buslogicR3OutgoingMailboxAdvance(pBusLogic);
    29732989
    29742990    return rc;
     
    29843000 * @param   pItem       The item to consume. Upon return this item will be freed.
    29853001 */
    2986 static DECLCALLBACK(bool) buslogicNotifyQueueConsumer(PPDMDEVINS pDevIns, PPDMQUEUEITEMCORE pItem)
     3002static DECLCALLBACK(bool) buslogicR3NotifyQueueConsumer(PPDMDEVINS pDevIns, PPDMQUEUEITEMCORE pItem)
    29873003{
    29883004    PBUSLOGIC  pBusLogic = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    29913007    Assert(pBusLogic->fNotificationSend);
    29923008    ASMAtomicXchgBool(&pBusLogic->fNotificationSend, false);
    2993     ASMAtomicXchgU32(&pBusLogic->cMailboxesReady, 0); /* @todo: Actually not required anymore but to stay compatible with older saved states. */
     3009    ASMAtomicXchgU32(&pBusLogic->cMailboxesReady, 0); /** @todo Actually not required anymore but to stay compatible with older saved states. */
    29943010
    29953011    /* Process mailboxes. */
     
    29973013    do
    29983014    {
    2999         rc = buslogicProcessMailboxNext(pBusLogic);
     3015        rc = buslogicR3ProcessMailboxNext(pBusLogic);
    30003016        AssertMsg(RT_SUCCESS(rc) || rc == VERR_NO_DATA, ("Processing mailbox failed rc=%Rrc\n", rc));
    30013017    } while (RT_SUCCESS(rc));
     
    30113027 * @param   pThis    The BusLogic device instance.
    30123028 */
    3013 static void buslogicKick(PBUSLOGIC pThis)
     3029static void buslogicR3Kick(PBUSLOGIC pThis)
    30143030{
    30153031    if (pThis->fRedo)
     
    30203036
    30213037            /* The BIOS had a request active when we got suspended. Resume it. */
    3022             int rc = buslogicPrepareBIOSSCSIRequest(pThis);
     3038            int rc = buslogicR3PrepareBIOSSCSIRequest(pThis);
    30233039            AssertRC(rc);
    30243040        }
     
    30343050                PBUSLOGICTASKSTATE pCur = pTaskState;
    30353051
    3036                 int rc = buslogicDeviceSCSIRequestSetup(pThis, pCur);
     3052                int rc = buslogicR3DeviceSCSIRequestSetup(pThis, pCur);
    30373053                AssertRC(rc);
    30383054
     
    30433059}
    30443060
    3045 static DECLCALLBACK(int) buslogicLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
     3061/** @callback_method_impl{FNSSMDEVLIVEEXEC}  */
     3062static DECLCALLBACK(int) buslogicR3LiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
    30463063{
    30473064    PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    30543071}
    30553072
    3056 static DECLCALLBACK(int) buslogicSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
     3073/** @callback_method_impl{FNSSMDEVSAVEEXEC}  */
     3074static DECLCALLBACK(int) buslogicR3SaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    30573075{
    30583076    PBUSLOGIC pBusLogic = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    31373155}
    31383156
    3139 static DECLCALLBACK(int) buslogicLoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
     3157/** @callback_method_impl{FNSSMDEVLOADDONE}  */
     3158static DECLCALLBACK(int) buslogicR3LoadDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    31403159{
    31413160    PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
    31423161
    3143     buslogicRegisterISARange(pThis, pThis->uISABaseCode);
    3144     buslogicKick(pThis);
     3162    buslogicR3RegisterISARange(pThis, pThis->uISABaseCode);
     3163    buslogicR3Kick(pThis);
    31453164    return VINF_SUCCESS;
    31463165}
    31473166
    3148 static DECLCALLBACK(int) buslogicLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
     3167/** @callback_method_impl{FNSSMDEVLOADEXEC}  */
     3168static DECLCALLBACK(int) buslogicR3LoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    31493169{
    31503170    PBUSLOGIC   pBusLogic = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    32713291
    32723292/**
    3273  * Gets the pointer to the status LED of a device - called from the SCSi driver.
     3293 * Gets the pointer to the status LED of a device - called from the SCSI driver.
    32743294 *
    32753295 * @returns VBox status code.
     
    32793299 * @param   ppLed           Where to store the LED pointer.
    32803300 */
    3281 static DECLCALLBACK(int) buslogicDeviceQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
     3301static DECLCALLBACK(int) buslogicR3DeviceQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
    32823302{
    32833303    PBUSLOGICDEVICE pDevice = PDMILEDPORTS_2_PBUSLOGICDEVICE(pInterface);
     
    32943314 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    32953315 */
    3296 static DECLCALLBACK(void *) buslogicDeviceQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     3316static DECLCALLBACK(void *) buslogicR3DeviceQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    32973317{
    32983318    PBUSLOGICDEVICE pDevice = PDMIBASE_2_PBUSLOGICDEVICE(pInterface);
     
    33113331 * @param   ppLed           Where to store the LED pointer.
    33123332 */
    3313 static DECLCALLBACK(int) buslogicStatusQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
     3333static DECLCALLBACK(int) buslogicR3StatusQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
    33143334{
    33153335    PBUSLOGIC pBusLogic = PDMILEDPORTS_2_PBUSLOGIC(pInterface);
     
    33263346 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
    33273347 */
    3328 static DECLCALLBACK(void *) buslogicStatusQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     3348static DECLCALLBACK(void *) buslogicR3StatusQueryInterface(PPDMIBASE pInterface, const char *pszIID)
    33293349{
    33303350    PBUSLOGIC pThis = PDMIBASE_2_PBUSLOGIC(pInterface);
     
    33413361 * @param   pszArgs     The arguments.
    33423362 */
    3343 static DECLCALLBACK(void) buslogicInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
     3363static DECLCALLBACK(void) buslogicR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    33443364{
    33453365    PBUSLOGIC   pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    33633383        pHlp->pfnPrintf(pHlp, "Mailbox not initialized\n");
    33643384    else
    3365     {
    33663385        pHlp->pfnPrintf(pHlp, "%u-bit mailbox with %u entries at %RGp\n",
    33673386                        pThis->fMbxIs24Bit ? 24 : 32, pThis->cMailbox,
    33683387                        pThis->GCPhysAddrMailboxOutgoingBase);
    3369     }
    33703388
    33713389    /* Print register contents. */
     
    33833401 * Checks if all asynchronous I/O is finished.
    33843402 *
    3385  * Used by buslogicReset, buslogicSuspend and buslogicPowerOff.
     3403 * Used by buslogicR3Reset, buslogicR3Suspend and buslogicR3PowerOff.
    33863404 *
    33873405 * @returns true if quiesced, false if busy.
     
    34753493 * @param   pDevIns     The device instance data.
    34763494 */
    3477 static DECLCALLBACK(void) buslogicSuspend(PPDMDEVINS pDevIns)
    3478 {
    3479     Log(("buslogicSuspend\n"));
     3495static DECLCALLBACK(void) buslogicR3Suspend(PPDMDEVINS pDevIns)
     3496{
     3497    Log(("buslogicR3Suspend\n"));
    34803498    buslogicR3SuspendOrPowerOff(pDevIns, false /* fPoweroff */);
    34813499}
     
    34863504 * @param   pDevIns     The device instance data.
    34873505 */
    3488 static DECLCALLBACK(void) buslogicResume(PPDMDEVINS pDevIns)
    3489 {
    3490     Log(("buslogicResume\n"));
     3506static DECLCALLBACK(void) buslogicR3Resume(PPDMDEVINS pDevIns)
     3507{
     3508    Log(("buslogicR3Resume\n"));
    34913509    PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
    3492     buslogicKick(pThis);
     3510    buslogicR3Kick(pThis);
    34933511}
    34943512
     
    35043522 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    35053523 */
    3506 static DECLCALLBACK(void) buslogicDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     3524static DECLCALLBACK(void) buslogicR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    35073525{
    35083526    PBUSLOGIC       pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    35323550 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    35333551 */
    3534 static DECLCALLBACK(int)  buslogicAttach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
     3552static DECLCALLBACK(int)  buslogicR3Attach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
    35353553{
    35363554    PBUSLOGIC       pThis   = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    35843602    ASMAtomicWriteBool(&pThis->fSignalIdle, false);
    35853603
    3586     buslogicHwReset(pThis, true);
     3604    buslogicR3HwReset(pThis, true);
    35873605    return true;
    35883606}
     
    35913609 * @copydoc FNPDMDEVRESET
    35923610 */
    3593 static DECLCALLBACK(void) buslogicReset(PPDMDEVINS pDevIns)
     3611static DECLCALLBACK(void) buslogicR3Reset(PPDMDEVINS pDevIns)
    35943612{
    35953613    PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    36013619    {
    36023620        ASMAtomicWriteBool(&pThis->fSignalIdle, false);
    3603         buslogicHwReset(pThis, true);
    3604     }
    3605 }
    3606 
    3607 static DECLCALLBACK(void) buslogicRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    3608 {
    3609     uint32_t i;
    3610     PBUSLOGIC pBusLogic = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
    3611 
    3612     pBusLogic->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    3613     pBusLogic->pNotifierQueueRC = PDMQueueRCPtr(pBusLogic->pNotifierQueueR3);
    3614 
    3615     for (i = 0; i < BUSLOGIC_MAX_DEVICES; i++)
    3616     {
    3617         PBUSLOGICDEVICE pDevice = &pBusLogic->aDeviceStates[i];
     3621        buslogicR3HwReset(pThis, true);
     3622    }
     3623}
     3624
     3625static DECLCALLBACK(void) buslogicR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
     3626{
     3627    PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     3628
     3629    pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
     3630    pThis->pNotifierQueueRC = PDMQueueRCPtr(pThis->pNotifierQueueR3);
     3631
     3632    for (uint32_t i = 0; i < BUSLOGIC_MAX_DEVICES; i++)
     3633    {
     3634        PBUSLOGICDEVICE pDevice = &pThis->aDeviceStates[i];
    36183635
    36193636        pDevice->pBusLogicRC = PDMINS_2_DATA_RCPTR(pDevIns);
     
    36273644 * @param   pDevIns Pointer to the device instance
    36283645 */
    3629 static DECLCALLBACK(void) buslogicPowerOff(PPDMDEVINS pDevIns)
    3630 {
    3631     Log(("buslogicPowerOff\n"));
     3646static DECLCALLBACK(void) buslogicR3PowerOff(PPDMDEVINS pDevIns)
     3647{
     3648    Log(("buslogicR3PowerOff\n"));
    36323649    buslogicR3SuspendOrPowerOff(pDevIns, true /* fPoweroff */);
    36333650}
     
    36413658 * @param   pDevIns     The device instance data.
    36423659 */
    3643 static DECLCALLBACK(int) buslogicDestruct(PPDMDEVINS pDevIns)
     3660static DECLCALLBACK(int) buslogicR3Destruct(PPDMDEVINS pDevIns)
    36443661{
    36453662    PBUSLOGIC  pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    36803697 * @interface_method_impl{PDMDEVREG,pfnConstruct}
    36813698 */
    3682 static DECLCALLBACK(int) buslogicConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
     3699static DECLCALLBACK(int) buslogicR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
    36833700{
    36843701    PBUSLOGIC  pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     
    36873704    char       achISACompat[16];
    36883705    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
     3706
     3707    /*
     3708     * Init instance data (do early because of constructor).
     3709     */
     3710    pThis->hTaskCache = NIL_RTMEMCACHE;
     3711    pThis->pDevInsR3 = pDevIns;
     3712    pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
     3713    pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
     3714    pThis->IBase.pfnQueryInterface = buslogicR3StatusQueryInterface;
     3715    pThis->ILeds.pfnQueryStatusLed = buslogicR3StatusQueryStatusLed;
     3716
     3717    PCIDevSetVendorId         (&pThis->dev, 0x104b); /* BusLogic */
     3718    PCIDevSetDeviceId         (&pThis->dev, 0x1040); /* BT-958 */
     3719    PCIDevSetCommand          (&pThis->dev, 0x0003);
     3720    PCIDevSetRevisionId       (&pThis->dev, 0x01);
     3721    PCIDevSetClassProg        (&pThis->dev, 0x00); /* SCSI */
     3722    PCIDevSetClassSub         (&pThis->dev, 0x00); /* SCSI */
     3723    PCIDevSetClassBase        (&pThis->dev, 0x01); /* Mass storage */
     3724    PCIDevSetBaseAddress      (&pThis->dev, 0, true  /*IO*/, false /*Pref*/, false /*64-bit*/, 0x00000000);
     3725    PCIDevSetBaseAddress      (&pThis->dev, 1, false /*IO*/, false /*Pref*/, false /*64-bit*/, 0x00000000);
     3726    PCIDevSetSubSystemVendorId(&pThis->dev, 0x104b);
     3727    PCIDevSetSubSystemId      (&pThis->dev, 0x1040);
     3728    PCIDevSetInterruptLine    (&pThis->dev, 0x00);
     3729    PCIDevSetInterruptPin     (&pThis->dev, 0x01);
    36893730
    36903731    /*
     
    37323773                                N_("BusLogic configuration error: invalid ISACompat setting"));
    37333774
    3734     pThis->pDevInsR3 = pDevIns;
    3735     pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    3736     pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    3737     pThis->IBase.pfnQueryInterface = buslogicStatusQueryInterface;
    3738     pThis->ILeds.pfnQueryStatusLed = buslogicStatusQueryStatusLed;
    3739 
    3740     PCIDevSetVendorId         (&pThis->dev, 0x104b); /* BusLogic */
    3741     PCIDevSetDeviceId         (&pThis->dev, 0x1040); /* BT-958 */
    3742     PCIDevSetCommand          (&pThis->dev, 0x0003);
    3743     PCIDevSetRevisionId       (&pThis->dev, 0x01);
    3744     PCIDevSetClassProg        (&pThis->dev, 0x00); /* SCSI */
    3745     PCIDevSetClassSub         (&pThis->dev, 0x00); /* SCSI */
    3746     PCIDevSetClassBase        (&pThis->dev, 0x01); /* Mass storage */
    3747     PCIDevSetBaseAddress      (&pThis->dev, 0, true  /*IO*/, false /*Pref*/, false /*64-bit*/, 0x00000000);
    3748     PCIDevSetBaseAddress      (&pThis->dev, 1, false /*IO*/, false /*Pref*/, false /*64-bit*/, 0x00000000);
    3749     PCIDevSetSubSystemVendorId(&pThis->dev, 0x104b);
    3750     PCIDevSetSubSystemId      (&pThis->dev, 0x1040);
    3751     PCIDevSetInterruptLine    (&pThis->dev, 0x00);
    3752     PCIDevSetInterruptPin     (&pThis->dev, 0x01);
    3753 
    37543775    /*
    37553776     * Register the PCI device and its I/O regions.
    37563777     */
    3757     rc = PDMDevHlpPCIRegister (pDevIns, &pThis->dev);
     3778    rc = PDMDevHlpPCIRegister(pDevIns, &pThis->dev);
    37583779    if (RT_FAILURE(rc))
    37593780        return rc;
    37603781
    3761     rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 32, PCI_ADDRESS_SPACE_IO, buslogicMMIOMap);
     3782    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 32, PCI_ADDRESS_SPACE_IO, buslogicR3MmioMap);
    37623783    if (RT_FAILURE(rc))
    37633784        return rc;
    37643785
    3765     rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 32, PCI_ADDRESS_SPACE_MEM, buslogicMMIOMap);
     3786    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 32, PCI_ADDRESS_SPACE_MEM, buslogicR3MmioMap);
    37663787    if (RT_FAILURE(rc))
    37673788        return rc;
     
    37713792        /* Register I/O port space for BIOS access. */
    37723793        rc = PDMDevHlpIOPortRegister(pDevIns, BUSLOGIC_BIOS_IO_PORT, 4, NULL,
    3773                                      buslogicBIOSIOPortWrite, buslogicBIOSIOPortRead,
    3774                                      buslogicBIOSIOPortWriteStr, buslogicBIOSIOPortReadStr,
     3794                                     buslogicR3BiosIoPortWrite, buslogicR3BiosIoPortRead,
     3795                                     buslogicR3BiosIoPortWriteStr, buslogicR3BiosIoPortReadStr,
    37753796                                     "BusLogic BIOS");
    37763797        if (RT_FAILURE(rc))
     
    37793800
    37803801    /* Set up the compatibility I/O range. */
    3781     rc = buslogicRegisterISARange(pThis, pThis->uDefaultISABaseCode);
     3802    rc = buslogicR3RegisterISARange(pThis, pThis->uDefaultISABaseCode);
    37823803    if (RT_FAILURE(rc))
    37833804        return PDMDEV_SET_ERROR(pDevIns, rc, N_("BusLogic cannot register ISA I/O handlers"));
     
    37923813    /* Initialize task queue. */
    37933814    rc = PDMDevHlpQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 5, 0,
    3794                               buslogicNotifyQueueConsumer, true, "BusLogicTask", &pThis->pNotifierQueueR3);
     3815                              buslogicR3NotifyQueueConsumer, true, "BusLogicTask", &pThis->pNotifierQueueR3);
    37953816    if (RT_FAILURE(rc))
    37963817        return rc;
     
    38003821    rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSectIntr, RT_SRC_POS, "BusLogic-Intr#%u", pDevIns->iInstance);
    38013822    if (RT_FAILURE(rc))
    3802         return PDMDEV_SET_ERROR(pDevIns, rc,
    3803                                 N_("BusLogic: cannot create critical section"));
     3823        return PDMDEV_SET_ERROR(pDevIns, rc, N_("BusLogic: cannot create critical section"));
    38043824
    38053825    /* Initialize per device state. */
     
    38093829        PBUSLOGICDEVICE pDevice = &pThis->aDeviceStates[i];
    38103830
    3811         RTStrPrintf(szName, sizeof(szName), "Device%d", i);
     3831        RTStrPrintf(szName, sizeof(szName), "Device%u", i);
    38123832
    38133833        /* Initialize static parts of the device. */
     
    38173837        pDevice->pBusLogicRC = PDMINS_2_DATA_RCPTR(pDevIns);
    38183838        pDevice->Led.u32Magic = PDMLED_MAGIC;
    3819         pDevice->IBase.pfnQueryInterface           = buslogicDeviceQueryInterface;
    3820         pDevice->ISCSIPort.pfnSCSIRequestCompleted = buslogicDeviceSCSIRequestCompleted;
    3821         pDevice->ISCSIPort.pfnQueryDeviceLocation  = buslogicQueryDeviceLocation;
    3822         pDevice->ILed.pfnQueryStatusLed            = buslogicDeviceQueryStatusLed;
     3839        pDevice->IBase.pfnQueryInterface           = buslogicR3DeviceQueryInterface;
     3840        pDevice->ISCSIPort.pfnSCSIRequestCompleted = buslogicR3DeviceSCSIRequestCompleted;
     3841        pDevice->ISCSIPort.pfnQueryDeviceLocation  = buslogicR3QueryDeviceLocation;
     3842        pDevice->ILed.pfnQueryStatusLed            = buslogicR3DeviceQueryStatusLed;
    38233843
    38243844        /* Attach SCSI driver. */
     
    38603880
    38613881    rc = PDMDevHlpSSMRegisterEx(pDevIns, BUSLOGIC_SAVED_STATE_MINOR_VERSION, sizeof(*pThis), NULL,
    3862                                 NULL, buslogicLiveExec, NULL,
    3863                                 NULL, buslogicSaveExec, NULL,
    3864                                 NULL, buslogicLoadExec, buslogicLoadDone);
     3882                                NULL, buslogicR3LiveExec, NULL,
     3883                                NULL, buslogicR3SaveExec, NULL,
     3884                                NULL, buslogicR3LoadExec, buslogicR3LoadDone);
    38653885    if (RT_FAILURE(rc))
    38663886        return PDMDEV_SET_ERROR(pDevIns, rc, N_("BusLogic cannot register save state handlers"));
     
    38713891    char szTmp[128];
    38723892    RTStrPrintf(szTmp, sizeof(szTmp), "%s%d", pDevIns->pReg->szName, pDevIns->iInstance);
    3873     PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, "BusLogic HBA info", buslogicInfo);
    3874 
    3875     rc = buslogicHwReset(pThis, true);
     3893    PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, "BusLogic HBA info", buslogicR3Info);
     3894
     3895    rc = buslogicR3HwReset(pThis, true);
    38763896    AssertMsgRC(rc, ("hardware reset of BusLogic host adapter failed rc=%Rrc\n", rc));
    38773897
     
    39053925    sizeof(BUSLOGIC),
    39063926    /* pfnConstruct */
    3907     buslogicConstruct,
     3927    buslogicR3Construct,
    39083928    /* pfnDestruct */
    3909     buslogicDestruct,
     3929    buslogicR3Destruct,
    39103930    /* pfnRelocate */
    3911     buslogicRelocate,
     3931    buslogicR3Relocate,
    39123932    /* pfnIOCtl */
    39133933    NULL,
     
    39153935    NULL,
    39163936    /* pfnReset */
    3917     buslogicReset,
     3937    buslogicR3Reset,
    39183938    /* pfnSuspend */
    3919     buslogicSuspend,
     3939    buslogicR3Suspend,
    39203940    /* pfnResume */
    3921     buslogicResume,
     3941    buslogicR3Resume,
    39223942    /* pfnAttach */
    3923     buslogicAttach,
     3943    buslogicR3Attach,
    39243944    /* pfnDetach */
    3925     buslogicDetach,
     3945    buslogicR3Detach,
    39263946    /* pfnQueryInterface. */
    39273947    NULL,
     
    39293949    NULL,
    39303950    /* pfnPowerOff */
    3931     buslogicPowerOff,
     3951    buslogicR3PowerOff,
    39323952    /* pfnSoftReset */
    39333953    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