|
AquilaOS documentation
How it works, and its code
|
#include <mm/mm.h>Go to the source code of this file.
Macros | |
| #define | BUDDY_MAX_ORDER (10) |
| #define | BUDDY_MIN_BS (4096) |
| #define | BUDDY_MAX_BS (BUDDY_MIN_BS << BUDDY_MAX_ORDER) |
| #define | BUDDY_ZONE_NR 2 |
| #define | BUDDY_ZONE_DMA 0 |
| #define | BUDDY_ZONE_NORMAL 1 |
Functions | |
| 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, then the kernel and its symbol tables set unusable. | |
| 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. | |
| void | buddy_free (int zone, paddr_t paddr, size_t size) |
| Frees a block that buddy_alloc() gave. | |
| 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, the modules, the firmware's ranges. | |
Variables | |
| uintptr_t | buddy_zone_offset [] |
| #define BUDDY_MAX_BS (BUDDY_MIN_BS << BUDDY_MAX_ORDER) |
Definition at line 12 of file buddy.h.
Referenced by buddy_alloc(), buddy_reserved_done(), buddy_set_unusable(), buddy_setup(), and mm_setup().
| #define BUDDY_MAX_ORDER (10) |
Definition at line 10 of file buddy.h.
Referenced by buddy_alloc(), buddy_free(), buddy_recursive_alloc(), buddy_recursive_free(), buddy_reserved_done(), buddy_set_unusable(), buddy_setup(), and procfs_buddyinfo().
| #define BUDDY_MIN_BS (4096) |
Definition at line 11 of file buddy.h.
Referenced by buddy_alloc(), buddy_free(), buddy_reserved_done(), and buddy_set_unusable().
| #define BUDDY_ZONE_DMA 0 |
Definition at line 16 of file buddy.h.
Referenced by mm_page_alloc(), and mm_page_dealloc().
| #define BUDDY_ZONE_NORMAL 1 |
Definition at line 17 of file buddy.h.
Referenced by mm_page_alloc(), and mm_page_dealloc().
| #define BUDDY_ZONE_NR 2 |
Definition at line 15 of file buddy.h.
Referenced by buddy_reserved_done(), buddy_set_unusable(), buddy_setup(), and procfs_buddyinfo().
Allocates a block of physical memory from a zone, rounded up to a power of two pages.
| zone | the zone to take it from (BUDDY_ZONE_DMA or BUDDY_ZONE_NORMAL) |
| _sz | the size wanted, in bytes, at most BUDDY_MAX_BS |
Definition at line 149 of file buddy.c.
References buddy_alloc(), BUDDY_MAX_BS, BUDDY_MAX_ORDER, BUDDY_MIN_BS, buddy_recursive_alloc(), buddy_reserved_done(), buddy_zone_offset, k_used_mem, panic, and reserved_done.
Referenced by buddy_alloc(), and mm_page_alloc().
Frees a block that buddy_alloc() gave.
| zone | the zone it came from |
| addr | its physical address |
| size | the size that was asked for, in bytes |
Definition at line 183 of file buddy.c.
References buddy_free(), BUDDY_MAX_ORDER, BUDDY_MIN_BS, buddy_recursive_free(), buddy_zone_offset, k_used_mem, kend, kstart, and panic.
Referenced by buddy_free(), and mm_page_dealloc().
Marks a range of physical memory as not free, at boot, before the first allocation: the kernel, the modules, the firmware's ranges.
| addr | the range's start |
| size | its size, in bytes (0 does nothing) |
Definition at line 212 of file buddy.c.
References buddy::bitmap, buddies, BUDDY_MAX_BS, BUDDY_MAX_ORDER, BUDDY_MIN_BS, buddy_set_unusable(), BUDDY_ZONE_NR, buddy_zone_offset, buddy::first_free_idx, MAX, bitmap::max_idx, MIN, panic, printk(), reserved, reserved_done, RESERVED_MAX, reserved_nr, and buddy::usable.
Referenced by arch_mm_setup(), buddy_set_unusable(), buddy_setup(), mm_mark_unusable(), and mm_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, then the kernel and its symbol tables set unusable.
| total_mem | the end of RAM, in bytes |
Definition at line 328 of file buddy.c.
References __kboot, alloc(), buddy::bitmap, bitmap_clear_range(), bitmap_set_range(), bitmap_size(), buddies, BUDDY_MAX_BS, BUDDY_MAX_ORDER, buddy_set_unusable(), buddy_setup(), BUDDY_ZONE_NR, buddy_zone_offset, buddy::first_free_idx, k_total_mem, k_used_mem, kend, kernel_end, kstart, LMA, bitmap::map, bitmap::max_idx, MIN, printk(), elf32_shdr::sh_addr, elf32_shdr::sh_size, boot::shdr, boot::strtab, boot::symtab, buddy::usable, and zone_blocks.
Referenced by buddy_setup(), and mm_setup().
|
extern |
Definition at line 49 of file buddy.c.
Referenced by buddy_alloc(), buddy_free(), buddy_reserved_done(), buddy_set_unusable(), buddy_setup(), and mm_page_dealloc().