The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
mm.c File Reference
#include "mm.h"
#include "memory_layout.h"
#include "mman.h"
#include "page.h"
#include "pmm.h"
#include "vma.h"
#include "arch/arch.h"
#include "kernel/memory/tlb.h"

Macros

#define UNMAP_BATCH   32
 mm_unmap, with the page lock held by the caller.

Functions

kerr_t mm_unmap (process_t *proc, uintptr_t start, uintptr_t end)
 changing a process's user mappings: unmap and protect ranges, keeping the process's areas (vma.h) and its page tables in step.
kerr_t mm_protect (process_t *proc, uintptr_t start, uintptr_t end, uint32_t prot)
 change the protection of [start, end) in a process.

Macro Definition Documentation

◆ UNMAP_BATCH

#define UNMAP_BATCH   32

mm_unmap, with the page lock held by the caller.

Function Documentation

◆ mm_unmap()

kerr_t mm_unmap ( process_t * proc,
uintptr_t start,
uintptr_t end )

changing a process's user mappings: unmap and protect ranges, keeping the process's areas (vma.h) and its page tables in step.

unmap [start, end) from a process: every mapped page is removed (frames from RAM are freed; device frames are not) and the areas are trimmed. unmapped parts of the range are not an error.

Parameters
procthe process.
startfirst byte (page-aligned, user space).
endfirst byte past the range (page-aligned).
Returns
KERR_OK, KERR_INVAL for a bad range, KERR_NOSPC if splitting an area needs a slot and the table is full (nothing is unmapped then).

◆ mm_protect()

kerr_t mm_protect ( process_t * proc,
uintptr_t start,
uintptr_t end,
uint32_t prot )

change the protection of [start, end) in a process.

pages already backed get the new permissions now; the rest are backed with them on first touch. PROT_NONE keeps the pages but makes them inaccessible to user code.

Parameters
procthe process.
startfirst byte (page-aligned, user space).
endfirst byte past the range (page-aligned).
protthe new PROT_* bits.
Returns
KERR_OK, KERR_INVAL for a bad range, KERR_NOENT if part of the range is not mapped, KERR_NOSPC if the areas cannot be split.