VMAP(9) VMAP(9)
NAME
vmap. vmappat - physical to virtual mapping
SYNOPSIS
#include "fns.h"
enum {
PATUC = 0, /* uncachable */
PATWC = 1, /* use write-combining buffers */
PATWT = 4, /* write-through */
PATWP = 5, /* write protect */
PATWB = 6, /* write back */
PATUCMINUS = 7, /* UC-; strongly uncacheable */
};
void* vmap(uintmem base, usize size)
void* vmappat(uintmem base, usize size, uint pattype)
void vunmap(void*)
int vmapsync(uintmem addr)
DESCRIPTION
Vmap creates and returns a virtual address for the physical
address base on the local processor. The most common use
for this is to map PCI BARs.
The actual map may be larger than the requested size if the
base is not smallest page-aligned or the size is not a mul-
tiple of the smallest page size. It is an error to map the
same region of memory twice, but overlap is calculated
before rounding to smallest page size. It is also an error
to map an unknown region. The default memory type is
uncachable memory, or PATUC. But vmappat allows the memory
type to be user-selected.
If the new map is accessed on another processor it will
fault. Fault can restore the mapping with vmapsync, which
returns 0 if a matching map is found and restored, and -1
otherwise.
SOURCE
/sys/src/nix/*/mmu.c
SEE ALSO
adr(9nix)
DIAGNOSTICS
Vmap and Vmappat return nil on failure. Vmapsync returns -1
if no map is found.
BUGS
Page 1 Plan 9 (printed 11/8/25)
VMAP(9) VMAP(9)
PAT is x86- and x86-64-specific.
Page 2 Plan 9 (printed 11/8/25)