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