VirtualBox

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

Last change on this file since 3477 was 3113, checked in by vboxsync, 18 years ago

Implement virtual paperclip (forced unmounting of media, currently
unused) and non-fatal error when media is not available on powerup.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.6 KB
Line 
1/** @file
2 *
3 * VBox storage devices:
4 * Host base drive access driver
5 */
6
7/*
8 * Copyright (C) 2006-2007 innotek GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * If you received this file as part of a commercial VirtualBox
19 * distribution, then only the terms of your commercial VirtualBox
20 * license agreement apply instead of the previous paragraph.
21 */
22
23#ifndef __HostDrvBase_h__
24#define __HostDrvBase_h__
25
26#include <VBox/cdefs.h>
27
28__BEGIN_DECLS
29
30
31/** Pointer to host base drive access driver instance data. */
32typedef struct DRVHOSTBASE *PDRVHOSTBASE;
33/**
34 * Host base drive access driver instance data.
35 */
36typedef struct DRVHOSTBASE
37{
38 /** Critical section used to serialize access to the handle and other
39 * members of this struct. */
40 RTCRITSECT CritSect;
41 /** Pointer driver instance. */
42 PPDMDRVINS pDrvIns;
43 /** Drive type. */
44 PDMBLOCKTYPE enmType;
45 /** Visible to the BIOS. */
46 bool fBiosVisible;
47 /** The configuration readonly value. */
48 bool fReadOnlyConfig;
49 /** The current readonly status. */
50 bool fReadOnly;
51 /** Flag whether failure to attach is an error or not. */
52 bool fAttachFailError;
53 /** Flag whether to keep instance working (as unmounted though). */
54 bool fKeepInstance;
55 /** Device name (MMHeap). */
56 char *pszDevice;
57 /** Device name to open (RTStrFree). */
58 char *pszDeviceOpen;
59 /** Uuid of the drive. */
60 RTUUID Uuid;
61
62 /** Pointer to the block port interface above us. */
63 PPDMIBLOCKPORT pDrvBlockPort;
64 /** Pointer to the mount notify interface above us. */
65 PPDMIMOUNTNOTIFY pDrvMountNotify;
66 /** Our block interface. */
67 PDMIBLOCK IBlock;
68 /** Our block interface. */
69 PDMIBLOCKBIOS IBlockBios;
70 /** Our mountable interface. */
71 PDMIMOUNT IMount;
72
73 /** Media present indicator. */
74 bool volatile fMediaPresent;
75 /** Locked indicator. */
76 bool fLocked;
77 /** The size of the media currently in the drive.
78 * This is invalid if no drive is in the drive. */
79 uint64_t volatile cbSize;
80#ifndef __DARWIN__
81 /** The filehandle of the device. */
82 RTFILE FileDevice;
83#endif
84
85 /** Handle of the poller thread. */
86 RTTHREAD ThreadPoller;
87#ifndef __WIN__
88 /** Event semaphore the thread will wait on. */
89 RTSEMEVENT EventPoller;
90#endif
91 /** The poller interval. */
92 unsigned cMilliesPoller;
93 /** The shutdown indicator. */
94 bool volatile fShutdownPoller;
95
96 /** Whether or not enmTranslation is valid. */
97 bool fTranslationSet;
98 /** BIOS Geometry: Translation mode. */
99 PDMBIOSTRANSLATION enmTranslation;
100 /** BIOS Geometry: Cylinders. */
101 uint32_t cCylinders;
102 /** BIOS Geometry: Heads. */
103 uint32_t cHeads;
104 /** BIOS Geometry: Sectors. */
105 uint32_t cSectors;
106
107 /** The number of errors that could go into the release log. (flood gate) */
108 uint32_t cLogRelErrors;
109
110#ifdef __DARWIN__
111 /** The master port. */
112 mach_port_t MasterPort;
113 /** The MMC-2 Device Interface. (This is only used to get the scsi task interface.) */
114 MMCDeviceInterface **ppMMCDI;
115 /** The SCSI Task Device Interface. */
116 SCSITaskDeviceInterface **ppScsiTaskDI;
117 /** The block size. Set when querying the media size. */
118 uint32_t cbBlock;
119 /** The disk arbitration session reference. NULL if we didn't have to claim & unmount the device. */
120 DASessionRef pDASession;
121 /** The disk arbritation disk reference. NULL if we didn't have to claim & unmount the device. */
122 DADiskRef pDADisk;
123#endif
124
125#ifdef __WIN__
126 /** Handle to the window we use to catch the device change broadcast messages. */
127 volatile HWND hwndDeviceChange;
128 /** The unit mask. */
129 DWORD fUnitMask;
130#endif
131
132
133 /**
134 * Performs the locking / unlocking of the device.
135 *
136 * This callback pointer should be set to NULL if the device doesn't support this action.
137 *
138 * @returns VBox status code.
139 * @param pThis Pointer to the instance data.
140 * @param fLock Set if locking, clear if unlocking.
141 */
142 DECLCALLBACKMEMBER(int, pfnDoLock)(PDRVHOSTBASE pThis, bool fLock);
143
144 /**
145 * Queries the media size.
146 * Can also be used to perform actions on media change.
147 *
148 * This callback pointer should be set to NULL if the default action is fine for this device.
149 *
150 * @returns VBox status code.
151 * @param pThis Pointer to the instance data.
152 * @param pcb Where to store the media size in bytes.
153 */
154 DECLCALLBACKMEMBER(int, pfnGetMediaSize)(PDRVHOSTBASE pThis, uint64_t *pcb);
155
156 /***
157 * Performs the polling operation.
158 *
159 * @returns VBox status code. (Failure means retry.)
160 * @param pThis Pointer to the instance data.
161 */
162 DECLCALLBACKMEMBER(int, pfnPoll)(PDRVHOSTBASE pThis);
163} DRVHOSTBASE;
164
165
166int DRVHostBaseInitData(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, PDMBLOCKTYPE enmType);
167int DRVHostBaseInitFinish(PDRVHOSTBASE pThis);
168int DRVHostBaseMediaPresent(PDRVHOSTBASE pThis);
169void DRVHostBaseMediaNotPresent(PDRVHOSTBASE pThis);
170DECLCALLBACK(void) DRVHostBaseDestruct(PPDMDRVINS pDrvIns);
171#ifdef __DARWIN__
172DECLCALLBACK(int) DRVHostBaseScsiCmd(PDRVHOSTBASE pThis, const uint8_t *pbCmd, size_t cbCmd, PDMBLOCKTXDIR enmTxDir,
173 void *pvBuf, size_t *pcbBuf, uint8_t *pbSense, size_t cbSense, uint32_t cTimeoutMillies);
174#endif
175
176
177/** Makes a PDRVHOSTBASE out of a PPDMIMOUNT. */
178#define PDMIMOUNT_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IMount)) )
179
180/** Makes a PDRVHOSTBASE out of a PPDMIBLOCK. */
181#define PDMIBLOCK_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IBlock)) )
182
183__END_DECLS
184
185#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