VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/IOBufMgmt.h

Last change on this file was 106061, checked in by vboxsync, 7 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/* $Id: IOBufMgmt.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox storage devices: I/O buffer management API.
4 */
5
6/*
7 * Copyright (C) 2016-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VBOX_INCLUDED_SRC_Storage_IOBufMgmt_h
29#define VBOX_INCLUDED_SRC_Storage_IOBufMgmt_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <VBox/cdefs.h>
35#include <iprt/sg.h>
36
37RT_C_DECLS_BEGIN
38
39/**
40 * Opaque I/O buffer manager.
41 */
42typedef struct IOBUFMGRINT *IOBUFMGR;
43/** Pointer to a I/O buffer manager. */
44typedef IOBUFMGR *PIOBUFMGR;
45
46/* NIL I/O buffer manager handle. */
47#define NIL_IOBUFMGR ((IOBUFMGR)0)
48
49#define IOBUFMGR_F_DEFAULT (0)
50/** I/O buffer memory needs to be non pageable (for example because it contains sensitive data
51 * which shouldn't end up in swap unencrypted). */
52#define IOBUFMGR_F_REQUIRE_NOT_PAGABLE RT_BIT(0)
53
54/**
55 * I/O buffer descriptor.
56 */
57typedef struct IOBUFDESC
58{
59 /** S/G buffer. */
60 RTSGBUF SgBuf;
61 /** Internal data */
62 union
63 {
64#ifdef IOBUFDESCINT_DECLARED
65 IOBUFDESCINT Int;
66#endif
67 uint8_t abPadding[HC_ARCH_BITS == 32 ? 88 : 172];
68 };
69} IOBUFDESC;
70/** Pointer to a I/O buffer descriptor. */
71typedef IOBUFDESC *PIOBUFDESC;
72
73/**
74 * Creates I/O buffer manager.
75 *
76 * @returns VBox status code.
77 * @param phIoBufMgr Where to store the handle to the I/O buffer manager on success.
78 * @param cbMax The maximum amount of I/O memory to allow. Trying to allocate more than
79 * this will lead to out of memory errors. 0 for "unlimited" size (only restriction
80 * is the available memory on the host).
81 * @param fFlags Combination of IOBUFMGR_F_*
82 */
83DECLHIDDEN(int) IOBUFMgrCreate(PIOBUFMGR phIoBufMgr, size_t cbMax, uint32_t fFlags);
84
85/**
86 * Destroys the given I/O buffer manager.
87 *
88 * @returns VBox status code.
89 * @retval VERR_INVALID_STATE if there is still memory allocated by the given manager.
90 * @param hIoBufMgr The I/O buffer manager.
91 */
92DECLHIDDEN(int) IOBUFMgrDestroy(IOBUFMGR hIoBufMgr);
93
94/**
95 * Allocates a I/O buffer and fills the descriptor.
96 *
97 * @returns VBox status code.
98 * @retval VERR_NO_MEMORY if there is not enough free memory to satisfy the request
99 * and partial allocations are not allowed or allocating some internal tracking
100 * structures failed.
101 * @param hIoBufMgr The I/O buffer manager.
102 * @param pIoBufDesc The I/O buffer descriptor to initialize on success.
103 * @param cbIoBuf How much to allocate.
104 * @param pcbIoBufAllocated Where to store amount of memory the manager was able to allocate
105 * if there is not enough free memory to satisfy the complete request.
106 * NULL if partial allocations are not supported.
107 */
108DECLHIDDEN(int) IOBUFMgrAllocBuf(IOBUFMGR hIoBufMgr, PIOBUFDESC pIoBufDesc, size_t cbIoBuf, size_t *pcbIoBufAllocated);
109
110/**
111 * Frees a given I/O buffer.
112 *
113 * @param pIoBufDesc The I/O buffer descriptor to free.
114 */
115DECLHIDDEN(void) IOBUFMgrFreeBuf(PIOBUFDESC pIoBufDesc);
116
117RT_C_DECLS_END
118
119#endif /* !VBOX_INCLUDED_SRC_Storage_IOBufMgmt_h */
Note: See TracBrowser for help on using the repository browser.

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