feat: initial locking etc.
This commit is contained in:
58
kernel/mem/paging.c
Normal file
58
kernel/mem/paging.c
Normal 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;
|
||||
}
|
||||
}
|
||||
8
kernel/mem/paging.h
Normal file
8
kernel/mem/paging.h
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by rick on 21-02-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_PAGING_H
|
||||
#define NEW_KERNEL_PAGING_H
|
||||
|
||||
#endif //NEW_KERNEL_PAGING_H
|
||||
Reference in New Issue
Block a user