peredOS/kernel/pmm.h

30 lines
1,007 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef PMM_H
#define PMM_H
#include <stdint.h>
#include "multiboot.h"
#define PAGE_SIZE 4096
// Инициализация: передаем инфу от GRUB и адрес конца ядра из линкера
void pmm_init(struct multiboot_info* mbi, uint32_t kernel_end);
// Выделить одну страницу памяти (возвращает физический адрес)
void* pmm_alloc_page(void);
// Освободить страницу памяти по адресу
void pmm_free_page(void* addr);
typedef struct {
uint32_t total_memory; // Всего памяти в байтах
uint32_t used_memory; // Занято в байтах
uint32_t free_memory; // Свободно в байтах
uint32_t total_pages; // Всего страниц
uint32_t used_pages; // Занято страниц
uint32_t free_pages; // Свободно страниц
} pmm_stats_t;
void pmm_get_stats(void);
pmm_stats_t* pmm_get_stats_ptr(void);
#endif