Changeset 1ecc5de in mainline for uspace/drv/bus/usb/ohci/hc.c


Ignore:
Timestamp:
2011-07-10T20:43:22Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2e8a01b
Parents:
2bc7122
Message:

OHCI: Create a new way to generate IRQ code

Replace asserts with runtime check.

File:
1 edited

Legend:

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

    r2bc7122 r1ecc5de  
    4646#define OHCI_USED_INTERRUPTS \
    4747    (I_SO | I_WDH | I_UE | I_RHSC)
     48
     49static const irq_cmd_t ohci_irq_commands[] =
     50{
     51        { .cmd = CMD_MEM_READ_32, .dstarg = 1, .addr = NULL /*filled later*/ },
     52        { .cmd = CMD_BTEST, .srcarg = 1, .dstarg = 2, .value = OHCI_USED_INTERRUPTS },
     53        { .cmd = CMD_PREDICATE, .srcarg = 2, .value = 2 },
     54        { .cmd = CMD_MEM_WRITE_A_32, .srcarg = 1, .addr = NULL /*filled later*/ },
     55        { .cmd = CMD_ACCEPT },
     56};
     57
    4858static int interrupt_emulator(hc_t *instance);
    4959static void hc_gain_control(hc_t *instance);
     
    150160}
    151161/*----------------------------------------------------------------------------*/
    152 /** Create end register endpoint structures
     162size_t hc_irq_cmd_count(void)
     163{
     164        return sizeof(ohci_irq_commands) / sizeof(irq_cmd_t);
     165}
     166/*----------------------------------------------------------------------------*/
     167int hc_get_irq_commands(
     168    irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size)
     169{
     170        if (cmd_size < sizeof(ohci_irq_commands)
     171            || reg_size < sizeof(ohci_regs_t))
     172                return EOVERFLOW;
     173
     174        /* Create register mapping to use in IRQ handler
     175         * this mapping should be present in kernel only.
     176         * Remove it from here when kernel knows how to create mappings
     177         * and accepts physical addresses in IRQ code.
     178         * TODO: remove */
     179        void *registers;
     180        const int ret = pio_enable((void*)regs, reg_size, &registers);
     181
     182        if (ret != EOK)
     183                return ret;
     184
     185        memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands));
     186
     187        void *address = (void*)&(((ohci_regs_t*)registers)->interrupt_status);
     188        cmds[0].addr = address;
     189        cmds[3].addr = address;
     190        return EOK;
     191}
     192/*----------------------------------------------------------------------------*/
     193/** Create and register endpoint structures
    153194 *
    154195 * @param[in] instance OHCI driver structure.
     
    621662        return EOK;
    622663}
     664
    623665/**
    624666 * @}
Note: See TracChangeset for help on using the changeset viewer.