Changes in / [fcbcaae9:c9256c5] in mainline


Ignore:
Location:
uspace/drv
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/hc.c

    rfcbcaae9 rc9256c5  
    565565        bzero(&instance->rh, sizeof(instance->rh));
    566566        /* Init queues */
    567         const int ret = hc_init_transfer_lists(instance);
    568         if (ret != EOK) {
    569                 return ret;
    570         }
     567        hc_init_transfer_lists(instance);
    571568
    572569        /*Init HCCA */
  • uspace/drv/uhci-hcd/batch.h

    rfcbcaae9 rc9256c5  
    3535#define DRV_UHCI_BATCH_H
    3636
     37#include <usbhc_iface.h>
     38#include <usb/usb.h>
     39#include <usb/host/device_keeper.h>
     40#include <usb/host/endpoint.h>
    3741#include <usb/host/batch.h>
    3842
  • uspace/drv/uhci-hcd/hc.c

    rfcbcaae9 rc9256c5  
    3939#include <usb/debug.h>
    4040#include <usb/usb.h>
     41#include <usb/ddfiface.h>
     42#include <usb_iface.h>
    4143
    4244#include "hc.h"
     
    8385        /* allow access to hc control registers */
    8486        regs_t *io;
    85         ret = pio_enable(regs, reg_size, (void **)&io);
     87        ret = pio_enable(regs, reg_size, (void**)&io);
    8688        CHECK_RET_RETURN(ret,
    8789            "Failed(%d) to gain access to registers at %p: %s.\n",
     
    141143        }
    142144
    143         const uint16_t status = pio_read_16(&registers->usbcmd);
     145        uint16_t status = pio_read_16(&registers->usbcmd);
    144146        if (status != 0)
    145147                usb_log_warning("Previous command value: %x.\n", status);
     
    210212        /* Init USB frame list page*/
    211213        instance->frame_list = get_page();
    212         ret = instance->frame_list ? EOK : ENOMEM;
     214        ret = instance ? EOK : ENOMEM;
    213215        CHECK_RET_RETURN(ret, "Failed to get frame list page.\n");
    214216        usb_log_debug("Initialized frame list at %p.\n", instance->frame_list);
     
    275277                &instance->transfers_control_slow);
    276278
    277         /*FSBR, This feature is not needed (adds no benefit) and is supposedly
    278          * buggy on certain hw, enable at your own risk. */
     279        /*FSBR*/
    279280#ifdef FSBR
    280281        transfer_list_set_next(&instance->transfers_bulk_full,
     
    427428                }
    428429
    429                 const uintptr_t frame_list =
     430                uintptr_t frame_list =
    430431                    pio_read_32(&instance->registers->flbaseadd) & ~0xfff;
    431432                if (frame_list != addr_to_phys(instance->frame_list)) {
  • uspace/drv/uhci-hcd/hc.h

    rfcbcaae9 rc9256c5  
    3737
    3838#include <fibril.h>
     39#include <fibril_synch.h>
     40#include <adt/list.h>
    3941#include <ddi.h>
    4042
     43#include <usbhc_iface.h>
    4144#include <usb/host/device_keeper.h>
    4245#include <usb/host/usb_endpoint_manager.h>
    43 #include <usb/host/batch.h>
    4446
     47#include "batch.h"
    4548#include "transfer_list.h"
    4649
     
    151154 */
    152155static inline hc_t * fun_to_hc(ddf_fun_t *fun)
    153 {
    154         assert(fun);
    155         return fun->driver_data;
    156 }
     156        { return (hc_t*)fun->driver_data; }
    157157#endif
    158158/**
  • uspace/drv/uhci-hcd/iface.c

    rfcbcaae9 rc9256c5  
    3939
    4040#include "iface.h"
    41 #include "batch.h"
    4241#include "hc.h"
    4342
     
    123122        return EOK;
    124123}
    125 /*----------------------------------------------------------------------------*/
     124
    126125/** Find device handle by address interface function.
    127126 *
     
    137136        hc_t *hc = fun_to_hc(fun);
    138137        assert(hc);
    139         const bool found =
     138        bool found =
    140139            usb_device_keeper_find_by_address(&hc->manager, address, handle);
    141140        return found ? EOK : ENOENT;
    142141}
     142
    143143/*----------------------------------------------------------------------------*/
    144144/** Release address interface function
     
    164164    size_t max_packet_size, unsigned int interval)
    165165{
    166         assert(fun);
    167166        hc_t *hc = fun_to_hc(fun);
    168167        assert(hc);
     
    184183    usb_endpoint_t endpoint, usb_direction_t direction)
    185184{
    186         assert(fun);
    187185        hc_t *hc = fun_to_hc(fun);
    188186        assert(hc);
     
    213211        if (ret != EOK)
    214212                return ret;
    215         assert(batch);
    216         assert(hc);
    217213        batch_interrupt_out(batch);
    218214        ret = hc_schedule(hc, batch);
     
    243239        if (ret != EOK)
    244240                return ret;
    245         assert(batch);
    246         assert(hc);
    247241        batch_interrupt_in(batch);
    248242        ret = hc_schedule(hc, batch);
     
    273267        if (ret != EOK)
    274268                return ret;
    275         assert(batch);
    276         assert(hc);
    277269        batch_bulk_out(batch);
    278270        ret = hc_schedule(hc, batch);
     
    303295        if (ret != EOK)
    304296                return ret;
    305         assert(batch);
    306         assert(hc);
    307297        batch_bulk_in(batch);
    308298        ret = hc_schedule(hc, batch);
     
    337327        if (ret != EOK)
    338328                return ret;
    339         assert(batch);
    340         assert(hc);
    341329        usb_endpoint_manager_reset_if_need(&hc->ep_manager, target, setup_data);
    342330        batch_control_write(batch);
     
    372360        if (ret != EOK)
    373361                return ret;
    374         assert(batch);
    375         assert(hc);
    376362        batch_control_read(batch);
    377363        ret = hc_schedule(hc, batch);
  • uspace/drv/uhci-hcd/pci.c

    rfcbcaae9 rc9256c5  
    5252 * @return Error code.
    5353 */
    54 int pci_get_my_registers(const ddf_dev_t *dev,
     54int pci_get_my_registers(ddf_dev_t *dev,
    5555    uintptr_t *io_reg_address, size_t *io_reg_size, int *irq_no)
    5656{
    57         assert(dev);
    58         assert(io_reg_address);
    59         assert(io_reg_size);
    60         assert(irq_no);
     57        assert(dev != NULL);
    6158
    6259        int parent_phone =
     
    6966        int rc = hw_res_get_resource_list(parent_phone, &hw_resources);
    7067        if (rc != EOK) {
    71                 async_hangup(parent_phone);
    72                 return rc;
     68                goto leave;
    7369        }
    7470
     
    8278        size_t i;
    8379        for (i = 0; i < hw_resources.count; i++) {
    84                 const hw_resource_t *res = &hw_resources.resources[i];
     80                hw_resource_t *res = &hw_resources.resources[i];
    8581                switch (res->type)
    8682                {
     
    10399                }
    104100        }
    105         async_hangup(parent_phone);
    106101
    107         if (!io_found || !irq_found)
    108                 return ENOENT;
     102        if (!io_found || !irq_found) {
     103                rc = ENOENT;
     104                goto leave;
     105        }
    109106
    110107        *io_reg_address = io_address;
     
    112109        *irq_no = irq;
    113110
    114         return EOK;
     111        rc = EOK;
     112leave:
     113        async_hangup(parent_phone);
     114        return rc;
    115115}
    116116/*----------------------------------------------------------------------------*/
     
    120120 * @return Error code.
    121121 */
    122 int pci_enable_interrupts(const ddf_dev_t *device)
     122int pci_enable_interrupts(ddf_dev_t *device)
    123123{
    124         const int parent_phone =
    125             devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING);
    126         if (parent_phone < 0) {
    127                 return parent_phone;
    128         }
    129         const bool enabled = hw_res_enable_interrupt(parent_phone);
     124        int parent_phone = devman_parent_device_connect(device->handle,
     125            IPC_FLAG_BLOCKING);
     126        bool enabled = hw_res_enable_interrupt(parent_phone);
    130127        async_hangup(parent_phone);
    131128        return enabled ? EOK : EIO;
     
    137134 * @return Error code.
    138135 */
    139 int pci_disable_legacy(const ddf_dev_t *device)
     136int pci_disable_legacy(ddf_dev_t *device)
    140137{
    141138        assert(device);
    142         const int parent_phone =
     139        int parent_phone =
    143140            devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING);
    144141        if (parent_phone < 0) {
     
    148145        /* See UHCI design guide for these values p.45,
    149146         * write all WC bits in USB legacy register */
    150         const sysarg_t address = 0xc0;
    151         const sysarg_t value = 0xaf00;
     147        sysarg_t address = 0xc0;
     148        sysarg_t value = 0xaf00;
    152149
    153         const int rc = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE),
     150        int rc = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE),
    154151            IPC_M_CONFIG_SPACE_WRITE_16, address, value);
    155152        async_hangup(parent_phone);
  • uspace/drv/uhci-hcd/pci.h

    rfcbcaae9 rc9256c5  
    3838#include <ddf/driver.h>
    3939
    40 int pci_get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
    41 int pci_enable_interrupts(const ddf_dev_t *);
    42 int pci_disable_legacy(const ddf_dev_t *);
     40int pci_get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);
     41int pci_enable_interrupts(ddf_dev_t *);
     42int pci_disable_legacy(ddf_dev_t *);
    4343
    4444#endif
  • uspace/drv/uhci-hcd/root_hub.c

    rfcbcaae9 rc9256c5  
    6060                return ret;
    6161        }
    62         assert(match_str);
    6362
    6463        ret = ddf_fun_add_match_id(fun, match_str, 100);
  • uspace/drv/uhci-hcd/root_hub.h

    rfcbcaae9 rc9256c5  
    4343        /** List of resources available to the root hub. */
    4444        hw_resource_list_t resource_list;
    45         /** The only resource in the RH resource list */
     45        /** The only resource in the above list */
    4646        hw_resource_t io_regs;
    4747} rh_t;
  • uspace/drv/uhci-hcd/transfer_list.c

    rfcbcaae9 rc9256c5  
    3636#include <arch/barrier.h>
    3737
    38 
    3938#include "transfer_list.h"
    40 #include "batch.h"
    4139
    4240static void transfer_list_remove_batch(
     
    6058                return ENOMEM;
    6159        }
    62         const uint32_t queue_head_pa = addr_to_phys(instance->queue_head);
     60        uint32_t queue_head_pa = addr_to_phys(instance->queue_head);
    6361        usb_log_debug2("Transfer list %s setup with QH: %p (%#" PRIx32" ).\n",
    6462            name, instance->queue_head, queue_head_pa);
     
    9290{
    9391        assert(instance);
    94         assert(instance->queue_head);
    9592        assert(next);
     93        if (!instance->queue_head)
     94                return;
    9695        /* Set queue_head.next to point to the follower */
    9796        qh_set_next_qh(instance->queue_head, next->queue_head);
     
    138137        write_barrier();
    139138
    140         /* Add to the driver's list */
     139        /* Add to the driver list */
    141140        list_append(&batch->link, &instance->batch_list);
    142141
     
    161160        link_t *current = instance->batch_list.next;
    162161        while (current != &instance->batch_list) {
    163                 link_t * const next = current->next;
     162                link_t *next = current->next;
    164163                usb_transfer_batch_t *batch =
    165164                    usb_transfer_batch_from_link(current);
     
    183182        fibril_mutex_lock(&instance->guard);
    184183        while (!list_empty(&instance->batch_list)) {
    185                 link_t * const current = instance->batch_list.next;
     184                link_t *current = instance->batch_list.next;
    186185                usb_transfer_batch_t *batch =
    187186                    usb_transfer_batch_from_link(current);
  • uspace/drv/uhci-hcd/transfer_list.h

    rfcbcaae9 rc9256c5  
    3636
    3737#include <fibril_synch.h>
    38 #include <usb/host/batch.h>
    3938
     39#include "batch.h"
    4040#include "hw_struct/queue_head.h"
    4141
  • uspace/drv/uhci-hcd/uhci.c

    rfcbcaae9 rc9256c5  
    7777{
    7878        assert(dev);
    79         uhci_t *uhci = dev->driver_data;
    80         assert(uhci);
    81         hc_t *hc = &uhci->hc;
     79        hc_t *hc = &((uhci_t*)dev->driver_data)->hc;
    8280        uint16_t status = IPC_GET_ARG1(*call);
    8381        assert(hc);
     
    146144{
    147145        assert(fun);
    148         rh_t *rh = fun->driver_data;
    149         assert(rh);
    150         return &rh->resource_list;
     146        return &((rh_t*)fun->driver_data)->resource_list;
    151147}
    152148/*----------------------------------------------------------------------------*/
  • uspace/drv/uhci-hcd/uhci.h

    rfcbcaae9 rc9256c5  
    3535#ifndef DRV_UHCI_UHCI_H
    3636#define DRV_UHCI_UHCI_H
     37#include <ddi.h>
    3738#include <ddf/driver.h>
    3839
  • uspace/drv/uhci-hcd/utils/malloc32.h

    rfcbcaae9 rc9256c5  
    5959        uintptr_t result;
    6060        const int ret = as_get_physical_mapping(addr, &result);
     61        assert(ret == EOK);
     62
    6163        if (ret != EOK)
    6264                return 0;
     
    9698{
    9799        void *free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE);
     100        assert(free_address); /* TODO: remove this assert */
    98101        if (free_address == 0)
    99102                return NULL;
  • uspace/drv/uhci-rhd/main.c

    rfcbcaae9 rc9256c5  
    3737#include <errno.h>
    3838#include <str_error.h>
    39 
    4039#include <usb_iface.h>
    4140#include <usb/ddfiface.h>
     
    4645#define NAME "uhci-rhd"
    4746
    48 static int hc_get_my_registers(const ddf_dev_t *dev,
     47static int hc_get_my_registers(ddf_dev_t *dev,
    4948    uintptr_t *io_reg_address, size_t *io_reg_size);
    5049/*----------------------------------------------------------------------------*/
     
    131130 */
    132131int hc_get_my_registers(
    133     const ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size)
     132    ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size)
    134133{
    135         assert(dev);
     134        assert(dev != NULL);
    136135
    137         const int parent_phone = devman_parent_device_connect(dev->handle,
     136        int parent_phone = devman_parent_device_connect(dev->handle,
    138137            IPC_FLAG_BLOCKING);
    139138        if (parent_phone < 0) {
     
    142141
    143142        hw_resource_list_t hw_resources;
    144         const int ret = hw_res_get_resource_list(parent_phone, &hw_resources);
     143        int ret = hw_res_get_resource_list(parent_phone, &hw_resources);
    145144        if (ret != EOK) {
    146145                async_hangup(parent_phone);
  • uspace/drv/uhci-rhd/port.c

    rfcbcaae9 rc9256c5  
    3636#include <errno.h>
    3737#include <str_error.h>
     38#include <time.h>
    3839#include <async.h>
    3940
     
    8182 * @param[in] number Port number.
    8283 * @param[in] usec Polling interval.
    83  * @param[in] rh Pointer to ddf instance of the root hub driver.
     84 * @param[in] rh Pointer to ddf instance fo the root hub driver.
    8485 * @return Error code.
    8586 *
     
    9091{
    9192        assert(port);
    92         char *id_string;
    93         asprintf(&id_string, "Port (%p - %u)", port, number);
    94         if (id_string == NULL) {
     93        asprintf(&port->id_string, "Port (%p - %u)", port, number);
     94        if (port->id_string == NULL) {
    9595                return ENOMEM;
    9696        }
    9797
    98         port->id_string = id_string;
    9998        port->address = address;
    10099        port->number = number;
     
    106105            usb_hc_connection_initialize_from_device(&port->hc_connection, rh);
    107106        if (ret != EOK) {
    108                 usb_log_error("%s: failed to initialize connection to HC.",
    109                     port->id_string);
    110                 free(id_string);
     107                usb_log_error("Failed to initialize connection to HC.");
    111108                return ret;
    112109        }
     
    116113                usb_log_error("%s: failed to create polling fibril.",
    117114                    port->id_string);
    118                 free(id_string);
    119115                return ENOMEM;
    120116        }
     
    136132        assert(port);
    137133        free(port->id_string);
    138         // TODO: Kill fibril here
     134        /* TODO: Kill fibril here */
    139135        return;
    140136}
     
    154150
    155151                /* Read register value */
    156                 const port_status_t port_status =
    157                     uhci_port_read_status(instance);
     152                port_status_t port_status = uhci_port_read_status(instance);
    158153
    159154                /* Print the value if it's interesting */
     
    166161                usb_log_debug("%s: Connected change detected: %x.\n",
    167162                    instance->id_string, port_status);
     163
     164                int rc =
     165                    usb_hc_connection_open(&instance->hc_connection);
     166                if (rc != EOK) {
     167                        usb_log_error("%s: Failed to connect to HC.",
     168                            instance->id_string);
     169                        continue;
     170                }
    168171
    169172                /* Remove any old device */
     
    172175                            instance->id_string);
    173176                        uhci_port_remove_device(instance);
    174                 }
    175 
    176                 int ret =
    177                     usb_hc_connection_open(&instance->hc_connection);
    178                 if (ret != EOK) {
    179                         usb_log_error("%s: Failed to connect to HC.",
    180                             instance->id_string);
    181                         continue;
    182177                }
    183178
     
    195190                }
    196191
    197                 ret = usb_hc_connection_close(&instance->hc_connection);
    198                 if (ret != EOK) {
     192                rc = usb_hc_connection_close(&instance->hc_connection);
     193                if (rc != EOK) {
    199194                        usb_log_error("%s: Failed to disconnect.",
    200195                            instance->id_string);
     
    214209int uhci_port_reset_enable(int portno, void *arg)
    215210{
    216         uhci_port_t *port = arg;
    217         assert(port);
     211        uhci_port_t *port = (uhci_port_t *) arg;
    218212
    219213        usb_log_debug2("%s: new_device_enable_port.\n", port->id_string);
     
    289283        usb_log_error("%s: Don't know how to remove device %" PRIun ".\n",
    290284            port->id_string, port->attached_device);
    291         port->attached_device = 0;
    292285        return ENOTSUP;
    293286}
  • uspace/drv/uhci-rhd/port.h

    rfcbcaae9 rc9256c5  
    5757typedef struct uhci_port
    5858{
    59         const char *id_string;
     59        char *id_string;
    6060        port_status_t *address;
    6161        unsigned number;
Note: See TracChangeset for help on using the changeset viewer.