42_KFS/headers/memory.h

27 lines
708 B
C

#pragma once
#include <stddef.h>
#include <stdint.h>
#define PRESENT (1 << 0)
#define RW (1 << 1)
#define SUPERVISOR (0 << 2)
#define ACCESSED (1 << 4)
#define INIT_FLAGS (PRESENT | RW | SUPERVISOR)
#define PAGE_SIZE 4096
#define PT_SIZE 1024
#define PD_SIZE 1024
#define PAGE_MASK 0xFFFFF000
#define HEAP_END 0xC0000000
extern uint32_t boot_page_directory;
extern uint32_t *page_directory;
extern uint32_t page_table_default[1024];
uint32_t *virt_to_phys(uint32_t *virt_addr);
void init_memory(void);
void *alloc_frames(size_t size);
int free_frames(void *frame_ptr, size_t size);
void *alloc_pages(size_t size, uint32_t **frame_ptr);
int free_pages(void *page_ptr, size_t size);