Changeset 0feaae4 in mainline
- Timestamp:
- 2011-07-02T17:21:50Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 239e7e10
- Parents:
- 2429e4a
- Location:
- uspace
- Files:
-
- 2 added
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile
r2429e4a r0feaae4 165 165 lib/block \ 166 166 lib/clui \ 167 lib/scsi \ 167 168 lib/softint \ 168 169 lib/softfloat \ -
uspace/Makefile.common
r2429e4a r0feaae4 120 120 LIBNET_PREFIX = $(LIB_PREFIX)/net 121 121 122 LIBSCSI_PREFIX = $(LIB_PREFIX)/scsi 123 122 124 ifeq ($(STATIC_NEEDED),y) 123 125 STATIC_BUILD = y -
uspace/drv/bus/usb/usbmast/Makefile
r2429e4a r0feaae4 32 32 $(LIBUSBDEV_PREFIX)/libusbdev.a \ 33 33 $(LIBUSB_PREFIX)/libusb.a \ 34 $(LIBDRV_PREFIX)/libdrv.a 34 $(LIBDRV_PREFIX)/libdrv.a \ 35 $(LIBSCSI_PREFIX)/libscsi.a 35 36 36 37 EXTRA_CFLAGS += \ 37 38 -I$(LIBUSB_PREFIX)/include \ 38 39 -I$(LIBUSBDEV_PREFIX)/include \ 39 -I$(LIBDRV_PREFIX)/include 40 -I$(LIBDRV_PREFIX)/include \ 41 -I$(LIBSCSI_PREFIX)/include 40 42 41 43 BINARY = usbmast -
uspace/drv/bus/usb/usbmast/inquiry.c
r2429e4a r0feaae4 42 42 #include <str.h> 43 43 #include <ctype.h> 44 #include <scsi/spc.h> 44 45 #include "cmds.h" 45 #include "scsi.h"46 46 #include "mast.h" 47 47 … … 54 54 #define INQUIRY_RESPONSE_LENGTH 36 55 55 56 #define STR_UNKNOWN "<unknown>"57 58 /** String constants for SCSI peripheral device types. */59 static const char *str_peripheral_device_types[] = {60 "direct-access device",61 "sequential-access device",62 "printer device",63 "processor device",64 "write-once device",65 "CDROM device",66 "scanner device",67 "optical memory device",68 "medium changer",69 "communications device",70 "graphic arts pre-press device",71 "graphic arts pre-press device",72 "storage array controller device",73 "enclosure services device",74 "simplified direct-access device",75 "optical card reader/writer device",76 "bridging expander",77 "object-based storage device",78 "automation driver interface",79 STR_UNKNOWN, // 0x1380 STR_UNKNOWN, // 0x1481 STR_UNKNOWN, // 0x1582 STR_UNKNOWN, // 0x1683 STR_UNKNOWN, // 0x1784 STR_UNKNOWN, // 0x1885 STR_UNKNOWN, // 0x1986 STR_UNKNOWN, // 0x1A87 STR_UNKNOWN, // 0x1B88 STR_UNKNOWN, // 0x1C89 STR_UNKNOWN, // 0x1D90 "well-known logical unit",91 "uknown or no device state"92 };93 #define str_peripheral_device_types_count \94 (sizeof(str_peripheral_device_types)/sizeof(str_peripheral_device_types[0]))95 96 56 /** Get string representation for SCSI peripheral device type. 97 *98 * See for example here for a list99 * http://en.wikipedia.org/wiki/SCSI_Peripheral_Device_Type.100 57 * 101 58 * @param type SCSI peripheral device type code. 102 59 * @return String representation. 103 60 */ 104 const char *usb_str_masstor_scsi_peripheral_device_type( inttype)61 const char *usb_str_masstor_scsi_peripheral_device_type(unsigned type) 105 62 { 106 if ((type < 0) 107 || ((size_t)type >= str_peripheral_device_types_count)) { 108 return STR_UNKNOWN; 109 } 110 return str_peripheral_device_types[type]; 63 return scsi_get_dev_type_str(type); 111 64 } 112 65 … … 136 89 usb_massstor_inquiry_result_t *inquiry_result) 137 90 { 138 scsi_c md_inquiry_t inquiry = {139 .op_code = 0x12,140 . lun_evpd = 0,91 scsi_cdb_inquiry_t inquiry = { 92 .op_code = SCSI_CMD_INQUIRY, 93 .evpd = 0, 141 94 .page_code = 0, 142 .alloc_len gth= host2uint16_t_be(INQUIRY_RESPONSE_LENGTH),143 .c trl = 095 .alloc_len = host2uint16_t_be(INQUIRY_RESPONSE_LENGTH), 96 .control = 0 144 97 }; 145 98 size_t response_len; -
uspace/drv/bus/usb/usbmast/main.c
r2429e4a r0feaae4 41 41 #include <str_error.h> 42 42 #include "cmds.h" 43 #include "scsi.h"44 43 #include "mast.h" 45 44 … … 107 106 (size_t) dev->pipes[BULK_OUT_EP].descriptor->max_packet_size); 108 107 108 /* usb_log_debug("Get LUN count...\n"); 109 109 size_t lun_count = usb_masstor_get_lun_count(dev); 110 110 */ size_t lun_count=1; 111 usb_log_debug("Inquire...\n"); 111 112 usb_massstor_inquiry_result_t inquiry; 112 113 rc = usb_massstor_inquiry(dev, BULK_IN_EP, BULK_OUT_EP, &inquiry); 113 114 if (rc != EOK) { 114 usb_log_warning("Failed to inquir ydevice `%s': %s.\n",115 usb_log_warning("Failed to inquire device `%s': %s.\n", 115 116 dev->ddf_dev->name, str_error(rc)); 116 117 return EOK; -
uspace/drv/bus/usb/usbmast/mast.h
r2429e4a r0feaae4 65 65 int usb_massstor_inquiry(usb_device_t *, size_t, size_t, 66 66 usb_massstor_inquiry_result_t *); 67 const char *usb_str_masstor_scsi_peripheral_device_type( int);67 const char *usb_str_masstor_scsi_peripheral_device_type(unsigned); 68 68 69 69 #endif -
uspace/lib/scsi/include/scsi/spc.h
r2429e4a r0feaae4 1 1 /* 2 * Copyright (c) 2011 Vojtech Horky2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup drvusbmast29 /** @addtogroup libscsi 30 30 * @{ 31 31 */ 32 /** @file33 * SCSI related structures.32 /** 33 * @file SCSI Primary Commands. 34 34 */ 35 35 36 #ifndef USB_USBMAST_SCSI_H_37 #define USB_USBMAST_SCSI_H_36 #ifndef LIBSCSI_SPC_H_ 37 #define LIBSCSI_SPC_H_ 38 38 39 #include <sys/types.h> 40 #include <usb/usb.h> 39 #include <stdint.h> 41 40 41 /** SCSI command codes defined in SCSI-SPC */ 42 enum scsi_cmd_spc { 43 SCSI_CMD_INQUIRY = 0x12 44 }; 45 46 /** SCSI Inquiry command */ 42 47 typedef struct { 48 /** Operation code (12h, SCSI_CMD_INQUIRY) */ 43 49 uint8_t op_code; 44 uint8_t lun_evpd; 50 /** Reserved:7-2, obsolete:1, evpd:0 */ 51 uint8_t evpd; 52 /* Page Code */ 45 53 uint8_t page_code; 46 uint16_t alloc_length; 47 uint8_t ctrl; 48 } __attribute__((packed)) scsi_cmd_inquiry_t; 54 /* Allocation Length */ 55 uint16_t alloc_len; 56 /* Control */ 57 uint8_t control; 58 } __attribute__((packed)) scsi_cdb_inquiry_t; 59 60 /** SCSI peripheral device type */ 61 enum scsi_device_type { 62 SCSI_DEV_BLOCK = 0x00, 63 SCSI_DEV_STREAM = 0x01, 64 SCSI_DEV_CD_DVD = 0x05, 65 SCSI_DEV_CHANGER = 0x08, 66 SCSI_DEV_ENCLOSURE = 0x0d, 67 SCSI_DEV_OSD = 0x11, 68 69 SCSI_DEV_LIMIT = 0x20 70 }; 71 72 extern const char *scsi_dev_type_str[SCSI_DEV_LIMIT]; 73 extern const char *scsi_get_dev_type_str(unsigned); 49 74 50 75 #endif 51 76 52 /** 53 * @} 77 /** @} 54 78 */
Note:
See TracChangeset
for help on using the changeset viewer.