58 lines
1.4 KiB
C
58 lines
1.4 KiB
C
//
|
|
// Created by rick on 21-02-21.
|
|
//
|
|
|
|
#include "paging.h"
|
|
#include <types.h>
|
|
#include <stdbool.h>
|
|
#include <attributes.h>
|
|
|
|
#define TABLE_ADDR_MASK 0xFFFFF000
|
|
#define DIRECTORY_SIZE 1024
|
|
|
|
const uint32_t x = TABLE_ADDR_MASK;
|
|
typedef struct {
|
|
union {
|
|
struct {
|
|
bool present: 1;
|
|
bool read_write: 1;
|
|
bool user_mode: 1;
|
|
bool write_through: 1;
|
|
bool cache_disabled: 1;
|
|
bool accessed: 1;
|
|
char ignored: 1;
|
|
bool page_size: 1;
|
|
bool global: 1; // ignored
|
|
uint8_t avail: 3;
|
|
} packed;
|
|
uint32_t addr;
|
|
};
|
|
} packed page_directory_entry;
|
|
|
|
typedef struct {
|
|
union {
|
|
struct {
|
|
bool present: 1;
|
|
bool read_write: 1;
|
|
bool user_supervisor: 1;
|
|
bool write_through: 1;
|
|
bool cache_disabled: 1;
|
|
bool accessed: 1;
|
|
bool dirty: 1;
|
|
char ignored: 1;
|
|
bool global: 1;
|
|
uint8_t available: 3;
|
|
} packed;
|
|
uint32_t addr;
|
|
};
|
|
} packed page_table_entry;
|
|
|
|
page_directory_entry page_directory[DIRECTORY_SIZE] at_aligned(4096);
|
|
|
|
void page_pre_init() {
|
|
for (int i = 0; i < DIRECTORY_SIZE; ++i) {
|
|
page_directory[i].read_write = true;
|
|
page_directory[i].user_mode = false;
|
|
page_directory[i].present = false;
|
|
}
|
|
} |