DrvHostFloppy.cpp revision ad77e3ec3cde24263bc7537575f5cae442bee3b1
/** @file
*
* VBox storage devices:
* Host floppy block driver
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DRV_HOST_FLOPPY
#ifdef RT_OS_LINUX
# include <errno.h>
# elif defined(RT_OS_WINDOWS)
# include <windows.h>
# include <dbt.h>
#else /* !RT_OS_WINDOWS nor RT_OS_LINUX nor RT_OS_L4 */
# error "Unsupported Platform."
#endif /* !RT_OS_WINDOWS nor RT_OS_LINUX nor RT_OS_L4 */
#include <iprt/semaphore.h>
#include <iprt/critsect.h>
#include "Builtins.h"
#include "DrvHostBase.h"
/**
* Floppy driver instance data.
*/
typedef struct DRVHOSTFLOPPY
{
/** Previous poll status. */
bool fPrevDiskIn;
#ifdef RT_OS_LINUX
/**
* Get media size and do change processing.
*
* @param pThis The instance data.
*/
{
if (rc)
{
return rc;
}
if (rc)
{
Log(("DrvHostFloppy: FDGETDRVSTAT ioctl(%s) failed, errno=%d rc=%Rrc\n", pThis->pszDevice, errno, rc));
return rc;
}
}
#endif /* RT_OS_LINUX */
#ifdef RT_OS_LINUX
/**
* This thread will periodically poll the Floppy for media presence.
*
* @returns Ignored.
* @param ThreadSelf Handle of this thread. Ignored.
* @param pvUser Pointer to the driver instance structure.
*/
{
if (rc)
return RTErrConvertFromErrno(errno);
if ( fDiskIn
&& !pThisFloppy->fPrevDiskIn)
{
if (pThis->fMediaPresent)
if (RT_FAILURE(rc))
{
return rc;
}
}
if ( !fDiskIn
&& pThis->fMediaPresent)
return VINF_SUCCESS;
}
#endif /* RT_OS_LINUX */
/**
* @copydoc FNPDMDRVCONSTRUCT
*/
static DECLCALLBACK(int) drvHostFloppyConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
{
/*
* Validate configuration.
*/
/*
* Init instance data.
*/
if (RT_SUCCESS(rc))
{
/*
* Override stuff.
*/
#ifdef RT_OS_LINUX
#endif
/*
* 2nd init part.
*/
}
if (RT_FAILURE(rc))
{
{
/* Suppressing the attach failure error must not affect the normal
* DRVHostBaseDestruct, so reset this flag below before leaving. */
rc = VINF_SUCCESS;
}
}
return rc;
}
/**
* Block driver registration record.
*/
const PDMDRVREG g_DrvHostFloppy =
{
/* u32Version */
/* szDriverName */
"HostFloppy",
/* szRCMod */
"",
/* szR0Mod */
"",
/* pszDescription */
"Host Floppy Block Driver.",
/* fFlags */
/* fClass. */
/* cMaxInstances */
~0,
/* cbInstance */
sizeof(DRVHOSTFLOPPY),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
NULL,
/* pfnIOCtl */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
NULL,
/* pfnSuspend */
NULL,
/* pfnResume */
NULL,
/* pfnAttach */
NULL,
/* pfnDetach */
NULL,
/* pfnPowerOff */
NULL,
/* pfnSoftReset */
NULL,
/* u32EndVersion */
};