Changeset 0b5644c in mainline for uspace/drv/uhci-hcd/root_hub.c


Ignore:
Timestamp:
2011-03-01T14:02:16Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
27270db
Parents:
5d4d98b (diff), cc44f7e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged development changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/root_hub.c

    r5d4d98b r0b5644c  
    3434#include <assert.h>
    3535#include <errno.h>
     36#include <str_error.h>
    3637#include <stdio.h>
     38#include <ops/hw_res.h>
     39
    3740#include <usb_iface.h>
    3841#include <usb/debug.h>
     
    4144#include "uhci.h"
    4245
     46/*----------------------------------------------------------------------------*/
    4347static int usb_iface_get_hc_handle_rh_impl(ddf_fun_t *root_hub_fun,
    4448    devman_handle_t *handle)
     
    5155        return EOK;
    5256}
    53 
     57/*----------------------------------------------------------------------------*/
    5458static int usb_iface_get_address_rh_impl(ddf_fun_t *fun, devman_handle_t handle,
    5559    usb_address_t *address)
     
    6165        assert(hc);
    6266
    63         usb_address_t addr = usb_address_keeping_find(&hc->address_manager,
     67        usb_address_t addr = device_keeper_find(&hc->device_manager,
    6468            handle);
    6569        if (addr < 0) {
     
    7377        return EOK;
    7478}
    75 
     79/*----------------------------------------------------------------------------*/
    7680usb_iface_t usb_iface_root_hub_fun_impl = {
    7781        .get_hc_handle = usb_iface_get_hc_handle_rh_impl,
    7882        .get_address = usb_iface_get_address_rh_impl
    7983};
     84/*----------------------------------------------------------------------------*/
     85static hw_resource_list_t *get_resource_list(ddf_fun_t *dev)
     86{
     87        assert(dev);
     88        ddf_fun_t *hc_ddf_instance = dev->driver_data;
     89        assert(hc_ddf_instance);
     90        uhci_t *hc = hc_ddf_instance->driver_data;
     91        assert(hc);
    8092
     93        //TODO: fix memory leak
     94        hw_resource_list_t *resource_list = malloc(sizeof(hw_resource_list_t));
     95        assert(resource_list);
     96        resource_list->count = 1;
     97        resource_list->resources = malloc(sizeof(hw_resource_t));
     98        assert(resource_list->resources);
     99        resource_list->resources[0].type = IO_RANGE;
     100        resource_list->resources[0].res.io_range.address =
     101            ((uintptr_t)hc->registers) + 0x10; // see UHCI design guide
     102        resource_list->resources[0].res.io_range.size = 4;
     103        resource_list->resources[0].res.io_range.endianness = LITTLE_ENDIAN;
     104
     105        return resource_list;
     106}
     107/*----------------------------------------------------------------------------*/
     108static hw_res_ops_t hw_res_iface = {
     109        .get_resource_list = get_resource_list,
     110        .enable_interrupt = NULL
     111};
     112/*----------------------------------------------------------------------------*/
    81113static ddf_dev_ops_t root_hub_ops = {
    82         .interfaces[USB_DEV_IFACE] = &usb_iface_root_hub_fun_impl
     114        .interfaces[USB_DEV_IFACE] = &usb_iface_root_hub_fun_impl,
     115        .interfaces[HW_RES_DEV_IFACE] = &hw_res_iface
    83116};
    84 
    85117/*----------------------------------------------------------------------------*/
    86118int setup_root_hub(ddf_fun_t **fun, ddf_dev_t *hc)
    87119{
    88120        assert(fun);
     121        assert(hc);
    89122        int ret;
    90123
     
    105138        ret = ddf_fun_add_match_id(hub, match_str, 100);
    106139        if (ret != EOK) {
    107                 usb_log_error("Failed to add root hub match id.\n");
     140                usb_log_error("Failed(%d) to add root hub match id: %s\n",
     141                    ret, str_error(ret));
    108142                ddf_fun_destroy(hub);
    109                 return ENOMEM;
     143                return ret;
    110144        }
    111145
Note: See TracChangeset for help on using the changeset viewer.