#include "memory.h" #include "kprintf.h" #include "string.h" #include extern void enable_paging(void); extern void load_page_directory(uint32_t *); extern uint32_t boot_page_table1; extern uint32_t boot_page_directory; // Pour récupérer une entrée spécifique uint32_t *page_directory = &boot_page_directory; uint32_t page_table_entries[1024] __attribute__((aligned(4096))); unsigned long read_cr3() { unsigned long cr3_value; // Inline assembly to read CR3 __asm__ volatile( "mov %%cr3, %0" // Move the value of CR3 into cr3_value : "=r"( cr3_value) // Output operand: cr3_value will receive the value : // No input operands : // No clobber list ); return cr3_value; } static inline void load_cr3(uint64_t cr3_value) { asm volatile("mov %0, %%cr3" ::"r"(cr3_value) : "memory"); } void init_memory(void) { for (int i = 0; i < 1024; i++) page_table_entries[i] = (i << 12) | INIT_FLAGS; page_directory[1] = (uint32_t)page_table_entries | INIT_FLAGS; }