#ifndef _KERNEL_SYS_MM_H
#define _KERNEL_SYS_MM_H

#include <libk/std.h>

#if defined(__x86_64__)
#include <amd64/mm.h>
#endif

#define MM_PG_PRESENT (1 << 0)
#define MM_PG_RW      (1 << 1)
#define MM_PG_USER    (1 << 2)
#define MM_PD_RELOAD  (1 << 30)
#define MM_PD_LOCK    (1 << 31)

uintptr_t mm_alloc_user_pd_phys (void);
void mm_reload (void);
void mm_map_page (struct pd* pd, uintptr_t paddr, uintptr_t vaddr, uint32_t flags);
void mm_map_kernel_page (uintptr_t paddr, uintptr_t vaddr, uint32_t flags);
void mm_unmap_page (struct pd* pd, uintptr_t vaddr, uint32_t flags);
void mm_unmap_kernel_page (uintptr_t vaddr, uint32_t flags);
void mm_lock_kernel (void);
void mm_unlock_kernel (void);
bool mm_validate (struct pd* pd, uintptr_t vaddr, uint32_t flags);
bool mm_validate_buffer (struct pd* pd, uintptr_t vaddr, size_t size, uint32_t flags);
uintptr_t mm_p2v (struct pd* pd, uintptr_t paddr, uint32_t flags);
uintptr_t mm_v2p (struct pd* pd, uintptr_t vaddr, uint32_t flags);
void mm_init (void);

#endif // _KERNEL_SYS_MM_H
