Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1ecc5de in mainline


Ignore:
Timestamp:
2011-07-10T20:43:22Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
2e8a01b
Parents:
2bc7122
Message:

OHCI: Create a new way to generate IRQ code

Replace asserts with runtime check.

Location:
uspace/drv/bus/usb/ohci
Files:
3 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 * @}
  • uspace/drv/bus/usb/ohci/hc.h

    r2bc7122 r1ecc5de  
    8686} hc_t;
    8787
    88 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
     88size_t hc_irq_cmd_count(void);
     89int hc_get_irq_commands(
     90    irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size);
    8991int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts);
    9092void hc_start_hw(hc_t *instance);
     93int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
    9194
    9295/** Safely dispose host controller internal structures
  • uspace/drv/bus/usb/ohci/ohci.c

    r2bc7122 r1ecc5de  
    5858{
    5959        assert(dev);
    60         assert(dev->driver_data);
    6160        return dev->driver_data;
    6261}
    63 
    6462/** IRQ handling callback, identifies device
    6563 *
     
    7169{
    7270        hc_t *hc = &dev_to_ohci(dev)->hc;
    73         assert(hc);
     71        if (!hc) {
     72                usb_log_warning("IRQ on device that is not ready.\n");
     73                return;
     74        }
    7475        const uint16_t status = IPC_GET_ARG1(*call);
    7576        hc_interrupt(hc, status);
Note: See TracChangeset for help on using the changeset viewer.