Changeset 64861b8 in mainline


Ignore:
Timestamp:
2011-01-21T12:26:09Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e8ad0de
Parents:
b65ca41d (diff), 96b0faef (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge from development

Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    rb65ca41d r64861b8  
    109109./uspace/srv/hw/irc/apic/apic
    110110./uspace/srv/hw/irc/i8259/i8259
    111 ./uspace/srv/hw/netif/dp8390/dp8390
     111./uspace/srv/hw/netif/ne2000/dp8390
     112./uspace/srv/hw/netif/ne2000/ne2000
    112113./uspace/srv/loader/loader
    113114./uspace/srv/net/cfg/lo
  • uspace/app/usbinfo/dump.c

    rb65ca41d r64861b8  
    4343#include <usb/usb.h>
    4444#include <usb/descriptor.h>
     45#include <usb/debug.h>
     46#include <usb/classes/classes.h>
    4547
    4648#include "usbinfo.h"
     
    5052#define BYTES_PER_LINE 12
    5153
    52 #define BCD_INT(a) (((unsigned int)(a)) / 256)
    53 #define BCD_FRAC(a) (((unsigned int)(a)) % 256)
    5454
    55 #define BCD_FMT "%x.%x"
    56 #define BCD_ARGS(a) BCD_INT((a)), BCD_FRAC((a))
     55static const char *get_indent(size_t level)
     56{
     57        static const char *indents[] = {
     58                INDENT,
     59                INDENT INDENT,
     60                INDENT INDENT INDENT,
     61                INDENT INDENT INDENT INDENT,
     62                INDENT INDENT INDENT INDENT INDENT
     63        };
     64        static size_t indents_count = sizeof(indents)/sizeof(indents[0]);
     65        if (level >= indents_count) {
     66                return indents[indents_count - 1];
     67        }
     68        return indents[level];
     69}
    5770
    58 void dump_buffer(const char *msg, const uint8_t *buffer, size_t length)
     71void dump_buffer(const char *msg, size_t indent,
     72    const uint8_t *buffer, size_t length)
    5973{
    60         printf("%s\n", msg);
     74        if (msg != NULL) {
     75                printf("%s\n", msg);
     76        }
    6177
    6278        size_t i;
     79        if (length > 0) {
     80                printf("%s", get_indent(indent));
     81        }
    6382        for (i = 0; i < length; i++) {
    64                 printf("  0x%02X", buffer[i]);
     83                printf("0x%02X", buffer[i]);
    6584                if (((i > 0) && (((i+1) % BYTES_PER_LINE) == 0))
    6685                    || (i + 1 == length)) {
    6786                        printf("\n");
     87                        if (i + 1 < length) {
     88                                printf("%s", get_indent(indent));
     89                        }
     90                } else {
     91                        printf("  ");
    6892                }
    6993        }
     94}
     95
     96void dump_usb_descriptor(uint8_t *descriptor, size_t size)
     97{
     98        usb_dump_standard_descriptor(stdout, get_indent(0), "\n",
     99            descriptor, size);
    70100}
    71101
     
    83113}
    84114
    85 void dump_standard_device_descriptor(usb_standard_device_descriptor_t *d)
    86 {
    87         printf("Standard device descriptor:\n");
    88 
    89         printf(INDENT "bLength = %d\n", d->length);
    90         printf(INDENT "bDescriptorType = 0x%02x\n", d->descriptor_type);
    91         printf(INDENT "bcdUSB = %d (" BCD_FMT ")\n", d->usb_spec_version,
    92             BCD_ARGS(d->usb_spec_version));
    93         printf(INDENT "bDeviceClass = 0x%02x\n", d->device_class);
    94         printf(INDENT "bDeviceSubClass = 0x%02x\n", d->device_subclass);
    95         printf(INDENT "bDeviceProtocol = 0x%02x\n", d->device_protocol);
    96         printf(INDENT "bMaxPacketSize0 = %d\n", d->max_packet_size);
    97         printf(INDENT "idVendor = %d\n", d->vendor_id);
    98         printf(INDENT "idProduct = %d\n", d->product_id);
    99         printf(INDENT "bcdDevice = %d\n", d->device_version);
    100         printf(INDENT "iManufacturer = %d\n", d->str_manufacturer);
    101         printf(INDENT "iProduct = %d\n", d->str_product);
    102         printf(INDENT "iSerialNumber = %d\n", d->str_serial_number);
    103         printf(INDENT "bNumConfigurations = %d\n", d->configuration_count);
    104 }
    105 
    106 void dump_standard_configuration_descriptor(
    107     int index, usb_standard_configuration_descriptor_t *d)
    108 {
    109         bool self_powered = d->attributes & 64;
    110         bool remote_wakeup = d->attributes & 32;
    111        
    112         printf("Standard configuration descriptor #%d\n", index);
    113         printf(INDENT "bLength = %d\n", d->length);
    114         printf(INDENT "bDescriptorType = 0x%02x\n", d->descriptor_type);
    115         printf(INDENT "wTotalLength = %d\n", d->total_length);
    116         printf(INDENT "bNumInterfaces = %d\n", d->interface_count);
    117         printf(INDENT "bConfigurationValue = %d\n", d->configuration_number);
    118         printf(INDENT "iConfiguration = %d\n", d->str_configuration);
    119         printf(INDENT "bmAttributes = %d [%s%s%s]\n", d->attributes,
    120             self_powered ? "self-powered" : "",
    121             (self_powered & remote_wakeup) ? ", " : "",
    122             remote_wakeup ? "remote-wakeup" : "");
    123         printf(INDENT "MaxPower = %d (%dmA)\n", d->max_power,
    124             2 * d->max_power);
    125         // printf(INDENT " = %d\n", d->);
    126 }
    127 
    128115static void dump_tree_descriptor(uint8_t *descriptor, size_t depth)
    129116{
    130117        if (descriptor == NULL) {
    131118                return;
    132         }
    133         while (depth > 0) {
    134                 printf("  ");
    135                 depth--;
    136119        }
    137120        int type = (int) *(descriptor + 1);
     
    151134#undef _TYPE
    152135        }
    153         printf("0x%02x (%s)\n", type, name);
     136        printf("%s%s (0x%02X):\n", get_indent(depth), name, type);
     137        usb_dump_standard_descriptor(stdout, get_indent(depth), "\n",
     138            descriptor, descriptor[0]);
    154139}
    155140
     
    172157        uint8_t *ptr = data->data;
    173158        printf("Descriptor tree:\n");
    174         dump_tree_internal(parser, data, ptr, 1);
     159        dump_tree_internal(parser, data, ptr, 0);
    175160}
    176161
  • uspace/app/usbinfo/info.c

    rb65ca41d r64861b8  
    7272                return rc;
    7373        }
    74         dump_standard_device_descriptor(&device_descriptor);
     74        dump_usb_descriptor((uint8_t *)&device_descriptor, sizeof(device_descriptor));
    7575
    7676        /*
     
    9191                return rc;
    9292        }
    93         dump_standard_configuration_descriptor(config_index,
    94             &config_descriptor);
     93        //dump_standard_configuration_descriptor(config_index, &config_descriptor);
    9594
    9695        void *full_config_descriptor = malloc(config_descriptor.total_length);
     
    109108                return rc;
    110109        }
    111         dump_buffer("Full configuration descriptor:",
    112             full_config_descriptor, config_descriptor.total_length);
    113110
    114111        dump_descriptor_tree(full_config_descriptor,
  • uspace/app/usbinfo/usbinfo.h

    rb65ca41d r64861b8  
    4444#define NAME "usbinfo"
    4545
    46 void dump_buffer(const char *, const uint8_t *, size_t);
     46void dump_buffer(const char *, size_t, const uint8_t *, size_t);
    4747void dump_match_ids(match_id_list_t *matches);
    48 void dump_standard_device_descriptor(usb_standard_device_descriptor_t *);
    49 void dump_standard_configuration_descriptor(int,
    50     usb_standard_configuration_descriptor_t *);
     48void dump_usb_descriptor(uint8_t *, size_t);
    5149int dump_device(int, usb_address_t);
    5250void dump_descriptor_tree(uint8_t *, size_t);
  • uspace/app/virtusbkbd/keys.h

    rb65ca41d r64861b8  
    4040
    4141/** Maximum number of keys that can be pressed simultaneously. */
    42 #define KB_MAX_KEYS_AT_ONCE 4
     42#define KB_MAX_KEYS_AT_ONCE 6
    4343
    4444/** Key code type. */
  • uspace/drv/usbkbd/descparser.c

    rb65ca41d r64861b8  
    9696        pos += sizeof(usb_standard_configuration_descriptor_t);
    9797
    98         printf("Parsed configuration descriptor: \n");
    99         dump_standard_configuration_descriptor(0, &config->config_descriptor);
     98        //printf("Parsed configuration descriptor: \n");
     99        //dump_standard_configuration_descriptor(0, &config->config_descriptor);
    100100       
    101101        int ret = EOK;
     
    139139                        pos += desc_size;
    140140
    141                         printf("Parsed interface descriptor: \n");
    142                         dump_standard_interface_descriptor(&actual_iface->iface_desc);
     141                        //printf("Parsed interface descriptor: \n");
     142                        //dump_standard_interface_descriptor(&actual_iface->iface_desc);
    143143                       
    144144                        // allocate space for endpoint descriptors
     
    153153                        ep_i = 0;
    154154
    155                         printf("Remaining size: %d\n", size - (size_t)(pos - data));
     155                        //printf("Remaining size: %d\n", size - (size_t)(pos - data));
    156156                       
    157157                        break;
     
    180180                        pos += desc_size;
    181181
    182                         printf("Parsed endpoint descriptor: \n");
    183                         dump_standard_endpoint_descriptor(&actual_iface->endpoints[ep_i]);
     182                        //printf("Parsed endpoint descriptor: \n");
     183                        //dump_standard_endpoint_descriptor(&actual_iface->endpoints[ep_i]);
    184184                        ++ep_i;
    185185                       
     
    187187                case USB_DESCTYPE_HID:
    188188                        if (desc_size < sizeof(usb_standard_hid_descriptor_t)) {
    189                                 printf("Wrong size of descriptor: %d (should be %d)\n",
     189                                printf("Wrong size of descriptor: %d (should be %zu)\n",
    190190                                    desc_size, sizeof(usb_standard_hid_descriptor_t));
    191191                                ret = EINVAL;
     
    208208                        }*/
    209209
    210                         printf("Parsed HID descriptor header: \n");
    211                         dump_standard_hid_descriptor_header(&actual_iface->hid_desc);
     210                        //printf("Parsed HID descriptor header: \n");
     211                        //dump_standard_hid_descriptor_header(&actual_iface->hid_desc);
    212212                       
    213213                        // allocate space for all class-specific descriptor info
  • uspace/drv/usbkbd/main.c

    rb65ca41d r64861b8  
    130130                assert(actual_size == length);
    131131
    132                 dump_hid_class_descriptor(0, USB_DESCTYPE_HID_REPORT,
    133                     kbd_dev->conf->interfaces[i].report_desc, length);
     132                //dump_hid_class_descriptor(0, USB_DESCTYPE_HID_REPORT,
     133                //    kbd_dev->conf->interfaces[i].report_desc, length);
    134134        }
    135135
     
    189189        }
    190190       
    191         usbkbd_print_config(kbd_dev->conf);
     191        //usbkbd_print_config(kbd_dev->conf);
    192192
    193193        /*
  • uspace/drv/vhc/devices.c

    rb65ca41d r64861b8  
    138138                } else {
    139139                        async_wait_for(req, &answer_rc);
     140                        transaction->actual_len = IPC_GET_ARG1(answer_data);
    140141                        rc = (int)answer_rc;
    141142                }
  • uspace/drv/vhc/hc.c

    rb65ca41d r64861b8  
    9696            usb_str_transaction_outcome(outcome));
    9797       
    98         transaction->callback(transaction->buffer, transaction->len, outcome,
    99             transaction->callback_arg);
     98        transaction->callback(transaction->buffer, transaction->actual_len,
     99            outcome, transaction->callback_arg);
    100100}
    101101
     
    169169        transaction->buffer = buffer;
    170170        transaction->len = len;
     171        transaction->actual_len = len;
    171172        transaction->callback = callback;
    172173        transaction->callback_arg = arg;
  • uspace/drv/vhc/hc.h

    rb65ca41d r64861b8  
    6565        /** Transaction data length. */
    6666        size_t len;
     67        /** Data length actually transfered. */
     68        size_t actual_len;
    6769        /** Callback after transaction is done. */
    6870        hc_transaction_done_callback_t callback;
  • uspace/lib/usb/Makefile

    rb65ca41d r64861b8  
    3838        src/dp.c \
    3939        src/drvpsync.c \
     40        src/dump.c \
    4041        src/hcdhubd.c \
    4142        src/hcdrv.c \
  • uspace/lib/usb/include/usb/debug.h

    rb65ca41d r64861b8  
    3535#ifndef LIBUSB_DEBUG_H_
    3636#define LIBUSB_DEBUG_H_
     37#include <stdio.h>
     38#include <usb/usb.h>
    3739
    3840void usb_dprintf(const char *tag, int level, const char *format, ...);
    3941void usb_dprintf_enable(const char *tag, int level);
    4042
     43void usb_dump_standard_descriptor(FILE *, const char *, const char *,
     44    const uint8_t *, size_t);
    4145
    4246#endif
  • uspace/lib/usbvirt/src/callback.c

    rb65ca41d r64861b8  
    160160                        return;
    161161                }
    162                 async_data_read_finalize(callid, buffer, receive_len);
    163         }
    164        
    165         ipc_answer_0(iid, rc);
     162                if (len > receive_len) {
     163                        len = receive_len;
     164                }
     165                async_data_read_finalize(callid, buffer, len);
     166        }
     167       
     168        ipc_answer_1(iid, rc, len);
    166169}
    167170
Note: See TracChangeset for help on using the changeset viewer.