AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
mm.h
Go to the documentation of this file.
1
#ifndef _MM_MM_H
2
#define _MM_MM_H
3
4
#include <
core/system.h
>
5
6
/* Physical memory, and page faults (mm/mm.c, mm/fault.c). */
7
8
/* An address rounded down, or up, to a page. */
9
#define PAGE_ALIGN(ptr) ((ptr) & ~PAGE_MASK)
10
#define PAGE_ROUND(ptr) (((ptr) + PAGE_MASK) & ~PAGE_MASK)
11
12
#include <
boot/boot.h
>
13
14
/* What a page fault is: a page was mapped there; a read, a write or an
15
* instruction fetch; from user mode. */
16
#define PF_PRESENT 0x001
17
#define PF_READ 0x002
18
#define PF_WRITE 0x004
19
#define PF_EXEC 0x008
20
#define PF_USER 0x010
21
22
struct
pmap
;
23
24
/* Sets up physical memory at boot. */
25
void
mm_setup
(
struct
boot
*
boot
);
26
27
/* Allocates and frees pages, and counts their references. */
28
struct
vm_page
*
mm_page_alloc
(
void
);
29
void
mm_page_incref
(
paddr_t
paddr
);
30
void
mm_page_decref
(
paddr_t
paddr
);
31
size_t
mm_page_ref
(
paddr_t
paddr
);
32
void
mm_page_dealloc
(
paddr_t
paddr
);
33
34
/* Maps and unmaps pages in an address space. */
35
int
mm_page_map
(
struct
pmap
*
pmap
,
vaddr_t
vaddr,
paddr_t
paddr
,
int
flags);
36
int
mm_map
(
struct
pmap
*
pmap
,
paddr_t
paddr
,
vaddr_t
vaddr,
size_t
size,
int
flags);
37
void
mm_unmap_full
(
struct
pmap
*
pmap
,
vaddr_t
vaddr,
size_t
size);
38
39
/* Handles a page fault in the current process. */
40
int
mm_page_fault
(
vaddr_t
vaddr,
int
flags);
41
42
#endif
/* !_MM_MM_H */
paddr_t
uint64_t paddr_t
Definition
mm.h:39
vaddr_t
uint64_t vaddr_t
Definition
mm.h:40
boot.h
system.h
mm_page_decref
void mm_page_decref(paddr_t paddr)
Drops a reference to a page of RAM.
Definition
mm.c:50
mm_page_alloc
struct vm_page * mm_page_alloc(void)
Allocates a free page of physical memory.
Definition
mm.c:78
mm_page_fault
int mm_page_fault(vaddr_t vaddr, int flags)
Handles a page fault in the current process's address space.
Definition
fault.c:395
mm_page_map
int mm_page_map(struct pmap *pmap, vaddr_t vaddr, paddr_t paddr, int flags)
Maps a page into an address space.
Definition
mm.c:122
mm_map
int mm_map(struct pmap *pmap, paddr_t paddr, vaddr_t vaddr, size_t size, int flags)
Maps a range of an address space, page by page.
Definition
mm.c:161
mm_page_ref
size_t mm_page_ref(paddr_t paddr)
Returns how many references a page of RAM has.
Definition
mm.c:62
mm_page_dealloc
void mm_page_dealloc(paddr_t paddr)
Frees a page of physical memory, back to the zone it came from.
Definition
mm.c:103
mm_unmap_full
void mm_unmap_full(struct pmap *pmap, vaddr_t vaddr, size_t size)
Unmaps every page of a range of an address space.
Definition
mm.c:208
mm_page_incref
void mm_page_incref(paddr_t paddr)
Adds a reference to a page of RAM.
Definition
mm.c:39
mm_setup
void mm_setup(struct boot *boot)
Sets up physical memory at boot, from the boot loader's memory map: the page structures,...
Definition
mm.c:365
boot
Definition
boot.h:35
pmap
An address space's page tables, on x86.
Definition
pmap.h:9
vm_page
A page of physical memory (pages[] has one for every page of RAM).
Definition
vm.h:150
vm_page::paddr
paddr_t paddr
its physical address
Definition
vm.h:151
kernel
include
mm
mm.h
Generated by
1.18.0