xref: /haiku/src/add-ons/kernel/busses/scsi/usb/sg_buffer.h (revision b617a7b410c05275effb95f4b2f5608359d9b7b9)
1 /**
2  *
3  * TODO: description
4  *
5  * This file is a part of USB SCSI CAM for Haiku.
6  * May be used under terms of the MIT License
7  *
8  * Author(s):
9  * 	Siarzhuk Zharski <imker@gmx.li>
10  *
11  *
12  */
13 /** handling SCSI data-buffer (both usual "plain" and scatter/gather ones) */
14 
15 #ifndef _SG_BUFFER_H_
16 	#define _SG_BUFFER_H_
17 
18 #ifndef _IOVEC_H
19 	#include <iovec.h>
20 #endif/*_IOVEC_H*/
21 
22 /**
23 	\struct:_sg_buffer
24 */
25 typedef struct _sg_buffer{
26 	iovec	iov;	 /**< to avoid extra memory allocations */
27 	iovec *piov;	/**< ptr to scatter/gather list, default is equal to &iov */
28 	int		count; /**< count of scatter/gather vector entries */
29 	bool	 b_own; /**< was allocated - must be freed */
30 } sg_buffer;
31 
32 #define member_offset(__type, __member) ((size_t)&(((__type *)0)->__member))
33 #define member_size(__type, __member) sizeof(((__type *)0)->__member)
34 
35 status_t init_sg_buffer(sg_buffer *sgb, CCB_SCSIIO *ccbio);
36 status_t realloc_sg_buffer(sg_buffer *sgb, size_t size);
37 status_t sg_buffer_len(sg_buffer *sgb, size_t *size);
38 status_t sg_access_byte(sg_buffer *sgb, off_t offset, uchar *byte, bool b_set);
39 status_t sg_memcpy(sg_buffer *dest_sgb, off_t dest_offset,
40 									 sg_buffer *src_sgb,	off_t src_offset, size_t size);
41 void free_sg_buffer(sg_buffer *sgb);
42 
43 #endif /*_SG_BUFFER_H_*/
44 
45