VirtualBox

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

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

HostDVD support for Darwin.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/** @file
2 *
3 * VBox storage devices:
4 * Host base drive access driver
5 */
6
7/*
8 * Copyright (C) 2006 InnoTek Systemberatung 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 /** Device name (MMHeap). */
52 char *pszDevice;
53 /** Device name to open (RTStrFree). */
54 char *pszDeviceOpen;
55 /** Uuid of the drive. */
56 RTUUID Uuid;
57
58 /** Pointer to the block port interface above us. */
59 PPDMIBLOCKPORT pDrvBlockPort;
60 /** Pointer to the mount notify interface above us. */
61 PPDMIMOUNTNOTIFY pDrvMountNotify;
62 /** Our block interface. */
63 PDMIBLOCK IBlock;
64 /** Our block interface. */
65 PDMIBLOCKBIOS IBlockBios;
66 /** Our mountable interface. */
67 PDMIMOUNT IMount;
68
69 /** Media present indicator. */
70 bool volatile fMediaPresent;
71 /** Locked indicator. */
72 bool fLocked;
73 /** The size of the media currently in the drive.
74 * This is invalid if no drive is in the drive. */
75 uint64_t volatile cbSize;
76#ifndef __DARWIN__
77 /** The filehandle of the device. */
78 RTFILE FileDevice;
79#endif
80
81 /** Handle of the poller thread. */
82 RTTHREAD ThreadPoller;
83#ifndef __WIN__
84 /** Event semaphore the thread will wait on. */
85 RTSEMEVENT EventPoller;
86#endif
87 /** The poller interval. */
88 unsigned cMilliesPoller;
89 /** The shutdown indicator. */
90 bool volatile fShutdownPoller;
91
92 /** Whether or not enmTranslation is valid. */
93 bool fTranslationSet;
94 /** BIOS Geometry: Translation mode. */
95 PDMBIOSTRANSLATION enmTranslation;
96 /** BIOS Geometry: Cylinders. */
97 uint32_t cCylinders;
98 /** BIOS Geometry: Heads. */
99 uint32_t cHeads;
100 /** BIOS Geometry: Sectors. */
101 uint32_t cSectors;
102
103 /** The number of errors that could go into the release log. (flood gate) */
104 uint32_t cLogRelErrors;
105
106#ifdef __DARWIN__
107 /** The master port. */
108 mach_port_t MasterPort;
109 /** The MMC-2 Device Interface. (This is only used to get the scsi task interface.) */
110 MMCDeviceInterface **ppMMCDI;
111 /** The SCSI Task Device Interface. */
112 SCSITaskDeviceInterface **ppScsiTaskDI;
113 /** The block size. Set when querying the media size. */
114 uint32_t cbBlock;
115#endif
116
117#ifdef __WIN__
118 /** Handle to the window we use to catch the device change broadcast messages. */
119 volatile HWND hwndDeviceChange;
120 /** The unit mask. */
121 DWORD fUnitMask;
122#endif
123
124
125 /**
126 * Performs the locking / unlocking of the device.
127 *
128 * This callback pointer should be set to NULL if the device doesn't support this action.
129 *
130 * @returns VBox status code.
131 * @param pThis Pointer to the instance data.
132 * @param fLock Set if locking, clear if unlocking.
133 */
134 DECLCALLBACKMEMBER(int, pfnDoLock)(PDRVHOSTBASE pThis, bool fLock);
135
136 /**
137 * Queries the media size.
138 * Can also be used to perform actions on media change.
139 *
140 * This callback pointer should be set to NULL if the default action is fine for this device.
141 *
142 * @returns VBox status code.
143 * @param pThis Pointer to the instance data.
144 * @param pcb Where to store the media size in bytes.
145 */
146 DECLCALLBACKMEMBER(int, pfnGetMediaSize)(PDRVHOSTBASE pThis, uint64_t *pcb);
147
148 /***
149 * Performs the polling operation.
150 *
151 * @returns VBox status code. (Failure means retry.)
152 * @param pThis Pointer to the instance data.
153 */
154 DECLCALLBACKMEMBER(int, pfnPoll)(PDRVHOSTBASE pThis);
155} DRVHOSTBASE;
156
157
158int DRVHostBaseInitData(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, PDMBLOCKTYPE enmType);
159int DRVHostBaseInitFinish(PDRVHOSTBASE pThis);
160int DRVHostBaseMediaPresent(PDRVHOSTBASE pThis);
161void DRVHostBaseMediaNotPresent(PDRVHOSTBASE pThis);
162DECLCALLBACK(void) DRVHostBaseDestruct(PPDMDRVINS pDrvIns);
163#ifdef __DARWIN__
164DECLCALLBACK(int) DRVHostBaseScsiCmd(PDRVHOSTBASE pThis, const uint8_t *pbCmd, size_t cbCmd, PDMBLOCKTXDIR enmTxDir,
165 void *pvBuf, size_t *pcbBuf, uint8_t *pbSense, size_t cbSense, uint32_t cTimeoutMillies);
166#endif
167
168
169/** Makes a PDRVHOSTBASE out of a PPDMIMOUNT. */
170#define PDMIMOUNT_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IMount)) )
171
172/** Makes a PDRVHOSTBASE out of a PPDMIBLOCK. */
173#define PDMIBLOCK_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IBlock)) )
174
175__END_DECLS
176
177#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