#ifndef _KERNEL_SYS_MM_H
#define _KERNEL_SYS_MM_H

#include <libk/std.h>
#include <sync/spin_lock.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)

uintptr_t mm_alloc_user_pd_phys (void);
void mm_kernel_lock (void);
void mm_kernel_unlock (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);
void mm_unmap_kernel_page (uintptr_t vaddr);
bool mm_validate (struct pd* pd, uintptr_t vaddr);
bool mm_validate_buffer (struct pd* pd, uintptr_t vaddr, size_t size);
uintptr_t mm_p2v (struct pd* pd, uintptr_t paddr);
uintptr_t mm_v2p (struct pd* pd, uintptr_t vaddr);
struct pd* mm_get_kernel_pd (void);
void mm_init (void);

#endif // _KERNEL_SYS_MM_H
