Ignore:
Timestamp:
2019-04-06T16:14:01Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3ef901d0
Parents:
46e886f
Message:

Pass physical address / port to ns16550_init

We need to know the physical address of the device's registers so that
we can put it into the registered parea.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/drivers/ns16550/ns16550.c

    r46e886f r82dcd25  
    3939#include <genarch/drivers/ns16550/ns16550.h>
    4040#include <ddi/irq.h>
     41#include <ddi/ddi.h>
    4142#include <arch/asm.h>
    4243#include <console/chardev.h>
    4344#include <stdlib.h>
     45#include <align.h>
    4446#include <str.h>
    4547
     
    143145 *
    144146 */
    145 ns16550_instance_t *ns16550_init(ioport8_t *dev, unsigned reg_shift, inr_t inr,
    146     cir_t cir, void *cir_arg, outdev_t **output)
    147 {
    148         ns16550_instance_t *instance =
    149             malloc(sizeof(ns16550_instance_t));
     147ns16550_instance_t *ns16550_init(ioport8_t *dev_phys, unsigned reg_shift,
     148    inr_t inr, cir_t cir, void *cir_arg, outdev_t **output)
     149{
     150        size_t size = 6 * (1U << reg_shift);
     151        ioport8_t *dev = pio_map((void *) dev_phys, size);
     152
     153        ns16550_instance_t *instance = malloc(sizeof(ns16550_instance_t));
    150154        if (instance) {
    151155                instance->ns16550 = dev;
     
    158162                        if (!instance->output) {
    159163                                free(instance);
     164                                pio_unmap((void *) dev_phys, (void *) dev,
     165                                    size);
    160166                                return NULL;
    161167                        }
     
    176182
    177183                ddi_parea_init(&instance->parea);
    178                 instance->parea.pbase = (uintptr_t) dev;
    179                 instance->parea.frames = 1;
     184                instance->parea.pbase = ALIGN_DOWN((uintptr_t) dev_phys,
     185                    PAGE_SIZE);
     186                instance->parea.frames = ALIGN_UP(size, PAGE_SIZE);
    180187                instance->parea.unpriv = false;
    181188                instance->parea.mapped = false;
Note: See TracChangeset for help on using the changeset viewer.