Changes in uspace/drv/ohci/hc.c [53f1c87:1387692] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/hc.c

    r53f1c87 r1387692  
    3939#include <usb/debug.h>
    4040#include <usb/usb.h>
     41#include <usb/hub.h>
    4142#include <usb/ddfiface.h>
    4243#include <usb/usbdevice.h>
     
    4445#include "hc.h"
    4546
    46 static int interrupt_emulator(hc_t *instance);
    47 /*----------------------------------------------------------------------------*/
    48 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun)
     47static int dummy_reset(int foo, void *arg)
    4948{
    50         assert(instance);
    51         assert(hub_fun);
    52 
    53         usb_address_t hub_address =
    54             device_keeper_get_free_address(&instance->manager, USB_SPEED_FULL);
    55         instance->rh.address = hub_address;
    56         usb_device_keeper_bind(
    57             &instance->manager, hub_address, hub_fun->handle);
    58 
    59         char *match_str = NULL;
    60         int ret = asprintf(&match_str, "usb&mid");
    61         ret = (match_str == NULL) ? ret : EOK;
    62         if (ret < 0) {
    63                 usb_log_error("Failed to create root hub match-id string.\n");
    64                 return ret;
    65         }
    66 
    67         ret = ddf_fun_add_match_id(hub_fun, match_str, 100);
    68         if (ret != EOK) {
    69                 usb_log_error("Failed add create root hub match-id.\n");
    70         }
    71         return ret;
     49        hc_t *hc = (hc_t*)arg;
     50        assert(hc);
     51        hc->rh.address = 0;
     52        return EOK;
    7253}
    7354/*----------------------------------------------------------------------------*/
     
    8667        usb_device_keeper_init(&instance->manager);
    8768
    88         if (!interrupts) {
    89                 instance->interrupt_emulator =
    90                     fibril_create((int(*)(void*))interrupt_emulator, instance);
    91                 fibril_add_ready(instance->interrupt_emulator);
    92         }
    9369
    9470        rh_init(&instance->rh, dev, instance->registers);
     71        /* TODO: implement */
     72        return EOK;
     73}
     74/*----------------------------------------------------------------------------*/
     75int hc_register_hub(hc_t *instance)
     76{
     77        async_usleep(1000000);
     78#define CHECK_RET_RETURN(ret, msg...) \
     79        if (ret != EOK) { \
     80                usb_log_error(msg); \
     81                return ret; \
     82        } else (void)0
     83        assert(instance);
     84        assert(instance->ddf_instance);
     85        assert(instance->ddf_instance->handle);
     86        ddf_dev_t *dev = instance->rh.device;
     87        int ret = EOK;
    9588
    96         /* TODO: implement */
     89        usb_hc_connection_t conn;
     90        ret =
     91            usb_hc_connection_initialize(&conn, instance->ddf_instance->handle);
     92        CHECK_RET_RETURN(ret, "Failed to initialize hc connection.\n");
     93
     94        ret = usb_hc_connection_open(&conn);
     95        CHECK_RET_RETURN(ret, "Failed to open hc connection.\n");
     96
     97        usb_address_t address;
     98        devman_handle_t handle;
     99        ret = usb_hc_new_device_wrapper(dev, &conn, USB_SPEED_FULL, dummy_reset,
     100            0, instance, &address, &handle, NULL, NULL, NULL);
     101        CHECK_RET_RETURN(ret, "Failed to add rh device.\n");
     102
     103        ret = usb_hc_connection_close(&conn);
     104        CHECK_RET_RETURN(ret, "Failed to close hc connection.\n");
    97105        return EOK;
    98106}
     
    109117}
    110118/*----------------------------------------------------------------------------*/
    111 void hc_interrupt(hc_t *instance, uint32_t status)
     119void hc_interrupt(hc_t *instance, uint16_t status)
    112120{
    113121        assert(instance);
    114         if (status == 0)
    115                 return;
    116         if (status & IS_RHSC)
    117                 rh_interrupt(&instance->rh);
    118 
    119         /* TODO: Check for further interrupt causes */
     122        /* TODO: Check for interrupt cause */
     123        rh_interrupt(&instance->rh);
    120124        /* TODO: implement */
    121 }
    122 /*----------------------------------------------------------------------------*/
    123 int interrupt_emulator(hc_t *instance)
    124 {
    125         assert(instance);
    126         usb_log_info("Started interrupt emulator.\n");
    127         while (1) {
    128                 uint32_t status = instance->registers->interrupt_status;
    129                 instance->registers->interrupt_status = status;
    130                 hc_interrupt(instance, status);
    131                 async_usleep(1000);
    132         }
    133         return EOK;
    134125}
    135126/**
Note: See TracChangeset for help on using the changeset viewer.