VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/DrvHostBase.h@ 61497

Last change on this file since 61497 was 59250, checked in by vboxsync, 9 years ago

Build fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1/* $Id: DrvHostBase.h 59250 2016-01-04 14:24:32Z vboxsync $ */
2/** @file
3 * DrvHostBase - Host base drive access driver.
4 */
5
6/*
7 * Copyright (C) 2006-2015 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef __HostDrvBase_h__
19#define __HostDrvBase_h__
20
21#include <VBox/cdefs.h>
22
23RT_C_DECLS_BEGIN
24
25
26/** Pointer to host base drive access driver instance data. */
27typedef struct DRVHOSTBASE *PDRVHOSTBASE;
28/**
29 * Host base drive access driver instance data.
30 *
31 * @implements PDMIMOUNT
32 * @implements PDMIBLOCKBIOS
33 * @implements PDMIBLOCK
34 */
35typedef struct DRVHOSTBASE
36{
37 /** Critical section used to serialize access to the handle and other
38 * members of this struct. */
39 RTCRITSECT CritSect;
40 /** Pointer driver instance. */
41 PPDMDRVINS pDrvIns;
42 /** Drive type. */
43 PDMMEDIATYPE enmType;
44 /** Visible to the BIOS. */
45 bool fBiosVisible;
46 /** The configuration readonly value. */
47 bool fReadOnlyConfig;
48 /** The current readonly status. */
49 bool fReadOnly;
50 /** Flag whether failure to attach is an error or not. */
51 bool fAttachFailError;
52 /** Flag whether to keep instance working (as unmounted though). */
53 bool fKeepInstance;
54 /** Device name (MMHeap). */
55 char *pszDevice;
56 /** Device name to open (RTStrFree). */
57 char *pszDeviceOpen;
58#ifdef RT_OS_SOLARIS
59 /** Device name of raw device (RTStrFree). */
60 char *pszRawDeviceOpen;
61#endif
62 /** Uuid of the drive. */
63 RTUUID Uuid;
64
65 /** Pointer to the block port interface above us. */
66 PPDMIMEDIAPORT pDrvMediaPort;
67 /** Pointer to the mount notify interface above us. */
68 PPDMIMOUNTNOTIFY pDrvMountNotify;
69 /** Our media interface. */
70 PDMIMEDIA IMedia;
71 /** Our mountable interface. */
72 PDMIMOUNT IMount;
73
74 /** Media present indicator. */
75 bool volatile fMediaPresent;
76 /** Locked indicator. */
77 bool fLocked;
78 /** The size of the media currently in the drive.
79 * This is invalid if no drive is in the drive. */
80 uint64_t volatile cbSize;
81#if !defined(RT_OS_DARWIN)
82 /** The filehandle of the device. */
83 RTFILE hFileDevice;
84#endif
85#ifdef RT_OS_SOLARIS
86 /** The raw filehandle of the device. */
87 RTFILE hFileRawDevice;
88#endif
89
90 /** Handle of the poller thread. */
91 RTTHREAD ThreadPoller;
92#ifndef RT_OS_WINDOWS
93 /** Event semaphore the thread will wait on. */
94 RTSEMEVENT EventPoller;
95#endif
96 /** The poller interval. */
97 RTMSINTERVAL cMilliesPoller;
98 /** The shutdown indicator. */
99 bool volatile fShutdownPoller;
100
101 /** BIOS PCHS geometry. */
102 PDMMEDIAGEOMETRY PCHSGeometry;
103 /** BIOS LCHS geometry. */
104 PDMMEDIAGEOMETRY LCHSGeometry;
105
106 /** The number of errors that could go into the release log. (flood gate) */
107 uint32_t cLogRelErrors;
108
109#ifdef RT_OS_DARWIN
110 /** The master port. */
111 mach_port_t MasterPort;
112 /** The MMC-2 Device Interface. (This is only used to get the scsi task interface.) */
113 MMCDeviceInterface **ppMMCDI;
114 /** The SCSI Task Device Interface. */
115 SCSITaskDeviceInterface **ppScsiTaskDI;
116 /** The block size. Set when querying the media size. */
117 uint32_t cbBlock;
118 /** The disk arbitration session reference. NULL if we didn't have to claim & unmount the device. */
119 DASessionRef pDASession;
120 /** The disk arbitration disk reference. NULL if we didn't have to claim & unmount the device. */
121 DADiskRef pDADisk;
122#endif
123
124#ifdef RT_OS_WINDOWS
125 /** Handle to the window we use to catch the device change broadcast messages. */
126 volatile HWND hwndDeviceChange;
127 /** The unit mask. */
128 DWORD fUnitMask;
129#endif
130
131#ifdef RT_OS_LINUX
132 /** Double buffer required for ioctl with the Linux kernel as long as we use
133 * remap_pfn_range() instead of vm_insert_page(). */
134 uint8_t *pbDoubleBuffer;
135#endif
136
137#ifdef RT_OS_FREEBSD
138 /** The block size. Set when querying the media size. */
139 uint32_t cbBlock;
140 /** SCSI bus number. */
141 path_id_t ScsiBus;
142 /** target ID of the passthrough device. */
143 target_id_t ScsiTargetID;
144 /** LUN of the passthrough device. */
145 lun_id_t ScsiLunID;
146#endif
147
148 /**
149 * Performs the locking / unlocking of the device.
150 *
151 * This callback pointer should be set to NULL if the device doesn't support this action.
152 *
153 * @returns VBox status code.
154 * @param pThis Pointer to the instance data.
155 * @param fLock Set if locking, clear if unlocking.
156 */
157 DECLCALLBACKMEMBER(int, pfnDoLock)(PDRVHOSTBASE pThis, bool fLock);
158
159 /**
160 * Queries the media size.
161 * Can also be used to perform actions on media change.
162 *
163 * This callback pointer should be set to NULL if the default action is fine for this device.
164 *
165 * @returns VBox status code.
166 * @param pThis Pointer to the instance data.
167 * @param pcb Where to store the media size in bytes.
168 */
169 DECLCALLBACKMEMBER(int, pfnGetMediaSize)(PDRVHOSTBASE pThis, uint64_t *pcb);
170
171 /***
172 * Performs the polling operation.
173 *
174 * @returns VBox status code. (Failure means retry.)
175 * @param pThis Pointer to the instance data.
176 */
177 DECLCALLBACKMEMBER(int, pfnPoll)(PDRVHOSTBASE pThis);
178} DRVHOSTBASE;
179
180
181int DRVHostBaseInitData(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, PDMMEDIATYPE enmType);
182int DRVHostBaseInitFinish(PDRVHOSTBASE pThis);
183int DRVHostBaseMediaPresent(PDRVHOSTBASE pThis);
184void DRVHostBaseMediaNotPresent(PDRVHOSTBASE pThis);
185DECLCALLBACK(void) DRVHostBaseDestruct(PPDMDRVINS pDrvIns);
186#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
187DECLCALLBACK(int) DRVHostBaseScsiCmd(PDRVHOSTBASE pThis, const uint8_t *pbCmd, size_t cbCmd, PDMMEDIATXDIR enmTxDir,
188 void *pvBuf, uint32_t *pcbBuf, uint8_t *pbSense, size_t cbSense, uint32_t cTimeoutMillies);
189#endif
190
191
192/** Makes a PDRVHOSTBASE out of a PPDMIMOUNT. */
193#define PDMIMOUNT_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IMount)) )
194
195/** Makes a PDRVHOSTBASE out of a PPDMIMEDIA. */
196#define PDMIMEDIA_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IMedia)) )
197
198RT_C_DECLS_END
199
200#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette