Changeset 1256a0a in mainline


Ignore:
Timestamp:
2011-02-01T00:08:46Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
993a1e1
Parents:
37ac7bb
Message:

uhci-rhd - UHCI Root hub drier as a separated process

this wil deffinitely need a lot of polishing

Files:
8 added
1 deleted
9 edited
6 moved

Legend:

Unmodified
Added
Removed
  • .bzrignore

    r37ac7bb r1256a0a  
    8585./uspace/drv/test2/test2
    8686./uspace/drv/uhci-hcd/uhci-hcd
     87./uspace/drv/uhci-rhd/uhci-rhd
    8788./uspace/drv/usbhub/usbhub
    8889./uspace/drv/usbhid/usbhid
  • boot/arch/amd64/Makefile.inc

    r37ac7bb r1256a0a  
    4444        ns8250 \
    4545        uhci-hcd \
     46        uhci-rhd \
    4647        usbhub \
    4748        usbhid \
  • uspace/Makefile

    r37ac7bb r1256a0a  
    118118                srv/hw/irc/i8259 \
    119119                drv/uhci-hcd \
     120                drv/uhci-rhd \
    120121                drv/usbhid \
    121122                drv/usbhub \
     
    132133                srv/hw/irc/i8259 \
    133134                drv/uhci-hcd \
     135                drv/uhci-rhd \
    134136                drv/usbhid \
    135137                drv/usbhub \
  • uspace/drv/uhci-hcd/Makefile

    r37ac7bb r1256a0a  
    3636        iface.c \
    3737        main.c \
    38         root_hub/port.c \
    39         root_hub/port_status.c \
    40         root_hub/root_hub.c \
     38        root_hub.c \
    4139        transfer_list.c \
    4240        uhci.c \
  • uspace/drv/uhci-hcd/main.c

    r37ac7bb r1256a0a  
    3434#include "iface.h"
    3535#include "name.h"
     36#include "pci.h"
     37#include "root_hub.h"
    3638#include "uhci.h"
    3739
     
    7577            io_reg_base, io_reg_size, irq);
    7678
    77         return uhci_init(device, (void*)io_reg_base, io_reg_size);
     79        int ret = uhci_init(device, (void*)io_reg_base, io_reg_size);
     80
     81        if (ret != EOK) {
     82                uhci_print_error("Failed to init uhci-hcd.\n");
     83                return ret;
     84        }
     85        device_t *rh;
     86        ret = setup_root_hub(&rh, device);
     87
     88        if (ret != EOK) {
     89                uhci_print_error("Failed to setup uhci root hub.\n");
     90                /* TODO: destroy uhci here */
     91                return ret;
     92        }
     93
     94        ret = child_device_register(rh, device);
     95        if (ret != EOK) {
     96                uhci_print_error("Failed to register root hub.\n");
     97                /* TODO: destroy uhci here */
     98                return ret;
     99        }
     100
     101        return EOK;
    78102}
    79103
  • uspace/drv/uhci-hcd/name.h

    r37ac7bb r1256a0a  
    3232 * @brief UHCI driver
    3333 */
    34 #ifndef DRV_UHCI_TD_NAME_H
    35 #define DRV_UHCI_TD_NAME_H
     34#ifndef DRV_UHCI_NAME_H
     35#define DRV_UHCI_NAME_H
    3636
    3737#define NAME "uhci-hcd"
  • uspace/drv/uhci-hcd/pci.c

    r37ac7bb r1256a0a  
    3434 * PCI related functions needed by the UHCI driver.
    3535 */
    36 #include "uhci.h"
     36#include "pci.h"
    3737#include <errno.h>
    3838#include <assert.h>
  • uspace/drv/uhci-hcd/uhci.c

    r37ac7bb r1256a0a  
    5151        uhci_print_verbose("Transfer lists initialized.\n");
    5252
    53         /* init root hub */
    54         ret = uhci_root_hub_init(&instance->root_hub, device,
    55           (char*)regs + UHCI_ROOT_HUB_PORT_REGISTERS_OFFSET);
    56         CHECK_RET_FREE_INSTANCE("Failed to initialize root hub driver.\n");
    5753
    5854        uhci_print_verbose("Initializing frame list.\n");
    5955        instance->frame_list = get_page();
    60 //        memalign32(sizeof(link_pointer_t) * UHCI_FRAME_LIST_COUNT, 4096);
    61         if (instance->frame_list == NULL) {
    62                 uhci_print_error("Failed to allocate frame list pointer.\n");
    63                 uhci_root_hub_fini(&instance->root_hub);
    64                 free(instance);
    65                 return ENOMEM;
    66         }
     56        ret = instance ? EOK : ENOMEM;
     57        CHECK_RET_FREE_INSTANCE("Failed to get frame list page.\n");
    6758
    6859        /* initialize all frames to point to the first queue head */
  • uspace/drv/uhci-hcd/uhci.h

    r37ac7bb r1256a0a  
    4141#include <usbhc_iface.h>
    4242
    43 #include "root_hub/root_hub.h"
    4443#include "transfer_list.h"
    4544
     
    7675typedef struct uhci {
    7776        usb_address_keeping_t address_manager;
    78         uhci_root_hub_t root_hub;
    7977        volatile regs_t *registers;
    8078
     
    8785
    8886/* init uhci specifics in device.driver_data */
    89 int uhci_init( device_t *device, void *regs, size_t reg_size );
     87int uhci_init(device_t *device, void *regs, size_t reg_size);
    9088
    91 int uhci_destroy( device_t *device );
     89int uhci_destroy(device_t *device);
    9290
    9391int uhci_transfer(
     
    102100  void *arg );
    103101
    104 int pci_get_my_registers(device_t *, uintptr_t *, size_t *, int *);
    105 
    106102#endif
    107103/**
  • uspace/drv/uhci-rhd/debug.h

    r37ac7bb r1256a0a  
    3838#include <usb/debug.h>
    3939
    40 #define NAME "uhci_root_hubd"
     40#include "name.h"
     41
    4142
    4243enum debug_levels {
  • uspace/drv/uhci-rhd/port.c

    r37ac7bb r1256a0a  
    1111static int uhci_port_remove_device(uhci_port_t *port);
    1212static int uhci_port_set_enabled(uhci_port_t *port, bool enabled);
     13static int uhci_port_check(void *port);
    1314
     15int uhci_port_init(
     16  uhci_port_t *port, port_status_t *address, unsigned number,
     17  unsigned usec, device_t *rh)
     18{
     19        assert(port);
     20        port->address = address;
     21        port->number = number;
     22        port->wait_period_usec = usec;
     23        port->attached_device = 0;
     24        port->rh = rh;
     25        port->hc_phone = rh->parent_phone;
     26
     27        port->checker = fibril_create(uhci_port_check, port);
     28        if (port->checker == 0) {
     29                uhci_print_error(": failed to launch root hub fibril.");
     30                return ENOMEM;
     31        }
     32        fibril_add_ready(port->checker);
     33        uhci_print_verbose(
     34          "Added fibril for port %d: %p.\n", number, port->checker);
     35        return EOK;
     36}
     37/*----------------------------------------------------------------------------*/
     38void uhci_port_fini(uhci_port_t *port)
     39{
     40//      fibril_teardown(port->checker);
     41        return;
     42}
    1443/*----------------------------------------------------------------------------*/
    1544int uhci_port_check(void *port)
     
    1847        uhci_port_t *port_instance = port;
    1948        assert(port_instance);
    20         port_instance->hc_phone = devman_device_connect(port_instance->hc->handle, 0);
    21         if (port_instance->hc_phone < 0) {
    22                 uhci_print_fatal("Failed(%d) to connect to the hc(handle=%x.\n",
    23                         port_instance->hc_phone, (unsigned)port_instance->hc->handle);
    24                 return port_instance->hc_phone;
    25         }
    2649
    2750        while (1) {
     
    119142        assert(port->attached_device == 0);
    120143
    121         ret = usb_drv_register_child_in_devman(port->hc_phone, port->hc, usb_address,
    122                 &port->attached_device);
     144        ret = usb_drv_register_child_in_devman(port->hc_phone, port->rh,
     145          usb_address, &port->attached_device);
    123146
    124147        if (ret != EOK) { /* something went wrong */
  • uspace/drv/uhci-rhd/port.h

    r37ac7bb r1256a0a  
    4444{
    4545        port_status_t *address;
    46         device_t *hc;
    4746        unsigned number;
    4847        unsigned wait_period_usec;
    4948        int hc_phone;
     49        device_t *rh;
    5050        devman_handle_t attached_device;
     51        fid_t checker;
    5152} uhci_port_t;
    5253
    53 static inline void uhci_port_init(
    54   uhci_port_t *port, port_status_t *address, device_t *hc, unsigned number,
    55   unsigned usec)
    56 {
    57         assert(port);
    58         port->address = address;
    59         port->hc = hc;
    60         port->number = number;
    61         port->hc_phone = -1;
    62         port->wait_period_usec = usec;
    63         port->attached_device = 0;
    64 }
     54int uhci_port_init(
     55  uhci_port_t *port, port_status_t *address, unsigned number,
     56  unsigned usec, device_t *rh);
    6557
    66 int uhci_port_check(void *port);
     58void uhci_port_fini(uhci_port_t *port);
    6759#endif
    6860/**
  • uspace/drv/uhci-rhd/root_hub.h

    r37ac7bb r1256a0a  
    4646typedef struct root_hub {
    4747        uhci_port_t ports[UHCI_ROOT_HUB_PORT_COUNT];
    48         fid_t checker[UHCI_ROOT_HUB_PORT_COUNT];
     48        devman_handle_t hc_handle;
    4949} uhci_root_hub_t;
    5050
    5151int uhci_root_hub_init(
    52   uhci_root_hub_t *instance, device_t *device, void *addr);
     52  uhci_root_hub_t *instance, void *addr, size_t size, device_t *rh);
    5353
    5454int uhci_root_hub_fini(uhci_root_hub_t* instance);
Note: See TracChangeset for help on using the changeset viewer.