Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 3515533 in mainline


Ignore:
Timestamp:
2010-12-17T22:07:41Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
18e35a7
Parents:
6b5f3b0
Message:

start of coding

root hub driver checks for devices
all addresses are hardcoded

Location:
uspace
Files:
12 added
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci/Makefile

    r6b5f3b0 r3515533  
    3333
    3434SOURCES = \
     35        iface.c \
    3536        main.c \
    36         transfers.c
     37        root_hub/port_status.c \
     38        root_hub/root_hub.c \
     39        uhci.c
    3740
    3841include $(USPACE_PREFIX)/Makefile.common
  • uspace/drv/uhci/iface.c

    r6b5f3b0 r3515533  
    2929#include <errno.h>
    3030
     31#include "iface.h"
    3132#include "uhci.h"
    32 
     33/*
    3334static int enqueue_transfer_out(device_t *dev,
    3435    usb_target_t target, usb_transfer_type_t transfer_type,
     
    6970        return ENOTSUP;
    7071}
    71 
     72*/
    7273
    7374static int get_address(device_t *dev, devman_handle_t handle,
     
    7677        return ENOTSUP;
    7778}
    78 
     79/*----------------------------------------------------------------------------*/
    7980static int interrupt_out(device_t *dev, usb_target_t target,
    8081    void *data, size_t size,
    8182    usbhc_iface_transfer_out_callback_t callback, void *arg)
    8283{
    83         return enqueue_transfer_out(dev, target, USB_TRANSFER_INTERRUPT,
    84             data, size,
    85             callback, arg);
     84        return uhci_out(dev, target, USB_TRANSFER_INTERRUPT,
     85            data, size, callback, arg);
    8686}
    87 
     87/*----------------------------------------------------------------------------*/
    8888static int interrupt_in(device_t *dev, usb_target_t target,
    8989    void *data, size_t size,
    9090    usbhc_iface_transfer_in_callback_t callback, void *arg)
    9191{
    92         return enqueue_transfer_in(dev, target, USB_TRANSFER_INTERRUPT,
    93             data, size,
    94             callback, arg);
     92        return uhci_in(dev, target, USB_TRANSFER_INTERRUPT,
     93            data, size, callback, arg);
    9594}
    96 
     95/*----------------------------------------------------------------------------*/
    9796static int control_write_setup(device_t *dev, usb_target_t target,
    9897    void *data, size_t size,
    9998    usbhc_iface_transfer_out_callback_t callback, void *arg)
    10099{
    101         return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
    102             data, size,
    103             callback, arg);
     100        return uhci_setup(dev, target, USB_TRANSFER_CONTROL,
     101            data, size, callback, arg);
    104102}
    105 
     103/*----------------------------------------------------------------------------*/
    106104static int control_write_data(device_t *dev, usb_target_t target,
    107105    void *data, size_t size,
    108106    usbhc_iface_transfer_out_callback_t callback, void *arg)
    109107{
    110         return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
    111             data, size,
    112             callback, arg);
     108        return uhci_out(dev, target, USB_TRANSFER_CONTROL,
     109            data, size, callback, arg);
    113110}
    114 
     111/*----------------------------------------------------------------------------*/
    115112static int control_write_status(device_t *dev, usb_target_t target,
    116113    usbhc_iface_transfer_in_callback_t callback, void *arg)
    117114{
    118         return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
    119             NULL, 0,
    120             callback, arg);
     115        return uhci_in(dev, target, USB_TRANSFER_CONTROL,
     116            NULL, 0, callback, arg);
    121117}
    122 
     118/*----------------------------------------------------------------------------*/
    123119static int control_read_setup(device_t *dev, usb_target_t target,
    124120    void *data, size_t size,
    125121    usbhc_iface_transfer_out_callback_t callback, void *arg)
    126122{
    127         return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
    128             data, size,
    129             callback, arg);
     123        return uhci_setup(dev, target, USB_TRANSFER_CONTROL,
     124            data, size, callback, arg);
    130125}
    131 
     126/*----------------------------------------------------------------------------*/
    132127static int control_read_data(device_t *dev, usb_target_t target,
    133128    void *data, size_t size,
    134129    usbhc_iface_transfer_in_callback_t callback, void *arg)
    135130{
    136         return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
    137             data, size,
    138             callback, arg);
     131        return uhci_in(dev, target, USB_TRANSFER_CONTROL,
     132            data, size, callback, arg);
    139133}
    140 
     134/*----------------------------------------------------------------------------*/
    141135static int control_read_status(device_t *dev, usb_target_t target,
    142136    usbhc_iface_transfer_out_callback_t callback, void *arg)
    143137{
    144         return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
    145             NULL, 0,
    146             callback, arg);
     138        return uhci_out(dev, target, USB_TRANSFER_CONTROL,
     139            NULL, 0, callback, arg);
    147140}
    148141
     
    150143usbhc_iface_t uhci_iface = {
    151144        .tell_address = get_address,
     145
     146        .reserve_default_address = NULL,
     147        .release_default_address = NULL,
     148        .request_address = NULL,
     149        .bind_address = NULL,
     150        .release_address = NULL,
     151
    152152        .interrupt_out = interrupt_out,
    153153        .interrupt_in = interrupt_in,
     154
    154155        .control_write_setup = control_write_setup,
    155156        .control_write_data = control_write_data,
    156157        .control_write_status = control_write_status,
     158
    157159        .control_read_setup = control_read_setup,
    158160        .control_read_data = control_read_data,
  • uspace/drv/uhci/main.c

    r6b5f3b0 r3515533  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2010 Vojtech Horky, Jan Vesely
    33 * All rights reserved.
    44 *
     
    2929#include <usb/debug.h>
    3030#include <errno.h>
    31 #include <driver.h>
     31
     32#include "iface.h"
     33#include "name.h"
    3234#include "uhci.h"
     35
    3336
    3437static device_ops_t uhci_ops = {
     
    4144        device->ops = &uhci_ops;
    4245
     46        uhci_init( device, (void*)0xc020 );
     47
    4348        /*
    4449         * We need to announce the presence of our root hub.
    4550         */
    46         usb_dprintf(NAME, 2, "adding root hub\n");
    47         usb_hcd_add_root_hub(device);
     51//      usb_dprintf(NAME, 2, "adding root hub\n");
     52//      usb_hcd_add_root_hub(device);
    4853
    4954        return EOK;
     
    6469         * Do some global initializations.
    6570         */
    66         sleep(5);
     71        sleep( 5);
    6772        usb_dprintf_enable(NAME, 5);
    6873
  • uspace/drv/uhci/uhci.h

    r6b5f3b0 r3515533  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2010 Jan Vesely
    33 * All rights reserved.
    44 *
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 
    2928/** @addtogroup usb
    3029 * @{
     
    3635#define DRV_UHCI_UHCI_H
    3736
     37#include <fibril.h>
     38
     39#include <usb/addrkeep.h>
     40#include <usb/hcdhubd.h>
    3841#include <usbhc_iface.h>
    3942
    40 #define NAME "uhci"
     43#include "root_hub/root_hub.h"
    4144
    42 usbhc_iface_t uhci_iface;
     45typedef struct uhci_regs {
     46        uint16_t usbcmd;
     47        uint16_t usbsts;
     48        uint16_t usbintr;
     49        uint16_t frnum;
     50        uint32_t flbaseadd;
     51        uint8_t sofmod;
     52} regs_t;
     53
     54typedef struct uhci {
     55        usb_address_keeping_t address_manager;
     56        uhci_root_hub_t root_hub;
     57        volatile regs_t* registers;
     58
     59} uhci_t ;
     60
     61/* init uhci specifics in device.driver_data */
     62int uhci_init( device_t *device, void *regs );
     63
     64int uhci_destroy( device_t *device );
     65
     66int uhci_in(
     67  device_t *dev,
     68        usb_target_t target,
     69        usb_transfer_type_t transfer_type,
     70        void *buffer, size_t size,
     71        usbhc_iface_transfer_in_callback_t callback, void *arg
     72        );
     73
     74int uhci_out(
     75  device_t *dev,
     76        usb_target_t target,
     77  usb_transfer_type_t transfer_type,
     78  void *buffer, size_t size,
     79        usbhc_iface_transfer_out_callback_t callback, void *arg
     80  );
     81
     82int uhci_setup(
     83  device_t *dev,
     84  usb_target_t target,
     85  usb_transfer_type_t transfer_type,
     86  void *buffer, size_t size,
     87  usbhc_iface_transfer_out_callback_t callback, void *arg
     88  );
    4389
    4490#endif
  • uspace/lib/usb/include/usb/hcd.h

    • Property mode changed from 100644 to 120000
    r6b5f3b0 r3515533  
    1 /*
    2  * Copyright (c) 2010 Vojtech Horky
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  *
    9  * - Redistributions of source code must retain the above copyright
    10  *   notice, this list of conditions and the following disclaimer.
    11  * - Redistributions in binary form must reproduce the above copyright
    12  *   notice, this list of conditions and the following disclaimer in the
    13  *   documentation and/or other materials provided with the distribution.
    14  * - The name of the author may not be used to endorse or promote products
    15  *   derived from this software without specific prior written permission.
    16  *
    17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    27  */
    28 
    29 /** @addtogroup libusb usb
    30  * @{
    31  */
    32 /** @file
    33  * @brief HC driver.
    34  */
    35 #ifndef LIBUSB_HCD_H_
    36 #define LIBUSB_HCD_H_
    37 
    38 #include <usb/usb.h>
    39 #include <fibril_synch.h>
    40 #include <devman.h>
    41 
    42 /** Info about used address. */
    43 typedef struct {
    44         /** Linked list member. */
    45         link_t link;
    46         /** Address. */
    47         usb_address_t address;
    48         /** Corresponding devman handle. */
    49         devman_handle_t devman_handle;
    50 } usb_address_keeping_used_t;
    51 
    52 /** Structure for keeping track of free and used USB addresses. */
    53 typedef struct {
    54         /** Head of list of used addresses. */
    55         link_t used_addresses;
    56         /** Upper bound for USB addresses. */
    57         usb_address_t max_address;
    58         /** Mutex protecting used address. */
    59         fibril_mutex_t used_addresses_guard;
    60         /** Condition variable for used addresses. */
    61         fibril_condvar_t used_addresses_condvar;
    62 
    63         /** Condition variable mutex for default address. */
    64         fibril_mutex_t default_condvar_guard;
    65         /** Condition variable for default address. */
    66         fibril_condvar_t default_condvar;
    67         /** Whether is default address available. */
    68         bool default_available;
    69 } usb_address_keeping_t;
    70 
    71 void usb_address_keeping_init(usb_address_keeping_t *, usb_address_t);
    72 
    73 void usb_address_keeping_reserve_default(usb_address_keeping_t *);
    74 void usb_address_keeping_release_default(usb_address_keeping_t *);
    75 
    76 usb_address_t usb_address_keeping_request(usb_address_keeping_t *);
    77 int usb_address_keeping_release(usb_address_keeping_t *, usb_address_t);
    78 void usb_address_keeping_devman_bind(usb_address_keeping_t *, usb_address_t,
    79     devman_handle_t);
    80 usb_address_t usb_address_keeping_find(usb_address_keeping_t *,
    81     devman_handle_t);
    82 
    83 
    84 #endif
     1addrkeep.h
  • uspace/lib/usb/src/addrkeep.c

    r6b5f3b0 r3515533  
    3333 * @brief Address keeping.
    3434 */
    35 #include <usb/hcd.h>
     35#include <usb/addrkeep.h>
    3636#include <errno.h>
    3737#include <assert.h>
Note: See TracChangeset for help on using the changeset viewer.