1 | /** @file
|
---|
2 | * PDM - Pluggable Device Manager, Storage related interfaces.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2019 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef VBOX_INCLUDED_vmm_pdmstorageifs_h
|
---|
27 | #define VBOX_INCLUDED_vmm_pdmstorageifs_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include <iprt/sg.h>
|
---|
33 | #include <VBox/types.h>
|
---|
34 | #include <VBox/vdmedia.h>
|
---|
35 |
|
---|
36 | RT_C_DECLS_BEGIN
|
---|
37 |
|
---|
38 | struct PDMISECKEY;
|
---|
39 | struct PDMISECKEYHLP;
|
---|
40 |
|
---|
41 |
|
---|
42 | /** @defgroup grp_pdm_ifs_storage PDM Storage Interfaces
|
---|
43 | * @ingroup grp_pdm_interfaces
|
---|
44 | * @{
|
---|
45 | */
|
---|
46 |
|
---|
47 |
|
---|
48 | /** Pointer to a mount interface. */
|
---|
49 | typedef struct PDMIMOUNTNOTIFY *PPDMIMOUNTNOTIFY;
|
---|
50 | /**
|
---|
51 | * Block interface (up).
|
---|
52 | * Pair with PDMIMOUNT.
|
---|
53 | */
|
---|
54 | typedef struct PDMIMOUNTNOTIFY
|
---|
55 | {
|
---|
56 | /**
|
---|
57 | * Called when a media is mounted.
|
---|
58 | *
|
---|
59 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
60 | * @thread The emulation thread.
|
---|
61 | */
|
---|
62 | DECLR3CALLBACKMEMBER(void, pfnMountNotify,(PPDMIMOUNTNOTIFY pInterface));
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Called when a media is unmounted
|
---|
66 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
67 | * @thread The emulation thread.
|
---|
68 | */
|
---|
69 | DECLR3CALLBACKMEMBER(void, pfnUnmountNotify,(PPDMIMOUNTNOTIFY pInterface));
|
---|
70 | } PDMIMOUNTNOTIFY;
|
---|
71 | /** PDMIMOUNTNOTIFY interface ID. */
|
---|
72 | #define PDMIMOUNTNOTIFY_IID "fa143ac9-9fc6-498e-997f-945380a558f9"
|
---|
73 |
|
---|
74 |
|
---|
75 | /** Pointer to mount interface. */
|
---|
76 | typedef struct PDMIMOUNT *PPDMIMOUNT;
|
---|
77 | /**
|
---|
78 | * Mount interface (down).
|
---|
79 | * Pair with PDMIMOUNTNOTIFY.
|
---|
80 | */
|
---|
81 | typedef struct PDMIMOUNT
|
---|
82 | {
|
---|
83 | /**
|
---|
84 | * Unmount the media.
|
---|
85 | *
|
---|
86 | * The driver will validate and pass it on. On the rebounce it will decide whether or not to detach it self.
|
---|
87 | *
|
---|
88 | * @returns VBox status code.
|
---|
89 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
90 | * @thread The emulation thread.
|
---|
91 | * @param fForce Force the unmount, even for locked media.
|
---|
92 | * @param fEject Eject the medium. Only relevant for host drives.
|
---|
93 | * @thread The emulation thread.
|
---|
94 | */
|
---|
95 | DECLR3CALLBACKMEMBER(int, pfnUnmount,(PPDMIMOUNT pInterface, bool fForce, bool fEject));
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Checks if a media is mounted.
|
---|
99 | *
|
---|
100 | * @returns true if mounted.
|
---|
101 | * @returns false if not mounted.
|
---|
102 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
103 | * @thread Any thread.
|
---|
104 | */
|
---|
105 | DECLR3CALLBACKMEMBER(bool, pfnIsMounted,(PPDMIMOUNT pInterface));
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * Locks the media, preventing any unmounting of it.
|
---|
109 | *
|
---|
110 | * @returns VBox status code.
|
---|
111 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
112 | * @thread The emulation thread.
|
---|
113 | */
|
---|
114 | DECLR3CALLBACKMEMBER(int, pfnLock,(PPDMIMOUNT pInterface));
|
---|
115 |
|
---|
116 | /**
|
---|
117 | * Unlocks the media, canceling previous calls to pfnLock().
|
---|
118 | *
|
---|
119 | * @returns VBox status code.
|
---|
120 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
121 | * @thread The emulation thread.
|
---|
122 | */
|
---|
123 | DECLR3CALLBACKMEMBER(int, pfnUnlock,(PPDMIMOUNT pInterface));
|
---|
124 |
|
---|
125 | /**
|
---|
126 | * Checks if a media is locked.
|
---|
127 | *
|
---|
128 | * @returns true if locked.
|
---|
129 | * @returns false if not locked.
|
---|
130 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
131 | * @thread Any thread.
|
---|
132 | */
|
---|
133 | DECLR3CALLBACKMEMBER(bool, pfnIsLocked,(PPDMIMOUNT pInterface));
|
---|
134 | } PDMIMOUNT;
|
---|
135 | /** PDMIMOUNT interface ID. */
|
---|
136 | #define PDMIMOUNT_IID "34fc7a4c-623a-4806-a6bf-5be1be33c99f"
|
---|
137 |
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * Callback which provides progress information.
|
---|
141 | *
|
---|
142 | * @return VBox status code.
|
---|
143 | * @param pvUser Opaque user data.
|
---|
144 | * @param uPercent Completion percentage.
|
---|
145 | */
|
---|
146 | typedef DECLCALLBACK(int) FNSIMPLEPROGRESS(void *pvUser, unsigned uPercentage);
|
---|
147 | /** Pointer to FNSIMPLEPROGRESS() */
|
---|
148 | typedef FNSIMPLEPROGRESS *PFNSIMPLEPROGRESS;
|
---|
149 |
|
---|
150 |
|
---|
151 | /**
|
---|
152 | * Media type.
|
---|
153 | */
|
---|
154 | typedef enum PDMMEDIATYPE
|
---|
155 | {
|
---|
156 | /** Error (for the query function). */
|
---|
157 | PDMMEDIATYPE_ERROR = 1,
|
---|
158 | /** 360KB 5 1/4" floppy drive. */
|
---|
159 | PDMMEDIATYPE_FLOPPY_360,
|
---|
160 | /** 720KB 3 1/2" floppy drive. */
|
---|
161 | PDMMEDIATYPE_FLOPPY_720,
|
---|
162 | /** 1.2MB 5 1/4" floppy drive. */
|
---|
163 | PDMMEDIATYPE_FLOPPY_1_20,
|
---|
164 | /** 1.44MB 3 1/2" floppy drive. */
|
---|
165 | PDMMEDIATYPE_FLOPPY_1_44,
|
---|
166 | /** 2.88MB 3 1/2" floppy drive. */
|
---|
167 | PDMMEDIATYPE_FLOPPY_2_88,
|
---|
168 | /** Fake drive that can take up to 15.6 MB images.
|
---|
169 | * C=255, H=2, S=63. */
|
---|
170 | PDMMEDIATYPE_FLOPPY_FAKE_15_6,
|
---|
171 | /** Fake drive that can take up to 63.5 MB images.
|
---|
172 | * C=255, H=2, S=255. */
|
---|
173 | PDMMEDIATYPE_FLOPPY_FAKE_63_5,
|
---|
174 | /** CDROM drive. */
|
---|
175 | PDMMEDIATYPE_CDROM,
|
---|
176 | /** DVD drive. */
|
---|
177 | PDMMEDIATYPE_DVD,
|
---|
178 | /** Hard disk drive. */
|
---|
179 | PDMMEDIATYPE_HARD_DISK
|
---|
180 | } PDMMEDIATYPE;
|
---|
181 |
|
---|
182 | /** Check if the given block type is a floppy. */
|
---|
183 | #define PDMMEDIATYPE_IS_FLOPPY(a_enmType) ( (a_enmType) >= PDMMEDIATYPE_FLOPPY_360 && (a_enmType) <= PDMMEDIATYPE_FLOPPY_2_88 )
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * Raw command data transfer direction.
|
---|
187 | */
|
---|
188 | typedef enum PDMMEDIATXDIR
|
---|
189 | {
|
---|
190 | PDMMEDIATXDIR_NONE = 0,
|
---|
191 | PDMMEDIATXDIR_FROM_DEVICE,
|
---|
192 | PDMMEDIATXDIR_TO_DEVICE
|
---|
193 | } PDMMEDIATXDIR;
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * Media geometry structure.
|
---|
197 | */
|
---|
198 | typedef struct PDMMEDIAGEOMETRY
|
---|
199 | {
|
---|
200 | /** Number of cylinders. */
|
---|
201 | uint32_t cCylinders;
|
---|
202 | /** Number of heads. */
|
---|
203 | uint32_t cHeads;
|
---|
204 | /** Number of sectors. */
|
---|
205 | uint32_t cSectors;
|
---|
206 | } PDMMEDIAGEOMETRY;
|
---|
207 |
|
---|
208 | /** Pointer to media geometry structure. */
|
---|
209 | typedef PDMMEDIAGEOMETRY *PPDMMEDIAGEOMETRY;
|
---|
210 | /** Pointer to constant media geometry structure. */
|
---|
211 | typedef const PDMMEDIAGEOMETRY *PCPDMMEDIAGEOMETRY;
|
---|
212 |
|
---|
213 | /** Pointer to a media port interface. */
|
---|
214 | typedef struct PDMIMEDIAPORT *PPDMIMEDIAPORT;
|
---|
215 | /**
|
---|
216 | * Media port interface (down).
|
---|
217 | */
|
---|
218 | typedef struct PDMIMEDIAPORT
|
---|
219 | {
|
---|
220 | /**
|
---|
221 | * Returns the storage controller name, instance and LUN of the attached medium.
|
---|
222 | *
|
---|
223 | * @returns VBox status.
|
---|
224 | * @param pInterface Pointer to this interface.
|
---|
225 | * @param ppcszController Where to store the name of the storage controller.
|
---|
226 | * @param piInstance Where to store the instance number of the controller.
|
---|
227 | * @param piLUN Where to store the LUN of the attached device.
|
---|
228 | */
|
---|
229 | DECLR3CALLBACKMEMBER(int, pfnQueryDeviceLocation, (PPDMIMEDIAPORT pInterface, const char **ppcszController,
|
---|
230 | uint32_t *piInstance, uint32_t *piLUN));
|
---|
231 |
|
---|
232 |
|
---|
233 | /**
|
---|
234 | * Queries the vendor and product ID and revision to report for INQUIRY commands in underlying devices.
|
---|
235 | *
|
---|
236 | * @returns VBox status code.
|
---|
237 | * @param pInterface Pointer to this interface.
|
---|
238 | * @param ppszVendorId Where to store the pointer to the vendor ID string to report.
|
---|
239 | * @param ppszProductId Where to store the pointer to the product ID string to report.
|
---|
240 | * @param ppszRevision Where to store the pointer to the revision string to report.
|
---|
241 | *
|
---|
242 | * @note The strings for the inquiry data are stored in the storage controller rather than in the device
|
---|
243 | * because if device attachments change (virtual CD/DVD drive versus host drive) there is currently no
|
---|
244 | * way to keep the INQUIRY data in extradata keys without causing trouble when the attachment is changed.
|
---|
245 | * Also Main currently doesn't has any settings for the attachment to store such information in the settings
|
---|
246 | * properly. Last reason (but not the most important one) is to stay compatible with older versions
|
---|
247 | * where the drive emulation was in AHCI but it now uses VSCSI and the settings overwrite should still work.
|
---|
248 | */
|
---|
249 | DECLR3CALLBACKMEMBER(int, pfnQueryScsiInqStrings, (PPDMIMEDIAPORT pInterface, const char **ppszVendorId,
|
---|
250 | const char **ppszProductId, const char **ppszRevision));
|
---|
251 |
|
---|
252 | } PDMIMEDIAPORT;
|
---|
253 | /** PDMIMEDIAPORT interface ID. */
|
---|
254 | #define PDMIMEDIAPORT_IID "77180ab8-6485-454f-b440-efca322b7bd7"
|
---|
255 |
|
---|
256 | /** Pointer to a media interface. */
|
---|
257 | typedef struct PDMIMEDIA *PPDMIMEDIA;
|
---|
258 | /**
|
---|
259 | * Media interface (up).
|
---|
260 | * Pairs with PDMIMEDIAPORT.
|
---|
261 | */
|
---|
262 | typedef struct PDMIMEDIA
|
---|
263 | {
|
---|
264 | /**
|
---|
265 | * Read bits.
|
---|
266 | *
|
---|
267 | * @returns VBox status code.
|
---|
268 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
269 | * @param off Offset to start reading from. The offset must be aligned to a sector boundary.
|
---|
270 | * @param pvBuf Where to store the read bits.
|
---|
271 | * @param cbRead Number of bytes to read. Must be aligned to a sector boundary.
|
---|
272 | * @thread Any thread.
|
---|
273 | */
|
---|
274 | DECLR3CALLBACKMEMBER(int, pfnRead,(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead));
|
---|
275 |
|
---|
276 | /**
|
---|
277 | * Read bits - version for DevPcBios.
|
---|
278 | *
|
---|
279 | * @returns VBox status code.
|
---|
280 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
281 | * @param off Offset to start reading from. The offset must be aligned to a sector boundary.
|
---|
282 | * @param pvBuf Where to store the read bits.
|
---|
283 | * @param cbRead Number of bytes to read. Must be aligned to a sector boundary.
|
---|
284 | * @thread Any thread.
|
---|
285 | *
|
---|
286 | * @note: Special version of pfnRead which doesn't try to suspend the VM when the DEKs for encrypted disks
|
---|
287 | * are missing but just returns an error.
|
---|
288 | */
|
---|
289 | DECLR3CALLBACKMEMBER(int, pfnReadPcBios,(PPDMIMEDIA pInterface, uint64_t off, void *pvBuf, size_t cbRead));
|
---|
290 |
|
---|
291 | /**
|
---|
292 | * Write bits.
|
---|
293 | *
|
---|
294 | * @returns VBox status code.
|
---|
295 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
296 | * @param off Offset to start writing at. The offset must be aligned to a sector boundary.
|
---|
297 | * @param pvBuf Where to store the write bits.
|
---|
298 | * @param cbWrite Number of bytes to write. Must be aligned to a sector boundary.
|
---|
299 | * @thread Any thread.
|
---|
300 | */
|
---|
301 | DECLR3CALLBACKMEMBER(int, pfnWrite,(PPDMIMEDIA pInterface, uint64_t off, const void *pvBuf, size_t cbWrite));
|
---|
302 |
|
---|
303 | /**
|
---|
304 | * Make sure that the bits written are actually on the storage medium.
|
---|
305 | *
|
---|
306 | * @returns VBox status code.
|
---|
307 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
308 | * @thread Any thread.
|
---|
309 | */
|
---|
310 | DECLR3CALLBACKMEMBER(int, pfnFlush,(PPDMIMEDIA pInterface));
|
---|
311 |
|
---|
312 | /**
|
---|
313 | * Send a raw command to the underlying device (CDROM).
|
---|
314 | * This method is optional (i.e. the function pointer may be NULL).
|
---|
315 | *
|
---|
316 | * @returns VBox status code.
|
---|
317 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
318 | * @param pbCdb The command to process.
|
---|
319 | * @param cbCdb The length of the command in bytes.
|
---|
320 | * @param enmTxDir Direction of transfer.
|
---|
321 | * @param pvBuf Pointer tp the transfer buffer.
|
---|
322 | * @param pcbBuf Size of the transfer buffer.
|
---|
323 | * @param pabSense Status of the command (when return value is VERR_DEV_IO_ERROR).
|
---|
324 | * @param cbSense Size of the sense buffer in bytes.
|
---|
325 | * @param cTimeoutMillies Command timeout in milliseconds.
|
---|
326 | * @thread Any thread.
|
---|
327 | */
|
---|
328 | DECLR3CALLBACKMEMBER(int, pfnSendCmd,(PPDMIMEDIA pInterface, const uint8_t *pbCdb, size_t cbCdb,
|
---|
329 | PDMMEDIATXDIR enmTxDir, void *pvBuf, uint32_t *pcbBuf,
|
---|
330 | uint8_t *pabSense, size_t cbSense, uint32_t cTimeoutMillies));
|
---|
331 |
|
---|
332 | /**
|
---|
333 | * Merge medium contents during a live snapshot deletion. All details
|
---|
334 | * must have been configured through CFGM or this will fail.
|
---|
335 | * This method is optional (i.e. the function pointer may be NULL).
|
---|
336 | *
|
---|
337 | * @returns VBox status code.
|
---|
338 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
339 | * @param pfnProgress Function pointer for progress notification.
|
---|
340 | * @param pvUser Opaque user data for progress notification.
|
---|
341 | * @thread Any thread.
|
---|
342 | */
|
---|
343 | DECLR3CALLBACKMEMBER(int, pfnMerge,(PPDMIMEDIA pInterface, PFNSIMPLEPROGRESS pfnProgress, void *pvUser));
|
---|
344 |
|
---|
345 | /**
|
---|
346 | * Sets the secret key retrieval interface to use to get secret keys.
|
---|
347 | *
|
---|
348 | * @returns VBox status code.
|
---|
349 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
350 | * @param pIfSecKey The secret key interface to use.
|
---|
351 | * Use NULL to clear the currently set interface and clear all secret
|
---|
352 | * keys from the user.
|
---|
353 | * @param pIfSecKeyHlp The secret key helper interface to use.
|
---|
354 | * @thread Any thread.
|
---|
355 | */
|
---|
356 | DECLR3CALLBACKMEMBER(int, pfnSetSecKeyIf,(PPDMIMEDIA pInterface, struct PDMISECKEY *pIfSecKey,
|
---|
357 | struct PDMISECKEYHLP *pIfSecKeyHlp));
|
---|
358 |
|
---|
359 | /**
|
---|
360 | * Get the media size in bytes.
|
---|
361 | *
|
---|
362 | * @returns Media size in bytes.
|
---|
363 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
364 | * @thread Any thread.
|
---|
365 | */
|
---|
366 | DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize,(PPDMIMEDIA pInterface));
|
---|
367 |
|
---|
368 | /**
|
---|
369 | * Gets the media sector size in bytes.
|
---|
370 | *
|
---|
371 | * @returns Media sector size in bytes.
|
---|
372 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
373 | * @thread Any thread.
|
---|
374 | */
|
---|
375 | DECLR3CALLBACKMEMBER(uint32_t, pfnGetSectorSize,(PPDMIMEDIA pInterface));
|
---|
376 |
|
---|
377 | /**
|
---|
378 | * Check if the media is readonly or not.
|
---|
379 | *
|
---|
380 | * @returns true if readonly.
|
---|
381 | * @returns false if read/write.
|
---|
382 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
383 | * @thread Any thread.
|
---|
384 | */
|
---|
385 | DECLR3CALLBACKMEMBER(bool, pfnIsReadOnly,(PPDMIMEDIA pInterface));
|
---|
386 |
|
---|
387 | /**
|
---|
388 | * Returns whether the medium should be marked as rotational or not.
|
---|
389 | *
|
---|
390 | * @returns true if non rotating medium.
|
---|
391 | * @returns false if rotating medium.
|
---|
392 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
393 | * @thread Any thread.
|
---|
394 | */
|
---|
395 | DECLR3CALLBACKMEMBER(bool, pfnIsNonRotational,(PPDMIMEDIA pInterface));
|
---|
396 |
|
---|
397 | /**
|
---|
398 | * Get stored media geometry (physical CHS, PCHS) - BIOS property.
|
---|
399 | * This is an optional feature of a media.
|
---|
400 | *
|
---|
401 | * @returns VBox status code.
|
---|
402 | * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
|
---|
403 | * @returns VERR_PDM_GEOMETRY_NOT_SET if the geometry hasn't been set using pfnBiosSetPCHSGeometry() yet.
|
---|
404 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
405 | * @param pPCHSGeometry Pointer to PCHS geometry (cylinders/heads/sectors).
|
---|
406 | * @remark This has no influence on the read/write operations.
|
---|
407 | * @thread Any thread.
|
---|
408 | */
|
---|
409 | DECLR3CALLBACKMEMBER(int, pfnBiosGetPCHSGeometry,(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pPCHSGeometry));
|
---|
410 |
|
---|
411 | /**
|
---|
412 | * Store the media geometry (physical CHS, PCHS) - BIOS property.
|
---|
413 | * This is an optional feature of a media.
|
---|
414 | *
|
---|
415 | * @returns VBox status code.
|
---|
416 | * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
|
---|
417 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
418 | * @param pPCHSGeometry Pointer to PCHS geometry (cylinders/heads/sectors).
|
---|
419 | * @remark This has no influence on the read/write operations.
|
---|
420 | * @thread The emulation thread.
|
---|
421 | */
|
---|
422 | DECLR3CALLBACKMEMBER(int, pfnBiosSetPCHSGeometry,(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pPCHSGeometry));
|
---|
423 |
|
---|
424 | /**
|
---|
425 | * Get stored media geometry (logical CHS, LCHS) - BIOS property.
|
---|
426 | * This is an optional feature of a media.
|
---|
427 | *
|
---|
428 | * @returns VBox status code.
|
---|
429 | * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
|
---|
430 | * @returns VERR_PDM_GEOMETRY_NOT_SET if the geometry hasn't been set using pfnBiosSetLCHSGeometry() yet.
|
---|
431 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
432 | * @param pLCHSGeometry Pointer to LCHS geometry (cylinders/heads/sectors).
|
---|
433 | * @remark This has no influence on the read/write operations.
|
---|
434 | * @thread Any thread.
|
---|
435 | */
|
---|
436 | DECLR3CALLBACKMEMBER(int, pfnBiosGetLCHSGeometry,(PPDMIMEDIA pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry));
|
---|
437 |
|
---|
438 | /**
|
---|
439 | * Store the media geometry (logical CHS, LCHS) - BIOS property.
|
---|
440 | * This is an optional feature of a media.
|
---|
441 | *
|
---|
442 | * @returns VBox status code.
|
---|
443 | * @returns VERR_NOT_IMPLEMENTED if the media doesn't support storing the geometry.
|
---|
444 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
445 | * @param pLCHSGeometry Pointer to LCHS geometry (cylinders/heads/sectors).
|
---|
446 | * @remark This has no influence on the read/write operations.
|
---|
447 | * @thread The emulation thread.
|
---|
448 | */
|
---|
449 | DECLR3CALLBACKMEMBER(int, pfnBiosSetLCHSGeometry,(PPDMIMEDIA pInterface, PCPDMMEDIAGEOMETRY pLCHSGeometry));
|
---|
450 |
|
---|
451 | /**
|
---|
452 | * Checks if the device should be visible to the BIOS or not.
|
---|
453 | *
|
---|
454 | * @returns true if the device is visible to the BIOS.
|
---|
455 | * @returns false if the device is not visible to the BIOS.
|
---|
456 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
457 | * @thread Any thread.
|
---|
458 | */
|
---|
459 | DECLR3CALLBACKMEMBER(bool, pfnBiosIsVisible,(PPDMIMEDIA pInterface));
|
---|
460 |
|
---|
461 | /**
|
---|
462 | * Gets the media type.
|
---|
463 | *
|
---|
464 | * @returns media type.
|
---|
465 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
466 | * @thread Any thread.
|
---|
467 | */
|
---|
468 | DECLR3CALLBACKMEMBER(PDMMEDIATYPE, pfnGetType,(PPDMIMEDIA pInterface));
|
---|
469 |
|
---|
470 | /**
|
---|
471 | * Gets the UUID of the media drive.
|
---|
472 | *
|
---|
473 | * @returns VBox status code.
|
---|
474 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
475 | * @param pUuid Where to store the UUID on success.
|
---|
476 | * @thread Any thread.
|
---|
477 | */
|
---|
478 | DECLR3CALLBACKMEMBER(int, pfnGetUuid,(PPDMIMEDIA pInterface, PRTUUID pUuid));
|
---|
479 |
|
---|
480 | /**
|
---|
481 | * Discards the given range.
|
---|
482 | *
|
---|
483 | * @returns VBox status code.
|
---|
484 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
485 | * @param paRanges Array of ranges to discard.
|
---|
486 | * @param cRanges Number of entries in the array.
|
---|
487 | * @thread Any thread.
|
---|
488 | */
|
---|
489 | DECLR3CALLBACKMEMBER(int, pfnDiscard,(PPDMIMEDIA pInterface, PCRTRANGE paRanges, unsigned cRanges));
|
---|
490 |
|
---|
491 | /**
|
---|
492 | * Returns the number of regions for the medium.
|
---|
493 | *
|
---|
494 | * @returns Number of regions.
|
---|
495 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
496 | */
|
---|
497 | DECLR3CALLBACKMEMBER(uint32_t, pfnGetRegionCount,(PPDMIMEDIA pInterface));
|
---|
498 |
|
---|
499 | /**
|
---|
500 | * Queries the properties for the given region.
|
---|
501 | *
|
---|
502 | * @returns VBox status code.
|
---|
503 | * @retval VERR_NOT_FOUND if the region index is not known.
|
---|
504 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
505 | * @param uRegion The region index to query the properties of.
|
---|
506 | * @param pu64LbaStart Where to store the starting LBA for the region on success.
|
---|
507 | * @param pcBlocks Where to store the number of blocks for the region on success.
|
---|
508 | * @param pcbBlock Where to store the size of one block in bytes on success.
|
---|
509 | * @param penmDataForm WHere to store the data form for the region on success.
|
---|
510 | */
|
---|
511 | DECLR3CALLBACKMEMBER(int, pfnQueryRegionProperties,(PPDMIMEDIA pInterface, uint32_t uRegion, uint64_t *pu64LbaStart,
|
---|
512 | uint64_t *pcBlocks, uint64_t *pcbBlock,
|
---|
513 | PVDREGIONDATAFORM penmDataForm));
|
---|
514 |
|
---|
515 | /**
|
---|
516 | * Queries the properties for the region covering the given LBA.
|
---|
517 | *
|
---|
518 | * @returns VBox status code.
|
---|
519 | * @retval VERR_NOT_FOUND if the region index is not known.
|
---|
520 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
521 | * @param u64LbaStart Where to store the starting LBA for the region on success.
|
---|
522 | * @param puRegion Where to store the region number on success.
|
---|
523 | * @param pcBlocks Where to store the number of blocks left in this region starting from the given LBA.
|
---|
524 | * @param pcbBlock Where to store the size of one block in bytes on success.
|
---|
525 | * @param penmDataForm WHere to store the data form for the region on success.
|
---|
526 | */
|
---|
527 | DECLR3CALLBACKMEMBER(int, pfnQueryRegionPropertiesForLba,(PPDMIMEDIA pInterface, uint64_t u64LbaStart,
|
---|
528 | uint32_t *puRegion, uint64_t *pcBlocks,
|
---|
529 | uint64_t *pcbBlock, PVDREGIONDATAFORM penmDataForm));
|
---|
530 |
|
---|
531 | } PDMIMEDIA;
|
---|
532 | /** PDMIMEDIA interface ID. */
|
---|
533 | #define PDMIMEDIA_IID "8ec68c48-dd20-4430-8386-f0d628a5aca6"
|
---|
534 |
|
---|
535 |
|
---|
536 | /**
|
---|
537 | * Opaque I/O request handle.
|
---|
538 | *
|
---|
539 | * The specific content depends on the driver implementing this interface.
|
---|
540 | */
|
---|
541 | typedef struct PDMMEDIAEXIOREQINT *PDMMEDIAEXIOREQ;
|
---|
542 | /** Pointer to an I/O request handle. */
|
---|
543 | typedef PDMMEDIAEXIOREQ *PPDMMEDIAEXIOREQ;
|
---|
544 |
|
---|
545 | /** A I/O request ID. */
|
---|
546 | typedef uint64_t PDMMEDIAEXIOREQID;
|
---|
547 |
|
---|
548 | /**
|
---|
549 | * I/O Request Type.
|
---|
550 | */
|
---|
551 | typedef enum PDMMEDIAEXIOREQTYPE
|
---|
552 | {
|
---|
553 | /** Invalid tpe. */
|
---|
554 | PDMMEDIAEXIOREQTYPE_INVALID = 0,
|
---|
555 | /** Flush request. */
|
---|
556 | PDMMEDIAEXIOREQTYPE_FLUSH,
|
---|
557 | /** Write request. */
|
---|
558 | PDMMEDIAEXIOREQTYPE_WRITE,
|
---|
559 | /** Read request. */
|
---|
560 | PDMMEDIAEXIOREQTYPE_READ,
|
---|
561 | /** Discard request. */
|
---|
562 | PDMMEDIAEXIOREQTYPE_DISCARD,
|
---|
563 | /** SCSI command. */
|
---|
564 | PDMMEDIAEXIOREQTYPE_SCSI
|
---|
565 | } PDMMEDIAEXIOREQTYPE;
|
---|
566 | /** Pointer to a I/O request type. */
|
---|
567 | typedef PDMMEDIAEXIOREQTYPE *PPDMMEDIAEXIOREQTYPE;
|
---|
568 |
|
---|
569 | /**
|
---|
570 | * Data direction for raw SCSI commands.
|
---|
571 | */
|
---|
572 | typedef enum PDMMEDIAEXIOREQSCSITXDIR
|
---|
573 | {
|
---|
574 | /** Invalid data direction. */
|
---|
575 | PDMMEDIAEXIOREQSCSITXDIR_INVALID = 0,
|
---|
576 | /** Direction is unknown. */
|
---|
577 | PDMMEDIAEXIOREQSCSITXDIR_UNKNOWN,
|
---|
578 | /** Direction is from device to host. */
|
---|
579 | PDMMEDIAEXIOREQSCSITXDIR_FROM_DEVICE,
|
---|
580 | /** Direction is from host to device. */
|
---|
581 | PDMMEDIAEXIOREQSCSITXDIR_TO_DEVICE,
|
---|
582 | /** No data transfer associated with this request. */
|
---|
583 | PDMMEDIAEXIOREQSCSITXDIR_NONE,
|
---|
584 | /** 32bit hack. */
|
---|
585 | PDMMEDIAEXIOREQSCSITXDIR_32BIT_HACK = 0x7fffffff
|
---|
586 | } PDMMEDIAEXIOREQSCSITXDIR;
|
---|
587 |
|
---|
588 | /**
|
---|
589 | * I/O request state.
|
---|
590 | */
|
---|
591 | typedef enum PDMMEDIAEXIOREQSTATE
|
---|
592 | {
|
---|
593 | /** Invalid state. */
|
---|
594 | PDMMEDIAEXIOREQSTATE_INVALID = 0,
|
---|
595 | /** The request is active and being processed. */
|
---|
596 | PDMMEDIAEXIOREQSTATE_ACTIVE,
|
---|
597 | /** The request is suspended due to an error and no processing will take place. */
|
---|
598 | PDMMEDIAEXIOREQSTATE_SUSPENDED,
|
---|
599 | /** 32bit hack. */
|
---|
600 | PDMMEDIAEXIOREQSTATE_32BIT_HACK = 0x7fffffff
|
---|
601 | } PDMMEDIAEXIOREQSTATE;
|
---|
602 | /** Pointer to a I/O request state. */
|
---|
603 | typedef PDMMEDIAEXIOREQSTATE *PPDMMEDIAEXIOREQSTATE;
|
---|
604 |
|
---|
605 | /** @name Supported feature flags
|
---|
606 | * @{ */
|
---|
607 | /** I/O requests will execute asynchronously by default. */
|
---|
608 | #define PDMIMEDIAEX_FEATURE_F_ASYNC RT_BIT_32(0)
|
---|
609 | /** The discard request is supported. */
|
---|
610 | #define PDMIMEDIAEX_FEATURE_F_DISCARD RT_BIT_32(1)
|
---|
611 | /** The send raw SCSI command request is supported. */
|
---|
612 | #define PDMIMEDIAEX_FEATURE_F_RAWSCSICMD RT_BIT_32(2)
|
---|
613 | /** Mask of valid flags. */
|
---|
614 | #define PDMIMEDIAEX_FEATURE_F_VALID (PDMIMEDIAEX_FEATURE_F_ASYNC | PDMIMEDIAEX_FEATURE_F_DISCARD | PDMIMEDIAEX_FEATURE_F_RAWSCSICMD)
|
---|
615 | /** @} */
|
---|
616 |
|
---|
617 | /** @name I/O request specific flags
|
---|
618 | * @{ */
|
---|
619 | /** Default behavior (async I/O).*/
|
---|
620 | #define PDMIMEDIAEX_F_DEFAULT (0)
|
---|
621 | /** The I/O request will be executed synchronously. */
|
---|
622 | #define PDMIMEDIAEX_F_SYNC RT_BIT_32(0)
|
---|
623 | /** Whether to suspend the VM on a recoverable error with
|
---|
624 | * an appropriate error message (disk full, etc.).
|
---|
625 | * The request will be retried by the driver implementing the interface
|
---|
626 | * when the VM resumes the next time. However before suspending the request
|
---|
627 | * the owner of the request will be notified using the PDMMEDIAEXPORT::pfnIoReqStateChanged.
|
---|
628 | * The same goes for resuming the request after the VM was resumed.
|
---|
629 | */
|
---|
630 | #define PDMIMEDIAEX_F_SUSPEND_ON_RECOVERABLE_ERR RT_BIT_32(1)
|
---|
631 | /** Mask of valid flags. */
|
---|
632 | #define PDMIMEDIAEX_F_VALID (PDMIMEDIAEX_F_SYNC | PDMIMEDIAEX_F_SUSPEND_ON_RECOVERABLE_ERR)
|
---|
633 | /** @} */
|
---|
634 |
|
---|
635 | /** Pointer to an extended media notification interface. */
|
---|
636 | typedef struct PDMIMEDIAEXPORT *PPDMIMEDIAEXPORT;
|
---|
637 |
|
---|
638 | /**
|
---|
639 | * Asynchronous version of the media interface (up).
|
---|
640 | * Pair with PDMIMEDIAEXPORT.
|
---|
641 | */
|
---|
642 | typedef struct PDMIMEDIAEXPORT
|
---|
643 | {
|
---|
644 | /**
|
---|
645 | * Notify completion of a I/O request.
|
---|
646 | *
|
---|
647 | * @returns VBox status code.
|
---|
648 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
649 | * @param hIoReq The I/O request handle.
|
---|
650 | * @param pvIoReqAlloc The allocator specific memory for this request.
|
---|
651 | * @param rcReq IPRT Status code of the completed request.
|
---|
652 | * VERR_PDM_MEDIAEX_IOREQ_CANCELED if the request was canceled by a call to
|
---|
653 | * PDMIMEDIAEX::pfnIoReqCancel.
|
---|
654 | * @thread Any thread.
|
---|
655 | */
|
---|
656 | DECLR3CALLBACKMEMBER(int, pfnIoReqCompleteNotify, (PPDMIMEDIAEXPORT pInterface, PDMMEDIAEXIOREQ hIoReq,
|
---|
657 | void *pvIoReqAlloc, int rcReq));
|
---|
658 |
|
---|
659 | /**
|
---|
660 | * Copy data from the memory buffer of the caller to the callees memory buffer for the given request.
|
---|
661 | *
|
---|
662 | * @returns VBox status code.
|
---|
663 | * @retval VERR_PDM_MEDIAEX_IOBUF_OVERFLOW if there is not enough room to store the data.
|
---|
664 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
665 | * @param hIoReq The I/O request handle.
|
---|
666 | * @param pvIoReqAlloc The allocator specific memory for this request.
|
---|
667 | * @param offDst The destination offset from the start to write the data to.
|
---|
668 | * @param pSgBuf The S/G buffer to read the data from.
|
---|
669 | * @param cbCopy How many bytes to copy.
|
---|
670 | */
|
---|
671 | DECLR3CALLBACKMEMBER(int, pfnIoReqCopyFromBuf, (PPDMIMEDIAEXPORT pInterface, PDMMEDIAEXIOREQ hIoReq,
|
---|
672 | void *pvIoReqAlloc, uint32_t offDst, PRTSGBUF pSgBuf,
|
---|
673 | size_t cbCopy));
|
---|
674 |
|
---|
675 | /**
|
---|
676 | * Copy data to the memory buffer of the caller from the callees memory buffer for the given request.
|
---|
677 | *
|
---|
678 | * @returns VBox status code.
|
---|
679 | * @retval VERR_PDM_MEDIAEX_IOBUF_UNDERRUN if there is not enough data to copy from the buffer.
|
---|
680 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
681 | * @param hIoReq The I/O request handle.
|
---|
682 | * @param pvIoReqAlloc The allocator specific memory for this request.
|
---|
683 | * @param offSrc The offset from the start of the buffer to read the data from.
|
---|
684 | * @param pSgBuf The S/G buffer to write the data to.
|
---|
685 | * @param cbCopy How many bytes to copy.
|
---|
686 | */
|
---|
687 | DECLR3CALLBACKMEMBER(int, pfnIoReqCopyToBuf, (PPDMIMEDIAEXPORT pInterface, PDMMEDIAEXIOREQ hIoReq,
|
---|
688 | void *pvIoReqAlloc, uint32_t offSrc, PRTSGBUF pSgBuf,
|
---|
689 | size_t cbCopy));
|
---|
690 |
|
---|
691 | /**
|
---|
692 | * Queries a pointer to the memory buffer for the request from the drive/device above.
|
---|
693 | *
|
---|
694 | * @returns VBox status code.
|
---|
695 | * @retval VERR_NOT_SUPPORTED if this is not supported for this request.
|
---|
696 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
697 | * @param hIoReq The I/O request handle.
|
---|
698 | * @param pvIoReqAlloc The allocator specific memory for this request.
|
---|
699 | * @param ppvBuf Where to store the pointer to the guest buffer on success.
|
---|
700 | * @param pcbBuf Where to store the size of the buffer on success.
|
---|
701 | *
|
---|
702 | * @note This is an optional feature of the entity implementing this interface to avoid overhead
|
---|
703 | * by copying the data between buffers. If NULL it is not supported at all and the caller
|
---|
704 | * has to resort to PDMIMEDIAEXPORT::pfnIoReqCopyToBuf and PDMIMEDIAEXPORT::pfnIoReqCopyFromBuf.
|
---|
705 | * The same holds when VERR_NOT_SUPPORTED is returned.
|
---|
706 | *
|
---|
707 | * On the upside the caller of this interface might not call this method at all and just
|
---|
708 | * use the before mentioned methods to copy the data between the buffers.
|
---|
709 | */
|
---|
710 | DECLR3CALLBACKMEMBER(int, pfnIoReqQueryBuf, (PPDMIMEDIAEXPORT pInterface, PDMMEDIAEXIOREQ hIoReq,
|
---|
711 | void *pvIoReqAlloc, void **ppvBuf, size_t *pcbBuf));
|
---|
712 |
|
---|
713 | /**
|
---|
714 | * Queries the specified amount of ranges to discard from the callee for the given I/O request.
|
---|
715 | *
|
---|
716 | * @returns VBox status code.
|
---|
717 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
718 | * @param hIoReq The I/O request handle.
|
---|
719 | * @param pvIoReqAlloc The allocator specific memory for this request.
|
---|
720 | * @param idxRangeStart The range index to start with.
|
---|
721 | * @param cRanges How man ranges can be stored in the provided array.
|
---|
722 | * @param paRanges Where to store the ranges on success.
|
---|
723 | * @param *pcRanges Where to store the number of ranges copied over on success.
|
---|
724 | */
|
---|
725 | DECLR3CALLBACKMEMBER(int, pfnIoReqQueryDiscardRanges, (PPDMIMEDIAEXPORT pInterface, PDMMEDIAEXIOREQ hIoReq,
|
---|
726 | void *pvIoReqAlloc, uint32_t idxRangeStart,
|
---|
727 | uint32_t cRanges, PRTRANGE paRanges,
|
---|
728 | uint32_t *pcRanges));
|
---|
729 |
|
---|
730 | /**
|
---|
731 | * Notify the request owner about a state change for the request.
|
---|
732 | *
|
---|
733 | * @returns nothing.
|
---|
734 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
735 | * @param hIoReq The I/O request handle.
|
---|
736 | * @param pvIoReqAlloc The allocator specific memory for this request.
|
---|
737 | * @param enmState The new state of the request.
|
---|
738 | */
|
---|
739 | DECLR3CALLBACKMEMBER(void, pfnIoReqStateChanged, (PPDMIMEDIAEXPORT pInterface, PDMMEDIAEXIOREQ hIoReq,
|
---|
740 | void *pvIoReqAlloc, PDMMEDIAEXIOREQSTATE enmState));
|
---|
741 |
|
---|
742 | /**
|
---|
743 | * Informs the device that the underlying medium was ejected.
|
---|
744 | *
|
---|
745 | * @returns nothing.
|
---|
746 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
747 | */
|
---|
748 | DECLR3CALLBACKMEMBER(void, pfnMediumEjected, (PPDMIMEDIAEXPORT pInterface));
|
---|
749 |
|
---|
750 | } PDMIMEDIAEXPORT;
|
---|
751 |
|
---|
752 | /** PDMIMEDIAAEXPORT interface ID. */
|
---|
753 | #define PDMIMEDIAEXPORT_IID "0ae2e534-6c28-41d6-9a88-7f88f2cb2ff8"
|
---|
754 |
|
---|
755 |
|
---|
756 | /** Pointer to an extended media interface. */
|
---|
757 | typedef struct PDMIMEDIAEX *PPDMIMEDIAEX;
|
---|
758 |
|
---|
759 | /**
|
---|
760 | * Extended version of PDMIMEDIA (down).
|
---|
761 | * Pair with PDMIMEDIAEXPORT.
|
---|
762 | */
|
---|
763 | typedef struct PDMIMEDIAEX
|
---|
764 | {
|
---|
765 | /**
|
---|
766 | * Queries the features supported by the entity implementing this interface.
|
---|
767 | *
|
---|
768 | * @returns VBox status code.
|
---|
769 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
770 | * @param pfFeatures Where to store the supported feature flags on success.
|
---|
771 | */
|
---|
772 | DECLR3CALLBACKMEMBER(int, pfnQueryFeatures, (PPDMIMEDIAEX pInterface, uint32_t *pfFeatures));
|
---|
773 |
|
---|
774 | /**
|
---|
775 | * Notifies the driver below that the device received a suspend notification.
|
---|
776 | *
|
---|
777 | * @returns nothing.
|
---|
778 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
779 | *
|
---|
780 | * @note this is required because the PDM drivers in the storage area usually get their suspend notification
|
---|
781 | * only after the device finished suspending. For some cases it is useful for the driver to know
|
---|
782 | * as early as possible that a suspend is in progress to stop issuing deferred requests or other things.
|
---|
783 | */
|
---|
784 | DECLR3CALLBACKMEMBER(void, pfnNotifySuspend, (PPDMIMEDIAEX pInterface));
|
---|
785 |
|
---|
786 | /**
|
---|
787 | * Sets the size of the allocator specific memory for a I/O request.
|
---|
788 | *
|
---|
789 | * @returns VBox status code.
|
---|
790 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
791 | * @param cbIoReqAlloc The size of the allocator specific memory in bytes.
|
---|
792 | * @thread EMT.
|
---|
793 | */
|
---|
794 | DECLR3CALLBACKMEMBER(int, pfnIoReqAllocSizeSet, (PPDMIMEDIAEX pInterface, size_t cbIoReqAlloc));
|
---|
795 |
|
---|
796 | /**
|
---|
797 | * Allocates a new I/O request.
|
---|
798 | *
|
---|
799 | * @returns VBox status code.
|
---|
800 | * @retval VERR_PDM_MEDIAEX_IOREQID_CONFLICT if the ID belongs to a still active request.
|
---|
801 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
802 | * @param phIoReq Where to store the handle to the new I/O request on success.
|
---|
803 | * @param ppvIoReqAlloc Where to store the pointer to the allocator specific memory on success.
|
---|
804 | * NULL if the memory size was not set or set to 0.
|
---|
805 | * @param uIoReqId A custom request ID which can be used to cancel the request.
|
---|
806 | * @param fFlags A combination of PDMIMEDIAEX_F_* flags.
|
---|
807 | * @thread Any thread.
|
---|
808 | */
|
---|
809 | DECLR3CALLBACKMEMBER(int, pfnIoReqAlloc, (PPDMIMEDIAEX pInterface, PPDMMEDIAEXIOREQ phIoReq, void **ppvIoReqAlloc,
|
---|
810 | PDMMEDIAEXIOREQID uIoReqId, uint32_t fFlags));
|
---|
811 |
|
---|
812 | /**
|
---|
813 | * Frees a given I/O request.
|
---|
814 | *
|
---|
815 | * @returns VBox status code.
|
---|
816 | * @retval VERR_PDM_MEDIAEX_IOREQ_INVALID_STATE if the given request is still active.
|
---|
817 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
818 | * @param hIoReq The I/O request to free.
|
---|
819 | * @thread Any thread.
|
---|
820 | */
|
---|
821 | DECLR3CALLBACKMEMBER(int, pfnIoReqFree, (PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq));
|
---|
822 |
|
---|
823 | /**
|
---|
824 | * Queries the residual amount of data not transfered when the request completed.
|
---|
825 | *
|
---|
826 | * @returns VBox status code.
|
---|
827 | * @retval VERR_PDM_MEDIAEX_IOREQ_INVALID_STATE has not completed yet.
|
---|
828 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
829 | * @param hIoReq The I/O request.
|
---|
830 | * @param pcbResidual Where to store the amount of resdiual data in bytes.
|
---|
831 | * @thread Any thread.
|
---|
832 | */
|
---|
833 | DECLR3CALLBACKMEMBER(int, pfnIoReqQueryResidual, (PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, size_t *pcbResidual));
|
---|
834 |
|
---|
835 | /**
|
---|
836 | * Queries the residual amount of data not transfered when the request completed.
|
---|
837 | *
|
---|
838 | * @returns VBox status code.
|
---|
839 | * @retval VERR_PDM_MEDIAEX_IOREQ_INVALID_STATE has not completed yet.
|
---|
840 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
841 | * @param hIoReq The I/O request.
|
---|
842 | * @param pcbXfer Where to store the amount of resdiual data in bytes.
|
---|
843 | * @thread Any thread.
|
---|
844 | *
|
---|
845 | * @note For simple read/write requests this returns the amount to read/write as given to the
|
---|
846 | * PDMIMEDIAEX::pfnIoReqRead or PDMIMEDIAEX::pfnIoReqWrite call.
|
---|
847 | * For SCSI commands this returns the transfer size as given in the provided CDB.
|
---|
848 | */
|
---|
849 | DECLR3CALLBACKMEMBER(int, pfnIoReqQueryXferSize, (PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, size_t *pcbXfer));
|
---|
850 |
|
---|
851 | /**
|
---|
852 | * Cancels all I/O active requests.
|
---|
853 | *
|
---|
854 | * @returns VBox status code.
|
---|
855 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
856 | * @thread Any thread.
|
---|
857 | */
|
---|
858 | DECLR3CALLBACKMEMBER(int, pfnIoReqCancelAll, (PPDMIMEDIAEX pInterface));
|
---|
859 |
|
---|
860 | /**
|
---|
861 | * Cancels a I/O request identified by the ID.
|
---|
862 | *
|
---|
863 | * @returns VBox status code.
|
---|
864 | * @retval VERR_PDM_MEDIAEX_IOREQID_NOT_FOUND if the given ID could not be found in the active request list.
|
---|
865 | * (The request has either completed already or an invalid ID was given).
|
---|
866 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
867 | * @param uIoReqId The I/O request ID
|
---|
868 | * @thread Any thread.
|
---|
869 | */
|
---|
870 | DECLR3CALLBACKMEMBER(int, pfnIoReqCancel, (PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQID uIoReqId));
|
---|
871 |
|
---|
872 | /**
|
---|
873 | * Start a reading request.
|
---|
874 | *
|
---|
875 | * @returns VBox status code.
|
---|
876 | * @retval VERR_PDM_MEDIAEX_IOREQ_CANCELED if the request was canceled by a call to
|
---|
877 | * PDMIMEDIAEX::pfnIoReqCancel.
|
---|
878 | * @retval VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS if the request was successfully submitted but is still in progress.
|
---|
879 | * Completion will be notified through PDMIMEDIAEXPORT::pfnIoReqCompleteNotify with the appropriate status code.
|
---|
880 | * @retval VINF_SUCCESS if the request completed successfully.
|
---|
881 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
882 | * @param hIoReq The I/O request to associate the read with.
|
---|
883 | * @param off Offset to start reading from. Must be aligned to a sector boundary.
|
---|
884 | * @param cbRead Number of bytes to read. Must be aligned to a sector boundary.
|
---|
885 | * @thread Any thread.
|
---|
886 | */
|
---|
887 | DECLR3CALLBACKMEMBER(int, pfnIoReqRead, (PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, uint64_t off, size_t cbRead));
|
---|
888 |
|
---|
889 | /**
|
---|
890 | * Start a writing request.
|
---|
891 | *
|
---|
892 | * @returns VBox status code.
|
---|
893 | * @retval VERR_PDM_MEDIAEX_IOREQ_CANCELED if the request was canceled by a call to
|
---|
894 | * PDMIMEDIAEX::pfnIoReqCancel.
|
---|
895 | * @retval VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS if the request was successfully submitted but is still in progress.
|
---|
896 | * Completion will be notified through PDMIMEDIAEXPORT::pfnIoReqCompleteNotify with the appropriate status code.
|
---|
897 | * @retval VINF_SUCCESS if the request completed successfully.
|
---|
898 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
899 | * @param hIoReq The I/O request to associate the write with.
|
---|
900 | * @param off Offset to start reading from. Must be aligned to a sector boundary.
|
---|
901 | * @param cbWrite Number of bytes to write. Must be aligned to a sector boundary.
|
---|
902 | * @thread Any thread.
|
---|
903 | */
|
---|
904 | DECLR3CALLBACKMEMBER(int, pfnIoReqWrite, (PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, uint64_t off, size_t cbWrite));
|
---|
905 |
|
---|
906 | /**
|
---|
907 | * Flush everything to disk.
|
---|
908 | *
|
---|
909 | * @returns VBox status code.
|
---|
910 | * @retval VERR_PDM_MEDIAEX_IOREQ_CANCELED if the request was canceled by a call to
|
---|
911 | * PDMIMEDIAEX::pfnIoReqCancel.
|
---|
912 | * @retval VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS if the request was successfully submitted but is still in progress.
|
---|
913 | * Completion will be notified through PDMIMEDIAEXPORT::pfnIoReqCompleteNotify with the appropriate status code.
|
---|
914 | * @retval VINF_SUCCESS if the request completed successfully.
|
---|
915 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
916 | * @param hIoReq The I/O request to associate the flush with.
|
---|
917 | * @thread Any thread.
|
---|
918 | */
|
---|
919 | DECLR3CALLBACKMEMBER(int, pfnIoReqFlush, (PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq));
|
---|
920 |
|
---|
921 | /**
|
---|
922 | * Discards the given range.
|
---|
923 | *
|
---|
924 | * @returns VBox status code.
|
---|
925 | * @retval VERR_PDM_MEDIAEX_IOREQ_CANCELED if the request was canceled by a call to
|
---|
926 | * PDMIMEDIAEX::pfnIoReqCancel.
|
---|
927 | * @retval VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS if the request was successfully submitted but is still in progress.
|
---|
928 | * Completion will be notified through PDMIMEDIAEXPORT::pfnIoReqCompleteNotify with the appropriate status code.
|
---|
929 | * @retval VINF_SUCCESS if the request completed successfully.
|
---|
930 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
931 | * @param hIoReq The I/O request to associate the discard with.
|
---|
932 | * @param cRangesMax The maximum number of ranges this request has associated, this must not be accurate
|
---|
933 | * but can actually be bigger than the amount of ranges actually available.
|
---|
934 | * @thread Any thread.
|
---|
935 | */
|
---|
936 | DECLR3CALLBACKMEMBER(int, pfnIoReqDiscard, (PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, unsigned cRangesMax));
|
---|
937 |
|
---|
938 | /**
|
---|
939 | * Send a raw command to the underlying device (CDROM).
|
---|
940 | *
|
---|
941 | * @returns VBox status code.
|
---|
942 | * @retval VERR_PDM_MEDIAEX_IOREQ_CANCELED if the request was canceled by a call to
|
---|
943 | * PDMIMEDIAEX::pfnIoReqCancel.
|
---|
944 | * @retval VINF_PDM_MEDIAEX_IOREQ_IN_PROGRESS if the request was successfully submitted but is still in progress.
|
---|
945 | * Completion will be notified through PDMIMEDIAEXPORT::pfnIoReqCompleteNotify with the appropriate status code.
|
---|
946 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
947 | * @param hIoReq The I/O request to associate the command with.
|
---|
948 | * @param uLun The LUN the command is for.
|
---|
949 | * @param pbCdb The SCSI CDB containing the command.
|
---|
950 | * @param cbCdb Size of the CDB in bytes.
|
---|
951 | * @param enmTxDir Direction of transfer.
|
---|
952 | * @param cbBuf Size of the transfer buffer.
|
---|
953 | * @param pabSense Where to store the optional sense key.
|
---|
954 | * @param cbSense Size of the sense key buffer.
|
---|
955 | * @param pu8ScsiSts Where to store the SCSI status on success.
|
---|
956 | * @param cTimeoutMillies Command timeout in milliseconds.
|
---|
957 | * @thread Any thread.
|
---|
958 | */
|
---|
959 | DECLR3CALLBACKMEMBER(int, pfnIoReqSendScsiCmd,(PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, uint32_t uLun,
|
---|
960 | const uint8_t *pbCdb, size_t cbCdb, PDMMEDIAEXIOREQSCSITXDIR enmTxDir,
|
---|
961 | size_t cbBuf, uint8_t *pabSense, size_t cbSense, uint8_t *pu8ScsiSts,
|
---|
962 | uint32_t cTimeoutMillies));
|
---|
963 |
|
---|
964 | /**
|
---|
965 | * Returns the number of active I/O requests.
|
---|
966 | *
|
---|
967 | * @returns Number of active I/O requests.
|
---|
968 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
969 | * @thread Any thread.
|
---|
970 | */
|
---|
971 | DECLR3CALLBACKMEMBER(uint32_t, pfnIoReqGetActiveCount, (PPDMIMEDIAEX pInterface));
|
---|
972 |
|
---|
973 | /**
|
---|
974 | * Returns the number of suspended requests.
|
---|
975 | *
|
---|
976 | * @returns Number of suspended I/O requests.
|
---|
977 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
978 | * @thread Any thread.
|
---|
979 | */
|
---|
980 | DECLR3CALLBACKMEMBER(uint32_t, pfnIoReqGetSuspendedCount, (PPDMIMEDIAEX pInterface));
|
---|
981 |
|
---|
982 | /**
|
---|
983 | * Gets the first suspended request handle.
|
---|
984 | *
|
---|
985 | * @returns VBox status code.
|
---|
986 | * @retval VERR_NOT_FOUND if there is no suspended request waiting.
|
---|
987 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
988 | * @param phIoReq Where to store the request handle on success.
|
---|
989 | * @param ppvIoReqAlloc Where to store the pointer to the allocator specific memory on success.
|
---|
990 | * @thread Any thread.
|
---|
991 | *
|
---|
992 | * @note This should only be called when the VM is suspended to make sure the request doesn't suddenly
|
---|
993 | * changes into the active state again. The only purpose for this method for now is to make saving the state
|
---|
994 | * possible without breaking saved state versions.
|
---|
995 | */
|
---|
996 | DECLR3CALLBACKMEMBER(int, pfnIoReqQuerySuspendedStart, (PPDMIMEDIAEX pInterface, PPDMMEDIAEXIOREQ phIoReq, void **ppvIoReqAlloc));
|
---|
997 |
|
---|
998 | /**
|
---|
999 | * Gets the next suspended request handle.
|
---|
1000 | *
|
---|
1001 | * @returns VBox status code.
|
---|
1002 | * @retval VERR_NOT_FOUND if there is no suspended request waiting.
|
---|
1003 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1004 | * @param hIoReq The current request handle.
|
---|
1005 | * @param phIoReqNext Where to store the request handle on success.
|
---|
1006 | * @param ppvIoReqAllocNext Where to store the pointer to the allocator specific memory on success.
|
---|
1007 | * @thread Any thread.
|
---|
1008 | *
|
---|
1009 | * @note This should only be called when the VM is suspended to make sure the request doesn't suddenly
|
---|
1010 | * changes into the active state again. The only purpose for this method for now is to make saving the state
|
---|
1011 | * possible without breaking saved state versions.
|
---|
1012 | */
|
---|
1013 | DECLR3CALLBACKMEMBER(int, pfnIoReqQuerySuspendedNext, (PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq,
|
---|
1014 | PPDMMEDIAEXIOREQ phIoReqNext, void **ppvIoReqAllocNext));
|
---|
1015 |
|
---|
1016 | /**
|
---|
1017 | * Saves the given I/O request state in the provided saved state unit.
|
---|
1018 | *
|
---|
1019 | * @returns VBox status code.
|
---|
1020 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1021 | * @param pSSM The SSM handle.
|
---|
1022 | * @param hIoReq The request handle to save.
|
---|
1023 | */
|
---|
1024 | DECLR3CALLBACKMEMBER(int, pfnIoReqSuspendedSave, (PPDMIMEDIAEX pInterface, PSSMHANDLE pSSM, PDMMEDIAEXIOREQ hIoReq));
|
---|
1025 |
|
---|
1026 | /**
|
---|
1027 | * Load a suspended request state from the given saved state unit and link it into the suspended list.
|
---|
1028 | *
|
---|
1029 | * @returns VBox status code.
|
---|
1030 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1031 | * @param pSSM The SSM handle to read the state from.
|
---|
1032 | * @param hIoReq The request handle to load the state into.
|
---|
1033 | */
|
---|
1034 | DECLR3CALLBACKMEMBER(int, pfnIoReqSuspendedLoad, (PPDMIMEDIAEX pInterface, PSSMHANDLE pSSM, PDMMEDIAEXIOREQ hIoReq));
|
---|
1035 |
|
---|
1036 | } PDMIMEDIAEX;
|
---|
1037 | /** PDMIMEDIAEX interface ID. */
|
---|
1038 | #define PDMIMEDIAEX_IID "1f82b709-a9f7-4928-ad50-e879c9bbeba1"
|
---|
1039 |
|
---|
1040 | /** @} */
|
---|
1041 |
|
---|
1042 | RT_C_DECLS_END
|
---|
1043 |
|
---|
1044 | #endif /* !VBOX_INCLUDED_vmm_pdmstorageifs_h */
|
---|