Changeset 4acf099 in mainline


Ignore:
Timestamp:
2011-03-25T14:15:03Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8c40822
Parents:
1cbfd6b (diff), 538bb6b (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:

Merged development changes

Files:
12 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    r1cbfd6b r4acf099  
    552552! CONFIG_RUN_VIRTUAL_USB_HC (n/y)
    553553
     554% Polling UHCI & OHCI (no interrupts)
     555! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_USBHC_NO_INTERRUPTS (y/n)
  • uspace/app/usbinfo/info.c

    r1cbfd6b r4acf099  
    294294}
    295295
     296
     297void dump_status(usbinfo_device_t *dev)
     298{
     299        int rc;
     300        uint16_t device_status = 0;
     301        uint16_t ctrl_pipe_status = 0;
     302
     303        /* Device status first. */
     304        rc = usb_request_get_status(&dev->ctrl_pipe,
     305            USB_REQUEST_RECIPIENT_DEVICE, 0,
     306            &device_status);
     307        if (rc != EOK) {
     308                printf("%sFailed to get device status: %s.\n",
     309                    get_indent(0), str_error(rc));
     310                goto try_ctrl_pipe_status;
     311        }
     312
     313        printf("%sDevice status 0x%04x: power=%s, remote-wakeup=%s.\n",
     314            get_indent(0),
     315            device_status,
     316            device_status & USB_DEVICE_STATUS_SELF_POWERED ? "self" : "bus",
     317            device_status & USB_DEVICE_STATUS_REMOTE_WAKEUP ? "yes" : "no");
     318
     319        /* Interface is not interesting, skipping ;-). */
     320
     321        /* Control endpoint zero. */
     322try_ctrl_pipe_status:
     323        rc = usb_request_get_status(&dev->ctrl_pipe,
     324            USB_REQUEST_RECIPIENT_ENDPOINT, 0,
     325            &ctrl_pipe_status);
     326        if (rc != EOK) {
     327                printf("%sFailed to get control endpoint status: %s.\n",
     328                    get_indent(0), str_error(rc));
     329                goto leave;
     330        }
     331
     332        printf("%sControl endpoint zero status %04X: halted=%s.\n",
     333            get_indent(0),
     334            ctrl_pipe_status,
     335            ctrl_pipe_status & USB_ENDPOINT_STATUS_HALTED ? "yes" : "no");
     336
     337leave:
     338        return;
     339}
     340
    296341/** @}
    297342 */
  • uspace/app/usbinfo/main.c

    r1cbfd6b r4acf099  
    136136        _OPTION("-T --descriptor-tree-full", "Print detailed descriptor tree");
    137137        _OPTION("-s --strings", "Try to print all string descriptors.");
     138        _OPTION("-S --status", "Get status of the device.");
    138139
    139140        printf("\n");
     
    152153        {"descriptor-tree-full", no_argument, NULL, 'T'},
    153154        {"strings", no_argument, NULL, 's'},
     155        {"status", no_argument, NULL, 'S'},
    154156        {0, 0, NULL, 0}
    155157};
    156 static const char *short_options = "himtTs";
     158static const char *short_options = "himtTsS";
    157159
    158160static usbinfo_action_t actions[] = {
     
    180182                .opt = 's',
    181183                .action = dump_strings,
     184                .active = false
     185        },
     186        {
     187                .opt = 'S',
     188                .action = dump_status,
    182189                .active = false
    183190        },
  • uspace/app/usbinfo/usbinfo.h

    r1cbfd6b r4acf099  
    8484void dump_descriptor_tree_full(usbinfo_device_t *);
    8585void dump_strings(usbinfo_device_t *);
     86void dump_status(usbinfo_device_t *);
    8687
    8788
  • uspace/drv/ohci/main.c

    r1cbfd6b r4acf099  
    149149        }
    150150
     151
    151152        bool interrupts = false;
     153#ifdef CONFIG_USBHC_NO_INTERRUPTS
     154        usb_log_warning("Interrupts disabled in OS config, " \
     155            "falling back to polling.\n");
     156#else
    152157        ret = pci_enable_interrupts(device);
    153158        if (ret != EOK) {
    154                 usb_log_warning(
    155                     "Failed(%d) to enable interrupts, fall back to polling.\n",
    156                     ret);
     159                usb_log_warning("Failed to enable interrupts: %s.\n",
     160                    str_error(ret));
     161                usb_log_info("HW interrupts not available, " \
     162                    "falling back to polling.\n");
    157163        } else {
    158164                usb_log_debug("Hw interrupts enabled.\n");
    159165                interrupts = true;
    160166        }
     167#endif
    161168
    162169        ret = hc_init(hcd, hc_fun, device, mem_reg_base, mem_reg_size, interrupts);
  • uspace/drv/uhci-hcd/batch.c

    r1cbfd6b r4acf099  
    4848        qh_t *qh;
    4949        td_t *tds;
    50         size_t packets;
     50        size_t transfers;
    5151        usb_device_keeper_t *manager;
    5252} uhci_batch_t;
     
    6464 * @param[in] target Device and endpoint target of the transaction.
    6565 * @param[in] transfer_type Interrupt, Control or Bulk.
    66  * @param[in] max_packet_size maximum allowed size of data packets.
     66 * @param[in] max_packet_size maximum allowed size of data transfers.
    6767 * @param[in] speed Speed of the transaction.
    6868 * @param[in] buffer Data source/destination.
     
    7777 * NULL otherwise.
    7878 *
    79  * Determines the number of needed packets (TDs). Prepares a transport buffer
     79 * Determines the number of needed transfers (TDs). Prepares a transport buffer
    8080 * (that is accessible by the hardware). Initializes parameters needed for the
    8181 * transaction and callback.
     
    117117        instance->private_data = data;
    118118
    119         data->packets = (buffer_size + max_packet_size - 1) / max_packet_size;
     119        data->transfers = (buffer_size + max_packet_size - 1) / max_packet_size;
    120120        if (transfer_type == USB_TRANSFER_CONTROL) {
    121                 data->packets += 2;
    122         }
    123 
    124         data->tds = malloc32(sizeof(td_t) * data->packets);
     121                data->transfers += 2;
     122        }
     123
     124        data->tds = malloc32(sizeof(td_t) * data->transfers);
    125125        CHECK_NULL_DISPOSE_RETURN(
    126126            data->tds, "Failed to allocate transfer descriptors.\n");
    127         bzero(data->tds, sizeof(td_t) * data->packets);
     127        bzero(data->tds, sizeof(td_t) * data->transfers);
    128128
    129129        data->qh = malloc32(sizeof(qh_t));
     
    166166        assert(data);
    167167
    168         usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n",
    169             instance, data->packets);
     168        usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n",
     169            instance, data->transfers);
    170170        instance->transfered_size = 0;
    171171        size_t i = 0;
    172         for (;i < data->packets; ++i) {
     172        for (;i < data->transfers; ++i) {
    173173                if (td_is_active(&data->tds[i])) {
    174174                        return false;
     
    298298 *
    299299 * @param[in] instance Batch structure to use.
    300  * @param[in] pid to use for data packets.
     300 * @param[in] pid Pid to use for data transfers.
    301301 *
    302302 * Packets with alternating toggle bit and supplied pid value.
    303  * The last packet is marked with IOC flag.
     303 * The last transfer is marked with IOC flag.
    304304 */
    305305void batch_data(usb_transfer_batch_t *instance, usb_packet_id pid)
     
    314314        assert(toggle == 0 || toggle == 1);
    315315
    316         size_t packet = 0;
     316        size_t transfer = 0;
    317317        size_t remain_size = instance->buffer_size;
    318318        while (remain_size > 0) {
     
    325325                    remain_size : instance->max_packet_size;
    326326
    327                 td_t *next_packet = (packet + 1 < data->packets)
    328                     ? &data->tds[packet + 1] : NULL;
    329 
    330                 assert(packet < data->packets);
     327                td_t *next_transfer = (transfer + 1 < data->transfers)
     328                    ? &data->tds[transfer + 1] : NULL;
     329
     330                assert(transfer < data->transfers);
    331331                assert(packet_size <= remain_size);
    332332
    333333                td_init(
    334                     &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size,
     334                    &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
    335335                    toggle, false, low_speed, instance->target, pid, trans_data,
    336                     next_packet);
     336                    next_transfer);
    337337
    338338
    339339                toggle = 1 - toggle;
    340340                remain_size -= packet_size;
    341                 ++packet;
    342         }
    343         td_set_ioc(&data->tds[packet - 1]);
     341                ++transfer;
     342        }
     343        td_set_ioc(&data->tds[transfer - 1]);
    344344        usb_device_keeper_set_toggle(data->manager, instance->target,
    345345            instance->direction, toggle);
     
    349349 *
    350350 * @param[in] instance Batch structure to use.
    351  * @param[in] data_stage to use for data packets.
    352  * @param[in] status_stage to use for data packets.
     351 * @param[in] data_stage Pid to use for data transfers.
     352 * @param[in] status_stage Pid to use for data transfers.
    353353 *
    354354 * Setup stage with toggle 0 and USB_PID_SETUP.
    355355 * Data stage with alternating toggle and pid supplied by parameter.
    356356 * Status stage with toggle 1 and pid supplied by parameter.
    357  * The last packet is marked with IOC.
     357 * The last transfer is marked with IOC.
    358358 */
    359359void batch_control(usb_transfer_batch_t *instance,
     
    363363        uhci_batch_t *data = instance->private_data;
    364364        assert(data);
    365         assert(data->packets >= 2);
     365        assert(data->transfers >= 2);
    366366
    367367        const bool low_speed = instance->speed == USB_SPEED_LOW;
     
    374374
    375375        /* data stage */
    376         size_t packet = 1;
     376        size_t transfer = 1;
    377377        size_t remain_size = instance->buffer_size;
    378378        while (remain_size > 0) {
     
    388388
    389389                td_init(
    390                     &data->tds[packet], DEFAULT_ERROR_COUNT, packet_size,
     390                    &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
    391391                    toggle, false, low_speed, instance->target, data_stage,
    392                     control_data, &data->tds[packet + 1]);
    393 
    394                 ++packet;
    395                 assert(packet < data->packets);
     392                    control_data, &data->tds[transfer + 1]);
     393
     394                ++transfer;
     395                assert(transfer < data->transfers);
    396396                assert(packet_size <= remain_size);
    397397                remain_size -= packet_size;
     
    399399
    400400        /* status stage */
    401         assert(packet == data->packets - 1);
     401        assert(transfer == data->transfers - 1);
    402402
    403403        td_init(
    404             &data->tds[packet], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
     404            &data->tds[transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
    405405            instance->target, status_stage, NULL, NULL);
    406         td_set_ioc(&data->tds[packet]);
     406        td_set_ioc(&data->tds[transfer]);
    407407
    408408        usb_log_debug2("Control last TD status: %x.\n",
    409             data->tds[packet].status);
     409            data->tds[transfer].status);
    410410}
    411411/*----------------------------------------------------------------------------*/
  • uspace/drv/uhci-hcd/hc.c

    r1cbfd6b r4acf099  
    6767static int hc_debug_checker(void *arg);
    6868
    69 static bool allowed_usb_packet(
     69static bool usb_is_allowed(
    7070    bool low_speed, usb_transfer_type_t transfer, size_t size);
    7171/*----------------------------------------------------------------------------*/
     
    323323        assert(batch);
    324324        const int low_speed = (batch->speed == USB_SPEED_LOW);
    325         if (!allowed_usb_packet(
     325        if (!usb_is_allowed(
    326326            low_speed, batch->transfer_type, batch->max_packet_size)) {
    327327                usb_log_warning(
    328                     "Invalid USB packet specified %s SPEED %d %zu.\n",
     328                    "Invalid USB transfer specified %s SPEED %d %zu.\n",
    329329                    low_speed ? "LOW" : "FULL" , batch->transfer_type,
    330330                    batch->max_packet_size);
     
    471471}
    472472/*----------------------------------------------------------------------------*/
    473 /** Check transfer packets, for USB validity
     473/** Check transfers for USB validity
    474474 *
    475475 * @param[in] low_speed Transfer speed.
    476476 * @param[in] transfer Transer type
    477  * @param[in] size Maximum size of used packets
     477 * @param[in] size Size of data packets
    478478 * @return True if transaction is allowed by USB specs, false otherwise
    479479 */
    480 bool allowed_usb_packet(
     480bool usb_is_allowed(
    481481    bool low_speed, usb_transfer_type_t transfer, size_t size)
    482482{
  • uspace/drv/uhci-hcd/hw_struct/transfer_descriptor.h

    r1cbfd6b r4acf099  
    108108}
    109109/*----------------------------------------------------------------------------*/
    110 /** Check whether less than max data were recieved and packet is marked as SPD.
     110/** Check whether less than max data were received on SPD marked transfer.
    111111 *
    112112 * @param[in] instance TD structure to use.
    113  * @return True if packet is short (less than max bytes and SPD set), false
    114  *     otherwise.
     113 * @return True if data packet is short (less than max bytes and SPD set),
     114 * false otherwise.
    115115 */
    116116static inline bool td_is_short(td_t *instance)
  • uspace/drv/uhci-hcd/iface.c

    r1cbfd6b r4acf099  
    279279 * @param[in] target USB device to write to.
    280280 * @param[in] max_packet_size maximum size of data packet the device accepts.
    281  * @param[in] setup_data Data to send with SETUP packet.
    282  * @param[in] setup_size Size of data to send with SETUP packet (should be 8B).
     281 * @param[in] setup_data Data to send with SETUP transfer.
     282 * @param[in] setup_size Size of data to send with SETUP transfer (always 8B).
    283283 * @param[in] data Source of data.
    284284 * @param[in] size Size of data source.
  • uspace/drv/uhci-hcd/transfer_list.c

    r1cbfd6b r4acf099  
    9191 * The batch is added to the end of the list and queue.
    9292 */
    93 void transfer_list_add_batch(transfer_list_t *instance, usb_transfer_batch_t *batch)
     93void transfer_list_add_batch(
     94    transfer_list_t *instance, usb_transfer_batch_t *batch)
    9495{
    9596        assert(instance);
     
    146147        while (current != &instance->batch_list) {
    147148                link_t *next = current->next;
    148                 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link);
     149                usb_transfer_batch_t *batch =
     150                    list_get_instance(current, usb_transfer_batch_t, link);
    149151
    150152                if (batch_is_complete(batch)) {
     
    160162                link_t *item = done.next;
    161163                list_remove(item);
    162                 usb_transfer_batch_t *batch = list_get_instance(item, usb_transfer_batch_t, link);
     164                usb_transfer_batch_t *batch =
     165                    list_get_instance(item, usb_transfer_batch_t, link);
    163166                batch->next_step(batch);
    164167        }
     
    174177        while (!list_empty(&instance->batch_list)) {
    175178                link_t *current = instance->batch_list.next;
    176                 usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link);
     179                usb_transfer_batch_t *batch =
     180                    list_get_instance(current, usb_transfer_batch_t, link);
    177181                transfer_list_remove_batch(instance, batch);
    178182                usb_transfer_batch_finish(batch, EIO);
     
    189193 * Does not lock the transfer list, caller is responsible for that.
    190194 */
    191 void transfer_list_remove_batch(transfer_list_t *instance, usb_transfer_batch_t *batch)
     195void transfer_list_remove_batch(
     196    transfer_list_t *instance, usb_transfer_batch_t *batch)
    192197{
    193198        assert(instance);
     
    210215        } else {
    211216                usb_transfer_batch_t *prev =
    212                     list_get_instance(batch->link.prev, usb_transfer_batch_t, link);
     217                    list_get_instance(
     218                        batch->link.prev, usb_transfer_batch_t, link);
    213219                assert((batch_qh(prev)->next & LINK_POINTER_ADDRESS_MASK)
    214220                    == addr_to_phys(batch_qh(batch)));
  • uspace/drv/uhci-hcd/uhci.c

    r1cbfd6b r4acf099  
    175175
    176176        bool interrupts = false;
     177#ifdef CONFIG_USBHC_NO_INTERRUPTS
     178        usb_log_warning("Interrupts disabled in OS config, " \
     179            "falling back to polling.\n");
     180#else
    177181        ret = pci_enable_interrupts(device);
    178182        if (ret != EOK) {
    179                 usb_log_warning(
    180                     "Failed(%d) to enable interrupts, fall back to polling.\n",
    181                     ret);
     183                usb_log_warning("Failed to enable interrupts: %s.\n",
     184                    str_error(ret));
     185                usb_log_info("HW interrupts not available, " \
     186                    "falling back to polling.\n");
    182187        } else {
    183188                usb_log_debug("Hw interrupts enabled.\n");
    184189                interrupts = true;
    185190        }
     191#endif
    186192
    187193        instance->hc_fun = ddf_fun_create(device, fun_exposed, "uhci-hc");
  • uspace/lib/usb/include/usb/request.h

    r1cbfd6b r4acf099  
    4141#include <usb/pipes.h>
    4242#include <usb/descriptor.h>
     43
     44/** USB device status - device is self powered (opposed to bus powered). */
     45#define USB_DEVICE_STATUS_SELF_POWERED ((uint16_t)(1 << 0))
     46
     47/** USB device status - remote wake-up signaling is enabled. */
     48#define USB_DEVICE_STATUS_REMOTE_WAKEUP ((uint16_t)(1 << 1))
     49
     50/** USB endpoint status - endpoint is halted (stalled). */
     51#define USB_ENDPOINT_STATUS_HALTED ((uint16_t)(1 << 0))
    4352
    4453/** Standard device request. */
Note: See TracChangeset for help on using the changeset viewer.