Changes in / [0f191a2:2b0db98] in mainline


Ignore:
Location:
uspace
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/virtusbkbd/virtusbkbd.c

    r0f191a2 r2b0db98  
    271271        printf("%s: Simulating keyboard events...\n", NAME);
    272272        fibril_sleep(10);
    273         while (1) {
     273        //while (1) {
    274274                kb_process_events(&status, keyboard_events, keyboard_events_count,
    275275                        on_keyboard_change);
    276         }
     276        //}
    277277       
    278278        printf("%s: Terminating...\n", NAME);
  • uspace/drv/usbkbd/Makefile

    r0f191a2 r2b0db98  
    3333
    3434SOURCES = \
    35         main.c
     35        main.c \
     36        descparser.c
    3637
    3738include $(USPACE_PREFIX)/Makefile.common
  • uspace/drv/usbkbd/main.c

    r0f191a2 r2b0db98  
    3838#include <usb/devreq.h>
    3939#include <usb/descriptor.h>
     40#include "descparser.h"
    4041
    4142#define BUFFER_SIZE 32
     
    9596                                    void *arg)
    9697{
    97 
     98        printf("Got keys: ");
     99        unsigned i;
     100        for (i = 0; i < count; ++i) {
     101                printf("%d ", key_codes[i]);
     102        }
     103        printf("\n");
    98104}
    99105
     
    101107 * Kbd functions
    102108 */
    103 static int usbkbd_parse_descriptors(usb_hid_dev_kbd_t *kbd_dev,
    104                                     const uint8_t *data, size_t size)
    105 {
    106 //      const uint8_t *pos = data;
    107        
    108 //      // get the configuration descriptor (should be first)
    109 //      if (*pos != sizeof(usb_standard_configuration_descriptor_t)
    110 //          || *(pos + 1) != USB_DESCTYPE_CONFIGURATION) {
    111 //              fprintf(stderr, "Wrong format of configuration descriptor");
    112 //              return EINVAL;
    113 //      }
    114        
    115 //      usb_standard_configuration_descriptor_t config_descriptor;
    116 //      memcpy(&config_descriptor, pos,
    117 //          sizeof(usb_standard_configuration_descriptor_t));
    118 //      pos += sizeof(usb_standard_configuration_descriptor_t);
    119        
    120 //      // parse other descriptors
    121 //      while (pos - data < size) {
    122 //              //uint8_t desc_size = *pos;
    123 //              uint8_t desc_type = *(pos + 1);
    124 //              switch (desc_type) {
    125 //              case USB_DESCTYPE_INTERFACE:
    126 //                      break;
    127 //              case USB_DESCTYPE_ENDPOINT:
    128 //                      break;
    129 //              case USB_DESCTYPE_HID:
    130 //                      break;
    131 //              case USB_DESCTYPE_HID_REPORT:
    132 //                      break;
    133 //              case USB_DESCTYPE_HID_PHYSICAL:
    134 //                      break;
    135 //              }
    136 //      }
    137        
    138         return EOK;
    139 }
    140 
    141 static int usbkbd_get_descriptors(usb_hid_dev_kbd_t *kbd_dev)
    142 {
    143         // get the first configuration descriptor (TODO: or some other??)
     109static int usbkbd_process_descriptors(usb_hid_dev_kbd_t *kbd_dev)
     110{
     111        // get the first configuration descriptor (TODO: parse also other!)
    144112        usb_standard_configuration_descriptor_t config_desc;
    145113       
     
    170138        }
    171139       
    172         rc = usbkbd_parse_descriptors(kbd_dev, descriptors, transferred);
     140        kbd_dev->conf = (usb_hid_configuration_t *)calloc(1,
     141            sizeof(usb_hid_configuration_t));
     142        if (kbd_dev->conf == NULL) {
     143                free(descriptors);
     144                return ENOMEM;
     145        }
     146       
     147        rc = usbkbd_parse_descriptors(descriptors, transferred, kbd_dev->conf);
    173148        free(descriptors);
    174149       
     150        //usbkbd_print_config(kbd_dev->conf);
     151       
    175152        return rc;
    176153}
     
    178155static usb_hid_dev_kbd_t *usbkbd_init_device(device_t *dev)
    179156{
    180         usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)malloc(
    181                         sizeof(usb_hid_dev_kbd_t));
     157        usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)calloc(1,
     158            sizeof(usb_hid_dev_kbd_t));
    182159
    183160        if (kbd_dev == NULL) {
     
    212189         */
    213190
    214         // TODO: get descriptors
    215         usbkbd_get_descriptors(kbd_dev);
    216         // TODO: parse descriptors and save endpoints
     191        // TODO: get descriptors, parse descriptors and save endpoints
     192        usbkbd_process_descriptors(kbd_dev);
    217193
    218194        return kbd_dev;
  • uspace/drv/vhc/hcd.c

    r0f191a2 r2b0db98  
    114114        sleep(5);
    115115
    116         usb_dprintf_enable(NAME, 0);
     116        usb_dprintf_enable(NAME, -1);
    117117
    118118        printf(NAME ": virtual USB host controller driver.\n");
  • uspace/lib/usb/include/usb/classes/hid.h

    r0f191a2 r2b0db98  
    3939#include <driver.h>
    4040#include <usb/classes/hidparser.h>
     41#include <usb/descriptor.h>
    4142
    4243/** USB/HID device requests. */
     
    6364 */
    6465typedef struct {
    65         /** Type of class descriptor (Report or Physical). */
    66         uint8_t class_descriptor_type;
    67         /** Length of class descriptor. */
    68         uint16_t class_descriptor_length;
    69 } __attribute__ ((packed)) usb_standard_hid_descriptor_class_item_t;
     66        /** Type of class-specific descriptor (Report or Physical). */
     67        uint8_t type;
     68        /** Length of class-specific descriptor in bytes. */
     69        uint16_t length;
     70} __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t;
    7071
    7172/** Standard USB HID descriptor.
     
    7374 * (See HID Specification, p.22)
    7475 *
    75  * It is actually only the "header" of the descriptor, as it may have arbitrary
    76  * length if more than one class descritor is provided.
     76 * It is actually only the "header" of the descriptor, it does not contain
     77 * the last two mandatory fields (type and length of the first class-specific
     78 * descriptor).
    7779 */
    7880typedef struct {
    79         /** Size of this descriptor in bytes. */
     81        /** Total size of this descriptor in bytes.
     82         *
     83         * This includes all class-specific descriptor info - type + length
     84         * for each descriptor.
     85         */
    8086        uint8_t length;
    8187        /** Descriptor type (USB_DESCTYPE_HID). */
     
    8591        /** Country code of localized hardware. */
    8692        uint8_t country_code;
    87         /** Total number of class (i.e. Report and Physical) descriptors. */
    88         uint8_t class_count;
    89         /** First mandatory class descriptor info. */
    90         usb_standard_hid_descriptor_class_item_t class_descriptor;
     93        /** Total number of class-specific (i.e. Report and Physical)
     94         * descriptors.
     95         */
     96        uint8_t class_desc_count;
     97//      /** First mandatory class descriptor info. */
     98//      usb_standard_hid_descriptor_class_item_t class_descriptor;
    9199} __attribute__ ((packed)) usb_standard_hid_descriptor_t;
    92100
     101/**
     102 *
     103 */
     104typedef struct {
     105        usb_standard_interface_descriptor_t iface_desc;
     106        usb_standard_endpoint_descriptor_t *endpoints;
     107        usb_standard_hid_descriptor_t hid_desc;
     108        usb_standard_hid_class_descriptor_info_t *class_desc_info;
     109        uint8_t **class_descs;
     110} usb_hid_iface_t;
     111
     112/**
     113 *
     114 */
     115typedef struct {
     116        usb_standard_configuration_descriptor_t config_descriptor;
     117        usb_hid_iface_t *interfaces;
     118} usb_hid_configuration_t;
    93119
    94120/**
     
    99125typedef struct {
    100126        device_t *device;
     127        usb_hid_configuration_t *conf;
    101128        usb_address_t address;
    102129        usb_endpoint_t poll_endpoint;
  • uspace/srv/devman/main.c

    r0f191a2 r2b0db98  
    479479        }
    480480
    481         printf(NAME ": devman_forward: forward connection to device %s to "
    482             "driver %s.\n", dev->pathname, driver->name);
     481//      printf(NAME ": devman_forward: forward connection to device %s to "
     482//          "driver %s.\n", dev->pathname, driver->name);
    483483        ipc_forward_fast(iid, driver->phone, method, dev->handle, 0, IPC_FF_NONE);
    484484}
Note: See TracChangeset for help on using the changeset viewer.