1 | /** $Id: VDIoBackend.h 46247 2013-05-23 19:19:42Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VBox HDD container test utility, async I/O backend
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2013 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 | #ifndef __VDIoBackend_h__
|
---|
19 | #define __VDIoBackend_h__
|
---|
20 |
|
---|
21 | #include <iprt/sg.h>
|
---|
22 |
|
---|
23 | #include "VDDefs.h"
|
---|
24 |
|
---|
25 | /** I/O backend handle. */
|
---|
26 | typedef struct VDIOBACKEND *PVDIOBACKEND;
|
---|
27 | /** Pointer to a I/O backend handle. */
|
---|
28 | typedef PVDIOBACKEND *PPVDIOBACKEND;
|
---|
29 |
|
---|
30 | /** Storage handle. */
|
---|
31 | typedef struct VDIOSTORAGE *PVDIOSTORAGE;
|
---|
32 | /** Pointer to a storage handle. */
|
---|
33 | typedef PVDIOSTORAGE *PPVDIOSTORAGE;
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Completion handler.
|
---|
37 | *
|
---|
38 | * @returns nothing.
|
---|
39 | * @param pvUser Opaque user data.
|
---|
40 | * @param rcReq Completion code for the request.
|
---|
41 | */
|
---|
42 | typedef DECLCALLBACK(int) FNVDIOCOMPLETE(void *pvUser, int rcReq);
|
---|
43 | /** Pointer to a completion handler. */
|
---|
44 | typedef FNVDIOCOMPLETE *PFNVDIOCOMPLETE;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Creates a new memory I/O backend.
|
---|
48 | *
|
---|
49 | * @returns IPRT status code.
|
---|
50 | *
|
---|
51 | * @param ppIoBackend Where to store the handle on success.
|
---|
52 | */
|
---|
53 | int VDIoBackendCreate(PPVDIOBACKEND ppIoBackend);
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Destroys a memory I/O backend.
|
---|
57 | *
|
---|
58 | * @returns nothing.
|
---|
59 | *
|
---|
60 | * @param pIoBackend The backend to destroy.
|
---|
61 | */
|
---|
62 | void VDIoBackendDestroy(PVDIOBACKEND pIoBackend);
|
---|
63 |
|
---|
64 | int VDIoBackendStorageCreate(PVDIOBACKEND pIoBackend, const char *pszBackend,
|
---|
65 | const char *pszName, PFNVDIOCOMPLETE pfnComplete,
|
---|
66 | PPVDIOSTORAGE ppIoStorage);
|
---|
67 |
|
---|
68 | void VDIoBackendStorageDestroy(PVDIOSTORAGE pIoStorage);
|
---|
69 |
|
---|
70 | int VDIoBackendStorageSetSize(PVDIOSTORAGE pIoStorage, uint64_t cbSize);
|
---|
71 |
|
---|
72 | int VDIoBackendStorageGetSize(PVDIOSTORAGE pIoStorage, uint64_t *pcbSize);
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Enqueues a new I/O request.
|
---|
76 | *
|
---|
77 | * @returns IPRT status code.
|
---|
78 | *
|
---|
79 | * @param pIoStorage Storage handle.
|
---|
80 | * @param enmTxDir The transfer direction.
|
---|
81 | * @param off Start offset of the transfer.
|
---|
82 | * @param cbTransfer Size of the transfer.
|
---|
83 | * @param pSgBuf S/G buffer to use.
|
---|
84 | * @param pvUser Opaque user data.
|
---|
85 | * @param fSync Flag whether to wait for the operation to complete.
|
---|
86 | */
|
---|
87 | int VDIoBackendTransfer(PVDIOSTORAGE pIoStorage, VDIOTXDIR enmTxDir, uint64_t off,
|
---|
88 | size_t cbTransfer, PRTSGBUF pSgBuf, void *pvUser, bool fSync);
|
---|
89 |
|
---|
90 | #endif /* __VDIoBackendMem_h__ */
|
---|