Kernelite 0.1.0
Kernelite is a minimalist, educational operating system kernel built from scratch. The project aims to recreate core components of the Linux architecture to explore the fundamentals of operating system design and hardware-software interaction.
Loading...
Searching...
No Matches
page_allocator.h
Go to the documentation of this file.
1
12#ifndef ALLOCATOR_PAGE_ALLOCATOR_H
13#define ALLOCATOR_PAGE_ALLOCATOR_H
14
17
18#include <stdbool.h>
19#include <stddef.h>
20#include <stdint.h>
21
23#define PHYS_ADDR_NULL ((phy_addr)NULL)
24
38bool page_allocator_add_region(phy_addr mem_start, size_t mem_size,
39 bool check_kernel_overlap);
40
51
54void fixup_page_allocator(void);
55
65bool reserve_page(phy_addr start, size_t num_pages);
66
76phy_addr page_alloc(size_t num_pages);
77
86void page_free(phy_addr start, size_t num_pages);
87
94void page_dump_status(void);
95
96#ifdef RUN_TESTS
97
104void invalidate_all_memory_chunks(void);
105
116void get_bitmap_addr_and_size(phy_addr addr, phy_addr *bitmap_addr,
117 size_t *bitmap_size);
118
119#endif /* RUN_TESTS */
120
121#endif /* ALLOCATOR_PAGE_ALLOCATOR_H */
Memory layout definitions.
uint64_t phy_addr
Type for representing physical addresses.
Definition mem_layout.h:17
void fixup_page_allocator(void)
Rewrites allocator bitmap pointers after the switch to high virtual addresses.
Definition page_allocator.c:429
void page_dump_status(void)
Scans the bitmap and prints the status of all memory regions.
Definition page_allocator.c:485
void page_free(phy_addr start, size_t num_pages)
Frees a previously allocated block of physical pages.
Definition page_allocator.c:474
bool reserve_page(phy_addr start, size_t num_pages)
Reserves a specific number of contiguous pages.
Definition page_allocator.c:451
bool page_allocator_add_region(phy_addr mem_start, size_t mem_size, bool check_kernel_overlap)
Registers a new physical memory region with the allocator.
Definition page_allocator.c:388
bool page_allocator_remove_region(phy_addr mem_start)
Removes a previously registered memory region.
Definition page_allocator.c:412
phy_addr page_alloc(size_t num_pages)
Allocates a contiguous block of physical pages.
Definition page_allocator.c:462
Page table definitions and helpers for virtual memory mapping.