Changeset 0feaae4 in mainline for uspace/drv/bus/usb


Ignore:
Timestamp:
2011-07-02T17:21:50Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
239e7e10
Parents:
2429e4a
Message:

Factor out standard SCSI code from usbmast to a separate SCSI library.

Location:
uspace/drv/bus/usb/usbmast
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbmast/Makefile

    r2429e4a r0feaae4  
    3232        $(LIBUSBDEV_PREFIX)/libusbdev.a \
    3333        $(LIBUSB_PREFIX)/libusb.a \
    34         $(LIBDRV_PREFIX)/libdrv.a
     34        $(LIBDRV_PREFIX)/libdrv.a \
     35        $(LIBSCSI_PREFIX)/libscsi.a
    3536
    3637EXTRA_CFLAGS += \
    3738        -I$(LIBUSB_PREFIX)/include \
    3839        -I$(LIBUSBDEV_PREFIX)/include \
    39         -I$(LIBDRV_PREFIX)/include
     40        -I$(LIBDRV_PREFIX)/include \
     41        -I$(LIBSCSI_PREFIX)/include
    4042
    4143BINARY = usbmast
  • uspace/drv/bus/usb/usbmast/inquiry.c

    r2429e4a r0feaae4  
    4242#include <str.h>
    4343#include <ctype.h>
     44#include <scsi/spc.h>
    4445#include "cmds.h"
    45 #include "scsi.h"
    4646#include "mast.h"
    4747
     
    5454#define INQUIRY_RESPONSE_LENGTH 36
    5555
    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, // 0x13
    80         STR_UNKNOWN, // 0x14
    81         STR_UNKNOWN, // 0x15
    82         STR_UNKNOWN, // 0x16
    83         STR_UNKNOWN, // 0x17
    84         STR_UNKNOWN, // 0x18
    85         STR_UNKNOWN, // 0x19
    86         STR_UNKNOWN, // 0x1A
    87         STR_UNKNOWN, // 0x1B
    88         STR_UNKNOWN, // 0x1C
    89         STR_UNKNOWN, // 0x1D
    90         "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 
    9656/** Get string representation for SCSI peripheral device type.
    97  *
    98  * See for example here for a list
    99  * http://en.wikipedia.org/wiki/SCSI_Peripheral_Device_Type.
    10057 *
    10158 * @param type SCSI peripheral device type code.
    10259 * @return String representation.
    10360 */
    104 const char *usb_str_masstor_scsi_peripheral_device_type(int type)
     61const char *usb_str_masstor_scsi_peripheral_device_type(unsigned type)
    10562{
    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);
    11164}
    11265
     
    13689    usb_massstor_inquiry_result_t *inquiry_result)
    13790{
    138         scsi_cmd_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,
    14194                .page_code = 0,
    142                 .alloc_length = host2uint16_t_be(INQUIRY_RESPONSE_LENGTH),
    143                 .ctrl = 0
     95                .alloc_len = host2uint16_t_be(INQUIRY_RESPONSE_LENGTH),
     96                .control = 0
    14497        };
    14598        size_t response_len;
  • uspace/drv/bus/usb/usbmast/main.c

    r2429e4a r0feaae4  
    4141#include <str_error.h>
    4242#include "cmds.h"
    43 #include "scsi.h"
    4443#include "mast.h"
    4544
     
    107106            (size_t) dev->pipes[BULK_OUT_EP].descriptor->max_packet_size);
    108107
     108/*      usb_log_debug("Get LUN count...\n");
    109109        size_t lun_count = usb_masstor_get_lun_count(dev);
    110 
     110  */ size_t lun_count=1;
     111        usb_log_debug("Inquire...\n");
    111112        usb_massstor_inquiry_result_t inquiry;
    112113        rc = usb_massstor_inquiry(dev, BULK_IN_EP, BULK_OUT_EP, &inquiry);
    113114        if (rc != EOK) {
    114                 usb_log_warning("Failed to inquiry device `%s': %s.\n",
     115                usb_log_warning("Failed to inquire device `%s': %s.\n",
    115116                    dev->ddf_dev->name, str_error(rc));
    116117                return EOK;
  • uspace/drv/bus/usb/usbmast/mast.h

    r2429e4a r0feaae4  
    6565int usb_massstor_inquiry(usb_device_t *, size_t, size_t,
    6666    usb_massstor_inquiry_result_t *);
    67 const char *usb_str_masstor_scsi_peripheral_device_type(int);
     67const char *usb_str_masstor_scsi_peripheral_device_type(unsigned);
    6868
    6969#endif
Note: See TracChangeset for help on using the changeset viewer.