Changes in / [d59d0bb:9be8669] in mainline


Ignore:
Location:
uspace
Files:
66 added
59 deleted
39 edited

Legend:

Unmodified
Added
Removed
  • uspace/Makefile

    rd59d0bb r9be8669  
    122122                drv/uhci-rhd \
    123123                drv/usbflbk \
     124                drv/usbkbd \
    124125                drv/usbhid \
    125126                drv/usbhub \
     
    143144                drv/uhci-rhd \
    144145                drv/usbflbk \
     146                drv/usbkbd \
    145147                drv/usbhid \
    146148                drv/usbhub \
     
    177179ifeq ($(UARCH),amd64)
    178180        LIBS += lib/usb
    179         LIBS += lib/usbhost
    180         LIBS += lib/usbdev
    181         LIBS += lib/usbhid
    182181        LIBS += lib/usbvirt
    183182endif
     
    185184ifeq ($(UARCH),ia32)
    186185        LIBS += lib/usb
    187         LIBS += lib/usbhost
    188         LIBS += lib/usbdev
    189         LIBS += lib/usbhid
    190186        LIBS += lib/usbvirt
    191187endif
  • uspace/Makefile.common

    rd59d0bb r9be8669  
    8888
    8989LIBUSB_PREFIX = $(LIB_PREFIX)/usb
    90 LIBUSBHOST_PREFIX = $(LIB_PREFIX)/usbhost
    91 LIBUSBDEV_PREFIX = $(LIB_PREFIX)/usbdev
    92 LIBUSBHID_PREFIX = $(LIB_PREFIX)/usbhid
    9390LIBUSBVIRT_PREFIX = $(LIB_PREFIX)/usbvirt
    9491LIBDRV_PREFIX = $(LIB_PREFIX)/drv
  • uspace/app/lsusb/Makefile

    rd59d0bb r9be8669  
    3030BINARY = lsusb
    3131
    32 LIBS = \
    33         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    34         $(LIBUSB_PREFIX)/libusb.a \
    35         $(LIBDRV_PREFIX)/libdrv.a
    36 EXTRA_CFLAGS = \
    37         -I$(LIBUSB_PREFIX)/include \
    38         -I$(LIBUSBDEV_PREFIX)/include \
    39         -I$(LIBDRV_PREFIX)/include
     32LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBDRV_PREFIX)/libdrv.a
     33EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIBDRV_PREFIX)/include
    4034
    4135SOURCES = \
  • uspace/app/tester/Makefile

    rd59d0bb r9be8669  
    3131BINARY = tester
    3232
     33LIBS += $(LIBUSB_PREFIX)/libusb.a
     34EXTRA_CFLAGS += -I$(LIBUSB_PREFIX)/include
     35
    3336SOURCES = \
    3437        tester.c \
     38        adt/usbaddrkeep.c \
    3539        thread/thread1.c \
    3640        print/print1.c \
  • uspace/app/tester/tester.c

    rd59d0bb r9be8669  
    6464#include "mm/mapping1.def"
    6565#include "hw/serial/serial1.def"
     66#include "adt/usbaddrkeep.def"
    6667#include "hw/misc/virtchar1.def"
    6768#include "devs/devman1.def"
  • uspace/app/tester/tester.h

    rd59d0bb r9be8669  
    8080extern const char *test_mapping1(void);
    8181extern const char *test_serial1(void);
     82extern const char *test_usbaddrkeep(void);
    8283extern const char *test_virtchar1(void);
    8384extern const char *test_devman1(void);
  • uspace/app/usbinfo/Makefile

    rd59d0bb r9be8669  
    3030BINARY = usbinfo
    3131
    32 LIBS = \
    33         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    34         $(LIBUSB_PREFIX)/libusb.a \
    35         $(LIBDRV_PREFIX)/libdrv.a
    36 EXTRA_CFLAGS = \
    37         -I$(LIBUSB_PREFIX)/include \
    38         -I$(LIBUSBDEV_PREFIX)/include \
    39         -I$(LIBDRV_PREFIX)/include
     32LIBS = $(LIBUSB_PREFIX)/libusb.a $(LIBDRV_PREFIX)/libdrv.a
     33EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIBDRV_PREFIX)/include
    4034
    4135SOURCES = \
  • uspace/app/usbinfo/info.c

    rd59d0bb r9be8669  
    4141#include <usb/request.h>
    4242#include <usb/classes/classes.h>
     43#include <usb/classes/hid.h>
    4344#include <usb/classes/hub.h>
    4445#include "usbinfo.h"
  • uspace/app/usbinfo/main.c

    rd59d0bb r9be8669  
    4646#include <usb/pipes.h>
    4747#include <usb/host.h>
    48 #include <usb/driver.h>
    4948#include "usbinfo.h"
    5049
  • uspace/app/vuhid/Makefile

    rd59d0bb r9be8669  
    3434LIBS = \
    3535        $(LIBUSBVIRT_PREFIX)/libusbvirt.a \
    36         $(LIBUSBHID_PREFIX)/libusbhid.a \
    37         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    3836        $(LIBUSB_PREFIX)/libusb.a
    3937EXTRA_CFLAGS = \
    4038        -I$(LIBUSB_PREFIX)/include \
    41         -I$(LIBUSBDEV_PREFIX)/include \
    42         -I$(LIBUSBHID_PREFIX)/include \
    4339        -I$(LIBUSBVIRT_PREFIX)/include \
    4440        -I$(LIBDRV_PREFIX)/include
  • uspace/drv/ehci-hcd/Makefile

    rd59d0bb r9be8669  
    2828
    2929USPACE_PREFIX = ../..
    30 
    31 LIBS = \
    32         $(LIBUSBHOST_PREFIX)/libusbhost.a \
    33         $(LIBUSB_PREFIX)/libusb.a \
    34         $(LIBDRV_PREFIX)/libdrv.a
    35 EXTRA_CFLAGS += \
    36         -I$(LIBUSB_PREFIX)/include \
    37         -I$(LIBUSBHOST_PREFIX)/include \
    38         -I$(LIBDRV_PREFIX)/include
    39 
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
    4032BINARY = ehci-hcd
    4133
  • uspace/drv/ehci-hcd/pci.c

    rd59d0bb r9be8669  
    5454
    5555#define CMD_OFFSET 0x0
    56 #define STS_OFFSET 0x4
    57 #define CFG_OFFSET 0x40
     56#define CONFIGFLAG_OFFSET 0x40
    5857
    5958#define USBCMD_RUN 1
     
    265264         * It would prevent pre-OS code from interfering. */
    266265        ret = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE),
    267            IPC_M_CONFIG_SPACE_WRITE_32, eecp + USBLEGCTLSTS_OFFSET,
    268            0xe0000000);
     266           IPC_M_CONFIG_SPACE_WRITE_32, eecp + USBLEGCTLSTS_OFFSET, 0);
    269267        CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) zero USBLEGCTLSTS.\n", ret);
     268        usb_log_debug("Zeroed USBLEGCTLSTS register.\n");
    270269
    271270        /* Read again Legacy Support and Control register */
     
    292291        volatile uint32_t *usbcmd =
    293292            (uint32_t*)((uint8_t*)registers + operation_offset + CMD_OFFSET);
    294         volatile uint32_t *usbsts =
    295             (uint32_t*)((uint8_t*)registers + operation_offset + STS_OFFSET);
    296293        volatile uint32_t *usbconfigured =
    297             (uint32_t*)((uint8_t*)registers + operation_offset + CFG_OFFSET);
     294            (uint32_t*)((uint8_t*)registers + operation_offset
     295            + CONFIGFLAG_OFFSET);
    298296        usb_log_debug("USBCMD value: %x.\n", *usbcmd);
    299297        if (*usbcmd & USBCMD_RUN) {
    300298                *usbcmd = 0;
    301                 while (!(*usbsts & (1 << 12))); /*wait until hc is halted */
    302299                *usbconfigured = 0;
    303300                usb_log_info("EHCI turned off.\n");
     
    305302                usb_log_info("EHCI was not running.\n");
    306303        }
    307         usb_log_debug("Registers: %x(0x00080000):%x(0x00001000):%x(0x0).\n",
    308             *usbcmd, *usbsts, *usbconfigured);
    309304
    310305        async_hangup(parent_phone);
  • uspace/drv/ohci/Makefile

    rd59d0bb r9be8669  
    2828
    2929USPACE_PREFIX = ../..
    30 
    31 LIBS = \
    32         $(LIBUSBHOST_PREFIX)/libusbhost.a \
    33         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    34         $(LIBUSB_PREFIX)/libusb.a \
    35         $(LIBDRV_PREFIX)/libdrv.a
    36 EXTRA_CFLAGS += \
    37         -I$(LIBUSB_PREFIX)/include \
    38         -I$(LIBUSBDEV_PREFIX)/include \
    39         -I$(LIBUSBHOST_PREFIX)/include \
    40         -I$(LIBDRV_PREFIX)/include
    41 
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
    4232BINARY = ohci
    4333
  • uspace/drv/ohci/hc.c

    rd59d0bb r9be8669  
    4040#include <usb/usb.h>
    4141#include <usb/ddfiface.h>
     42#include <usb/usbdevice.h>
    4243
    4344#include "hc.h"
  • uspace/drv/ohci/hw_struct/endpoint_descriptor.h

    rd59d0bb r9be8669  
    4040#include <usb/host/endpoint.h>
    4141
    42 #include "../utils/malloc32.h"
     42#include "utils/malloc32.h"
    4343#include "transfer_descriptor.h"
    4444
  • uspace/drv/ohci/hw_struct/transfer_descriptor.c

    rd59d0bb r9be8669  
    3333 */
    3434#include <usb/usb.h>
     35#include "utils/malloc32.h"
     36
    3537#include "transfer_descriptor.h"
    3638
  • uspace/drv/ohci/hw_struct/transfer_descriptor.h

    rd59d0bb r9be8669  
    3737#include <bool.h>
    3838#include <stdint.h>
    39 #include "../utils/malloc32.h"
     39#include "utils/malloc32.h"
    4040
    4141#include "completion_codes.h"
  • uspace/drv/uhci-hcd/Makefile

    rd59d0bb r9be8669  
    2828
    2929USPACE_PREFIX = ../..
    30 
    31 LIBS = \
    32         $(LIBUSBHOST_PREFIX)/libusbhost.a \
    33         $(LIBUSB_PREFIX)/libusb.a \
    34         $(LIBDRV_PREFIX)/libdrv.a
    35 EXTRA_CFLAGS += \
    36         -I$(LIBUSB_PREFIX)/include \
    37         -I$(LIBUSBHOST_PREFIX)/include \
    38         -I$(LIBDRV_PREFIX)/include
    39 
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
    4032BINARY = uhci-hcd
    4133
  • uspace/drv/uhci-hcd/hw_struct/queue_head.h

    rd59d0bb r9be8669  
    3838#include "link_pointer.h"
    3939#include "transfer_descriptor.h"
    40 #include "../utils/malloc32.h"
     40#include "utils/malloc32.h"
    4141
    4242/** This structure is defined in UHCI design guide p. 31 */
  • uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.c

    rd59d0bb r9be8669  
    3636
    3737#include "transfer_descriptor.h"
    38 #include "../utils/malloc32.h"
     38#include "utils/malloc32.h"
    3939
    4040/** Initialize Transfer Descriptor
  • uspace/drv/uhci-rhd/Makefile

    rd59d0bb r9be8669  
    2828
    2929USPACE_PREFIX = ../..
    30 
    31 LIBS = \
    32         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    33         $(LIBUSB_PREFIX)/libusb.a \
    34         $(LIBDRV_PREFIX)/libdrv.a
    35 EXTRA_CFLAGS += \
    36         -I$(LIBUSB_PREFIX)/include \
    37         -I$(LIBUSBDEV_PREFIX)/include \
    38         -I$(LIBDRV_PREFIX)/include
    39 
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
    4032BINARY = uhci-rhd
    4133
  • uspace/drv/uhci-rhd/port.c

    rd59d0bb r9be8669  
    3232 * @brief UHCI root hub port routines
    3333 */
    34 #include <libarch/ddi.h>  /* pio_read and pio_write */
    35 #include <fibril_synch.h> /* async_usleep */
     34#include <libarch/ddi.h> /* pio_read and pio_write */
    3635#include <errno.h>
    3736#include <str_error.h>
     37#include <fibril_synch.h>
    3838
    3939#include <usb/usb.h>    /* usb_address_t */
    40 #include <usb/hub.h>    /* usb_hc_new_device_wrapper */
     40#include <usb/hub.h>
    4141#include <usb/debug.h>
    4242
     
    212212
    213213        /*
    214          * Resets from root ports should be nominally 50ms (USB spec 7.1.7.3)
     214         * The host then waits for at least 100 ms to allow completion of
     215         * an insertion process and for power at the device to become stable.
     216         */
     217        async_usleep(100000);
     218
     219        /*
     220         * Resets from root ports should be nominally 50ms
    215221         */
    216222        {
     
    223229                port_status &= ~STATUS_IN_RESET;
    224230                uhci_port_write_status(port, port_status);
    225                 while (uhci_port_read_status(port) & STATUS_IN_RESET);
    226                 // TODO: find a better way to waste time (it should be less than
    227                 // 10ms, if we reschedule it takes too much time (random
    228                 // interrupts can be solved by multiple attempts).
    229                 usb_log_debug2("%s: Reset Signal stop.\n", port->id_string);
    230         }
     231                usb_log_debug("%s: Reset Signal stop.\n", port->id_string);
     232        }
     233
     234        /* the reset recovery time 10ms */
     235        async_usleep(10000);
     236
    231237        /* Enable the port. */
    232238        uhci_port_set_enabled(port, true);
    233 
    234         /* Reset recovery period,
    235          * devices do not have to respond during this period
    236          */
    237         async_usleep(10000);
    238239        return EOK;
    239240}
     
    254255        usb_log_debug("%s: Detected new device.\n", port->id_string);
    255256
    256         int ret, count = 0;
    257257        usb_address_t dev_addr;
    258         do {
    259                 ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection,
    260                     speed, uhci_port_reset_enable, port->number, port,
    261                     &dev_addr, &port->attached_device, NULL, NULL, NULL);
    262         } while (ret != EOK && ++count < 4);
     258        int ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection,
     259            speed, uhci_port_reset_enable, port->number, port,
     260            &dev_addr, &port->attached_device, NULL, NULL, NULL);
    263261
    264262        if (ret != EOK) {
     
    315313        /* Wait for port to become enabled */
    316314        do {
     315                async_usleep(1000);
    317316                port_status = uhci_port_read_status(port);
    318317        } while ((port_status & STATUS_CONNECTED) &&
  • uspace/drv/usbflbk/Makefile

    rd59d0bb r9be8669  
    2828
    2929USPACE_PREFIX = ../..
    30 
    31 LIBS = \
    32         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    33         $(LIBUSB_PREFIX)/libusb.a \
    34         $(LIBDRV_PREFIX)/libdrv.a
    35 EXTRA_CFLAGS += \
    36         -I$(LIBUSB_PREFIX)/include \
    37         -I$(LIBUSBDEV_PREFIX)/include \
    38         -I$(LIBDRV_PREFIX)/include
    39 
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
    4032BINARY = usbflbk
    4133
  • uspace/drv/usbhid/Makefile

    rd59d0bb r9be8669  
    2828
    2929USPACE_PREFIX = ../..
    30 
    31 LIBS = \
    32         $(LIBUSBHID_PREFIX)/libusbhid.a \
    33         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    34         $(LIBUSB_PREFIX)/libusb.a \
    35         $(LIBDRV_PREFIX)/libdrv.a
    36 EXTRA_CFLAGS += \
    37         -I. \
    38         -I$(LIBUSB_PREFIX)/include \
    39         -I$(LIBUSBDEV_PREFIX)/include \
    40         -I$(LIBUSBHID_PREFIX)/include \
    41         -I$(LIBDRV_PREFIX)/include
    42 
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
    4332BINARY = usbhid
    4433
     
    5746        generic/hiddev.c \
    5847        mouse/mousedev.c \
    59         multimedia/multimedia.c \
    60         multimedia/keymap.c \
     48        lgtch-ultrax/lgtch-ultrax.c \
     49        lgtch-ultrax/keymap.c \
    6150        $(STOLEN_LAYOUT_SOURCES)
    6251
  • uspace/drv/usbhid/subdrivers.c

    rd59d0bb r9be8669  
    3838#include "usb/classes/hidpath.h"
    3939
    40 //#include "lgtch-ultrax/lgtch-ultrax.h"
    41 #include "multimedia/multimedia.h"
     40#include "lgtch-ultrax/lgtch-ultrax.h"
    4241#include "mouse/mousedev.h"
    4342
    4443static usb_hid_subdriver_usage_t path_kbd[] = {
    45         {USB_HIDUT_PAGE_GENERIC_DESKTOP,
    46          USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD},
     44        {USB_HIDUT_PAGE_GENERIC_DESKTOP, USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD},
    4745        {0, 0}
    4846};
    4947
    50 static usb_hid_subdriver_usage_t path_mouse[] = {
    51         {USB_HIDUT_PAGE_GENERIC_DESKTOP, USB_HIDUT_USAGE_GENERIC_DESKTOP_MOUSE},
     48static usb_hid_subdriver_usage_t path_mouse2[] = {
     49        {USB_HIDUT_PAGE_GENERIC_DESKTOP, USB_HIDUT_USAGE_GENERIC_DESKTOP_MOUSE}, 
    5250        {0, 0}
    5351};
    5452
    55 static usb_hid_subdriver_usage_t multim_key_path[] = {
    56         {USB_HIDUT_PAGE_CONSUMER, USB_HIDUT_USAGE_CONSUMER_CONSUMER_CONTROL},
     53static usb_hid_subdriver_usage_t lgtch_path[] = {
     54        {0xc, 0},
    5755        {0, 0}
    5856};
     
    6159        {
    6260                path_kbd,
    63                 -1,
    64                 USB_HID_PATH_COMPARE_ANYWHERE,
     61                0,
     62                USB_HID_PATH_COMPARE_BEGIN,
    6563                -1,
    6664                -1,
     
    7472        },
    7573        {
    76                 multim_key_path,
     74                lgtch_path,
    7775                1,
    78                 USB_HID_PATH_COMPARE_ANYWHERE,
    79                 -1,
    80                 -1,
     76                USB_HID_PATH_COMPARE_BEGIN
     77                | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,         
     78                0x046d,
     79                0xc30e,
    8180                {
    82                         .init = usb_multimedia_init,
    83                         .deinit = usb_multimedia_deinit,
    84                         .poll = usb_multimedia_polling_callback,
     81                        .init = usb_lgtch_init,
     82                        .deinit = usb_lgtch_deinit,
     83                        .poll = usb_lgtch_polling_callback,
    8584                        .poll_end = NULL
    8685                }
    8786        },
    8887        {
    89                 path_mouse,
    90                 -1,
    91                 USB_HID_PATH_COMPARE_ANYWHERE,
     88                path_mouse2,
     89                0,
     90                USB_HID_PATH_COMPARE_BEGIN,
    9291                -1,
    9392                -1,
  • uspace/drv/usbhub/Makefile

    rd59d0bb r9be8669  
    2828
    2929USPACE_PREFIX = ../..
    30 
    31 LIBS = \
    32         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    33         $(LIBUSB_PREFIX)/libusb.a \
    34         $(LIBDRV_PREFIX)/libdrv.a
    35 EXTRA_CFLAGS += \
    36         -I$(LIBUSB_PREFIX)/include \
    37         -I$(LIBUSBDEV_PREFIX)/include \
    38         -I$(LIBDRV_PREFIX)/include
    39 
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
    4032BINARY = usbhub
    4133
  • uspace/drv/usbmast/Makefile

    rd59d0bb r9be8669  
    2828
    2929USPACE_PREFIX = ../..
    30 
    31 LIBS = \
    32         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    33         $(LIBUSB_PREFIX)/libusb.a \
    34         $(LIBDRV_PREFIX)/libdrv.a
    35 EXTRA_CFLAGS += \
    36         -I$(LIBUSB_PREFIX)/include \
    37         -I$(LIBUSBDEV_PREFIX)/include \
    38         -I$(LIBDRV_PREFIX)/include
    39 
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
    4032BINARY = usbmast
    4133
    4234SOURCES = \
    43         inquiry.c \
    4435        main.c \
    4536        mast.c
  • uspace/drv/usbmast/main.c

    rd59d0bb r9be8669  
    7575};
    7676
     77#define BITS_GET_MASK(type, bitcount) (((type)(1 << (bitcount)))-1)
     78#define BITS_GET_MID_MASK(type, bitcount, offset) \
     79        ((type)( BITS_GET_MASK(type, (bitcount) + (offset)) - BITS_GET_MASK(type, bitcount) ))
     80#define BITS_GET(type, number, bitcount, offset) \
     81        ((type)( (number) & (BITS_GET_MID_MASK(type, bitcount, offset)) ) >> (offset))
     82
     83#define INQUIRY_RESPONSE_LENGTH 35
     84
     85static void try_inquiry(usb_device_t *dev)
     86{
     87        scsi_cmd_inquiry_t inquiry = {
     88                .op_code = 0x12,
     89                .lun_evpd = 0,
     90                .page_code = 0,
     91                .alloc_length = INQUIRY_RESPONSE_LENGTH,
     92                .ctrl = 0
     93        };
     94        size_t response_len;
     95        uint8_t response[INQUIRY_RESPONSE_LENGTH];
     96
     97        int rc;
     98
     99        rc = usb_massstor_data_in(GET_BULK_IN(dev), GET_BULK_OUT(dev),
     100            0xDEADBEEF, 0, (uint8_t *) &inquiry, sizeof(inquiry),
     101            response, INQUIRY_RESPONSE_LENGTH, &response_len);
     102
     103        if (rc != EOK) {
     104                usb_log_error("Failed to probe device %s using %s: %s.\n",
     105                   dev->ddf_dev->name, "SCSI:INQUIRY", str_error(rc));
     106                return;
     107        }
     108
     109        if (response_len < 8) {
     110                usb_log_error("The SCSI response is too short.\n");
     111                return;
     112        }
     113
     114        /*
     115         * This is an ugly part of the code. We will parse the returned
     116         * data by hand and try to get as many useful data as possible.
     117         */
     118        int device_type = BITS_GET(uint8_t, response[0], 5, 0);
     119        int removable = BITS_GET(uint8_t, response[1], 1, 7);
     120
     121        usb_log_info("SCSI information for device `%s':\n", dev->ddf_dev->name);
     122        usb_log_info("  - peripheral device type: %d\n", device_type);
     123        usb_log_info("  - removable: %s\n", removable ? "yes" : "no");
     124
     125        if (response_len < 32) {
     126                return;
     127        }
     128
     129        char dev_vendor[9];
     130        str_ncpy(dev_vendor, 9, (const char *) &response[8], 8);
     131        usb_log_info("  - vendor: '%s'\n", dev_vendor);
     132
     133        char dev_product[9];
     134        str_ncpy(dev_product, 9, (const char *) &response[16], 8);
     135        usb_log_info("  - product: '%s'\n", dev_vendor);
     136}
     137
    77138/** Callback when new device is attached and recognized as a mass storage.
    78139 *
     
    107168            (size_t) dev->pipes[BULK_OUT_EP].descriptor->max_packet_size);
    108169
    109         size_t lun_count = usb_masstor_get_lun_count(dev);
    110 
    111         usb_massstor_inquiry_result_t inquiry;
    112         rc = usb_massstor_inquiry(dev, BULK_IN_EP, BULK_OUT_EP, &inquiry);
    113         if (rc != EOK) {
    114                 usb_log_warning("Failed to inquiry device `%s': %s.\n",
    115                     dev->ddf_dev->name, str_error(rc));
    116                 return EOK;
    117         }
    118 
    119         usb_log_info("Mass storage `%s': " \
    120             "`%s' by `%s' is %s (%s), %zu LUN(s).\n",
    121             dev->ddf_dev->name,
    122             inquiry.product_and_revision, inquiry.vendor_id,
    123             usb_str_masstor_scsi_peripheral_device_type(inquiry.peripheral_device_type),
    124             inquiry.removable ? "removable" : "non-removable",
    125             lun_count);
     170        try_inquiry(dev);
    126171
    127172        return EOK;
  • uspace/drv/usbmast/mast.c

    rd59d0bb r9be8669  
    4040#include <str_error.h>
    4141#include <usb/debug.h>
    42 #include <usb/request.h>
    4342
    4443bool usb_mast_verbose = true;
     
    6463 * @return Error code.
    6564 */
    66 int usb_massstor_data_in(usb_device_t *dev,
    67     size_t bulk_in_pipe_index, size_t bulk_out_pipe_index,
     65int usb_massstor_data_in(usb_pipe_t *bulk_in_pipe, usb_pipe_t *bulk_out_pipe,
    6866    uint32_t tag, uint8_t lun, void *cmd, size_t cmd_size,
    6967    void *in_buffer, size_t in_buffer_size, size_t *received_size)
     
    7169        int rc;
    7270        size_t act_size;
    73         usb_pipe_t *bulk_in_pipe = dev->pipes[bulk_in_pipe_index].pipe;
    74         usb_pipe_t *bulk_out_pipe = dev->pipes[bulk_out_pipe_index].pipe;
    7571
    7672        /* Prepare CBW - command block wrapper */
     
    139135}
    140136
    141 /** Perform bulk-only mass storage reset.
    142  *
    143  * @param dev Device to be reseted.
    144  * @return Error code.
    145  */
    146 int usb_massstor_reset(usb_device_t *dev)
    147 {
    148         return usb_control_request_set(&dev->ctrl_pipe,
    149             USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
    150             0xFF, 0, dev->interface_no, NULL, 0);
    151 }
    152 
    153 /** Perform complete reset recovery of bulk-only mass storage.
    154  *
    155  * Notice that no error is reported because if this fails, the error
    156  * would reappear on next transaction somehow.
    157  *
    158  * @param dev Device to be reseted.
    159  * @param bulk_in_idx Index of bulk in pipe.
    160  * @param bulk_out_idx Index of bulk out pipe.
    161  */
    162 void usb_massstor_reset_recovery(usb_device_t *dev,
    163     size_t bulk_in_idx, size_t bulk_out_idx)
    164 {
    165         /* We would ignore errors here because if this fails
    166          * we are doomed anyway and any following transaction would fail.
    167          */
    168         usb_massstor_reset(dev);
    169         usb_pipe_clear_halt(&dev->ctrl_pipe, dev->pipes[bulk_in_idx].pipe);
    170         usb_pipe_clear_halt(&dev->ctrl_pipe, dev->pipes[bulk_out_idx].pipe);
    171 }
    172 
    173 /** Get max LUN of a mass storage device.
    174  *
    175  * @see usb_masstor_get_lun_count
    176  *
    177  * @warning Error from this command does not necessarily indicate malfunction
    178  * of the device. Device does not need to support this request.
    179  * You shall rather use usb_masstor_get_lun_count.
    180  *
    181  * @param dev Mass storage device.
    182  * @return Error code of maximum LUN (index, not count).
    183  */
    184 int usb_massstor_get_max_lun(usb_device_t *dev)
    185 {
    186         uint8_t max_lun;
    187         size_t data_recv_len;
    188         int rc = usb_control_request_get(&dev->ctrl_pipe,
    189             USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
    190             0xFE, 0, dev->interface_no, &max_lun, 1, &data_recv_len);
    191         if (rc != EOK) {
    192                 return rc;
    193         }
    194         if (data_recv_len != 1) {
    195                 return EEMPTY;
    196         }
    197         return (int) max_lun;
    198 }
    199 
    200 /** Get number of LUNs supported by mass storage device.
    201  *
    202  * @warning This function hides any error during the request
    203  * (typically that shall not be a problem).
    204  *
    205  * @param dev Mass storage device.
    206  * @return Number of LUNs.
    207  */
    208 size_t usb_masstor_get_lun_count(usb_device_t *dev)
    209 {
    210         int max_lun = usb_massstor_get_max_lun(dev);
    211         if (max_lun < 0) {
    212                 max_lun = 1;
    213         } else {
    214                 max_lun++;
    215         }
    216 
    217         return (size_t) max_lun;
    218 }
    219 
    220137/**
    221138 * @}
  • uspace/drv/usbmast/mast.h

    rd59d0bb r9be8669  
    4040#include <usb/usb.h>
    4141#include <usb/pipes.h>
    42 #include <usb/devdrv.h>
    4342
    44 /** Result of SCSI INQUIRY command.
    45  * This is already parsed structure, not the original buffer returned by
    46  * the device.
    47  */
    48 typedef struct {
    49         /** SCSI peripheral device type. */
    50         int peripheral_device_type;
    51         /** Whether the device is removable. */
    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];
    57 } usb_massstor_inquiry_result_t;
    58 
    59 int usb_massstor_data_in(usb_device_t *dev, size_t, size_t,
    60     uint32_t, uint8_t, void *, size_t, void *, size_t, size_t *);
    61 int usb_massstor_reset(usb_device_t *);
    62 void usb_massstor_reset_recovery(usb_device_t *, size_t, size_t);
    63 int usb_massstor_get_max_lun(usb_device_t *);
    64 size_t usb_masstor_get_lun_count(usb_device_t *);
    65 int usb_massstor_inquiry(usb_device_t *, size_t, size_t,
    66     usb_massstor_inquiry_result_t *);
    67 const char *usb_str_masstor_scsi_peripheral_device_type(int);
     43int usb_massstor_data_in(usb_pipe_t *, usb_pipe_t *, uint32_t, uint8_t,
     44    void *, size_t, void *, size_t, size_t *);
    6845
    6946#endif
  • uspace/drv/usbmid/Makefile

    rd59d0bb r9be8669  
    2828
    2929USPACE_PREFIX = ../..
    30 
    31 LIBS = \
    32         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    33         $(LIBUSB_PREFIX)/libusb.a \
    34         $(LIBDRV_PREFIX)/libdrv.a
    35 EXTRA_CFLAGS += \
    36         -I$(LIBUSB_PREFIX)/include \
    37         -I$(LIBUSBDEV_PREFIX)/include \
    38         -I$(LIBDRV_PREFIX)/include
    39        
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include
    4032BINARY = usbmid
    4133
  • uspace/drv/usbmouse/Makefile

    rd59d0bb r9be8669  
    2828
    2929USPACE_PREFIX = ../..
    30 
    31 LIBS = \
    32         $(LIBUSBHID_PREFIX)/libusbhid.a \
    33         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    34         $(LIBUSB_PREFIX)/libusb.a \
    35         $(LIBDRV_PREFIX)/libdrv.a
    36 EXTRA_CFLAGS += \
    37         -I$(LIBUSB_PREFIX)/include \
    38         -I$(LIBUSBDEV_PREFIX)/include \
    39         -I$(LIBUSBHID_PREFIX)/include \
    40         -I$(LIBDRV_PREFIX)/include
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBUSB_PREFIX)/libusb.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBUSB_PREFIX)/include -I.
    4132
    4233BINARY = usbmouse
  • uspace/drv/vhc/Makefile

    rd59d0bb r9be8669  
    2929USPACE_PREFIX = ../..
    3030LIBS = \
    31         $(LIBUSBDEV_PREFIX)/libusbdev.a \
    32         $(LIBUSBHOST_PREFIX)/libusbhost.a \
    3331        $(LIBUSB_PREFIX)/libusb.a \
    3432        $(LIBUSBVIRT_PREFIX)/libusbvirt.a \
     
    3634EXTRA_CFLAGS += \
    3735        -I$(LIBUSBVIRT_PREFIX)/include \
    38         -I$(LIBUSBDEV_PREFIX)/include \
    39         -I$(LIBUSBHOST_PREFIX)/include \
    4036        -I$(LIBUSB_PREFIX)/include \
    4137        -I$(LIBDRV_PREFIX)/include
  • uspace/lib/usb/Makefile

    rd59d0bb r9be8669  
    2929USPACE_PREFIX = ../..
    3030LIBRARY = libusb
    31 EXTRA_CFLAGS += \
    32         -I$(LIBDRV_PREFIX)/include \
    33         -Iinclude
     31LIBS = $(LIBDRV_PREFIX)/libdrv.a
     32EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -Iinclude
    3433
    3534SOURCES = \
     35        src/addrkeep.c \
     36        src/altiface.c \
    3637        src/class.c \
    3738        src/ddfiface.c \
    3839        src/debug.c \
    39         src/driver.c \
     40        src/devdrv.c \
     41        src/devpoll.c \
     42        src/dp.c \
    4043        src/dump.c \
     44        src/hidiface.c \
     45        src/hidpath.c \
     46        src/hidparser.c \
     47        src/hiddescriptor.c \
    4148        src/host.c \
    42         src/usb.c
     49        src/hub.c \
     50        src/pipepriv.c \
     51        src/pipes.c \
     52        src/pipesinit.c \
     53        src/pipesio.c \
     54        src/recognise.c \
     55        src/request.c \
     56        src/usb.c \
     57        src/usbdevice.c \
     58        src/hidreq.c \
     59        src/hidreport.c \
     60        src/host/device_keeper.c \
     61        src/host/batch.c \
     62        src/host/endpoint.c \
     63        src/host/usb_endpoint_manager.c
    4364
    4465include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/usb/include/usb/ddfiface.h

    rd59d0bb r9be8669  
    3737
    3838#include <sys/types.h>
     39#include <usb/usbdevice.h>
    3940#include <usb_iface.h>
    4041
  • uspace/lib/usb/include/usb/descriptor.h

    rd59d0bb r9be8669  
    167167} __attribute__ ((packed)) usb_standard_endpoint_descriptor_t;
    168168
    169 /** Part of standard USB HID descriptor specifying one class descriptor.
    170  *
    171  * (See HID Specification, p.22)
    172  */
    173 typedef struct {
    174         /** Type of class-specific descriptor (Report or Physical). */
    175         uint8_t type;
    176         /** Length of class-specific descriptor in bytes. */
    177         uint16_t length;
    178 } __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t;
    179 
    180 /** Standard USB HID descriptor.
    181  *
    182  * (See HID Specification, p.22)
    183  *
    184  * It is actually only the "header" of the descriptor, it does not contain
    185  * the last two mandatory fields (type and length of the first class-specific
    186  * descriptor).
    187  */
    188 typedef struct {
    189         /** Total size of this descriptor in bytes.
    190          *
    191          * This includes all class-specific descriptor info - type + length
    192          * for each descriptor.
    193          */
    194         uint8_t length;
    195         /** Descriptor type (USB_DESCTYPE_HID). */
    196         uint8_t descriptor_type;
    197         /** HID Class Specification release. */
    198         uint16_t spec_release;
    199         /** Country code of localized hardware. */
    200         uint8_t country_code;
    201         /** Total number of class-specific (i.e. Report and Physical)
    202          * descriptors.
    203          *
    204          * @note There is always only one Report descriptor.
    205          */
    206         uint8_t class_desc_count;
    207         /** First mandatory class descriptor (Report) info. */
    208         usb_standard_hid_class_descriptor_info_t report_desc_info;
    209 } __attribute__ ((packed)) usb_standard_hid_descriptor_t;
    210 
    211169#endif
    212170/**
  • uspace/lib/usb/src/ddfiface.c

    rd59d0bb r9be8669  
    3737#include <async.h>
    3838#include <usb/ddfiface.h>
    39 #include <usb/driver.h>
    4039#include <usb/debug.h>
    4140#include <errno.h>
  • uspace/lib/usb/src/dump.c

    rd59d0bb r9be8669  
    4141#include <usb/descriptor.h>
    4242#include <usb/classes/classes.h>
     43#include <usb/classes/hid.h>
    4344
    4445/** Mapping between descriptor id and dumping function. */
  • uspace/lib/usbvirt/Makefile

    rd59d0bb r9be8669  
    3030LIBRARY = libusbvirt
    3131
    32 EXTRA_CFLAGS = \
    33         -I$(LIBDRV_PREFIX)/include \
    34         -I$(LIBUSB_PREFIX)/include \
    35         -I$(LIBUSBDEV_PREFIX)/include \
    36         -Iinclude
     32EXTRA_CFLAGS = -I$(LIBUSB_PREFIX)/include -I$(LIBDRV_PREFIX)/include -Iinclude
    3733
    3834SOURCES = \
Note: See TracChangeset for help on using the changeset viewer.