Changeset 7b2c17c in mainline
- Timestamp:
- 2011-07-02T20:42:14Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d2fac08c
- Parents:
- 239e7e10
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmast/inquiry.c
r239e7e10 r7b2c17c 52 52 ((type)( (number) & (BITS_GET_MID_MASK(type, bitcount, offset)) ) >> (offset)) 53 53 54 #define INQUIRY_RESPONSE_LENGTH 3655 56 54 /** Get string representation for SCSI peripheral device type. 57 55 * … … 89 87 usb_massstor_inquiry_result_t *inquiry_result) 90 88 { 89 scsi_std_inquiry_data_t inq_data; 90 size_t response_len; 91 91 scsi_cdb_inquiry_t inquiry = { 92 92 .op_code = SCSI_CMD_INQUIRY, 93 93 .evpd = 0, 94 94 .page_code = 0, 95 .alloc_len = host2uint16_t_be( INQUIRY_RESPONSE_LENGTH),95 .alloc_len = host2uint16_t_be(sizeof(inq_data)), 96 96 .control = 0 97 97 }; 98 size_t response_len;99 uint8_t response[INQUIRY_RESPONSE_LENGTH];100 98 101 99 int rc; … … 103 101 rc = usb_massstor_data_in(dev, bulk_in_idx, bulk_out_idx, 104 102 0xDEADBEEF, 0, (uint8_t *) &inquiry, sizeof(inquiry), 105 response, INQUIRY_RESPONSE_LENGTH, &response_len);103 &inq_data, sizeof(inq_data), &response_len); 106 104 107 105 if (rc != EOK) { … … 111 109 } 112 110 113 if (response_len < 8) {114 usb_log_error("The SCSI response is too short.\n");115 return E RANGE;111 if (response_len < SCSI_STD_INQUIRY_DATA_MIN_SIZE) { 112 usb_log_error("The SCSI inquiry response is too short.\n"); 113 return EIO; 116 114 } 117 115 118 116 /* 119 * This is an ugly part of the code. We will parse the returned 120 * data by hand and try to get as many useful data as possible. 117 * Parse inquiry data and fill in the result structure. 121 118 */ 119 122 120 bzero(inquiry_result, sizeof(*inquiry_result)); 123 121 124 /* This shall be returned by all devices. */125 inquiry_result->peripheral_device_type126 = BITS_GET(uint8_t, response[0], 5, 0);127 inquiry_result->removable = BITS_GET(uint8_t, response[1], 1, 7);122 inquiry_result->device_type = 123 BITS_GET(uint8_t, inq_data.pqual_devtype, 5, 0); 124 inquiry_result->removable = 125 BITS_GET(uint8_t, inq_data.rmb, 1, 7); 128 126 129 if (response_len < 32) {130 return EOK;131 }127 str_ncpy(inquiry_result->vendor, 9, 128 (const char *) &inq_data.vendor, 8); 129 trim_trailing_spaces(inquiry_result->vendor); 132 130 133 str_ncpy(inquiry_result-> vendor_id, 9,134 (const char *) & response[8], 8);135 trim_trailing_spaces(inquiry_result-> vendor_id);131 str_ncpy(inquiry_result->product, 17, 132 (const char *) &inq_data.product, 16); 133 trim_trailing_spaces(inquiry_result->product); 136 134 137 str_ncpy(inquiry_result-> product_and_revision, 12,138 (const char *) & response[16], 11);139 trim_trailing_spaces(inquiry_result-> product_and_revision);135 str_ncpy(inquiry_result->revision, 5, 136 (const char *) &inq_data.revision, 4); 137 trim_trailing_spaces(inquiry_result->revision); 140 138 141 139 return EOK; -
uspace/drv/bus/usb/usbmast/main.c
r239e7e10 r7b2c17c 119 119 120 120 usb_log_info("Mass storage `%s': " \ 121 " `%s' by `%s'is %s (%s), %zu LUN(s).\n",121 "%s by %s rev. %s is %s (%s), %zu LUN(s).\n", 122 122 dev->ddf_dev->name, 123 inquiry.product_and_revision, inquiry.vendor_id, 124 usb_str_masstor_scsi_peripheral_device_type(inquiry.peripheral_device_type), 123 inquiry.product, 124 inquiry.vendor, 125 inquiry.revision, 126 usb_str_masstor_scsi_peripheral_device_type(inquiry.device_type), 125 127 inquiry.removable ? "removable" : "non-removable", 126 128 lun_count); -
uspace/drv/bus/usb/usbmast/mast.h
r239e7e10 r7b2c17c 47 47 */ 48 48 typedef struct { 49 /** SCSI peripheral device type .*/50 int peripheral_device_type;51 /** Whether the device is removable .*/49 /** SCSI peripheral device type */ 50 unsigned device_type; 51 /** Whether the device is removable */ 52 52 bool removable; 53 /** Vendor ID string. */ 54 char vendor_id[9]; 55 /** Product ID and product revision string. */ 56 char product_and_revision[12]; 53 /** Vendor ID string */ 54 char vendor[9]; 55 /** Product ID string */ 56 char product[17]; 57 /** Revision string */ 58 char revision[17]; 57 59 } usb_massstor_inquiry_result_t; 58 60 -
uspace/lib/scsi/include/scsi/spc.h
r239e7e10 r7b2c17c 58 58 } __attribute__((packed)) scsi_cdb_inquiry_t; 59 59 60 /** Minimum size of inquiry data required since SCSI-2 */ 61 #define SCSI_STD_INQUIRY_DATA_MIN_SIZE 36 62 63 /** Standard inquiry data. 64 * 65 * Returned for Inquiry command with evpd bit cleared. 66 */ 67 typedef struct { 68 /** Peripheral qualifier, Peripheral device type */ 69 uint8_t pqual_devtype; 70 /** RMB, reserved */ 71 uint8_t rmb; 72 /** Version */ 73 uint8_t version; 74 /** Obsolete, NormACA, HiSup, Response Data Format */ 75 uint8_t aca_hisup_rdf; 76 /** Additional Length */ 77 uint8_t additional_len; 78 /** SCCS, ACC, TPGS, 3PC, Reserved, Protect */ 79 uint8_t cap1; 80 /** Obsolete, EncServ, VS, MuliP, Obsolete, Addr16 */ 81 uint8_t cap2; 82 /** Obsolete, WBus16, Sync, Obsolete, CmdQue, VS */ 83 uint8_t cap3; 84 85 /** Vendor string */ 86 uint8_t vendor[8]; 87 /** Product string */ 88 uint8_t product[16]; 89 /** Revision string */ 90 uint8_t revision[4]; 91 92 /* End of required data */ 93 } scsi_std_inquiry_data_t; 94 60 95 /** SCSI peripheral device type */ 61 96 enum scsi_device_type {
Note:
See TracChangeset
for help on using the changeset viewer.