Changeset dfe4955 in mainline for uspace/drv/bus/usb/uhci/hc.c


Ignore:
Timestamp:
2011-07-12T18:38:27Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
26858040
Parents:
b4f291d
Message:

UHCI: Mirror OHCI changes to generating irq code, and enabling interrupts.

Rename regs_t ⇒ uhci_regs_t

File:
1 edited

Legend:

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

    rb4f291d rdfe4955  
    4747    (UHCI_STATUS_INTERRUPT | UHCI_STATUS_ERROR_INTERRUPT)
    4848
     49static const irq_cmd_t uhci_irq_commands[] =
     50{
     51        { .cmd = CMD_PIO_READ_16, .dstarg = 1, .addr = NULL/*filled later*/},
     52        { .cmd = CMD_BTEST, .srcarg = 1, .dstarg = 2,
     53          .value = UHCI_STATUS_USED_INTERRUPTS | UHCI_STATUS_NM_INTERRUPTS },
     54        { .cmd = CMD_PREDICATE, .srcarg = 2, .value = 2 },
     55        { .cmd = CMD_PIO_WRITE_A_16, .srcarg = 1, .addr = NULL/*filled later*/},
     56        { .cmd = CMD_ACCEPT },
     57};
    4958
    5059static int hc_init_transfer_lists(hc_t *instance);
     
    5463static int hc_interrupt_emulator(void *arg);
    5564static int hc_debug_checker(void *arg);
     65
     66/*----------------------------------------------------------------------------*/
     67/** Get number of commands used in IRQ code.
     68 * @return Number of commands.
     69 */
     70size_t hc_irq_cmd_count(void)
     71{
     72        return sizeof(uhci_irq_commands) / sizeof(irq_cmd_t);
     73}
     74/*----------------------------------------------------------------------------*/
     75/** Generate IRQ code commands.
     76 * @param[out] cmds Place to store the commands.
     77 * @param[in] cmd_size Size of the place (bytes).
     78 * @param[in] regs Physical address of device's registers.
     79 * @param[in] reg_size Size of the register area (bytes).
     80 *
     81 * @return Error code.
     82 */
     83int hc_get_irq_commands(
     84    irq_cmd_t cmds[], size_t cmd_size, uintptr_t regs, size_t reg_size)
     85{
     86        if (cmd_size < sizeof(uhci_irq_commands)
     87            || reg_size < sizeof(uhci_regs_t))
     88                return EOVERFLOW;
     89
     90        uhci_regs_t *registers = (uhci_regs_t*)regs;
     91
     92        memcpy(cmds, uhci_irq_commands, sizeof(uhci_irq_commands));
     93
     94        cmds[0].addr = (void*)&registers->usbsts;
     95        cmds[3].addr = (void*)&registers->usbsts;
     96        return EOK;
     97}
    5698/*----------------------------------------------------------------------------*/
    5799/** Initialize UHCI hc driver structure
     
    69111int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interrupts)
    70112{
    71         assert(reg_size >= sizeof(regs_t));
     113        assert(reg_size >= sizeof(uhci_regs_t));
    72114        int ret;
    73115
     
    82124
    83125        /* allow access to hc control registers */
    84         regs_t *io;
     126        uhci_regs_t *io;
    85127        ret = pio_enable(regs, reg_size, (void **)&io);
    86128        CHECK_RET_RETURN(ret,
     
    116158{
    117159        assert(instance);
    118         regs_t *registers = instance->registers;
     160        uhci_regs_t *registers = instance->registers;
    119161
    120162        /* Reset everything, who knows what touched it before us */
Note: See TracChangeset for help on using the changeset viewer.