Changes in / [44d8853:4046c1ea] in mainline


Ignore:
Location:
uspace/drv/uhci
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci/debug.h

    r44d8853 r4046c1ea  
    6060        usb_dprintf( NAME, DEBUG_LEVEL_VERBOSE, fmt, ##args )
    6161
     62#define UHCI_GET_STR_FLAG(reg, flag, msg_set, msg_unset) \
     63        ((((reg) & (flag)) > 0) ? (msg_set) : (msg_unset))
     64
     65
    6266#endif
    6367/**
  • uspace/drv/uhci/root_hub/port.c

    r44d8853 r4046c1ea  
    11
    22#include <errno.h>
     3#include <str_error.h>
    34//#include <usb/devreq.h> /* for usb_device_request_setup_packet_t */
    45#include <usb/usb.h>
     
    2223
    2324        while (1) {
    24                 uhci_print_info("Port(%d) status address %p:\n",
    25                   port_instance->number, port_instance->address);
    26 
    27                 /* read register value */
     25                /* Read port status. */
    2826                port_status_t port_status =
    2927                        port_status_read(port_instance->address);
    3028
    31                 /* debug print */
    32                 uhci_print_info("Port(%d) status %#.4x:\n",
    33                   port_instance->number, port_status);
    34                 print_port_status(port_status);
     29                uhci_print_info("Port %d: %04X (@ 0x%x) = " \
     30                    "%s,%s,%s,%s,[%s,%s],%s,%s,%s,%s\n",
     31                    port_instance->number, port_status, port_instance->address,
     32                    UHCI_GET_STR_FLAG(port_status, STATUS_SUSPEND, "suspend", "up"),
     33                    UHCI_GET_STR_FLAG(port_status, STATUS_IN_RESET, "in reset", "-"),
     34                    UHCI_GET_STR_FLAG(port_status, STATUS_LOW_SPEED, "lowsp", "fullsp"),
     35                    UHCI_GET_STR_FLAG(port_status, STATUS_RESUME, "resume", "k-state"),
     36                    UHCI_GET_STR_FLAG(port_status, STATUS_LINE_D_MINUS, "D- on", "D- off"),
     37                    UHCI_GET_STR_FLAG(port_status, STATUS_LINE_D_PLUS, "D+ on", "D+ off"),
     38                    UHCI_GET_STR_FLAG(port_status, STATUS_ENABLED_CHANGED, "enblchg", "-"),
     39                    UHCI_GET_STR_FLAG(port_status, STATUS_ENABLED, "enabled", "disabled"),
     40                    UHCI_GET_STR_FLAG(port_status, STATUS_CONNECTED_CHANGED, "connchg", "-"),
     41                    UHCI_GET_STR_FLAG(port_status, STATUS_CONNECTED, "hasdev", "nodev"));
    3542
    3643                if (port_status & STATUS_CONNECTED_CHANGED) {
     
    9299
    93100        if (ret != EOK) { /* address assigning went wrong */
    94                 uhci_print_error("Failed(%d) to assign address to the device.\n", ret);
     101                uhci_print_error("Failed to assign address (port %d): %s.\n",
     102                    port->number, str_error(ret));
    95103                uhci_port_set_enabled(port, false);
    96104                usb_address_keeping_release_default(&uhci_instance->address_manager);
  • uspace/drv/uhci/uhci.c

    r44d8853 r4046c1ea  
    219219        return EOK;
    220220}
     221
    221222/*---------------------------------------------------------------------------*/
    222223int uhci_debug_checker(void *arg)
     
    228229                reg = pio_read_16(&instance->registers->usbcmd);
    229230                uhci_print_info("Command register: %X\n", reg);
     231
    230232                reg = pio_read_16(&instance->registers->usbsts);
    231                 uhci_print_info("Status register: %X\n", reg);
     233                uhci_print_info("Status register: %X (%s,%s,%s,%s,%s,%s)\n",
     234                    reg,
     235                    UHCI_GET_STR_FLAG(reg, UHCI_STATUS_HALTED, "halted", "-"),
     236                    UHCI_GET_STR_FLAG(reg, UHCI_STATUS_PROCESS_ERROR, "prerr", "-"),
     237                    UHCI_GET_STR_FLAG(reg, UHCI_STATUS_SYSTEM_ERROR, "syserr", "-"),
     238                    UHCI_GET_STR_FLAG(reg, UHCI_STATUS_RESUME, "res", "-"),
     239                    UHCI_GET_STR_FLAG(reg, UHCI_STATUS_ERROR_INTERRUPT, "errintr", "-"),
     240                    UHCI_GET_STR_FLAG(reg, UHCI_STATUS_INTERRUPT, "intr", "-"));
    232241/*
    233242                uintptr_t frame_list = pio_read_32(&instance->registers->flbaseadd);
  • uspace/drv/uhci/uhci.h

    r44d8853 r4046c1ea  
    5656
    5757        uint16_t usbsts;
     58#define UHCI_STATUS_HALTED (1 << 5)
     59#define UHCI_STATUS_PROCESS_ERROR (1 << 4)
     60#define UHCI_STATUS_SYSTEM_ERROR (1 << 3)
     61#define UHCI_STATUS_RESUME (1 << 2)
     62#define UHCI_STATUS_ERROR_INTERRUPT (1 << 1)
     63#define UHCI_STATUS_INTERRUPT (1 << 0)
     64
    5865        uint16_t usbintr;
    5966        uint16_t frnum;
  • uspace/drv/uhci/uhci_struct/transfer_descriptor.c

    r44d8853 r4046c1ea  
     1#include <stdio.h>
    12#include "transfer_descriptor.h"
     3
     4#define BUFFER_LEN 10
     5
     6static void buffer_to_str(char *str, size_t str_size,
     7    uint8_t *buffer, size_t buffer_size)
     8{
     9        if (buffer_size == 0) {
     10                *str = 0;
     11                return;
     12        }
     13        while (str_size >= 4) {
     14                snprintf(str, 4, " %02X", (int) *buffer);
     15                str += 3;
     16                str_size -= 3;
     17                buffer++;
     18                buffer_size--;
     19                if (buffer_size == 0) {
     20                        break;
     21                }
     22        }
     23}
    224
    325void transfer_descriptor_init(transfer_descriptor_t *instance,
     
    1941        uhci_print_verbose("Creating status field: %x.\n", instance->status);
    2042
     43        uint32_t maxlen_field = (size == 0) ? 0x7FF : ((uint32_t) size - 1);
     44        maxlen_field = (maxlen_field & TD_DEVICE_MAXLEN_MASK)
     45            << TD_DEVICE_MAXLEN_POS;
    2146        instance->device = 0
    22                 | (((size - 1) & TD_DEVICE_MAXLEN_MASK) << TD_DEVICE_MAXLEN_POS)
     47                | (maxlen_field)
    2348                | ((target.address & TD_DEVICE_ADDRESS_MASK) << TD_DEVICE_ADDRESS_POS)
    2449                | ((target.endpoint & TD_DEVICE_ENDPOINT_MASK) << TD_DEVICE_ENDPOINT_POS)
     
    2752        uhci_print_verbose("Creating device field: %x.\n", instance->device);
    2853
     54        char buffer_dump[BUFFER_LEN];
     55        buffer_to_str(buffer_dump, BUFFER_LEN, buffer, size);
     56        uhci_print_verbose("Buffer dump (%zuB): %s.\n", size, buffer_dump);
     57
    2958        if (size) {
    3059                instance->buffer_ptr = (uintptr_t)addr_to_phys(buffer);
     
    3261                uhci_print_verbose("Creating buffer field: %p(%p).\n",
    3362                        buffer, instance->buffer_ptr);
    34 
    35                 if (size >= 8) {
    36                         char * buff = buffer;
    37 
    38                         uhci_print_verbose("Buffer dump(8B): %x %x %x %x %x %x %x %x.\n",
    39                                 buff[0], buff[1], buff[2], buff[3], buff[4], buff[5], buff[6], buff[7]);
    40                 }
    4163        } else {
    4264                instance->buffer_ptr = 0;
    4365        }
     66
    4467
    4568        instance->next_va = NULL;
  • uspace/drv/uhci/utils/malloc32.h

    r44d8853 r4046c1ea  
    5353static inline void * malloc32(size_t size)
    5454/* TODO: this is ugly */
    55         { return memalign(size, 16); }
     55        { return memalign(16, size); }
    5656
    5757static inline void * get_page()
Note: See TracChangeset for help on using the changeset viewer.