VirtualBox

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

Last change on this file since 6484 was 6291, checked in by vboxsync, 17 years ago

Big virtual disk changeset containing several modifications

  • remove the always buggy translation setting and replace it with two sets of geometries, physical and logical
  • complete vmdk creation (fixed/dynamic variants, both split in 2G chunks and single file)
  • implemented VBoxHDD-new generic snapshot support, i.e. diff image creation and image merging (completely untested, I'm pretty sure there are bugs)
  • assorted changes which generalize the VBoxHDD-new interfaces (both externally and internally)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 KB
Line 
1/* $Id: DrvHostBase.h 6291 2008-01-09 10:57:05Z vboxsync $ */
2/** @file
3 * DrvHostBase - Host base drive access driver.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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
23__BEGIN_DECLS
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 */
31typedef struct DRVHOSTBASE
32{
33 /** Critical section used to serialize access to the handle and other
34 * members of this struct. */
35 RTCRITSECT CritSect;
36 /** Pointer driver instance. */
37 PPDMDRVINS pDrvIns;
38 /** Drive type. */
39 PDMBLOCKTYPE enmType;
40 /** Visible to the BIOS. */
41 bool fBiosVisible;
42 /** The configuration readonly value. */
43 bool fReadOnlyConfig;
44 /** The current readonly status. */
45 bool fReadOnly;
46 /** Flag whether failure to attach is an error or not. */
47 bool fAttachFailError;
48 /** Flag whether to keep instance working (as unmounted though). */
49 bool fKeepInstance;
50 /** Device name (MMHeap). */
51 char *pszDevice;
52 /** Device name to open (RTStrFree). */
53 char *pszDeviceOpen;
54#ifdef RT_OS_SOLARIS
55 /** Device name of raw device (RTStrFree). */
56 char *pszRawDeviceOpen;
57#endif
58 /** Uuid of the drive. */
59 RTUUID Uuid;
60
61 /** Pointer to the block port interface above us. */
62 PPDMIBLOCKPORT pDrvBlockPort;
63 /** Pointer to the mount notify interface above us. */
64 PPDMIMOUNTNOTIFY pDrvMountNotify;
65 /** Our block interface. */
66 PDMIBLOCK IBlock;
67 /** Our block interface. */
68 PDMIBLOCKBIOS IBlockBios;
69 /** Our mountable interface. */
70 PDMIMOUNT IMount;
71
72 /** Media present indicator. */
73 bool volatile fMediaPresent;
74 /** Locked indicator. */
75 bool fLocked;
76 /** The size of the media currently in the drive.
77 * This is invalid if no drive is in the drive. */
78 uint64_t volatile cbSize;
79#ifndef RT_OS_DARWIN
80 /** The filehandle of the device. */
81 RTFILE FileDevice;
82#endif
83#ifdef RT_OS_SOLARIS
84 /** The raw filehandle of the device. */
85 RTFILE FileRawDevice;
86#endif
87
88 /** Handle of the poller thread. */
89 RTTHREAD ThreadPoller;
90#ifndef RT_OS_WINDOWS
91 /** Event semaphore the thread will wait on. */
92 RTSEMEVENT EventPoller;
93#endif
94 /** The poller interval. */
95 unsigned cMilliesPoller;
96 /** The shutdown indicator. */
97 bool volatile fShutdownPoller;
98
99 /** BIOS PCHS geometry. */
100 PDMMEDIAGEOMETRY PCHSGeometry;
101 /** BIOS LCHS geometry. */
102 PDMMEDIAGEOMETRY LCHSGeometry;
103
104 /** The number of errors that could go into the release log. (flood gate) */
105 uint32_t cLogRelErrors;
106
107#ifdef RT_OS_DARWIN
108 /** The master port. */
109 mach_port_t MasterPort;
110 /** The MMC-2 Device Interface. (This is only used to get the scsi task interface.) */
111 MMCDeviceInterface **ppMMCDI;
112 /** The SCSI Task Device Interface. */
113 SCSITaskDeviceInterface **ppScsiTaskDI;
114 /** The block size. Set when querying the media size. */
115 uint32_t cbBlock;
116 /** The disk arbitration session reference. NULL if we didn't have to claim & unmount the device. */
117 DASessionRef pDASession;
118 /** The disk arbritation disk reference. NULL if we didn't have to claim & unmount the device. */
119 DADiskRef pDADisk;
120#endif
121
122#ifdef RT_OS_WINDOWS
123 /** Handle to the window we use to catch the device change broadcast messages. */
124 volatile HWND hwndDeviceChange;
125 /** The unit mask. */
126 DWORD fUnitMask;
127#endif
128
129
130 /**
131 * Performs the locking / unlocking of the device.
132 *
133 * This callback pointer should be set to NULL if the device doesn't support this action.
134 *
135 * @returns VBox status code.
136 * @param pThis Pointer to the instance data.
137 * @param fLock Set if locking, clear if unlocking.
138 */
139 DECLCALLBACKMEMBER(int, pfnDoLock)(PDRVHOSTBASE pThis, bool fLock);
140
141 /**
142 * Queries the media size.
143 * Can also be used to perform actions on media change.
144 *
145 * This callback pointer should be set to NULL if the default action is fine for this device.
146 *
147 * @returns VBox status code.
148 * @param pThis Pointer to the instance data.
149 * @param pcb Where to store the media size in bytes.
150 */
151 DECLCALLBACKMEMBER(int, pfnGetMediaSize)(PDRVHOSTBASE pThis, uint64_t *pcb);
152
153 /***
154 * Performs the polling operation.
155 *
156 * @returns VBox status code. (Failure means retry.)
157 * @param pThis Pointer to the instance data.
158 */
159 DECLCALLBACKMEMBER(int, pfnPoll)(PDRVHOSTBASE pThis);
160} DRVHOSTBASE;
161
162
163int DRVHostBaseInitData(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, PDMBLOCKTYPE enmType);
164int DRVHostBaseInitFinish(PDRVHOSTBASE pThis);
165int DRVHostBaseMediaPresent(PDRVHOSTBASE pThis);
166void DRVHostBaseMediaNotPresent(PDRVHOSTBASE pThis);
167DECLCALLBACK(void) DRVHostBaseDestruct(PPDMDRVINS pDrvIns);
168#ifdef RT_OS_DARWIN
169DECLCALLBACK(int) DRVHostBaseScsiCmd(PDRVHOSTBASE pThis, const uint8_t *pbCmd, size_t cbCmd, PDMBLOCKTXDIR enmTxDir,
170 void *pvBuf, size_t *pcbBuf, uint8_t *pbSense, size_t cbSense, uint32_t cTimeoutMillies);
171#endif
172
173
174/** Makes a PDRVHOSTBASE out of a PPDMIMOUNT. */
175#define PDMIMOUNT_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IMount)) )
176
177/** Makes a PDRVHOSTBASE out of a PPDMIBLOCK. */
178#define PDMIBLOCK_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IBlock)) )
179
180__END_DECLS
181
182#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