Changeset 46e886f in mainline for kernel/generic/src/ddi/ddi.c


Ignore:
Timestamp:
2019-04-06T16:10:08Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
82dcd25
Parents:
69c31ab
Message:

Add port/MM IO agnostic functions to map/unmap PIO

In kernel we have drivers that use port IO on one architecture and
MM IO on another. We therefore need some function which does the right
thing depending on the type of the register address.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ddi/ddi.c

    r69c31ab r46e886f  
    4646#include <mm/frame.h>
    4747#include <mm/as.h>
     48#include <mm/km.h>
    4849#include <mm/page.h>
    4950#include <synch/mutex.h>
     
    5657#include <trace.h>
    5758#include <bitops.h>
     59#include <arch/asm.h>
    5860
    5961/** This lock protects the @c pareas ordered dictionary. */
     
    527529                return dmamem_unmap_anonymous(virt);
    528530}
     531void *pio_map(void *phys, size_t size)
     532{
     533#ifdef IO_SPACE_BOUNDARY
     534        if (phys < IO_SPACE_BOUNDARY)
     535                return phys;
     536#endif
     537        return (void *) km_map((uintptr_t) phys, size, KM_NATURAL_ALIGNMENT,
     538            PAGE_READ | PAGE_WRITE | PAGE_NOT_CACHEABLE);
     539}
     540
     541void pio_unmap(void *phys, void *virt, size_t size)
     542{
     543#ifdef IO_SPACE_BOUNDARY
     544        if (phys < IO_SPACE_BOUNDARY)
     545                return;
     546#endif
     547        km_unmap((uintptr_t) virt, size);
     548}
    529549
    530550/** @}
Note: See TracChangeset for help on using the changeset viewer.