0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** @file
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * PDM - Pluggable Device Manager, Async I/O Completion.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/*
be41e59f051a3abb5cd05e7fe270ab2fea791f5avboxsync * Copyright (C) 2007-2013 Oracle Corporation
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync *
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * available from http://www.virtualbox.org. This file is free software;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * you can redistribute it and/or modify it under the terms of the GNU
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * General Public License (GPL) as published by the Free Software
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync *
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * The contents of this file may alternatively be used under the terms
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * of the Common Development and Distribution License Version 1.0
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * VirtualBox OSE distribution, in which case the provisions of the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * CDDL are applicable instead of those of the GPL.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync *
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * You may elect to license modified versions of this file under the
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * terms and conditions of either the GPL or the CDDL or both.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#ifndef ___VBox_vmm_pdmasynccompletion_h
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#define ___VBox_vmm_pdmasynccompletion_h
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#include <VBox/types.h>
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#include <VBox/err.h>
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#include <iprt/assert.h>
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#include <iprt/sg.h>
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncRT_C_DECLS_BEGIN
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** @defgroup grp_pdm_async_completion The PDM Async I/O Completion API
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @ingroup grp_pdm
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @{
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Pointer to a PDM async completion template handle. */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef struct PDMASYNCCOMPLETIONTEMPLATE *PPDMASYNCCOMPLETIONTEMPLATE;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Pointer to a PDM async completion template handle pointer. */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef PPDMASYNCCOMPLETIONTEMPLATE *PPPDMASYNCCOMPLETIONTEMPLATE;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Pointer to a PDM async completion task handle. */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef struct PDMASYNCCOMPLETIONTASK *PPDMASYNCCOMPLETIONTASK;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Pointer to a PDM async completion task handle pointer. */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef PPDMASYNCCOMPLETIONTASK *PPPDMASYNCCOMPLETIONTASK;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Pointer to a PDM async completion endpoint handle. */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef struct PDMASYNCCOMPLETIONENDPOINT *PPDMASYNCCOMPLETIONENDPOINT;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Pointer to a PDM async completion endpoint handle pointer. */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef PPDMASYNCCOMPLETIONENDPOINT *PPPDMASYNCCOMPLETIONENDPOINT;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/**
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * Completion callback for devices.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync *
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param pDevIns The device instance.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param pvUser User argument.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param rc The status code of the completed request.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEDEV(PPDMDEVINS pDevIns, void *pvUser, int rc);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Pointer to a FNPDMASYNCCOMPLETEDEV(). */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef FNPDMASYNCCOMPLETEDEV *PFNPDMASYNCCOMPLETEDEV;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/**
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * Completion callback for drivers.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync *
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param pDrvIns The driver instance.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param pvTemplateUser User argument given when creating the template.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param pvUser User argument given during request initiation.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param rc The status code of the completed request.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEDRV(PPDMDRVINS pDrvIns, void *pvTemplateUser, void *pvUser, int rc);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Pointer to a FNPDMASYNCCOMPLETEDRV(). */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef FNPDMASYNCCOMPLETEDRV *PFNPDMASYNCCOMPLETEDRV;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/**
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * Completion callback for USB devices.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync *
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param pUsbIns The USB device instance.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param pvUser User argument.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param rc The status code of the completed request.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEUSB(PPDMUSBINS pUsbIns, void *pvUser, int rc);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Pointer to a FNPDMASYNCCOMPLETEUSB(). */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef FNPDMASYNCCOMPLETEUSB *PFNPDMASYNCCOMPLETEUSB;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/**
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * Completion callback for internal.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync *
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param pVM Pointer to the shared VM structure.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param pvUser User argument for the task.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param pvUser2 User argument for the template.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @param rc The status code of the completed request.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEINT(PVM pVM, void *pvUser, void *pvUser2, int rc);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Pointer to a FNPDMASYNCCOMPLETEINT(). */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsynctypedef FNPDMASYNCCOMPLETEINT *PFNPDMASYNCCOMPLETEINT;
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncVMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateInternal(PVM pVM, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate, PFNPDMASYNCCOMPLETEINT pfnCompleted, void *pvUser2, const char *pszDesc);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncVMMR3DECL(int) PDMR3AsyncCompletionTemplateDestroy(PPDMASYNCCOMPLETIONTEMPLATE pTemplate);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncVMMR3DECL(int) PDMR3AsyncCompletionEpCreateForFile(PPPDMASYNCCOMPLETIONENDPOINT ppEndpoint,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync const char *pszFilename, uint32_t fFlags,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync PPDMASYNCCOMPLETIONTEMPLATE pTemplate);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** @defgroup grp_pdmacep_file_flags Flags for PDMR3AsyncCompletionEpCreateForFile
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * @{ */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Open the file in read-only mode. */
fa78f7365d7888f0aa971132275c94611249bd7fvboxsync#define PDMACEP_FILE_FLAGS_READ_ONLY RT_BIT_32(0)
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** Whether the file should not be write protected.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * The default is to protect the file against writes by other processes
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * when opened in read/write mode to prevent data corruption by
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync * concurrent access which can occur if the local writeback cache is enabled.
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync */
fa78f7365d7888f0aa971132275c94611249bd7fvboxsync#define PDMACEP_FILE_FLAGS_DONT_LOCK RT_BIT_32(2)
fa78f7365d7888f0aa971132275c94611249bd7fvboxsync/** Open the endpoint with the host cache enabled. */
fa78f7365d7888f0aa971132275c94611249bd7fvboxsync#define PDMACEP_FILE_FLAGS_HOST_CACHE_ENABLED RT_BIT_32(3)
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** @} */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncVMMR3DECL(void) PDMR3AsyncCompletionEpClose(PPDMASYNCCOMPLETIONENDPOINT pEndpoint);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncVMMR3DECL(int) PDMR3AsyncCompletionEpRead(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync PCRTSGSEG paSegments, unsigned cSegments,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync size_t cbRead, void *pvUser,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync PPPDMASYNCCOMPLETIONTASK ppTask);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncVMMR3DECL(int) PDMR3AsyncCompletionEpWrite(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync PCRTSGSEG paSegments, unsigned cSegments,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync size_t cbWrite, void *pvUser,
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync PPPDMASYNCCOMPLETIONTASK ppTask);
be41e59f051a3abb5cd05e7fe270ab2fea791f5avboxsyncVMMR3DECL(int) PDMR3AsyncCompletionEpFlush(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, void *pvUser, PPPDMASYNCCOMPLETIONTASK ppTask);
be41e59f051a3abb5cd05e7fe270ab2fea791f5avboxsyncVMMR3DECL(int) PDMR3AsyncCompletionEpGetSize(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint64_t *pcbSize);
be41e59f051a3abb5cd05e7fe270ab2fea791f5avboxsyncVMMR3DECL(int) PDMR3AsyncCompletionEpSetSize(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint64_t cbSize);
be41e59f051a3abb5cd05e7fe270ab2fea791f5avboxsyncVMMR3DECL(int) PDMR3AsyncCompletionEpSetBwMgr(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, const char *pszBwMgr);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncVMMR3DECL(int) PDMR3AsyncCompletionTaskCancel(PPDMASYNCCOMPLETIONTASK pTask);
be41e59f051a3abb5cd05e7fe270ab2fea791f5avboxsyncVMMR3DECL(int) PDMR3AsyncCompletionBwMgrSetMaxForFile(PUVM pUVM, const char *pszBwMgr, uint32_t cbMaxNew);
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync/** @} */
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsyncRT_C_DECLS_END
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync#endif
0b74a2f80aba476dc8be8bc1c63891fc53945986vboxsync