Files
bsb2/kernel/memory/pagetable.h
2026-01-19 19:38:45 +01:00

57 lines
1.3 KiB
C

#ifndef _PAGETABLE_H_
#define _PAGETABLE_H_
#include "../types.h"
typedef struct {
uint8_t present:1 = 0;
uint8_t write:1 = 0;
uint8_t user:1 = 0;
uint8_t pwt:1 = 0;
uint8_t cache_disable:1 = 0;
uint8_t accessed:1 = 0;
uint8_t dirty:1 = 0;
uint8_t pat:1 = 0;
uint8_t rsvd_0:4 = 0;
uint64_t address:39 = 0;
uint16_t rsvd_1:10 = 0;
uint8_t execute_disable:1 = 0;
} __attribute__((__packed__)) pagetable_entry_t;
typedef struct {
pagetable_entry_t entries[512];
} pagetable_t;
typedef struct {
uint8_t present:1 = 0;
uint8_t write:1 = 0;
uint8_t user:1 = 0;
uint8_t pwt:1 = 0;
uint8_t cache_disable:1 = 0;
uint8_t accessed:1 = 0;
uint8_t rsvd_0:6 = 0;
uint64_t address:39 = 0;
uint16_t rsvd_1:10 = 0;
uint8_t execute_disable:1 = 0;
} __attribute__((__packed__)) pagedirectory_entry_t;
typedef struct {
alignas(4096) pagedirectory_entry_t l4;
alignas(4096) pagedirectory_entry_t l3;
alignas(4096) pagedirectory_entry_t l2[32];
alignas(4096) pagetable_t l1[32];
} four_lvl_paging_t;
void create_basic_page_table(uintptr_t base);
void load_cr3( void* cr3_value );
//typedef struct {
// same
//} pagedirectory_pointertable_entry_t;
//typedef struct {
// same
//} PML4_entry_t;
#endif