The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
mmio.c File Reference
#include "mmio.h"
#include "memory_layout.h"
#include "page.h"
#include "arch/arch.h"
#include "kernel/sync/spinlock.h"

Macros

#define MAP_CACHED   0
#define MAP_UNCACHED   1
#define MAP_WRITE_COMBINING   2

Functions

void mmio_init (void)
 mapping device memory (MMIO) into the kernel.
void * ioremap (phys_addr_t phys, size_t size)
 map a range of device memory into the kernel.
void * ioremap_nocache (phys_addr_t phys, size_t size)
 map a range of device registers into the kernel, not cached (each access goes to the device).
void * ioremap_wc (phys_addr_t phys, size_t size)
 map memory such as a framebuffer write-combining (uncached if the CPU has no PAT): writes are combined into bursts, reads are slow.

Macro Definition Documentation

◆ MAP_CACHED

#define MAP_CACHED   0

◆ MAP_UNCACHED

#define MAP_UNCACHED   1

◆ MAP_WRITE_COMBINING

#define MAP_WRITE_COMBINING   2

Function Documentation

◆ mmio_init()

void mmio_init ( void )

mapping device memory (MMIO) into the kernel.

device memory such as a linear framebuffer sits outside RAM, so the direct map of RAM does not cover it. ioremap maps it into a kernel-only window (MMIO_REGION_BASE..MMIO_REGION_END) shared by every address space. mappings are permanent: devices are never unplugged. reserve the MMIO window. must run after paging_init() and before the first address space is created.

◆ ioremap()

void * ioremap ( phys_addr_t phys,
size_t size )

map a range of device memory into the kernel.

Parameters
physphysical address of the device memory (need not be aligned).
sizenumber of bytes.
Returns
kernel pointer to phys, or NULL if the window is exhausted.

◆ ioremap_nocache()

void * ioremap_nocache ( phys_addr_t phys,
size_t size )

map a range of device registers into the kernel, not cached (each access goes to the device).

use this for controller registers; ioremap is for memory such as a framebuffer.

Parameters
physphysical address of the registers (need not be aligned).
sizenumber of bytes.
Returns
kernel pointer to phys, or NULL if the window is exhausted.

◆ ioremap_wc()

void * ioremap_wc ( phys_addr_t phys,
size_t size )

map memory such as a framebuffer write-combining (uncached if the CPU has no PAT): writes are combined into bursts, reads are slow.

Parameters
physphysical address (need not be aligned).
sizenumber of bytes.
Returns
kernel pointer to phys, or NULL if the window is exhausted.