DrvHostBase.h revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
* DrvHostBase - Host base drive access driver.
*/
/*
* Copyright (C) 2006-2007 Oracle Corporation
*
* 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.
*/
#ifndef __HostDrvBase_h__
#define __HostDrvBase_h__
/** Pointer to host base drive access driver instance data. */
typedef struct DRVHOSTBASE *PDRVHOSTBASE;
/**
* Host base drive access driver instance data.
*
* @implements PDMIMOUNT
* @implements PDMIBLOCKBIOS
* @implements PDMIBLOCK
*/
typedef struct DRVHOSTBASE
{
/** Critical section used to serialize access to the handle and other
* members of this struct. */
/** Pointer driver instance. */
/** Drive type. */
/** Visible to the BIOS. */
bool fBiosVisible;
/** The configuration readonly value. */
bool fReadOnlyConfig;
/** The current readonly status. */
bool fReadOnly;
/** Flag whether failure to attach is an error or not. */
bool fAttachFailError;
/** Flag whether to keep instance working (as unmounted though). */
bool fKeepInstance;
/** Device name (MMHeap). */
char *pszDevice;
/** Device name to open (RTStrFree). */
char *pszDeviceOpen;
#ifdef RT_OS_SOLARIS
/** Device name of raw device (RTStrFree). */
char *pszRawDeviceOpen;
#endif
/** Uuid of the drive. */
/** Pointer to the block port interface above us. */
/** Pointer to the mount notify interface above us. */
/** Our block interface. */
/** Our block interface. */
/** Our mountable interface. */
/** Media present indicator. */
bool volatile fMediaPresent;
/** Locked indicator. */
bool fLocked;
/** The size of the media currently in the drive.
* This is invalid if no drive is in the drive. */
#if !defined(RT_OS_DARWIN)
/** The filehandle of the device. */
#endif
#ifdef RT_OS_SOLARIS
/** The raw filehandle of the device. */
#endif
/** Handle of the poller thread. */
#ifndef RT_OS_WINDOWS
/** Event semaphore the thread will wait on. */
#endif
/** The poller interval. */
/** The shutdown indicator. */
bool volatile fShutdownPoller;
/** BIOS PCHS geometry. */
/** BIOS LCHS geometry. */
/** The number of errors that could go into the release log. (flood gate) */
#ifdef RT_OS_DARWIN
/** The master port. */
/** The MMC-2 Device Interface. (This is only used to get the scsi task interface.) */
/** The SCSI Task Device Interface. */
/** The block size. Set when querying the media size. */
/** The disk arbitration session reference. NULL if we didn't have to claim & unmount the device. */
/** The disk arbritation disk reference. NULL if we didn't have to claim & unmount the device. */
#endif
#ifdef RT_OS_WINDOWS
/** Handle to the window we use to catch the device change broadcast messages. */
volatile HWND hwndDeviceChange;
/** The unit mask. */
#endif
#ifdef RT_OS_LINUX
/** Double buffer required for ioctl with the Linux kernel as long as we use
* remap_pfn_range() instead of vm_insert_page(). */
#endif
#ifdef RT_OS_FREEBSD
/** The block size. Set when querying the media size. */
/** SCSI bus number. */
/** target ID of the passthrough device. */
/** LUN of the passthrough device. */
#endif
/**
* Performs the locking / unlocking of the device.
*
* This callback pointer should be set to NULL if the device doesn't support this action.
*
* @returns VBox status code.
* @param pThis Pointer to the instance data.
* @param fLock Set if locking, clear if unlocking.
*/
/**
* Queries the media size.
* Can also be used to perform actions on media change.
*
* This callback pointer should be set to NULL if the default action is fine for this device.
*
* @returns VBox status code.
* @param pThis Pointer to the instance data.
* @param pcb Where to store the media size in bytes.
*/
/***
* Performs the polling operation.
*
* @returns VBox status code. (Failure means retry.)
* @param pThis Pointer to the instance data.
*/
} DRVHOSTBASE;
#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
DECLCALLBACK(int) DRVHostBaseScsiCmd(PDRVHOSTBASE pThis, const uint8_t *pbCmd, size_t cbCmd, PDMBLOCKTXDIR enmTxDir,
#endif
/** Makes a PDRVHOSTBASE out of a PPDMIMOUNT. */
#define PDMIMOUNT_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IMount)) )
/** Makes a PDRVHOSTBASE out of a PPDMIBLOCK. */
#define PDMIBLOCK_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IBlock)) )
#endif