Changeset 6ce42e85 in mainline


Ignore:
Timestamp:
2011-04-06T18:13:05Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
391d55b
Parents:
90b9ab5
Message:

Use new usb_endpoint_manager instead of bandwidth_t

Bandwidth checks turned off for now.

Location:
uspace/drv/uhci-hcd
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/Makefile

    r90b9ab5 r6ce42e85  
    3737        transfer_list.c \
    3838        uhci.c \
     39        endpoint.c \
    3940        hc.c \
    4041        root_hub.c \
  • uspace/drv/uhci-hcd/hc.c

    r90b9ab5 r6ce42e85  
    239239        usb_log_debug("Initialized device manager.\n");
    240240
    241         ret = bandwidth_init(&instance->bandwidth, BANDWIDTH_AVAILABLE_USB11,
    242             bandwidth_count_usb11);
     241        ret =
     242            usb_endpoint_manager_init(&instance->ep_manager,
     243                BANDWIDTH_AVAILABLE_USB11);
    243244        assert(ret == EOK);
    244245
     
    335336        }
    336337        /* Check available bandwidth */
     338/*
    337339        if (batch->transfer_type == USB_TRANSFER_INTERRUPT ||
    338340            batch->transfer_type == USB_TRANSFER_ISOCHRONOUS) {
    339                 size_t bw = bandwidth_count_usb11(batch->speed,
     341                const size_t bw = bandwidth_count_usb11(batch->speed,
    340342                    batch->transfer_type, batch->buffer_size,
    341343                    batch->max_packet_size);
     344
    342345                int ret =
    343346                    bandwidth_use(&instance->bandwidth, batch->target.address,
     
    349352                }
    350353        }
     354*/
    351355
    352356        transfer_list_t *list =
     
    402406                        case USB_TRANSFER_INTERRUPT:
    403407                        case USB_TRANSFER_ISOCHRONOUS: {
     408/*
    404409                                int ret = bandwidth_free(&instance->bandwidth,
    405410                                    batch->target.address,
     
    410415                                            "reserved bw: %s.\n", ret,
    411416                                            str_error(ret));
     417*/
    412418                                }
    413419                        default:
  • uspace/drv/uhci-hcd/hc.h

    r90b9ab5 r6ce42e85  
    4343#include <usbhc_iface.h>
    4444#include <usb/host/device_keeper.h>
    45 #include <usb/host/bandwidth.h>
     45#include <usb/host/usb_endpoint_manager.h>
    4646
    4747#include "batch.h"
     
    8585typedef struct hc {
    8686        usb_device_keeper_t manager;
    87         bandwidth_t bandwidth;
     87        usb_endpoint_manager_t ep_manager;
    8888
    8989        regs_t *registers;
  • uspace/drv/uhci-hcd/iface.c

    r90b9ab5 r6ce42e85  
    3737#include <usb/debug.h>
    3838
     39#include "endpoint.h"
    3940#include "iface.h"
    4041#include "hc.h"
     
    137138        const usb_speed_t speed =
    138139            usb_device_keeper_get_speed(&hc->manager, address);
    139         size_t size = max_packet_size;
     140        const size_t size = max_packet_size;
     141
     142        endpoint_t *ep = malloc(sizeof(endpoint_t));
     143        if (ep == NULL)
     144                return ENOMEM;
     145        endpoint_init(ep, transfer_type, speed, max_packet_size);
    140146
    141147        usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n",
    142148            address, endpoint, usb_str_transfer_type(transfer_type),
    143149            usb_str_speed(speed), direction, size, max_packet_size, interval);
    144         return bandwidth_reserve(&hc->bandwidth, address, endpoint, direction,
    145             speed, transfer_type, max_packet_size, size, interval);
     150
     151        const size_t bw = bandwidth_count_usb11(speed, transfer_type, size,
     152            max_packet_size);
     153        int ret = usb_endpoint_manager_register_ep(&hc->ep_manager,
     154            address, endpoint, direction, ep, endpoint_destroy, bw);
     155        if (ret != EOK) {
     156                endpoint_destroy(ep);
     157        }
     158
     159        return ret;
    146160}
    147161/*----------------------------------------------------------------------------*/
     
    154168        usb_log_debug("Unregister endpoint %d:%d %d.\n",
    155169            address, endpoint, direction);
    156         return bandwidth_release(&hc->bandwidth, address, endpoint, direction);
     170        return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address,
     171            endpoint, direction);
    157172}
    158173/*----------------------------------------------------------------------------*/
     
    175190        hc_t *hc = fun_to_hc(fun);
    176191        assert(hc);
    177         usb_speed_t speed =
    178             usb_device_keeper_get_speed(&hc->manager, target.address);
    179192
    180193        usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
    181194            target.address, target.endpoint, size, max_packet_size);
    182195
    183         usb_transfer_batch_t *batch =
    184             batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size,
    185                 speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager);
     196        endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager,
     197            target.address, target.endpoint, USB_DIRECTION_OUT, NULL);
     198        if (ep == NULL) {
     199                usb_log_error("Endpoint(%d:%d) not registered for INT OUT.\n",
     200                        target.address, target.endpoint);
     201                return ENOENT;
     202        }
     203        assert(ep->speed ==
     204            usb_device_keeper_get_speed(&hc->manager, target.address));
     205        assert(ep->max_packet_size == max_packet_size);
     206        assert(ep->transfer_type == USB_TRANSFER_INTERRUPT);
     207
     208        usb_transfer_batch_t *batch =
     209            batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
     210                ep->speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager);
    186211        if (!batch)
    187212                return ENOMEM;
     
    212237        hc_t *hc = fun_to_hc(fun);
    213238        assert(hc);
    214         usb_speed_t speed =
    215             usb_device_keeper_get_speed(&hc->manager, target.address);
     239
    216240        usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
    217241            target.address, target.endpoint, size, max_packet_size);
    218242
    219         usb_transfer_batch_t *batch =
    220             batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size,
    221                 speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager);
     243        endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager,
     244            target.address, target.endpoint, USB_DIRECTION_IN, NULL);
     245        if (ep == NULL) {
     246                usb_log_error("Endpoint(%d:%d) not registered for INT IN.\n",
     247                        target.address, target.endpoint);
     248                return ENOENT;
     249        }
     250        assert(ep->speed ==
     251            usb_device_keeper_get_speed(&hc->manager, target.address));
     252        assert(ep->max_packet_size == max_packet_size);
     253        assert(ep->transfer_type == USB_TRANSFER_INTERRUPT);
     254
     255        usb_transfer_batch_t *batch =
     256            batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
     257                ep->speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager);
    222258        if (!batch)
    223259                return ENOMEM;
     
    248284        hc_t *hc = fun_to_hc(fun);
    249285        assert(hc);
    250         usb_speed_t speed =
    251             usb_device_keeper_get_speed(&hc->manager, target.address);
    252286
    253287        usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
    254288            target.address, target.endpoint, size, max_packet_size);
    255289
    256         usb_transfer_batch_t *batch =
    257             batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,
    258                 data, size, NULL, 0, NULL, callback, arg, &hc->manager);
     290        endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager,
     291            target.address, target.endpoint, USB_DIRECTION_OUT, NULL);
     292        if (ep == NULL) {
     293                usb_log_error("Endpoint(%d:%d) not registered for BULK OUT.\n",
     294                        target.address, target.endpoint);
     295                return ENOENT;
     296        }
     297        assert(ep->speed ==
     298            usb_device_keeper_get_speed(&hc->manager, target.address));
     299        assert(ep->max_packet_size == max_packet_size);
     300        assert(ep->transfer_type == USB_TRANSFER_BULK);
     301
     302
     303        usb_transfer_batch_t *batch =
     304            batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
     305                ep->speed, data, size, NULL, 0, NULL, callback, arg,
     306                &hc->manager);
    259307        if (!batch)
    260308                return ENOMEM;
     
    285333        hc_t *hc = fun_to_hc(fun);
    286334        assert(hc);
    287         usb_speed_t speed =
    288             usb_device_keeper_get_speed(&hc->manager, target.address);
    289335        usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
    290336            target.address, target.endpoint, size, max_packet_size);
    291337
    292         usb_transfer_batch_t *batch =
    293             batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed,
     338        endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager,
     339            target.address, target.endpoint, USB_DIRECTION_IN, NULL);
     340        if (ep == NULL) {
     341                usb_log_error("Endpoint(%d:%d) not registered for BULK IN.\n",
     342                        target.address, target.endpoint);
     343                return ENOENT;
     344        }
     345        assert(ep->speed ==
     346            usb_device_keeper_get_speed(&hc->manager, target.address));
     347        assert(ep->max_packet_size == max_packet_size);
     348        assert(ep->transfer_type == USB_TRANSFER_BULK);
     349
     350        usb_transfer_batch_t *batch =
     351            batch_get(fun, target, ep->transfer_type, ep->max_packet_size, ep->speed,
    294352                data, size, NULL, 0, callback, NULL, arg, &hc->manager);
    295353        if (!batch)
     
    328386        usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
    329387            speed, target.address, target.endpoint, size, max_packet_size);
     388        endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager,
     389            target.address, target.endpoint, USB_DIRECTION_BOTH, NULL);
     390        if (ep == NULL) {
     391                usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n",
     392                        target.address, target.endpoint);
     393        }
    330394
    331395        if (setup_size != 8)
     
    373437        usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
    374438            speed, target.address, target.endpoint, size, max_packet_size);
     439        endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager,
     440            target.address, target.endpoint, USB_DIRECTION_BOTH, NULL);
     441        if (ep == NULL) {
     442                usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n",
     443                        target.address, target.endpoint);
     444        }
    375445        usb_transfer_batch_t *batch =
    376446            batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed,
Note: See TracChangeset for help on using the changeset viewer.