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