Changes in / [7c169ce:6336b6e] in mainline


Ignore:
Files:
1 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • .bzrignore

    r7c169ce r6336b6e  
    109109./uspace/srv/hw/irc/apic/apic
    110110./uspace/srv/hw/irc/i8259/i8259
    111 ./uspace/srv/hw/netif/ne2000/dp8390
    112 ./uspace/srv/hw/netif/ne2000/ne2000
     111./uspace/srv/hw/netif/dp8390/dp8390
    113112./uspace/srv/loader/loader
    114113./uspace/srv/net/cfg/lo
  • uspace/app/usbinfo/dump.c

    r7c169ce r6336b6e  
    4343#include <usb/usb.h>
    4444#include <usb/descriptor.h>
    45 #include <usb/debug.h>
    46 #include <usb/classes/classes.h>
    4745
    4846#include "usbinfo.h"
     
    5250#define BYTES_PER_LINE 12
    5351
    54 
    55 static 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 }
    70 
    71 void dump_buffer(const char *msg, size_t indent,
    72     const uint8_t *buffer, size_t length)
    73 {
    74         if (msg != NULL) {
    75                 printf("%s\n", msg);
    76         }
     52#define BCD_INT(a) (((unsigned int)(a)) / 256)
     53#define BCD_FRAC(a) (((unsigned int)(a)) % 256)
     54
     55#define BCD_FMT "%x.%x"
     56#define BCD_ARGS(a) BCD_INT((a)), BCD_FRAC((a))
     57
     58void dump_buffer(const char *msg, const uint8_t *buffer, size_t length)
     59{
     60        printf("%s\n", msg);
    7761
    7862        size_t i;
    79         if (length > 0) {
    80                 printf("%s", get_indent(indent));
    81         }
    8263        for (i = 0; i < length; i++) {
    83                 printf("0x%02X", buffer[i]);
     64                printf("  0x%02X", buffer[i]);
    8465                if (((i > 0) && (((i+1) % BYTES_PER_LINE) == 0))
    8566                    || (i + 1 == length)) {
    8667                        printf("\n");
    87                         if (i + 1 < length) {
    88                                 printf("%s", get_indent(indent));
    89                         }
    90                 } else {
    91                         printf("  ");
    9268                }
    9369        }
    94 }
    95 
    96 void dump_usb_descriptor(uint8_t *descriptor, size_t size)
    97 {
    98         usb_dump_standard_descriptor(stdout, get_indent(0), "\n",
    99             descriptor, size);
    10070}
    10171
     
    11383}
    11484
     85void 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
     106void 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
    115128static void dump_tree_descriptor(uint8_t *descriptor, size_t depth)
    116129{
    117130        if (descriptor == NULL) {
    118131                return;
     132        }
     133        while (depth > 0) {
     134                printf("  ");
     135                depth--;
    119136        }
    120137        int type = (int) *(descriptor + 1);
     
    134151#undef _TYPE
    135152        }
    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]);
     153        printf("0x%02x (%s)\n", type, name);
    139154}
    140155
     
    157172        uint8_t *ptr = data->data;
    158173        printf("Descriptor tree:\n");
    159         dump_tree_internal(parser, data, ptr, 0);
     174        dump_tree_internal(parser, data, ptr, 1);
    160175}
    161176
  • uspace/app/usbinfo/info.c

    r7c169ce r6336b6e  
    7272                return rc;
    7373        }
    74         dump_usb_descriptor((uint8_t *)&device_descriptor, sizeof(device_descriptor));
     74        dump_standard_device_descriptor(&device_descriptor);
    7575
    7676        /*
     
    9191                return rc;
    9292        }
    93         //dump_standard_configuration_descriptor(config_index, &config_descriptor);
     93        dump_standard_configuration_descriptor(config_index,
     94            &config_descriptor);
    9495
    9596        void *full_config_descriptor = malloc(config_descriptor.total_length);
     
    108109                return rc;
    109110        }
     111        dump_buffer("Full configuration descriptor:",
     112            full_config_descriptor, config_descriptor.total_length);
    110113
    111114        dump_descriptor_tree(full_config_descriptor,
  • uspace/app/usbinfo/usbinfo.h

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

    r7c169ce r6336b6e  
    4040
    4141/** Maximum number of keys that can be pressed simultaneously. */
    42 #define KB_MAX_KEYS_AT_ONCE 6
     42#define KB_MAX_KEYS_AT_ONCE 4
    4343
    4444/** Key code type. */
  • uspace/drv/usbhub/main.c

    r7c169ce r6336b6e  
    5252        while(true){
    5353                usb_hub_check_hub_changes();
    54                 async_usleep(1000 * 1000 );/// \TODO proper number once
     54                async_usleep(1000 * 1000);
    5555        }
    5656        return 0;
  • uspace/drv/usbhub/usbhub.c

    r7c169ce r6336b6e  
    4646#include "usbhub_private.h"
    4747#include "port_status.h"
    48 #include "usb/usb.h"
    4948
    5049static usb_iface_t hub_usb_iface = {
     
    8685
    8786        // get hub descriptor
     87        usb_target_t target;
     88        target.address = addr;
     89        target.endpoint = 0;
     90        usb_device_request_setup_packet_t request;
     91        //printf("[usb_hub] creating descriptor request\n");
     92        usb_hub_set_descriptor_request(&request);
    8893
    8994        //printf("[usb_hub] creating serialized descriptor\n");
     
    9398        int opResult;
    9499        //printf("[usb_hub] starting control transaction\n");
    95        
    96         opResult = usb_drv_req_get_descriptor(hc, addr,
    97                         USB_REQUEST_TYPE_CLASS,
    98                         USB_DESCTYPE_HUB, 0, 0, serialized_descriptor,
     100        opResult = usb_drv_sync_control_read(
     101                        hc, target, &request, serialized_descriptor,
    99102                        USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
    100 
    101103        if (opResult != EOK) {
    102104                dprintf(1,"[usb_hub] failed when receiving hub descriptor, badcode = %d",opResult);
     
    153155        int port;
    154156        int opResult;
     157        usb_device_request_setup_packet_t request;
    155158        usb_target_t target;
    156159        target.address = hub_info->usb_device->address;
     
    170173        if(std_descriptor.configuration_count<1){
    171174                dprintf(1,"[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE");
    172                 //shouldn`t I return?
    173175        }
    174176        /// \TODO check other configurations
     
    182184        }
    183185        //set configuration
    184         opResult = usb_drv_req_set_configuration(hc, target.address,
    185     config_descriptor.configuration_number);
    186 
     186        request.request_type = 0;
     187        request.request = USB_DEVREQ_SET_CONFIGURATION;
     188        request.index=0;
     189        request.length=0;
     190        request.value_high=0;
     191        request.value_low = config_descriptor.configuration_number;
     192        opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
    187193        if (opResult != EOK) {
    188194                dprintf(1,"[usb_hub]something went wrong when setting hub`s configuration, %d", opResult);
    189195        }
    190196
    191         usb_device_request_setup_packet_t request;
    192197        for (port = 1; port < hub_info->port_count+1; ++port) {
    193198                usb_hub_set_power_port_request(&request, port);
     
    224229
    225230
     231
    226232//*********************************************
    227233//
     
    231237
    232238/**
    233  * Convenience function for releasing default address and writing debug info
    234  * (these few lines are used too often to be written again and again).
     239 * convenience function for releasing default address and writing debug info
     240 * (these few lines are used too often to be written again and again)
    235241 * @param hc
    236242 * @return
     
    247253
    248254/**
    249  * Reset the port with new device and reserve the default address.
     255 * reset the port with new device and reserve the default address
    250256 * @param hc
    251257 * @param port
     
    276282
    277283/**
    278  * Finalize adding new device after port reset
     284 * finalize adding new device after port reset
    279285 * @param hc
    280286 * @param port
     
    339345
    340346/**
    341  * Unregister device address in hc
     347 * unregister device address in hc
    342348 * @param hc
    343349 * @param port
     
    349355        int opResult;
    350356       
    351         /** \TODO remove device from device manager - not yet implemented in
    352          * devide manager
    353          */
     357        /// \TODO remove device
    354358
    355359        hub->attached_devs[port].devman_handle=0;
     
    372376
    373377/**
    374  * Process interrupts on given hub port
     378 * process interrupts on given hub port
    375379 * @param hc
    376380 * @param port
     
    430434        usb_port_set_reset_completed(&status, false);
    431435        usb_port_set_dev_connected(&status, false);
    432         if (status>>16) {
    433                 dprintf(1,"[usb_hub]there was some unsupported change on port %d: %X",port,status);
    434 
     436        if (status) {
     437                dprintf(1,"[usb_hub]there was some unsupported change on port %d",port);
    435438        }
    436439        /// \TODO handle other changes
     
    439442}
    440443
    441 /**
    442  * Check changes on all known hubs.
     444/* Check changes on all known hubs.
    443445 */
    444446void usb_hub_check_hub_changes(void) {
  • uspace/drv/usbhub/usbhub_private.h

    r7c169ce r6336b6e  
    3131 */
    3232/** @file
    33  * @brief Hub driver private definitions
     33 * @brief Hub driver.
    3434 */
    3535
     
    6868
    6969/**
    70  * Create hub structure instance
     70 * create hub structure instance
    7171 *
    7272 * Set the address and port count information most importantly.
     
    7878usb_hub_info_t * usb_create_hub_info(device_t * device, int hc);
    7979
    80 /** List of hubs maanged by this driver */
     80/** list of hubs maanged by this driver */
    8181extern usb_general_list_t usb_hub_list;
    8282
    83 /** Lock for hub list*/
     83/** lock for hub list*/
    8484extern futex_t usb_hub_list_lock;
    8585
    8686
    8787/**
    88  * Perform complete control read transaction
     88 * perform complete control read transaction
    8989 *
    90  * Manages all three steps of transaction: setup, read and finalize
     90 * manages all three steps of transaction: setup, read and finalize
    9191 * @param phone
    9292 * @param target
    93  * @param request Request packet
    94  * @param rcvd_buffer Received data
     93 * @param request request for data
     94 * @param rcvd_buffer received data
    9595 * @param rcvd_size
    96  * @param actual_size Actual size of received data
     96 * @param actual_size actual size of received data
    9797 * @return error code
    9898 */
     
    104104
    105105/**
    106  * Perform complete control write transaction
     106 * perform complete control write transaction
    107107 *
    108  * Manages all three steps of transaction: setup, write and finalize
     108 * manages all three steps of transaction: setup, write and finalize
    109109 * @param phone
    110110 * @param target
    111  * @param request Request packet to send data
     111 * @param request request to send data
    112112 * @param sent_buffer
    113113 * @param sent_size
     
    121121
    122122/**
    123  * Set the device request to be a get hub descriptor request.
     123 * set the device request to be a get hub descriptor request.
    124124 * @warning the size is allways set to USB_HUB_MAX_DESCRIPTOR_SIZE
    125125 * @param request
     
    137137}
    138138
    139 /**
    140  * Clear feature on hub port.
    141  *
    142  * @param hc Host controller telephone
    143  * @param address Hub address
    144  * @param port_index Port
    145  * @param feature Feature selector
    146  * @return Operation result
    147  */
    148139static inline int usb_hub_clear_port_feature(int hc, usb_address_t address,
    149140    int port_index,
  • uspace/drv/usbkbd/Makefile

    r7c169ce r6336b6e  
    3636        descparser.c \
    3737        descdump.c \
    38         conv.c \
    39         us_qwerty.c
     38        conv.c
    4039
    4140include $(USPACE_PREFIX)/Makefile.common
  • uspace/drv/usbkbd/descparser.c

    r7c169ce r6336b6e  
    187187                case USB_DESCTYPE_HID:
    188188                        if (desc_size < sizeof(usb_standard_hid_descriptor_t)) {
    189                                 printf("Wrong size of descriptor: %d (should be %zu)\n",
     189                                printf("Wrong size of descriptor: %d (should be %d)\n",
    190190                                    desc_size, sizeof(usb_standard_hid_descriptor_t));
    191191                                ret = EINVAL;
  • uspace/drv/usbkbd/main.c

    r7c169ce r6336b6e  
    4242#include "descdump.h"
    4343#include "conv.h"
    44 #include "layout.h"
    4544
    4645#define BUFFER_SIZE 32
     
    126125static unsigned lock_keys;
    127126
    128 #define NUM_LAYOUTS 3
    129 
    130 static layout_op_t *layout[NUM_LAYOUTS] = {
    131         &us_qwerty_op,
    132         &us_dvorak_op,
    133         &cz_op
    134 };
    135 
    136127// TODO: put to device?
    137 static int active_layout = 0;
     128//static int active_layout = 0;
    138129
    139130static void kbd_push_ev(int type, unsigned int key)
     
    215206        ev.mods = mods;
    216207
    217         ev.c = layout[active_layout]->parse_ev(&ev);
     208        //ev.c = layout[active_layout]->parse_ev(&ev);
    218209
    219210        printf("Sending key %d to the console\n", ev.key);
    220211        assert(console_callback_phone != -1);
    221         async_msg_4(console_callback_phone, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c);
     212        async_msg_4(console_callback_phone, KBD_EVENT, ev.type, ev.key, ev.mods, 0);
    222213}
    223214/*
     
    414405        //usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks,
    415406        //    NULL);
    416         printf("Calling usb_hid_boot_keyboard_input_report() with size %d\n",
    417             actual_size);
    418         //dump_buffer("bufffer: ", buffer, actual_size);
     407//      printf("Calling usb_hid_boot_keyboard_input_report() with size %d\n",
     408//          actual_size);
     409//      dump_buffer("bufffer: ", buffer, actual_size);
    419410        int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, callbacks,
    420411            NULL);
     
    466457                 */
    467458                if (actual_size == 0) {
    468                         printf("Keyboard returned NAK\n");
     459                        printf("Keyboar returned NAK\n");
    469460                        continue;
    470461                }
     
    474465                 */
    475466                printf("Calling usbkbd_process_interrupt_in()\n");
    476                 usbkbd_process_interrupt_in(kbd_dev, buffer, actual_size);
     467                // actual_size is not set, workaround...
     468                usbkbd_process_interrupt_in(kbd_dev, buffer, /*actual_size*/8);
    477469        }
    478470
  • uspace/drv/vhc/devices.c

    r7c169ce r6336b6e  
    138138                } else {
    139139                        async_wait_for(req, &answer_rc);
    140                         transaction->actual_len = IPC_GET_ARG1(answer_data);
    141140                        rc = (int)answer_rc;
    142141                }
  • uspace/drv/vhc/hc.c

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

    r7c169ce r6336b6e  
    6565        /** Transaction data length. */
    6666        size_t len;
    67         /** Data length actually transfered. */
    68         size_t actual_len;
    6967        /** Callback after transaction is done. */
    7068        hc_transaction_done_callback_t callback;
  • uspace/lib/usb/Makefile

    r7c169ce r6336b6e  
    3838        src/dp.c \
    3939        src/drvpsync.c \
    40         src/dump.c \
    4140        src/hcdhubd.c \
    4241        src/hcdrv.c \
  • uspace/lib/usb/include/usb/debug.h

    r7c169ce r6336b6e  
    3535#ifndef LIBUSB_DEBUG_H_
    3636#define LIBUSB_DEBUG_H_
    37 #include <stdio.h>
    38 #include <usb/usb.h>
    3937
    4038void usb_dprintf(const char *tag, int level, const char *format, ...);
    4139void usb_dprintf_enable(const char *tag, int level);
    4240
    43 void usb_dump_standard_descriptor(FILE *, const char *, const char *,
    44     const uint8_t *, size_t);
    4541
    4642#endif
  • uspace/lib/usbvirt/src/callback.c

    r7c169ce r6336b6e  
    160160                        return;
    161161                }
    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);
     162                async_data_read_finalize(callid, buffer, receive_len);
     163        }
     164       
     165        ipc_answer_0(iid, rc);
    169166}
    170167
Note: See TracChangeset for help on using the changeset viewer.