AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
buddy.h
Go to the documentation of this file.
1
#ifndef _MM_BUDDY_H
2
#define _MM_BUDDY_H
3
4
#include <
mm/mm.h
>
5
6
/* The buddy allocator (mm/buddy.c): physical memory, in blocks of 2^n
7
* pages. */
8
9
/* The largest order, and the smallest and largest block sizes. */
10
#define BUDDY_MAX_ORDER (10)
11
#define BUDDY_MIN_BS (4096)
12
#define BUDDY_MAX_BS (BUDDY_MIN_BS << BUDDY_MAX_ORDER)
13
14
/* The zones of RAM: below 16 MiB (for ISA DMA), and above. */
15
#define BUDDY_ZONE_NR 2
16
#define BUDDY_ZONE_DMA 0
17
#define BUDDY_ZONE_NORMAL 1
18
19
/* Where each zone starts. */
20
extern
uintptr_t
buddy_zone_offset
[];
21
22
/* Sets up the allocator; allocates and frees blocks; marks memory used at
23
* boot. */
24
int
buddy_setup
(
size_t
total_mem);
25
paddr_t
buddy_alloc
(
int
zone,
size_t
size);
26
void
buddy_free
(
int
zone,
paddr_t
paddr,
size_t
size);
27
void
buddy_set_unusable
(
paddr_t
paddr,
size_t
size);
28
29
#endif
/* !_MM_BUDDY_H */
paddr_t
uint64_t paddr_t
Definition
mm.h:39
mm.h
buddy_free
void buddy_free(int zone, paddr_t paddr, size_t size)
Frees a block that buddy_alloc() gave.
Definition
buddy.c:183
buddy_set_unusable
void buddy_set_unusable(paddr_t paddr, size_t size)
Marks a range of physical memory as not free, at boot, before the first allocation: the kernel,...
Definition
buddy.c:212
buddy_alloc
paddr_t buddy_alloc(int zone, size_t size)
Allocates a block of physical memory from a zone, rounded up to a power of two pages.
Definition
buddy.c:149
buddy_zone_offset
uintptr_t buddy_zone_offset[]
Definition
buddy.c:49
buddy_setup
int buddy_setup(size_t total_mem)
Sets up the allocator at boot: a bitmap for each zone and order, every top-order block of RAM free,...
Definition
buddy.c:328
uintptr_t
__SIZE_TYPE__ uintptr_t
Definition
stddef.h:12
kernel
include
mm
buddy.h
Generated by
1.18.0