#ifndef _PAGING_H
#define _PAGING_H

#include "types.h"

/*enable paging*/
void enable_paging();
/*page directory entry*/
struct pde
{
	uint32_t present   : 1; 
	uint32_t read_write : 1;
	uint32_t user_priv : 1;
	uint32_t unused : 9;
	uint32_t address : 20;
} __attribute__((packed));
typedef struct pde pde_t;
/*page table entry*/
struct pte
{
	uint32_t present : 1;
	uint32_t read_write : 1;
	uint32_t user_priv : 1;
	uint32_t unused : 9;
	uint32_t address : 20;
} __attribute__((packed));
typedef struct pte pte_t;
/*page table*/
struct page_table
{
	pte_t page[1024]; 
} __attribute__((packed, aligned(4096)));
typedef struct page_table page_table_t;
/*page directory*/
struct page_dir
{
	pde_t page_table[1024];
} __attribute__((packed, aligned(4096)));
typedef struct page_dir page_dir_t;



extern void init_paging(void* directory);
extern void context_switch(uint32_t entry, uint32_t esp);
#endif // _PAGING_H
