4 #include <linux/blkdev.h>
6 /* Bulk only data structures */
8 /* command block wrapper */
10 __le32 Signature
; /* contains 'USBC' */
11 __u32 Tag
; /* unique per command id */
12 __le32 DataTransferLength
; /* size of data */
13 __u8 Flags
; /* direction in bit 0 */
14 __u8 Lun
; /* LUN normally 0 */
15 __u8 Length
; /* of of the CDB */
16 __u8 CDB
[16]; /* max command */
19 #define US_BULK_CB_WRAP_LEN 31
20 #define US_BULK_CB_SIGN 0x43425355 /*spells out USBC */
21 #define US_BULK_FLAG_IN 1
22 #define US_BULK_FLAG_OUT 0
24 /* command status wrapper */
26 __le32 Signature
; /* should = 'USBS' */
27 __u32 Tag
; /* same as original command */
28 __le32 Residue
; /* amount not transferred */
29 __u8 Status
; /* see below */
33 #define US_BULK_CS_WRAP_LEN 13
34 #define US_BULK_CS_SIGN 0x53425355 /* spells out 'USBS' */
35 #define US_BULK_STAT_OK 0
36 #define US_BULK_STAT_FAIL 1
37 #define US_BULK_STAT_PHASE 2
39 /* bulk-only class specific requests */
40 #define US_BULK_RESET_REQUEST 0xff
41 #define US_BULK_GET_MAX_LUN 0xfe
43 /* usb_stor_bulk_transfer_xxx() return codes, in order of severity */
44 #define USB_STOR_XFER_GOOD 0 /* good transfer */
45 #define USB_STOR_XFER_SHORT 1 /* transferred less than expected */
46 #define USB_STOR_XFER_STALLED 2 /* endpoint stalled */
47 #define USB_STOR_XFER_LONG 3 /* device tried to send too much */
48 #define USB_STOR_XFER_ERROR 4 /* transfer died in the middle */
50 /* Transport return codes */
51 #define USB_STOR_TRANSPORT_GOOD 0 /* Transport good, command good */
52 #define USB_STOR_TRANSPORT_FAILED 1 /* Transport good, command failed */
53 #define USB_STOR_TRANSPORT_NO_SENSE 2 /* Command failed, no auto-sense */
54 #define USB_STOR_TRANSPORT_ERROR 3 /* Transport bad (i.e. device dead) */
57 * We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED
58 * return codes. But now the transport and low-level transfer routines
59 * treat an abort as just another error (-ENOENT for a cancelled URB).
60 * It is up to the invoke_transport() function to test for aborts and
61 * distinguish them from genuine communication errors.
64 /* CBI accept device specific command */
66 extern int usb_stor_Bulk_transport(struct scsi_cmnd
*, struct us_data
*);
67 extern int usb_stor_Bulk_max_lun(struct us_data
*);
68 extern int usb_stor_Bulk_reset(struct us_data
*);
69 extern void usb_stor_print_cmd(struct scsi_cmnd
*);
70 extern void usb_stor_invoke_transport(struct scsi_cmnd
*, struct us_data
*);
71 extern void usb_stor_stop_transport(struct us_data
*);
72 extern int usb_stor_control_msg(struct us_data
*us
, unsigned int pipe
,
73 u8 request
, u8 requesttype
, u16 value
, u16 index
,
74 void *data
, u16 size
, int timeout
);
75 extern int usb_stor_clear_halt(struct us_data
*us
, unsigned int pipe
);
76 extern int usb_stor_bulk_transfer_buf(struct us_data
*us
, unsigned int pipe
,
77 void *buf
, unsigned int length
, unsigned int *act_len
);
78 extern int usb_stor_bulk_transfer_sg(struct us_data
*us
, unsigned int pipe
,
79 void *buf
, unsigned int length
, int use_sg
, int *residual
);
80 extern int usb_stor_bulk_srb(struct us_data
* us
, unsigned int pipe
,
81 struct scsi_cmnd
* srb
);
82 extern int usb_stor_port_reset(struct us_data
*us
);
84 /* Protocol handling routines */
85 enum xfer_buf_dir
{TO_XFER_BUF
, FROM_XFER_BUF
};
86 extern unsigned int usb_stor_access_xfer_buf(struct us_data
*, unsigned char *buffer
,
87 unsigned int buflen
, struct scsi_cmnd
*srb
, struct scatterlist
**,
88 unsigned int *offset
, enum xfer_buf_dir dir
);
89 extern void usb_stor_set_xfer_buf(struct us_data
*, unsigned char *buffer
, unsigned int buflen
, struct scsi_cmnd
*srb
,
93 extern void ENE_stor_invoke_transport(struct scsi_cmnd
*, struct us_data
*);
94 extern int ENE_InitMedia(struct us_data
*);
95 extern int ENE_SDInit(struct us_data
*);
96 extern int ENE_MSInit(struct us_data
*);
97 extern int ENE_SMInit(struct us_data
*);
98 extern int ENE_ReadSDReg(struct us_data
*, u8
*);
99 extern int ENE_SendScsiCmd(struct us_data
*, BYTE
, void*, int);
100 extern int ENE_LoadBinCode(struct us_data
*, BYTE
);
101 extern int ENE_Read_BYTE(struct us_data
*, WORD index
, void *buf
);
102 extern int ENE_Read_Data(struct us_data
*, void *buf
, unsigned int length
);
103 extern int ENE_Write_Data(struct us_data
*, void *buf
, unsigned int length
);
104 extern void BuildSenseBuffer(struct scsi_cmnd
*, int);
107 extern int SD_SCSIIrp(struct us_data
*us
, struct scsi_cmnd
*srb
);
108 extern int MS_SCSIIrp(struct us_data
*us
, struct scsi_cmnd
*srb
);
109 extern int SM_SCSIIrp(struct us_data
*us
, struct scsi_cmnd
*srb
);
112 extern int MS_CardInit(struct us_data
*us
);
113 extern void MS_LibFreeAllocatedArea(struct us_data
*us
);
114 extern void MS_LibFreeWriteBuf(struct us_data
*us
);
115 extern int MS_LibFreeLogicalMap(struct us_data
*us
);
116 extern int MS_LibForceSetLogicalPair(struct us_data
*us
, WORD logblk
, WORD phyblk
);
117 extern int MS_ReaderReadPage(struct us_data
*us
, DWORD PhyBlockAddr
, BYTE PageNum
, DWORD
*PageBuf
, MS_LibTypeExtdat
*ExtraDat
);
118 extern int MS_ReaderCopyBlock(struct us_data
*us
, WORD oldphy
, WORD newphy
, WORD PhyBlockAddr
, BYTE PageNum
, PBYTE buf
, WORD len
);
119 extern int MS_ReaderEraseBlock(struct us_data
*us
, DWORD PhyBlockAddr
);
120 extern int MS_LibProcessBootBlock(struct us_data
*us
, WORD PhyBlock
, BYTE
*PageData
);
121 extern int MS_LibAllocLogicalMap(struct us_data
*us
);
122 extern int MS_LibSetBootBlockMark(struct us_data
*us
, WORD phyblk
);
123 extern int MS_LibSetLogicalBlockMark(struct us_data
*us
, WORD phyblk
, WORD mark
);
124 extern int MS_LibSetInitialErrorBlock(struct us_data
*us
, WORD phyblk
);
125 extern int MS_LibScanLogicalBlockNumber(struct us_data
*us
, WORD phyblk
);
126 extern int MS_LibAllocWriteBuf(struct us_data
*us
);
127 void MS_LibClearWriteBuf(struct us_data
*us
);
128 void MS_LibPhy2LogRange(WORD PhyBlock
, WORD
*LogStart
, WORD
*LogEnde
);
129 extern int MS_LibReadExtra(struct us_data
*us
, DWORD PhyBlock
, BYTE PageNum
, MS_LibTypeExtdat
*ExtraDat
);
130 extern int MS_LibReadExtraBlock(struct us_data
*us
, DWORD PhyBlock
, BYTE PageNum
, BYTE blen
, void *buf
);
131 extern int MS_LibSetAcquiredErrorBlock(struct us_data
*us
, WORD phyblk
);
132 extern int MS_LibErasePhyBlock(struct us_data
*us
, WORD phyblk
);
133 extern int MS_LibErrorPhyBlock(struct us_data
*us
, WORD phyblk
);
134 extern int MS_LibOverwriteExtra(struct us_data
*us
, DWORD PhyBlockAddr
, BYTE PageNum
, BYTE OverwriteFlag
);
135 extern int MS_LibSetLogicalPair(struct us_data
*us
, WORD logblk
, WORD phyblk
);
136 extern int MS_LibCheckDisableBlock(struct us_data
*us
, WORD PhyBlock
);
137 extern int MS_CountFreeBlock(struct us_data
*us
, WORD PhyBlock
);
138 extern int MS_LibSearchBlockFromLogical(struct us_data
*us
, WORD logblk
);
139 extern int MS_LibSearchBlockFromPhysical(struct us_data
*us
, WORD phyblk
);
142 extern int SM_FreeMem(void);