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


Ignore:
Timestamp:
2013-09-12T22:05:13Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4285851b
Parents:
695b6ff (diff), 7de1988c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Support for PIO window-relative and absolute HW resource ranges.

The goal of this merge is to allow bus drivers to pass resources with IO
and memory ranges to the child drivers either in the PIO window-relative
form or system bus absolute form. Using the PIO window and the
relative/absolute attribute of a range, each driver can now reconstruct
both forms. Helper functions are provided to automate these
transformations as much as possible.

Changes in this merge in a greater detail:

  • Support for PIO_WINDOW_DEV_IFACE in isa so that it can provide the PIO window to its children.
  • Add 'relative' member to both hw_resource_t.res.mem_range and hw_resource_t.res.io_range so that the drivers can actually tell whether a range is absolute (eg. it was absolutized by its parent).
  • Add pio_enable_resource() to allow drivers to enable PIO without the need to actually care about what kind of range the resource contains. This is used by pci now.
  • Automate things even more for drivers that use hw_res_get_list_parsed(). The parsed HW resources compute both forms (relative/absolute) and offer it to the driver which is using them. Such a driver then uses whatever form is more fit for it and its purposes.
  • Drivers using the parsed resources can use pio_enable_range() to enable PIO and RNGABS*()/RNGREL()/RNGSZ courtesy macros for easier access to the actual range address/size are provided.
  • Device drivers affected by these API changes were converted.
  • uhcirh now requires uhci to provide PIO_WINDOW_DEV_IFACE; however, the uhcirh driver is removed in the feature USB branch so there was no point in implementing this feature and UHCI USB is thus temporarily broken.
File:
1 edited

Legend:

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

    r695b6ff rddd0499d  
    105105 * @param[out] cmds Commands buffer.
    106106 * @param[in] cmds_size Size of the commands buffer (bytes).
    107  * @param[in] regs Physical address of device's registers.
    108  * @param[in] reg_size Size of the register area (bytes).
     107 * @param[in] regs Device's register range.
    109108 *
    110109 * @return Error code.
     
    112111int
    113112hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[],
    114     size_t cmds_size, uintptr_t regs, size_t reg_size)
     113    size_t cmds_size, addr_range_t *regs)
    115114{
    116115        if ((ranges_size < sizeof(uhci_irq_pio_ranges)) ||
    117116            (cmds_size < sizeof(uhci_irq_commands)) ||
    118             (reg_size < sizeof(uhci_regs_t)))
     117            (RNGSZ(*regs) < sizeof(uhci_regs_t)))
    119118                return EOVERFLOW;
    120119
    121120        memcpy(ranges, uhci_irq_pio_ranges, sizeof(uhci_irq_pio_ranges));
    122         ranges[0].base = regs;
     121        ranges[0].base = RNGABS(*regs);
    123122
    124123        memcpy(cmds, uhci_irq_commands, sizeof(uhci_irq_commands));
    125         uhci_regs_t *registers = (uhci_regs_t *) regs;
     124        uhci_regs_t *registers = (uhci_regs_t *) RNGABSPTR(*regs);
    126125        cmds[0].addr = &registers->usbsts;
    127126        cmds[3].addr = &registers->usbsts;
     
    133132 *
    134133 * @param[in] device Host controller DDF device
    135  * @param[in] reg_base Register range base
    136  * @param[in] reg_size Register range size
     134 * @param[in] regs Register range
    137135 * @param[in] irq Interrupt number
    138136 * @paran[in] handler Interrupt handler
     
    140138 * @return EOK on success or negative error code
    141139 */
    142 int hc_register_irq_handler(ddf_dev_t *device, uintptr_t reg_base, size_t reg_size,
    143     int irq, interrupt_handler_t handler)
     140int hc_register_irq_handler(ddf_dev_t *device, addr_range_t *regs, int irq,
     141    interrupt_handler_t handler)
    144142{
    145143        int rc;
     
    147145        irq_cmd_t irq_cmds[hc_irq_cmd_count];
    148146        rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds,
    149             sizeof(irq_cmds), reg_base, reg_size);
     147            sizeof(irq_cmds), regs);
    150148        if (rc != EOK) {
    151149                usb_log_error("Failed to generate IRQ commands: %s.\n",
     
    232230 *
    233231 * @param[in] instance Memory place to initialize.
    234  * @param[in] regs Address of I/O control registers.
    235  * @param[in] reg_size Size of I/O control registers.
     232 * @param[in] regs Range of device's I/O control registers.
    236233 * @param[in] interrupts True if hw interrupts should be used.
    237234 * @return Error code.
     
    241238 * interrupt fibrils.
    242239 */
    243 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interrupts)
    244 {
    245         assert(reg_size >= sizeof(uhci_regs_t));
     240int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
     241{
     242        assert(regs->size >= sizeof(uhci_regs_t));
    246243        int rc;
    247244
     
    251248        /* allow access to hc control registers */
    252249        uhci_regs_t *io;
    253         rc = pio_enable(regs, reg_size, (void **)&io);
     250        rc = pio_enable_range(regs, (void **) &io);
    254251        if (rc != EOK) {
    255252                usb_log_error("Failed to gain access to registers at %p: %s.\n",
     
    260257        instance->registers = io;
    261258        usb_log_debug(
    262             "Device registers at %p (%zuB) accessible.\n", io, reg_size);
     259            "Device registers at %p (%zuB) accessible.\n", io, regs->size);
    263260
    264261        rc = hc_init_mem_structures(instance);
Note: See TracChangeset for help on using the changeset viewer.