1 | /** @file
|
---|
2 | * PDM - Pluggable Device Manager, Async I/O Completion.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2007-2023 Oracle and/or its affiliates.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox base platform packages, as
|
---|
9 | * available from https://www.virtualbox.org.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or
|
---|
12 | * modify it under the terms of the GNU General Public License
|
---|
13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | * General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | *
|
---|
24 | * The contents of this file may alternatively be used under the terms
|
---|
25 | * of the Common Development and Distribution License Version 1.0
|
---|
26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | * CDDL are applicable instead of those of the GPL.
|
---|
29 | *
|
---|
30 | * You may elect to license modified versions of this file under the
|
---|
31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | *
|
---|
33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef VBOX_INCLUDED_vmm_pdmasynccompletion_h
|
---|
37 | #define VBOX_INCLUDED_vmm_pdmasynccompletion_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #include <VBox/types.h>
|
---|
43 | #include <iprt/sg.h>
|
---|
44 |
|
---|
45 |
|
---|
46 | RT_C_DECLS_BEGIN
|
---|
47 |
|
---|
48 | /** @defgroup grp_pdm_async_completion The PDM Async I/O Completion API
|
---|
49 | * @ingroup grp_pdm
|
---|
50 | * @{
|
---|
51 | */
|
---|
52 |
|
---|
53 | /** Pointer to a PDM async completion template handle. */
|
---|
54 | typedef struct PDMASYNCCOMPLETIONTEMPLATE *PPDMASYNCCOMPLETIONTEMPLATE;
|
---|
55 | /** Pointer to a PDM async completion template handle pointer. */
|
---|
56 | typedef PPDMASYNCCOMPLETIONTEMPLATE *PPPDMASYNCCOMPLETIONTEMPLATE;
|
---|
57 |
|
---|
58 | /** Pointer to a PDM async completion task handle. */
|
---|
59 | typedef struct PDMASYNCCOMPLETIONTASK *PPDMASYNCCOMPLETIONTASK;
|
---|
60 | /** Pointer to a PDM async completion task handle pointer. */
|
---|
61 | typedef PPDMASYNCCOMPLETIONTASK *PPPDMASYNCCOMPLETIONTASK;
|
---|
62 |
|
---|
63 | /** Pointer to a PDM async completion endpoint handle. */
|
---|
64 | typedef struct PDMASYNCCOMPLETIONENDPOINT *PPDMASYNCCOMPLETIONENDPOINT;
|
---|
65 | /** Pointer to a PDM async completion endpoint handle pointer. */
|
---|
66 | typedef PPDMASYNCCOMPLETIONENDPOINT *PPPDMASYNCCOMPLETIONENDPOINT;
|
---|
67 |
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Completion callback for devices.
|
---|
71 | *
|
---|
72 | * @param pDevIns The device instance.
|
---|
73 | * @param pvUser User argument.
|
---|
74 | * @param rc The status code of the completed request.
|
---|
75 | */
|
---|
76 | typedef DECLCALLBACKTYPE(void, FNPDMASYNCCOMPLETEDEV,(PPDMDEVINS pDevIns, void *pvUser, int rc));
|
---|
77 | /** Pointer to a FNPDMASYNCCOMPLETEDEV(). */
|
---|
78 | typedef FNPDMASYNCCOMPLETEDEV *PFNPDMASYNCCOMPLETEDEV;
|
---|
79 |
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Completion callback for drivers.
|
---|
83 | *
|
---|
84 | * @param pDrvIns The driver instance.
|
---|
85 | * @param pvTemplateUser User argument given when creating the template.
|
---|
86 | * @param pvUser User argument given during request initiation.
|
---|
87 | * @param rc The status code of the completed request.
|
---|
88 | */
|
---|
89 | typedef DECLCALLBACKTYPE(void, FNPDMASYNCCOMPLETEDRV,(PPDMDRVINS pDrvIns, void *pvTemplateUser, void *pvUser, int rc));
|
---|
90 | /** Pointer to a FNPDMASYNCCOMPLETEDRV(). */
|
---|
91 | typedef FNPDMASYNCCOMPLETEDRV *PFNPDMASYNCCOMPLETEDRV;
|
---|
92 |
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * Completion callback for USB devices.
|
---|
96 | *
|
---|
97 | * @param pUsbIns The USB device instance.
|
---|
98 | * @param pvUser User argument.
|
---|
99 | * @param rc The status code of the completed request.
|
---|
100 | */
|
---|
101 | typedef DECLCALLBACKTYPE(void, FNPDMASYNCCOMPLETEUSB,(PPDMUSBINS pUsbIns, void *pvUser, int rc));
|
---|
102 | /** Pointer to a FNPDMASYNCCOMPLETEUSB(). */
|
---|
103 | typedef FNPDMASYNCCOMPLETEUSB *PFNPDMASYNCCOMPLETEUSB;
|
---|
104 |
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Completion callback for internal.
|
---|
108 | *
|
---|
109 | * @param pVM The cross context VM structure.
|
---|
110 | * @param pvUser User argument for the task.
|
---|
111 | * @param pvUser2 User argument for the template.
|
---|
112 | * @param rc The status code of the completed request.
|
---|
113 | */
|
---|
114 | typedef DECLCALLBACKTYPE(void, FNPDMASYNCCOMPLETEINT,(PVM pVM, void *pvUser, void *pvUser2, int rc));
|
---|
115 | /** Pointer to a FNPDMASYNCCOMPLETEINT(). */
|
---|
116 | typedef FNPDMASYNCCOMPLETEINT *PFNPDMASYNCCOMPLETEINT;
|
---|
117 |
|
---|
118 | VMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateInternal(PVM pVM, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
|
---|
119 | PFNPDMASYNCCOMPLETEINT pfnCompleted, void *pvUser2, const char *pszDesc);
|
---|
120 | VMMR3DECL(int) PDMR3AsyncCompletionTemplateDestroy(PPDMASYNCCOMPLETIONTEMPLATE pTemplate);
|
---|
121 | VMMR3DECL(int) PDMR3AsyncCompletionEpCreateForFile(PPPDMASYNCCOMPLETIONENDPOINT ppEndpoint,
|
---|
122 | const char *pszFilename, uint32_t fFlags,
|
---|
123 | PPDMASYNCCOMPLETIONTEMPLATE pTemplate);
|
---|
124 |
|
---|
125 | /** @defgroup grp_pdmacep_file_flags Flags for PDMR3AsyncCompletionEpCreateForFile
|
---|
126 | * @{ */
|
---|
127 | /** Open the file in read-only mode. */
|
---|
128 | #define PDMACEP_FILE_FLAGS_READ_ONLY RT_BIT_32(0)
|
---|
129 | /** Whether the file should not be write protected.
|
---|
130 | * The default is to protect the file against writes by other processes
|
---|
131 | * when opened in read/write mode to prevent data corruption by
|
---|
132 | * concurrent access which can occur if the local writeback cache is enabled.
|
---|
133 | */
|
---|
134 | #define PDMACEP_FILE_FLAGS_DONT_LOCK RT_BIT_32(2)
|
---|
135 | /** Open the endpoint with the host cache enabled. */
|
---|
136 | #define PDMACEP_FILE_FLAGS_HOST_CACHE_ENABLED RT_BIT_32(3)
|
---|
137 | /** @} */
|
---|
138 |
|
---|
139 | VMMR3DECL(void) PDMR3AsyncCompletionEpClose(PPDMASYNCCOMPLETIONENDPOINT pEndpoint);
|
---|
140 | VMMR3DECL(int) PDMR3AsyncCompletionEpRead(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
|
---|
141 | PCRTSGSEG paSegments, unsigned cSegments,
|
---|
142 | size_t cbRead, void *pvUser,
|
---|
143 | PPPDMASYNCCOMPLETIONTASK ppTask);
|
---|
144 | VMMR3DECL(int) PDMR3AsyncCompletionEpWrite(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, RTFOFF off,
|
---|
145 | PCRTSGSEG paSegments, unsigned cSegments,
|
---|
146 | size_t cbWrite, void *pvUser,
|
---|
147 | PPPDMASYNCCOMPLETIONTASK ppTask);
|
---|
148 | VMMR3DECL(int) PDMR3AsyncCompletionEpFlush(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, void *pvUser, PPPDMASYNCCOMPLETIONTASK ppTask);
|
---|
149 | VMMR3DECL(int) PDMR3AsyncCompletionEpGetSize(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint64_t *pcbSize);
|
---|
150 | VMMR3DECL(int) PDMR3AsyncCompletionEpSetSize(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, uint64_t cbSize);
|
---|
151 | VMMR3DECL(int) PDMR3AsyncCompletionEpSetBwMgr(PPDMASYNCCOMPLETIONENDPOINT pEndpoint, const char *pszBwMgr);
|
---|
152 | VMMR3DECL(int) PDMR3AsyncCompletionTaskCancel(PPDMASYNCCOMPLETIONTASK pTask);
|
---|
153 | VMMR3DECL(int) PDMR3AsyncCompletionBwMgrSetMaxForFile(PUVM pUVM, const char *pszBwMgr, uint32_t cbMaxNew);
|
---|
154 |
|
---|
155 | /** @} */
|
---|
156 |
|
---|
157 | RT_C_DECLS_END
|
---|
158 |
|
---|
159 | #endif /* !VBOX_INCLUDED_vmm_pdmasynccompletion_h */
|
---|
160 |
|
---|