xref: /haiku/src/add-ons/kernel/busses/scsi/usb/proto_module.h (revision 25a7b01d15612846f332751841da3579db313082)
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 #ifndef _PROTO_MODULE_H_
14 	#define _PROTO_MODULE_H_
15 
16 #ifndef _MODULE_H
17 	#include <module.h>
18 #endif /*_MODULE_H*/
19 
20 /*#ifndef _SG_BUFFER_H_
21 	#include "sg_buffer.h"
22 #endif / *_SG_BUFFER_H_*/
23 
24 enum {
25 	/* B_OK */											 /* JFYI:command is OK */
26 	B_CMD_FAILED = B_ERRORS_END + 1, /* command failed */
27 	B_CMD_WIRE_FAILED,							 /* device problems */
28 	B_CMD_UNKNOWN,									 /* command state unknown */
29 };
30 
31 typedef enum{
32 	eDirNone = 0,
33 	eDirIn,
34 	eDirOut,
35 } EDirection;
36 
37 struct _usb_device_info; /* forward, we can be included from device_info.h */
38 
39 typedef void (*ud_transfer_callback)(struct _usb_device_info *udi,
40 									 CCB_SCSIIO *ccbio,
41  									 int32 residue,
42 									 status_t status);
43 
44 typedef struct {
45 	module_info	module;
46 
47 	status_t		 (*init)(struct _usb_device_info *udi);
48 	status_t		(*reset)(struct _usb_device_info *udi);
49 	void		 (*transfer)(struct _usb_device_info *udi,
50 							 uint8 *cmd, uint8	cmdlen,
51 							 //sg_buffer *sgb,
52 							 iovec *sg_data,
53 							 int32	sg_count,
54 							 int32 transfer_len,
55 							 EDirection dir,
56 							 CCB_SCSIIO *ccbio,
57 							 ud_transfer_callback cb);
58 } protocol_module_info;
59 
60 
61 typedef struct {
62 	module_info	module;
63 
64 	status_t (*transform)(struct _usb_device_info *udi,
65 							uint8	*cmd, uint8	 len,
66 							uint8 **rcmd, uint8	*rlen);
67 } transform_module_info;
68 
69 #define MODULE_PREFIX		"generic/usb_scsi_extensions/"
70 #define PROTOCOL_SUFFIX		"/protocol/v1"
71 #define TRANSFORM_SUFFIX 	"/transform/v1"
72 #define PROTOCOL_MODULE_MASK	MODULE_PREFIX"%s"PROTOCOL_SUFFIX
73 #define TRANSFORM_MODULE_MASK	MODULE_PREFIX"%s"TRANSFORM_SUFFIX
74 
75 /**
76 	\define:_TRACE_ALWAYS
77 	trace always - used mainly for error messages
78 */
79 #define PTRACE_ALWAYS(__udi, __x...) \
80 		{ /*if(__udi->b_trace)*/ __udi->trace(true, __x); }
81 /**
82 	\define:TRACE
83 	trace only if logging is activated
84 */
85 #define PTRACE(__udi, __x...) \
86 		{ if(__udi->b_trace) __udi->trace(false, __x); }
87 
88 #endif /* _PROTO_MODULE_H_ */
89 
90