VirtualBox

Changeset 43517 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 2, 2012 4:34:27 PM (12 years ago)
Author:
vboxsync
Message:

DrvSCSI: Connect some of the dots for removable media change (not yet complete).

File:
1 edited

Legend:

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

    r40282 r43517  
    7171    /** The optional block async port interface. */
    7272    PDMIBLOCKASYNCPORT      IPortAsync;
    73 #if 0 /* these interfaces aren't implemented */
    7473    /** The mount notify interface. */
    7574    PDMIMOUNTNOTIFY         IMountNotify;
    76 #endif
    7775    /** Fallback status LED state for this drive.
    7876     * This is used in case the device doesn't has a LED interface. */
     
    115113/** Converts a pointer to DRVSCSI::IPortAsync to a PDRVSCSI. */
    116114#define PDMIBLOCKASYNCPORT_2_DRVSCSI(pInterface) ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPortAsync)) )
     115/** Converts a pointer to DRVSCSI::IMountNotify to PDRVSCSI. */
     116#define PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface)    ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IMountNotify)) )
    117117/** Converts a pointer to DRVSCSI::IPort to a PDRVSCSI. */
    118118#define PDMIBLOCKPORT_2_DRVSCSI(pInterface)      ( (PDRVSCSI)((uintptr_t)pInterface - RT_OFFSETOF(DRVSCSI, IPort)) )
     
    636636    PDRVSCSI    pThis   = PDMINS_2_DATA(pDrvIns, PDRVSCSI);
    637637
     638    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNT, pThis->pDrvMount);
    638639    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
    639640    PDMIBASE_RETURN_INTERFACE(pszIID, PDMISCSICONNECTOR, &pThis->ISCSIConnector);
    640641    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKPORT, &pThis->IPort);
     642    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNTNOTIFY, &pThis->IMountNotify);
    641643    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKASYNCPORT, &pThis->IPortAsync);
    642644    return NULL;
     
    650652    return pThis->pDevScsiPort->pfnQueryDeviceLocation(pThis->pDevScsiPort, ppcszController,
    651653                                                       piInstance, piLUN);
     654}
     655
     656/**
     657 * Called when media is mounted.
     658 *
     659 * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     660 */
     661static DECLCALLBACK(void) drvscsiMountNotify(PPDMIMOUNTNOTIFY pInterface)
     662{
     663    PDRVSCSI pThis = PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface);
     664    LogFlowFunc(("mounting LUN#%p\n", pThis->hVScsiLun));
     665
     666    /* Ignore the call if we're called while being attached. */
     667    if (!pThis->pDrvBlock)
     668        return;
     669
     670    //@todo: Notify of media change? Update media size?
     671}
     672
     673/**
     674 * Called when media is unmounted
     675 * 
     676 * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     677 */
     678static DECLCALLBACK(void) drvscsiUnmountNotify(PPDMIMOUNTNOTIFY pInterface)
     679{
     680    PDRVSCSI pThis = PDMIMOUNTNOTIFY_2_DRVSCSI(pInterface);
     681    LogFlowFunc(("unmounting LUN#%p\n", pThis->hVScsiLun));
     682
     683    //@todo: Notify of media change? Report that no media is present?
    652684}
    653685
     
    832864    pDrvIns->IBase.pfnQueryInterface            = drvscsiQueryInterface;
    833865
     866    pThis->IMountNotify.pfnMountNotify          = drvscsiMountNotify;
     867    pThis->IMountNotify.pfnUnmountNotify        = drvscsiUnmountNotify;
    834868    pThis->IPort.pfnQueryDeviceLocation         = drvscsiQueryDeviceLocation;
    835869    pThis->IPortAsync.pfnTransferCompleteNotify = drvscsiTransferCompleteNotify;
     
    897931
    898932    PDMBLOCKTYPE enmType = pThis->pDrvBlock->pfnGetType(pThis->pDrvBlock);
    899     if (enmType != PDMBLOCKTYPE_HARD_DISK)
     933    VSCSILUNTYPE enmLunType;
     934    switch (enmType)
     935    {
     936    case PDMBLOCKTYPE_HARD_DISK:
     937        enmLunType = VSCSILUNTYPE_SBC;
     938        break;
     939    case PDMBLOCKTYPE_CDROM:
     940    case PDMBLOCKTYPE_DVD:
     941        enmLunType = VSCSILUNTYPE_MMC;
     942        break;
     943    default:
    900944        return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_UNSUPPORTED_BLOCK_TYPE, RT_SRC_POS,
    901                                    N_("Only hard disks are currently supported as SCSI devices (enmType=%d)"),
     945                                   N_("Only hard disks and CD/DVD-ROMs are currently supported as SCSI devices (enmType=%d)"),
    902946                                   enmType);
     947    }
     948    if (    (   enmType == PDMBLOCKTYPE_DVD
     949             || enmType == PDMBLOCKTYPE_CDROM)
     950        &&  !pThis->pDrvMount)
     951    {
     952        AssertMsgFailed(("Internal error: cdrom without a mountable interface\n"));
     953        return VERR_INTERNAL_ERROR;
     954    }
    903955
    904956    /* Create VSCSI device and LUN. */
     
    909961    rc = VSCSIDeviceCreate(&pThis->hVScsiDevice, drvscsiVScsiReqCompleted, pThis);
    910962    AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create VSCSI device rc=%Rrc\n"), rc);
    911     rc = VSCSILunCreate(&pThis->hVScsiLun, VSCSILUNTYPE_SBC, &pThis->VScsiIoCallbacks,
     963    rc = VSCSILunCreate(&pThis->hVScsiLun, enmLunType, &pThis->VScsiIoCallbacks,
    912964                        pThis);
    913965    AssertMsgReturn(RT_SUCCESS(rc), ("Failed to create VSCSI LUN rc=%Rrc\n"), rc);
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