Changeset d57122c in mainline for uspace/drv/bus/usb/uhci


Ignore:
Timestamp:
2012-02-12T18:41:44Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bd8c6537
Parents:
a996ae31
Message:

UHCI and OHCI HC's now define and use proper IRQ PIO range.

Location:
uspace/drv/bus/usb/uhci
Files:
3 edited

Legend:

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

    ra996ae31 rd57122c  
    4848    (UHCI_STATUS_INTERRUPT | UHCI_STATUS_ERROR_INTERRUPT)
    4949
    50 
    51 static const irq_cmd_t uhci_irq_commands[] =
    52 {
     50static const irq_pio_range_t uhci_irq_pio_ranges[] = {
     51        {
     52                .base = 0,      /* filled later */
     53                .size = sizeof(uhci_regs_t)
     54        }
     55};
     56
     57static const irq_cmd_t uhci_irq_commands[] = {
    5358        { .cmd = CMD_PIO_READ_16, .dstarg = 1, .addr = NULL/*filled later*/},
    5459        { .cmd = CMD_BTEST, .srcarg = 1, .dstarg = 2,
     
    6873
    6974/*----------------------------------------------------------------------------*/
     75/** Get number of PIO ranges used in IRQ code.
     76 * @return Number of ranges.
     77 */
     78size_t hc_irq_pio_range_count(void)
     79{
     80        return sizeof(uhci_irq_pio_ranges) / sizeof(irq_pio_range_t);
     81}
     82/*----------------------------------------------------------------------------*/
    7083/** Get number of commands used in IRQ code.
    7184 * @return Number of commands.
     
    7689}
    7790/*----------------------------------------------------------------------------*/
    78 /** Generate IRQ code commands.
    79  * @param[out] cmds Place to store the commands.
    80  * @param[in] cmd_size Size of the place (bytes).
     91/** Generate IRQ code.
     92 * @param[out] ranges PIO ranges buffer.
     93 * @param[in] ranges_size Size of the ranges buffer (bytes).
     94 * @param[out] cmds Commands buffer.
     95 * @param[in] cmds_size Size of the commands buffer (bytes).
    8196 * @param[in] regs Physical address of device's registers.
    8297 * @param[in] reg_size Size of the register area (bytes).
     
    8499 * @return Error code.
    85100 */
    86 int hc_get_irq_commands(
    87     irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size)
    88 {
    89         if (cmd_size < sizeof(uhci_irq_commands)
    90             || reg_size < sizeof(uhci_regs_t))
     101int
     102hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[],
     103    size_t cmds_size, uintptr_t regs, size_t reg_size)
     104{
     105        if ((ranges_size < sizeof(uhci_irq_pio_ranges)) ||
     106            (cmds_size < sizeof(uhci_irq_commands)) ||
     107            (reg_size < sizeof(uhci_regs_t)))
    91108                return EOVERFLOW;
    92109
    93         uhci_regs_t *registers = (uhci_regs_t*)regs;
     110        memcpy(ranges, uhci_irq_pio_ranges, sizeof(uhci_irq_pio_ranges));
     111        ranges[0].base = regs;
    94112
    95113        memcpy(cmds, uhci_irq_commands, sizeof(uhci_irq_commands));
    96 
    97         cmds[0].addr = (void*)&registers->usbsts;
    98         cmds[3].addr = (void*)&registers->usbsts;
     114        uhci_regs_t *registers = (uhci_regs_t *) regs;
     115        cmds[0].addr = &registers->usbsts;
     116        cmds[3].addr = &registers->usbsts;
     117
    99118        return EOK;
    100119}
  • uspace/drv/bus/usb/uhci/hc.h

    ra996ae31 rd57122c  
    121121} hc_t;
    122122
     123size_t hc_irq_pio_range_count(void);
    123124size_t hc_irq_cmd_count(void);
    124 int hc_get_irq_commands(
    125     irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size);
     125int hc_get_irq_code(irq_pio_range_t [], size_t, irq_cmd_t [], size_t, uintptr_t,
     126    size_t);
    126127void hc_interrupt(hc_t *instance, uint16_t status);
    127128int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interupts);
  • uspace/drv/bus/usb/uhci/uhci.c

    ra996ae31 rd57122c  
    198198            "Failed to disable legacy USB: %s.\n", str_error(ret));
    199199
    200         const size_t cmd_count = hc_irq_cmd_count();
    201         irq_cmd_t irq_cmds[cmd_count];
    202         ret =
    203             hc_get_irq_commands(irq_cmds, sizeof(irq_cmds), reg_base, reg_size);
     200        const size_t ranges_count = hc_irq_pio_range_count();
     201        const size_t cmds_count = hc_irq_cmd_count();
     202        irq_pio_range_t irq_ranges[ranges_count];
     203        irq_cmd_t irq_cmds[cmds_count];
     204        ret = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds,
     205            sizeof(irq_cmds), reg_base, reg_size);
    204206        CHECK_RET_DEST_FREE_RETURN(ret,
    205207            "Failed to generate IRQ commands: %s.\n", str_error(ret));
    206208
    207         irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds };
     209        irq_code_t irq_code = {
     210                .rangecount = ranges_count,
     211                .ranges = irq_ranges,
     212                .cmdcount = cmds_count,
     213                .cmds = irq_cmds
     214        };
    208215
    209216        /* Register handler to avoid interrupt lockup */
Note: See TracChangeset for help on using the changeset viewer.