Changeset de3432b in mainline for uspace/drv/bus/usb/usbmast/bo_trans.c
- Timestamp:
- 2011-07-24T18:09:09Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1bfae13, 358dc13, eff10e03
- Parents:
- 582fe388
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmast/bo_trans.c
r582fe388 rde3432b 58 58 * @param tag Command block wrapper tag (automatically compared 59 59 * with answer) 60 * @param cmd Command block 61 * @param cmd_size Command block size in bytes 62 * @param ddir Direction in which data will be transferred 63 * @param dbuf Data send/receive buffer 64 * @param dbuf_size Size of the data buffer 65 * @param xferred_size Number of bytes actually transferred 66 * @param cmd_status Command status 60 * @param cmd SCSI command 67 61 * 68 62 * @return Error code 69 63 */ 70 static int usb_massstor_cmd(usbmast_fun_t *mfun, uint32_t tag, const void *cmd, 71 size_t cmd_size, usb_direction_t ddir, void *dbuf, size_t dbuf_size, 72 size_t *xferred_size, cmd_status_t *cmd_status) 64 int usb_massstor_cmd(usbmast_fun_t *mfun, uint32_t tag, scsi_cmd_t *cmd) 73 65 { 74 66 int rc; … … 77 69 usb_pipe_t *bulk_in_pipe = mfun->mdev->usb_dev->pipes[BULK_IN_EP].pipe; 78 70 usb_pipe_t *bulk_out_pipe = mfun->mdev->usb_dev->pipes[BULK_OUT_EP].pipe; 71 usb_direction_t ddir; 72 void *dbuf; 73 size_t dbuf_size; 74 75 if (cmd->data_out != NULL && cmd->data_in == NULL) { 76 ddir = USB_DIRECTION_OUT; 77 dbuf = (void *)cmd->data_out; 78 dbuf_size = cmd->data_out_size; 79 } else if (cmd->data_out == NULL && cmd->data_in != NULL) { 80 ddir = USB_DIRECTION_IN; 81 dbuf = cmd->data_in; 82 dbuf_size = cmd->data_in_size; 83 } else { 84 assert(false); 85 } 79 86 80 87 /* Prepare CBW - command block wrapper */ 81 88 usb_massstor_cbw_t cbw; 82 89 usb_massstor_cbw_prepare(&cbw, tag, dbuf_size, ddir, mfun->lun, 83 cmd _size, cmd);90 cmd->cdb_size, cmd->cdb); 84 91 85 92 /* Send the CBW. */ … … 148 155 switch (csw.dCSWStatus) { 149 156 case cbs_passed: 150 *cmd_status = CMDS_GOOD;157 cmd->status = CMDS_GOOD; 151 158 break; 152 159 case cbs_failed: 153 160 MASTLOG("Command failed\n"); 154 *cmd_status = CMDS_FAILED;161 cmd->status = CMDS_FAILED; 155 162 break; 156 163 case cbs_phase_error: … … 177 184 */ 178 185 179 if ( xferred_size != NULL)180 *xferred_size = dbuf_size - residue;186 if (ddir == USB_DIRECTION_IN) 187 cmd->rcvd_size = dbuf_size - residue; 181 188 182 189 return retval; 183 }184 185 /** Perform data-in command.186 *187 * @param mfun Mass storage function188 * @param tag Command block wrapper tag (automatically compared with189 * answer)190 * @param cmd CDB (Command Descriptor)191 * @param cmd_size CDB length in bytes192 * @param dbuf Data receive buffer193 * @param dbuf_size Data receive buffer size in bytes194 * @param proc_size Number of bytes actually processed by device195 * @param cmd_status Command status196 *197 * @return Error code198 */199 int usb_massstor_data_in(usbmast_fun_t *mfun, uint32_t tag, const void *cmd,200 size_t cmd_size, void *dbuf, size_t dbuf_size, size_t *proc_size,201 cmd_status_t *cmd_status)202 {203 return usb_massstor_cmd(mfun, tag, cmd, cmd_size, USB_DIRECTION_IN,204 dbuf, dbuf_size, proc_size, cmd_status);205 }206 207 /** Perform data-out command.208 *209 * @param mfun Mass storage function210 * @param tag Command block wrapper tag (automatically compared with211 * answer)212 * @param cmd CDB (Command Descriptor)213 * @param cmd_size CDB length in bytes214 * @param data Command data215 * @param data_size Size of @a data in bytes216 * @param proc_size Number of bytes actually processed by device217 * @param cmd_status Command status218 *219 * @return Error code220 */221 int usb_massstor_data_out(usbmast_fun_t *mfun, uint32_t tag, const void *cmd,222 size_t cmd_size, const void *data, size_t data_size, size_t *proc_size,223 cmd_status_t *cmd_status)224 {225 return usb_massstor_cmd(mfun, tag, cmd, cmd_size, USB_DIRECTION_OUT,226 (void *) data, data_size, proc_size, cmd_status);227 190 } 228 191
Note:
See TracChangeset
for help on using the changeset viewer.