LumaOS  v0.1.116
An experimental x86-64 OS
Loading...
Searching...
No Matches
pmm.h
Go to the documentation of this file.
1
9
10#ifndef KERNEL_MM_PMM_H
11#define KERNEL_MM_PMM_H
12
13#include <limine/limine.h>
14
15#define FRAME_SIZE 4096ULL
16#define FRAME_SHIFT 12
17
19struct pmm_state {
21 uint64_t *bitmap;
23 uint64_t frame_count;
25 uint64_t free_frames;
27 uint64_t next_hint;
28};
29
34void pmm_init(const struct limine_memmap_response *memmap_response);
35
40struct pmm_state get_pmm_state(void);
41
46uint64_t pmm_alloc_frame(void);
47
53uint64_t pmm_alloc_contiguous(uint64_t count);
54
59uint64_t pmm_alloc_zeroed(void);
60
66uint64_t pmm_alloc_zeroed_contiguous(uint64_t count);
67
72void pmm_free_frame(uint64_t physical_addr);
73
74#endif
uint64_t pmm_alloc_frame(void)
Allocate a frame from the physical memory manager.
Definition pmm.c:112
uint64_t pmm_alloc_contiguous(uint64_t count)
Allocates count contiguous frames from the physical memory manager.
Definition pmm.c:134
void pmm_free_frame(uint64_t physical_addr)
Frees a frame from the physical memory manager.
Definition pmm.c:227
void pmm_init(const struct limine_memmap_response *memmap_response)
Initialize the physical memory manager.
Definition pmm.c:23
uint64_t pmm_alloc_zeroed_contiguous(uint64_t count)
Allocate and zero count contiguous frames from the physical memory manager.
Definition pmm.c:215
struct pmm_state get_pmm_state(void)
Get the current pmm state.
Definition pmm.c:19
uint64_t pmm_alloc_zeroed(void)
Allocate and zero a frame from the physical memory manager.
Definition pmm.c:204
Holds the state of the physical memory manager and information about its memory.
Definition pmm.h:19
uint64_t free_frames
how many frames are currently free
Definition pmm.h:25
uint64_t * bitmap
virtual address (through the HHDM) of the bitmap
Definition pmm.h:21
uint64_t next_hint
word index where the next search starts
Definition pmm.h:27
uint64_t frame_count
number of frames the bitmap covers
Definition pmm.h:23