Changeset ddd0499d in mainline for uspace/drv/char/i8042/main.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/char/i8042/main.c

    r695b6ff rddd0499d  
    4949 *
    5050 * @param[in]  dev            Device asking for the addresses.
    51  * @param[out] io_reg_address Base address of the memory range.
    52  * @param[out] io_reg_size    Size of the memory range.
     51 * @param[out] p_io_reg       Pointer to register range.
    5352 * @param[out] kbd_irq        Primary port IRQ.
    5453 * @param[out] mouse_irq      Auxiliary port IRQ.
     
    5756 *
    5857 */
    59 static int get_my_registers(ddf_dev_t *dev, uintptr_t *io_reg_address,
    60     size_t *io_reg_size, int *kbd_irq, int *mouse_irq)
     58static int get_my_registers(ddf_dev_t *dev, addr_range_t *p_io_reg,
     59    int *kbd_irq, int *mouse_irq)
    6160{
    6261        assert(dev);
     
    7978        }
    8079       
    81         if (io_reg_address)
    82                 *io_reg_address = hw_resources.io_ranges.ranges[0].address;
    83        
    84         if (io_reg_size)
    85                 *io_reg_size = hw_resources.io_ranges.ranges[0].size;
     80        if (p_io_reg)
     81                *p_io_reg = hw_resources.io_ranges.ranges[0];
    8682       
    8783        if (kbd_irq)
     
    104100static int i8042_dev_add(ddf_dev_t *device)
    105101{
    106         uintptr_t io_regs = 0;
    107         size_t io_size = 0;
     102        addr_range_t io_regs;
    108103        int kbd = 0;
    109104        int mouse = 0;
     
    113108                return EINVAL;
    114109       
    115         rc = get_my_registers(device, &io_regs, &io_size, &kbd, &mouse);
     110        rc = get_my_registers(device, &io_regs, &kbd, &mouse);
    116111        if (rc != EOK) {
    117112                ddf_msg(LVL_ERROR, "Failed to get registers: %s.",
     
    120115        }
    121116       
    122         ddf_msg(LVL_DEBUG, "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.",
    123             (void *) io_regs, io_size, kbd, mouse);
     117        ddf_msg(LVL_DEBUG,
     118            "I/O regs at %p (size %zuB), IRQ kbd %d, IRQ mouse %d.",
     119            RNGABSPTR(io_regs), RNGSZ(io_regs), kbd, mouse);
    124120       
    125121        i8042_t *i8042 = ddf_dev_data_alloc(device, sizeof(i8042_t));
     
    129125        }
    130126       
    131         rc = i8042_init(i8042, (void *) io_regs, io_size, kbd, mouse, device);
     127        rc = i8042_init(i8042, &io_regs, kbd, mouse, device);
    132128        if (rc != EOK) {
    133129                ddf_msg(LVL_ERROR, "Failed to initialize i8042 driver: %s.",
Note: See TracChangeset for help on using the changeset viewer.