Changeset 7d6a676 in mainline for uspace/drv/ohci/hc.c


Ignore:
Timestamp:
2011-03-21T14:20:23Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5d1db18
Parents:
925e099
Message:

Add interrupt emulator

File:
1 edited

Legend:

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

    r925e099 r7d6a676  
    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        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
     
    117118}
    118119/*----------------------------------------------------------------------------*/
    119 void hc_interrupt(hc_t *instance, uint16_t status)
     120void hc_interrupt(hc_t *instance, uint32_t status)
    120121{
    121122        assert(instance);
    122         /* TODO: Check for interrupt cause */
    123         rh_interrupt(&instance->rh);
     123        if (status == 0)
     124                return;
     125        if (status & IS_RHSC)
     126                rh_interrupt(&instance->rh);
     127
     128        /* TODO: Check for further interrupt causes */
    124129        /* TODO: implement */
     130}
     131/*----------------------------------------------------------------------------*/
     132static int dummy_reset(int foo, void *arg)
     133{
     134        hc_t *hc = (hc_t*)arg;
     135        assert(hc);
     136        hc->rh.address = 0;
     137        return EOK;
     138}
     139/*----------------------------------------------------------------------------*/
     140static int interrupt_emulator(hc_t *instance)
     141{
     142        assert(instance);
     143        usb_log_info("Started interrupt emulator.\n");
     144        while (1) {
     145                uint32_t status = instance->registers->interrupt_status;
     146                instance->registers->interrupt_status = status;
     147                hc_interrupt(instance, status);
     148                async_usleep(1000);
     149        }
     150        return EOK;
    125151}
    126152/**
Note: See TracChangeset for help on using the changeset viewer.