VirtualBox

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

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

Solaris.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.6 KB
Line 
1/* $Id: DrvHostBase.h 5212 2007-10-09 18:43:56Z 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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * 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 /** Whether or not enmTranslation is valid. */
100 bool fTranslationSet;
101 /** BIOS Geometry: Translation mode. */
102 PDMBIOSTRANSLATION enmTranslation;
103 /** BIOS Geometry: Cylinders. */
104 uint32_t cCylinders;
105 /** BIOS Geometry: Heads. */
106 uint32_t cHeads;
107 /** BIOS Geometry: Sectors. */
108 uint32_t cSectors;
109
110 /** The number of errors that could go into the release log. (flood gate) */
111 uint32_t cLogRelErrors;
112
113#ifdef RT_OS_DARWIN
114 /** The master port. */
115 mach_port_t MasterPort;
116 /** The MMC-2 Device Interface. (This is only used to get the scsi task interface.) */
117 MMCDeviceInterface **ppMMCDI;
118 /** The SCSI Task Device Interface. */
119 SCSITaskDeviceInterface **ppScsiTaskDI;
120 /** The block size. Set when querying the media size. */
121 uint32_t cbBlock;
122 /** The disk arbitration session reference. NULL if we didn't have to claim & unmount the device. */
123 DASessionRef pDASession;
124 /** The disk arbritation disk reference. NULL if we didn't have to claim & unmount the device. */
125 DADiskRef pDADisk;
126#endif
127
128#ifdef RT_OS_WINDOWS
129 /** Handle to the window we use to catch the device change broadcast messages. */
130 volatile HWND hwndDeviceChange;
131 /** The unit mask. */
132 DWORD fUnitMask;
133#endif
134
135
136 /**
137 * Performs the locking / unlocking of the device.
138 *
139 * This callback pointer should be set to NULL if the device doesn't support this action.
140 *
141 * @returns VBox status code.
142 * @param pThis Pointer to the instance data.
143 * @param fLock Set if locking, clear if unlocking.
144 */
145 DECLCALLBACKMEMBER(int, pfnDoLock)(PDRVHOSTBASE pThis, bool fLock);
146
147 /**
148 * Queries the media size.
149 * Can also be used to perform actions on media change.
150 *
151 * This callback pointer should be set to NULL if the default action is fine for this device.
152 *
153 * @returns VBox status code.
154 * @param pThis Pointer to the instance data.
155 * @param pcb Where to store the media size in bytes.
156 */
157 DECLCALLBACKMEMBER(int, pfnGetMediaSize)(PDRVHOSTBASE pThis, uint64_t *pcb);
158
159 /***
160 * Performs the polling operation.
161 *
162 * @returns VBox status code. (Failure means retry.)
163 * @param pThis Pointer to the instance data.
164 */
165 DECLCALLBACKMEMBER(int, pfnPoll)(PDRVHOSTBASE pThis);
166} DRVHOSTBASE;
167
168
169int DRVHostBaseInitData(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, PDMBLOCKTYPE enmType);
170int DRVHostBaseInitFinish(PDRVHOSTBASE pThis);
171int DRVHostBaseMediaPresent(PDRVHOSTBASE pThis);
172void DRVHostBaseMediaNotPresent(PDRVHOSTBASE pThis);
173DECLCALLBACK(void) DRVHostBaseDestruct(PPDMDRVINS pDrvIns);
174#ifdef RT_OS_DARWIN
175DECLCALLBACK(int) DRVHostBaseScsiCmd(PDRVHOSTBASE pThis, const uint8_t *pbCmd, size_t cbCmd, PDMBLOCKTXDIR enmTxDir,
176 void *pvBuf, size_t *pcbBuf, uint8_t *pbSense, size_t cbSense, uint32_t cTimeoutMillies);
177#endif
178
179
180/** Makes a PDRVHOSTBASE out of a PPDMIMOUNT. */
181#define PDMIMOUNT_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IMount)) )
182
183/** Makes a PDRVHOSTBASE out of a PPDMIBLOCK. */
184#define PDMIBLOCK_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IBlock)) )
185
186__END_DECLS
187
188#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