2021-05-10 20:32:28 +00:00
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
2022-02-26 19:44:16 +00:00
|
|
|
#include "./memory.h"
|
2023-02-03 20:47:05 +00:00
|
|
|
#include "./../terminal/kterm.h"
|
2022-02-26 19:44:16 +00:00
|
|
|
#define KB 1024
|
2021-11-02 20:03:11 +00:00
|
|
|
|
|
|
|
|
2022-02-26 19:44:16 +00:00
|
|
|
typedef uintptr_t address_t;
|
2021-11-02 20:03:11 +00:00
|
|
|
|
|
|
|
static const int MAX_PAGES = 1024 * KB; // 4GB , 4kB/page
|
|
|
|
static volatile address_t pmem_stack[MAX_PAGES];
|
|
|
|
static volatile address_t pmem_stack_top = MAX_PAGES; // top down allocation
|
|
|
|
|
2022-02-26 19:44:16 +00:00
|
|
|
extern "C" void loadPageDirectory (uint32_t* addr );
|
|
|
|
extern "C" void enablePaging();
|
2021-11-02 20:03:11 +00:00
|
|
|
|
|
|
|
struct page_directory_entry {};
|
|
|
|
struct page_table_entry{};
|
|
|
|
|
|
|
|
|
2021-05-10 20:32:28 +00:00
|
|
|
|
2021-11-02 20:15:00 +00:00
|
|
|
class PageDirectory {
|
2021-05-10 20:32:28 +00:00
|
|
|
public:
|
|
|
|
void enable ();
|
2022-02-26 19:44:16 +00:00
|
|
|
void MapPhysicalToVirtualAddress ( address_t PAddress , address_t VAddress, uint32_t size );
|
|
|
|
|
2021-05-10 20:32:28 +00:00
|
|
|
private:
|
2022-02-26 19:44:16 +00:00
|
|
|
uint32_t page_directory[1024] __attribute__((aligned(4096))); // align on 4 kiloByte pages
|
|
|
|
uint32_t first_page_table[1024] __attribute__((aligned(4096))); // align on 4 kiloByte pages
|
|
|
|
|
2021-05-10 20:32:28 +00:00
|
|
|
};
|