Changeset 7a5c8b8f in mainline


Ignore:
Timestamp:
2011-04-10T16:53:44Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
92fd730e
Parents:
2715978
Message:

Hackish SCSI INQUIRY command in usbmast

Location:
uspace/drv/usbmast
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbmast/main.c

    r2715978 r7a5c8b8f  
    4040#include <errno.h>
    4141#include <str_error.h>
     42#include "cmds.h"
     43#include "scsi.h"
    4244
    4345#define NAME "usbmast"
     
    4547#define BULK_IN_EP 0
    4648#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)
    4752
    4853static usb_endpoint_description_t bulk_in_ep = {
     
    6873        NULL
    6974};
     75
     76#define INQUIRY_RESPONSE_LENGTH 35
     77
     78static 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}
    70118
    71119/** Callback when new device is attached and recognized as a mass storage.
     
    101149            (size_t) dev->pipes[BULK_OUT_EP].descriptor->max_packet_size);
    102150
     151        try_inquiry(dev);
     152
    103153        return EOK;
    104154}
Note: See TracChangeset for help on using the changeset viewer.