HhhOS/include/paging.h
2021-08-17 12:45:35 +03:00

37 lines
806 B
C

#pragma once
#include <types.h>
#define PAGE_PRESENT 1 << 0
#define PAGE_WRITABLE 1 << 1
#define PAGE_USER 1 << 2
#define PAGE_WRITE_THROUGH 1 << 3
#define PAGE_CACHE_DISABLE 1 << 4
#define PAGE_ACCESSED 1 << 5
#define PAGE_DIRTY 1 << 6
#define PAGE_GLOBAL 1 << 8
#define PAGE_NO_EXECUTE 1 << 63
#define PAGE_ADDRESS_MASK 0x000FFFFFFFFFF000
typedef struct {
u16 page_offset : 12;
u16 pt_offset : 9;
u16 pd_offset : 9;
u16 pdp_offset : 9;
u16 pml4_offset : 9;
u16 sign_extend : 16;
} __attribute__((packed)) parsed_address_t;
typedef union {
u64 int_address;
parsed_address_t parsed_address;
} address_t;
static u64 PML4[512] __attribute__((aligned(4096)));
static bitmap_t *page_bitmap;
void setup_paging(u64 total_memory);
void map_page(u64 physical, u64 virtual);