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

    r695b6ff rddd0499d  
    145145 *
    146146 * @param dev       Driver structure to initialize.
    147  * @param regs      I/O address of registers.
    148  * @param reg_size  size of the reserved I/O address space.
     147 * @param regs      I/O range  of registers.
    149148 * @param irq_kbd   IRQ for primary port.
    150149 * @param irq_mouse IRQ for aux port.
     
    154153 *
    155154 */
    156 int i8042_init(i8042_t *dev, void *regs, size_t reg_size, int irq_kbd,
     155int i8042_init(i8042_t *dev, addr_range_t *regs, int irq_kbd,
    157156    int irq_mouse, ddf_dev_t *ddf_dev)
    158157{
     
    162161        const size_t cmd_count = sizeof(i8042_cmds) / sizeof(irq_cmd_t);
    163162        irq_cmd_t cmds[cmd_count];
     163        i8042_regs_t *ar;
    164164
    165165        int rc;
     
    170170        dev->aux_fun = NULL;
    171171       
    172         if (reg_size < sizeof(i8042_regs_t)) {
     172        if (regs->size < sizeof(i8042_regs_t)) {
    173173                rc = EINVAL;
    174174                goto error;
    175175        }
    176176       
    177         if (pio_enable(regs, sizeof(i8042_regs_t), (void **) &dev->regs) != 0) {
     177        if (pio_enable_range(regs, (void **) &dev->regs) != 0) {
    178178                rc = EIO;
    179179                goto error;
     
    234234
    235235        memcpy(ranges, i8042_ranges, sizeof(i8042_ranges));
    236         ranges[0].base = (uintptr_t) regs;
    237 
     236        ranges[0].base = RNGABS(*regs);
     237
     238
     239        ar = RNGABSPTR(*regs);
    238240        memcpy(cmds, i8042_cmds, sizeof(i8042_cmds));
    239         cmds[0].addr = (void *) &(((i8042_regs_t *) regs)->status);
    240         cmds[3].addr = (void *) &(((i8042_regs_t *) regs)->data);
     241        cmds[0].addr = (void *) &ar->status;
     242        cmds[3].addr = (void *) &ar->data;
    241243
    242244        irq_code_t irq_code = {
Note: See TracChangeset for help on using the changeset viewer.