Changeset 7a5c8b8f in mainline
- Timestamp:
- 2011-04-10T16:53:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 92fd730e
- Parents:
- 2715978
- Location:
- uspace/drv/usbmast
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmast/main.c
r2715978 r7a5c8b8f 40 40 #include <errno.h> 41 41 #include <str_error.h> 42 #include "cmds.h" 43 #include "scsi.h" 42 44 43 45 #define NAME "usbmast" … … 45 47 #define BULK_IN_EP 0 46 48 #define BULK_OUT_EP 1 49 50 #define GET_BULK_IN(dev) ((dev)->pipes[BULK_IN_EP].pipe) 51 #define GET_BULK_OUT(dev) ((dev)->pipes[BULK_OUT_EP].pipe) 47 52 48 53 static usb_endpoint_description_t bulk_in_ep = { … … 68 73 NULL 69 74 }; 75 76 #define INQUIRY_RESPONSE_LENGTH 35 77 78 static void try_inquiry(usb_device_t *dev) 79 { 80 usb_massstor_cbw_t cbw; 81 scsi_cmd_inquiry_t inquiry = { 82 .op_code = 0x12, 83 .lun_evpd = 0, 84 .page_code = 0, 85 .alloc_length = INQUIRY_RESPONSE_LENGTH, 86 .ctrl = 0 87 }; 88 size_t response_len; 89 uint8_t response[INQUIRY_RESPONSE_LENGTH]; 90 usb_massstor_csw_t csw; 91 size_t csw_len; 92 93 usb_massstor_cbw_prepare(&cbw, 0xdeadbeef, INQUIRY_RESPONSE_LENGTH, 94 USB_DIRECTION_IN, 0, sizeof(inquiry), (uint8_t *) &inquiry); 95 96 int rc; 97 rc = usb_pipe_write(GET_BULK_OUT(dev), &cbw, sizeof(cbw)); 98 usb_log_debug("Wrote CBW: %s.\n", str_error(rc)); 99 if (rc != EOK) { 100 return; 101 } 102 103 rc = usb_pipe_read(GET_BULK_IN(dev), response, INQUIRY_RESPONSE_LENGTH, 104 &response_len); 105 usb_log_debug("Read response (%zuB): '%s' (%s).\n", response_len, 106 usb_debug_str_buffer(response, response_len, 0), 107 str_error(rc)); 108 if (rc != EOK) { 109 return; 110 } 111 112 rc = usb_pipe_read(GET_BULK_IN(dev), &csw, sizeof(csw), &csw_len); 113 usb_log_debug("Read CSW (%zuB): '%s' (%s).\n", csw_len, 114 usb_debug_str_buffer((uint8_t *) &csw, csw_len, 0), 115 str_error(rc)); 116 117 } 70 118 71 119 /** Callback when new device is attached and recognized as a mass storage. … … 101 149 (size_t) dev->pipes[BULK_OUT_EP].descriptor->max_packet_size); 102 150 151 try_inquiry(dev); 152 103 153 return EOK; 104 154 }
Note:
See TracChangeset
for help on using the changeset viewer.