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


Ignore:
Timestamp:
2013-09-12T22:05:13Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4285851
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/ohci/hc.c

    r695b6ff rddd0499d  
    106106 * @param[out] cmds Commands buffer.
    107107 * @param[in] cmds_size Size of the commands buffer (bytes).
    108  * @param[in] regs Physical address of device's registers.
    109  * @param[in] reg_size Size of the register area (bytes).
     108 * @param[in] regs Device's register range.
    110109 *
    111110 * @return Error code.
     
    113112int
    114113hc_get_irq_code(irq_pio_range_t ranges[], size_t ranges_size, irq_cmd_t cmds[],
    115     size_t cmds_size, uintptr_t regs, size_t reg_size)
     114    size_t cmds_size, addr_range_t *regs)
    116115{
    117116        if ((ranges_size < sizeof(ohci_pio_ranges)) ||
    118117            (cmds_size < sizeof(ohci_irq_commands)) ||
    119             (reg_size < sizeof(ohci_regs_t)))
     118            (RNGSZ(*regs) < sizeof(ohci_regs_t)))
    120119                return EOVERFLOW;
    121120
    122121        memcpy(ranges, ohci_pio_ranges, sizeof(ohci_pio_ranges));
    123         ranges[0].base = regs;
     122        ranges[0].base = RNGABS(*regs);
    124123
    125124        memcpy(cmds, ohci_irq_commands, sizeof(ohci_irq_commands));
    126         ohci_regs_t *registers = (ohci_regs_t *) regs;
     125        ohci_regs_t *registers = (ohci_regs_t *) RNGABSPTR(*regs);
    127126        cmds[0].addr = (void *) &registers->interrupt_status;
    128127        cmds[3].addr = (void *) &registers->interrupt_status;
     
    135134 *
    136135 * @param[in] device Host controller DDF device
    137  * @param[in] reg_base Register range base
    138  * @param[in] reg_size Register range size
     136 * @param[in] regs Register range
    139137 * @param[in] irq Interrupt number
    140138 * @paran[in] handler Interrupt handler
     
    142140 * @return EOK on success or negative error code
    143141 */
    144 int hc_register_irq_handler(ddf_dev_t *device, uintptr_t reg_base, size_t reg_size,
    145     int irq, interrupt_handler_t handler)
     142int hc_register_irq_handler(ddf_dev_t *device, addr_range_t *regs, int irq,
     143    interrupt_handler_t handler)
    146144{
    147145        int rc;
     
    158156
    159157        rc = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds,
    160             sizeof(irq_cmds), reg_base, reg_size);
     158            sizeof(irq_cmds), regs);
    161159        if (rc != EOK) {
    162160                usb_log_error("Failed to generate IRQ code: %s.\n",
     
    259257 *
    260258 * @param[in] instance Memory place for the structure.
    261  * @param[in] regs Address of the memory mapped I/O registers.
    262  * @param[in] reg_size Size of the memory mapped area.
     259 * @param[in] regs Device's I/O registers range.
    263260 * @param[in] interrupts True if w interrupts should be used
    264261 * @return Error code
    265262 */
    266 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts)
    267 {
    268         assert(instance);
    269 
    270         int rc =
    271             pio_enable((void*)regs, reg_size, (void**)&instance->registers);
     263int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
     264{
     265        assert(instance);
     266
     267        int rc = pio_enable_range(regs, (void **) &instance->registers);
    272268        if (rc != EOK) {
    273269                usb_log_error("Failed to gain access to device registers: %s.\n",
Note: See TracChangeset for help on using the changeset viewer.