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