VirtualBox

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

Last change on this file since 546 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 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 /** The filehandle of the device. */
77 RTFILE FileDevice;
78
79 /** Handle of the poller thread. */
80 RTTHREAD ThreadPoller;
81#ifndef __WIN__
82 /** Event semaphore the thread will wait on. */
83 RTSEMEVENT EventPoller;
84#endif
85 /** The poller interval. */
86 unsigned cMilliesPoller;
87 /** The shutdown indicator. */
88 bool volatile fShutdownPoller;
89
90 /** Whether or not enmTranslation is valid. */
91 bool fTranslationSet;
92 /** BIOS Geometry: Translation mode. */
93 PDMBIOSTRANSLATION enmTranslation;
94 /** BIOS Geometry: Cylinders. */
95 uint32_t cCylinders;
96 /** BIOS Geometry: Heads. */
97 uint32_t cHeads;
98 /** BIOS Geometry: Sectors. */
99 uint32_t cSectors;
100
101#ifdef __WIN__
102 /** Handle to the window we use to catch the device change broadcast messages. */
103 volatile HWND hwndDeviceChange;
104 /** The unit mask. */
105 DWORD fUnitMask;
106#endif
107
108
109 /**
110 * Performs the locking / unlocking of the device.
111 *
112 * This callback pointer should be set to NULL if the device doesn't support this action.
113 *
114 * @returns VBox status code.
115 * @param pThis Pointer to the instance data.
116 * @param fLock Set if locking, clear if unlocking.
117 */
118 DECLCALLBACKMEMBER(int, pfnDoLock)(PDRVHOSTBASE pThis, bool fLock);
119
120 /**
121 * Queries the media size.
122 * Can also be used to perform actions on media change.
123 *
124 * This callback pointer should be set to NULL if the default action is fine for this device.
125 *
126 * @returns VBox status code.
127 * @param pThis Pointer to the instance data.
128 * @param pcb Where to store the media size in bytes.
129 */
130 DECLCALLBACKMEMBER(int, pfnGetMediaSize)(PDRVHOSTBASE pThis, uint64_t *pcb);
131
132 /***
133 * Performs the polling operation.
134 *
135 * @returns VBox status code. (Failure means retry.)
136 * @param pThis Pointer to the instance data.
137 */
138 DECLCALLBACKMEMBER(int, pfnPoll)(PDRVHOSTBASE pThis);
139} DRVHOSTBASE;
140
141
142int DRVHostBaseInitData(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, PDMBLOCKTYPE enmType);
143int DRVHostBaseInitFinish(PDRVHOSTBASE pThis);
144int DRVHostBaseMediaPresent(PDRVHOSTBASE pThis);
145void DRVHostBaseMediaNotPresent(PDRVHOSTBASE pThis);
146DECLCALLBACK(void) DRVHostBaseDestruct(PPDMDRVINS pDrvIns);
147
148
149/** Makes a PDRVHOSTBASE out of a PPDMIMOUNT. */
150#define PDMIMOUNT_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IMount)) )
151
152/** Makes a PDRVHOSTBASE out of a PPDMIBLOCK. */
153#define PDMIBLOCK_2_DRVHOSTBASE(pInterface) ( (PDRVHOSTBASE)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTBASE, IBlock)) )
154
155__END_DECLS
156
157#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