VirtualBox

Changeset 10715 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Jul 16, 2008 10:38:23 PM (16 years ago)
Author:
vboxsync
Message:

Merge async I/O for VMDK backend from private branch

Location:
trunk/include/VBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxHDD-new.h

    r10467 r10715  
    178178 * used for querying information, and nothing else. */
    179179#define VD_OPEN_FLAGS_INFO          RT_BIT(3)
     180/** Open image for asynchronous access.
     181 *  Only available if VD_CAP_ASYNC_IO is set
     182 *  Check with VDIsAsynchonousIoSupported wether
     183 *  asynchronous I/O is really supported for this file.
     184 */
     185#define VD_OPEN_FLAGS_ASYNC_IO      RT_BIT(4)
    180186/** Mask of valid flags. */
    181 #define VD_OPEN_FLAGS_MASK          (VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_HONOR_ZEROES | VD_OPEN_FLAGS_HONOR_SAME | VD_OPEN_FLAGS_INFO)
     187#define VD_OPEN_FLAGS_MASK          (VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_HONOR_ZEROES | VD_OPEN_FLAGS_HONOR_SAME | VD_OPEN_FLAGS_INFO | VD_OPEN_FLAGS_ASYNC_IO)
    182188/** @}*/
    183189
     
    196202/** Supports being used as differencing image format backend. */
    197203#define VD_CAP_DIFF                 RT_BIT(4)
     204/** Supports asynchronous I/O operations for at least some configurations. */
     205#define VD_CAP_ASYNC                RT_BIT(5)
    198206/** The backend operates on files. The caller needs to know to handle the
    199207 * location appropriately. */
    200208#define VD_CAP_FILE                 RT_BIT(6)
    201209/** @}*/
    202 
    203210
    204211/**
     
    213220} VDBACKENDINFO, *PVDBACKENDINFO;
    214221
    215 
    216 /**
    217  * Error message callback.
    218  *
    219  * @param   pvUser          The opaque data passed on container creation.
    220  * @param   rc              The VBox error code.
    221  * @param   RT_SRC_POS_DECL Use RT_SRC_POS.
    222  * @param   pszFormat       Error message format string.
    223  * @param   va              Error message arguments.
    224  */
    225 typedef DECLCALLBACK(void) FNVDERROR(void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va);
    226 /** Pointer to a FNVDERROR(). */
    227 typedef FNVDERROR *PFNVDERROR;
     222/**
     223 * Supported interface types.
     224 */
     225typedef enum VDINTERFACETYPE
     226{
     227    /** First valid interface. */
     228    VDINTERFACETYPE_FIRST = 0,
     229    /** Interface to pass error message to upper layers. */
     230    VDINTERFACETYPE_ERROR = VDINTERFACETYPE_FIRST,
     231    /** Interface for asynchronous I/O operations. */
     232    VDINTERFACETYPE_ASYNCIO,
     233    /** Interface for progress notification. */
     234    VDINTERFACETYPE_PROGRESS,
     235    /** invalid interface. */
     236    VDINTERFACETYPE_INVALID
     237} VDINTERFACETYPE;
     238
     239/**
     240 * Common structure for all interfaces.
     241 */
     242typedef struct VDINTERFACE
     243{
     244    /** Human readable interface name. */
     245    const char         *pszInterfaceName;
     246    /** The size of the struct. */
     247    uint32_t            cbSize;
     248    /** Pointer to the next common interface structure. */
     249    struct VDINTERFACE *pNext;
     250    /** Interface type. */
     251    VDINTERFACETYPE     enmInterface;
     252    /** Opaque user data which is passed on every call. */
     253    void               *pvUser;
     254    /** Pointer to the function call table of the interface.
     255     *  As this is opaque this must be casted to the right interface
     256     *  struct defined below based on the interface type in enmInterface. */
     257    void               *pCallbacks;
     258} VDINTERFACE, *PVDINTERFACE;
     259/** Pointer to a const PVDINTERFACE. */
     260typedef const PVDINTERFACE PCVDINTERFACE;
     261
     262/**
     263 * Helper functions to handle interface lists.
     264 */
     265
     266/**
     267 * Get a specific interface from a list of interfaces specified by the type.
     268 *
     269 * @returns Pointer to the matching interface or NULL if none was found.
     270 * @param   pInterfaces     Pointer to the first interface in the list.
     271 * @param   enmInterface    Interface to search for.
     272 */
     273DECLINLINE(PVDINTERFACE) VDGetInterfaceFromList(PVDINTERFACE pInterfaces, VDINTERFACETYPE enmInterface)
     274{
     275    AssertMsgReturn(   (enmInterface >= VDINTERFACETYPE_FIRST)
     276                    && (enmInterface < VDINTERFACETYPE_INVALID),
     277                    ("enmInterface=%u", enmInterface), NULL);
     278
     279    while (pInterfaces)
     280    {
     281        /* Sanity checks. */
     282        AssertMsgBreak(pInterfaces->cbSize == sizeof(VDINTERFACE),
     283                       ("cbSize=%u\n", pInterfaces->cbSize));
     284                       
     285        if (pInterfaces->enmInterface == enmInterface)
     286            return pInterfaces;
     287        pInterfaces = pInterfaces->pNext;
     288    }
     289
     290    /* No matching interface was found. */
     291    return NULL;
     292}
     293
     294/**
     295 * Initialize a common interface structure.
     296 *
     297 * @return VBox status code.
     298 * @param  pInterface   Pointer to an unitialized common interface structure.
     299 * @param  pszName      Name of the interface.
     300 * @param  enmInterface Type of the interface.
     301 * @param  pCallbacks   The callback table of the interface.
     302 * @param  pvUser       Opaque user data passed on every function call.
     303 * @param  pNext        Pointer to the next supported interface if any.
     304 */
     305DECLINLINE(int) VDInterfaceCreate(PVDINTERFACE pInterface, const char *pszName,
     306                                  VDINTERFACETYPE enmInterface, void *pCallbacks,
     307                                  void *pvUser, PVDINTERFACE pNext)
     308{
     309
     310    /** Argument checks. */
     311    AssertMsgReturn(   (enmInterface >= VDINTERFACETYPE_FIRST)
     312                    && (enmInterface < VDINTERFACETYPE_INVALID),
     313                    ("enmInterface=%u", enmInterface), VERR_INVALID_PARAMETER);
     314
     315    AssertMsgReturn(VALID_PTR(pCallbacks),
     316                    ("pCallbacks=%#p", pCallbacks),
     317                    VERR_INVALID_PARAMETER);
     318
     319    pInterface->cbSize           = sizeof(VDINTERFACE);
     320    pInterface->pszInterfaceName = pszName;
     321    pInterface->enmInterface     = enmInterface;
     322    pInterface->pCallbacks       = pCallbacks;
     323    pInterface->pvUser           = pvUser;
     324    pInterface->pNext            = pNext;
     325    return VINF_SUCCESS;
     326}
     327
     328/**
     329 * Interface to deliver error messages to upper layers.
     330 */
     331typedef struct VDINTERFACEERROR
     332{
     333    /**
     334     * Size of the error interface.
     335     */
     336    uint32_t    cbSize;
     337
     338    /**
     339     * Interface type.
     340     */
     341    VDINTERFACETYPE enmInterface;
     342
     343    /**
     344     * Error message callback.
     345     *
     346     * @param   pvUser          The opaque data passed on container creation.
     347     * @param   rc              The VBox error code.
     348     * @param   RT_SRC_POS_DECL Use RT_SRC_POS.
     349     * @param   pszFormat       Error message format string.
     350     * @param   va              Error message arguments.
     351     */
     352    DECLR3CALLBACKMEMBER(void, pfnError, (void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va));
     353
     354} VDINTERFACEERROR, *PVDINTERFACEERROR;
     355
     356/**
     357 * Get error interface from opaque callback table.
     358 *
     359 * @return Pointer to the callback table.
     360 * @param  pCallbacks Opaque interface pointer.
     361 */
     362DECLINLINE(PVDINTERFACEERROR) VDGetInterfaceError(void *pCallbacks)
     363{
     364    PVDINTERFACEERROR pInterfaceError = (PVDINTERFACEERROR)pCallbacks;
     365
     366    /* Do basic checks. */
     367    AssertMsgReturn(   (pInterfaceError->cbSize == sizeof(VDINTERFACEERROR))
     368                    && (pInterfaceError->enmInterface == VDINTERFACETYPE_ERROR),
     369                    ("Not an error interface\n"), NULL);
     370
     371    return pInterfaceError;
     372}
     373
     374/**
     375 * Completion callback which is called by the interface owner
     376 * to inform the backend that a task finished.
     377 *
     378 * @returns VBox status code.
     379 * @param   pvUser          Opaque user data which is passed on request submission.
     380 */
     381typedef DECLCALLBACK(int) FNVDCOMPLETED(void *pvUser);
     382/** Pointer to FNVDCOMPLETED() */
     383typedef FNVDCOMPLETED *PFNVDCOMPLETED;
     384
     385
     386/**
     387 * Support interface for asynchronous I/O
     388 */
     389typedef struct VDINTERFACEASYNCIO
     390{
     391    /**
     392     * Size of the async interface.
     393     */
     394    uint32_t    cbSize;
     395
     396    /**
     397     * Interface type.
     398     */
     399    VDINTERFACETYPE enmInterface;
     400
     401    /**
     402     * Open callback
     403     *
     404     * @returns VBox status code.
     405     * @param   pvUser          The opaque data passed on container creation.
     406     * @param   pszLocation     Name of the location to open.
     407     * @param   fReadonly       Whether to open the storage medium read only.
     408     * @param   ppStorage       Where to store the opaque storage handle.
     409     */
     410    DECLR3CALLBACKMEMBER(int, pfnOpen, (void *pvUser, const char *pszLocation, bool fReadonly, void **ppStorage));
     411
     412    /**
     413     * Close callback.
     414     *
     415     * @returns VBox status code.
     416     * @param   pvUser          The opaque data passed on container creation.
     417     * @param   pStorage        The opaque storage handle to close.
     418     */
     419    DECLR3CALLBACKMEMBER(int, pfnClose, (void *pvUser, void *pStorage));
     420
     421    /**
     422     * Synchronous write callback.
     423     *
     424     * @returns VBox status code.
     425     * @param   pvUser          The opaque data passed on container creation.
     426     * @param   pStorage        The storage handle to use.
     427     * @param   uOffset         The offset to start from.
     428     * @þaram   cbWrite         How many bytes to write.
     429     * @param   pvBuf           Pointer to the bits need to be written.
     430     * @param   pcbWritten      Where to store how many bytes where actually written.
     431     */
     432    DECLR3CALLBACKMEMBER(int, pfnWrite, (void *pvUser, void *pStorage, uint64_t uOffset,
     433                                         size_t cbWrite, const void *pvBuf, size_t *pcbWritten));
     434
     435    /**
     436     * Synchronous read callback.
     437     *
     438     * @returns VBox status code.
     439     * @param   pvUser          The opaque data passed on container creation.
     440     * @param   pStorage        The storage handle to use.
     441     * @param   uOffset         The offset to start from.
     442     * @þaram   cbRead          How many bytes to read.
     443     * @param   pvBuf           Where to store the read bits.
     444     * @param   pcbRead         Where to store how many bytes where actually read.
     445     */
     446    DECLR3CALLBACKMEMBER(int, pfnRead, (void *pvUser, void *pStorage, uint64_t uOffset,
     447                                        size_t cbRead, void *pvBuf, size_t *pcbRead));
     448
     449    /**
     450     * Flush data to the storage backend.
     451     *
     452     * @returns VBox statis code.
     453     * @param   pvUser          The opaque data passed on container creation.
     454     * @param   pStorage        The storage handle to flush.
     455     */
     456    DECLR3CALLBACKMEMBER(int, pfnFlush, (void *pvUser, void *pStorage));
     457
     458    /**
     459     * Prepare an asynchronous read task.
     460     *
     461     * @returns VBox status code.
     462     * @param   pvUser         The opqaue user data passed on container creation.
     463     * @param   pStorage       The storage handle.
     464     * @param   uOffset        The offset to start reading from.
     465     * @param   pvBuf          Where to store read bits.
     466     * @param   cbRead         How many bytes to read.
     467     * @param   ppTask         Where to store the opaque task handle.
     468     */
     469    DECLR3CALLBACKMEMBER(int, pfnPrepareRead, (void *pvUser, void *pStorage, uint64_t uOffset,
     470                                               void *pvBuf, size_t cbRead, void **ppTask));
     471
     472    /**
     473     * Prepare an asynchronous write task.
     474     *
     475     * @returns VBox status code.
     476     * @param   pvUser         The opaque user data passed on conatiner creation.
     477     * @param   pStorage       The storage handle.
     478     * @param   uOffset        The offset to start writing to.
     479     * @param   pvBuf          Where to read the data from.
     480     * @param   cbWrite        How many bytes to write.
     481     * @param   ppTask         Where to store the opaque task handle.
     482     */
     483    DECLR3CALLBACKMEMBER(int, pfnPrepareWrite, (void *pvUser, void *pStorage, uint64_t uOffset,
     484                                                void *pvBuf, size_t cbWrite, void **ppTask));
     485
     486    /**
     487     * Submit an array of tasks for processing
     488     *
     489     * @returns VBox status code.
     490     * @param   pvUser        The opaque user data passed on container creation.
     491     * @param   apTasks       Array of task handles to submit.
     492     * @param   cTasks        How many tasks to submit.
     493     * @param   pvUser2       User data which is passed on completion.
     494     * @param   pvUserCaller  Opaque user data the caller of VDAsyncWrite/Read passed.
     495     * @param   pfnTasksCompleted Pointer to callback which is called on request completion.
     496     */
     497    DECLR3CALLBACKMEMBER(int, pfnTasksSubmit, (void *pvUser, void *apTasks[], unsigned cTasks, void *pvUser2,
     498                                               void *pvUserCaller, PFNVDCOMPLETED pfnTasksCompleted));
     499
     500} VDINTERFACEASYNCIO, *PVDINTERFACEASYNCIO;
     501
     502/**
     503 * Get async I/O interface from opaque callback table.
     504 *
     505 * @return Pointer to the callback table.
     506 * @param  pCallbacks Opaque interface pointer.
     507 */
     508DECLINLINE(PVDINTERFACEASYNCIO) VDGetInterfaceAsyncIO(void *pCallbacks)
     509{
     510    PVDINTERFACEASYNCIO pInterfaceAsyncIO = (PVDINTERFACEASYNCIO)pCallbacks;
     511
     512    /* Do basic checks. */
     513    AssertMsgReturn(   (pInterfaceAsyncIO->cbSize == sizeof(VDINTERFACEASYNCIO))
     514                    && (pInterfaceAsyncIO->enmInterface == VDINTERFACETYPE_ASYNCIO),
     515                    ("Not an async I/O interface\n"), NULL);
     516
     517    return pInterfaceAsyncIO;
     518}
     519
     520/**
     521 * Progress notification interface
     522 */
     523typedef struct VDINTERFACEPROGRESS
     524{
     525    /**
     526     * Size of the progress interface.
     527     */
     528    uint32_t    cbSize;
     529
     530    /**
     531     * Interface type.
     532     */
     533    VDINTERFACETYPE enmInterface;
     534
     535    /**
     536     * Progress notification callbacks.
     537     */
     538    PFNVMPROGRESS   pfnProgress;
     539} VDINTERFACEPROGRESS, *PVDINTERFACEPROGRESS;
     540
     541/**
     542 * Get progress interface from opaque callback table.
     543 *
     544 * @return Pointer to the callback table.
     545 * @param  pCallbacks Opaque interface pointer.
     546 */
     547DECLINLINE(PVDINTERFACEPROGRESS) VDGetInterfaceProgress(void *pCallbacks)
     548{
     549    PVDINTERFACEPROGRESS pInterfaceProgress = (PVDINTERFACEPROGRESS)pCallbacks;
     550
     551    /* Do basic checks. */
     552    AssertMsgReturn(   (pInterfaceProgress->cbSize == sizeof(VDINTERFACEPROGRESS))
     553                    && (pInterfaceProgress->enmInterface == VDINTERFACETYPE_PROGRESS),
     554                    ("Not an progress notification interface\n"), NULL);
     555
     556    return pInterfaceProgress;
     557}
    228558
    229559
     
    250580                                unsigned *pcEntriesUsed);
    251581
     582/**
     583 * Lists the capablities of a backend indentified by its name.
     584 * Free all returned names with RTStrFree() when you no longer need them.
     585 *
     586 * @returns VBox status code.
     587 * @param   pszBackend      The backend name.
     588 * @param   pEntries        Pointer to an entry.
     589 */
     590VBOXDDU_DECL(int) VDBackendInfoOne(const char *pszBackend, PVDBACKENDINFO pEntry);
    252591
    253592/**
     
    256595 *
    257596 * @returns VBox status code.
    258  * @param   pfnError        Callback for setting extended error information.
    259  * @param   pvErrorUser     Opaque parameter for pfnError.
     597 * @param   pInterfaces     Pointer to the first supported interface.
    260598 * @param   ppDisk          Where to store the reference to HDD container.
    261599 */
    262 VBOXDDU_DECL(int) VDCreate(PFNVDERROR pfnError, void *pvErrorUser,
    263                            PVBOXHDD *ppDisk);
     600VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pInterfaces, PVBOXHDD *ppDisk);
    264601
    265602/**
     
    559896
    560897/**
     898 * List the capabilities of image backend in HDD container.
     899 *
     900 * @returns VBox status code.
     901 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
     902 * @param   pDisk           Pointer to the HDD container.
     903 * @param   nImage          Image number, counts from 0. 0 is always base image of container.
     904 * @param   pbackendInfo    Where to store the backend information.
     905 */
     906VBOXDDU_DECL(int) VDBackendInfoSingle(PVBOXHDD pDisk, unsigned nImage,
     907                                      PVDBACKENDINFO pBackendInfo);
     908
     909/**
    561910 * Get flags of image in HDD container.
    562911 *
     
    7141063VBOXDDU_DECL(void) VDDumpImages(PVBOXHDD pDisk);
    7151064
     1065
     1066/**
     1067 * Query if asynchronous operations are supported for this disk.
     1068 *
     1069 * @returns VBox status code.
     1070 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
     1071 * @param   pDisk           Pointer to the HDD container.
     1072 * @param   nImage          Image number, counts from 0. 0 is always base image of container.
     1073 * @param   pfAIOSupported  Where to store if async IO is supported.
     1074 */
     1075VBOXDDU_DECL(int) VDImageIsAsyncIOSupported(PVBOXHDD pDisk, unsigned nImage, bool *pfAIOSupported);
     1076
     1077
     1078/**
     1079 * Start a asynchronous read request.
     1080 *
     1081 * @returns VBox status code.
     1082 * @param   pDisk           Pointer to the HDD container.
     1083 * @param   uOffset         The offset of the virtual disk to read from.
     1084 * @param   cbRead          How many bytes to read.
     1085 * @param   paSeg           Pointer to an array of segments.
     1086 * @param   cSeg            Number of segments in the array.
     1087 * @param   pvUser          User data which is passed on completion
     1088 */
     1089VBOXDDU_DECL(int) VDAsyncRead(PVBOXHDD pDisk, uint64_t uOffset, size_t cbRead,
     1090                              PPDMDATASEG paSeg, unsigned cSeg,
     1091                              void *pvUser);
     1092
     1093
     1094/**
     1095 * Start a asynchronous write request.
     1096 *
     1097 * @returns VBox status code.
     1098 * @param   pDisk           Pointer to the HDD container.
     1099 * @param   uOffset         The offset of the virtual disk to write to.
     1100 * @param   cbWrtie         How many bytes to write.
     1101 * @param   paSeg           Pointer to an array of segments.
     1102 * @param   cSeg            Number of segments in the array.
     1103 * @param   pvUser          User data which is passed on completion.
     1104 */
     1105VBOXDDU_DECL(int) VDAsyncWrite(PVBOXHDD pDisk, uint64_t uOffset, size_t cbWrite,
     1106                               PPDMDATASEG paSeg, unsigned cSeg,
     1107                               void *pvUser);
     1108
     1109
    7161110__END_DECLS
    7171111
  • trunk/include/VBox/err.h

    r10530 r10715  
    10491049/** Configuration value not found. */
    10501050#define VERR_VDI_VALUE_NOT_FOUND                    (-3216)
     1051/** Asynchronous I/O request finished. */
     1052#define VINF_VDI_ASYNC_IO_FINISHED                  3218
     1053/** Asynchronous I/O is not finished yet. */
     1054#define VERR_VDI_ASYNC_IO_IN_PROGRESS               (-3219)
    10511055/** @} */
    10521056
  • trunk/include/VBox/pdmifs.h

    r9765 r10715  
    11151115
    11161116
    1117 /**
    1118  * Data transport buffer (scatter/gather)
    1119  */
    1120 typedef struct PDMIDATATRANSPORTSEG
    1121 {
    1122     /** Length of buffer in entry. */
    1123     size_t  cbSeg;
    1124     /** Pointer to the start of the buffer. */
    1125     void   *pvSeg;
    1126 } PDMIDATATRANSPORTSEG;
    1127 /** Pointer to a data transport segment. */
    1128 typedef PDMIDATATRANSPORTSEG *PPDMIDATATRANSPORTSEG;
    1129 /** Pointer to a const data transport segment. */
    1130 typedef PDMIDATATRANSPORTSEG const *PCPDMIDATATRANSPORTSEG;
    1131 
    1132 
    11331117/** Pointer to an asynchronous iSCSI transport driver interface. */
    11341118typedef struct PDMIISCSITRANSPORTASYNC *PPDMIISCSITRANSPORTASYNC;
     
    12071191{
    12081192    /**
    1209      * Notify completion of a read task.
    1210      *
    1211      * @returns VBox status code.
    1212      * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1213      * @param   off             Offset the task read from.
    1214      * @param   pSeg            Pointer to the first element in the gather list.
    1215      * @param   cSeg            Number of segments in the gather list.
    1216      * @param   cbRead          Number of bytes read.
    1217      * @param   pvUser          The user argument given in pfnStartRead.
    1218      * @thread  Any thread.
    1219      */
    1220     DECLR3CALLBACKMEMBER(int, pfnReadCompleteNotify, (PPDMIBLOCKASYNCPORT pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg, size_t cbRead, void *pvUser));
    1221 
    1222     /**
    1223      * Notify completion of a write task.
    1224      *
    1225      * @returns VBox status code.
    1226      * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1227      * @param   off             Offset the task has written to.
    1228      * @param   pSeg            Pointer to the first element in the scatter list.
    1229      * @param   cSeg            Number of segments in the scatter list.
    1230      * @param   cbWritten       Number of bytes actually written.
    1231      * @param   pvUser          The user argument given in pfnStartWrite.
    1232      * @thread  Any thread.
    1233      */
    1234     DECLR3CALLBACKMEMBER(int, pfnWriteCompleteNotify, (PPDMIBLOCKASYNCPORT pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg, size_t cbWritten, void *pvUser));
     1193     * Notify completion of a asynchronous transfer.
     1194     *
     1195     * @returns VBox status code.
     1196     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     1197     * @param   pvUser          The user argument given in pfnStartWrite/Read.
     1198     * @thread  Any thread.
     1199     */
     1200    DECLR3CALLBACKMEMBER(int, pfnTransferCompleteNotify, (PPDMIBLOCKASYNCPORT pInterface, void *pvUser));
    12351201} PDMIBLOCKASYNCPORT;
    12361202
     
    12561222     * @thread  Any thread.
    12571223     */
    1258     DECLR3CALLBACKMEMBER(int, pfnStartRead,(PPDMIBLOCKASYNC pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg, size_t cbRead, void *pvUser));
     1224    DECLR3CALLBACKMEMBER(int, pfnStartRead,(PPDMIBLOCKASYNC pInterface, uint64_t off, PPDMDATASEG pSeg, unsigned cSeg, size_t cbRead, void *pvUser));
    12591225
    12601226    /**
     
    12701236     * @thread  Any thread.
    12711237     */
    1272     DECLR3CALLBACKMEMBER(int, pfnStartWrite,(PPDMIBLOCKASYNC pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg, size_t cbWrite, void *pvUser));
     1238    DECLR3CALLBACKMEMBER(int, pfnStartWrite,(PPDMIBLOCKASYNC pInterface, uint64_t off, PPDMDATASEG pSeg, unsigned cSeg, size_t cbWrite, void *pvUser));
    12731239
    12741240} PDMIBLOCKASYNC;
     
    12841250{
    12851251    /**
    1286      * Notify completion of a read task.
    1287      *
    1288      * @returns VBox status code.
    1289      * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1290      * @param   off             Offset the task read from.
    1291      * @param   pSeg            Pointer to the first element in the scatter list.
    1292      * @param   cSeg            Number of entries in the list.
    1293      * @param   cbRead          Number of bytes read.
    1294      * @param   pvUser          The user argument given in pfnStartRead.
    1295      * @thread  Any thread.
    1296      */
    1297     DECLR3CALLBACKMEMBER(int, pfnReadCompleteNotify, (PPDMIMEDIAASYNCPORT pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg, size_t cbRead, void *pvUser));
    1298 
    1299     /**
    1300      * Notify completion of a write task.
    1301      *
    1302      * @returns VBox status code.
    1303      * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1304      * @param   off             Offset the task has written to.
    1305      * @param   pSeg            Pointer to the first element in the gather list.
    1306      * @param   cSeg            Number of entries in the list.
    1307      * @param   cbWritten       Number of bytes actually written.
     1252     * Notify completion of a task.
     1253     *
     1254     * @returns VBox status code.
     1255     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    13081256     * @param   pvUser          The user argument given in pfnStartWrite.
    13091257     * @thread  Any thread.
    13101258     */
    1311     DECLR3CALLBACKMEMBER(int, pfnWriteCompleteNotify, (PPDMIMEDIAASYNCPORT pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg, size_t cbWritten, void *pvUser));
     1259    DECLR3CALLBACKMEMBER(int, pfnTransferCompleteNotify, (PPDMIMEDIAASYNCPORT pInterface, void *pvUser));
    13121260} PDMIMEDIAASYNCPORT;
    13131261
     
    13331281     * @thread  Any thread.
    13341282     */
    1335     DECLR3CALLBACKMEMBER(int, pfnStartRead,(PPDMIMEDIAASYNC pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg, size_t cbRead, void *pvUser));
     1283    DECLR3CALLBACKMEMBER(int, pfnStartRead,(PPDMIMEDIAASYNC pInterface, uint64_t off, PPDMDATASEG pSeg, unsigned cSeg, size_t cbRead, void *pvUser));
    13361284
    13371285    /**
     
    13471295     * @thread  Any thread.
    13481296     */
    1349     DECLR3CALLBACKMEMBER(int, pfnStartWrite,(PPDMIMEDIAASYNC pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg, size_t cbWrite, void *pvUser));
     1297    DECLR3CALLBACKMEMBER(int, pfnStartWrite,(PPDMIMEDIAASYNC pInterface, uint64_t off, PPDMDATASEG pSeg, unsigned cSeg, size_t cbWrite, void *pvUser));
    13501298
    13511299} PDMIMEDIAASYNC;
     
    13611309{
    13621310    /**
    1363      * Notify completion of a read task.
    1364      *
    1365      * @returns VBox status code.
    1366      * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1367      * @param   off             Offset the task read from.
    1368      * @param   pSeg            Pointer to the first element in the scatter list.
    1369      * @param   cSeg            Number of entries in the list.
    1370      * @param   cbRead          Number of bytes read.
    1371      * @param   pvUser          The user argument given in pfnStartRead.
    1372      * @thread  Any thread.
    1373      */
    1374     DECLR3CALLBACKMEMBER(int, pfnReadCompleteNotify, (PPDMITRANSPORTASYNCPORT pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg,
    1375                                                       size_t cbRead, void *pvUser));
    1376 
    1377     /**
    1378      * Notify completion of a write task.
    1379      *
    1380      * @returns VBox status code.
    1381      * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1382      * @param   off             Offset the task has written to.
    1383      * @param   pSeg            Pointer to the first element in the gather list.
    1384      * @param   cSeg            Number of entries in the list.
    1385      * @param   cbWritten       Number of bytes actually written.
    1386      * @param   pvUser          The user argument given in pfnStartWrite.
    1387      * @thread  Any thread.
    1388      */
    1389     DECLR3CALLBACKMEMBER(int, pfnWriteCompleteNotify, (PPDMITRANSPORTASYNCPORT pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg,
    1390                                                        size_t cbWritten, void *pvUser));
     1311     * Notify completion of tasks.
     1312     *
     1313     * @returns VBox status code.
     1314     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     1315     * @param   pvUser          The user argument given in pfnTasksSubmit.
     1316     * @thread  Any thread.
     1317     */
     1318    DECLR3CALLBACKMEMBER(int, pfnTaskCompleteNotify, (PPDMITRANSPORTASYNCPORT pInterface, void *pvUser));
     1319
    13911320} PDMITRANSPORTASYNCPORT;
    13921321
     
    14061335     * @returns VBox status code.
    14071336     * @param   pInterface      Pointer to the interface structure containint the called function pointer.
     1337     * @param   pStorage        The storage handle to read from.
    14081338     * @param   off             Offset to start reading from.
    1409      * @param   pvBuf           here to store the read bits.
     1339     * @param   pvBuf           Where to store the read bits.
    14101340     * @param   cbRead          Number of bytes to read.
    14111341     * @param   pcbRead         Where to store the number of bytes actually read.
    14121342     * @thread  Any thread.
    14131343     */
    1414     DECLR3CALLBACKMEMBER(int, pfnReadSynchronous, (PPDMITRANSPORTASYNC pInterface, uint64_t off, void *pvBuf, size_t cbRead, size_t *pcbRead));
     1344    DECLR3CALLBACKMEMBER(int, pfnReadSynchronous, (PPDMITRANSPORTASYNC pInterface, void *pStorage,
     1345                                                   uint64_t off, void *pvBuf, size_t cbRead, size_t *pcbRead));
    14151346
    14161347    /**
     
    14201351     * @returns VBox status code.
    14211352     * @param   pInterface      Pointer to the interface structure containint the called function pointer.
     1353     * @param   pStorage        The storage handle to write to.
    14221354     * @param   off             Offset to start reading from.
    1423      * @param   pvBuf           here to store the read bits.
     1355     * @param   pvBuf           Pointer to the buffer which contains the data to write.
    14241356     * @param   cbWrite         Number of bytes to read.
    14251357     * @param   pcbWritten      Where to store the number of bytes actually read.
    14261358     * @thread  Any thread.
    14271359     */
    1428     DECLR3CALLBACKMEMBER(int, pfnWriteSynchronous, (PPDMITRANSPORTASYNC pInterface, uint64_t off, void *pvBuf, size_t cbWrite, size_t *pcbWritten));
    1429 
    1430     /**
    1431      * Start asynchronous read.
    1432      *
    1433      * @returns VBox status code.
    1434      * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1435      * @param   off             Offset to start reading from.
    1436      * @param   pSeg            Pointer to the first element in the scatter list.
    1437      * @param   cSeg            Number of entries in the list.
    1438      * @param   cbRead          Number of bytes to read.
    1439      * @param   pvUser          User argument returned in completion callback.
    1440      * @thread  Any thread.
    1441      */
    1442     DECLR3CALLBACKMEMBER(int, pfnReadStartAsynchronous,(PPDMITRANSPORTASYNC pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg,
    1443                                                         size_t cbRead, void *pvUser));
    1444 
    1445     /**
    1446      * Start asynchronous write.
    1447      *
    1448      * @returns VBox status code.
    1449      * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1450      * @param   off             Offset to start writing at.
    1451      * @param   pSeg            Pointer to the first element in the gather list.
    1452      * @param   cSeg            Number of entries in the list.
    1453      * @param   cbWrite         Number of bytes to write.
    1454      * @param   pvUser          User argument returned in completion callback.
    1455      * @thread  Any thread.
    1456      */
    1457     DECLR3CALLBACKMEMBER(int, pfnWriteStartAsynchronous,(PPDMITRANSPORTASYNC pInterface, uint64_t off, PPDMIDATATRANSPORTSEG pSeg, unsigned cSeg,
    1458                                                          size_t cbWrite, void *pvUser));
     1360    DECLR3CALLBACKMEMBER(int, pfnWriteSynchronous, (PPDMITRANSPORTASYNC pInterface, void *pStorage,
     1361                                                    uint64_t off, const void *pvBuf, size_t cbWrite, size_t *pcbWritten));
    14591362
    14601363    /**
     
    14641367     * @returns VBox status code.
    14651368     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1466      * @thread  Any thread.
    1467      */
    1468     DECLR3CALLBACKMEMBER(int, pfnFlushSynchronous,(PPDMITRANSPORTASYNC pInterface));
     1369     * @param   pStorage        The storage handle to flush-
     1370     * @thread  Any thread.
     1371     */
     1372    DECLR3CALLBACKMEMBER(int, pfnFlushSynchronous,(PPDMITRANSPORTASYNC pInterface, void *pStorage));
    14691373
    14701374    /**
     
    14731377     * @returns Media size in bytes.
    14741378     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1475      * @thread  Any thread.
    1476      */
    1477     DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize,(PPDMITRANSPORTASYNC pInterface));
     1379     * @param   pStorage        The storage handle.
     1380     * @thread  Any thread.
     1381     */
     1382    DECLR3CALLBACKMEMBER(uint64_t, pfnGetSize,(PPDMITRANSPORTASYNC pInterface, void *pStorage));
    14781383
    14791384    /**
     
    14831388     * @returns false if read/write.
    14841389     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1485      * @thread  Any thread.
    1486      */
    1487     DECLR3CALLBACKMEMBER(bool, pfnIsReadOnly,(PPDMITRANSPORTASYNC pInterface));
     1390     * @param   pStorage        The storage handle.
     1391     * @thread  Any thread.
     1392     */
     1393    DECLR3CALLBACKMEMBER(bool, pfnIsReadOnly,(PPDMITRANSPORTASYNC pInterface, void *pStorage));
    14881394
    14891395    /**
     
    14941400     * @param   pszPath         The path to open.
    14951401     * @param   fReadonly       If the target shoudl opened readonly.
    1496      * @thread  Any thread.
    1497      */
    1498     DECLR3CALLBACKMEMBER(int, pfnOpen, (PPDMITRANSPORTASYNC pInterface, const char *pszTargetPath, bool fReadonly));
     1402     * @param   ppStorage       Where to store the storage handle.
     1403     * @thread  Any thread.
     1404     */
     1405    DECLR3CALLBACKMEMBER(int, pfnOpen, (PPDMITRANSPORTASYNC pInterface, const char *pszTargetPath, bool fReadonly, void **ppStorage));
    14991406
    15001407    /**
     
    15031410     * @returns VBox status code.
    15041411     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
    1505      * @thread  Any thread.
    1506      */
    1507     DECLR3CALLBACKMEMBER(int, pfnClose, (PPDMITRANSPORTASYNC pInterface));
    1508 
     1412     * @param   pStorage        The storage handle to close.
     1413     * @thread  Any thread.
     1414     */
     1415    DECLR3CALLBACKMEMBER(int, pfnClose, (PPDMITRANSPORTASYNC pInterface, void *pStorage));
     1416
     1417    /**
     1418     * Prepare an asynchronous read task.
     1419     *
     1420     * @returns VBox status code.
     1421     * @param   pInterface     Pointer to the interface structure containing the called function pointer.
     1422     * @param   pStorage       The storage handle.
     1423     * @param   uOffset        The offset to start reading from.
     1424     * @param   pvBuf          Where to store read bits.
     1425     * @param   cbRead         How many bytes to read.
     1426     * @param   ppTask         Where to store the opaque task handle.
     1427     */
     1428    DECLR3CALLBACKMEMBER(int, pfnPrepareRead, (PPDMITRANSPORTASYNC pInterface, void *pStorage, uint64_t uOffset,
     1429                                               void *pvBuf, size_t cbRead, void **ppTask));
     1430
     1431    /**
     1432     * Prepare an asynchronous write task.
     1433     *
     1434     * @returns VBox status code.
     1435     * @param   pInterface     Pointer to the interface structure containing the called function pointer.
     1436     * @param   pStorage       The storage handle.
     1437     * @param   uOffset        The offset to start writing to.
     1438     * @param   pvBuf          Where to read the data from.
     1439     * @param   cbWrite        How many bytes to write.
     1440     * @param   ppTask         Where to store the opaque task handle.
     1441     */
     1442    DECLR3CALLBACKMEMBER(int, pfnPrepareWrite, (PPDMITRANSPORTASYNC pInterface, void *pStorage, uint64_t uOffset,
     1443                                                void *pvBuf, size_t cbWrite, void **ppTask));
     1444
     1445    /**
     1446     * Submit an array of tasks for processing
     1447     *
     1448     * @returns VBox status code.
     1449     * @param   pInterface    Pointer to the interface structure containing the called function pointer.
     1450     * @param   apTasks       Array of task handles to submit.
     1451     * @param   cTasks        How many tasks to submit.
     1452     * @param   pvUser        User data which is passed on completion.
     1453     */
     1454    DECLR3CALLBACKMEMBER(int, pfnTasksSubmit, (PPDMITRANSPORTASYNC pInterface, void *apTasks[], unsigned cTasks, void *pvUser));
    15091455} PDMITRANSPORTASYNC;
    15101456
  • trunk/include/VBox/types.h

    r10087 r10715  
    508508typedef const PDMMAC *PCPDMMAC;
    509509
     510/**
     511 * Data transport buffer (scatter/gather)
     512 */
     513typedef struct PDMDATASEG
     514{
     515    /** Length of buffer in entry. */
     516    size_t  cbSeg;
     517    /** Pointer to the start of the buffer. */
     518    void   *pvSeg;
     519} PDMDATASEG;
     520/** Pointer to a data transport segment. */
     521typedef PDMDATASEG *PPDMDATASEG;
     522/** Pointer to a const data transport segment. */
     523typedef PDMDATASEG const *PCPDMDATASEG;
    510524
    511525/** @} */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette