#pragma once

#include <efi.h>

#define PAGE_SIZE   4096
#define PAGE_SHIFT  12
#define PAGE_MASK   (~(PAGE_SIZE - 1ULL))

typedef struct {
    UINT8*  bitmap;
    UINTN   bitmap_size;
    UINTN   total_pages;
    UINTN   free_pages;
    void*   free_list_head;
    UINT64  base_addr;
    UINT64  max_addr;
} pmm_t;

extern pmm_t g_pmm;

EFI_STATUS  pmm_init();
void*       pmm_alloc_pages(UINTN n);
void        pmm_free_pages(void* addr, UINTN n);
UINTN       pmm_get_free_count();
BOOLEAN     pmm_is_page_free(void* addr);
