Changeset 66346 in vbox for trunk/include/VBox
- Timestamp:
- Mar 29, 2017 7:43:15 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 114282
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vd.h
r66264 r66346 1392 1392 PRTVFSFILE phVfsFile); 1393 1393 1394 /** @defgroup grp_vd_ioiter I/O iterator 1395 * @{ 1396 */ 1397 1398 /** Read metadata coming before each main data block addressed in the segment. */ 1399 #define VD_IOITER_SEG_F_PRE_METADATA RT_BIT_32(0) 1400 /** Read the main user data of each addressed block in the segment. */ 1401 #define VD_IOITER_SEG_F_MAIN_DATA RT_BIT_32(1) 1402 /** Read metadata coming after each main data block addressed in the segment. */ 1403 #define VD_IOITER_SEG_F_POST_METADATA RT_BIT_32(2) 1404 /** Read checksum data of each data block addressed in the segment. */ 1405 #define VD_IOITER_SEG_F_CHKSUM RT_BIT_32(3) 1406 /** Read all available data for each addressed block in the segment. */ 1407 #define VD_IOITER_SEG_F_AVAILABLE RT_BIT_32(4) 1408 1409 /** The offset and size members in the segments use byte granularity instead of a 1410 * block address and number of blocks respectively. */ 1411 #define VDIOITER_F_BYTE_OFFSET_AND_SIZE RT_BIT_32(0) 1412 1413 /** 1414 * VD I/O iterator segment. 1415 */ 1416 typedef struct VDIOITERSEG 1417 { 1418 /** Start offset for this segment. */ 1419 uint64_t offStartSeg; 1420 /** Size of the segment (bytes or blocks). */ 1421 uint64_t cSizeSeg; 1422 /** Flags for this segment, see VD_IOITER_SEG_F_*. */ 1423 uint32_t fFlags; 1424 } VDIOITERSEG; 1425 /** Pointer to a I/O iterator segment. */ 1426 typedef VDIOITERSEG *PVDIOITERSEG; 1427 /** Pointer to a constant I/O iterator segment. */ 1428 typedef VDIOITERSEG *PCVDIOITERSEG; 1429 1430 /** I/O iterator handle. */ 1431 typedef struct VDIOITERINT *VDIOITER; 1432 /** Pointer to a I/O iterator handle. */ 1433 typedef VDIOITER *PVDIOITER; 1434 1435 /** 1436 * Create a new I/O iterator. 1437 * 1438 * @returns VBox status code. 1439 * @param pDisk The disk to create the iterator for. 1440 * @param phVdIoIter Where to store the handle to the I/O iterator on success. 1441 * @param paIoIterSegs The segments for the iterator, can be destroyed after the call. 1442 * @param cIoIterSegs Number of segments. 1443 * @param fFlags Flags for the iterator, see VDIOITER_F_* 1444 */ 1445 VBOXDDU_DECL(int) VDIoIterCreate(PVDISK pDisk, PVDIOITER phVdIoIter, PCVDIOITERSEG paIoIterSegs, 1446 uint32_t cIoIterSegs, uint32_t fFlags); 1447 1448 /** 1449 * Retains the reference count of the given I/O iterator. 1450 * 1451 * @returns New reference count. 1452 * @param hVdIoIter The I/O iterator handle. 1453 */ 1454 VBOXDDU_DECL(uint32_t) VDIoIterRetain(VDIOITER hVdIoIter); 1455 1456 /** 1457 * Releases the reference count of the given I/O iterator. 1458 * 1459 * @returns New reference count, on 0 the iterator is destroyed. 1460 * @param hVdIoIter The I/O iterator handle. 1461 */ 1462 VBOXDDU_DECL(uint32_t) VDIoIterRelease(VDIOITER hVdIoIter); 1463 1464 /** 1465 * Returns the number of segments in the given I/O iterator. 1466 * 1467 * @returns Number of segments. 1468 * @param hVdIoIter The I/O iterator handle. 1469 */ 1470 VBOXDDU_DECL(uint32_t) VDIoIterGetSegmentCount(VDIOITER hVdIoIter); 1471 1472 /** 1473 * Returns the flags of the given I/O iterator. 1474 * 1475 * @returns Flags. 1476 * @param hVdIoIter The I/O iterator handle. 1477 */ 1478 VBOXDDU_DECL(uint32_t) VDIoIterGetFlags(VDIOITER hVdIoIter); 1479 1480 /** 1481 * Queries the properties of the given segment for the given I/O iterator. 1482 * 1483 * @returns VBox status code. 1484 * @param hVdIoIter The I/O iterator handle. 1485 * @param idx The segment index to query. 1486 * @param pSegment Where to store the segment properties on success. 1487 */ 1488 VBOXDDU_DECL(int) VDIoIterQuerySegment(VDIOITER hVdIoIter, uint32_t idx, PVDIOITERSEG pSegment); 1489 1490 /** @} */ 1491 1492 1493 /** @defgroup grp_vd_io_buf I/O buffer management API. 1494 * @{ 1495 */ 1496 1497 /** VD I/O buffer manager handle. */ 1498 typedef struct VDIOBUFMGRINT *VDIOBUFMGR; 1499 /** Pointer to VD I/O buffer manager handle. */ 1500 typedef VDIOBUFMGR *PVDIOBUFMGR; 1501 1502 /** VD I/O buffer handle. */ 1503 typedef struct VDIOBUFINT *VDIOBUF; 1504 /** Pointer to a VD I/O buffer handle. */ 1505 typedef VDIOBUF *PVDIOBUF; 1506 1507 /** Default I/O buffer manager flags. */ 1508 #define VD_IOBUFMGR_F_DEFAULT (0) 1509 /** I/O buffer memory needs to be non pageable (for example because it contains sensitive data 1510 * which shouldn't end up in swap unencrypted). */ 1511 #define VD_IOBUFMGR_F_REQUIRE_NOT_PAGABLE RT_BIT(0) 1512 1513 /** Pointer to VD I/O buffer callbacks. */ 1514 typedef struct VDIOBUFCALLBACKS *PVDIOBUFCALLBACKS; 1515 /** Pointer to const VD I/O buffer callbacks. */ 1516 typedef const VDIOBUFCALLBACKS *PCVDIOBUFCALLBACKS; 1517 1518 /** 1519 * VD I/O buffer callbacks. 1520 */ 1521 typedef struct VDIOBUFCALLBACKS 1522 { 1523 /** 1524 * Copy data from the memory buffer of the caller to the callees memory buffer for the given request. 1525 * 1526 * @returns VBox status code. 1527 * @retval VERR_PDM_MEDIAEX_IOBUF_OVERFLOW if there is not enough room to store the data. 1528 * @param pInterface Pointer to the interface structure containing the called function pointer. 1529 * @param hIoBuf The I/O request handle. 1530 * @param pvIoBufAlloc The allocator specific memory for this request. 1531 * @param offDst The destination offset from the start to write the data to. 1532 * @param pSgBuf The S/G buffer to read the data from. 1533 * @param cbCopy How many bytes to copy. 1534 */ 1535 DECLR3CALLBACKMEMBER(int, pfnIoBufCopyFromBuf, (PVDIOBUFCALLBACKS pInterface, VDIOBUF hIoBuf, 1536 void *pvIoBufAlloc, uint32_t offDst, PRTSGBUF pSgBuf, 1537 size_t cbCopy)); 1538 1539 /** 1540 * Copy data to the memory buffer of the caller from the callees memory buffer for the given request. 1541 * 1542 * @returns VBox status code. 1543 * @retval VERR_PDM_MEDIAEX_IOBUF_UNDERRUN if there is not enough data to copy from the buffer. 1544 * @param pInterface Pointer to the interface structure containing the called function pointer. 1545 * @param hIoBuf The I/O request handle. 1546 * @param pvIoBufAlloc The allocator specific memory for this request. 1547 * @param offSrc The offset from the start of the buffer to read the data from. 1548 * @param pSgBuf The S/G buffer to write the data to. 1549 * @param cbCopy How many bytes to copy. 1550 */ 1551 DECLR3CALLBACKMEMBER(int, pfnIoBufCopyToBuf, (PVDIOBUFCALLBACKS pInterface, VDIOBUF hIoBuf, 1552 void *pvIoBufAlloc, uint32_t offSrc, PRTSGBUF pSgBuf, 1553 size_t cbCopy)); 1554 1555 /** 1556 * Queries a pointer to the memory buffer for the request from the drive/device above. 1557 * 1558 * @returns VBox status code. 1559 * @retval VERR_NOT_SUPPORTED if this is not supported for this request. 1560 * @param pInterface Pointer to the interface structure containing the called function pointer. 1561 * @param hIoBuf The I/O request handle. 1562 * @param pvIoBufAlloc The allocator specific memory for this request. 1563 * @param offBuf The offset from the start of the buffer to get the buffer address. 1564 * @param cbBuf The number of bytes requested. 1565 * @param ppvBuf Where to store the pointer to the guest buffer on success. 1566 * @param pcbBuf Where to store the size of the buffer on success. 1567 * 1568 * @note This is an optional feature of the entity implementing this interface to avoid overhead 1569 * by copying the data between buffers. If NULL it is not supported at all and the caller 1570 * has to resort to VDIOBUFCALLBACKS::pfnIoBufCopyToBuf and VDIOBUFCALLBACKS::pfnIoBufCopyFromBuf. 1571 * The same holds when VERR_NOT_SUPPORTED is returned. 1572 * 1573 * On the upside the caller of this interface might not call this method at all and just 1574 * use the before mentioned methods to copy the data between the buffers. 1575 */ 1576 DECLR3CALLBACKMEMBER(int, pfnIoBufQueryBuf, (PVDIOBUFCALLBACKS pInterface, VDIOBUF hIoBuf, 1577 void *pvIoBufAlloc, uint32_t offBuf, size_t cbBuf, 1578 void **ppvBuf, size_t *pcbBuf)); 1579 1580 } VDIOBUFCALLBACKS; 1581 1582 /** 1583 * Creates a new I/O buffer manager. 1584 * 1585 * @returns VBox status code. 1586 * @param phIoBufMgr Where to store the handle to the I/O buffer manager on success. 1587 * @param cbMax The maximum amount of I/O memory to allow. Trying to allocate more than 1588 * this will lead to out of memory errors. 0 for "unlimited" size (only restriction 1589 * is the available memory on the host). 1590 * @param fFlags Combination of VD_IOBUFMGR_F_*. 1591 * @param pIoBufClbks Memory copy callbacks between source and target memory regions, optional. 1592 * When NULL all I/O buffers must be allocated with a valid S/G buffer laying out the 1593 * memory. 1594 * @param cbIoBufAlloc How much to allocate extra in the I/O buffer for private use. 1595 */ 1596 VBOXDDU_DECL(int) VDIoBufMgrCreate(PVDIOBUFMGR phIoBufMgr, size_t cbMax, uint32_t fFlags, 1597 PVDIOBUFCALLBACKS pIoBufClbks, size_t cbIoBufAlloc); 1598 1599 /** 1600 * Destroys the given I/O buffer manager. 1601 * 1602 * @returns VBox status code. 1603 * @retval VERR_INVALID_STATE if there are still buffers allocated by the given manager. 1604 * @param hIoBufMgr The I/O buffer manager. 1605 */ 1606 VBOXDDU_DECL(int) VDIoBufMgrDestroy(VDIOBUFMGR hIoBufMgr); 1607 1608 /**- 1609 * Allocate a new I/O buffer. 1610 * 1611 * @returns VBox status code. 1612 * @param hIoBufMgr The I/O buffer manager to use. 1613 * @param phIoBuf Where to store the I/O buffer handle on success. 1614 * @param ppvIoBufAlloc Where to store the pointe to the private party on success. 1615 * @param pSgBuf The S/G buffer to use, optional. If NULL the I/O buffer callbacks 1616 * supplied when creating the owning manager are used to transfer the 1617 * data. 1618 * @param cbBuf Size of the buffer in bytes. 1619 */ 1620 VBOXDDU_DECL(int) VDIoBufMgrAllocBuf(VDIOBUFMGR hIoBufMgr, PVDIOBUF phIoBuf, void **ppvIoBufAlloc, 1621 PCRTSGBUF pSgBuf, size_t cbBuf); 1622 1623 /** 1624 * Retains the I/O buffer reference count. 1625 * 1626 * @returns New reference count. 1627 * @param hIoBuf The I/O buffer handle. 1628 */ 1629 VBOXDDU_DECL(uint32_t) VDIoBufRetain(VDIOBUF hIoBuf); 1630 1631 /** 1632 * Releases the given I/O buffer reference. 1633 * 1634 * @returns New reference count, on 0 the I/O buffer is destroyed. 1635 * @param hIoBuf The I/O buffer handle. 1636 */ 1637 VBOXDDU_DECL(uint32_t) VDIoBufRelease(VDIOBUF hIoBuf); 1638 1639 /** @} */ 1640 1641 1394 1642 /** @defgroup grp_vd_ioqueue I/O queues 1395 1643 * @{ … … 1408 1656 /** A I/O request ID. */ 1409 1657 typedef uint64_t VDIOREQID; 1658 1659 /** 1660 * I/O request type. 1661 */ 1662 typedef enum VDIOREQTYPE 1663 { 1664 /** Invalid request type. */ 1665 VDIOREQTYPE_INVALID = 0, 1666 /** Read request. */ 1667 VDIOREQTYPE_READ, 1668 /** Write request. */ 1669 VDIOREQTYPE_WRITE, 1670 /** Flush request. */ 1671 VDIOREQTYPE_FLUSH, 1672 /** Discard request. */ 1673 VDIOREQTYPE_DISCARD, 1674 /** 32bit hack. */ 1675 VDIOREQTYPE_32BIT_HACK = 0x7fffffff 1676 } VDIOREQTYPE; 1677 /** Pointer to a request type. */ 1678 typedef VDIOREQTYPE *PVDIOREQTYPE; 1410 1679 1411 1680 /** … … 1513 1782 1514 1783 /** 1515 * Initiates a read request using the given request handle. 1516 * 1517 * @returns VBox status code. 1518 * @param hVdIoReq The I/O request handle. 1519 * @param off Where to start reading from. 1520 * @param cbRead Number of bytes to read. 1521 * @param pcSgBuf The S/G buffer to use. 1522 */ 1523 VBOXDDU_DECL(int) VDIoQueueReqRead(VDIOREQ hVdIoReq, uint64_t off, size_t cbRead, 1524 PCRTSGBUF pcSgBuf); 1525 1526 /** 1527 * Initiates a write request using the given request handle. 1528 * 1529 * @returns VBox status code. 1530 * @param hVdIoReq The I/O request handle. 1531 * @param off Where to start writing to. 1532 * @param cbWrite Number of bytes to write. 1533 * @param pcSgBuf The S/G buffer to use. 1534 */ 1535 VBOXDDU_DECL(int) VDIoQueueReqWrite(VDIOREQ hVdIoReq, uint64_t off, size_t cbWrite, 1536 PCRTSGBUF pcSgBuf); 1537 1538 /** 1539 * Initiates a flush request using the given request handle. 1540 * 1541 * @returns VBox status code. 1542 * @param hVdIoReq The I/O request handle. 1543 */ 1544 VBOXDDU_DECL(int) VDIoQueueReqFlush(VDIOREQ hVdIoReq); 1545 1546 /** 1547 * Initiates a discard request using the given request handle. 1548 * 1549 * @returns VBox status code. 1550 * @param hVdIoReq The I/O request handle. 1551 * @param paRanges Pointer to the array of ranges to discard. 1552 * @param cRanges Number of entries in the array. 1553 */ 1554 VBOXDDU_DECL(int) VDIoQueueReqDiscard(VDIOREQ hVdIoReq, PCRTRANGE paRanges, 1555 unsigned cRanges); 1784 * Submit a new request to the queue the request was allocated from. 1785 * 1786 * @returns VBox status code. 1787 * @param hVdIoReq The I/O request handle to submit. 1788 * @param enmType The type of the request. 1789 * @param hVdIoIter The iterator to use, NULL for flush requests. 1790 * @param hVdIoBuf The I/O buffer handle to use, NULL for flush and discard requests. 1791 */ 1792 VBOXDDU_DECL(int) VDIoQueueReqSubmit(VDIOREQ hVdIoReq, VDIOREQTYPE enmType, 1793 VDIOITER hVdIoIter, VDIOBUF hVdIoBuf); 1556 1794 1557 1795 /** @} */
Note:
See TracChangeset
for help on using the changeset viewer.