wip: change the way memory is handled
This commit is contained in:
		@ -4,40 +4,16 @@
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
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 = &boot_page_table1;
 | 
			
		||||
 | 
			
		||||
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");
 | 
			
		||||
}
 | 
			
		||||
uint32_t page_table1[1024] __attribute__((aligned(4096)));
 | 
			
		||||
uint32_t page_table_entries[1024] __attribute__((aligned(4096)));
 | 
			
		||||
 | 
			
		||||
void init_memory(void)
 | 
			
		||||
{
 | 
			
		||||
	//for (int i = 0x00; i < 0x300; i++)
 | 
			
		||||
	//	page_table_entries[i] = (i << 12) | INIT_FLAGS;
 | 
			
		||||
	//page_directory[1] = (uint32_t)page_table_entries | INIT_FLAGS;
 | 
			
		||||
}
 | 
			
		||||
	for (int16_t i = 0; i < 0x300; i++)
 | 
			
		||||
		page_directory[i] = 0x02;
 | 
			
		||||
	for (int16_t i = 0; i < 1024; i++)
 | 
			
		||||
		page_table1[i] = i << 12 | 0x03;
 | 
			
		||||
	page_directory[0] = (uint32_t)page_table1 | 0x03;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user