Changeset 7102aa5 in mainline for uspace/drv/ohci/hc.c


Ignore:
Timestamp:
2011-03-21T15:08:29Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
28eee11c, aaff605
Parents:
c92c13f (diff), 5971dd3 (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:

Merge development/ changes

File:
1 edited

Legend:

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

    rc92c13f r7102aa5  
    4545#include "hc.h"
    4646
    47 static int dummy_reset(int foo, void *arg)
    48 {
    49         hc_t *hc = (hc_t*)arg;
    50         assert(hc);
    51         hc->rh.address = 0;
    52         return EOK;
    53 }
     47static int dummy_reset(int foo, void *arg);
     48static int interrupt_emulator(hc_t *instance);
    5449/*----------------------------------------------------------------------------*/
    5550int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev,
     
    6661        instance->ddf_instance = fun;
    6762        usb_device_keeper_init(&instance->manager);
     63
     64        if (!interrupts) {
     65                instance->interrupt_emulator =
     66                    fibril_create((int(*)(void*))interrupt_emulator, instance);
     67                fibril_add_ready(instance->interrupt_emulator);
     68        }
    6869
    6970
     
    99100        ret = usb_hc_new_device_wrapper(dev, &conn, USB_SPEED_FULL, dummy_reset,
    100101            0, instance, &address, &handle, NULL, NULL, NULL);
    101         CHECK_RET_RETURN(ret, "Failed to add rh device.\n");
     102        if (ret != EOK) {
     103                usb_log_error("Failed to add rh device.\n");
     104                instance->rh.address = -1;
     105                return ret;
     106        }
    102107
    103108        ret = usb_hc_connection_close(&conn);
     
    117122}
    118123/*----------------------------------------------------------------------------*/
    119 void hc_interrupt(hc_t *instance, uint16_t status)
     124void hc_interrupt(hc_t *instance, uint32_t status)
    120125{
    121126        assert(instance);
    122         /* TODO: Check for interrupt cause */
    123         rh_interrupt(&instance->rh);
     127        if (status == 0)
     128                return;
     129        if (status & IS_RHSC)
     130                rh_interrupt(&instance->rh);
     131
     132        /* TODO: Check for further interrupt causes */
    124133        /* TODO: implement */
     134}
     135/*----------------------------------------------------------------------------*/
     136static int dummy_reset(int foo, void *arg)
     137{
     138        hc_t *hc = (hc_t*)arg;
     139        assert(hc);
     140        hc->rh.address = 0;
     141        return EOK;
     142}
     143/*----------------------------------------------------------------------------*/
     144static int interrupt_emulator(hc_t *instance)
     145{
     146        assert(instance);
     147        usb_log_info("Started interrupt emulator.\n");
     148        while (1) {
     149                uint32_t status = instance->registers->interrupt_status;
     150                instance->registers->interrupt_status = status;
     151                hc_interrupt(instance, status);
     152                async_usleep(1000);
     153        }
     154        return EOK;
    125155}
    126156/**
Note: See TracChangeset for help on using the changeset viewer.