1 /************************************************************************** 2 * 3 * Copyright (C) 2014 Red Hat Inc. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included 13 * in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * OTHER DEALINGS IN THE SOFTWARE. 22 * 23 **************************************************************************/ 24 #ifndef VREND_IOV_H 25 #define VREND_IOV_H 26 27 #include <stdint.h> 28 #include <stdbool.h> 29 #include "config.h" 30 31 #ifdef HAVE_SYS_UIO_H 32 #include <sys/uio.h> 33 #else 34 struct iovec { 35 void *iov_base; 36 size_t iov_len; 37 }; 38 #endif 39 40 struct vrend_transfer_info { 41 int level; 42 uint32_t stride; 43 uint32_t layer_stride; 44 unsigned int iovec_cnt; 45 const struct iovec *iovec; 46 uint64_t offset; 47 struct pipe_box *box; 48 bool synchronized; 49 }; 50 51 typedef void (*iov_cb)(void *cookie, unsigned int doff, void *src, int len); 52 53 size_t vrend_get_iovec_size(const struct iovec *iov, int iovlen); 54 size_t vrend_read_from_iovec(const struct iovec *iov, int iov_cnt, 55 size_t offset, char *buf, size_t bytes); 56 size_t vrend_write_to_iovec(const struct iovec *iov, int iov_cnt, 57 size_t offset, const char *buf, size_t bytes); 58 59 size_t vrend_read_from_iovec_cb(const struct iovec *iov, int iov_cnt, 60 size_t offset, size_t bytes, iov_cb iocb, void *cookie); 61 62 int vrend_copy_iovec(const struct iovec *src_iov, int src_iovlen, size_t src_offset, 63 const struct iovec *dst_iov, int dst_iovlen, size_t dst_offset, 64 size_t count, char *buf); 65 66 #endif 67