1 /* 2 * Copyright (c) 2003-2005 by Siarzhuk Zharski <imker@gmx.li> 3 * Distributed under the terms of the BSD License. 4 * 5 */ 6 7 /** handling SCSI data-buffer (both usual "plain" and scatter/gather ones) */ 8 9 #ifndef _SG_BUFFER_H_ 10 #define _SG_BUFFER_H_ 11 12 #ifndef _IOVEC_H 13 #include <iovec.h> 14 #endif/*_IOVEC_H*/ 15 16 /** 17 \struct:_sg_buffer 18 */ 19 typedef struct _sg_buffer{ 20 iovec iov; /**< to avoid extra memory allocations */ 21 iovec *piov; /**< ptr to scatter/gather list, default is equal to &iov */ 22 int count; /**< count of scatter/gather vector entries */ 23 bool b_own; /**< was allocated - must be freed */ 24 } sg_buffer; 25 26 #define member_offset(__type, __member) ((size_t)&(((__type *)0)->__member)) 27 #define member_size(__type, __member) sizeof(((__type *)0)->__member) 28 29 status_t init_sg_buffer(sg_buffer *sgb, CCB_SCSIIO *ccbio); 30 status_t realloc_sg_buffer(sg_buffer *sgb, size_t size); 31 status_t sg_buffer_len(sg_buffer *sgb, size_t *size); 32 status_t sg_access_byte(sg_buffer *sgb, off_t offset, uchar *byte, bool b_set); 33 status_t sg_memcpy(sg_buffer *dest_sgb, off_t dest_offset, 34 sg_buffer *src_sgb, off_t src_offset, size_t size); 35 void free_sg_buffer(sg_buffer *sgb); 36 37 #endif /*_SG_BUFFER_H_*/ 38