feat: initial locking etc.

This commit is contained in:
2021-03-01 21:07:53 +01:00
parent ebe006a8ba
commit 990b850c43
14 changed files with 427 additions and 14 deletions

58
kernel/mem/paging.c Normal file
View File

@@ -0,0 +1,58 @@
//
// 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;
}
}