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