Changes in / [df949c5:b3bdb68] in mainline


Ignore:
Location:
uspace
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/iface.c

    rdf949c5 rb3bdb68  
    280280        assert(hc);
    281281        usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
    282         usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
    283             speed, target.address, target.endpoint, size, max_packet_size);
     282        usb_log_debug("Control WRITE %d:%d %zu(%zu).\n",
     283            target.address, target.endpoint, size, max_packet_size);
    284284
    285285        if (setup_size != 8)
     
    319319        usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
    320320
    321         usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
    322             speed, target.address, target.endpoint, size, max_packet_size);
     321        usb_log_debug("Control READ %d:%d %zu(%zu).\n",
     322            target.address, target.endpoint, size, max_packet_size);
    323323        batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
    324324            max_packet_size, speed, data, size, setup_data, setup_size, callback,
  • uspace/drv/uhci-hcd/uhci.c

    rdf949c5 rb3bdb68  
    356356
    357357        transfer_list_t *list =
    358             instance->transfers[batch->speed][batch->transfer_type];
     358            instance->transfers[low_speed][batch->transfer_type];
    359359        assert(list);
    360360        transfer_list_add_batch(list, batch);
  • uspace/drv/uhci-rhd/Makefile

    rdf949c5 rb3bdb68  
    3535        main.c \
    3636        port.c \
     37        port_status.c \
    3738        root_hub.c
    3839
  • uspace/drv/uhci-rhd/port.c

    rdf949c5 rb3bdb68  
    6767{
    6868        assert(port);
    69         asprintf(&port->id_string, "Port (%p - %d)", port, number);
    70         if (port->id_string == NULL) {
    71                 return ENOMEM;
    72         }
    7369
    7470        port->address = address;
     
    120116        assert(instance);
    121117
     118        /* Iteration count, for debug purposes only */
     119        unsigned count = 0;
     120
    122121        while (1) {
    123122                async_usleep(instance->wait_period_usec);
    124123
    125124                /* read register value */
    126                 port_status_t port_status = uhci_port_read_status(instance);
    127 
    128                 print_port_status(instance->id_string, port_status);
     125                port_status_t port_status = port_status_read(instance->address);
     126
     127                /* debug print mutex */
     128                static fibril_mutex_t dbg_mtx =
     129                    FIBRIL_MUTEX_INITIALIZER(dbg_mtx);
     130                fibril_mutex_lock(&dbg_mtx);
     131                usb_log_debug2("Port(%p - %d): Status: %#04x. === %u\n",
     132                  instance->address, instance->number, port_status, count++);
     133//              print_port_status(port_status);
     134                fibril_mutex_unlock(&dbg_mtx);
    129135
    130136                if ((port_status & STATUS_CONNECTED_CHANGED) == 0)
    131137                        continue;
    132138
    133                 usb_log_debug("%s: Connected change detected: %x.\n",
    134                     instance->id_string, port_status);
     139                usb_log_debug("Port(%p - %d): Connected change detected: %x.\n",
     140                    instance->address, instance->number, port_status);
    135141
    136142                int rc =
    137143                    usb_hc_connection_open(&instance->hc_connection);
    138144                if (rc != EOK) {
    139                         usb_log_error("%s: Failed to connect to HC.",
    140                             instance->id_string);
     145                        usb_log_error("Port(%p - %d): Failed to connect to HC.",
     146                            instance->address, instance->number);
    141147                        continue;
    142148                }
     
    144150                /* Remove any old device */
    145151                if (instance->attached_device) {
    146                         usb_log_debug2("%s: Removing device.\n",
    147                             instance->id_string);
     152                        usb_log_debug2("Port(%p - %d): Removing device.\n",
     153                            instance->address, instance->number);
    148154                        uhci_port_remove_device(instance);
    149155                }
     
    157163                } else {
    158164                        /* Write one to WC bits, to ack changes */
    159                         uhci_port_write_status(instance, port_status);
    160                         usb_log_debug("%s: Change status ACK.\n",
    161                             instance->id_string);
     165                        port_status_write(instance->address, port_status);
     166                        usb_log_debug("Port(%p - %d): Change status ACK.\n",
     167                            instance->address, instance->number);
    162168                }
    163169
    164170                rc = usb_hc_connection_close(&instance->hc_connection);
    165171                if (rc != EOK) {
    166                         usb_log_error("%s: Failed to disconnect.",
    167                             instance->id_string);
     172                        usb_log_error("Port(%p - %d): Failed to disconnect.",
     173                            instance->address, instance->number);
    168174                }
    169175        }
     
    181187        uhci_port_t *port = (uhci_port_t *) arg;
    182188
    183         usb_log_debug2("%s: new_device_enable_port.\n",
    184             port->id_string);
     189        usb_log_debug2("Port(%p - %d): new_device_enable_port.\n",
     190            port->address, port->number);
    185191
    186192        /*
     
    195201         */
    196202        {
    197                 usb_log_debug("%s: Reset Signal start.\n",
    198                     port->id_string);
    199                 port_status_t port_status = uhci_port_read_status(port);
     203                usb_log_debug("Port(%p - %d): Reset Signal start.\n",
     204                    port->address, port->number);
     205                port_status_t port_status =
     206                        port_status_read(port->address);
    200207                port_status |= STATUS_IN_RESET;
    201                 uhci_port_write_status(port, port_status);
     208                port_status_write(port->address, port_status);
    202209                async_usleep(10000);
    203                 port_status = uhci_port_read_status(port);
     210                port_status = port_status_read(port->address);
    204211                port_status &= ~STATUS_IN_RESET;
    205                 uhci_port_write_status(port, port_status);
    206                 usb_log_debug("%s: Reset Signal stop.\n",
    207                     port->id_string);
     212                port_status_write(port->address, port_status);
     213                usb_log_debug("Port(%p - %d): Reset Signal stop.\n",
     214                    port->address, port->number);
    208215        }
    209216
     
    226233        assert(usb_hc_connection_is_opened(&port->hc_connection));
    227234
    228         usb_log_info("%s: Detected new device.\n",
    229             port->id_string);
     235        usb_log_info("Port(%p-%d): Detected new device.\n",
     236            port->address, port->number);
    230237
    231238        usb_address_t dev_addr;
     
    235242
    236243        if (rc != EOK) {
    237                 usb_log_error("%s: Failed(%d) to add device: %s.\n",
    238                     port->id_string, rc, str_error(rc));
     244                usb_log_error("Port(%p-%d): Failed(%d) to add device: %s.\n",
     245                    port->address, port->number, rc, str_error(rc));
    239246                uhci_port_set_enabled(port, false);
    240247                return rc;
    241248        }
    242249
    243         usb_log_info("%s: New device has address %d (handle %zu).\n",
    244             port->id_string, dev_addr, port->attached_device);
     250        usb_log_info("Port(%p-%d): New device has address %d (handle %zu).\n",
     251            port->address, port->number, dev_addr, port->attached_device);
    245252
    246253        return EOK;
     
    256263int uhci_port_remove_device(uhci_port_t *port)
    257264{
    258         usb_log_error("%s: Don't know how to remove device %d.\n",
    259             port->id_string, (unsigned int)port->attached_device);
     265        usb_log_error("Port(%p-%d): Don't know how to remove device %#x.\n",
     266            port->address, port->number, (unsigned int)port->attached_device);
    260267        return EOK;
    261268}
     
    271278
    272279        /* Read register value */
    273         port_status_t port_status = uhci_port_read_status(port);
     280        port_status_t port_status = port_status_read(port->address);
    274281
    275282        /* Set enabled bit */
     
    281288
    282289        /* Write new value. */
    283         uhci_port_write_status(port, port_status);
    284 
    285         usb_log_info("%s: %sabled port.\n",
    286                 port->id_string, enabled ? "En" : "Dis");
     290        port_status_write(port->address, port_status);
     291
     292        usb_log_info("Port(%p-%d): %sabled port.\n",
     293                port->address, port->number, enabled ? "En" : "Dis");
    287294        return EOK;
    288295}
  • uspace/drv/uhci-rhd/port.h

    rdf949c5 rb3bdb68  
    4444typedef struct uhci_port
    4545{
    46         char *id_string;
    4746        port_status_t *address;
    4847        unsigned number;
     
    5958
    6059void uhci_port_fini(uhci_port_t *port);
    61 
    62 static inline port_status_t uhci_port_read_status(uhci_port_t *port)
    63 {
    64         assert(port);
    65         return pio_read_16(port->address);
    66 }
    67 
    68 static inline void uhci_port_write_status(
    69     uhci_port_t *port, port_status_t value)
    70 {
    71         assert(port);
    72         pio_write_16(port->address, value);
    73 }
    7460#endif
    7561/**
  • uspace/drv/uhci-rhd/port_status.h

    rdf949c5 rb3bdb68  
    5454#define STATUS_SUSPEND   (1 << 12)
    5555
     56static inline port_status_t port_status_read(port_status_t * address)
     57        { return pio_read_16(address); }
    5658
    57 static inline void print_port_status(
    58     const char* prefix, const port_status_t value)
    59 {
    60         usb_log_debug2("%s Port status:%s%s%s%s%s%s%s%s.\n",
    61             prefix,
    62             (value & STATUS_SUSPEND) ? " SUSPENDED," : "",
    63             (value & STATUS_IN_RESET) ? " IN RESET," : "",
    64             (value & STATUS_LOW_SPEED) ? " LOWSPEED," : "",
    65             (value & STATUS_ENABLED_CHANGED) ? " ENABLED-CHANGE," : "",
    66             (value & STATUS_ENABLED) ? " ENABLED," : "",
    67             (value & STATUS_CONNECTED_CHANGED) ? " CONNECTED-CHANGE," : "",
    68             (value & STATUS_CONNECTED) ? " CONNECTED," : "",
    69             (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERROR: NO ALWAYS ONE"
    70         );
    71 }
     59static inline void port_status_write(
     60  port_status_t *address, port_status_t value)
     61        { pio_write_16(address, value); }
     62
     63void print_port_status(const port_status_t status);
    7264#endif
    7365/**
  • uspace/lib/usb/src/pipesinit.c

    rdf949c5 rb3bdb68  
    3737#include <usb/pipes.h>
    3838#include <usb/dp.h>
    39 #include <usb/request.h>
    4039#include <errno.h>
    4140#include <assert.h>
     
    371370        int rc = usb_endpoint_pipe_initialize(pipe, connection,
    372371            0, USB_TRANSFER_CONTROL, 8, USB_DIRECTION_BOTH);
    373         if (rc != EOK) {
    374                 return rc;
    375         }
    376         rc = usb_endpoint_pipe_start_session(pipe);
    377         if (rc != EOK) {
    378                 return rc;
    379         }
    380 
    381         uint8_t first[8];
    382         size_t size = 0;
    383         rc = usb_control_request_get(pipe, USB_REQUEST_TYPE_STANDARD,
    384             USB_REQUEST_RECIPIENT_DEVICE, USB_DEVREQ_GET_DESCRIPTOR, 1 << 8,
    385                         0, first, 8, &size);
    386         usb_endpoint_pipe_end_session(pipe);
    387         if (rc != EOK || size  != 8) {
    388                 return rc;
    389         }
    390 
    391         pipe->max_packet_size = first[7];
     372
    392373        return rc;
    393374}
Note: See TracChangeset for help on using the changeset viewer.