Ignore:
File:
1 edited

Legend:

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

    racdb5bac r507c6f3  
    8383};
    8484
     85enum {
     86        /** Number of PIO ranges used in IRQ code */
     87        hc_irq_pio_range_count =
     88            sizeof(ohci_pio_ranges) / sizeof(irq_pio_range_t),
     89
     90        /** Number of commands used in IRQ code */
     91        hc_irq_cmd_count =
     92            sizeof(ohci_irq_commands) / sizeof(irq_cmd_t)
     93};
     94
    8595static void hc_gain_control(hc_t *instance);
    8696static void hc_start(hc_t *instance);
     
    8999static int interrupt_emulator(hc_t *instance);
    90100static int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
    91 
    92 /** Get number of PIO ranges used in IRQ code.
    93  * @return Number of ranges.
    94  */
    95 size_t hc_irq_pio_range_count(void)
    96 {
    97         return sizeof(ohci_pio_ranges) / sizeof(irq_pio_range_t);
    98 }
    99 
    100 /** Get number of commands used in IRQ code.
    101  * @return Number of commands.
    102  */
    103 size_t hc_irq_cmd_count(void)
    104 {
    105         return sizeof(ohci_irq_commands) / sizeof(irq_cmd_t);
    106 }
    107101
    108102/** Generate IRQ code.
     
    133127        cmds[3].addr = (void *) &registers->interrupt_status;
    134128        OHCI_WR(cmds[1].value, OHCI_USED_INTERRUPTS);
     129
     130        return EOK;
     131}
     132
     133/** Register interrupt handler.
     134 *
     135 * @param[in] device Host controller DDF device
     136 * @param[in] reg_base Register range base
     137 * @param[in] reg_size Register range size
     138 * @param[in] irq Interrupt number
     139 * @paran[in] handler Interrupt handler
     140 *
     141 * @return EOK on success or negative error code
     142 */
     143int hc_register_irq_handler(ddf_dev_t *device, uintptr_t reg_base, size_t reg_size,
     144    int irq, interrupt_handler_t handler)
     145{
     146        int rc;
     147
     148        irq_pio_range_t irq_ranges[hc_irq_pio_range_count];
     149        irq_cmd_t irq_cmds[hc_irq_cmd_count];
     150
     151        irq_code_t irq_code = {
     152                .rangecount = hc_irq_pio_range_count,
     153                .ranges = irq_ranges,
     154                .cmdcount = hc_irq_cmd_count,
     155                .cmds = irq_cmds
     156        };
     157
     158        rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds,
     159            sizeof(irq_cmds), reg_base, reg_size);
     160        if (rc != EOK) {
     161                usb_log_error("Failed to generate IRQ code: %s.\n",
     162                    str_error(rc));
     163                return rc;
     164        }
     165
     166        /* Register handler to avoid interrupt lockup */
     167        rc = register_interrupt_handler(device, irq, handler, &irq_code);
     168        if (rc != EOK) {
     169                usb_log_error("Failed to register interrupt handler: %s.\n",
     170                    str_error(rc));
     171                return rc;
     172        }
    135173
    136174        return EOK;
Note: See TracChangeset for help on using the changeset viewer.