Changeset 1a93bb0 in mainline


Ignore:
Timestamp:
2011-02-25T23:27:26Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c3ae877
Parents:
5f183dc
Message:

Preperly support both low and full speed devices using device_keeper

Location:
uspace/drv
Files:
9 edited

Legend:

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

    r5f183dc r1a93bb0  
    3939        uhci.c \
    4040        uhci_struct/transfer_descriptor.c \
     41        utils/device_keeper.c \
    4142        pci.c \
    4243        batch.c
  • uspace/drv/uhci-hcd/batch.c

    r5f183dc r1a93bb0  
    5353batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
    5454    usb_transfer_type_t transfer_type, size_t max_packet_size,
    55     dev_speed_t speed, char *buffer, size_t size,
     55    usb_speed_t speed, char *buffer, size_t size,
    5656    char* setup_buffer, size_t setup_size,
    5757    usbhc_iface_transfer_in_callback_t func_in,
  • uspace/drv/uhci-hcd/batch.h

    r5f183dc r1a93bb0  
    4343#include "uhci_struct/queue_head.h"
    4444
    45 typedef enum {
    46         LOW_SPEED,
    47         FULL_SPEED,
    48 } dev_speed_t;
    49 
    5045typedef struct batch
    5146{
    5247        link_t link;
    53         dev_speed_t speed;
     48        usb_speed_t speed;
    5449        usb_target_t target;
    5550        usb_transfer_type_t transfer_type;
     
    7671batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
    7772    usb_transfer_type_t transfer_type, size_t max_packet_size,
    78     dev_speed_t speed, char *buffer, size_t size,
     73    usb_speed_t speed, char *buffer, size_t size,
    7974                char *setup_buffer, size_t setup_size,
    8075    usbhc_iface_transfer_in_callback_t func_in,
  • uspace/drv/uhci-hcd/iface.c

    r5f183dc r1a93bb0  
    4141#include "iface.h"
    4242#include "uhci.h"
    43 
    44 #define DEFAULT_SPEED FULL_SPEED
     43#include "utils/device_keeper.h"
    4544
    4645/*----------------------------------------------------------------------------*/
     
    5049        uhci_t *hc = fun_to_uhci(fun);
    5150        assert(hc);
    52         usb_address_keeping_reserve_default(&hc->address_manager);
     51        usb_log_debug("Default address request with speed %d.\n", speed);
     52        device_keeper_reserve_default(&hc->device_manager, speed);
    5353        return EOK;
    5454}
     
    5959        uhci_t *hc = fun_to_uhci(fun);
    6060        assert(hc);
    61         usb_address_keeping_release_default(&hc->address_manager);
     61        usb_log_debug("Default address release.\n");
     62        device_keeper_release_default(&hc->device_manager);
    6263        return EOK;
    6364}
     
    6970        uhci_t *hc = fun_to_uhci(fun);
    7071        assert(hc);
    71         *address = usb_address_keeping_request(&hc->address_manager);
     72        assert(address);
     73
     74        usb_log_debug("Address request with speed %d.\n", speed);
     75        *address = device_keeper_request(&hc->device_manager, speed);
     76        usb_log_debug("Address request with result: %d.\n", *address);
    7277        if (*address <= 0)
    7378          return *address;
     
    8186        uhci_t *hc = fun_to_uhci(fun);
    8287        assert(hc);
    83         usb_address_keeping_devman_bind(&hc->address_manager, address, handle);
     88        usb_log_debug("Address bind %d-%d.\n", address, handle);
     89        device_keeper_bind(&hc->device_manager, address, handle);
    8490        return EOK;
    8591}
     
    9096        uhci_t *hc = fun_to_uhci(fun);
    9197        assert(hc);
    92         usb_address_keeping_release_default(&hc->address_manager);
     98        usb_log_debug("Address release %d.\n", address);
     99        device_keeper_release(&hc->device_manager, address);
    93100        return EOK;
    94101}
    95102/*----------------------------------------------------------------------------*/
    96103static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
    97     size_t max_packet_size,
    98     void *data, size_t size,
     104    size_t max_packet_size, void *data, size_t size,
    99105    usbhc_iface_transfer_out_callback_t callback, void *arg)
    100106{
    101         dev_speed_t speed = DEFAULT_SPEED;
     107        assert(fun);
     108        uhci_t *hc = fun_to_uhci(fun);
     109        assert(hc);
     110        usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
    102111
    103112        batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
     
    114123    usbhc_iface_transfer_in_callback_t callback, void *arg)
    115124{
    116         dev_speed_t speed = DEFAULT_SPEED;
     125        assert(fun);
     126        uhci_t *hc = fun_to_uhci(fun);
     127        assert(hc);
     128        usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
    117129
    118130        batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
     
    129141    usbhc_iface_transfer_out_callback_t callback, void *arg)
    130142{
    131         dev_speed_t speed = DEFAULT_SPEED;
     143        assert(fun);
     144        uhci_t *hc = fun_to_uhci(fun);
     145        assert(hc);
     146        usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
    132147
    133148        batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
     
    145160    usbhc_iface_transfer_in_callback_t callback, void *arg)
    146161{
    147         dev_speed_t speed = DEFAULT_SPEED;
     162        assert(fun);
     163        uhci_t *hc = fun_to_uhci(fun);
     164        assert(hc);
     165        usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
    148166
    149167        batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
  • uspace/drv/uhci-hcd/main.c

    r5f183dc r1a93bb0  
    8282        usb_log_info("uhci_add_device() called\n");
    8383
    84 
    8584        uintptr_t io_reg_base = 0;
    8685        size_t io_reg_size = 0;
     
    9695        io_reg_size = 32;
    9796
    98 //      ret = pci_enable_interrupts(device);
    99 //      CHECK_RET_RETURN(ret, "Failed(%d) to get enable interrupts:\n", ret);
     97        ret = pci_enable_interrupts(device);
     98        CHECK_RET_RETURN(ret, "Failed(%d) to get enable interrupts:\n", ret);
    10099
    101100        uhci_t *uhci_hc = malloc(sizeof(uhci_t));
  • uspace/drv/uhci-hcd/root_hub.c

    r5f183dc r1a93bb0  
    6464        assert(hc);
    6565
    66         usb_address_t addr = usb_address_keeping_find(&hc->address_manager,
     66        usb_address_t addr = device_keeper_find(&hc->device_manager,
    6767            handle);
    6868        if (addr < 0) {
  • uspace/drv/uhci-hcd/uhci.c

    r5f183dc r1a93bb0  
    6969        assert(hc);
    7070
    71         usb_address_t addr = usb_address_keeping_find(&hc->address_manager,
     71//      usb_address_t addr = usb_address_keeping_find(&hc->address_manager,
     72//          handle);
     73        usb_address_t addr = device_keeper_find(&hc->device_manager,
    7274            handle);
    7375        if (addr < 0) {
     
    141143
    142144        instance->cleaner = fibril_create(uhci_interrupt_emulator, instance);
    143         fibril_add_ready(instance->cleaner);
     145//      fibril_add_ready(instance->cleaner);
    144146
    145147        instance->debug_checker = fibril_create(uhci_debug_checker, instance);
     
    161163
    162164        /* enable all interrupts, but resume interrupt */
    163 //      pio_write_16(&instance->registers->usbintr,
    164 //                UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET);
     165        pio_write_16(&instance->registers->usbintr,
     166                  UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET);
    165167
    166168        /* Start the hc with large(64B) packet FSBR */
     
    207209
    208210        /* init address keeper(libusb) */
    209         usb_address_keeping_init(&instance->address_manager, USB11_ADDRESS_MAX);
    210         usb_log_debug("Initialized address manager.\n");
     211        device_keeper_init(&instance->device_manager);
     212        usb_log_debug("Initialized device manager.\n");
    211213
    212214        return EOK;
     
    259261        assert(instance);
    260262        assert(batch);
    261         const int low_speed = (batch->speed == LOW_SPEED);
     263        const int low_speed = (batch->speed == USB_SPEED_LOW);
    262264        if (!allowed_usb_packet(
    263265            low_speed, batch->transfer_type, batch->max_packet_size)) {
  • uspace/drv/uhci-hcd/uhci.h

    r5f183dc r1a93bb0  
    4141#include <ddi.h>
    4242
    43 #include <usb/addrkeep.h>
    4443#include <usbhc_iface.h>
    4544
     45#include "batch.h"
    4646#include "transfer_list.h"
    47 #include "batch.h"
     47#include "utils/device_keeper.h"
    4848
    4949typedef struct uhci_regs {
     
    8282
    8383typedef struct uhci {
    84         usb_address_keeping_t address_manager;
     84        device_keeper_t device_manager;
     85
    8586        volatile regs_t *registers;
    8687
  • uspace/drv/uhci-rhd/main.c

    r5f183dc r1a93bb0  
    116116int main(int argc, char *argv[])
    117117{
    118         usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     118        usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
    119119        return ddf_driver_main(&uhci_rh_driver);
    120120}
Note: See TracChangeset for help on using the changeset viewer.